📄 java1.5.jj
字号:
ReferenceType() | "?" [ WildcardBounds() ]}void WildcardBounds():{}{ "extends" ReferenceType() | "super" ReferenceType()}void PrimitiveType():{}{ "boolean"| "char"| "byte"| "short"| "int"| "long"| "float"| "double"}void ResultType():{}{ "void"| Type()}void Name():/* * A lookahead of 2 is required below since "Name" can be followed * by a ".*" when used in the context of an "ImportDeclaration". */{}{ <IDENTIFIER> ( LOOKAHEAD(2) "." <IDENTIFIER> )*}void NameList():{}{ Name() ( "," Name() )*}/* * Expression syntax follows. */void Expression():/* * This expansion has been written this way instead of: * Assignment() | ConditionalExpression() * for performance reasons. * However, it is a weakening of the grammar for it allows the LHS of * assignments to be any conditional expression whereas it can only be * a primary expression. Consider adding a semantic predicate to work * around this. */{}{ ConditionalExpression() [ LOOKAHEAD(2) AssignmentOperator() Expression() ]}void AssignmentOperator():{}{ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="}void ConditionalExpression():{}{ ConditionalOrExpression() [ "?" Expression() ":" Expression() ]}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():{}{ ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*}void ShiftExpression():{}{ AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) 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("(" Type() "[") "(" Type() "[" "]"| "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )}void PostfixExpression():{}{ PrimaryExpression() [ "++" | "--" ]}void CastExpression():{}{ LOOKAHEAD("(" PrimitiveType()) "(" Type() ")" UnaryExpression()| "(" Type() ")" UnaryExpressionNotPlusMinus()}void PrimaryExpression():{}{ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*}void MemberSelector():{}{ "." TypeArguments() <IDENTIFIER>}void PrimaryPrefix():{}{ Literal()| LOOKAHEAD( ( <IDENTIFIER> "." )* "this" ) ( <IDENTIFIER> "." )* "this"| "super" "." <IDENTIFIER>| // danson, added this part to support a construct like: // Buffer.super.setDirty(true); // See Java Language Specification, 3rd edition, section 15.11.2. LOOKAHEAD( ClassOrInterfaceType() "." "super" "." <IDENTIFIER> ) ClassOrInterfaceType() "." "super" "." <IDENTIFIER>| "(" Expression() ")"| AllocationExpression()| LOOKAHEAD( ResultType() "." "class" ) ResultType() "." "class"| Name()}void PrimarySuffix():{}{ LOOKAHEAD("." "super" ".") "." "super"| LOOKAHEAD("." "this") "." "this"| LOOKAHEAD(2) "." AllocationExpression()| LOOKAHEAD(3) MemberSelector()| "[" Expression() "]"| "." <IDENTIFIER>| Arguments()}void Literal():{}{ <INTEGER_LITERAL>| <FLOATING_POINT_LITERAL>| <CHARACTER_LITERAL>| <STRING_LITERAL>| BooleanLiteral()| NullLiteral()}void BooleanLiteral():{}{ "true"| "false"}void NullLiteral():{}{ "null"}void Arguments():{}{ "(" [ ArgumentList() ] ")"}void ArgumentList():{}{ Expression() ( "," Expression() )*}void AllocationExpression():{}{ LOOKAHEAD(2) "new" PrimitiveType() ArrayDimsAndInits()| "new" ClassOrInterfaceType() [ TypeArguments() ] ( ArrayDimsAndInits() | Arguments() [ ClassOrInterfaceBody(false) ] )}/* * The third LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */void ArrayDimsAndInits():{}{ LOOKAHEAD(2) ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*| ( "[" "]" )+ ArrayInitializer()}/* * Statement syntax follows. */void Statement():{}{ LOOKAHEAD(2) LabeledStatement()| AssertStatement()| Block()| EmptyStatement()| StatementExpression() ";"| SwitchStatement()| IfStatement()| WhileStatement()| DoStatement()| ForStatement()| BreakStatement()| ContinueStatement()| ReturnStatement()| ThrowStatement()| SynchronizedStatement()| TryStatement()}void AssertStatement():{}{ "assert" Expression() [ ":" Expression() ] ";"}void LabeledStatement():{}{ <IDENTIFIER> ":" Statement()}void Block():{}{ "{" ( BlockStatement() )* "}"}void BlockStatement():{}{ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) LocalVariableDeclaration() ";"| Statement()| ClassOrInterfaceDeclaration(0)}void LocalVariableDeclaration():{}{ Modifiers() 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() ]}void SwitchStatement():{}{ "switch" "(" Expression() ")" "{" ( SwitchLabel() ( BlockStatement() )* )* "}"}void SwitchLabel():{}{ "case" Expression() ":"| "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() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]}void WhileStatement():{}{ "while" "(" Expression() ")" Statement()}void DoStatement():{}{ "do" Statement() "while" "(" Expression() ")" ";"}void ForStatement():{}{ "for" "(" ( LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":") Modifiers() Type() <IDENTIFIER> ":" Expression() | [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ) ")" Statement()}void ForInit():{}{ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) LocalVariableDeclaration()| StatementExpressionList()}void StatementExpressionList():{}{ StatementExpression() ( "," StatementExpression() )*}void ForUpdate():{}{ StatementExpressionList()}void BreakStatement():{}{ "break" [ <IDENTIFIER> ] ";"}void ContinueStatement():{}{ "continue" [ <IDENTIFIER> ] ";"}void ReturnStatement():{}{ "return" [ Expression() ] ";"}void ThrowStatement():{}{ "throw" Expression() ";"}void SynchronizedStatement():{}{ "synchronized" "(" Expression() ")" Block()}void TryStatement():/* * Semantic check required here to make sure that at least one * finally/catch is present. */{}{ "try" Block() ( "catch" "(" FormalParameter() ")" Block() )* [ "finally" Block() ]}/* We use productions to match >>>, >> and > so that we can keep the * type declaration syntax with generics clean */void RUNSIGNEDSHIFT():{}{ ( LOOKAHEAD({ getToken(1).kind == GT && ((MyToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) ">" ">" ">" )}void RSIGNEDSHIFT():{}{ ( LOOKAHEAD({ getToken(1).kind == GT && ((MyToken)getToken(1)).realKind == RSIGNEDSHIFT} ) ">" ">" )}/* Annotation syntax follows. */void Annotation():{}{ LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) NormalAnnotation() | LOOKAHEAD( "@" Name() "(" ) SingleMemberAnnotation() | MarkerAnnotation()}void NormalAnnotation():{}{ "@" Name() "(" [ MemberValuePairs() ] ")"}void MarkerAnnotation():{}{ "@" Name()}void SingleMemberAnnotation():{}{ "@" Name() "(" MemberValue() ")"}void MemberValuePairs():{}{ MemberValuePair() ( "," MemberValuePair() )*}void MemberValuePair():{}{ <IDENTIFIER> "=" MemberValue()}void MemberValue():{}{ Annotation() | MemberValueArrayInitializer() | ConditionalExpression()}void MemberValueArrayInitializer():{}{ "{" (MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ])? "}"}/* Annotation Types. */void AnnotationTypeDeclaration(int modifiers):{}{ "@" "interface" <IDENTIFIER> AnnotationTypeBody()}void AnnotationTypeBody():{}{ "{" ( AnnotationTypeMemberDeclaration() )* "}"}void AnnotationTypeMemberDeclaration():{ int modifiers;}{ modifiers = Modifiers() ( LOOKAHEAD(Type() <IDENTIFIER> "(") Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" | ClassOrInterfaceDeclaration(modifiers) | EnumDeclaration(modifiers) | AnnotationTypeDeclaration(modifiers) | FieldDeclaration(modifiers) ) | ( ";" )}void DefaultValue():{}{ "default" MemberValue()}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -