/** * P7 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.21">JLS section 15.21</a> */ Rule equalityExpressionChaining() { return forLeftAssociativeBinaryExpression("exprEquality", FirstOf(String("==="), String("!=="), String("=="), String("!=")), relationalExpressionChaining()); }
/** * P7 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.21">JLS section 15.21</a> */ Rule equalityExpressionChaining() { return forLeftAssociativeBinaryExpression("exprEquality", FirstOf(String("==="), String("!=="), String("=="), String("!=")), relationalExpressionChaining()); }
/** * P5 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.19">JLS section 15.19</a> */ Rule shiftExpressionChaining() { return forLeftAssociativeBinaryExpression("exprShift", FirstOf(String(">>>"), String("<<<"), String("<<"), String(">>")), additiveExpressionChaining()); }
/** * P7 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.21">JLS section 15.21</a> */ Rule equalityExpressionChaining() { return forLeftAssociativeBinaryExpression("exprEquality", FirstOf(String("==="), String("!=="), String("=="), String("!=")), relationalExpressionChaining()); }
/** * P11 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.23">JLS section 15.23</a> */ Rule conditionalAndExpressionChaining() { return forLeftAssociativeBinaryExpression("exprLogicalAnd", String("&&"), bitwiseOrExpressionChaining()); }
/** * P12' * * This is not a legal operator; however, it is entirely imaginable someone presumes it does exist. * It also has no other sensible meaning, so we will parse it and flag it as a syntax error in AST phase. */ Rule conditionalXorExpressionChaining() { return forLeftAssociativeBinaryExpression("exprLogicalXor", String("^^"), conditionalAndExpressionChaining()); }
/** * P12 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.24">JLS section 15.24</a> */ Rule conditionalOrExpressionChaining() { return forLeftAssociativeBinaryExpression("exprLogicalOr", String("||"), conditionalXorExpressionChaining()); }
/** * P12' * * This is not a legal operator; however, it is entirely imaginable someone presumes it does exist. * It also has no other sensible meaning, so we will parse it and flag it as a syntax error in AST phase. */ Rule conditionalXorExpressionChaining() { return forLeftAssociativeBinaryExpression("exprLogicalXor", String("^^"), conditionalAndExpressionChaining()); }
/** * P12 * * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#15.24">JLS section 15.24</a> */ Rule conditionalOrExpressionChaining() { return forLeftAssociativeBinaryExpression("exprLogicalOr", String("||"), conditionalXorExpressionChaining()); }
/** * @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")))); }
/** * 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 postfixIncrementExpression() { return Sequence( dotNewExpressionChaining(), set(), OneOrMore(Sequence( FirstOf(String("++"), String("--")).label("operator"), group.basics.optWS()).label("operatorCt")), set(actions.createUnaryPostfixExpression(value(), nodes("OneOrMore/operatorCt/operator"), texts("OneOrMore/operatorCt/operator")))); }
Rule postfixIncrementExpression() { return Sequence( dotNewExpressionChaining(), set(), OneOrMore(Sequence( FirstOf(String("++"), String("--")).label("operator"), group.basics.optWS()).label("operatorCt")), set(actions.createUnaryPostfixExpression(value(), nodes("OneOrMore/operatorCt/operator"), texts("OneOrMore/operatorCt/operator")))); }
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")))); }
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")))); }
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")))); }