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