167 lines
2.3 KiB
Plaintext
167 lines
2.3 KiB
Plaintext
Grammatik:
|
|
|
|
1. Ausdrücke
|
|
|
|
Primary:
|
|
Literal
|
|
Variable
|
|
IncDecExpression
|
|
( Expression )
|
|
MethodInvocation
|
|
|
|
Variable:
|
|
Identifier { [ Expression ] }
|
|
|
|
Identifier:
|
|
[ Identifier . ] Name
|
|
|
|
IncDecExpression:
|
|
Variable IncDec
|
|
IncDec Variable
|
|
|
|
IncDec:
|
|
++ | --
|
|
|
|
Expression:
|
|
UnaryExpression
|
|
BinaryExpression
|
|
AssignmentExpression
|
|
MethodInvocation
|
|
CreationExpression
|
|
|
|
UnaryExpression:
|
|
Primary
|
|
UnaryExpression
|
|
UnaryOperator
|
|
+ | - | ! | ...
|
|
|
|
BinaryExpression:
|
|
Expression BinaryOperator Expression
|
|
|
|
BinaryOperator:
|
|
== | + | - | * | / | & | && | | | || |
|
|
|
|
|
|
AssignmentExpression:
|
|
Variable = Expression
|
|
|
|
MethodInvocation:
|
|
Method ( [ ActualArguments ] )
|
|
|
|
Method:
|
|
Identifier
|
|
|
|
ActualArguments:
|
|
Expression { , Expression }
|
|
|
|
CreationExpression:
|
|
new ClassIdentifier ( [ ActualArguments ] )
|
|
|
|
|
|
|
|
2. Anweisungen
|
|
|
|
Statement:
|
|
SimpleStatement
|
|
CompositeStatement
|
|
Label : Statement
|
|
|
|
SimpleStatement:
|
|
EmptyStatement
|
|
StatementExpression
|
|
EmptyStatement ;
|
|
ReturnStatement
|
|
|
|
StatementExpression:
|
|
AssignmentExpression
|
|
IncDecExpression
|
|
MethodInvocation
|
|
CreationExpression
|
|
|
|
ContinueStatement:
|
|
continue [ Name ] ;
|
|
|
|
ReturnStatement.
|
|
return [ Expression ] ;
|
|
|
|
|
|
CompositeStatement:
|
|
Block
|
|
CaseStatement
|
|
|
|
Block:
|
|
"{" { VariableDeclaration | Statement } "}"
|
|
|
|
VariableDeclaration:
|
|
Type VariableDeclarator ;
|
|
|
|
VariableDeclarator:
|
|
Name [ = Expression ]
|
|
|
|
Type:
|
|
Name # konkrete Typen hinzufügen
|
|
Identifier
|
|
|
|
CaseStatement: # Andere CaseStatements heraussuchen. Assign, MethodCall,
|
|
ConditionalStatement
|
|
WhileStatement
|
|
|
|
|
|
ConditionalStatement:
|
|
if ( Expression ) Statement [ else Statement ]
|
|
|
|
ConstantExpression:
|
|
Expression
|
|
|
|
WhileStatement:
|
|
while ( Expression ) Statement
|
|
|
|
Initialization:
|
|
StatementExpression { , StatementExpression }
|
|
VariableDeclaration
|
|
|
|
|
|
3. Methoden
|
|
|
|
MethodDeclaration:
|
|
MethodHeader Block
|
|
|
|
MethodHeader:
|
|
{ Modifier } ResultType MethodDeclarator
|
|
|
|
Modifier:
|
|
public | static | ...
|
|
|
|
ResultType:
|
|
Type | void
|
|
|
|
MethodDeclarator:
|
|
Identifier "(" [ FormalArguments ] ")"
|
|
|
|
FormalArguments:
|
|
FormalArgument { , FormalArgument }
|
|
|
|
FormalArgument:
|
|
Type Name
|
|
|
|
|
|
|
|
4. Klassen
|
|
|
|
Start:
|
|
ClassDeclaration {ClassDeclaration}
|
|
|
|
ClassDeclaration:
|
|
[ public ] class Name ClassBody
|
|
|
|
ClassBody:
|
|
"{" { { Modifier } Declaration } "}"
|
|
|
|
Declaration:
|
|
VariableDeclaration
|
|
MethodDeclaration
|
|
ConstructorDeclaration
|
|
|
|
ConstructorDeclaration:
|
|
[ public ] Name ( [ FormalArguments ] ) Block
|