public ExpressionsParser(ParserGroup group) { this.actions = new ExpressionsActions(group.getSource()); this.group = group; }
Rule assignmentLHS() { return Sequence( level1ExpressionChaining(), set(), actions.checkIfLevel1ExprIsValidForAssignment(value())); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/arrays.html#10.3">JLS section 10.3</a> * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.10">JLS section 15.10</a> */ Rule arrayCreationExpression() { return Sequence( String("new"), group.basics.testLexBreak(), group.basics.optWS(), group.types.nonArrayType().label("type"), OneOrMore(Sequence( Ch('[').label("openArray"), group.basics.optWS(), Optional(anyExpression()).label("dimension"), Ch(']'), group.basics.optWS(), set(actions.createDimension(value("dimension"), node("openArray"))))), Optional(arrayInitializer()).label("initializer"), set(actions.createArrayCreationExpression(value("type"), values("OneOrMore/Sequence"), value("initializer")))); }
/** * P2'' * * This is the relational new operator; not just 'new', but new with context, so: "a.new InnerClass(params)". It is grouped with P2, but for some reason has higher precedence * in all java parsers, and so we give it its own little precedence group here. */ Rule dotNewExpressionChaining() { return Sequence( level1ExpressionChaining().label("head"), set(), ZeroOrMore(Sequence( Sequence( Ch('.'), group.basics.optWS(), String("new"), group.basics.testLexBreak(), group.basics.optWS()), group.types.typeArguments().label("constructorTypeArgs"), group.basics.identifier().label("innerClassName"), group.types.typeArguments().label("classTypeArgs"), group.structures.methodArguments().label("methodArguments"), Optional(group.structures.typeBody()).label("classBody"), set(actions.createQualifiedConstructorInvocation(value("constructorTypeArgs"), node("innerClassName"), node("classTypeArgs"), value("methodArguments"), value("classBody"))))), set(actions.createChainOfQualifiedConstructorInvocations(node("head"), nodes("ZeroOrMore/Sequence")))); }
Rule assignmentExpression() { return Sequence( assignmentLHS(), set(), assignmentOperator().label("operator"), group.basics.optWS(), assignmentExpressionChaining().label("RHS"), set(actions.createAssignmentExpression(value(), text("operator"), lastValue()))); }
/** * @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 arrayAccessOperation() { return Sequence( Ch('['), group.basics.optWS(), anyExpression(), set(), Ch(']'), group.basics.optWS(), set(actions.createArrayAccessOperation(value()))); }
Rule parenGrouping() { return Sequence( Ch('('), group.basics.optWS(), anyExpression(), set(), Ch(')'), set(actions.addParens(value())), group.basics.optWS()); }
public Rule arrayInitializer() { return Sequence( Ch('{'), group.basics.optWS(), Optional(Sequence( FirstOf(arrayInitializer(), anyExpression()).label("head"), ZeroOrMore(Sequence( Ch(','), group.basics.optWS(), FirstOf(arrayInitializer(), anyExpression()).label("tail"))), Optional(Ch(',')), group.basics.optWS())), Ch('}'), group.basics.optWS(), set(actions.createArrayInitializerExpression(value("Optional/Sequence/head"), values("Optional/Sequence/ZeroOrMore/Sequence/tail")))); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/arrays.html#10.3">JLS section 10.3</a> * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.10">JLS section 15.10</a> */ Rule arrayCreationExpression() { return Sequence( String("new"), group.basics.testLexBreak(), group.basics.optWS(), group.types.nonArrayType().label("type"), OneOrMore(Sequence( Ch('[').label("openArray"), group.basics.optWS(), Optional(anyExpression()).label("dimension"), Ch(']'), group.basics.optWS(), set(actions.createDimension(value("dimension"), node("openArray"))))), Optional(arrayInitializer()).label("initializer"), set(actions.createArrayCreationExpression(value("type"), values("OneOrMore/Sequence"), value("initializer")))); }
/** * P2'' * * This is the relational new operator; not just 'new', but new with context, so: "a.new InnerClass(params)". It is grouped with P2, but for some reason has higher precedence * in all java parsers, and so we give it its own little precedence group here. */ Rule dotNewExpressionChaining() { return Sequence( level1ExpressionChaining().label("head"), set(), ZeroOrMore(Sequence( Sequence( Ch('.'), group.basics.optWS(), String("new"), group.basics.testLexBreak(), group.basics.optWS()), group.types.typeArguments().label("constructorTypeArgs"), group.basics.identifier().label("innerClassName"), group.types.typeArguments().label("classTypeArgs"), group.structures.methodArguments().label("methodArguments"), Optional(group.structures.typeBody()).label("classBody"), set(actions.createQualifiedConstructorInvocation(value("constructorTypeArgs"), node("innerClassName"), node("classTypeArgs"), value("methodArguments"), value("classBody"))))), set(actions.createChainOfQualifiedConstructorInvocations(node("head"), nodes("ZeroOrMore/Sequence")))); }
Rule assignmentExpression() { return Sequence( assignmentLHS(), set(), assignmentOperator().label("operator"), group.basics.optWS(), assignmentExpressionChaining().label("RHS"), set(actions.createAssignmentExpression(value(), text("operator"), lastValue()))); }
/** * @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 arrayAccessOperation() { return Sequence( Ch('['), group.basics.optWS(), anyExpression(), set(), Ch(']'), group.basics.optWS(), set(actions.createArrayAccessOperation(value()))); }
Rule parenGrouping() { return Sequence( Ch('('), group.basics.optWS(), anyExpression(), set(), Ch(')'), set(actions.addParens(value())), group.basics.optWS()); }
public Rule arrayInitializer() { return Sequence( Ch('{'), group.basics.optWS(), Optional(Sequence( FirstOf(arrayInitializer(), anyExpression()).label("head"), ZeroOrMore(Sequence( Ch(','), group.basics.optWS(), FirstOf(arrayInitializer(), anyExpression()).label("tail"))), Optional(Ch(',')), group.basics.optWS())), Ch('}'), group.basics.optWS(), set(actions.createArrayInitializerExpression(value("Optional/Sequence/head"), values("Optional/Sequence/ZeroOrMore/Sequence/tail")))); }
/** * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/arrays.html#10.3">JLS section 10.3</a> * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.10">JLS section 15.10</a> */ Rule arrayCreationExpression() { return Sequence( String("new"), group.basics.testLexBreak(), group.basics.optWS(), group.types.nonArrayType().label("type"), OneOrMore(Sequence( Ch('[').label("openArray"), group.basics.optWS(), Optional(anyExpression()).label("dimension"), Ch(']'), group.basics.optWS(), set(actions.createDimension(value("dimension"), node("openArray"))))), Optional(arrayInitializer()).label("initializer"), set(actions.createArrayCreationExpression(value("type"), values("OneOrMore/Sequence"), value("initializer")))); }
/** * P2'' * * This is the relational new operator; not just 'new', but new with context, so: "a.new InnerClass(params)". It is grouped with P2, but for some reason has higher precedence * in all java parsers, and so we give it its own little precedence group here. */ Rule dotNewExpressionChaining() { return Sequence( level1ExpressionChaining().label("head"), set(), ZeroOrMore(Sequence( Sequence( Ch('.'), group.basics.optWS(), String("new"), group.basics.testLexBreak(), group.basics.optWS()), group.types.typeArguments().label("constructorTypeArgs"), group.basics.identifier().label("innerClassName"), group.types.typeArguments().label("classTypeArgs"), group.structures.methodArguments().label("methodArguments"), Optional(group.structures.typeBody()).label("classBody"), set(actions.createQualifiedConstructorInvocation(value("constructorTypeArgs"), node("innerClassName"), node("classTypeArgs"), value("methodArguments"), value("classBody"))))), set(actions.createChainOfQualifiedConstructorInvocations(node("head"), nodes("ZeroOrMore/Sequence")))); }
Rule assignmentExpression() { return Sequence( assignmentLHS(), set(), assignmentOperator().label("operator"), group.basics.optWS(), assignmentExpressionChaining().label("RHS"), set(actions.createAssignmentExpression(value(), text("operator"), lastValue()))); }
/** * @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()))); }