Structure and Fixes
This commit is contained in:
parent
c9ec426412
commit
b7cb34c6ec
BIN
Tester.class
BIN
Tester.class
Binary file not shown.
@ -1,3 +1,2 @@
|
|||||||
public class Example {
|
public class Example {
|
||||||
}
|
}
|
||||||
|
|
@ -14,9 +14,11 @@ import java.nio.file.Paths;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
CharStream codeCharStream = null;
|
CharStream codeCharStream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
codeCharStream = CharStreams.fromPath(Paths.get("./Example.java"));
|
codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/CompilerInput.txt"));
|
||||||
parsefile(codeCharStream);
|
parsefile(codeCharStream);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Error reading the file: " + e.getMessage());
|
System.err.println("Error reading the file: " + e.getMessage());
|
||||||
@ -25,7 +27,7 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
static void parsefile(CharStream codeCharStream){
|
static void parsefile(CharStream codeCharStream){
|
||||||
// CharStream codeCharStream = CharStreams.fromString("class Example { } class Example2 { }");
|
// CharStream codeCharStream = CharStreams.fromString("class javaFileInput.Example { } class Example2 { }");
|
||||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
||||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
SimpleJavaParser parser = new SimpleJavaParser(tokens);
|
SimpleJavaParser parser = new SimpleJavaParser(tokens);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
public class SimpleJavaFeatureTest {
|
public class AllFeaturesClassExample {
|
||||||
int a;
|
int a;
|
||||||
boolean b;
|
boolean b;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
// Konstruktor
|
// Konstruktor
|
||||||
SimpleJavaFeatureTest(int a, boolean b, char c) {
|
AllFeaturesClassExample(int a, boolean b, char c) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
@ -62,7 +62,7 @@ public class SimpleJavaFeatureTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SimpleJavaFeatureTest obj = new SimpleJavaFeatureTest(12, true, 'a');
|
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||||
obj.controlStructures();
|
obj.controlStructures();
|
||||||
obj.logicalOperations();
|
obj.logicalOperations();
|
||||||
}
|
}
|
4
src/main/test/java/EmptyClassExample.java
Normal file
4
src/main/test/java/EmptyClassExample.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
public class EmptyClassExample {
|
||||||
|
private class Inner {
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ public class MainTest {
|
|||||||
void testEmptyClass() {
|
void testEmptyClass() {
|
||||||
CharStream codeCharStream = null;
|
CharStream codeCharStream = null;
|
||||||
try {
|
try {
|
||||||
codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java"));
|
codeCharStream = CharStreams.fromPath(Paths.get("src/main/test/java/EmptyClassExample.java"));
|
||||||
Main.parsefile(codeCharStream);
|
Main.parsefile(codeCharStream);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Error reading the file: " + e.getMessage());
|
System.err.println("Error reading the file: " + e.getMessage());
|
||||||
|
6
src/main/test/java/MoreFeaturesClassExample.java
Normal file
6
src/main/test/java/MoreFeaturesClassExample.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
public class MoreFeaturesClassExample {
|
||||||
|
int hallo;
|
||||||
|
private class Inner {
|
||||||
|
int hallo2;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
### Beispiel 2: Filled Class
|
### Beispiel 2: Filled Class
|
||||||
|
|
||||||
String filled class =
|
String filled class =
|
||||||
"class Example {" +
|
"class javaFileInput.Example {" +
|
||||||
"if (x < 5) {" +
|
"if (x < 5) {" +
|
||||||
"for (int i = 0; i < 10; i++) {" +
|
"for (int i = 0; i < 10; i++) {" +
|
||||||
"while (true) {" +
|
"while (true) {" +
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
### Beispiel 2: Filled Class
|
### Beispiel 2: Filled Class
|
||||||
|
|
||||||
[TokClass,TokIdentifier "Example",TokLeftBrace]
|
[TokClass,TokIdentifier "javaFileInput.Example",TokLeftBrace]
|
||||||
[TokIf,TokLeftParen,TokIdentifier "x",TokLessThan,TokNumber 5,TokRightParen,TokLeftBrace]
|
[TokIf,TokLeftParen,TokIdentifier "x",TokLessThan,TokNumber 5,TokRightParen,TokLeftBrace]
|
||||||
[TokFor,TokLeftParen,TokIdentifier "int",TokIdentifier "i",TokAssign,TokNumber 0,TokSemicolon,TokIdentifier "i",TokLessThan,TokNumber 10,TokSemicolon,TokIdentifier "i",TokPlus,TokPlus,TokRightParen,TokLeftBrace]
|
[TokFor,TokLeftParen,TokIdentifier "int",TokIdentifier "i",TokAssign,TokNumber 0,TokSemicolon,TokIdentifier "i",TokLessThan,TokNumber 10,TokSemicolon,TokIdentifier "i",TokPlus,TokPlus,TokRightParen,TokLeftBrace]
|
||||||
[TokWhile,TokLeftParen,TokIdentifier "true",TokRightParen,TokLeftBrace]
|
[TokWhile,TokLeftParen,TokIdentifier "true",TokRightParen,TokLeftBrace]
|
||||||
@ -63,7 +63,7 @@
|
|||||||
### Beispiel 1: Empty Class
|
### Beispiel 1: Empty Class
|
||||||
Compiled Classfile
|
Compiled Classfile
|
||||||
|
|
||||||
public class Example {
|
public class javaFileInput.Example {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
public class Tester {
|
public class Tester {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Example();
|
new EmptyClassExample();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user