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 org.antlr.v4.runtime.tree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
public class CompilationUnitEvaluator extends Java8BaseListener{
|
public class CompilationUnitEvaluator extends Java8BaseListener{
|
||||||
|
@Override
|
||||||
|
public void enterCompilationUnit(Java8Parser.CompilationUnitContext ctx) {
|
||||||
|
System.out.println("Entering compilationUnit...");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void exitCompilationUnit(Java8Parser.CompilationUnitContext ctx) {
|
public void exitCompilationUnit(Java8Parser.CompilationUnitContext ctx) {
|
||||||
// SourceFile result = new SourceFile(new List<Class>());
|
|
||||||
System.out.println("sourceFile(");
|
System.out.println("sourceFile(");
|
||||||
System.out.println(ctx.packageDeclaration());
|
System.out.println(ctx.packageDeclaration().Identifier());
|
||||||
System.out.println(")");
|
System.out.println(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,16 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
|||||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
public class RunParser{
|
public class RunParser{
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
try{
|
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));
|
InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
|
||||||
ANTLRInputStream input = new ANTLRInputStream(stream);
|
ANTLRInputStream input = new ANTLRInputStream(stream);
|
||||||
Java8Lexer lexer = new Java8Lexer(input);
|
Java8Lexer lexer = new Java8Lexer(input);
|
||||||
|
Loading…
Reference in New Issue
Block a user