From 1d0bb99b7efd51d8a6f97f2acdae7f73cc91c308 Mon Sep 17 00:00:00 2001 From: Linus K Date: Mon, 24 Oct 2022 03:22:40 +0200 Subject: [PATCH] Small change --- src/main/antlr4/astRefactor/astRefactor.g4 | 45 ++++++++++++---------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/antlr4/astRefactor/astRefactor.g4 b/src/main/antlr4/astRefactor/astRefactor.g4 index ed1a2aa0..20a4c8a9 100644 --- a/src/main/antlr4/astRefactor/astRefactor.g4 +++ b/src/main/antlr4/astRefactor/astRefactor.g4 @@ -5,13 +5,13 @@ grammar astRefactor; */ syntaxtreenode: typablestatement | reftypeortphorwildcardorgeneric | methodinterface | fieldinterface | formalparameter | parameterlist | generictypevar | sourcefile | genericdecllist | argumentlist | classorinterface; -class : ACCESSMODIFIER WHITESPACE CLASS WHITESPACE CLASSNAME '(' (( formalparameter| typeplaceholder ) WHITESPACE NAME)* ')''{'(NEWLINE)* classbody'}'; -classbody : ( method NEWLINE | variable NEWLINE | NEWLINE | whilestmt | dostmt)*; +class : ACCESSMODIFIER WHITESPACE CLASS WHITESPACE CLASSNAME ('(' (( syntaxtreenode ) WHITESPACE NAME)* ')''{'(NEWLINE)* classbody'}'| '{'(NEWLINE)* classbody'}'); +classbody : ( method NEWLINE | variable NEWLINE | NEWLINE | syntaxtreenode)*; -variable : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder )WHITESPACE NAME WHITESPACE '=' WHITESPACE ( WORD | NUMBER) ';' - | ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME ';'; +variable : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME WHITESPACE '=' WHITESPACE ( WORD | NUMBER) ';' + | ACCESSMODIFIER WHITESPACE ( syntaxtreenode ) WHITESPACE NAME ';'; -method : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME '(' ( formalparameter | typeplaceholder ) WHITESPACE WORD ')'; +method : ACCESSMODIFIER WHITESPACE ( syntaxtreenode ) WHITESPACE NAME '(' ( formalparameter | typeplaceholder ) WHITESPACE WORD ')'; classorinterface: class; @@ -26,7 +26,7 @@ generictypevar: GENERICTYPEVAR; parameterlist: (variable)+; -formalparameter: variable; +formalparameter: FORMALPARAMETER; fieldinterface: fielddeclaration | field; @@ -48,7 +48,7 @@ reftype: REFTYPE; wildcardtypeinterface: superwildcardtype | wildcardtype | extendswildcardType; -extendswildcardType: EXTENDSWILDARDARDARDTYPE; +extendswildcardType: EXTENDSWILDARDTYPE; wildcardtype: WILDCARDTYPE; @@ -74,19 +74,25 @@ expressionreceiver: EXPRESSIONRECEIVER; staticclassname: STATICCLASSNAME; -statement: whileinterface | methodcallinterface | returninterface | javainternalexpressioninterface | FORSMT | BLOCK | EMPTYSTMT | LOCALVARDECL | ASSIGN | IFSTMT | LOCALVAR; +statement: whileinterface | methodcallinterface | returninterface | javainternalexpressioninterface | forstmt | BLOCK | EMPTYSTMT | LOCALVARDECL | ASSIGN | ifstmt | LOCALVAR; + +ifstmt: IFSTMT')''{'( NEWLINE )*'}'; + +forstmt: FORSMT')''{'( NEWLINE )*'}'; javainternalexpressioninterface: UNARYEXPR; -returninterface: RETURN | RETURNVOID; +returninterface: RETURN | returnvoid; + +returnvoid: RETURN VOID; methodcallinterface: METHODCALL | THISCALL | SUPERCALL | NEWCLASS; whileinterface: whilestmt | dostmt; -dostmt: DOSTMT '{'( NEWLINE )*'}' (NEWLINE)* whilestmt ; +dostmt: DOSTMT ( NEWLINE )*'}' (NEWLINE)* whilestmt ; -whilestmt: WHILESTMT'('')''{'( NEWLINE)*'}'; +whilestmt: WHILESTMT')''{'( NEWLINE)*'}'; assignleft: assigntofield | ASSIGNLEFTSIDE; @@ -108,15 +114,15 @@ GENERICDECLLIST : 'List'; SOURCEFILE : WORD '.java'; ASSIGNTOFIELD : 'assigntofield'; ASSIGNLEFTSIDE : 'assignleftside'; -WHILESTMT : 'while'; -DOSTMT : 'do'; +WHILESTMT : 'while('; +DOSTMT : 'do{'; GENERICTYPEVAR : 'generictypevar'; FORMALPARAMETER : ('int' | 'String' | 'double' | 'float' | 'boolean'); FIELDDECLARATION : 'fielddeclaration'; CONSTRUCTOR : 'constructor'; VOID : 'void'; REFTYPE : 'reftype'; -EXTENDSWILDARDARDARDTYPE : 'extendwildcardType'; +EXTENDSWILDARDTYPE : 'extendwildcardType'; WILDCARDTYPE : 'wildcardtype'; SUPERWILDCARDTYPE : 'superwildcardtype'; TYPEPLACEHOLDER : 'typeplaceholder'; @@ -128,22 +134,21 @@ NEWARRAY : 'new ArrayList'; LITERAL : 'literal'; CASTEXPR : 'castexpr'; LAMBDAEXPRESSION : 'lambdaexpression'; -INSTANCEOF : 'instanceOf'; +INSTANCEOF : 'instanceof'; BINARYEXPR : 'binaryexpr'; EXPRESSIONRECEIVER : 'expressionreceiver'; STATICCLASSNAME : 'staticclassname'; -FORSMT : 'for'; +FORSMT : 'for('; BLOCK : 'block'; EMPTYSTMT : 'emptystmt'; LOCALVARDECL : 'localvardecl'; ASSIGN : 'assign'; -IFSTMT : 'if'; +IFSTMT : 'if('; LOCALVAR : 'localvar'; RETURN : 'return'; -RETURNVOID : 'return void'; METHODCALL : 'methodcall'; -THISCALL : 'this()'; -SUPERCALL : 'super()'; +THISCALL : 'this('; +SUPERCALL : 'super('; NEWCLASS : 'newclass'; UNARYEXPR : ('+' | '-' | '++' | '--' | '!'); CLASSNAME : UPPERCASE ( LOWERCASE | UPPERCASE)*;