Änderungen am Lexer

This commit is contained in:
JanUlrich 2014-07-09 10:52:23 +02:00
parent d5258d2d09
commit 39bcd6702b
9 changed files with 10022 additions and 5971 deletions

View File

@ -169,18 +169,6 @@ null {
{ws}|\n { /* System.out.print(yytext()); */ } {ws}|\n { /* System.out.print(yytext()); */ }
\\.\n {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());} \\.\n {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());}
"->" {this.token = new Token(JavaParser.LAMBDAASSIGNMENT, yytext(), yyline, yychar);return true;} "->" {this.token = new Token(JavaParser.LAMBDAASSIGNMENT, yytext(), yyline, yychar);return true;}
">" {this.token = new Token(JavaParser.ENDOFGENERICVARDECLARATION, yytext(), yyline, yychar);return true;}

View File

@ -7,6 +7,7 @@ Backup von JavaParser.jay 10.April 17 Uhr
package mycompiler.myparser; package mycompiler.myparser;
import mycompiler.myclass.FieldDeclaration; import mycompiler.myclass.FieldDeclaration;
import mycompiler.myclass.GenericDeclarationList;
import mycompiler.myclass.Field; import mycompiler.myclass.Field;
import java.util.Vector; import java.util.Vector;
import mycompiler.SourceFile; import mycompiler.SourceFile;
@ -200,6 +201,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
%token OP %token OP
%token EOF %token EOF
%token LAMBDAASSIGNMENT %token LAMBDAASSIGNMENT
%token <Token> ENDOFGENERICVARDECLARATION
%type <Class> classdeclaration %type <Class> classdeclaration
%type <Interface> interfacedeclaration %type <Interface> interfacedeclaration
@ -903,13 +905,13 @@ fielddeclarator :
} }
genericdeclarationlist : '<' boundedMethodParameters '>' genericdeclarationlist : '<' boundedMethodParameters ENDOFGENERICVARDECLARATION
{ {
GenericDeclarationList ret = new GenericDeclarationList($2); GenericDeclarationList ret = new GenericDeclarationList($2,$3.getOffset());
ret.setOffset($3.getOffset());
$$ = ret; $$ = ret;
} }
fielddeclaration : fielddeclarator ';' fielddeclaration : fielddeclarator ';'
{ {
$$=$1; $$=$1;

View File

@ -1195,7 +1195,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
classBodyCode.attach(bodyString); classBodyCode.attach(bodyString);
//Zuerst die generischen Parameter für diese Klasse berechnen: //Zuerst die generischen Parameter für diese Klasse berechnen:
this.createGenericTypeVars(classBodyCode.getUnresolvedTPH()); //this.createGenericTypeVars(classBodyCode.getUnresolvedTPH());
if(this.genericClassParameters != null && this.genericClassParameters.size()>0){ if(this.genericClassParameters != null && this.genericClassParameters.size()>0){
ret.attach("<"); ret.attach("<");
@ -1218,7 +1218,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
* Errechnet die Generischen Parameter der Klasse für diese Klasse. * Errechnet die Generischen Parameter der Klasse für diese Klasse.
* Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben. * Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben.
* @param tphs : Alle übriggebliebenen TypePLaceholder * @param tphs : Alle übriggebliebenen TypePLaceholder
*/
private void createGenericTypeVars(Vector<TypePlaceholder> tphs){ private void createGenericTypeVars(Vector<TypePlaceholder> tphs){
this.genericClassParameters = new GenericDeclarationList(new Vector<GenericTypeVar>()); this.genericClassParameters = new GenericDeclarationList(new Vector<GenericTypeVar>());
for(TypePlaceholder tph : tphs){ for(TypePlaceholder tph : tphs){
@ -1226,7 +1226,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
if(!this.genericClassParameters.contains(toAdd))this.genericClassParameters.add(toAdd); if(!this.genericClassParameters.contains(toAdd))this.genericClassParameters.add(toAdd);
} }
} }
*/
/** /**
* Errechnet die Generischen Parameter der Klasse für diese Klasse. * Errechnet die Generischen Parameter der Klasse für diese Klasse.
* Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben. * Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben.

View File

@ -13,9 +13,8 @@ import mycompiler.mytype.GenericTypeVar;
*/ */
public class GenericDeclarationList extends Vector<GenericTypeVar>{ public class GenericDeclarationList extends Vector<GenericTypeVar>{
public GenericDeclarationList(Vector<GenericTypeVar> vector) { public GenericDeclarationList(Vector<GenericTypeVar> vector, int offset) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
} }

View File

@ -169,18 +169,6 @@ null {
{ws}|\n { /* System.out.print(yytext()); */ } {ws}|\n { /* System.out.print(yytext()); */ }
\\.\n {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());} \\.\n {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());}
"->" {this.token = new Token(JavaParser.LAMBDAASSIGNMENT, yytext(), yyline, yychar);return true;} "->" {this.token = new Token(JavaParser.LAMBDAASSIGNMENT, yytext(), yyline, yychar);return true;}
">" {this.token = new Token(JavaParser.ENDOFGENERICVARDECLARATION, yytext(), yyline, yychar);return true;}

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ Backup von JavaParser.jay 10.April 17 Uhr
package mycompiler.myparser; package mycompiler.myparser;
import mycompiler.myclass.FieldDeclaration; import mycompiler.myclass.FieldDeclaration;
import mycompiler.myclass.GenericDeclarationList;
import mycompiler.myclass.Field; import mycompiler.myclass.Field;
import java.util.Vector; import java.util.Vector;
import mycompiler.SourceFile; import mycompiler.SourceFile;
@ -200,6 +201,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
%token OP %token OP
%token EOF %token EOF
%token LAMBDAASSIGNMENT %token LAMBDAASSIGNMENT
%token <Token> ENDOFGENERICVARDECLARATION
%type <Class> classdeclaration %type <Class> classdeclaration
%type <Interface> interfacedeclaration %type <Interface> interfacedeclaration
@ -903,13 +905,13 @@ fielddeclarator :
} }
genericdeclarationlist : '<' boundedMethodParameters '>' genericdeclarationlist : '<' boundedMethodParameters ENDOFGENERICVARDECLARATION
{ {
GenericDeclarationList ret = new GenericDeclarationList($2); GenericDeclarationList ret = new GenericDeclarationList($2,$3.getOffset());
ret.setOffset($3.getOffset());
$$ = ret; $$ = ret;
} }
fielddeclaration : fielddeclarator ';' fielddeclaration : fielddeclarator ';'
{ {
$$=$1; $$=$1;

View File

@ -29,8 +29,8 @@ public class GeneralParserTest{
public void run(){ public void run(){
Vector<String> filenames = new Vector<String>(); Vector<String> filenames = new Vector<String>();
filenames.add("FieldInitializationTest.jav"); filenames.add("FieldInitializationTest.jav");
filenames.add("ImportTest.jav"); //filenames.add("ImportTest.jav");
filenames.add("BoundedParameter.jav"); //filenames.add("BoundedParameter.jav");
filenames.add("GenericFieldVarTest.jav"); filenames.add("GenericFieldVarTest.jav");
MyCompilerAPI compiler = MyCompiler.getAPI(); MyCompilerAPI compiler = MyCompiler.getAPI();
try{ try{

File diff suppressed because it is too large Load Diff