diff --git a/Grammatik.txt b/Grammatik.txt index 1c19c35..97e06b5 100644 --- a/Grammatik.txt +++ b/Grammatik.txt @@ -1,218 +1,166 @@ -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 - ConditionalExpression - AssignmentExpression - MethodInvocation - CreationExpression - -UnaryExpression: - Primary - UnaryOperator - UnaryExpression - UnaryOperator - + | - | ! | ... - -BinaryExpression: - Expression BinaryOperator Expression - -BinaryOperator: - + | - | * | / | & | && | | | || | ... - - -AssignmentExpression: - Variable AssignmentOperator Expression - -AssignmentOperator: - = | += | -= | *= | /= | ... - -MethodInvocation: - Method ( [ ActualArguments ] ) - -Method: - Identifier - -ActualArguments: - Expression { , Expression } - -CreationExpression: - new ClassIdentifier ( [ ActualArguments ] ) - - - -2. Anweisungen - -Statement: - SimpleStatement - CompositeStatement - Label : Statement - -SimpleStatement: - EmptyStatement - ExpressionStatement - JumpStatement - EmptyStatement ; - -ExpressionStatement: - StatementExpression ; - -StatementExpression: - AssignmentExpression - IncDecExpression - MethodInvocation - CreationExpression - -JumpStatement: - BreakStatement - ContinueStatement - ReturnStatement - BreakStatement - break [ Label ] ; - -ContinueStatement: - continue [ Label ] ; - -ReturnStatement. - return [ Expression ] ; - -Label: - Name - -CompositeStatement: - Block - CaseStatement - RepetitiveStatement - -Block: - { { VariableDeclaration | Statement } } - VariableDeclaration [ final ] Type VariableDeclarators ; - VariableDeclarators VariableDeclarator { , VariableDeclarator } - VariableDeclarator Name [ = Expression ] - -Type: - PrimitiveType - ClassType - -PrimitiveType: - Name - -ClassType: - Identifier - -CaseStatement: - ConditionalStatement - SwitchStatement - RepetitiveStatement WhileStatement - DoStatement - ForStatement - -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: - { 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 \ No newline at end of file +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