Update Grammatik

This commit is contained in:
i22022 2024-05-02 10:36:12 +00:00
parent 7c91cee342
commit 1536d6c3f6

View File

@ -1,218 +1,166 @@
Grammatik: Grammatik:
1. Ausdrücke 1. Ausdrücke
Primary: Primary:
Literal Literal
Variable Variable
IncDecExpression IncDecExpression
( Expression ) ( Expression )
MethodInvocation MethodInvocation
Variable: Variable:
Identifier { [ Expression ] } Identifier { [ Expression ] }
Identifier: Identifier:
[ Identifier . ] Name [ Identifier . ] Name
IncDecExpression: IncDecExpression:
Variable IncDec Variable IncDec
IncDec Variable IncDec Variable
IncDec: IncDec:
++ | -- ++ | --
Expression: Expression:
UnaryExpression UnaryExpression
BinaryExpression BinaryExpression
ConditionalExpression AssignmentExpression
AssignmentExpression MethodInvocation
MethodInvocation CreationExpression
CreationExpression
UnaryExpression:
UnaryExpression: Primary
Primary UnaryExpression
UnaryOperator UnaryOperator
UnaryExpression + | - | ! | ...
UnaryOperator
+ | - | ! | ... BinaryExpression:
Expression BinaryOperator Expression
BinaryExpression:
Expression BinaryOperator Expression BinaryOperator:
== | + | - | * | / | & | && | | | || |
BinaryOperator:
+ | - | * | / | & | && | | | || | ...
AssignmentExpression:
Variable = Expression
AssignmentExpression:
Variable AssignmentOperator Expression MethodInvocation:
Method ( [ ActualArguments ] )
AssignmentOperator:
= | += | -= | *= | /= | ... Method:
Identifier
MethodInvocation:
Method ( [ ActualArguments ] ) ActualArguments:
Expression { , Expression }
Method:
Identifier CreationExpression:
new ClassIdentifier ( [ ActualArguments ] )
ActualArguments:
Expression { , Expression }
CreationExpression: 2. Anweisungen
new ClassIdentifier ( [ ActualArguments ] )
Statement:
SimpleStatement
CompositeStatement
2. Anweisungen Label : Statement
Statement: SimpleStatement:
SimpleStatement EmptyStatement
CompositeStatement StatementExpression
Label : Statement EmptyStatement ;
ReturnStatement
SimpleStatement:
EmptyStatement StatementExpression:
ExpressionStatement AssignmentExpression
JumpStatement IncDecExpression
EmptyStatement ; MethodInvocation
CreationExpression
ExpressionStatement:
StatementExpression ; ContinueStatement:
continue [ Name ] ;
StatementExpression:
AssignmentExpression ReturnStatement.
IncDecExpression return [ Expression ] ;
MethodInvocation
CreationExpression
CompositeStatement:
JumpStatement: Block
BreakStatement CaseStatement
ContinueStatement
ReturnStatement Block:
BreakStatement "{" { VariableDeclaration | Statement } "}"
break [ Label ] ;
VariableDeclaration:
ContinueStatement: Type VariableDeclarator ;
continue [ Label ] ;
VariableDeclarator:
ReturnStatement. Name [ = Expression ]
return [ Expression ] ;
Type:
Label: Name # konkrete Typen hinzufügen
Name Identifier
CompositeStatement: CaseStatement: # Andere CaseStatements heraussuchen. Assign, MethodCall,
Block ConditionalStatement
CaseStatement WhileStatement
RepetitiveStatement
Block: ConditionalStatement:
{ { VariableDeclaration | Statement } } if ( Expression ) Statement [ else Statement ]
VariableDeclaration [ final ] Type VariableDeclarators ;
VariableDeclarators VariableDeclarator { , VariableDeclarator } ConstantExpression:
VariableDeclarator Name [ = Expression ] Expression
Type: WhileStatement:
PrimitiveType while ( Expression ) Statement
ClassType
Initialization:
PrimitiveType: StatementExpression { , StatementExpression }
Name VariableDeclaration
ClassType:
Identifier 3. Methoden
CaseStatement: MethodDeclaration:
ConditionalStatement MethodHeader Block
SwitchStatement
RepetitiveStatement WhileStatement MethodHeader:
DoStatement { Modifier } ResultType MethodDeclarator
ForStatement
Modifier:
ConditionalStatement: public | static | ...
if ( Expression ) Statement [ else Statement ]
ResultType:
SwitchStatement: Type | void
switch ( Expression ) SwitchBlock
MethodDeclarator:
SwitchBlock: Identifier "(" [ FormalArguments ] ")"
{ { CaseGroup } }
FormalArguments:
CaseGroup: FormalArgument { , FormalArgument }
SwitchLabel { SwitchLabel } StatementSequence
FormalArgument:
SwitchLabel: Type Name
case ConstantExpression :
default :
ConstantExpression: 4. Klassen
Expression
Start:
WhileStatement: ClassDeclaration {ClassDeclaration}
while ( Expression ) Statement
ClassDeclaration:
DoStatement: [ public ] class Name ClassBody
do Statement while ( Expression ) ;
ClassBody:
ForStatement: { { Modifier } Declaration }
for ( [ Initialization ] ; [ Expression ] ; [ Update ] ) Statement
Declaration:
Initialization: VariableDeclaration
StatementExpression { , StatementExpression } MethodDeclaration
VariableDeclaration ConstructorDeclaration
Update: ConstructorDeclaration:
StatementExpression { , StatementExpression } [ public ] Name ( [ FormalArguments ] ) Block
3. Methoden
MethodDeclaration:
MethodHeader MethodBody
MethodHeader:
{ Modifier } ResultType MethodDeclarator
Modifier:
public | static | ...
ResultType:
Type | void
MethodDeclarator:
Identifier ( [ FormalArguments ] )
FormalArguments:
FormalArgument { , FormalArgument }
FormalArgument:
Type Name
MethodBody:
; | Block
4. Klassen
ClassDeclaration:
[ public ] class Name ClassBody
ClassBody:
{ { { Modifier } Declaration } }
Declaration:
FieldDeclaration
MethodDeclaration
ClassDeclaration
ConstructorDeclaration
Initializer
FieldDeclaration:
VariableDeclaration
ConstructorDeclaration:
[ public ] Name ( [ FormalArguments ] ) Block
Initializer:
[ static ] Block