Environment einführen

This commit is contained in:
Andreas Stadelmeier 2017-09-20 14:00:44 +02:00
parent 6e03d24582
commit b1adc4671d
2 changed files with 11 additions and 2 deletions

View File

@ -21,6 +21,8 @@ import java.util.stream.Collectors;
public class JavaTXCompiler { public class JavaTXCompiler {
CompilationEnvironment environment;
protected List<SourceFile> sourceFiles = new ArrayList<>(); protected List<SourceFile> sourceFiles = new ArrayList<>();
/* /*
public JavaTXCompiler(List<File> sourceFiles){ public JavaTXCompiler(List<File> sourceFiles){
@ -68,13 +70,13 @@ public class JavaTXCompiler {
} }
public SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException { public SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
SourceFile ret = new JavaTXParser().parse(sourceFile); SourceFile ret = new JavaTXParser(environment).parse(sourceFile);
sourceFiles.add(ret); sourceFiles.add(ret);
return ret; return ret;
} }
public SourceFile parse(String source) throws IOException, java.lang.ClassNotFoundException { public SourceFile parse(String source) throws IOException, java.lang.ClassNotFoundException {
SourceFile ret = new JavaTXParser().parse(source); SourceFile ret = new JavaTXParser(environment).parse(source);
sourceFiles.add(ret); sourceFiles.add(ret);
return ret; return ret;
} }

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.parser; package de.dhbwstuttgart.parser;
import de.dhbwstuttgart.core.CompilationEnvironment;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator;
import de.dhbwstuttgart.parser.antlr.Java8Lexer; import de.dhbwstuttgart.parser.antlr.Java8Lexer;
import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.antlr.Java8Parser;
@ -14,6 +15,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class JavaTXParser { public class JavaTXParser {
CompilationEnvironment environment;
public JavaTXParser(CompilationEnvironment env) {
environment = env;
}
public SourceFile parse(InputStream source) throws IOException, java.lang.ClassNotFoundException { public SourceFile parse(InputStream source) throws IOException, java.lang.ClassNotFoundException {
InputStream stream = source;//new FileInputStream(sourceFile); InputStream stream = source;//new FileInputStream(sourceFile);
ANTLRInputStream input = new ANTLRInputStream(stream); ANTLRInputStream input = new ANTLRInputStream(stream);