Small changes, i.e. RunParser now reads from System.in.

This commit is contained in:
Jakob Herrmann 2016-12-15 13:35:07 +01:00
parent 81e223334b
commit b0a6585252
2 changed files with 9 additions and 3 deletions

View File

@ -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<Class>());
System.out.println("sourceFile(");
System.out.println(ctx.packageDeclaration());
System.out.println(ctx.packageDeclaration().Identifier());
System.out.println(")");
}
}

View File

@ -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);