From dd33b17f5c3afb1ed4e343654e7a674e32f456ac Mon Sep 17 00:00:00 2001 From: Linus K Date: Mon, 24 Oct 2022 01:55:54 +0200 Subject: [PATCH] Small change --- src/main/antlr4/astRefactor/astRefactor.g4 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/antlr4/astRefactor/astRefactor.g4 b/src/main/antlr4/astRefactor/astRefactor.g4 index 8e376338..ed1a2aa0 100644 --- a/src/main/antlr4/astRefactor/astRefactor.g4 +++ b/src/main/antlr4/astRefactor/astRefactor.g4 @@ -5,8 +5,8 @@ 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 )*; +class : ACCESSMODIFIER WHITESPACE CLASS WHITESPACE CLASSNAME '(' (( formalparameter| typeplaceholder ) WHITESPACE NAME)* ')''{'(NEWLINE)* classbody'}'; +classbody : ( method NEWLINE | variable NEWLINE | NEWLINE | whilestmt | dostmt)*; variable : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder )WHITESPACE NAME WHITESPACE '=' WHITESPACE ( WORD | NUMBER) ';' | ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME ';'; @@ -82,7 +82,11 @@ returninterface: RETURN | RETURNVOID; methodcallinterface: METHODCALL | THISCALL | SUPERCALL | NEWCLASS; -whileinterface: WHILESTMT | DOSTMT; +whileinterface: whilestmt | dostmt; + +dostmt: DOSTMT '{'( NEWLINE )*'}' (NEWLINE)* whilestmt ; + +whilestmt: WHILESTMT'('')''{'( NEWLINE)*'}'; assignleft: assigntofield | ASSIGNLEFTSIDE; @@ -104,8 +108,8 @@ 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'; @@ -120,7 +124,7 @@ GENERICREFTYPE : 'genericreftype'; THIS : 'this'; SUPER : 'super'; FIELDVAR : 'fieldvar'; -NEWARRAY : 'new ArrayList<>()'; +NEWARRAY : 'new ArrayList'; LITERAL : 'literal'; CASTEXPR : 'castexpr'; LAMBDAEXPRESSION : 'lambdaexpression'; @@ -128,12 +132,12 @@ 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';