/* * StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* * ChildOrAttributeAxisSpecifier ::= @ ? | ('child' | 'attribute') '::' */ private QilNode ParseStepPattern() { QilNode opnd; XPathAxis axis; switch (scanner.Kind) { case LexKind.Dot: case LexKind.DotDot: throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); case LexKind.At: //>> '@' axis = XPathAxis.Attribute; scanner.NextLex(); break; case LexKind.Axis: //>> AxisName '::' axis = XPathParser.GetAxis(scanner.Name, scanner); if (axis != XPathAxis.Child && axis != XPathAxis.Attribute) { throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); } scanner.NextLex(); break; case LexKind.Name: case LexKind.Star: // NodeTest must start with Name or '*' axis = XPathAxis.Child; break; default: throw scanner.CreateException(Res.XPath_UnexpectedToken, scanner.RawValue); } XPathNodeType nodeType; string nodePrefix, nodeName; XPathParser.InternalParseNodeTest(scanner, axis, out nodeType, out nodePrefix, out nodeName); opnd = ptrnBuilder.Axis(axis, nodeType, nodePrefix, nodeName); while (scanner.Kind == LexKind.LBracket) { opnd = ptrnBuilder.Predicate(opnd, ParsePredicate(opnd), /*reverseStep:*/ false); } return(opnd); }