📄 javacc.jj
字号:
ConditionalExpression() [ AssignmentOperator() Expression(new java.util.Vector()) ] { Token last = getToken(0); Token t = first; while (true) { tokens.addElement(t); if (t == last) break; t = t.next; } }}void AssignmentOperator() :{}{ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|="| OtherAssignmentOps()}void ConditionalExpression() :{}{ ConditionalOrExpression() [ "?" Expression(new java.util.Vector()) ":" ConditionalExpression() ]}void ConditionalOrExpression() :{}{ ConditionalAndExpression() ( "||" ConditionalAndExpression() )*}void ConditionalAndExpression() :{}{ InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*}void InclusiveOrExpression() :{}{ ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*}void ExclusiveOrExpression() :{}{ AndExpression() ( "^" AndExpression() )*}void AndExpression() :{}{ EqualityExpression() ( "&" EqualityExpression() )*}void EqualityExpression() :{}{ InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*}void InstanceOfExpression() :{}{ RelationalExpression() [ "instanceof" Type() ]}void RelationalExpression() :{}{ /* * The lookahead of 2 below is due to the fact that we have split * the shift and shift assignment operator into multiple tokens that * now clash with these tokens. */ ShiftExpression() ( LOOKAHEAD(2) ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*}void ShiftExpression() :{}{ /* * The lookahead of 2 below is due to the fact that we have split * the shift and shift assignment operator into multiple tokens that * now clash with these tokens and the relational operators. */ AdditiveExpression() ( LOOKAHEAD(2) ( ShiftOps() ) AdditiveExpression() )*}void AdditiveExpression() :{}{ MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*}void MultiplicativeExpression() :{}{ UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*}void UnaryExpression() :{}{ ( "+" | "-" ) UnaryExpression()| PreIncrementExpression()| PreDecrementExpression()| UnaryExpressionNotPlusMinus()}void PreIncrementExpression() :{}{ "++" PrimaryExpression()}void PreDecrementExpression() :{}{ "--" PrimaryExpression()}void UnaryExpressionNotPlusMinus() :{}{ ( "~" | "!" ) UnaryExpression()| LOOKAHEAD( CastLookahead() ) CastExpression()| PostfixExpression()}// This production is to determine lookahead only. The LOOKAHEAD specifications// below are not used, but they are there just to indicate that we know about// this.void CastLookahead() :{}{ LOOKAHEAD(2) "(" PrimitiveType()| LOOKAHEAD("(" Name(new java.util.Vector()) "[") "(" Name(new java.util.Vector()) "[" "]"| "(" Name(new java.util.Vector()) ")" ( "~" | "!" | "(" | JavaIdentifier() | "this" | "super" | "new" | Literal() )}void PostfixExpression() :{}{ PrimaryExpression() [ "++" | "--" ]}void CastExpression() :{}{ LOOKAHEAD("(" PrimitiveType()) "(" Type() ")" UnaryExpression()| LOOKAHEAD("(" Name(new java.util.Vector())) "(" Type() ")" UnaryExpressionNotPlusMinus()}void PrimaryExpression() :{}{ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*}void PrimaryPrefix() :{}{ Literal()| "this"| "super" "." JavaIdentifier()| "(" Expression(new java.util.Vector()) ")"| AllocationExpression()| LOOKAHEAD( ResultType(new java.util.Vector()) "." "class" ) ResultType(new java.util.Vector()) "." "class"| Name(new java.util.Vector())}void PrimarySuffix() :{}{ LOOKAHEAD(2) "." "this"| LOOKAHEAD(2) "." AllocationExpression()| "[" Expression(new java.util.Vector()) "]"| "." JavaIdentifier()| Arguments(new java.util.Vector())}void Literal() :{}{ <INTEGER_LITERAL>| <FLOATING_POINT_LITERAL>| <CHARACTER_LITERAL>| <STRING_LITERAL>| BooleanLiteral()| NullLiteral()}int IntegerLiteral() :{}{ <INTEGER_LITERAL> { try { return Integer.parseInt(token.image); } catch (NumberFormatException e) { throw new Error(); } }}boolean BooleanLiteral() :{}{ "true" { return true; }| "false" { return false; }}String StringLiteral() : { Token t; }{ t=<STRING_LITERAL> { return remove_escapes_and_quotes(t, t.image); }}void NullLiteral() :{}{ "null"}void Arguments(java.util.Vector tokens) :/* * Parsing this fills "tokens" with all tokens of the arguments * excluding the parentheses at each end. */ { Token first, last; }{ "(" { first = getToken(1); } [ ArgumentList() ] { last = getToken(0); } ")" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.addElement(t); if (t == last) break; t = t.next; } } }}void ArgumentList() :{}{ Expression(new java.util.Vector()) ( "," Expression(new java.util.Vector()) )*}void AllocationExpression() :{}{ LOOKAHEAD(2) "new" PrimitiveType() ArrayDimsAndInits()| "new" Name(new java.util.Vector()) ( ArrayDimsAndInits() | Arguments(new java.util.Vector()) [ ClassBody(new java.util.Vector()) ] )}/* * The second LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */void ArrayDimsAndInits() :{}{ LOOKAHEAD(2) ( LOOKAHEAD(2) "[" Expression(new java.util.Vector()) "]" )+ ( LOOKAHEAD(2) "[" "]" )*| ( "[" "]" )+ ArrayInitializer()}/* * Statement syntax follows. */void Statement() :{}{ LOOKAHEAD(2) LabeledStatement()| Block(new java.util.Vector())| EmptyStatement()| StatementExpression() ";"| SwitchStatement()| IfStatement()| WhileStatement()| DoStatement()| ForStatement()| BreakStatement()| ContinueStatement()| ReturnStatement()| ThrowStatement()| SynchronizedStatement()| TryStatement()}void LabeledStatement() :{}{ JavaIdentifier() ":" Statement()}void Block(java.util.Vector tokens) :/* * Parsing this fills "tokens" with all tokens of the block * excluding the braces at each end. */ { Token first, last; }{ "{" { first = getToken(1); } ( BlockStatement() )* { last = getToken(0); } "}" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.addElement(t); if (t == last) break; t = t.next; } } }}void BlockStatement() :{}{ LOOKAHEAD([ "final" ] Type() JavaIdentifier()) LocalVariableDeclaration() ";"| Statement()| UnmodifiedClassDeclaration()}void LocalVariableDeclaration() :{}{ [ "final" ] Type() VariableDeclarator() ( "," VariableDeclarator() )*}void EmptyStatement() :{}{ ";"}void StatementExpression() :/* * The last expansion of this production accepts more than the legal * Java expansions for StatementExpression. This expansion does not * use PostfixExpression for performance reasons. */{}{ PreIncrementExpression()| PreDecrementExpression()| PrimaryExpression() [ "++" | "--" | AssignmentOperator() Expression(new java.util.Vector()) ]}void SwitchStatement() :{}{ "switch" "(" Expression(new java.util.Vector()) ")" "{" ( SwitchLabel() ( BlockStatement() )* )* "}"}void SwitchLabel() :{}{ "case" Expression(new java.util.Vector()) ":"| "default" ":"}void IfStatement() :/* * The disambiguating algorithm of JavaCC automatically binds dangling * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */{}{ "if" "(" Expression(new java.util.Vector()) ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]}void WhileStatement() :{}{ "while" "(" Expression(new java.util.Vector()) ")" Statement()}void DoStatement() :{}{ "do" Statement() "while" "(" Expression(new java.util.Vector()) ")" ";"}void ForStatement() :{}{ "for" "(" [ ForInit() ] ";" [ Expression(new java.util.Vector()) ] ";" [ ForUpdate() ] ")" Statement()}void ForInit() :{}{ LOOKAHEAD( [ "final" ] Type() JavaIdentifier() ) LocalVariableDeclaration()| StatementExpressionList()}void StatementExpressionList() :{}{ StatementExpression() ( "," StatementExpression() )*}void ForUpdate() :{}{ StatementExpressionList()}void BreakStatement() :{}{ "break" [ JavaIdentifier() ] ";"}void ContinueStatement() :{}{ "continue" [ JavaIdentifier() ] ";"}void ReturnStatement() : { Token t; }{ t="return" { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) return"; jumpPatched = true; } } [ Expression(new java.util.Vector()) ] t=";" { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } }}void ThrowStatement() : { Token t; }{ t="throw" { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) throw"; jumpPatched = true; } } Expression(new java.util.Vector()) t=";" { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } }}void SynchronizedStatement() :{}{ "synchronized" "(" Expression(new java.util.Vector()) ")" Block(new java.util.Vector())}void TryStatement() :/* * Semantic check required here to make sure that at least one * finally/catch is present. */{}{ "try" Block(new java.util.Vector()) ( "catch" "(" FormalParameter() ")" Block(new java.util.Vector()) )* [ "finally" Block(new java.util.Vector()) ]}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -