forked from JavaTX/JavaCompilerCore
rootDirectory GeneralParserTest, dep. Klasse JavaTXParser
This commit is contained in:
parent
df3e2b55f9
commit
58cd490639
@ -7,7 +7,8 @@ import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
|||||||
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
import org.antlr.v4.runtime.CharStream;
|
||||||
|
import org.antlr.v4.runtime.CharStreams;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -18,7 +19,8 @@ import java.util.List;
|
|||||||
public class JavaTXParser {
|
public class JavaTXParser {
|
||||||
public static Java8Parser.CompilationUnitContext parse(File source) throws IOException, java.lang.ClassNotFoundException {
|
public static Java8Parser.CompilationUnitContext parse(File source) throws IOException, java.lang.ClassNotFoundException {
|
||||||
InputStream stream = new FileInputStream(source);
|
InputStream stream = new FileInputStream(source);
|
||||||
ANTLRInputStream input = new ANTLRInputStream(stream);
|
//DEPRECATED: ANTLRInputStream input = new ANTLRInputStream(stream);
|
||||||
|
CharStream input = CharStreams.fromStream(stream);
|
||||||
Java8Lexer lexer = new Java8Lexer(input);
|
Java8Lexer lexer = new Java8Lexer(input);
|
||||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
Java8Parser parser = new Java8Parser(tokens);
|
Java8Parser parser = new Java8Parser(tokens);
|
||||||
|
@ -818,7 +818,7 @@ public class StatementGenerator {
|
|||||||
private Expression convert(Java8Parser.PrimaryNoNewArray_lfno_primaryContext expression) {
|
private Expression convert(Java8Parser.PrimaryNoNewArray_lfno_primaryContext expression) {
|
||||||
if(expression.literal() != null){
|
if(expression.literal() != null){
|
||||||
return convert(expression.literal());
|
return convert(expression.literal());
|
||||||
}else if(expression.parExpression().expression()!=null){
|
}else if(expression.parExpression()!=null){
|
||||||
return convert(expression.parExpression().expression());
|
return convert(expression.parExpression().expression());
|
||||||
}else if(expression.methodInvocation_lfno_primary() != null){
|
}else if(expression.methodInvocation_lfno_primary() != null){
|
||||||
return convert(expression.methodInvocation_lfno_primary());
|
return convert(expression.methodInvocation_lfno_primary());
|
||||||
|
@ -204,8 +204,7 @@ public class SyntaxTreeGenerator{
|
|||||||
List<Method> methods = new ArrayList<>();
|
List<Method> methods = new ArrayList<>();
|
||||||
List<Constructor> konstruktoren = new ArrayList<>();
|
List<Constructor> konstruktoren = new ArrayList<>();
|
||||||
//int noOfMethods = methods.size();
|
//int noOfMethods = methods.size();
|
||||||
for(int i = 0; i < methodsAndConstructors.size(); i++){
|
for(Method m : methodsAndConstructors){
|
||||||
Method m = methodsAndConstructors.get(i);
|
|
||||||
if(m instanceof Constructor){
|
if(m instanceof Constructor){
|
||||||
konstruktoren.add((Constructor) m);
|
konstruktoren.add((Constructor) m);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import org.junit.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GeneralParserTest{
|
public class GeneralParserTest{
|
||||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
|
private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/java/parser/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void run(){
|
public void run(){
|
||||||
|
@ -132,9 +132,9 @@ public class JavaTXCompilerTest {
|
|||||||
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
||||||
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
|
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
|
||||||
//filesToTest.add(new File(rootDirectory+"Import.jav"));
|
//filesToTest.add(new File(rootDirectory+"Import.jav"));
|
||||||
// //filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
||||||
// //filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||||
// //filesToTest.add(new File(rootDirectory+"test.jav"));
|
//filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||||
for(File f : compiler.sourceFiles.keySet()){
|
for(File f : compiler.sourceFiles.keySet()){
|
||||||
SourceFile sf = compiler.sourceFiles.get(f);
|
SourceFile sf = compiler.sourceFiles.get(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user