Small change

This commit is contained in:
Linus K 2022-10-24 01:16:31 +02:00
parent 6c688b8aeb
commit 440fa33793

View File

@ -3,21 +3,20 @@ grammar astRefactor;
/*
* Parser Rules
*/
class : ACCESSMODIFIER WHITESPACE CLASS WHITESPACE NAME '(' ( MODIFIER| TYPEPLACEHOLDER ) WHITESPACE NAME ')''{'NEWLINE classbody'}';
classbody : ( method NEWLINE | variable NEWLINE )+;
variable : ACCESSMODIFIER WHITESPACE ( MODIFIER | TYPEPLACEHOLDER )WHITESPACE NAME WHITESPACE '=' WHITESPACE ( WORD | NUMBER) ';'
| ACCESSMODIFIER WHITESPACE ( MODIFIER | TYPEPLACEHOLDER ) WHITESPACE NAME ';';
method : ACCESSMODIFIER WHITESPACE ( MODIFIER | TYPEPLACEHOLDER ) WHITESPACE NAME '(' ( MODIFIER | TYPEPLACEHOLDER ) WHITESPACE WORD ')';
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 )*;
variable : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder )WHITESPACE NAME WHITESPACE '=' WHITESPACE ( WORD | NUMBER) ';'
| ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME ';';
method : ACCESSMODIFIER WHITESPACE ( formalparameter | typeplaceholder ) WHITESPACE NAME '(' ( formalparameter | typeplaceholder ) WHITESPACE WORD ')';
classorinterface: class;
argumentlist: ARGUMENTLIST;
argumentlist: (variable)+;
genericdecllist: GENERICDECLLIST;
@ -25,11 +24,15 @@ sourcefile: SOURCEFILE;
generictypevar: GENERICTYPEVAR;
parameterlist: PARAMLIST;
parameterlist: (variable)+;
formalparameter: FORMALPARAMETER;
formalparameter: variable;
fieldinterface: FIELDDECLARATION | FIELD;
fieldinterface: fielddeclaration | field;
fielddeclaration: variable;
field: NAME;
methodinterface: method | constructor;
@ -75,7 +78,7 @@ statement: whileinterface | methodcallinterface | returninterface | javainternal
javainternalexpressioninterface: UNARYEXPR;
returninterface: RETURN | RETRUNVOID;
returninterface: RETURN | RETURNVOID;
methodcallinterface: METHODCALL | THISCALL | SUPERCALL | NEWCLASS;
@ -95,19 +98,18 @@ fragment UPPERCASE : [A-Z] ;
NUMBER : [0-9]+;
CLASS : 'class';
ACCESSMODIFIER : ('public' | 'private');
MODIFIER : ('int' | 'String' | 'char');
WHITESPACE : ' ';
NEWLINE : ('\r'? '\n' | '\r')+ ;
ARGUMENTLIST : 'argumentlist';
GENERICDECLLIST : 'genericdecllist';
SOURCEFILE : 'sourcefile';
GENERICDECLLIST : 'List<T>';
SOURCEFILE : (UPPERCASE | LOWERCASE)+'.java';
ASSIGNTOFIELD : 'assigntofield';
ASSIGNLEFTSIDE : 'assignleftside';
WHILESTMT : 'whilestmt';
DOSTMT : 'dosstmt';
WHILESTMT : 'while()';
DOSTMT : 'do()';
GENERICTYPEVAR : 'generictypevar';
PARAMLIST : 'paramlist';
FORMALPARAMETER : 'formalparameter';
FORMALPARAMETER : ('int' | 'String' | 'char');
FIELDDECLARATION : 'fielddeclaration';
FIELD : 'field';
CONSTRUCTOR : 'constructor';
@ -121,30 +123,31 @@ GENERICREFTYPE : 'genericreftype';
THIS : 'this';
SUPER : 'super';
FIELDVAR : 'fieldvar';
NEWARRAY : 'newarray';
NEWARRAY : 'new ArrayList<>()';
LITERAL : 'literal';
CASTEXPR : 'castexpr';
LAMBDAEXPRESSION : 'lambdaexpression';
INSTANCEOF : 'instanceof';
INSTANCEOF : 'instanceOf';
BINARYEXPR : 'binaryexpr';
EXPRESSIONRECEIVER : 'expressionreceiver';
STATICCLASSNAME : 'staticclassname';
FORSMT : 'forstmt';
FORSMT : 'for()';
BLOCK : 'block';
EMPTYSTMT : 'emptystmt';
LOCALVARDECL : 'localvardecl';
ASSIGN : 'assign';
IFSTMT : 'ifstmt';
IFSTMT : 'if()';
LOCALVAR : 'localvar';
RETURN : 'return';
RETRUNVOID : 'returnvoid';
RETURNVOID : 'return void';
METHODCALL : 'methodcall';
THISCALL : 'thiscall';
SUPERCALL : 'supercall';
THISCALL : 'this';
SUPERCALL : 'super';
NEWCLASS : 'newclass';
UNARYEXPR : 'unaryexpr';
NAME : (LOWERCASE)( LOWERCASE | UPPERCASE )+;
WORD : (LOWERCASE | UPPERCASE | '_')+ ;
UNARYEXPR : ('+' | '-' | '++' | '--' | '!');
CLASSNAME : UPPERCASE ( LOWERCASE | UPPERCASE)*;
NAME : LOWERCASE( LOWERCASE | UPPERCASE )*;
WORD : (LOWERCASE | UPPERCASE | '_')+;