diff --git a/Source/Decaf.g4 b/Source/Decaf.g4 index f40a9f8..2dde8dd 100644 --- a/Source/Decaf.g4 +++ b/Source/Decaf.g4 @@ -3,12 +3,12 @@ grammar Decaf; program: classdecl+; //class identifier{...} -classdecl: (AccessModifierPrivate|AccessModifierPublic|AccessModifierProtected)? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)* ClosedCurlyBracket; -constuctorDecl: (AccessModifierPrivate|AccessModifierPublic|AccessModifierProtected)? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Maybe not needed +classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)* ClosedCurlyBracket; +constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Maybe not needed //Method and FieldVar -methodDecl: MainMethodDecl block | (AccessModifierPrivate|AccessModifierPublic|AccessModifierProtected)? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; -fieldDecl: (AccessModifierPrivate|AccessModifierPublic|AccessModifierProtected)? type Identifier Semicolon; +methodDecl: MainMethodDecl block | AccessModifierPublic? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; +fieldDecl: AccessModifierPublic? type Identifier Semicolon; //Parameters parameterList: parameter(Comma parameter)*; @@ -57,8 +57,6 @@ value: IntValue | BooleanValue | CharValue | NullValue; //Access modifier AccessModifierPublic : 'public' ; -AccessModifierPrivate : 'private'; -AccessModifierProtected : 'protected'; MainMethodDecl : 'public static void main(String[] args)'; //Types