// --------------- Helper methods ---------------------- private void CheckToken(XPathScanner.LexKind t) { if (_scanner.Kind != t) { throw XPathException.Create(SR.Xp_InvalidToken, _scanner.SourceText); } }
// --------------- Helper methods ---------------------- void CheckToken(XPathScanner.LexKind t) { if (this.scanner.Kind != t) { throw XPathException.Create(Res.Xp_InvalidToken, this.scanner.SourceText); } }
// --------------- Helper methods ---------------------- void CheckToken(XPathScanner.LexKind t) { if (this.scanner.Kind != t) { throw new XPathException(String.Format("'{0}' has an invalid token.", this.scanner.SourceText)); } }
private static bool IsStep(XPathScanner.LexKind lexKind) { if ((((lexKind != XPathScanner.LexKind.Dot) && (lexKind != XPathScanner.LexKind.DotDot)) && ((lexKind != XPathScanner.LexKind.At) && (lexKind != XPathScanner.LexKind.Axe))) && (lexKind != XPathScanner.LexKind.Star)) { return(lexKind == XPathScanner.LexKind.Name); } return(true); }
private static bool IsStep(XPathScanner.LexKind lexKind) { return( lexKind == XPathScanner.LexKind.Dot || lexKind == XPathScanner.LexKind.DotDot || lexKind == XPathScanner.LexKind.At || lexKind == XPathScanner.LexKind.Axe || lexKind == XPathScanner.LexKind.Star || lexKind == XPathScanner.LexKind.Name // NodeTest is also Name ); }
private AstNode ParsePrimaryExpr(AstNode qyInput) { AstNode groupNode = null; XPathScanner.LexKind kind = this.scanner.Kind; if (kind <= XPathScanner.LexKind.LParens) { switch (kind) { case XPathScanner.LexKind.Dollar: this.NextLex(); this.CheckToken(XPathScanner.LexKind.Name); groupNode = new Variable(this.scanner.Name, this.scanner.Prefix); this.NextLex(); return(groupNode); case XPathScanner.LexKind.LParens: this.NextLex(); groupNode = this.ParseExpresion(qyInput); if (groupNode.Type != AstNode.AstType.ConstantOperand) { groupNode = new Group(groupNode); } this.PassToken(XPathScanner.LexKind.RParens); return(groupNode); } return(groupNode); } if (kind != XPathScanner.LexKind.Number) { if (kind != XPathScanner.LexKind.Name) { if (kind == XPathScanner.LexKind.String) { groupNode = new Operand(this.scanner.StringValue); this.NextLex(); } return(groupNode); } if (this.scanner.CanBeFunction && !IsNodeType(this.scanner)) { groupNode = this.ParseMethod(null); } return(groupNode); } groupNode = new Operand(this.scanner.NumberValue); this.NextLex(); return(groupNode); }
private AstNode ParseNodeTest(AstNode qyInput, Axis.AxisType axisType, XPathNodeType nodeType) { string stringValue; string prefix; XPathScanner.LexKind kind = this.scanner.Kind; if (kind != XPathScanner.LexKind.Star) { if (kind != XPathScanner.LexKind.Name) { throw XPathException.Create("Xp_NodeSetExpected", this.scanner.SourceText); } if (this.scanner.CanBeFunction && IsNodeType(this.scanner)) { prefix = string.Empty; stringValue = string.Empty; nodeType = (this.scanner.Name == "comment") ? XPathNodeType.Comment : ((this.scanner.Name == "text") ? XPathNodeType.Text : ((this.scanner.Name == "node") ? XPathNodeType.All : ((this.scanner.Name == "processing-instruction") ? XPathNodeType.ProcessingInstruction : XPathNodeType.Root))); this.NextLex(); this.PassToken(XPathScanner.LexKind.LParens); if ((nodeType == XPathNodeType.ProcessingInstruction) && (this.scanner.Kind != XPathScanner.LexKind.RParens)) { this.CheckToken(XPathScanner.LexKind.String); stringValue = this.scanner.StringValue; this.NextLex(); } this.PassToken(XPathScanner.LexKind.RParens); } else { prefix = this.scanner.Prefix; stringValue = this.scanner.Name; this.NextLex(); if (stringValue == "*") { stringValue = string.Empty; } } } else { prefix = string.Empty; stringValue = string.Empty; this.NextLex(); } return(new Axis(axisType, qyInput, prefix, stringValue, nodeType)); }
private AstNode ParseLocationPathPattern(AstNode qyInput) { AstNode input = null; switch (this.scanner.Kind) { case XPathScanner.LexKind.Slash: this.NextLex(); input = new Root(); if ((this.scanner.Kind == XPathScanner.LexKind.Eof) || (this.scanner.Kind == XPathScanner.LexKind.Union)) { return(input); } break; case XPathScanner.LexKind.SlashSlash: this.NextLex(); input = new Axis(Axis.AxisType.DescendantOrSelf, new Root()); break; case XPathScanner.LexKind.Name: if (this.scanner.CanBeFunction) { input = this.ParseIdKeyPattern(qyInput); if (input != null) { XPathScanner.LexKind kind = this.scanner.Kind; if (kind != XPathScanner.LexKind.Slash) { if (kind != XPathScanner.LexKind.SlashSlash) { return(input); } this.NextLex(); input = new Axis(Axis.AxisType.DescendantOrSelf, input); break; } this.NextLex(); } } break; } return(this.ParseRelativePathPattern(input)); }
private void PassToken(XPathScanner.LexKind t) { CheckToken(t); NextLex(); }
void NextLex(XPathScanner.LexKind t) { Debug.Assert(this.scanner.Kind == t); NextLex(); }
private void PassToken(XPathScanner.LexKind t) { this.CheckToken(t); this.NextLex(); }