diff --git a/src/de/dhbwstuttgart/parser/CompilationUnitEvaluator.java b/src/de/dhbwstuttgart/parser/CompilationUnitEvaluator.java index 496dd290..9260bccf 100644 --- a/src/de/dhbwstuttgart/parser/CompilationUnitEvaluator.java +++ b/src/de/dhbwstuttgart/parser/CompilationUnitEvaluator.java @@ -2,11 +2,14 @@ package de.dhbwstuttgart.parser; import org.antlr.v4.runtime.tree.*; import de.dhbwstuttgart.syntaxtree.*; public class CompilationUnitEvaluator extends Java8BaseListener{ + @Override + public void enterCompilationUnit(Java8Parser.CompilationUnitContext ctx) { + System.out.println("Entering compilationUnit..."); + } @Override public void exitCompilationUnit(Java8Parser.CompilationUnitContext ctx) { - // SourceFile result = new SourceFile(new List()); System.out.println("sourceFile("); - System.out.println(ctx.packageDeclaration()); + System.out.println(ctx.packageDeclaration().Identifier()); System.out.println(")"); } } diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index d4a6a740..9b1c8653 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -6,13 +6,16 @@ import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ParseTreeWalker; import de.dhbwstuttgart.syntaxtree.*; +import java.util.Scanner; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; public class RunParser{ public static void main(String[] args){ try{ - String inputString = args[0]; + Scanner sc = new Scanner(System.in); + String inputString = sc.nextLine(); + while(sc.hasNextLine()) inputString = inputString + sc.nextLine(); InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8)); ANTLRInputStream input = new ANTLRInputStream(stream); Java8Lexer lexer = new Java8Lexer(input);