您的位置:无忧脚本 » winter的个人空间 » 日志
[java从0开始](X1)语法表
Identifier:
IDENTIFIER
QualifiedIdentifier:
Identifier { . Identifier }
Literal:
IntegerLiteral
FloatingPointLiteral
CharacterLiteral
StringLiteral
BooleanLiteral
NullLiteral
Expression:
Expression1 [AssignmentOperator Expression1]]
AssignmentOperator:
=
+=
-=
*=
/=
&=
|=
^=
%=
<<=
>>=
>>>=
Type:
Identifier [TypeArguments]{ . Identifier [TypeArguments]} {[]}
BasicType
TypeArguments:
< TypeArgument {, TypeArgument} >
TypeArgument:
Type
StatementExpression:
Expression
ConstantExpression:
Expression
Expression1:
Expression2 [Expression1Rest]
Expression1Rest:
? Expression : Expression1
Expression2 :
Expression3 [Expression2Rest]
Expression2Rest:
{InfixOp Expression3}
Expression3 instanceof Type
InfixOp:
||
&&
|
^
&
==
!=
<
>
<=
>=
<<
>>
>>>
+
-
*
/
%
Expression3:
PrefixOp Expression3
( Expression | Type ) Expression3
Primary {Selector} {PostfixOp}
Primary:
ParExpression
NonWildcardTypeArguments (ExplicitGenericInvocationSuffix |
Arguments)
Literal
Identifier { . Identifier }[ IdentifierSuffix]
BasicType {[]} .
IdentifierSuffix:
[ ( ] {[]} .
Arguments
. (
[NonWildcardTypeArguments] InnerCreator )
ExplicitGenericInvocation:
NonWildcardTypeArguments ExplicitGenericInvocationSuffix
NonWildcardTypeArguments:
< TypeList >
ExplicitGenericInvocationSuffix:
Identifier Arguments
PrefixOp:
++
--
!
~
+
-
PostfixOp:
++
--
Selector: Selector:
. Identifier [Arguments]
. ExplicitGenericInvocation
.
.
[ Expression ]
SuperSuffix:
Arguments
. Identifier [Arguments]
BasicType:
Arguments:
( [Expression { , Expression }] )
Creator:
[NonWildcardTypeArguments] CreatedName ( ArrayCreatorRest |
ClassCreatorRest )
CreatedName:
Identifier [NonWildcardTypeArguments] {. Identifier
[NonWildcardTypeArguments]}
InnerCreator:
Identifier ClassCreatorRest
ArrayCreatorRest:
[ ( ] {[]} ArrayInitializer | Expression ] {[ Expression ]} {[]} )
ClassCreatorRest:
Arguments [ClassBody]
ArrayInitializer:
{ [VariableInitializer {, VariableInitializer} [,]] }
VariableInitializer:
ArrayInitializer
Expression
ParExpression:
( Expression )
Block:
{ BlockStatements }
BlockStatements:
{ BlockStatement }
BlockStatement :
LocalVariableDeclarationStatement
ClassOrInterfaceDeclaration
[Identifier :] Statement
LocalVariableDeclarationStatement:
[
Statement:
Block
;
StatementExpression ;
Identifier : Statement
Catches:
CatchClause {CatchClause}
CatchClause:
SwitchBlockStatementGroups:
{ SwitchBlockStatementGroup }
SwitchBlockStatementGroup:
SwitchLabel BlockStatements
SwitchLabel:
case EnumConstantName :
default :
MoreStatementExpressions:
{
ForControl:
ForVarControl
ForInit; [Expression] ; [ForUpdate]
ForVarControl
[
Annotations:
Annotation [Annotations]
Annotation:
ElementValue:
ConditionalExpression
Annotation
ElementValueArrayInitializer
ConditionalExpression:
Expression2 Expression1Rest
ElementValueArrayInitializer:
ElementValues:
ElementValue [ElementValues]
ForVarControlRest:
VariableDeclaratorsRest; [Expression] ; [ForUpdate]
ForInit:
StatementExpression Expressions
Modifier:
VariableDeclarators:
VariableDeclarator { , VariableDeclarator }
VariableDeclaratorsRest:
VariableDeclaratorRest { , VariableDeclarator }
ConstantDeclaratorsRest:
ConstantDeclaratorRest { , ConstantDeclarator }
VariableDeclarator:
Identifier VariableDeclaratorRest
ConstantDeclarator:
Identifier ConstantDeclaratorRest
VariableDeclaratorRest:
{[]} [ = VariableInitializer]
ConstantDeclaratorRest:
{[]} = VariableInitializer
VariableDeclaratorId:
Identifier {[]}
CompilationUnit:
[[Annotations]
{TypeDeclaration}
ImportDeclaration:
TypeDeclaration:
ClassOrInterfaceDeclaration
;
ClassOrInterfaceDeclaration:
{Modifier} (ClassDeclaration | InterfaceDeclaration)
ClassDeclaration:
NormalClassDeclaration
EnumDeclaration
NormalClassDeclaration:
ClassBody
TypeParameters:
< TypeParameter {, TypeParameter} >
TypeParameter:
Identifier [extends Bound]
Bound:
Type {& Type}
EnumDeclaration:
enum Identifier [
EnumBody:
{ [EnumConstants] [,] [EnumBodyDeclarations] }
EnumConstants:
EnumConstant
EnumConstants , EnumConstant
EnumConstant:
Annotations Identifier [Arguments] [ClassBody]
EnumBodyDeclarations:
; {ClassBodyDeclaration}
InterfaceDeclaration:
NormalInterfaceDeclaration
AnnotationTypeDeclaration
NormalInterfaceDeclaration:
TypeList:
Type { , Type}
AnnotationTypeDeclaration:
@ interface Identifier AnnotationTypeBody
AnnotationTypeBody:
{ [AnnotationTypeElementDeclarations] }
AnnotationTypeElementDeclarations:
AnnotationTypeElementDeclaration
AnnotationTypeElementDeclarations AnnotationTypeElementDeclaration
AnnotationTypeElementDeclaration:
{Modifier} AnnotationTypeElementRest
AnnotationTypeElementRest:
Type Identifier AnnotationMethodOrConstantRest;
ClassDeclaration
InterfaceDeclaration
EnumDeclaration
AnnotationTypeDeclaration
AnnotationMethodOrConstantRest:
AnnotationMethodRest
AnnotationConstantRest
AnnotationMethodRest:
( ) [DefaultValue]
AnnotationConstantRest:
VariableDeclarators
DefaultValue:
ClassBody:
{ {ClassBodyDeclaration} }
InterfaceBody:
{ {InterfaceBodyDeclaration} }
ClassBodyDeclaration:
;
[
{Modifier} MemberDecl
MemberDecl:
GenericMethodOrConstructorDecl
MethodOrFieldDecl
Identifier ConstructorDeclaratorRest
InterfaceDeclaration
ClassDeclaration
GenericMethodOrConstructorDecl:
TypeParameters GenericMethodOrConstructorRest
GenericMethodOrConstructorRest:
(Type |
Identifier ConstructorDeclaratorRest
MethodOrFieldDecl:
Type Identifier MethodOrFieldRest
MethodOrFieldRest:
VariableDeclaratorRest
MethodDeclaratorRest
InterfaceBodyDeclaration:
;
{Modifier} InterfaceMemberDecl
InterfaceMemberDecl:
InterfaceMethodOrFieldDecl
InterfaceGenericMethodDecl
InterfaceDeclaration
ClassDeclaration
InterfaceMethodOrFieldDecl:
Type Identifier InterfaceMethodOrFieldRest
InterfaceMethodOrFieldRest:
ConstantDeclaratorsRest ;
InterfaceMethodDeclaratorRest
MethodDeclaratorRest:
FormalParameters {[]} [
)
VoidMethodDeclaratorRest:
FormalParameters [
InterfaceMethodDeclaratorRest:
FormalParameters {[]} [
InterfaceGenericMethodDecl:
TypeParameters (Type |
VoidInterfaceMethodDeclaratorRest:
FormalParameters [
ConstructorDeclaratorRest:
FormalParameters [
QualifiedIdentifierList:
QualifiedIdentifier { , QualifiedIdentifier}
FormalParameters:
( [FormalParameterDecls] )
FormalParameterDecls:
[
FormalParameterDeclsRest:
VariableDeclaratorId [ , FormalParameterDecls]
MethodBody:
Block
EnumConstantName:
Identifier
IDENTIFIER
QualifiedIdentifier:
Identifier { . Identifier }
Literal:
IntegerLiteral
FloatingPointLiteral
CharacterLiteral
StringLiteral
BooleanLiteral
NullLiteral
Expression:
Expression1 [AssignmentOperator Expression1]]
AssignmentOperator:
=
+=
-=
*=
/=
&=
|=
^=
%=
<<=
>>=
>>>=
Type:
Identifier [TypeArguments]{ . Identifier [TypeArguments]} {[]}
BasicType
TypeArguments:
< TypeArgument {, TypeArgument} >
TypeArgument:
Type
? [( extends |super ) Type]StatementExpression:
Expression
ConstantExpression:
Expression
Expression1:
Expression2 [Expression1Rest]
Expression1Rest:
? Expression : Expression1
Expression2 :
Expression3 [Expression2Rest]
Expression2Rest:
{InfixOp Expression3}
Expression3 instanceof Type
InfixOp:
||
&&
|
^
&
==
!=
<
>
<=
>=
<<
>>
>>>
+
-
*
/
%
Expression3:
PrefixOp Expression3
( Expression | Type ) Expression3
Primary {Selector} {PostfixOp}
Primary:
ParExpression
NonWildcardTypeArguments (ExplicitGenericInvocationSuffix |
thisArguments)
this [Arguments] super SuperSuffixLiteral
new CreatorIdentifier { . Identifier }[ IdentifierSuffix]
BasicType {[]} .
class
void.class
IdentifierSuffix:
[ ( ] {[]} .
class | Expression ])Arguments
. (
class | ExplicitGenericInvocation | this | super Arguments | new[NonWildcardTypeArguments] InnerCreator )
ExplicitGenericInvocation:
NonWildcardTypeArguments ExplicitGenericInvocationSuffix
NonWildcardTypeArguments:
< TypeList >
ExplicitGenericInvocationSuffix:
super SuperSuffixIdentifier Arguments
PrefixOp:
++
--
!
~
+
-
PostfixOp:
++
--
Selector: Selector:
. Identifier [Arguments]
. ExplicitGenericInvocation
.
this
. super SuperSuffix.
new [NonWildcardTypeArguments] InnerCreator[ Expression ]
SuperSuffix:
Arguments
. Identifier [Arguments]
BasicType:
byte short char int long float double boolean
Arguments:
( [Expression { , Expression }] )
Creator:
[NonWildcardTypeArguments] CreatedName ( ArrayCreatorRest |
ClassCreatorRest )
CreatedName:
Identifier [NonWildcardTypeArguments] {. Identifier
[NonWildcardTypeArguments]}
InnerCreator:
Identifier ClassCreatorRest
ArrayCreatorRest:
[ ( ] {[]} ArrayInitializer | Expression ] {[ Expression ]} {[]} )
ClassCreatorRest:
Arguments [ClassBody]
ArrayInitializer:
{ [VariableInitializer {, VariableInitializer} [,]] }
VariableInitializer:
ArrayInitializer
Expression
ParExpression:
( Expression )
Block:
{ BlockStatements }
BlockStatements:
{ BlockStatement }
BlockStatement :
LocalVariableDeclarationStatement
ClassOrInterfaceDeclaration
[Identifier :] Statement
LocalVariableDeclarationStatement:
[
final] Type VariableDeclarators ;Statement:
Block
assert Expression [ : Expression] ; if ParExpression Statement [else Statement] for ( ForControl ) Statement while ParExpression Statement do Statement while ParExpression ; try Block ( Catches | [Catches] finally Block ) switch ParExpression { SwitchBlockStatementGroups } synchronized ParExpression Block return [Expression] ; throw Expression ; break [Identifier] continue [Identifier];
StatementExpression ;
Identifier : Statement
Catches:
CatchClause {CatchClause}
CatchClause:
catch ( FormalParameter ) BlockSwitchBlockStatementGroups:
{ SwitchBlockStatementGroup }
SwitchBlockStatementGroup:
SwitchLabel BlockStatements
SwitchLabel:
case ConstantExpression :case EnumConstantName :
default :
MoreStatementExpressions:
{
, StatementExpression }ForControl:
ForVarControl
ForInit; [Expression] ; [ForUpdate]
ForVarControl
[
final] [Annotations] Type Identifier ForVarControlRestAnnotations:
Annotation [Annotations]
Annotation:
@ TypeName [( [Identifier =] ElementValue)]ElementValue:
ConditionalExpression
Annotation
ElementValueArrayInitializer
ConditionalExpression:
Expression2 Expression1Rest
ElementValueArrayInitializer:
{ [ElementValues] [,] }
ElementValues:
ElementValue [ElementValues]
ForVarControlRest:
VariableDeclaratorsRest; [Expression] ; [ForUpdate]
: ExpressionForInit:
StatementExpression Expressions
Modifier:
Annotation public protected private static abstract final native synchronized transient volatile
strictfp
VariableDeclarators:
VariableDeclarator { , VariableDeclarator }
VariableDeclaratorsRest:
VariableDeclaratorRest { , VariableDeclarator }
ConstantDeclaratorsRest:
ConstantDeclaratorRest { , ConstantDeclarator }
VariableDeclarator:
Identifier VariableDeclaratorRest
ConstantDeclarator:
Identifier ConstantDeclaratorRest
VariableDeclaratorRest:
{[]} [ = VariableInitializer]
ConstantDeclaratorRest:
{[]} = VariableInitializer
VariableDeclaratorId:
Identifier {[]}
CompilationUnit:
[[Annotations]
package QualifiedIdentifier ; ] {ImportDeclaration}{TypeDeclaration}
ImportDeclaration:
import [ static] Identifier { . Identifier } [ . * ] ;TypeDeclaration:
ClassOrInterfaceDeclaration
;
ClassOrInterfaceDeclaration:
{Modifier} (ClassDeclaration | InterfaceDeclaration)
ClassDeclaration:
NormalClassDeclaration
EnumDeclaration
NormalClassDeclaration:
class Identifier [TypeParameters] [extends Type] [implements TypeList]ClassBody
TypeParameters:
< TypeParameter {, TypeParameter} >
TypeParameter:
Identifier [extends Bound]
Bound:
Type {& Type}
EnumDeclaration:
enum Identifier [
implements TypeList] EnumBodyEnumBody:
{ [EnumConstants] [,] [EnumBodyDeclarations] }
EnumConstants:
EnumConstant
EnumConstants , EnumConstant
EnumConstant:
Annotations Identifier [Arguments] [ClassBody]
EnumBodyDeclarations:
; {ClassBodyDeclaration}
InterfaceDeclaration:
NormalInterfaceDeclaration
AnnotationTypeDeclaration
NormalInterfaceDeclaration:
interface Identifier [ TypeParameters] [extends TypeList] InterfaceBodyTypeList:
Type { , Type}
AnnotationTypeDeclaration:
@ interface Identifier AnnotationTypeBody
AnnotationTypeBody:
{ [AnnotationTypeElementDeclarations] }
AnnotationTypeElementDeclarations:
AnnotationTypeElementDeclaration
AnnotationTypeElementDeclarations AnnotationTypeElementDeclaration
AnnotationTypeElementDeclaration:
{Modifier} AnnotationTypeElementRest
AnnotationTypeElementRest:
Type Identifier AnnotationMethodOrConstantRest;
ClassDeclaration
InterfaceDeclaration
EnumDeclaration
AnnotationTypeDeclaration
AnnotationMethodOrConstantRest:
AnnotationMethodRest
AnnotationConstantRest
AnnotationMethodRest:
( ) [DefaultValue]
AnnotationConstantRest:
VariableDeclarators
DefaultValue:
default ElementValueClassBody:
{ {ClassBodyDeclaration} }
InterfaceBody:
{ {InterfaceBodyDeclaration} }
ClassBodyDeclaration:
;
[
static] Block{Modifier} MemberDecl
MemberDecl:
GenericMethodOrConstructorDecl
MethodOrFieldDecl
void Identifier VoidMethodDeclaratorRestIdentifier ConstructorDeclaratorRest
InterfaceDeclaration
ClassDeclaration
GenericMethodOrConstructorDecl:
TypeParameters GenericMethodOrConstructorRest
GenericMethodOrConstructorRest:
(Type |
void) Identifier MethodDeclaratorRestIdentifier ConstructorDeclaratorRest
MethodOrFieldDecl:
Type Identifier MethodOrFieldRest
MethodOrFieldRest:
VariableDeclaratorRest
MethodDeclaratorRest
InterfaceBodyDeclaration:
;
{Modifier} InterfaceMemberDecl
InterfaceMemberDecl:
InterfaceMethodOrFieldDecl
InterfaceGenericMethodDecl
void Identifier VoidInterfaceMethodDeclaratorRestInterfaceDeclaration
ClassDeclaration
InterfaceMethodOrFieldDecl:
Type Identifier InterfaceMethodOrFieldRest
InterfaceMethodOrFieldRest:
ConstantDeclaratorsRest ;
InterfaceMethodDeclaratorRest
MethodDeclaratorRest:
FormalParameters {[]} [
throws QualifiedIdentifierList] ( MethodBody | ;)
VoidMethodDeclaratorRest:
FormalParameters [
throws QualifiedIdentifierList] ( MethodBody | ; )InterfaceMethodDeclaratorRest:
FormalParameters {[]} [
throws QualifiedIdentifierList] ;InterfaceGenericMethodDecl:
TypeParameters (Type |
void) Identifier InterfaceMethodDeclaratorRestVoidInterfaceMethodDeclaratorRest:
FormalParameters [
throws QualifiedIdentifierList] ;ConstructorDeclaratorRest:
FormalParameters [
throws QualifiedIdentifierList] MethodBodyQualifiedIdentifierList:
QualifiedIdentifier { , QualifiedIdentifier}
FormalParameters:
( [FormalParameterDecls] )
FormalParameterDecls:
[
final] [Annotations] Type FormalParameterDeclsRest]FormalParameterDeclsRest:
VariableDeclaratorId [ , FormalParameterDecls]
... VariableDeclaratorIdMethodBody:
Block
EnumConstantName:
Identifier
TAG:
