From 4c79023889afee3c17dca32238cb94e2bf9635c9 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Mon, 16 Jan 2017 14:28:22 +0100 Subject: [PATCH 01/10] Implement base constructor in ClassOrInterface. --- .../syntaxtree/ClassOrInterface.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java index b2d70b7f..e160972b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java +++ b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java @@ -24,19 +24,36 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith protected boolean isInterface; private List implementedInterfaces; + public ClassOrInterface(Modifiers modifiers, JavaClassName name, Block class_block, List fielddecl, GenericDeclarationList genericClassParameters, int offset, RefType superClass, Boolean isInterface, List implementedInterfaces){ + if(modifiers != null){ + this.modifiers = modifiers; + } + if(name != null){ + this.name = name; + } + if(class_block != null){ + this.class_block = class_block; + } + if(fielddecl != null){ + this.fielddecl = fielddecl; + } + if(genericClassParameters != null){ + this.genericClassParameters = genericClassParameters; + } + this.offset = offset; + if(superClass != null){ + this.superClass = superClass; + } + this.isInterface = isInterface; + if(implementedInterfaces != null){ + this.implementedInterfaces = implementedInterfaces; + } + } + // Gets class name public JavaClassName getClassName(){ return this.name; } - // Sets class name. - public void setClassName(JavaClassName name){ - this.name = name; - } - - // Sets interface "switch". - public void setInterface(Boolean isInterface){ - this.isInterface = isInterface; - } } From 0db15bffa85b6e603da6c0a85d3d9ecc3c02a5ab Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Mon, 16 Jan 2017 23:32:12 +0100 Subject: [PATCH 02/10] Begin rewriting of convert for TypeDecl. --- src/de/dhbwstuttgart/parser/RunParser.java | 11 +++- .../parser/SyntaxTreeGenerator.java | 64 ++++++++++++------- .../dhbwstuttgart/syntaxtree/SourceFile.java | 4 ++ 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index 6f04ac55..b557f0a1 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -10,6 +10,7 @@ import de.dhbwstuttgart.typecheck.*; import java.util.Scanner; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.IOException; import java.nio.charset.StandardCharsets; public class RunParser{ public static void main(String[] args){ @@ -24,14 +25,18 @@ public class RunParser{ Java8Parser parser = new Java8Parser(tokens); Java8Parser.CompilationUnitContext tree = parser.compilationUnit(); SyntaxTreeGenerator generator = new SyntaxTreeGenerator(); - generator.getNames(tree); SourceFile f = generator.convert((Java8Parser.CompilationUnitContext) tree); + String pkgName = f.getPkgName(); + System.out.println(pkgName); for(ClassOrInterface c : f.KlassenVektor){ System.out.println(c.getClassName().toString()); } } - catch(Exception e){ - System.out.println("An exception occured which is unknown and on our TODO list."); + catch(java.util.NoSuchElementException e){ + System.out.println("Error: Source seems to be empty."); + } + catch(IOException e){ + System.out.println("An exception occured which is on our TODO list."); e.printStackTrace(); } } diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index bc9c773a..0e4468df 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -1,29 +1,33 @@ package de.dhbwstuttgart.parser; -import de.dhbwstuttgart.syntaxtree.SourceFile; -import de.dhbwstuttgart.syntaxtree.ClassOrInterface; +import de.dhbwstuttgart.syntaxtree.*; +import de.dhbwstuttgart.syntaxtree.modifier.*; +import de.dhbwstuttgart.syntaxtree.statement.Block; +import de.dhbwstuttgart.syntaxtree.statement.Expr; +import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.typecheck.*; - import java.util.ArrayList; import java.util.List; import org.antlr.v4.runtime.tree.TerminalNode; public class SyntaxTreeGenerator{ JavaClassRegistry reg = new JavaClassRegistry(); - String packageDecl = ""; + String pkgName = null; + List imports = null; public void getNames(Java8Parser.CompilationUnitContext ctx){ if(ctx.packageDeclaration() != null){ + this.pkgName = ""; for(TerminalNode t : ctx.packageDeclaration().Identifier()){ - this.packageDecl = this.packageDecl + "." + t.toString(); + this.pkgName = this.pkgName + "." + t.toString(); } - this.packageDecl = this.packageDecl.substring(1); + this.pkgName = this.pkgName.substring(1); } String nameString = ""; for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ if(typeDecl.interfaceDeclaration() != null){ if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){ - if(packageDecl != ""){ - nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString(); + if(this.pkgName != null){ + nameString = this.pkgName + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString(); } else{ nameString = typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString(); @@ -33,8 +37,8 @@ public class SyntaxTreeGenerator{ } else{ if(typeDecl.classDeclaration().normalClassDeclaration() != null){ - if(packageDecl != ""){ - nameString = packageDecl + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString(); + if(this.pkgName != ""){ + nameString = this.pkgName + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString(); } else{ nameString = typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString(); @@ -47,23 +51,39 @@ public class SyntaxTreeGenerator{ public SourceFile convert(Java8Parser.CompilationUnitContext ctx){ List classes = new ArrayList<>(); + this.getNames(ctx); for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ - ClassOrInterface newClass = convert(typeDecl.classDeclaration()); + ClassOrInterface newClass = convert(typeDecl); classes.add(newClass); } - return new SourceFile(classes); + return new SourceFile(this.pkgName, classes, this.imports); } - private ClassOrInterface convert(Java8Parser.ClassDeclarationContext ctx) { - ClassOrInterface newClass = new ClassOrInterface(); - String name = ""; - if(this.packageDecl != ""){ - name = packageDecl + "." + ctx.normalClassDeclaration().Identifier().toString(); + private ClassOrInterface convert(Java8Parser.TypeDeclarationContext ctx) { + Java8Parser.ClassDeclarationContext cl = ctx.classDeclaration(); + Java8Parser.InterfaceDeclarationContext id = ctx.interfaceDeclaration(); + if(cl != null){ + Java8Parser.NormalClassDeclarationContext nc = cl.normalClassDeclaration(); + if(nc != null){ + Modifiers modifiers = null; + JavaClassName name = null; + if(this.pkgName != null){ + name = new JavaClassName(this.pkgName +"."+ nc.Identifier().toString()); + } + else{ + name = new JavaClassName(nc.Identifier().toString()); + } + System.out.println("Created name" + name); + Block class_block = null; + List fielddecl = null; + GenericDeclarationList genericClassParameters = null; + int offset = 0; + RefType superClass = null; + Boolean isInterface = false; + List implementedInterfaces = null; + return new ClassOrInterface(modifiers, name, class_block, fielddecl, genericClassParameters, offset, superClass, isInterface, implementedInterfaces); + } } - else{ - name = ctx.normalClassDeclaration().Identifier().toString(); - } - newClass.setClassName(new JavaClassName(name)); - return newClass; + return null; } } diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 6e51c074..57d9658f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -36,4 +36,8 @@ public class SourceFile extends SyntaxTreeNode{ public SourceFile(List classDefinitions, List imports){ this(null, classDefinitions, imports); } + + public String getPkgName(){ + return this.pkgName; + } } From 9ef41280ca53d36049b2fbbd8fa6890474dce12b Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Tue, 17 Jan 2017 00:58:03 +0100 Subject: [PATCH 03/10] * Implement missing constructor for Modifiers. * TODO: convert for Modifier --- .../dhbwstuttgart/parser/SyntaxTreeGenerator.java | 13 ++++++++++++- .../syntaxtree/modifier/Modifiers.java | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 0e4468df..4b5c1d64 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -66,6 +66,14 @@ public class SyntaxTreeGenerator{ Java8Parser.NormalClassDeclarationContext nc = cl.normalClassDeclaration(); if(nc != null){ Modifiers modifiers = null; + if(nc.classModifier() != null){ + List modList = new ArrayList(); + for(Java8Parser.ClassModifierContext mod : nc.classModifier()){ + Modifier m = convert(mod); + modList.add(m); + } + modifiers = new Modifiers(modList); + } JavaClassName name = null; if(this.pkgName != null){ name = new JavaClassName(this.pkgName +"."+ nc.Identifier().toString()); @@ -73,7 +81,6 @@ public class SyntaxTreeGenerator{ else{ name = new JavaClassName(nc.Identifier().toString()); } - System.out.println("Created name" + name); Block class_block = null; List fielddecl = null; GenericDeclarationList genericClassParameters = null; @@ -86,4 +93,8 @@ public class SyntaxTreeGenerator{ } return null; } + + private Modifier convert(Java8Parser.ClassModifierContext ctx){ + return null; + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java b/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java index efed7fd9..10162203 100755 --- a/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java +++ b/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java @@ -15,6 +15,10 @@ import java.util.List; public class Modifiers { protected List modifier = new ArrayList(); + + public Modifiers(List modifier){ + this.modifier = modifier; + } // ino.end From 5814cac83f5048e858a0a7bb1d77ddbf64e819a7 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Tue, 17 Jan 2017 12:34:23 +0100 Subject: [PATCH 04/10] Start rewriting converters to simplify readability etc. --- .../parser/SyntaxTreeGenerator.java | 43 ++++--------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 4b5c1d64..c81bb537 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -53,48 +53,23 @@ public class SyntaxTreeGenerator{ List classes = new ArrayList<>(); this.getNames(ctx); for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ - ClassOrInterface newClass = convert(typeDecl); + ClassOrInterface newClass = null; + if(typeDecl.classDeclaration() != null){ + newClass = convertCl(typeDecl.classDeclaration()); + } + else{ + newClass = convertIf(typeDecl.interfaceDeclaration()); + } classes.add(newClass); } return new SourceFile(this.pkgName, classes, this.imports); } - private ClassOrInterface convert(Java8Parser.TypeDeclarationContext ctx) { - Java8Parser.ClassDeclarationContext cl = ctx.classDeclaration(); - Java8Parser.InterfaceDeclarationContext id = ctx.interfaceDeclaration(); - if(cl != null){ - Java8Parser.NormalClassDeclarationContext nc = cl.normalClassDeclaration(); - if(nc != null){ - Modifiers modifiers = null; - if(nc.classModifier() != null){ - List modList = new ArrayList(); - for(Java8Parser.ClassModifierContext mod : nc.classModifier()){ - Modifier m = convert(mod); - modList.add(m); - } - modifiers = new Modifiers(modList); - } - JavaClassName name = null; - if(this.pkgName != null){ - name = new JavaClassName(this.pkgName +"."+ nc.Identifier().toString()); - } - else{ - name = new JavaClassName(nc.Identifier().toString()); - } - Block class_block = null; - List fielddecl = null; - GenericDeclarationList genericClassParameters = null; - int offset = 0; - RefType superClass = null; - Boolean isInterface = false; - List implementedInterfaces = null; - return new ClassOrInterface(modifiers, name, class_block, fielddecl, genericClassParameters, offset, superClass, isInterface, implementedInterfaces); - } - } + private ClassOrInterface convertCl(Java8Parser.ClassDeclarationContext ctx) { return null; } - private Modifier convert(Java8Parser.ClassModifierContext ctx){ + private ClassOrInterface convertIf(Java8Parser.InterfaceDeclarationContext ctx){ return null; } } From fbfa407c261222b61bfac8454c2c26287b987aa6 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Tue, 17 Jan 2017 20:59:42 +0100 Subject: [PATCH 05/10] More converters & cleanup. --- .../parser/SyntaxTreeGenerator.java | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index c81bb537..2da9691e 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -55,21 +55,59 @@ public class SyntaxTreeGenerator{ for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ ClassOrInterface newClass = null; if(typeDecl.classDeclaration() != null){ - newClass = convertCl(typeDecl.classDeclaration()); + newClass = convertClass(typeDecl.classDeclaration()); } else{ - newClass = convertIf(typeDecl.interfaceDeclaration()); + newClass = convertInterface(typeDecl.interfaceDeclaration()); } classes.add(newClass); } return new SourceFile(this.pkgName, classes, this.imports); } - private ClassOrInterface convertCl(Java8Parser.ClassDeclarationContext ctx) { + private ClassOrInterface convertClass(Java8Parser.ClassDeclarationContext ctx) { + ClassOrInterface newClass = null; + if(ctx.normalClassDeclaration() != null){ + newClass = convertNormal(ctx.normalClassDeclaration()); + } + else{ + newClass = convertEnum(ctx.enumDeclaration()); + } + return newClass; + } + + private ClassOrInterface convertNormal(Java8Parser.NormalClassDeclarationContext ctx){ + Modifiers modifiers = null; + JavaClassName name = convert(ctx.Identifier()); + Block class_block = null; + List fielddecl = null; + GenericDeclarationList genericClassParameters = null; + int offset = 0; + RefType superClass = null; + Boolean isInterface = false; + List implementedInterfaces = null; + return new ClassOrInterface(modifiers, name, class_block, fielddecl, genericClassParameters, offset, superClass, isInterface, implementedInterfaces); + } + + /** + Converts a TerminalNode to JavaClassName. If pkgName is set, it will be included like expected. + **/ + private JavaClassName convert(TerminalNode t){ + String name = ""; + if(this.pkgName != null){ + name = this.pkgName + "." + t.toString(); + } + else{ + name = t.toString(); + } + return new JavaClassName(name); + } + + private ClassOrInterface convertEnum(Java8Parser.EnumDeclarationContext ctx){ return null; } - private ClassOrInterface convertIf(Java8Parser.InterfaceDeclarationContext ctx){ + private ClassOrInterface convertInterface(Java8Parser.InterfaceDeclarationContext ctx){ return null; } } From 68476f9f96084bc685e6f054dee5d5939623a345 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Wed, 18 Jan 2017 00:45:46 +0100 Subject: [PATCH 06/10] * Implemented converter for Modifier. * Missing getters etc. in some classes added. --- src/de/dhbwstuttgart/parser/RunParser.java | 5 +++ .../parser/SyntaxTreeGenerator.java | 34 +++++++++++++++++++ .../syntaxtree/ClassOrInterface.java | 4 +++ .../syntaxtree/modifier/Modifiers.java | 11 +++--- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index b557f0a1..10e4ea8b 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -5,6 +5,7 @@ import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ParseTreeWalker; import de.dhbwstuttgart.syntaxtree.*; +import de.dhbwstuttgart.syntaxtree.modifier.*; import de.dhbwstuttgart.typecheck.*; import java.util.Scanner; @@ -28,7 +29,11 @@ public class RunParser{ SourceFile f = generator.convert((Java8Parser.CompilationUnitContext) tree); String pkgName = f.getPkgName(); System.out.println(pkgName); + System.out.println("classes:"); for(ClassOrInterface c : f.KlassenVektor){ + for(Modifier mod : c.getModifiers().getModifierList()){ + System.out.println(mod.getClass().getName()); + } System.out.println(c.getClassName().toString()); } } diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 2da9691e..32c721e7 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -78,6 +78,14 @@ public class SyntaxTreeGenerator{ private ClassOrInterface convertNormal(Java8Parser.NormalClassDeclarationContext ctx){ Modifiers modifiers = null; + if(ctx.classModifier() != null){ + List modList = new ArrayList(); + for(Java8Parser.ClassModifierContext mod : ctx.classModifier()){ + Modifier newModifier = convert(mod); + modList.add(newModifier); + } + modifiers = new Modifiers(modList); + } JavaClassName name = convert(ctx.Identifier()); Block class_block = null; List fielddecl = null; @@ -89,6 +97,32 @@ public class SyntaxTreeGenerator{ return new ClassOrInterface(modifiers, name, class_block, fielddecl, genericClassParameters, offset, superClass, isInterface, implementedInterfaces); } + private Modifier convert(Java8Parser.ClassModifierContext ctx){ + Modifier newModifier = null; + if(ctx.annotation() == null){ + TerminalNode t = (TerminalNode)ctx.getChild(0); + if(t.getText().equals("public")){ + newModifier = new Public(); + } + else if(t.getText().equals("private")){ + newModifier = new Private(); + } + else if(t.getText().equals("protected")){ + newModifier = new Protected(); + } + else if(t.getText().equals("abstract")){ + newModifier = new Abstract(); + } + else if(t.getText().equals("static")){ + newModifier = new Static(); + } + else{ + newModifier = new Final(); + } + } + return newModifier; + } + /** Converts a TerminalNode to JavaClassName. If pkgName is set, it will be included like expected. **/ diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java index e160972b..89fe9daa 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java +++ b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java @@ -55,5 +55,9 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith return this.name; } + // Get modifiers + public Modifiers getModifiers(){ + return this.modifiers; + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java b/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java index 10162203..dfb4785f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java +++ b/src/de/dhbwstuttgart/syntaxtree/modifier/Modifiers.java @@ -18,9 +18,10 @@ public class Modifiers public Modifiers(List modifier){ this.modifier = modifier; - } - // ino.end - - + } + + public List getModifierList(){ + return this.modifier; + } } -// ino.end + From c3320858a364b0853f55571dce339be6704c0138 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Wed, 18 Jan 2017 13:27:17 +0100 Subject: [PATCH 07/10] RunParser no handles line breaks.This should also fix problems with comments. --- src/de/dhbwstuttgart/parser/RunParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index 10e4ea8b..b5118a92 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -18,7 +18,7 @@ public class RunParser{ try{ Scanner sc = new Scanner(System.in); String inputString = sc.nextLine(); - while(sc.hasNextLine()) inputString = inputString + sc.nextLine(); + while(sc.hasNextLine()) inputString = inputString + sc.nextLine() + "\n"; InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8)); ANTLRInputStream input = new ANTLRInputStream(stream); Java8Lexer lexer = new Java8Lexer(input); From e8537c3886822a48a173c282a3d9b709460f6263 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Wed, 18 Jan 2017 15:12:16 +0100 Subject: [PATCH 08/10] TODO cleanup --- src/de/dhbwstuttgart/parser/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/parser/TODO b/src/de/dhbwstuttgart/parser/TODO index ae1d80c4..165cb562 100644 --- a/src/de/dhbwstuttgart/parser/TODO +++ b/src/de/dhbwstuttgart/parser/TODO @@ -2,4 +2,4 @@ * Core-Problem: Typinferenz vs. Konstruktoren * möglicherweise Problem: falsche Return-Expressions -* Problem: Line-Comments werden nicht erkannt bzw. führen dazu dass das gesamte File nicht geparsed wird (Java8.g4). + From a1bbd8b11e89df6906624c364418dc886e960880 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Wed, 18 Jan 2017 15:55:07 +0100 Subject: [PATCH 09/10] Implement Strictfp modifier. --- .../syntaxtree/modifier/Strictfp.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 src/de/dhbwstuttgart/syntaxtree/modifier/Strictfp.java diff --git a/src/de/dhbwstuttgart/syntaxtree/modifier/Strictfp.java b/src/de/dhbwstuttgart/syntaxtree/modifier/Strictfp.java new file mode 100755 index 00000000..b9cdb1ef --- /dev/null +++ b/src/de/dhbwstuttgart/syntaxtree/modifier/Strictfp.java @@ -0,0 +1,20 @@ +// ino.module.Public.8591.package +package de.dhbwstuttgart.syntaxtree.modifier; + +// ino.class.Public.24073.declaration +public class Strictfp extends Modifier +// ino.end +// ino.class.Public.24073.body +{ + + // ino.method.getBitmask.24077.definition + public short getBitmask() + // ino.end + // ino.method.getBitmask.24077.body + { + return 2048; + } + // ino.end + +} +// ino.end From a77b65e65cd8f3e1ff5b8f6f80fb1b3d232754bb Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Wed, 18 Jan 2017 15:58:34 +0100 Subject: [PATCH 10/10] Extend converter for modifiers by strictfp. --- src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 32c721e7..8e01897e 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -116,6 +116,9 @@ public class SyntaxTreeGenerator{ else if(t.getText().equals("static")){ newModifier = new Static(); } + else if(t.getText().equals("strictfp")){ + newModifier = new Strictfp(); + } else{ newModifier = new Final(); }