forked from JavaTX/JavaCompilerCore
Small changes, i.e. RunParser now reads from System.in.
This commit is contained in:
parent
81e223334b
commit
b0a6585252
@ -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(")");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user