Update Grammatik

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

View File

@ -25,14 +25,12 @@ IncDec:
Expression:
UnaryExpression
BinaryExpression
ConditionalExpression
AssignmentExpression
MethodInvocation
CreationExpression
UnaryExpression:
Primary
UnaryOperator
UnaryExpression
UnaryOperator
+ | - | ! | ...
@ -41,14 +39,11 @@ BinaryExpression:
Expression BinaryOperator Expression
BinaryOperator:
+ | - | * | / | & | && | | | || | ...
== | + | - | * | / | & | && | | | || |
AssignmentExpression:
Variable AssignmentOperator Expression
AssignmentOperator:
= | += | -= | *= | /= | ...
Variable = Expression
MethodInvocation:
Method ( [ ActualArguments ] )
@ -73,12 +68,9 @@ Statement:
SimpleStatement:
EmptyStatement
ExpressionStatement
JumpStatement
StatementExpression
EmptyStatement ;
ExpressionStatement:
StatementExpression ;
ReturnStatement
StatementExpression:
AssignmentExpression
@ -86,90 +78,53 @@ StatementExpression:
MethodInvocation
CreationExpression
JumpStatement:
BreakStatement
ContinueStatement
ReturnStatement
BreakStatement
break [ Label ] ;
ContinueStatement:
continue [ Label ] ;
continue [ Name ] ;
ReturnStatement.
return [ Expression ] ;
Label:
Name
CompositeStatement:
Block
CaseStatement
RepetitiveStatement
Block:
{ { VariableDeclaration | Statement } }
VariableDeclaration [ final ] Type VariableDeclarators ;
VariableDeclarators VariableDeclarator { , VariableDeclarator }
VariableDeclarator Name [ = Expression ]
"{" { VariableDeclaration | Statement } "}"
VariableDeclaration:
Type VariableDeclarator ;
VariableDeclarator:
Name [ = Expression ]
Type:
PrimitiveType
ClassType
PrimitiveType:
Name
ClassType:
Name # konkrete Typen hinzufügen
Identifier
CaseStatement:
CaseStatement: # Andere CaseStatements heraussuchen. Assign, MethodCall,
ConditionalStatement
SwitchStatement
RepetitiveStatement WhileStatement
DoStatement
ForStatement
WhileStatement
ConditionalStatement:
if ( Expression ) Statement [ else Statement ]
SwitchStatement:
switch ( Expression ) SwitchBlock
SwitchBlock:
{ { CaseGroup } }
CaseGroup:
SwitchLabel { SwitchLabel } StatementSequence
SwitchLabel:
case ConstantExpression :
default :
ConstantExpression:
Expression
WhileStatement:
while ( Expression ) Statement
DoStatement:
do Statement while ( Expression ) ;
ForStatement:
for ( [ Initialization ] ; [ Expression ] ; [ Update ] ) Statement
Initialization:
StatementExpression { , StatementExpression }
VariableDeclaration
Update:
StatementExpression { , StatementExpression }
3. Methoden
MethodDeclaration:
MethodHeader MethodBody
MethodHeader Block
MethodHeader:
{ Modifier } ResultType MethodDeclarator
@ -181,7 +136,7 @@ ResultType:
Type | void
MethodDeclarator:
Identifier ( [ FormalArguments ] )
Identifier "(" [ FormalArguments ] ")"
FormalArguments:
FormalArgument { , FormalArgument }
@ -189,30 +144,23 @@ FormalArguments:
FormalArgument:
Type Name
MethodBody:
; | Block
4. Klassen
Start:
ClassDeclaration {ClassDeclaration}
ClassDeclaration:
[ public ] class Name ClassBody
ClassBody:
{ { { Modifier } Declaration } }
{ { Modifier } Declaration }
Declaration:
FieldDeclaration
MethodDeclaration
ClassDeclaration
ConstructorDeclaration
Initializer
FieldDeclaration:
VariableDeclaration
MethodDeclaration
ConstructorDeclaration
ConstructorDeclaration:
[ public ] Name ( [ FormalArguments ] ) Block
Initializer:
[ static ] Block