Kurs:Programmierung in Java/EBNF-Syntax Java 1.5

Aus Wikiversity

Wechseln zu: Navigation, Suche
 CompilationUnit 	::= 	( PackageDeclaration )? ( ImportDeclaration )* ( TypeDeclaration )* <EOF> ;
 PackageDeclaration 	::= 	"package" Name ";";
 ImportDeclaration 	::= 	"import" ( "static" )? Name ( "." "*" )? ";";
 Modifiers 	        ::= 	( ( "public" | "static" | "protected" | "private" | "final" | "abstract" | "synchronized" | "native" | "transient" | "volatile" | "strictfp" | Annotation ) )*;
 TypeDeclaration 	::= 	( ";" | Modifiers ( ClassOrInterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration ) );
 ClassOrInterfaceDeclaration 	::= 	( "class" | "interface" ) <IDENTIFIER> ( TypeParameters )? ( ExtendsList )? (  ImplementsList )? ClassOrInterfaceBody;
 ExtendsList 	        ::= 	"extends" ClassOrInterfaceType ( "," ClassOrInterfaceType )*;
 ImplementsList 	::= 	"implements" ClassOrInterfaceType ( "," ClassOrInterfaceType )*;
 EnumDeclaration 	::= 	"enum" <IDENTIFIER> ( ImplementsList )? EnumBody;
 EnumBody 	        ::= 	"{" EnumConstant ( "," EnumConstant )* ( ";" ( ClassOrInterfaceBodyDeclaration )* )? "}";
 EnumConstant    	::= 	<IDENTIFIER> ( Arguments )? ( ClassOrInterfaceBody )?;
 TypeParameters 	::= 	"<" TypeParameter ( "," TypeParameter )* ">";
 TypeParameter 	        ::= 	<IDENTIFIER> ( TypeBound )?;
 TypeBound 	        ::= 	"extends" ClassOrInterfaceType ( "&" ClassOrInterfaceType )*;
 ClassOrInterfaceBody 	::= 	"{" ( ClassOrInterfaceBodyDeclaration )* "}";
 ClassOrInterfaceBodyDeclaration 	::= 	( Initializer | Modifiers ( ClassOrInterfaceDeclaration | EnumDeclaration |    ConstructorDeclaration | FieldDeclaration | MethodDeclaration ) | ";" ); 
 FieldDeclaration 	::= 	Type VariableDeclarator ( "," VariableDeclarator )* ";";
 VariableDeclarator 	::= 	VariableDeclaratorId ( "=" VariableInitializer )?;
 VariableDeclaratorId 	::= 	<IDENTIFIER> ( "[" "]" )*;
 VariableInitializer 	::= 	( ArrayInitializer | Expression );
 ArrayInitializer 	::= 	"{" ( VariableInitializer ( "," VariableInitializer )* )? ( "," )? "}";
 MethodDeclaration 	::= 	( TypeParameters )? ResultType MethodDeclarator ( "throws" NameList )? ( Block | ";" );
 MethodDeclarator 	::= 	<IDENTIFIER> FormalParameters ( "[" "]" )*;
 FormalParameters 	::= 	"(" ( FormalParameter ( "," FormalParameter )* )? ")";
 FormalParameter 	::= 	( "final" )? Type ( "..." )? VariableDeclaratorId;
 ConstructorDeclaration 	::= 	( TypeParameters )? <IDENTIFIER> FormalParameters ( "throws" NameList )? "{" (  ExplicitConstructorInvocation )? ( BlockStatement )* "}";
 ExplicitConstructorInvocation 	::= 	( "this" Arguments ";" | ( PrimaryExpression "." )? "super" Arguments ";" );
 Initializer 	::= 	( "static" )? Block;
 Type 	::= 	( ReferenceType | PrimitiveType );
 ReferenceType 	::= 	( PrimitiveType ( "[" "]" )+ | ( ClassOrInterfaceType ) ( "[" "]" )* );
 ClassOrInterfaceType 	::= 	<IDENTIFIER> ( TypeArguments )? ( "." <IDENTIFIER> ( TypeArguments )? )*;
 TypeArguments 	::= 	"<" TypeArgument ( "," TypeArgument )* ">";
 TypeArgument 	::= 	( ReferenceType | "?" ( WildcardBounds )? );
 WildcardBounds 	::= 	( "extends" ReferenceType | "super" ReferenceType );
 PrimitiveType 	::= 	( "boolean" | "char" | "byte" | "short" | "int" | "long" | "float" | "double" );
 ResultType 	::= 	( "void" | Type );
 Name 	::= 	<IDENTIFIER> ( "." <IDENTIFIER> )*;
 NameList 	::= 	Name ( "," Name )*;
 Expression 	::= 	ConditionalExpression ( AssignmentOperator Expression )?;
 AssignmentOperator 	::= 	( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" );
 ConditionalExpression 	::= 	ConditionalOrExpression ( "?" Expression ":" Expression )?;
 ConditionalOrExpression 	::= 	ConditionalAndExpression ( "||" ConditionalAndExpression )*;
 ConditionalAndExpression 	::= 	InclusiveOrExpression ( "&&" InclusiveOrExpression )*;
 InclusiveOrExpression 	::= 	ExclusiveOrExpression ( "|" ExclusiveOrExpression )*;
 ExclusiveOrExpression 	::= 	AndExpression ( "^" AndExpression )*;
 AndExpression 	::= 	EqualityExpression ( "&" EqualityExpression )*;
 EqualityExpression 	::= 	InstanceOfExpression ( ( "==" | "!=" ) InstanceOfExpression )*;
 InstanceOfExpression 	::= 	RelationalExpression ( "instanceof" Type )?;
 RelationalExpression 	::= 	ShiftExpression ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression )*;
 ShiftExpression 	::= 	AdditiveExpression ( ( "<<" | RSIGNEDSHIFT | RUNSIGNEDSHIFT ) AdditiveExpression )*;
 AdditiveExpression 	::= 	MultiplicativeExpression ( ( "+" | "-" ) MultiplicativeExpression )*;
 MultiplicativeExpression 	::= 	UnaryExpression ( ( "*" | "/" | "%" ) UnaryExpression )*;
 UnaryExpression 	::= 	( ( "+" | "-" ) UnaryExpression | PreIncrementExpression | PreDecrementExpression |   UnaryExpressionNotPlusMinus );
 PreIncrementExpression 	::= 	"++" PrimaryExpression;
 PreDecrementExpression 	::= 	"--" PrimaryExpression;
 UnaryExpressionNotPlusMinus 	::= 	( ( "~" | "!" ) UnaryExpression | CastExpression | PostfixExpression );
 CastLookahead 	::= 	( "(" PrimitiveType | "(" Type "[" "]" | "(" Type ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal ) );
 PostfixExpression 	::= 	PrimaryExpression ( "++" | "--" )?;
 CastExpression 	::= 	( "(" Type ")" UnaryExpression | "(" Type ")" UnaryExpressionNotPlusMinus );
 PrimaryExpression 	::= 	PrimaryPrefix ( PrimarySuffix )*;
 MemberSelector 	::= 	"." TypeArguments <IDENTIFIER>;
 PrimaryPrefix 	::= 	( Literal | "this" | "super" "." <IDENTIFIER> | "(" Expression ")" | AllocationExpression | ResultType "."  "class" | Name );
 PrimarySuffix 	::= 	( "." "this" | "." AllocationExpression | MemberSelector | "[" Expression "]" | "." <IDENTIFIER> |  Arguments );
 Literal 	::= 	( <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> | <CHARACTER_LITERAL> | <STRING_LITERAL> | BooleanLiteral | NullLiteral );
 BooleanLiteral 	::= 	( "true" | "false" );
 NullLiteral 	::= 	"null";
 Arguments 	::= 	"(" ( ArgumentList )? ")";
 ArgumentList 	::= 	Expression ( "," Expression )*;
 AllocationExpression 	::= 	( "new" PrimitiveType ArrayDimsAndInits | "new" ClassOrInterfaceType ( TypeArguments )? (  ArrayDimsAndInits | Arguments ( ClassOrInterfaceBody )? ) );
 ArrayDimsAndInits 	::= 	( ( "[" Expression "]" )+ ( "[" "]" )* | ( "[" "]" )+ ArrayInitializer );
 Statement 	::= 	( LabeledStatement | AssertStatement | Block | EmptyStatement | StatementExpression ";" | SwitchStatement | IfStatement | WhileStatement | DoStatement | ForStatement | BreakStatement | ContinueStatement | ReturnStatement |  ThrowStatement | SynchronizedStatement | TryStatement );
 AssertStatement 	::= 	"assert" Expression ( ":" Expression )? ";";
 LabeledStatement 	::= 	<IDENTIFIER> ":" Statement;
 Block 	::= 	"{" ( BlockStatement )* "}";
 BlockStatement 	::= 	( LocalVariableDeclaration ";" | Statement | ClassOrInterfaceDeclaration );
 LocalVariableDeclaration 	::= 	( "final" )? Type VariableDeclarator ( "," VariableDeclarator )*;
 EmptyStatement 	::= 	";";
 StatementExpression 	::= 	( PreIncrementExpression | PreDecrementExpression | PrimaryExpression ( "++" | "--" |  AssignmentOperator Expression )? );
 SwitchStatement 	::= 	"switch" "(" Expression ")" "{" ( SwitchLabel ( BlockStatement )* )* "}";
 SwitchLabel 	::= 	( "case" Expression ":" | "default" ":" );
 IfStatement 	::= 	"if" "(" Expression ")" Statement ( "else" Statement )?;
 WhileStatement 	::= 	"while" "(" Expression ")" Statement;
 DoStatement 	::= 	"do" Statement "while" "(" Expression ")" ";";
 ForStatement 	::= 	"for" "(" ( Type <IDENTIFIER> ":" Expression | ( ForInit )? ";" ( Expression )? ";" ( ForUpdate )? ) ")"  Statement;
 ForInit 	::= 	( LocalVariableDeclaration | StatementExpressionList );
 StatementExpressionList 	::= 	StatementExpression ( "," StatementExpression )*;
 ForUpdate 	::= 	StatementExpressionList;
 BreakStatement 	::= 	"break" ( <IDENTIFIER> )? ";";
 ContinueStatement 	::= 	"continue" ( <IDENTIFIER> )? ";";
 ReturnStatement 	::= 	"return" ( Expression )? ";";
 ThrowStatement 	::= 	"throw" Expression ";";
 SynchronizedStatement 	::= 	"synchronized" "(" Expression ")" Block;
 TryStatement 	::= 	"try" Block ( "catch" "(" FormalParameter ")" Block )* ( "finally" Block )?;
 RUNSIGNEDSHIFT 	::= 	( ">" ">" ">" );
 RSIGNEDSHIFT 	::= 	( ">" ">" );
 Annotation 	::= 	( NormalAnnotation | SingleMemberAnnotation | MarkerAnnotation );
 NormalAnnotation 	::= 	"@" Name "(" ( MemberValuePairs )? ")";
 MarkerAnnotation 	::= 	"@" Name;
 SingleMemberAnnotation 	::= 	"@" Name "(" MemberValue ")";
 MemberValuePairs 	::= 	MemberValuePair ( "," MemberValuePair )*;
 MemberValuePair 	::= 	<IDENTIFIER> "=" MemberValue;
 MemberValue 	::= 	( Annotation | MemberValueArrayInitializer | ConditionalExpression );
 MemberValueArrayInitializer 	::= 	"{" MemberValue ( "," MemberValue )* ( "," )? "}";
 AnnotationTypeDeclaration 	::= 	"@" "interface" <IDENTIFIER> AnnotationTypeBody;
 AnnotationTypeBody 	::= 	"{" ( AnnotationTypeMemberDeclaration )* "}";
 AnnotationTypeMemberDeclaration 	::= 	( Modifiers ( Type <IDENTIFIER> "(" ")" ( DefaultValue )? ";" |  ClassOrInterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration | FieldDeclaration ) | ( ";" ) );
 DefaultValue 	::= 	"default" MemberValue;
Persönliche Werkzeuge