1 // created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de
6 // Author - Piers Haken <piersh@friskit.com>
9 // TODO: FUNCTION_CALL should be a QName, not just a NCName
10 // TODO: PROCESSING_INSTRUCTION's optional parameter
11 // TODO: flatten argument/predicate lists in place
14 using System.Xml.XPath;
17 namespace Mono.Xml.XPath
19 public class XPathParser
21 internal object yyparseSafe (Tokenizer tok)
23 return yyparseSafe (tok, null);
26 internal object yyparseSafe (Tokenizer tok, object yyDebug)
30 return yyparse (tok, yyDebug);
32 catch (XPathException e)
38 throw new XPathException ("Error during parse", e);
42 internal object yyparseDebug (Tokenizer tok)
44 return yyparseSafe (tok, new yydebug.yyDebugSimple ());
49 /** simplified error message.
50 @see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a>
52 public void yyerror (string message) {
53 yyerror(message, null);
56 /** (syntax) error message.
57 Can be overwritten to control message format.
58 @param message text to be displayed.
59 @param expected vector of acceptable tokens, if available.
61 public void yyerror (string message, string[] expected) {
62 if ((expected != null) && (expected.Length > 0)) {
63 System.Console.Write (message+", expecting");
64 for (int n = 0; n < expected.Length; ++ n)
65 System.Console.Write (" "+expected[n]);
66 System.Console.WriteLine ();
68 System.Console.WriteLine (message);
71 /** debugging support, requires the package jay.yydebug.
72 Set to null to suppress debugging messages.
74 protected yydebug.yyDebug debug;
76 protected static int yyFinal = 25;
77 public static string [] yyRule = {
81 "OrExpr : OrExpr OR AndExpr",
82 "AndExpr : EqualityExpr",
83 "AndExpr : AndExpr AND EqualityExpr",
84 "EqualityExpr : RelationalExpr",
85 "EqualityExpr : EqualityExpr EQ RelationalExpr",
86 "EqualityExpr : EqualityExpr NE RelationalExpr",
87 "RelationalExpr : AdditiveExpr",
88 "RelationalExpr : RelationalExpr LT AdditiveExpr",
89 "RelationalExpr : RelationalExpr GT AdditiveExpr",
90 "RelationalExpr : RelationalExpr LE AdditiveExpr",
91 "RelationalExpr : RelationalExpr GE AdditiveExpr",
92 "AdditiveExpr : MultiplicativeExpr",
93 "AdditiveExpr : AdditiveExpr PLUS MultiplicativeExpr",
94 "AdditiveExpr : AdditiveExpr MINUS MultiplicativeExpr",
95 "MultiplicativeExpr : UnaryExpr",
96 "MultiplicativeExpr : MultiplicativeExpr ASTERISK UnaryExpr",
97 "MultiplicativeExpr : MultiplicativeExpr DIV UnaryExpr",
98 "MultiplicativeExpr : MultiplicativeExpr MOD UnaryExpr",
99 "UnaryExpr : UnionExpr",
100 "UnaryExpr : MINUS UnaryExpr",
101 "UnionExpr : PathExpr",
102 "UnionExpr : UnionExpr BAR PathExpr",
103 "PathExpr : RelativeLocationPath",
105 "PathExpr : SLASH RelativeLocationPath",
106 "PathExpr : SLASH2 RelativeLocationPath",
107 "PathExpr : FilterExpr",
108 "PathExpr : FilterExpr SLASH RelativeLocationPath",
109 "PathExpr : FilterExpr SLASH2 RelativeLocationPath",
110 "RelativeLocationPath : Step",
111 "RelativeLocationPath : RelativeLocationPath SLASH Step",
112 "RelativeLocationPath : RelativeLocationPath SLASH2 Step",
113 "Step : AxisSpecifier QName ZeroOrMorePredicates",
114 "Step : AxisSpecifier ASTERISK ZeroOrMorePredicates",
115 "Step : AxisSpecifier NodeType PAREN_OPEN OptionalLiteral PAREN_CLOSE ZeroOrMorePredicates",
119 "AxisSpecifier : AT",
120 "AxisSpecifier : AxisName COLON2",
121 "NodeType : COMMENT",
123 "NodeType : PROCESSING_INSTRUCTION",
125 "FilterExpr : PrimaryExpr",
126 "FilterExpr : FilterExpr Predicate",
127 "PrimaryExpr : DOLLAR QName",
128 "PrimaryExpr : PAREN_OPEN Expr PAREN_CLOSE",
129 "PrimaryExpr : LITERAL",
130 "PrimaryExpr : NUMBER",
131 "PrimaryExpr : FunctionCall",
132 "FunctionCall : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE",
133 "OptionalArgumentList :",
134 "OptionalArgumentList : Expr OptionalArgumentListTail",
135 "OptionalArgumentListTail :",
136 "OptionalArgumentListTail : COMMA Expr OptionalArgumentListTail",
137 "ZeroOrMorePredicates :",
138 "ZeroOrMorePredicates : Predicate ZeroOrMorePredicates",
139 "Predicate : BRACKET_OPEN Expr BRACKET_CLOSE",
140 "AxisName : ANCESTOR",
141 "AxisName : ANCESTOR_OR_SELF",
142 "AxisName : ATTRIBUTE",
144 "AxisName : DESCENDANT",
145 "AxisName : DESCENDANT_OR_SELF",
146 "AxisName : FOLLOWING",
147 "AxisName : FOLLOWING_SIBLING",
148 "AxisName : NAMESPACE",
150 "AxisName : PRECEDING",
151 "AxisName : PRECEDING_SIBLING",
154 "OptionalLiteral : LITERAL",
156 "QName : NCName COLON ASTERISK",
157 "QName : NCName COLON NCName",
159 protected static string [] yyName = {
160 "end-of-file",null,null,null,null,null,null,null,null,null,null,null,
161 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
162 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
163 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
164 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
165 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
166 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
167 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
168 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
169 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
170 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
171 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
172 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
173 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
174 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
175 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
176 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
177 null,null,null,null,null,null,null,null,null,null,null,null,null,null,
178 null,null,null,null,null,null,null,"ERROR","EOF","SLASH","SLASH2",
179 "DOT","DOT2","COLON","COLON2","COMMA","AT","FUNCTION_NAME",
180 "BRACKET_OPEN","BRACKET_CLOSE","PAREN_OPEN","PAREN_CLOSE","AND","OR",
181 "DIV","MOD","PLUS","MINUS","ASTERISK","DOLLAR","BAR","EQ","NE","LE",
182 "GE","LT","GT","ANCESTOR","ANCESTOR_OR_SELF","ATTRIBUTE","CHILD",
183 "DESCENDANT","DESCENDANT_OR_SELF","FOLLOWING","FOLLOWING_SIBLING",
184 "NAMESPACE","PARENT","PRECEDING","PRECEDING_SIBLING","SELF","COMMENT",
185 "TEXT","PROCESSING_INSTRUCTION","NODE","NUMBER","LITERAL","NCName",
188 /** index-checked interface to yyName[].
189 @param token single character or %token value.
190 @return token name or [illegal] or [unknown].
192 public static string yyname (int token) {
193 if ((token < 0) || (token > yyName.Length)) return "[illegal]";
195 if ((name = yyName[token]) != null) return name;
199 /** computes list of expected tokens on error by tracing the tables.
200 @param state for which to compute the list.
201 @return list of token names.
203 protected string[] yyExpecting (int state) {
204 int token, n, len = 0;
205 bool[] ok = new bool[yyName.Length];
207 if ((n = yySindex[state]) != 0)
208 for (token = n < 0 ? -n : 0;
209 (token < yyName.Length) && (n+token < yyTable.Length); ++ token)
210 if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) {
214 if ((n = yyRindex[state]) != 0)
215 for (token = n < 0 ? -n : 0;
216 (token < yyName.Length) && (n+token < yyTable.Length); ++ token)
217 if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) {
222 string [] result = new string[len];
223 for (n = token = 0; n < len; ++ token)
224 if (ok[token]) result[n++] = yyName[token];
228 /** the generated parser, with debugging messages.
229 Maintains a state and a value stack, currently with fixed maximum size.
230 @param yyLex scanner.
231 @param yydebug debug message writer implementing yyDebug, or null.
232 @return result of the last reduction, if any.
233 @throws yyException on irrecoverable parse error.
235 public Object yyparse (yyParser.yyInput yyLex, Object yyd)
237 this.debug = (yydebug.yyDebug)yyd;
238 return yyparse(yyLex);
241 /** initial size and increment of the state/value stack [default 256].
242 This is not final so that it can be overwritten outside of invocations
247 /** executed at the beginning of a reduce action.
248 Used as $$ = yyDefault($1), prior to the user-specified action, if any.
249 Can be overwritten to provide deep copy, etc.
250 @param first value for $1, or null.
253 protected Object yyDefault (Object first) {
257 /** the generated parser.
258 Maintains a state and a value stack, currently with fixed maximum size.
259 @param yyLex scanner.
260 @return result of the last reduction, if any.
261 @throws yyException on irrecoverable parse error.
263 public Object yyparse (yyParser.yyInput yyLex)
265 if (yyMax <= 0) yyMax = 256; // initial size
266 int yyState = 0; // state stack ptr
267 int [] yyStates = new int[yyMax]; // state stack
268 Object yyVal = null; // value stack ptr
269 Object [] yyVals = new Object[yyMax]; // value stack
270 int yyToken = -1; // current input
271 int yyErrorFlag = 0; // #tks to shift
279 if (yyTop >= yyStates.Length) { // dynamically increase
280 int[] i = new int[yyStates.Length+yyMax];
281 yyStates.CopyTo (i, 0);
283 Object[] o = new Object[yyVals.Length+yyMax];
284 yyVals.CopyTo (o, 0);
287 yyStates[yyTop] = yyState;
288 yyVals[yyTop] = yyVal;
289 if (debug != null) debug.push(yyState, yyVal);
291 yyDiscarded: for (;;) { // discarding a token does not change stack
293 if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
295 yyToken = yyLex.advance() ? yyLex.token() : 0;
297 debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value());
299 if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0)
300 && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) {
302 debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
303 yyState = yyTable[yyN]; // shift to yyN
304 yyVal = yyLex.value();
306 if (yyErrorFlag > 0) -- yyErrorFlag;
309 if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
310 && yyN < yyTable.Length && yyCheck[yyN] == yyToken)
311 yyN = yyTable[yyN]; // reduce (yyN)
313 switch (yyErrorFlag) {
316 yyerror("syntax error", yyExpecting(yyState));
317 if (debug != null) debug.error("syntax error");
322 if ((yyN = yySindex[yyStates[yyTop]]) != 0
323 && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length
324 && yyCheck[yyN] == Token.yyErrorCode) {
326 debug.shift(yyStates[yyTop], yyTable[yyN], 3);
327 yyState = yyTable[yyN];
328 yyVal = yyLex.value();
331 if (debug != null) debug.pop(yyStates[yyTop]);
332 } while (-- yyTop >= 0);
333 if (debug != null) debug.reject();
334 throw new yyParser.yyException("irrecoverable syntax error");
338 if (debug != null) debug.reject();
339 throw new yyParser.yyException("irrecoverable syntax error at end-of-file");
342 debug.discard(yyState, yyToken, yyname(yyToken),
345 goto yyDiscarded; // leave stack alone
348 int yyV = yyTop + 1-yyLen[yyN];
350 debug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]);
351 yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
354 // line 133 "Parser.jay"
356 yyVal = new ExprOR ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
360 // line 141 "Parser.jay"
362 yyVal = new ExprAND ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
366 // line 149 "Parser.jay"
368 yyVal = new ExprEQ ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
372 // line 153 "Parser.jay"
374 yyVal = new ExprNE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
378 // line 161 "Parser.jay"
380 yyVal = new ExprLT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
384 // line 165 "Parser.jay"
386 yyVal = new ExprGT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
390 // line 169 "Parser.jay"
392 yyVal = new ExprLE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
396 // line 173 "Parser.jay"
398 yyVal = new ExprGE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
402 // line 181 "Parser.jay"
404 yyVal = new ExprPLUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
408 // line 185 "Parser.jay"
410 yyVal = new ExprMINUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
414 // line 193 "Parser.jay"
416 yyVal = new ExprMULT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
420 // line 197 "Parser.jay"
422 yyVal = new ExprDIV ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
426 // line 201 "Parser.jay"
428 yyVal = new ExprMOD ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
432 // line 209 "Parser.jay"
434 yyVal = new ExprNEG ((Expression) yyVals[0+yyTop]);
438 // line 217 "Parser.jay"
440 yyVal = new ExprUNION ((NodeSet) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
444 // line 225 "Parser.jay"
446 yyVal = new ExprRoot ();
450 // line 229 "Parser.jay"
452 yyVal = new ExprSLASH (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
456 // line 233 "Parser.jay"
458 ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
459 yyVal = new ExprSLASH (new ExprSLASH (new ExprRoot (), exprStep), (NodeSet) yyVals[0+yyTop]);
463 // line 239 "Parser.jay"
465 yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
469 // line 243 "Parser.jay"
471 ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
472 yyVal = new ExprSLASH (new ExprSLASH ((Expression) yyVals[-2+yyTop], exprStep), (NodeSet) yyVals[0+yyTop]);
476 // line 252 "Parser.jay"
478 yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
482 // line 256 "Parser.jay"
484 ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
485 yyVal = new ExprSLASH (new ExprSLASH ((Expression) yyVals[-2+yyTop], exprStep), (NodeSet) yyVals[0+yyTop]);
489 // line 264 "Parser.jay"
491 yyVal = new ExprStep (new NodeNameTest ((Axes) yyVals[-2+yyTop], (QName) yyVals[-1+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
495 // line 268 "Parser.jay"
497 yyVal = new ExprStep (new NodeTypeTest ((Axes) yyVals[-2+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
501 // line 272 "Parser.jay"
503 yyVal = new ExprStep (new NodeTypeTest ((Axes) yyVals[-5+yyTop], (XPathNodeType) yyVals[-4+yyTop], (String) yyVals[-2+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
507 // line 276 "Parser.jay"
509 yyVal = new ExprStep (new NodeTypeTest (Axes.Self, XPathNodeType.All));
513 // line 280 "Parser.jay"
515 yyVal = new ExprStep (new NodeTypeTest (Axes.Parent, XPathNodeType.All));
519 // line 287 "Parser.jay"
525 // line 291 "Parser.jay"
527 yyVal = Axes.Attribute;
531 // line 295 "Parser.jay"
533 yyVal = yyVals[-1+yyTop];
537 // line 301 "Parser.jay"
538 { yyVal = XPathNodeType.Comment; }
541 // line 302 "Parser.jay"
542 { yyVal = XPathNodeType.Text; }
545 // line 303 "Parser.jay"
546 { yyVal = XPathNodeType.ProcessingInstruction; }
549 // line 304 "Parser.jay"
550 { yyVal = XPathNodeType.All; }
553 // line 311 "Parser.jay"
555 yyVal = new ExprFilter ((Expression) yyVals[-1+yyTop], (Expression) yyVals[0+yyTop]);
559 // line 318 "Parser.jay"
561 yyVal = new ExprVariable ((QName) yyVals[0+yyTop]);
565 // line 322 "Parser.jay"
567 yyVal = yyVals[-1+yyTop];
571 // line 326 "Parser.jay"
573 yyVal = new ExprLiteral ((String) yyVals[0+yyTop]);
577 // line 330 "Parser.jay"
579 yyVal = new ExprNumber ((double) yyVals[0+yyTop]);
583 // line 338 "Parser.jay"
585 yyVal = new ExprFunctionCall ((String) yyVals[-3+yyTop], (FunctionArguments) yyVals[-1+yyTop]);
589 // line 346 "Parser.jay"
591 yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
595 // line 354 "Parser.jay"
597 yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
601 // line 363 "Parser.jay"
603 yyVal = new ExprPredicates ((Expression) yyVals[-1+yyTop], (ExprPredicates) yyVals[0+yyTop]);
607 // line 370 "Parser.jay"
609 yyVal = yyVals[-1+yyTop];
613 // line 376 "Parser.jay"
614 { yyVal = Axes.Ancestor; }
617 // line 377 "Parser.jay"
618 { yyVal = Axes.AncestorOrSelf; }
621 // line 378 "Parser.jay"
622 { yyVal = Axes.Attribute; }
625 // line 379 "Parser.jay"
626 { yyVal = Axes.Child; }
629 // line 380 "Parser.jay"
630 { yyVal = Axes.Descendant; }
633 // line 381 "Parser.jay"
634 { yyVal = Axes.DescendantOrSelf; }
637 // line 382 "Parser.jay"
638 { yyVal = Axes.Following; }
641 // line 383 "Parser.jay"
642 { yyVal = Axes.FollowingSibling; }
645 // line 384 "Parser.jay"
646 { yyVal = Axes.Namespace; }
649 // line 385 "Parser.jay"
650 { yyVal = Axes.Parent; }
653 // line 386 "Parser.jay"
654 { yyVal = Axes.Preceding; }
657 // line 387 "Parser.jay"
658 { yyVal = Axes.PrecedingSibling; }
661 // line 388 "Parser.jay"
662 { yyVal = Axes.Self; }
665 // line 398 "Parser.jay"
667 yyVal = new NCName ((String) yyVals[0+yyTop]);
671 // line 402 "Parser.jay"
673 yyVal = new QName ((String) yyVals[-2+yyTop], null);
677 // line 406 "Parser.jay"
679 yyVal = new QName ((String) yyVals[-2+yyTop], (String) yyVals[0+yyTop]);
685 yyState = yyStates[yyTop];
686 int yyM = yyLhs[yyN];
687 if (yyState == 0 && yyM == 0) {
688 if (debug != null) debug.shift(0, yyFinal);
691 yyToken = yyLex.advance() ? yyLex.token() : 0;
693 debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
696 if (debug != null) debug.accept(yyVal);
701 if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
702 && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
703 yyState = yyTable[yyN];
705 yyState = yyDgoto[yyM];
706 if (debug != null) debug.shift(yyStates[yyTop], yyState);
712 static short [] yyLhs = { -1,
713 0, 1, 1, 2, 2, 3, 3, 3, 4, 4,
714 4, 4, 4, 5, 5, 5, 6, 6, 6, 6,
715 7, 7, 8, 8, 9, 9, 9, 9, 9, 9,
716 9, 10, 10, 10, 12, 12, 12, 12, 12, 13,
717 13, 13, 16, 16, 16, 16, 11, 11, 19, 19,
718 19, 19, 19, 21, 22, 22, 23, 23, 15, 15,
719 20, 18, 18, 18, 18, 18, 18, 18, 18, 18,
720 18, 18, 18, 18, 17, 17, 14, 14, 14,
722 static short [] yyLen = { 2,
723 1, 1, 3, 1, 3, 1, 3, 3, 1, 3,
724 3, 3, 3, 1, 3, 3, 1, 3, 3, 3,
725 1, 2, 1, 3, 1, 1, 2, 2, 1, 3,
726 3, 1, 3, 3, 3, 3, 6, 1, 1, 0,
727 1, 2, 1, 1, 1, 1, 1, 2, 2, 3,
728 1, 1, 1, 4, 0, 2, 0, 3, 0, 2,
729 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
730 1, 1, 1, 1, 0, 1, 1, 3, 3,
732 static short [] yyDefRed = { 0,
733 0, 0, 38, 39, 41, 0, 0, 0, 0, 62,
734 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
735 73, 74, 52, 51, 0, 0, 0, 0, 0, 0,
736 0, 17, 0, 23, 0, 0, 32, 0, 0, 47,
737 53, 0, 0, 0, 0, 22, 0, 49, 0, 0,
738 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
739 0, 0, 0, 0, 0, 0, 0, 48, 0, 43,
740 44, 45, 46, 0, 0, 42, 0, 0, 50, 0,
741 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
742 19, 20, 18, 24, 33, 34, 0, 0, 0, 36,
743 0, 35, 0, 0, 56, 54, 78, 79, 61, 60,
746 protected static short [] yyDgoto = { 25,
747 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
748 36, 37, 38, 48, 100, 75, 112, 39, 40, 101,
751 protected static short [] yySindex = { -188,
752 -85, -85, 0, 0, 0, -258, -188, -188, -297, 0,
753 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
754 0, 0, 0, 0, 0, -215, -257, -253, -265, -245,
755 -261, 0, -221, 0, -218, -252, 0, -256, -203, 0,
756 0, -218, -218, -188, -209, 0, -200, 0, -188, -188,
757 -188, -188, -188, -188, -188, -188, -188, -188, -188, -188,
758 -188, -130, -85, -85, -85, -85, -188, 0, -204, 0,
759 0, 0, 0, -204, -195, 0, -199, -194, 0, -268,
760 -257, -253, -265, -265, -245, -245, -245, -245, -261, -261,
761 0, 0, 0, 0, 0, 0, -218, -218, -202, 0,
762 -204, 0, -229, -188, 0, 0, 0, 0, 0, 0,
763 0, -191, -199, -204, 0, 0,
765 protected static short [] yyRindex = { -182,
766 1, -182, 0, 0, 0, 0, -182, -182, 0, 0,
767 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
768 0, 0, 0, 0, 0, 253, 65, 23, 435, 319,
769 244, 0, 222, 0, 90, 112, 0, 0, 0, 0,
770 0, 134, 156, -267, 0, 0, 40, 0, -182, -182,
771 -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
772 -182, -182, -182, -182, -182, -182, -182, 0, 68, 0,
773 0, 0, 0, 68, 0, 0, -190, 0, 0, 0,
774 510, 501, 457, 479, 347, 369, 391, 413, 267, 289,
775 0, 0, 0, 0, 0, 0, 178, 200, 0, 0,
776 68, 0, -187, -182, 0, 0, 0, 0, 0, 0,
777 0, 0, -190, 68, 0, 0,
779 protected static short [] yyGindex = { -7,
780 0, 34, 35, -3, -29, -1, -6, 0, 24, 4,
781 0, -12, 0, 49, -71, 0, 0, 0, 0, 52,
784 protected static short [] yyTable = { 45,
785 26, 46, 102, 55, 42, 43, 65, 66, 47, 107,
786 40, 44, 59, 60, 50, 67, 61, 53, 54, 55,
787 56, 69, 4, 85, 86, 87, 88, 51, 52, 110,
788 57, 58, 40, 40, 40, 40, 77, 108, 40, 77,
789 63, 64, 116, 70, 71, 72, 73, 83, 84, 47,
790 95, 96, 91, 92, 93, 89, 90, 49, 62, 99,
791 76, 79, 80, 67, 2, 104, 109, 59, 97, 98,
792 1, 2, 3, 4, 103, 111, 106, 5, 6, 114,
793 57, 7, 81, 75, 82, 94, 74, 68, 8, 25,
794 9, 115, 0, 0, 0, 40, 113, 0, 10, 11,
795 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
796 22, 29, 0, 0, 0, 23, 24, 40, 40, 40,
797 40, 0, 0, 40, 0, 0, 0, 0, 1, 2,
798 3, 4, 0, 27, 0, 5, 6, 0, 0, 7,
799 0, 0, 0, 0, 0, 0, 0, 0, 9, 0,
800 0, 0, 0, 0, 0, 28, 10, 11, 12, 13,
801 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
802 0, 0, 0, 23, 24, 3, 4, 30, 0, 0,
803 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
804 0, 0, 0, 0, 0, 0, 0, 0, 0, 31,
805 0, 10, 11, 12, 13, 14, 15, 16, 17, 18,
806 19, 20, 21, 22, 0, 0, 0, 0, 0, 0,
807 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
808 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
809 0, 0, 0, 14, 0, 0, 0, 0, 0, 0,
810 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
811 0, 0, 0, 0, 0, 26, 15, 0, 0, 26,
812 0, 26, 26, 26, 26, 26, 26, 26, 26, 0,
813 26, 26, 26, 26, 26, 26, 26, 4, 16, 0,
814 0, 4, 0, 4, 4, 4, 0, 0, 77, 77,
815 40, 40, 40, 40, 77, 0, 40, 77, 77, 0,
816 77, 77, 77, 77, 77, 77, 77, 77, 9, 77,
817 77, 77, 77, 77, 77, 77, 59, 59, 0, 2,
818 0, 0, 59, 2, 0, 2, 59, 2, 59, 59,
819 59, 59, 59, 59, 59, 59, 12, 59, 59, 59,
820 59, 59, 59, 59, 25, 0, 0, 0, 25, 0,
821 25, 25, 25, 25, 25, 25, 25, 25, 13, 25,
822 25, 25, 25, 25, 25, 25, 29, 0, 0, 0,
823 29, 0, 29, 29, 29, 29, 29, 29, 29, 29,
824 10, 29, 29, 29, 29, 29, 29, 29, 27, 0,
825 0, 0, 27, 0, 27, 27, 27, 27, 27, 27,
826 27, 27, 11, 27, 27, 27, 27, 27, 27, 27,
827 28, 0, 0, 0, 28, 0, 28, 28, 28, 28,
828 28, 28, 28, 28, 6, 28, 28, 28, 28, 28,
829 28, 28, 30, 0, 0, 0, 30, 0, 30, 30,
830 30, 30, 30, 30, 30, 30, 7, 30, 30, 30,
831 30, 30, 30, 30, 31, 0, 0, 0, 31, 0,
832 31, 31, 31, 31, 31, 31, 31, 31, 8, 31,
833 31, 31, 31, 31, 31, 31, 21, 0, 0, 0,
834 21, 0, 21, 21, 21, 21, 21, 21, 21, 21,
835 5, 0, 21, 21, 21, 21, 21, 21, 14, 3,
836 0, 0, 14, 0, 14, 14, 14, 1, 0, 14,
837 14, 1, 0, 1, 14, 14, 14, 14, 14, 14,
838 0, 15, 0, 0, 0, 15, 0, 15, 15, 15,
839 0, 0, 15, 15, 0, 0, 0, 15, 15, 15,
840 15, 15, 15, 16, 0, 0, 0, 16, 0, 16,
841 16, 16, 0, 0, 16, 16, 0, 0, 0, 16,
842 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
843 0, 0, 0, 9, 0, 0, 0, 9, 0, 9,
844 9, 9, 0, 0, 0, 0, 0, 0, 0, 9,
845 9, 9, 9, 9, 9, 0, 0, 0, 0, 0,
846 0, 12, 0, 0, 0, 12, 0, 12, 12, 12,
847 0, 0, 0, 0, 0, 0, 0, 12, 12, 12,
848 12, 12, 12, 13, 0, 0, 0, 13, 0, 13,
849 13, 13, 0, 0, 0, 0, 0, 0, 0, 13,
850 13, 13, 13, 13, 13, 10, 0, 0, 0, 10,
851 0, 10, 10, 10, 0, 0, 0, 0, 0, 0,
852 0, 10, 10, 10, 10, 10, 10, 11, 0, 0,
853 0, 11, 0, 11, 11, 11, 0, 0, 0, 0,
854 0, 0, 0, 11, 11, 11, 11, 11, 11, 6,
855 0, 0, 0, 6, 0, 6, 6, 6, 0, 0,
856 0, 0, 0, 0, 0, 6, 6, 0, 0, 0,
857 0, 7, 0, 0, 0, 7, 0, 7, 7, 7,
858 0, 0, 0, 0, 0, 0, 0, 7, 7, 0,
859 0, 0, 0, 8, 0, 0, 0, 8, 0, 8,
860 8, 8, 0, 0, 0, 0, 0, 0, 0, 8,
861 8, 0, 0, 0, 0, 5, 0, 0, 0, 5,
862 0, 5, 5, 5, 3, 0, 0, 0, 3, 0,
865 protected static short [] yyCheck = { 7,
866 0, 8, 74, 271, 1, 2, 259, 260, 306, 278,
867 278, 270, 274, 275, 272, 268, 278, 283, 284, 285,
868 286, 278, 0, 53, 54, 55, 56, 281, 282, 101,
869 276, 277, 300, 301, 302, 303, 44, 306, 306, 0,
870 259, 260, 114, 300, 301, 302, 303, 51, 52, 306,
871 63, 64, 59, 60, 61, 57, 58, 273, 280, 67,
872 264, 271, 263, 268, 0, 265, 269, 0, 65, 66,
873 259, 260, 261, 262, 270, 305, 271, 266, 267, 271,
874 271, 270, 49, 271, 50, 62, 38, 36, 277, 0,
875 279, 113, -1, -1, -1, 278, 104, -1, 287, 288,
876 289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
877 299, 0, -1, -1, -1, 304, 305, 300, 301, 302,
878 303, -1, -1, 306, -1, -1, -1, -1, 259, 260,
879 261, 262, -1, 0, -1, 266, 267, -1, -1, 270,
880 -1, -1, -1, -1, -1, -1, -1, -1, 279, -1,
881 -1, -1, -1, -1, -1, 0, 287, 288, 289, 290,
882 291, 292, 293, 294, 295, 296, 297, 298, 299, -1,
883 -1, -1, -1, 304, 305, 261, 262, 0, -1, -1,
884 266, -1, -1, -1, -1, -1, -1, -1, -1, -1,
885 -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
886 -1, 287, 288, 289, 290, 291, 292, 293, 294, 295,
887 296, 297, 298, 299, -1, -1, -1, -1, -1, -1,
888 -1, 0, -1, -1, -1, -1, -1, -1, -1, -1,
889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
890 -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
891 -1, -1, 0, -1, -1, -1, -1, -1, -1, -1,
892 -1, -1, -1, -1, -1, 265, 0, -1, -1, 269,
893 -1, 271, 272, 273, 274, 275, 276, 277, 278, -1,
894 280, 281, 282, 283, 284, 285, 286, 265, 0, -1,
895 -1, 269, -1, 271, 272, 273, -1, -1, 259, 260,
896 300, 301, 302, 303, 265, -1, 306, 268, 269, -1,
897 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
898 281, 282, 283, 284, 285, 286, 259, 260, -1, 265,
899 -1, -1, 265, 269, -1, 271, 269, 273, 271, 272,
900 273, 274, 275, 276, 277, 278, 0, 280, 281, 282,
901 283, 284, 285, 286, 265, -1, -1, -1, 269, -1,
902 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
903 281, 282, 283, 284, 285, 286, 265, -1, -1, -1,
904 269, -1, 271, 272, 273, 274, 275, 276, 277, 278,
905 0, 280, 281, 282, 283, 284, 285, 286, 265, -1,
906 -1, -1, 269, -1, 271, 272, 273, 274, 275, 276,
907 277, 278, 0, 280, 281, 282, 283, 284, 285, 286,
908 265, -1, -1, -1, 269, -1, 271, 272, 273, 274,
909 275, 276, 277, 278, 0, 280, 281, 282, 283, 284,
910 285, 286, 265, -1, -1, -1, 269, -1, 271, 272,
911 273, 274, 275, 276, 277, 278, 0, 280, 281, 282,
912 283, 284, 285, 286, 265, -1, -1, -1, 269, -1,
913 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
914 281, 282, 283, 284, 285, 286, 265, -1, -1, -1,
915 269, -1, 271, 272, 273, 274, 275, 276, 277, 278,
916 0, -1, 281, 282, 283, 284, 285, 286, 265, 0,
917 -1, -1, 269, -1, 271, 272, 273, 265, -1, 276,
918 277, 269, -1, 271, 281, 282, 283, 284, 285, 286,
919 -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
920 -1, -1, 276, 277, -1, -1, -1, 281, 282, 283,
921 284, 285, 286, 265, -1, -1, -1, 269, -1, 271,
922 272, 273, -1, -1, 276, 277, -1, -1, -1, 281,
923 282, 283, 284, 285, 286, -1, -1, -1, -1, -1,
924 -1, -1, -1, 265, -1, -1, -1, 269, -1, 271,
925 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
926 282, 283, 284, 285, 286, -1, -1, -1, -1, -1,
927 -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
928 -1, -1, -1, -1, -1, -1, -1, 281, 282, 283,
929 284, 285, 286, 265, -1, -1, -1, 269, -1, 271,
930 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
931 282, 283, 284, 285, 286, 265, -1, -1, -1, 269,
932 -1, 271, 272, 273, -1, -1, -1, -1, -1, -1,
933 -1, 281, 282, 283, 284, 285, 286, 265, -1, -1,
934 -1, 269, -1, 271, 272, 273, -1, -1, -1, -1,
935 -1, -1, -1, 281, 282, 283, 284, 285, 286, 265,
936 -1, -1, -1, 269, -1, 271, 272, 273, -1, -1,
937 -1, -1, -1, -1, -1, 281, 282, -1, -1, -1,
938 -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
939 -1, -1, -1, -1, -1, -1, -1, 281, 282, -1,
940 -1, -1, -1, 265, -1, -1, -1, 269, -1, 271,
941 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
942 282, -1, -1, -1, -1, 265, -1, -1, -1, 269,
943 -1, 271, 272, 273, 265, -1, -1, -1, 269, -1,
947 // line 412 "Parser.jay"
952 public interface yyDebug {
953 void push (int state, Object value);
954 void lex (int state, int token, string name, Object value);
955 void shift (int from, int to, int errorFlag);
956 void pop (int state);
957 void discard (int state, int token, string name, Object value);
958 void reduce (int from, int to, int rule, string text, int len);
959 void shift (int from, int to);
960 void accept (Object value);
961 void error (string message);
965 class yyDebugSimple : yyDebug {
966 void println (string s){
967 Console.WriteLine (s);
970 public void push (int state, Object value) {
971 println ("push\tstate "+state+"\tvalue "+value);
974 public void lex (int state, int token, string name, Object value) {
975 println("lex\tstate "+state+"\treading "+name+"\tvalue "+value);
978 public void shift (int from, int to, int errorFlag) {
981 println("shift\tfrom state "+from+" to "+to);
983 case 0: case 1: case 2: // in error recovery
984 println("shift\tfrom state "+from+" to "+to
985 +"\t"+errorFlag+" left to recover");
988 println("shift\tfrom state "+from+" to "+to+"\ton error");
993 public void pop (int state) {
994 println("pop\tstate "+state+"\ton error");
997 public void discard (int state, int token, string name, Object value) {
998 println("discard\tstate "+state+"\ttoken "+name+"\tvalue "+value);
1001 public void reduce (int from, int to, int rule, string text, int len) {
1002 println("reduce\tstate "+from+"\tuncover "+to
1003 +"\trule ("+rule+") "+text);
1006 public void shift (int from, int to) {
1007 println("goto\tfrom state "+from+" to "+to);
1010 public void accept (Object value) {
1011 println("accept\tvalue "+value);
1014 public void error (string message) {
1015 println("error\t"+message);
1018 public void reject () {
1026 public const int ERROR = 257;
1027 public const int EOF = 258;
1028 public const int SLASH = 259;
1029 public const int SLASH2 = 260;
1030 public const int DOT = 261;
1031 public const int DOT2 = 262;
1032 public const int COLON = 263;
1033 public const int COLON2 = 264;
1034 public const int COMMA = 265;
1035 public const int AT = 266;
1036 public const int FUNCTION_NAME = 267;
1037 public const int BRACKET_OPEN = 268;
1038 public const int BRACKET_CLOSE = 269;
1039 public const int PAREN_OPEN = 270;
1040 public const int PAREN_CLOSE = 271;
1041 public const int AND = 272;
1042 public const int OR = 273;
1043 public const int DIV = 274;
1044 public const int MOD = 275;
1045 public const int PLUS = 276;
1046 public const int MINUS = 277;
1047 public const int ASTERISK = 278;
1048 public const int DOLLAR = 279;
1049 public const int BAR = 280;
1050 public const int EQ = 281;
1051 public const int NE = 282;
1052 public const int LE = 283;
1053 public const int GE = 284;
1054 public const int LT = 285;
1055 public const int GT = 286;
1056 public const int ANCESTOR = 287;
1057 public const int ANCESTOR_OR_SELF = 288;
1058 public const int ATTRIBUTE = 289;
1059 public const int CHILD = 290;
1060 public const int DESCENDANT = 291;
1061 public const int DESCENDANT_OR_SELF = 292;
1062 public const int FOLLOWING = 293;
1063 public const int FOLLOWING_SIBLING = 294;
1064 public const int NAMESPACE = 295;
1065 public const int PARENT = 296;
1066 public const int PRECEDING = 297;
1067 public const int PRECEDING_SIBLING = 298;
1068 public const int SELF = 299;
1069 public const int COMMENT = 300;
1070 public const int TEXT = 301;
1071 public const int PROCESSING_INSTRUCTION = 302;
1072 public const int NODE = 303;
1073 public const int NUMBER = 304;
1074 public const int LITERAL = 305;
1075 public const int NCName = 306;
1076 public const int yyErrorCode = 256;
1078 namespace yyParser {
1080 /** thrown for irrecoverable syntax errors and stack overflow.
1082 public class yyException : System.Exception {
1083 public yyException (string message) : base (message) {
1087 /** must be implemented by a scanner object to supply input to the parser.
1089 public interface yyInput {
1090 /** move on to next token.
1091 @return false if positioned beyond tokens.
1092 @throws IOException on input error.
1094 bool advance (); // throws java.io.IOException;
1095 /** classifies current token.
1096 Should not be called if advance() returned false.
1097 @return current %token or single character.
1100 /** associated with current token.
1101 Should not be called if advance() returned false.
1102 @return value for token().
1107 } // close outermost namespace, that MUST HAVE BEEN opened in the prolog