Skip to content

Instantly share code, notes, and snippets.

@atsushieno
Created July 18, 2014 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atsushieno/b2290bc1162e42848cb3 to your computer and use it in GitHub Desktop.
Save atsushieno/b2290bc1162e42848cb3 to your computer and use it in GitHub Desktop.
// created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de
#line 2 "Parser.jay"
// XPath/XSLT Pattern parser
//
// Author: Piers Haken <piersh@friskit.com>
// Atsushi Enomoto <atsushi@ximian.com>
//
// IMPORTANT:
// Do not edit "PatternParser.jay". It is autogenerated from
// Parser.jay. It will be overwritten!
//
using System;
using System.Collections;
using System.Xml;
using System.Xml.XPath;
#if XSLT_PATTERN
namespace Mono.Xml.Xsl
#else
namespace Mono.Xml.XPath
#endif
{
#if XSLT_PATTERN
internal class XsltPatternParser
#else
internal class XPathParser
#endif
{
internal System.Xml.Xsl.IStaticXsltContext Context;
#if XSLT_PATTERN
public XsltPatternParser () : this (null) {}
internal XsltPatternParser (System.Xml.Xsl.IStaticXsltContext context)
#else
public XPathParser () : this (null) {}
internal XPathParser (System.Xml.Xsl.IStaticXsltContext context)
#endif
{
Context = context;
ErrorOutput = System.IO.TextWriter.Null;
// debug = new yydebug.yyDebugSimple ();
}
internal Expression Compile (string xpath)
{
try {
Tokenizer tokenizer = new Tokenizer (xpath);
return (Expression) yyparse (tokenizer);
} catch (XPathException) {
throw;
} catch (Exception e) {
throw new XPathException ("Error during parse of " + xpath, e);
}
}
#pragma warning disable 649
static readonly int yacc_verbose_flag;
#pragma warning restore 649
private NodeSet CreateNodeTest (Axes axis, object nodeTest, ArrayList plist)
{
NodeSet test = CreateNodeTest (axis, nodeTest);
if (plist != null) {
for (int i = 0; i < plist.Count; i++)
test = new ExprFilter (test,
(Expression) plist [i]);
}
return test;
}
private NodeTest CreateNodeTest (Axes axis, object test)
{
if (test is XPathNodeType)
return new NodeTypeTest (axis,
(XPathNodeType) test, null);
else if (test is string || test == null)
return new NodeTypeTest (axis,
XPathNodeType.ProcessingInstruction,
(string) test);
XmlQualifiedName q = (XmlQualifiedName) test;
if (q == XmlQualifiedName.Empty)
return new NodeTypeTest (axis);
else
return new NodeNameTest (axis, q, Context);
}
#line default
/** error output stream.
It should be changeable.
*/
public System.IO.TextWriter ErrorOutput = System.Console.Out;
/** simplified error message.
@see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a>
*/
public void yyerror (string message) {
yyerror(message, null);
}
#pragma warning disable 649
/* An EOF token */
public int eof_token;
#pragma warning restore 649
/** (syntax) error message.
Can be overwritten to control message format.
@param message text to be displayed.
@param expected vector of acceptable tokens, if available.
*/
public void yyerror (string message, string[] expected) {
if ((yacc_verbose_flag > 0) && (expected != null) && (expected.Length > 0)) {
ErrorOutput.Write (message+", expecting");
for (int n = 0; n < expected.Length; ++ n)
ErrorOutput.Write (" "+expected[n]);
ErrorOutput.WriteLine ();
} else
ErrorOutput.WriteLine (message);
}
/** debugging support, requires the package jay.yydebug.
Set to null to suppress debugging messages.
*/
internal yydebug.yyDebug debug;
protected const int yyFinal = 25;
// Put this array into a separate class so it is only initialized if debugging is actually used
// Use MarshalByRefObject to disable inlining
class YYRules : MarshalByRefObject {
public static readonly string [] yyRule = {
"$accept : Expr",
"Pattern : LocationPathPattern",
"Pattern : Pattern BAR LocationPathPattern",
"LocationPathPattern : SLASH",
"LocationPathPattern : SLASH RelativePathPattern",
"LocationPathPattern : IdKeyPattern",
"LocationPathPattern : IdKeyPattern SLASH RelativePathPattern",
"LocationPathPattern : IdKeyPattern SLASH2 RelativePathPattern",
"LocationPathPattern : SLASH2 RelativePathPattern",
"LocationPathPattern : RelativePathPattern",
"IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL PAREN_CLOSE",
"IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL COMMA LITERAL PAREN_CLOSE",
"RelativePathPattern : StepPattern",
"RelativePathPattern : RelativePathPattern SLASH StepPattern",
"RelativePathPattern : RelativePathPattern SLASH2 StepPattern",
"StepPattern : ChildOrAttributeAxisSpecifier NodeTest Predicates",
"ChildOrAttributeAxisSpecifier : AbbreviatedAxisSpecifier",
"ChildOrAttributeAxisSpecifier : CHILD COLON2",
"ChildOrAttributeAxisSpecifier : ATTRIBUTE COLON2",
"Predicates :",
"Predicates : Predicates Predicate",
"Expr : OrExpr",
"OrExpr : AndExpr",
"OrExpr : OrExpr OR AndExpr",
"AndExpr : EqualityExpr",
"AndExpr : AndExpr AND EqualityExpr",
"EqualityExpr : RelationalExpr",
"EqualityExpr : EqualityExpr EQ RelationalExpr",
"EqualityExpr : EqualityExpr NE RelationalExpr",
"RelationalExpr : AdditiveExpr",
"RelationalExpr : RelationalExpr LT AdditiveExpr",
"RelationalExpr : RelationalExpr GT AdditiveExpr",
"RelationalExpr : RelationalExpr LE AdditiveExpr",
"RelationalExpr : RelationalExpr GE AdditiveExpr",
"AdditiveExpr : MultiplicativeExpr",
"AdditiveExpr : AdditiveExpr PLUS MultiplicativeExpr",
"AdditiveExpr : AdditiveExpr MINUS MultiplicativeExpr",
"MultiplicativeExpr : UnaryExpr",
"MultiplicativeExpr : MultiplicativeExpr MULTIPLY UnaryExpr",
"MultiplicativeExpr : MultiplicativeExpr DIV UnaryExpr",
"MultiplicativeExpr : MultiplicativeExpr MOD UnaryExpr",
"UnaryExpr : UnionExpr",
"UnaryExpr : MINUS UnaryExpr",
"UnionExpr : PathExpr",
"UnionExpr : UnionExpr BAR PathExpr",
"PathExpr : LocationPath",
"PathExpr : FilterExpr",
"PathExpr : FilterExpr SLASH RelativeLocationPath",
"PathExpr : FilterExpr SLASH2 RelativeLocationPath",
"LocationPath : RelativeLocationPath",
"LocationPath : AbsoluteLocationPath",
"AbsoluteLocationPath : SLASH",
"AbsoluteLocationPath : SLASH RelativeLocationPath",
"AbsoluteLocationPath : SLASH2 RelativeLocationPath",
"RelativeLocationPath : Step",
"RelativeLocationPath : RelativeLocationPath SLASH Step",
"RelativeLocationPath : RelativeLocationPath SLASH2 Step",
"Step : AxisSpecifier NodeTest Predicates",
"Step : AbbreviatedStep",
"NodeTest : NameTest",
"NodeTest : NodeType PAREN_OPEN PAREN_CLOSE",
"NodeTest : PROCESSING_INSTRUCTION PAREN_OPEN OptionalLiteral PAREN_CLOSE",
"NameTest : ASTERISK",
"NameTest : QName",
"AbbreviatedStep : DOT",
"AbbreviatedStep : DOT2",
"Predicates :",
"Predicates : Predicates Predicate",
"AxisSpecifier : AxisName COLON2",
"AxisSpecifier : AbbreviatedAxisSpecifier",
"AbbreviatedAxisSpecifier :",
"AbbreviatedAxisSpecifier : AT",
"NodeType : COMMENT",
"NodeType : TEXT",
"NodeType : PROCESSING_INSTRUCTION",
"NodeType : NODE",
"FilterExpr : PrimaryExpr",
"FilterExpr : FilterExpr Predicate",
"PrimaryExpr : DOLLAR QName",
"PrimaryExpr : PAREN_OPEN Expr PAREN_CLOSE",
"PrimaryExpr : LITERAL",
"PrimaryExpr : NUMBER",
"PrimaryExpr : FunctionCall",
"FunctionCall : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE",
"OptionalArgumentList :",
"OptionalArgumentList : Expr OptionalArgumentListTail",
"OptionalArgumentListTail :",
"OptionalArgumentListTail : COMMA Expr OptionalArgumentListTail",
"Predicate : BRACKET_OPEN Expr BRACKET_CLOSE",
"AxisName : ANCESTOR",
"AxisName : ANCESTOR_OR_SELF",
"AxisName : ATTRIBUTE",
"AxisName : CHILD",
"AxisName : DESCENDANT",
"AxisName : DESCENDANT_OR_SELF",
"AxisName : FOLLOWING",
"AxisName : FOLLOWING_SIBLING",
"AxisName : NAMESPACE",
"AxisName : PARENT",
"AxisName : PRECEDING",
"AxisName : PRECEDING_SIBLING",
"AxisName : SELF",
"OptionalLiteral :",
"OptionalLiteral : LITERAL",
};
public static string getRule (int index) {
return yyRule [index];
}
}
protected static readonly string [] yyNames = {
"end-of-file",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,"'$'",null,null,
null,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",null,null,null,
null,null,null,null,null,null,null,null,null,"'<'","'='","'>'",null,
"'@'",null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,"'|'",null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,
"ERROR","EOF","SLASH","SLASH2","\"//\"","DOT","DOT2","\"..\"",
"COLON2","\"::\"","COMMA","AT","FUNCTION_NAME","BRACKET_OPEN",
"BRACKET_CLOSE","PAREN_OPEN","PAREN_CLOSE","AND","\"and\"","OR",
"\"or\"","DIV","\"div\"","MOD","\"mod\"","PLUS","MINUS","ASTERISK",
"DOLLAR","BAR","EQ","NE","\"!=\"","LE","\"<=\"","GE","\">=\"","LT",
"GT","ANCESTOR","\"ancestor\"","ANCESTOR_OR_SELF",
"\"ancstor-or-self\"","ATTRIBUTE","\"attribute\"","CHILD","\"child\"",
"DESCENDANT","\"descendant\"","DESCENDANT_OR_SELF",
"\"descendant-or-self\"","FOLLOWING","\"following\"",
"FOLLOWING_SIBLING","\"sibling\"","NAMESPACE","\"NameSpace\"",
"PARENT","\"parent\"","PRECEDING","\"preceding\"","PRECEDING_SIBLING",
"\"preceding-sibling\"","SELF","\"self\"","COMMENT","\"comment\"",
"TEXT","\"text\"","PROCESSING_INSTRUCTION",
"\"processing-instruction\"","NODE","\"node\"","MULTIPLY","NUMBER",
"LITERAL","QName",
};
/** index-checked interface to yyNames[].
@param token single character or %token value.
@return token name or [illegal] or [unknown].
*/
public static string yyname (int token) {
if ((token < 0) || (token > yyNames.Length)) return "[illegal]";
string name;
if ((name = yyNames[token]) != null) return name;
return "[unknown]";
}
#pragma warning disable 414
int yyExpectingState;
#pragma warning restore 414
/** computes list of expected tokens on error by tracing the tables.
@param state for which to compute the list.
@return list of token names.
*/
protected int [] yyExpectingTokens (int state){
int token, n, len = 0;
bool[] ok = new bool[yyNames.Length];
if ((n = yySindex[state]) != 0)
for (token = n < 0 ? -n : 0;
(token < yyNames.Length) && (n+token < yyTable.Length); ++ token)
if (yyCheck[n+token] == token && !ok[token] && yyNames[token] != null) {
++ len;
ok[token] = true;
}
if ((n = yyRindex[state]) != 0)
for (token = n < 0 ? -n : 0;
(token < yyNames.Length) && (n+token < yyTable.Length); ++ token)
if (yyCheck[n+token] == token && !ok[token] && yyNames[token] != null) {
++ len;
ok[token] = true;
}
int [] result = new int [len];
for (n = token = 0; n < len; ++ token)
if (ok[token]) result[n++] = token;
return result;
}
protected string[] yyExpecting (int state) {
int [] tokens = yyExpectingTokens (state);
string [] result = new string[tokens.Length];
for (int n = 0; n < tokens.Length; n++)
result[n++] = yyNames[tokens [n]];
return result;
}
/** the generated parser, with debugging messages.
Maintains a state and a value stack, currently with fixed maximum size.
@param yyLex scanner.
@param yydebug debug message writer implementing yyDebug, or null.
@return result of the last reduction, if any.
@throws yyException on irrecoverable parse error.
*/
internal Object yyparse (yyParser.yyInput yyLex, Object yyd)
{
this.debug = (yydebug.yyDebug)yyd;
return yyparse(yyLex);
}
/** initial size and increment of the state/value stack [default 256].
This is not final so that it can be overwritten outside of invocations
of yyparse().
*/
protected int yyMax;
/** executed at the beginning of a reduce action.
Used as $$ = yyDefault($1), prior to the user-specified action, if any.
Can be overwritten to provide deep copy, etc.
@param first value for $1, or null.
@return first.
*/
protected Object yyDefault (Object first) {
return first;
}
static int[] global_yyStates;
static object[] global_yyVals;
#pragma warning disable 649
protected bool use_global_stacks;
#pragma warning restore 649
object[] yyVals; // value stack
object yyVal; // value stack ptr
int yyToken; // current input
int yyTop;
/** the generated parser.
Maintains a state and a value stack, currently with fixed maximum size.
@param yyLex scanner.
@return result of the last reduction, if any.
@throws yyException on irrecoverable parse error.
*/
internal Object yyparse (yyParser.yyInput yyLex)
{
if (yyMax <= 0) yyMax = 256; // initial size
int yyState = 0; // state stack ptr
int [] yyStates; // state stack
yyVal = null;
yyToken = -1;
int yyErrorFlag = 0; // #tks to shift
if (use_global_stacks && global_yyStates != null) {
yyVals = global_yyVals;
yyStates = global_yyStates;
} else {
yyVals = new object [yyMax];
yyStates = new int [yyMax];
if (use_global_stacks) {
global_yyVals = yyVals;
global_yyStates = yyStates;
}
}
/*yyLoop:*/ for (yyTop = 0;; ++ yyTop) {
if (yyTop >= yyStates.Length) { // dynamically increase
global::System.Array.Resize (ref yyStates, yyStates.Length+yyMax);
global::System.Array.Resize (ref yyVals, yyVals.Length+yyMax);
}
yyStates[yyTop] = yyState;
yyVals[yyTop] = yyVal;
if (debug != null) debug.push(yyState, yyVal);
/*yyDiscarded:*/ while (true) { // discarding a token does not change stack
int yyN;
if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
if (yyToken < 0) {
yyToken = yyLex.advance() ? yyLex.token() : 0;
if (debug != null)
debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value());
}
if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0)
&& (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) {
if (debug != null)
debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
yyState = yyTable[yyN]; // shift to yyN
yyVal = yyLex.value();
yyToken = -1;
if (yyErrorFlag > 0) -- yyErrorFlag;
goto continue_yyLoop;
}
if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
&& yyN < yyTable.Length && yyCheck[yyN] == yyToken)
yyN = yyTable[yyN]; // reduce (yyN)
else
switch (yyErrorFlag) {
case 0:
yyExpectingState = yyState;
// yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState));
if (debug != null) debug.error("syntax error");
if (yyToken == 0 /*eof*/ || yyToken == eof_token) throw new yyParser.yyUnexpectedEof ();
goto case 1;
case 1: case 2:
yyErrorFlag = 3;
do {
if ((yyN = yySindex[yyStates[yyTop]]) != 0
&& (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length
&& yyCheck[yyN] == Token.yyErrorCode) {
if (debug != null)
debug.shift(yyStates[yyTop], yyTable[yyN], 3);
yyState = yyTable[yyN];
yyVal = yyLex.value();
goto continue_yyLoop;
}
if (debug != null) debug.pop(yyStates[yyTop]);
} while (-- yyTop >= 0);
if (debug != null) debug.reject();
throw new yyParser.yyException("irrecoverable syntax error");
case 3:
if (yyToken == 0) {
if (debug != null) debug.reject();
throw new yyParser.yyException("irrecoverable syntax error at end-of-file");
}
if (debug != null)
debug.discard(yyState, yyToken, yyname(yyToken),
yyLex.value());
yyToken = -1;
goto continue_yyDiscarded; // leave stack alone
}
}
int yyV = yyTop + 1-yyLen[yyN];
if (debug != null)
debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]);
yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
switch (yyN) {
case 2:
#line 175 "Parser.jay"
{
yyVal = new ExprUNION ((NodeSet) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 3:
#line 182 "Parser.jay"
{
yyVal = new ExprRoot ();
}
break;
case 4:
#line 186 "Parser.jay"
{
yyVal = new ExprSLASH (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
}
break;
case 6:
#line 191 "Parser.jay"
{
yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 7:
#line 195 "Parser.jay"
{
yyVal = new ExprSLASH2 ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 8:
#line 199 "Parser.jay"
{
yyVal = new ExprSLASH2 (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
}
break;
case 10:
case_10();
break;
case 11:
case_11();
break;
case 13:
#line 235 "Parser.jay"
{
yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 14:
#line 239 "Parser.jay"
{
yyVal = new ExprSLASH2 ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 15:
#line 246 "Parser.jay"
{
yyVal = CreateNodeTest ((Axes) yyVals[-2+yyTop], yyVals[-1+yyTop], (ArrayList) yyVals[0+yyTop]);
}
break;
case 17:
#line 254 "Parser.jay"
{
yyVal = Axes.Child;
}
break;
case 18:
#line 258 "Parser.jay"
{
yyVal = Axes.Attribute;
}
break;
case 19:
#line 265 "Parser.jay"
{
yyVal = null;
}
break;
case 20:
case_20();
break;
case 23:
#line 288 "Parser.jay"
{
yyVal = new ExprOR ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 25:
#line 296 "Parser.jay"
{
yyVal = new ExprAND ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 27:
#line 304 "Parser.jay"
{
yyVal = new ExprEQ ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 28:
#line 308 "Parser.jay"
{
yyVal = new ExprNE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 30:
#line 316 "Parser.jay"
{
yyVal = new ExprLT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 31:
#line 320 "Parser.jay"
{
yyVal = new ExprGT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 32:
#line 324 "Parser.jay"
{
yyVal = new ExprLE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 33:
#line 328 "Parser.jay"
{
yyVal = new ExprGE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 35:
#line 336 "Parser.jay"
{
yyVal = new ExprPLUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 36:
#line 340 "Parser.jay"
{
yyVal = new ExprMINUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 38:
#line 348 "Parser.jay"
{
yyVal = new ExprMULT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 39:
#line 352 "Parser.jay"
{
yyVal = new ExprDIV ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 40:
#line 356 "Parser.jay"
{
yyVal = new ExprMOD ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 42:
#line 364 "Parser.jay"
{
yyVal = new ExprNEG ((Expression) yyVals[0+yyTop]);
}
break;
case 44:
#line 372 "Parser.jay"
{
yyVal = new ExprUNION ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 47:
#line 381 "Parser.jay"
{
yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 48:
#line 385 "Parser.jay"
{
yyVal = new ExprSLASH2 ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 51:
#line 397 "Parser.jay"
{
yyVal = new ExprRoot ();
}
break;
case 52:
#line 401 "Parser.jay"
{
yyVal = new ExprSLASH (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
}
break;
case 53:
#line 405 "Parser.jay"
{
yyVal = new ExprSLASH2 (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
}
break;
case 55:
#line 413 "Parser.jay"
{
yyVal = new ExprSLASH ((NodeSet) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 56:
#line 417 "Parser.jay"
{
yyVal = new ExprSLASH2 ((NodeSet) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
}
break;
case 57:
#line 424 "Parser.jay"
{
yyVal = CreateNodeTest ((Axes) yyVals[-2+yyTop], yyVals[-1+yyTop], (ArrayList) yyVals[0+yyTop]);
}
break;
case 60:
#line 433 "Parser.jay"
{
yyVal = (XPathNodeType) yyVals[-2+yyTop];
}
break;
case 61:
#line 437 "Parser.jay"
{
yyVal = (string) yyVals[-1+yyTop];
}
break;
case 62:
#line 444 "Parser.jay"
{
yyVal = XmlQualifiedName.Empty;
}
break;
case 64:
#line 452 "Parser.jay"
{
yyVal = new NodeTypeTest (Axes.Self, XPathNodeType.All);
}
break;
case 65:
#line 456 "Parser.jay"
{
yyVal = new NodeTypeTest (Axes.Parent, XPathNodeType.All);
}
break;
case 66:
#line 463 "Parser.jay"
{
yyVal = null;
}
break;
case 67:
case_67();
break;
case 68:
#line 478 "Parser.jay"
{
yyVal = yyVals[-1+yyTop];
}
break;
case 70:
#line 486 "Parser.jay"
{
yyVal = Axes.Child;
}
break;
case 71:
#line 490 "Parser.jay"
{
yyVal = Axes.Attribute;
}
break;
case 72:
#line 494 "Parser.jay"
{ yyVal = XPathNodeType.Comment; }
break;
case 73:
#line 495 "Parser.jay"
{ yyVal = XPathNodeType.Text; }
break;
case 74:
#line 496 "Parser.jay"
{ yyVal = XPathNodeType.ProcessingInstruction; }
break;
case 75:
#line 497 "Parser.jay"
{ yyVal = XPathNodeType.All; }
break;
case 77:
#line 506 "Parser.jay"
{
yyVal = new ExprFilter ((Expression) yyVals[-1+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 78:
case_78();
break;
case 79:
#line 524 "Parser.jay"
{
yyVal = new ExprParens ((Expression) yyVals[-1+yyTop]);
}
break;
case 80:
#line 528 "Parser.jay"
{
yyVal = new ExprLiteral ((String) yyVals[0+yyTop]);
}
break;
case 81:
#line 532 "Parser.jay"
{
yyVal = new ExprNumber ((double) yyVals[0+yyTop]);
}
break;
case 83:
case_83();
break;
case 85:
#line 554 "Parser.jay"
{
yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
}
break;
case 87:
#line 562 "Parser.jay"
{
yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
}
break;
case 88:
#line 569 "Parser.jay"
{
yyVal = yyVals[-1+yyTop];
}
break;
case 89:
#line 573 "Parser.jay"
{ yyVal = Axes.Ancestor; }
break;
case 90:
#line 574 "Parser.jay"
{ yyVal = Axes.AncestorOrSelf; }
break;
case 91:
#line 575 "Parser.jay"
{ yyVal = Axes.Attribute; }
break;
case 92:
#line 576 "Parser.jay"
{ yyVal = Axes.Child; }
break;
case 93:
#line 577 "Parser.jay"
{ yyVal = Axes.Descendant; }
break;
case 94:
#line 578 "Parser.jay"
{ yyVal = Axes.DescendantOrSelf; }
break;
case 95:
#line 579 "Parser.jay"
{ yyVal = Axes.Following; }
break;
case 96:
#line 580 "Parser.jay"
{ yyVal = Axes.FollowingSibling; }
break;
case 97:
#line 581 "Parser.jay"
{ yyVal = Axes.Namespace; }
break;
case 98:
#line 582 "Parser.jay"
{ yyVal = Axes.Parent; }
break;
case 99:
#line 583 "Parser.jay"
{ yyVal = Axes.Preceding; }
break;
case 100:
#line 584 "Parser.jay"
{ yyVal = Axes.PrecedingSibling; }
break;
case 101:
#line 585 "Parser.jay"
{ yyVal = Axes.Self; }
break;
#line default
}
yyTop -= yyLen[yyN];
yyState = yyStates[yyTop];
int yyM = yyLhs[yyN];
if (yyState == 0 && yyM == 0) {
if (debug != null) debug.shift(0, yyFinal);
yyState = yyFinal;
if (yyToken < 0) {
yyToken = yyLex.advance() ? yyLex.token() : 0;
if (debug != null)
debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
}
if (yyToken == 0) {
if (debug != null) debug.accept(yyVal);
return yyVal;
}
goto continue_yyLoop;
}
if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
&& (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
yyState = yyTable[yyN];
else
yyState = yyDgoto[yyM];
if (debug != null) debug.shift(yyStates[yyTop], yyState);
goto continue_yyLoop;
continue_yyDiscarded: ; // implements the named-loop continue: 'continue yyDiscarded'
}
continue_yyLoop: ; // implements the named-loop continue: 'continue yyLoop'
}
}
/*
All more than 3 lines long rules are wrapped into a method
*/
void case_10()
#line 206 "Parser.jay"
{
XmlQualifiedName name = (XmlQualifiedName) yyVals[-3+yyTop];
if (name.Name != "id" || name.Namespace != String.Empty)
throw new XPathException (String.Format ("Expected 'id' but got '{0}'", name));
yyVal = ExprFunctionCall.Factory (name,
new FunctionArguments (
new ExprLiteral ((string) yyVals[-1+yyTop]),
null),
Context);
}
void case_11()
#line 217 "Parser.jay"
{
XmlQualifiedName name = (XmlQualifiedName) yyVals[-5+yyTop];
if (name.Name != "key" || name.Namespace != String.Empty)
throw new XPathException (String.Format ("Expected 'key' but got '{0}'", name));
yyVal = Context.TryGetFunction (name,
new FunctionArguments (
new ExprLiteral ((string) yyVals[-3+yyTop]),
new FunctionArguments (
new ExprLiteral ((string) yyVals[-1+yyTop]),
null)));
}
void case_20()
#line 267 "Parser.jay"
{
ArrayList al = (ArrayList) yyVals[-1+yyTop];
if (al == null)
al = new ArrayList ();
al.Add ((Expression) yyVals[0+yyTop]);
yyVal = al;
}
void case_67()
#line 465 "Parser.jay"
{
ArrayList al = (ArrayList) yyVals[-1+yyTop];
if (al == null)
al = new ArrayList ();
al.Add (yyVals[0+yyTop]);
yyVal = al;
}
void case_78()
#line 511 "Parser.jay"
{
Expression ret = null;
if (Context != null)
ret = Context.TryGetVariable (((XmlQualifiedName) yyVals[0+yyTop]).ToString ());
if (ret == null)
ret = new ExprVariable ((XmlQualifiedName) yyVals[0+yyTop], Context);
yyVal = ret;
}
void case_83()
#line 538 "Parser.jay"
{
Expression ret = null;
if (Context != null)
ret = Context.TryGetFunction ((XmlQualifiedName) yyVals[-3+yyTop], (FunctionArguments) yyVals[-1+yyTop]);
if (ret == null)
ret = ExprFunctionCall.Factory ((XmlQualifiedName) yyVals[-3+yyTop], (FunctionArguments) yyVals[-1+yyTop], Context);
yyVal = ret;
}
#line default
static readonly short [] yyLhs = { -1,
1, 1, 2, 2, 2, 2, 2, 2, 2, 4,
4, 3, 3, 3, 5, 6, 6, 6, 8, 8,
0, 11, 11, 12, 12, 13, 13, 13, 14, 14,
14, 14, 14, 15, 15, 15, 16, 16, 16, 16,
17, 17, 18, 18, 19, 19, 19, 19, 20, 20,
23, 23, 23, 22, 22, 22, 24, 24, 7, 7,
7, 27, 27, 26, 26, 8, 8, 25, 25, 9,
9, 28, 28, 28, 28, 21, 21, 31, 31, 31,
31, 31, 32, 33, 33, 34, 34, 10, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 29, 29,
};
static readonly short [] yyLen = { 2,
1, 3, 1, 2, 1, 3, 3, 2, 1, 4,
6, 1, 3, 3, 3, 1, 2, 2, 0, 2,
1, 1, 3, 1, 3, 1, 3, 3, 1, 3,
3, 3, 3, 1, 3, 3, 1, 3, 3, 3,
1, 2, 1, 3, 1, 1, 3, 3, 1, 1,
1, 2, 2, 1, 3, 3, 3, 1, 1, 3,
4, 1, 1, 1, 1, 0, 2, 2, 1, 0,
1, 1, 1, 1, 1, 1, 2, 2, 3, 1,
1, 1, 4, 0, 2, 0, 3, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1,
};
static readonly short [] yyDefRed = { 0,
0, 0, 64, 65, 71, 0, 0, 0, 0, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 81, 80, 0, 69, 0, 0, 0, 0,
0, 0, 37, 0, 43, 45, 0, 0, 50, 54,
0, 58, 0, 76, 82, 0, 0, 0, 0, 42,
78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 77, 0,
0, 62, 72, 73, 0, 75, 63, 19, 59, 0,
68, 0, 0, 79, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 39, 40, 38, 44, 0, 0,
0, 55, 56, 0, 0, 0, 0, 85, 83, 88,
103, 0, 20, 60, 0, 61, 87,
};
protected static readonly short [] yyDgoto = { 25,
0, 0, 0, 0, 0, 0, 78, 105, 26, 69,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 79, 80, 112, 43,
44, 45, 83, 108,
};
protected static readonly short [] yySindex = { -254,
-130, -130, 0, 0, 0, -270, -254, -254, -326, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -266, -262, -271, -256,
-201, -267, 0, -258, 0, 0, -238, -169, 0, 0,
-227, 0, -245, 0, 0, -169, -169, -254, -243, 0,
0, -254, -254, -254, -254, -254, -254, -254, -254, -254,
-254, -254, -254, -254, -189, -130, -130, -254, 0, -130,
-130, 0, 0, 0, -237, 0, 0, 0, 0, -232,
0, -224, -228, 0, -262, -271, -256, -256, -201, -201,
-201, -201, -267, -267, 0, 0, 0, 0, -169, -169,
-222, 0, 0, -285, -219, -220, -254, 0, 0, 0,
0, -218, 0, 0, -224, 0, 0,
};
protected static readonly short [] yyRindex = { -176,
1, -176, 0, 0, 0, 0, -176, -176, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 19, 93, 37, 27,
357, 276, 0, 250, 0, 0, 85, 114, 0, 0,
0, 0, 0, 0, 0, 140, 169, -198, 0, 0,
0, -176, -176, -176, -176, -176, -176, -176, -176, -176,
-176, -176, -176, -176, -176, -176, -176, -176, 0, -176,
-176, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, -208, 0, 0, 336, 484, 458, 476, 383, 393,
419, 429, 302, 328, 0, 0, 0, 0, 195, 224,
0, 0, 0, -206, 59, 0, -176, 0, 0, 0,
0, 0, 0, 0, -208, 0, 0,
};
protected static readonly short [] yyGindex = { -7,
0, 0, 0, 0, 0, 0, 0, 0, 0, -29,
0, 20, 31, 48, -33, 44, 25, 0, 29, 0,
0, 2, 0, 66, 0, 0, 0, 0, 0, 0,
0, 0, 0, -23,
};
protected static readonly short [] yyTable = { 49,
51, 48, 46, 47, 1, 2, 51, 3, 4, 52,
62, 53, 63, 5, 6, 54, 55, 7, 21, 81,
66, 67, 89, 90, 91, 92, 26, 65, 8, 84,
9, 68, 50, 56, 104, 57, 24, 58, 59, 106,
82, 10, 107, 11, 109, 12, 111, 13, 110, 14,
68, 15, 114, 16, 116, 17, 72, 18, 57, 19,
101, 20, 64, 21, 86, 22, 102, 99, 100, 1,
2, 85, 3, 4, 84, 113, 23, 24, 5, 6,
60, 61, 7, 86, 46, 70, 95, 96, 97, 70,
71, 117, 22, 98, 73, 9, 74, 0, 75, 115,
76, 87, 88, 93, 94, 77, 10, 70, 11, 0,
12, 0, 13, 49, 14, 0, 15, 0, 16, 0,
17, 0, 18, 70, 19, 70, 20, 70, 21, 70,
22, 3, 4, 0, 70, 102, 103, 5, 0, 52,
0, 23, 24, 0, 0, 70, 0, 70, 0, 70,
0, 70, 0, 0, 0, 0, 70, 0, 0, 0,
0, 0, 0, 0, 0, 10, 0, 11, 53, 12,
0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
0, 18, 0, 19, 0, 20, 0, 21, 0, 22,
0, 0, 0, 0, 47, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 48, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 41,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 51, 0, 0,
0, 51, 0, 51, 51, 34, 51, 0, 51, 0,
51, 0, 51, 51, 70, 21, 51, 51, 51, 21,
51, 21, 51, 26, 51, 51, 0, 26, 0, 26,
26, 35, 26, 24, 0, 0, 0, 24, 0, 24,
24, 0, 24, 26, 26, 0, 0, 57, 57, 0,
0, 0, 70, 0, 70, 57, 70, 36, 70, 57,
51, 57, 57, 70, 57, 23, 57, 0, 57, 0,
57, 57, 0, 0, 57, 57, 57, 0, 57, 0,
57, 46, 57, 57, 0, 46, 29, 46, 46, 22,
46, 0, 46, 22, 46, 22, 46, 46, 22, 0,
46, 46, 46, 0, 46, 0, 46, 0, 46, 46,
49, 0, 32, 0, 49, 0, 49, 49, 57, 49,
0, 49, 33, 49, 0, 49, 49, 0, 0, 49,
49, 49, 0, 49, 0, 49, 52, 49, 49, 0,
52, 0, 52, 52, 46, 52, 0, 52, 30, 52,
0, 52, 52, 0, 0, 52, 52, 52, 31, 52,
0, 52, 0, 52, 52, 53, 0, 0, 0, 53,
0, 53, 53, 49, 53, 0, 53, 0, 53, 0,
53, 53, 0, 0, 53, 53, 53, 27, 53, 0,
53, 47, 53, 53, 0, 47, 0, 47, 47, 52,
47, 0, 47, 0, 47, 28, 47, 47, 0, 0,
47, 47, 47, 25, 47, 0, 47, 0, 47, 47,
48, 0, 0, 0, 48, 0, 48, 48, 53, 48,
0, 48, 0, 48, 0, 48, 48, 0, 0, 48,
48, 48, 0, 48, 0, 48, 41, 48, 48, 0,
41, 0, 41, 41, 47, 41, 0, 41, 0, 41,
0, 41, 41, 0, 0, 0, 41, 41, 0, 41,
0, 41, 34, 41, 41, 0, 34, 0, 34, 34,
0, 34, 0, 48, 0, 0, 0, 34, 34, 0,
0, 0, 34, 34, 0, 34, 0, 34, 35, 34,
34, 0, 35, 0, 35, 35, 0, 35, 0, 41,
0, 0, 0, 35, 35, 0, 0, 0, 35, 35,
0, 35, 0, 35, 36, 35, 35, 0, 36, 0,
36, 36, 23, 36, 0, 0, 23, 0, 23, 36,
36, 23, 0, 0, 36, 36, 0, 36, 0, 36,
0, 36, 36, 29, 0, 0, 0, 29, 0, 29,
29, 0, 29, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 29, 29, 0, 29, 0, 29, 32,
29, 29, 0, 32, 0, 32, 32, 0, 32, 33,
0, 0, 0, 33, 0, 33, 33, 0, 33, 32,
32, 0, 32, 0, 32, 0, 32, 32, 0, 33,
33, 0, 33, 0, 33, 30, 33, 33, 0, 30,
0, 30, 30, 0, 30, 31, 0, 0, 0, 31,
0, 31, 31, 0, 31, 30, 30, 0, 30, 0,
30, 0, 30, 30, 0, 31, 31, 0, 31, 0,
31, 0, 31, 31, 27, 0, 0, 0, 27, 0,
27, 27, 0, 27, 0, 0, 0, 0, 0, 0,
0, 0, 28, 0, 27, 27, 28, 0, 28, 28,
25, 28, 0, 0, 25, 0, 25, 25, 0, 25,
0, 0, 28, 28,
};
protected static readonly short [] yyCheck = { 7,
0, 272, 1, 2, 259, 260, 333, 262, 263, 276,
278, 274, 280, 268, 269, 287, 288, 272, 0, 265,
259, 260, 56, 57, 58, 59, 0, 286, 283, 273,
285, 270, 8, 290, 272, 292, 0, 294, 295, 272,
48, 296, 267, 298, 273, 300, 332, 302, 271, 304,
270, 306, 273, 308, 273, 310, 284, 312, 0, 314,
68, 316, 330, 318, 273, 320, 273, 66, 67, 259,
260, 52, 262, 263, 273, 105, 331, 332, 268, 269,
282, 283, 272, 53, 0, 284, 62, 63, 64, 259,
260, 115, 0, 65, 322, 285, 324, -1, 326, 107,
328, 54, 55, 60, 61, 333, 296, 284, 298, -1,
300, -1, 302, 0, 304, -1, 306, -1, 308, -1,
310, -1, 312, 322, 314, 324, 316, 326, 318, 328,
320, 262, 263, -1, 333, 70, 71, 268, -1, 0,
-1, 331, 332, -1, -1, 322, -1, 324, -1, 326,
-1, 328, -1, -1, -1, -1, 333, -1, -1, -1,
-1, -1, -1, -1, -1, 296, -1, 298, 0, 300,
-1, 302, -1, 304, -1, 306, -1, 308, -1, 310,
-1, 312, -1, 314, -1, 316, -1, 318, -1, 320,
-1, -1, -1, -1, 0, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 267, -1, -1,
-1, 271, -1, 273, 274, 0, 276, -1, 278, -1,
280, -1, 282, 283, 284, 267, 286, 287, 288, 271,
290, 273, 292, 267, 294, 295, -1, 271, -1, 273,
274, 0, 276, 267, -1, -1, -1, 271, -1, 273,
274, -1, 276, 287, 288, -1, -1, 259, 260, -1,
-1, -1, 322, -1, 324, 267, 326, 0, 328, 271,
330, 273, 274, 333, 276, 0, 278, -1, 280, -1,
282, 283, -1, -1, 286, 287, 288, -1, 290, -1,
292, 267, 294, 295, -1, 271, 0, 273, 274, 267,
276, -1, 278, 271, 280, 273, 282, 283, 276, -1,
286, 287, 288, -1, 290, -1, 292, -1, 294, 295,
267, -1, 0, -1, 271, -1, 273, 274, 330, 276,
-1, 278, 0, 280, -1, 282, 283, -1, -1, 286,
287, 288, -1, 290, -1, 292, 267, 294, 295, -1,
271, -1, 273, 274, 330, 276, -1, 278, 0, 280,
-1, 282, 283, -1, -1, 286, 287, 288, 0, 290,
-1, 292, -1, 294, 295, 267, -1, -1, -1, 271,
-1, 273, 274, 330, 276, -1, 278, -1, 280, -1,
282, 283, -1, -1, 286, 287, 288, 0, 290, -1,
292, 267, 294, 295, -1, 271, -1, 273, 274, 330,
276, -1, 278, -1, 280, 0, 282, 283, -1, -1,
286, 287, 288, 0, 290, -1, 292, -1, 294, 295,
267, -1, -1, -1, 271, -1, 273, 274, 330, 276,
-1, 278, -1, 280, -1, 282, 283, -1, -1, 286,
287, 288, -1, 290, -1, 292, 267, 294, 295, -1,
271, -1, 273, 274, 330, 276, -1, 278, -1, 280,
-1, 282, 283, -1, -1, -1, 287, 288, -1, 290,
-1, 292, 267, 294, 295, -1, 271, -1, 273, 274,
-1, 276, -1, 330, -1, -1, -1, 282, 283, -1,
-1, -1, 287, 288, -1, 290, -1, 292, 267, 294,
295, -1, 271, -1, 273, 274, -1, 276, -1, 330,
-1, -1, -1, 282, 283, -1, -1, -1, 287, 288,
-1, 290, -1, 292, 267, 294, 295, -1, 271, -1,
273, 274, 267, 276, -1, -1, 271, -1, 273, 282,
283, 276, -1, -1, 287, 288, -1, 290, -1, 292,
-1, 294, 295, 267, -1, -1, -1, 271, -1, 273,
274, -1, 276, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 287, 288, -1, 290, -1, 292, 267,
294, 295, -1, 271, -1, 273, 274, -1, 276, 267,
-1, -1, -1, 271, -1, 273, 274, -1, 276, 287,
288, -1, 290, -1, 292, -1, 294, 295, -1, 287,
288, -1, 290, -1, 292, 267, 294, 295, -1, 271,
-1, 273, 274, -1, 276, 267, -1, -1, -1, 271,
-1, 273, 274, -1, 276, 287, 288, -1, 290, -1,
292, -1, 294, 295, -1, 287, 288, -1, 290, -1,
292, -1, 294, 295, 267, -1, -1, -1, 271, -1,
273, 274, -1, 276, -1, -1, -1, -1, -1, -1,
-1, -1, 267, -1, 287, 288, 271, -1, 273, 274,
267, 276, -1, -1, 271, -1, 273, 274, -1, 276,
-1, -1, 287, 288,
};
#line 594 "Parser.jay"
}
#line default
namespace yydebug {
using System;
internal interface yyDebug {
void push (int state, Object value);
void lex (int state, int token, string name, Object value);
void shift (int from, int to, int errorFlag);
void pop (int state);
void discard (int state, int token, string name, Object value);
void reduce (int from, int to, int rule, string text, int len);
void shift (int from, int to);
void accept (Object value);
void error (string message);
void reject ();
}
class yyDebugSimple : yyDebug {
void println (string s){
Console.Error.WriteLine (s);
}
public void push (int state, Object value) {
println ("push\tstate "+state+"\tvalue "+value);
}
public void lex (int state, int token, string name, Object value) {
println("lex\tstate "+state+"\treading "+name+"\tvalue "+value);
}
public void shift (int from, int to, int errorFlag) {
switch (errorFlag) {
default: // normally
println("shift\tfrom state "+from+" to "+to);
break;
case 0: case 1: case 2: // in error recovery
println("shift\tfrom state "+from+" to "+to
+"\t"+errorFlag+" left to recover");
break;
case 3: // normally
println("shift\tfrom state "+from+" to "+to+"\ton error");
break;
}
}
public void pop (int state) {
println("pop\tstate "+state+"\ton error");
}
public void discard (int state, int token, string name, Object value) {
println("discard\tstate "+state+"\ttoken "+name+"\tvalue "+value);
}
public void reduce (int from, int to, int rule, string text, int len) {
println("reduce\tstate "+from+"\tuncover "+to
+"\trule ("+rule+") "+text);
}
public void shift (int from, int to) {
println("goto\tfrom state "+from+" to "+to);
}
public void accept (Object value) {
println("accept\tvalue "+value);
}
public void error (string message) {
println("error\t"+message);
}
public void reject () {
println("reject");
}
}
}
// %token constants
class Token {
public const int ERROR = 257;
public const int EOF = 258;
public const int SLASH = 259;
public const int SLASH2 = 260;
public const int DOT = 262;
public const int DOT2 = 263;
public const int COLON2 = 265;
public const int COMMA = 267;
public const int AT = 268;
public const int FUNCTION_NAME = 269;
public const int BRACKET_OPEN = 270;
public const int BRACKET_CLOSE = 271;
public const int PAREN_OPEN = 272;
public const int PAREN_CLOSE = 273;
public const int AND = 274;
public const int and = 275;
public const int OR = 276;
public const int or = 277;
public const int DIV = 278;
public const int div = 279;
public const int MOD = 280;
public const int mod = 281;
public const int PLUS = 282;
public const int MINUS = 283;
public const int ASTERISK = 284;
public const int DOLLAR = 285;
public const int BAR = 286;
public const int EQ = 287;
public const int NE = 288;
public const int LE = 290;
public const int GE = 292;
public const int LT = 294;
public const int GT = 295;
public const int ANCESTOR = 296;
public const int ancestor = 297;
public const int ANCESTOR_OR_SELF = 298;
public const int ATTRIBUTE = 300;
public const int attribute = 301;
public const int CHILD = 302;
public const int child = 303;
public const int DESCENDANT = 304;
public const int descendant = 305;
public const int DESCENDANT_OR_SELF = 306;
public const int FOLLOWING = 308;
public const int following = 309;
public const int FOLLOWING_SIBLING = 310;
public const int sibling = 311;
public const int NAMESPACE = 312;
public const int NameSpace = 313;
public const int PARENT = 314;
public const int parent = 315;
public const int PRECEDING = 316;
public const int preceding = 317;
public const int PRECEDING_SIBLING = 318;
public const int SELF = 320;
public const int self = 321;
public const int COMMENT = 322;
public const int comment = 323;
public const int TEXT = 324;
public const int text = 325;
public const int PROCESSING_INSTRUCTION = 326;
public const int NODE = 328;
public const int node = 329;
public const int MULTIPLY = 330;
public const int NUMBER = 331;
public const int LITERAL = 332;
public const int QName = 333;
public const int yyErrorCode = 256;
}
namespace yyParser {
using System;
/** thrown for irrecoverable syntax errors and stack overflow.
*/
internal class yyException : System.Exception {
public yyException (string message) : base (message) {
}
}
internal class yyUnexpectedEof : yyException {
public yyUnexpectedEof (string message) : base (message) {
}
public yyUnexpectedEof () : base ("") {
}
}
/** must be implemented by a scanner object to supply input to the parser.
*/
internal interface yyInput {
/** move on to next token.
@return false if positioned beyond tokens.
@throws IOException on input error.
*/
bool advance (); // throws java.io.IOException;
/** classifies current token.
Should not be called if advance() returned false.
@return current %token or single character.
*/
int token ();
/** associated with current token.
Should not be called if advance() returned false.
@return value for token().
*/
Object value ();
}
}
} // close outermost namespace, that MUST HAVE BEEN opened in the prolog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment