XPathParser { protected StepExpression parseStepExpr( TokenStream tokens ) { KindTest kindTest = parseKindTest(tokens); if (kindTest != null) { List<Component> predicates = parsePredicates(tokens); return new AxisStep(kindTest, predicates); } if (tokens.matches('(') || tokens.matches('.') || tokens.matches(XPathTokenizer.QUOTED_STRING) || tokens.matches(ANY_VALUE, "(") || tokens.matches(ANY_VALUE, ":", ANY_VALUE, "(")) { return parseFilterExpr(tokens); } AxisStep result = parseAxisStep(tokens); if (result != null) return result; return parseFilterExpr(tokens); } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }
@Test public void shouldParseStepExpressionFromParenthesizedLiteral() { assertThat(parser.parseStepExpr(tokenize("('foo')")), is((StepExpression)filterStep(paren(literal("foo"))))); }
@Test public void shouldParseStepExpressionFromQuotedStringLiteral() { assertThat(parser.parseStepExpr(tokenize("'foo'")), is((StepExpression)filterStep(literal("foo")))); }
@Test public void shouldParseStepExpressionFromFunctionCallWithUnqualifiedName() { assertThat(parser.parseStepExpr(tokenize("element2(*,*)")), is((StepExpression)filterStep(functionCall(nameTest("element2"), wildcard(), wildcard())))); }
@Test public void shouldParseStepExpressionFromFunctionCallWithQualifiedName() { assertThat(parser.parseStepExpr(tokenize("foo:bar(*)")), is((StepExpression)filterStep(functionCall(nameTest("foo", "bar"), wildcard())))); }
@Test public void shouldParseStepExpressionFromQualifiedNameWithPredicate() { assertThat(parser.parseStepExpr(tokenize("foo:bar[3]")), is((StepExpression)axisStep(nameTest("foo", "bar"), literal("3")))); }