@Override public boolean run(Context<Node> context) { setContext(context); return set(); } },
@Override public boolean run(Context<Node> context) { setContext(context); return set(); } },
@Override public boolean run(Context<Node> context) { setContext(context); return set(actions.createLeftAssociativeBinaryExpression( node("head"), nodes("ZeroOrMore/Sequence/operator"), texts("ZeroOrMore/Sequence/operator"), nodes("ZeroOrMore/Sequence/tail"))); } },
Rule assignmentLHS() { return Sequence( level1ExpressionChaining(), set(), actions.checkIfLevel1ExprIsValidForAssignment(value())); }
/** * P1 */ Rule level1ExpressionChaining() { return Sequence( primaryExpression().label("head"), set(), ZeroOrMore(FirstOf( arrayAccessOperation().label("arrayAccess"), methodInvocationWithTypeArgsOperation().label("methodInvocation"), select().label("select"))), set(actions.createLevel1Expression(node("head"), nodes("ZeroOrMore/FirstOf")))); }
/** * P2' * Technically, postfix increment operations are in P2 along with all the unary operators like ~ and !, as well as typecasts. * However, because ALL of the P2 expression are right-associative, the postfix operators can be considered as a higher level of precedence. */ Rule postfixIncrementExpressionChaining() { return Sequence( dotNewExpressionChaining(), set(), ZeroOrMore(Sequence( FirstOf(String("++"), String("--")).label("operator"), group.basics.optWS()).label("operatorCt")), set(actions.createUnaryPostfixExpression(value(), nodes("ZeroOrMore/operatorCt/operator"), texts("ZeroOrMore/operatorCt/operator")))); }
Rule select() { return Sequence( group.basics.dotIdentifier().label("identifier"), TestNot(Ch('(')), set(actions.createSelectOperation(value("identifier")))); }
/** * P1 */ Rule level1ExpressionChaining() { return Sequence( primaryExpression().label("head"), set(), ZeroOrMore(FirstOf( arrayAccessOperation().label("arrayAccess"), methodInvocationWithTypeArgsOperation().label("methodInvocation"), select().label("select"))), set(actions.createLevel1Expression(node("head"), nodes("ZeroOrMore/FirstOf")))); }
Rule prefixIncrementExpression() { return Sequence( OneOrMore(Sequence( FirstOf(String("++"), String("--")).label("operator"), group.basics.optWS()).label("operatorCt")), postfixIncrementExpressionChaining().label("operand"), set(), set(actions.createUnaryPrefixExpressions(node("operand"), nodes("OneOrMore/operatorCt/operator"), texts("OneOrMore/operatorCt/operator")))); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.8">JLS section 14.8</a> */ public Rule statementExpression() { return FirstOf( assignmentExpression(), postfixIncrementExpression(), prefixIncrementExpression(), Sequence(dotNewExpressionChaining(), set(), actions.checkIfMethodOrConstructorInvocation(value()))); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.8">JLS section 14.8</a> */ public Rule statementExpression() { return FirstOf( assignmentExpression(), postfixIncrementExpression(), prefixIncrementExpression(), Sequence(dotNewExpressionChaining(), set(), actions.checkIfMethodOrConstructorInvocation(value()))); }
Rule unqualifiedThisOrSuperLiteral() { return Sequence( FirstOf(String("this"), String("super")).label("thisOrSuper"), group.basics.testLexBreak(), group.basics.optWS(), TestNot(Ch('(')), set(actions.createThisOrSuperOrClass(null, text("thisOrSuper"), null))); }
Rule methodInvocationWithTypeArgsOperation() { return Sequence( Ch('.').label("dot"), group.basics.optWS(), group.types.typeArguments().label("typeArguments"), group.basics.identifier().label("name"), group.structures.methodArguments().label("methodArguments"), set(actions.createMethodInvocationOperation(node("dot"), value("typeArguments"), value("name"), value("methodArguments")))); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.8.2">JLS section 15.8.2</a> */ Rule qualifiedClassOrThisOrSuperLiteral() { return Sequence( group.types.type().label("type"), Ch('.').label("dot"), group.basics.optWS(), FirstOf(String("this"), String("super"), String("class")).label("thisOrSuperOrClass"), group.basics.testLexBreak(), group.basics.optWS(), set(actions.createThisOrSuperOrClass(node("dot"), text("thisOrSuperOrClass"), value("type")))); }
Rule unqualifiedConstructorInvocation() { return Sequence( String("new"), group.basics.testLexBreak(), group.basics.optWS(), group.types.typeArguments().label("constructorTypeArgs"), group.types.type().label("type"), group.structures.methodArguments().label("args"), Optional(group.structures.typeBody()).label("classBody"), set(actions.createUnqualifiedConstructorInvocation(value("constructorTypeArgs"), value("type"), value("args"), value("classBody")))); }