From a86bede5a78e6dc0af9a0881544d52aa00e6a4cd Mon Sep 17 00:00:00 2001
From: Bruder John
Date: Thu, 9 May 2024 00:13:23 +0200
Subject: [PATCH 1/4] Added down to Expression
---
src/main/java/CompilerInput.txt | 6 +++++
src/main/java/Main.java | 3 ---
src/main/java/ast/AssignmentNode.java | 14 ++++++++++++
src/main/java/ast/ExpressionNode.java | 9 +++++++-
src/main/java/classFileOutput/Example.class | Bin 100 -> 108 bytes
src/main/java/parser/ASTBuilder.java | 23 ++++++++++++++++++++
6 files changed, 51 insertions(+), 4 deletions(-)
create mode 100644 src/main/java/ast/AssignmentNode.java
diff --git a/src/main/java/CompilerInput.txt b/src/main/java/CompilerInput.txt
index 0a31d5c..a7d717c 100644
--- a/src/main/java/CompilerInput.txt
+++ b/src/main/java/CompilerInput.txt
@@ -2,6 +2,12 @@ public class Example {
public int test;
+ public static int test(char b){
+
+ test = 3;
+
+ }
+
}
public class Test {
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
index e15eafa..bcb48c5 100644
--- a/src/main/java/Main.java
+++ b/src/main/java/Main.java
@@ -9,9 +9,6 @@ import parser.ASTBuilder;
import parser.generated.SimpleJavaLexer;
import parser.generated.SimpleJavaParser;
import semantic.SemanticAnalyzer;
-import ast.ClassNode;
-import ast.ProgramNode;
-import bytecode.ByteCodeGenerator;
import java.io.IOException;
import java.nio.file.Paths;
diff --git a/src/main/java/ast/AssignmentNode.java b/src/main/java/ast/AssignmentNode.java
new file mode 100644
index 0000000..38e7fb9
--- /dev/null
+++ b/src/main/java/ast/AssignmentNode.java
@@ -0,0 +1,14 @@
+package ast;
+
+public class AssignmentNode extends StatementNode {
+
+ public Identifier identifier;
+
+ public ExpressionNode expression;
+
+ public AssignmentNode(String identifier, ExpressionNode expression) {
+ this.identifier = new Identifier(identifier);
+ this.expression = expression;
+ }
+
+}
diff --git a/src/main/java/ast/ExpressionNode.java b/src/main/java/ast/ExpressionNode.java
index 891d87c..9e6f2a8 100644
--- a/src/main/java/ast/ExpressionNode.java
+++ b/src/main/java/ast/ExpressionNode.java
@@ -1,4 +1,11 @@
package ast;
-public class ExpressionNode {
+public class ExpressionNode extends ASTNode {
+
+ int Value;
+
+ public ExpressionNode(int value) {
+ this.Value = value;
+ }
+
}
diff --git a/src/main/java/classFileOutput/Example.class b/src/main/java/classFileOutput/Example.class
index 7490cc13f94b6ef8362c61528e6ed8b919e01a52..c4a896adb0f253a0ebeaa67c21c610091b4b047a 100644
GIT binary patch
delta 24
XcmYevnGh+=#K6eF%D~3J0H+xMDQ^Mi
delta 16
Vcmc~vnGng%$iT?J%D~0|1OOT80nz{f
diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/ASTBuilder.java
index f57181d..e90ba95 100644
--- a/src/main/java/parser/ASTBuilder.java
+++ b/src/main/java/parser/ASTBuilder.java
@@ -6,6 +6,7 @@ import parser.generated.SimpleJavaParser;
import java.util.ArrayList;
import java.util.List;
+import parser.generated.SimpleJavaParser.LiteralContext;
public class ASTBuilder extends SimpleJavaBaseVisitor {
@Override
@@ -107,4 +108,26 @@ public class ASTBuilder extends SimpleJavaBaseVisitor {
return null;
}
+ @Override
+ public ASTNode visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) {
+ ExpressionNode expressionNode = (ExpressionNode) visit(ctx.expression());
+ return new AssignmentNode(ctx.IDENTIFIER().getText(), expressionNode);
+ }
+
+ @Override
+ public ASTNode visitExpression(SimpleJavaParser.ExpressionContext ctx) {
+ if(ctx.literal() != null){
+ return visitLiteral(ctx.literal());
+ }
+ return null;
+ }
+
+ @Override
+ public ASTNode visitLiteral(SimpleJavaParser.LiteralContext ctx) {
+ if(ctx.INTEGERLITERAL() != null){
+ return new ExpressionNode(Integer.parseInt(ctx.INTEGERLITERAL().getSymbol().getText()));
+ }
+ return null;
+ }
+
}
From 0bce8639f5943c66ca91ee67efe65dade5b8a187 Mon Sep 17 00:00:00 2001
From: IchHab4Euro <136733014+IchHab4Euro@users.noreply.github.com>
Date: Thu, 9 May 2024 12:56:37 +0200
Subject: [PATCH 2/4] Updated Contructor Parsing
---
.idea/misc.xml | 4 +-
src/main/java/CompilerInput.txt | 4 +
src/main/java/parser/SimpleJava.g4 | 4 +-
.../java/parser/generated/SimpleJava.interp | 3 +-
.../generated/SimpleJavaBaseListener.java | 14 +-
.../generated/SimpleJavaBaseVisitor.java | 9 +-
.../parser/generated/SimpleJavaLexer.java | 2 +-
.../parser/generated/SimpleJavaListener.java | 12 +-
.../parser/generated/SimpleJavaParser.java | 623 +++++++++++-------
.../parser/generated/SimpleJavaVisitor.java | 8 +-
10 files changed, 421 insertions(+), 262 deletions(-)
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 50ba7ce..ccb48ca 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -6,10 +6,10 @@
-
+
-
+
diff --git a/src/main/java/CompilerInput.txt b/src/main/java/CompilerInput.txt
index a7d717c..53924f6 100644
--- a/src/main/java/CompilerInput.txt
+++ b/src/main/java/CompilerInput.txt
@@ -2,6 +2,10 @@ public class Example {
public int test;
+ public Example(int conInput) {
+
+ }
+
public static int test(char b){
test = 3;
diff --git a/src/main/java/parser/SimpleJava.g4 b/src/main/java/parser/SimpleJava.g4
index 1990892..3de3979 100644
--- a/src/main/java/parser/SimpleJava.g4
+++ b/src/main/java/parser/SimpleJava.g4
@@ -4,12 +4,14 @@ program : classDeclaration+;
classDeclaration : accessType 'class' IDENTIFIER '{' memberDeclaration* '}';
-memberDeclaration : fieldDeclaration | methodDeclaration;
+memberDeclaration : fieldDeclaration | methodDeclaration | constructorDeclaration;
fieldDeclaration : accessType type IDENTIFIER ';';
methodDeclaration : accessType 'static' type IDENTIFIER '(' parameterList? ')' '{' statement* '}' ;
+constructorDeclaration : accessType IDENTIFIER '(' parameterList? ')' '{' statement* '}' ;
+
parameterList : parameter (',' parameter)* ;
parameter : type IDENTIFIER ;
diff --git a/src/main/java/parser/generated/SimpleJava.interp b/src/main/java/parser/generated/SimpleJava.interp
index bfbefcd..00547cb 100644
--- a/src/main/java/parser/generated/SimpleJava.interp
+++ b/src/main/java/parser/generated/SimpleJava.interp
@@ -86,6 +86,7 @@ classDeclaration
memberDeclaration
fieldDeclaration
methodDeclaration
+constructorDeclaration
parameterList
parameter
type
@@ -104,4 +105,4 @@ charLiteral
atn:
-[4, 1, 38, 189, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 1, 0, 4, 0, 42, 8, 0, 11, 0, 12, 0, 43, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, 10, 1, 12, 1, 54, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 2, 60, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 73, 8, 4, 1, 4, 1, 4, 1, 4, 5, 4, 78, 8, 4, 10, 4, 12, 4, 81, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 88, 8, 5, 10, 5, 12, 5, 91, 9, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 106, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 3, 10, 112, 8, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 128, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 3, 14, 138, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 5, 15, 144, 8, 15, 10, 15, 12, 15, 147, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 162, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 173, 8, 16, 10, 16, 12, 16, 176, 9, 16, 1, 17, 1, 17, 1, 17, 3, 17, 181, 8, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 0, 1, 32, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 0, 6, 1, 0, 9, 11, 1, 0, 12, 13, 1, 0, 19, 20, 1, 0, 21, 26, 1, 0, 27, 31, 1, 0, 33, 34, 192, 0, 41, 1, 0, 0, 0, 2, 45, 1, 0, 0, 0, 4, 59, 1, 0, 0, 0, 6, 61, 1, 0, 0, 0, 8, 66, 1, 0, 0, 0, 10, 84, 1, 0, 0, 0, 12, 92, 1, 0, 0, 0, 14, 95, 1, 0, 0, 0, 16, 97, 1, 0, 0, 0, 18, 105, 1, 0, 0, 0, 20, 107, 1, 0, 0, 0, 22, 115, 1, 0, 0, 0, 24, 120, 1, 0, 0, 0, 26, 129, 1, 0, 0, 0, 28, 135, 1, 0, 0, 0, 30, 141, 1, 0, 0, 0, 32, 161, 1, 0, 0, 0, 34, 180, 1, 0, 0, 0, 36, 182, 1, 0, 0, 0, 38, 184, 1, 0, 0, 0, 40, 42, 3, 2, 1, 0, 41, 40, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 1, 1, 0, 0, 0, 45, 46, 3, 16, 8, 0, 46, 47, 5, 1, 0, 0, 47, 48, 5, 37, 0, 0, 48, 52, 5, 2, 0, 0, 49, 51, 3, 4, 2, 0, 50, 49, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 56, 5, 3, 0, 0, 56, 3, 1, 0, 0, 0, 57, 60, 3, 6, 3, 0, 58, 60, 3, 8, 4, 0, 59, 57, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 5, 1, 0, 0, 0, 61, 62, 3, 16, 8, 0, 62, 63, 3, 14, 7, 0, 63, 64, 5, 37, 0, 0, 64, 65, 5, 4, 0, 0, 65, 7, 1, 0, 0, 0, 66, 67, 3, 16, 8, 0, 67, 68, 5, 5, 0, 0, 68, 69, 3, 14, 7, 0, 69, 70, 5, 37, 0, 0, 70, 72, 5, 6, 0, 0, 71, 73, 3, 10, 5, 0, 72, 71, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 75, 5, 7, 0, 0, 75, 79, 5, 2, 0, 0, 76, 78, 3, 18, 9, 0, 77, 76, 1, 0, 0, 0, 78, 81, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 83, 5, 3, 0, 0, 83, 9, 1, 0, 0, 0, 84, 89, 3, 12, 6, 0, 85, 86, 5, 8, 0, 0, 86, 88, 3, 12, 6, 0, 87, 85, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 11, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 93, 3, 14, 7, 0, 93, 94, 5, 37, 0, 0, 94, 13, 1, 0, 0, 0, 95, 96, 7, 0, 0, 0, 96, 15, 1, 0, 0, 0, 97, 98, 7, 1, 0, 0, 98, 17, 1, 0, 0, 0, 99, 106, 3, 20, 10, 0, 100, 106, 3, 22, 11, 0, 101, 106, 3, 24, 12, 0, 102, 106, 3, 26, 13, 0, 103, 106, 3, 28, 14, 0, 104, 106, 3, 30, 15, 0, 105, 99, 1, 0, 0, 0, 105, 100, 1, 0, 0, 0, 105, 101, 1, 0, 0, 0, 105, 102, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 105, 104, 1, 0, 0, 0, 106, 19, 1, 0, 0, 0, 107, 108, 3, 14, 7, 0, 108, 111, 5, 37, 0, 0, 109, 110, 5, 14, 0, 0, 110, 112, 3, 32, 16, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 5, 4, 0, 0, 114, 21, 1, 0, 0, 0, 115, 116, 5, 37, 0, 0, 116, 117, 5, 14, 0, 0, 117, 118, 3, 32, 16, 0, 118, 119, 5, 4, 0, 0, 119, 23, 1, 0, 0, 0, 120, 121, 5, 15, 0, 0, 121, 122, 5, 6, 0, 0, 122, 123, 3, 32, 16, 0, 123, 124, 5, 7, 0, 0, 124, 127, 3, 18, 9, 0, 125, 126, 5, 16, 0, 0, 126, 128, 3, 18, 9, 0, 127, 125, 1, 0, 0, 0, 127, 128, 1, 0, 0, 0, 128, 25, 1, 0, 0, 0, 129, 130, 5, 17, 0, 0, 130, 131, 5, 6, 0, 0, 131, 132, 3, 32, 16, 0, 132, 133, 5, 7, 0, 0, 133, 134, 3, 18, 9, 0, 134, 27, 1, 0, 0, 0, 135, 137, 5, 18, 0, 0, 136, 138, 3, 32, 16, 0, 137, 136, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 5, 4, 0, 0, 140, 29, 1, 0, 0, 0, 141, 145, 5, 2, 0, 0, 142, 144, 3, 18, 9, 0, 143, 142, 1, 0, 0, 0, 144, 147, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 148, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 148, 149, 5, 3, 0, 0, 149, 31, 1, 0, 0, 0, 150, 151, 6, 16, -1, 0, 151, 152, 5, 28, 0, 0, 152, 162, 3, 32, 16, 5, 153, 154, 5, 32, 0, 0, 154, 162, 3, 32, 16, 4, 155, 156, 5, 6, 0, 0, 156, 157, 3, 32, 16, 0, 157, 158, 5, 7, 0, 0, 158, 162, 1, 0, 0, 0, 159, 162, 3, 34, 17, 0, 160, 162, 5, 37, 0, 0, 161, 150, 1, 0, 0, 0, 161, 153, 1, 0, 0, 0, 161, 155, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 161, 160, 1, 0, 0, 0, 162, 174, 1, 0, 0, 0, 163, 164, 10, 8, 0, 0, 164, 165, 7, 2, 0, 0, 165, 173, 3, 32, 16, 9, 166, 167, 10, 7, 0, 0, 167, 168, 7, 3, 0, 0, 168, 173, 3, 32, 16, 8, 169, 170, 10, 6, 0, 0, 170, 171, 7, 4, 0, 0, 171, 173, 3, 32, 16, 7, 172, 163, 1, 0, 0, 0, 172, 166, 1, 0, 0, 0, 172, 169, 1, 0, 0, 0, 173, 176, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, 33, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 177, 181, 5, 36, 0, 0, 178, 181, 3, 36, 18, 0, 179, 181, 3, 38, 19, 0, 180, 177, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 180, 179, 1, 0, 0, 0, 181, 35, 1, 0, 0, 0, 182, 183, 7, 5, 0, 0, 183, 37, 1, 0, 0, 0, 184, 185, 5, 35, 0, 0, 185, 186, 9, 0, 0, 0, 186, 187, 5, 35, 0, 0, 187, 39, 1, 0, 0, 0, 15, 43, 52, 59, 72, 79, 89, 105, 111, 127, 137, 145, 161, 172, 174, 180]
\ No newline at end of file
+[4, 1, 38, 208, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 4, 0, 44, 8, 0, 11, 0, 12, 0, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 53, 8, 1, 10, 1, 12, 1, 56, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 63, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 76, 8, 4, 1, 4, 1, 4, 1, 4, 5, 4, 81, 8, 4, 10, 4, 12, 4, 84, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 92, 8, 5, 1, 5, 1, 5, 1, 5, 5, 5, 97, 8, 5, 10, 5, 12, 5, 100, 9, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 5, 6, 107, 8, 6, 10, 6, 12, 6, 110, 9, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 3, 10, 125, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 131, 8, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 147, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 157, 8, 15, 1, 15, 1, 15, 1, 16, 1, 16, 5, 16, 163, 8, 16, 10, 16, 12, 16, 166, 9, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 181, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 5, 17, 192, 8, 17, 10, 17, 12, 17, 195, 9, 17, 1, 18, 1, 18, 1, 18, 3, 18, 200, 8, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 0, 1, 34, 21, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 0, 6, 1, 0, 9, 11, 1, 0, 12, 13, 1, 0, 19, 20, 1, 0, 21, 26, 1, 0, 27, 31, 1, 0, 33, 34, 213, 0, 43, 1, 0, 0, 0, 2, 47, 1, 0, 0, 0, 4, 62, 1, 0, 0, 0, 6, 64, 1, 0, 0, 0, 8, 69, 1, 0, 0, 0, 10, 87, 1, 0, 0, 0, 12, 103, 1, 0, 0, 0, 14, 111, 1, 0, 0, 0, 16, 114, 1, 0, 0, 0, 18, 116, 1, 0, 0, 0, 20, 124, 1, 0, 0, 0, 22, 126, 1, 0, 0, 0, 24, 134, 1, 0, 0, 0, 26, 139, 1, 0, 0, 0, 28, 148, 1, 0, 0, 0, 30, 154, 1, 0, 0, 0, 32, 160, 1, 0, 0, 0, 34, 180, 1, 0, 0, 0, 36, 199, 1, 0, 0, 0, 38, 201, 1, 0, 0, 0, 40, 203, 1, 0, 0, 0, 42, 44, 3, 2, 1, 0, 43, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 45, 46, 1, 0, 0, 0, 46, 1, 1, 0, 0, 0, 47, 48, 3, 18, 9, 0, 48, 49, 5, 1, 0, 0, 49, 50, 5, 37, 0, 0, 50, 54, 5, 2, 0, 0, 51, 53, 3, 4, 2, 0, 52, 51, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 57, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 57, 58, 5, 3, 0, 0, 58, 3, 1, 0, 0, 0, 59, 63, 3, 6, 3, 0, 60, 63, 3, 8, 4, 0, 61, 63, 3, 10, 5, 0, 62, 59, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 5, 1, 0, 0, 0, 64, 65, 3, 18, 9, 0, 65, 66, 3, 16, 8, 0, 66, 67, 5, 37, 0, 0, 67, 68, 5, 4, 0, 0, 68, 7, 1, 0, 0, 0, 69, 70, 3, 18, 9, 0, 70, 71, 5, 5, 0, 0, 71, 72, 3, 16, 8, 0, 72, 73, 5, 37, 0, 0, 73, 75, 5, 6, 0, 0, 74, 76, 3, 12, 6, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 78, 5, 7, 0, 0, 78, 82, 5, 2, 0, 0, 79, 81, 3, 20, 10, 0, 80, 79, 1, 0, 0, 0, 81, 84, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 85, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 85, 86, 5, 3, 0, 0, 86, 9, 1, 0, 0, 0, 87, 88, 3, 18, 9, 0, 88, 89, 5, 37, 0, 0, 89, 91, 5, 6, 0, 0, 90, 92, 3, 12, 6, 0, 91, 90, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 94, 5, 7, 0, 0, 94, 98, 5, 2, 0, 0, 95, 97, 3, 20, 10, 0, 96, 95, 1, 0, 0, 0, 97, 100, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 101, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 101, 102, 5, 3, 0, 0, 102, 11, 1, 0, 0, 0, 103, 108, 3, 14, 7, 0, 104, 105, 5, 8, 0, 0, 105, 107, 3, 14, 7, 0, 106, 104, 1, 0, 0, 0, 107, 110, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 13, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 112, 3, 16, 8, 0, 112, 113, 5, 37, 0, 0, 113, 15, 1, 0, 0, 0, 114, 115, 7, 0, 0, 0, 115, 17, 1, 0, 0, 0, 116, 117, 7, 1, 0, 0, 117, 19, 1, 0, 0, 0, 118, 125, 3, 22, 11, 0, 119, 125, 3, 24, 12, 0, 120, 125, 3, 26, 13, 0, 121, 125, 3, 28, 14, 0, 122, 125, 3, 30, 15, 0, 123, 125, 3, 32, 16, 0, 124, 118, 1, 0, 0, 0, 124, 119, 1, 0, 0, 0, 124, 120, 1, 0, 0, 0, 124, 121, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, 124, 123, 1, 0, 0, 0, 125, 21, 1, 0, 0, 0, 126, 127, 3, 16, 8, 0, 127, 130, 5, 37, 0, 0, 128, 129, 5, 14, 0, 0, 129, 131, 3, 34, 17, 0, 130, 128, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 5, 4, 0, 0, 133, 23, 1, 0, 0, 0, 134, 135, 5, 37, 0, 0, 135, 136, 5, 14, 0, 0, 136, 137, 3, 34, 17, 0, 137, 138, 5, 4, 0, 0, 138, 25, 1, 0, 0, 0, 139, 140, 5, 15, 0, 0, 140, 141, 5, 6, 0, 0, 141, 142, 3, 34, 17, 0, 142, 143, 5, 7, 0, 0, 143, 146, 3, 20, 10, 0, 144, 145, 5, 16, 0, 0, 145, 147, 3, 20, 10, 0, 146, 144, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 27, 1, 0, 0, 0, 148, 149, 5, 17, 0, 0, 149, 150, 5, 6, 0, 0, 150, 151, 3, 34, 17, 0, 151, 152, 5, 7, 0, 0, 152, 153, 3, 20, 10, 0, 153, 29, 1, 0, 0, 0, 154, 156, 5, 18, 0, 0, 155, 157, 3, 34, 17, 0, 156, 155, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 159, 5, 4, 0, 0, 159, 31, 1, 0, 0, 0, 160, 164, 5, 2, 0, 0, 161, 163, 3, 20, 10, 0, 162, 161, 1, 0, 0, 0, 163, 166, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 167, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 167, 168, 5, 3, 0, 0, 168, 33, 1, 0, 0, 0, 169, 170, 6, 17, -1, 0, 170, 171, 5, 28, 0, 0, 171, 181, 3, 34, 17, 5, 172, 173, 5, 32, 0, 0, 173, 181, 3, 34, 17, 4, 174, 175, 5, 6, 0, 0, 175, 176, 3, 34, 17, 0, 176, 177, 5, 7, 0, 0, 177, 181, 1, 0, 0, 0, 178, 181, 3, 36, 18, 0, 179, 181, 5, 37, 0, 0, 180, 169, 1, 0, 0, 0, 180, 172, 1, 0, 0, 0, 180, 174, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 180, 179, 1, 0, 0, 0, 181, 193, 1, 0, 0, 0, 182, 183, 10, 8, 0, 0, 183, 184, 7, 2, 0, 0, 184, 192, 3, 34, 17, 9, 185, 186, 10, 7, 0, 0, 186, 187, 7, 3, 0, 0, 187, 192, 3, 34, 17, 8, 188, 189, 10, 6, 0, 0, 189, 190, 7, 4, 0, 0, 190, 192, 3, 34, 17, 7, 191, 182, 1, 0, 0, 0, 191, 185, 1, 0, 0, 0, 191, 188, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 35, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 200, 5, 36, 0, 0, 197, 200, 3, 38, 19, 0, 198, 200, 3, 40, 20, 0, 199, 196, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 199, 198, 1, 0, 0, 0, 200, 37, 1, 0, 0, 0, 201, 202, 7, 5, 0, 0, 202, 39, 1, 0, 0, 0, 203, 204, 5, 35, 0, 0, 204, 205, 9, 0, 0, 0, 205, 206, 5, 35, 0, 0, 206, 41, 1, 0, 0, 0, 17, 45, 54, 62, 75, 82, 91, 98, 108, 124, 130, 146, 156, 164, 180, 191, 193, 199]
\ No newline at end of file
diff --git a/src/main/java/parser/generated/SimpleJavaBaseListener.java b/src/main/java/parser/generated/SimpleJavaBaseListener.java
index a7c55f8..d4d6ae5 100644
--- a/src/main/java/parser/generated/SimpleJavaBaseListener.java
+++ b/src/main/java/parser/generated/SimpleJavaBaseListener.java
@@ -1,4 +1,4 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.ParserRuleContext;
@@ -72,6 +72,18 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
* The default implementation does nothing.
*/
@Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
diff --git a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java
index d220df2..5e96c5e 100644
--- a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java
+++ b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java
@@ -1,4 +1,4 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
@@ -47,6 +47,13 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem
* {@link #visitChildren} on {@code ctx}.
*/
@Override public T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { return visitChildren(ctx); }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation returns the result of calling
+ * {@link #visitChildren} on {@code ctx}.
+ */
+ @Override public T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
diff --git a/src/main/java/parser/generated/SimpleJavaLexer.java b/src/main/java/parser/generated/SimpleJavaLexer.java
index 1caaafe..d0cafe6 100644
--- a/src/main/java/parser/generated/SimpleJavaLexer.java
+++ b/src/main/java/parser/generated/SimpleJavaLexer.java
@@ -1,4 +1,4 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
diff --git a/src/main/java/parser/generated/SimpleJavaListener.java b/src/main/java/parser/generated/SimpleJavaListener.java
index 153e20e..3223932 100644
--- a/src/main/java/parser/generated/SimpleJavaListener.java
+++ b/src/main/java/parser/generated/SimpleJavaListener.java
@@ -1,4 +1,4 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.ParseTreeListener;
@@ -57,6 +57,16 @@ public interface SimpleJavaListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
+ /**
+ * Enter a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
+ * @param ctx the parse tree
+ */
+ void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
+ /**
+ * Exit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
+ * @param ctx the parse tree
+ */
+ void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#parameterList}.
* @param ctx the parse tree
diff --git a/src/main/java/parser/generated/SimpleJavaParser.java b/src/main/java/parser/generated/SimpleJavaParser.java
index ea84fe1..cfa95de 100644
--- a/src/main/java/parser/generated/SimpleJavaParser.java
+++ b/src/main/java/parser/generated/SimpleJavaParser.java
@@ -1,10 +1,13 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
public class SimpleJavaParser extends Parser {
@@ -22,19 +25,19 @@ public class SimpleJavaParser extends Parser {
WS=38;
public static final int
RULE_program = 0, RULE_classDeclaration = 1, RULE_memberDeclaration = 2,
- RULE_fieldDeclaration = 3, RULE_methodDeclaration = 4, RULE_parameterList = 5,
- RULE_parameter = 6, RULE_type = 7, RULE_accessType = 8, RULE_statement = 9,
- RULE_variableDeclarationStatement = 10, RULE_assignmentStatement = 11,
- RULE_ifStatement = 12, RULE_whileStatement = 13, RULE_returnStatement = 14,
- RULE_block = 15, RULE_expression = 16, RULE_literal = 17, RULE_booleanLiteral = 18,
- RULE_charLiteral = 19;
+ RULE_fieldDeclaration = 3, RULE_methodDeclaration = 4, RULE_constructorDeclaration = 5,
+ RULE_parameterList = 6, RULE_parameter = 7, RULE_type = 8, RULE_accessType = 9,
+ RULE_statement = 10, RULE_variableDeclarationStatement = 11, RULE_assignmentStatement = 12,
+ RULE_ifStatement = 13, RULE_whileStatement = 14, RULE_returnStatement = 15,
+ RULE_block = 16, RULE_expression = 17, RULE_literal = 18, RULE_booleanLiteral = 19,
+ RULE_charLiteral = 20;
private static String[] makeRuleNames() {
return new String[] {
"program", "classDeclaration", "memberDeclaration", "fieldDeclaration",
- "methodDeclaration", "parameterList", "parameter", "type", "accessType",
- "statement", "variableDeclarationStatement", "assignmentStatement", "ifStatement",
- "whileStatement", "returnStatement", "block", "expression", "literal",
- "booleanLiteral", "charLiteral"
+ "methodDeclaration", "constructorDeclaration", "parameterList", "parameter",
+ "type", "accessType", "statement", "variableDeclarationStatement", "assignmentStatement",
+ "ifStatement", "whileStatement", "returnStatement", "block", "expression",
+ "literal", "booleanLiteral", "charLiteral"
};
}
public static final String[] ruleNames = makeRuleNames();
@@ -142,17 +145,17 @@ public class SimpleJavaParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(41);
+ setState(43);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
- setState(40);
+ setState(42);
classDeclaration();
}
}
- setState(43);
+ setState(45);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==T__11 || _la==T__12 );
@@ -207,29 +210,29 @@ public class SimpleJavaParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(45);
- accessType();
- setState(46);
- match(T__0);
setState(47);
- match(IDENTIFIER);
+ accessType();
setState(48);
+ match(T__0);
+ setState(49);
+ match(IDENTIFIER);
+ setState(50);
match(T__1);
- setState(52);
+ setState(54);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__11 || _la==T__12) {
{
{
- setState(49);
+ setState(51);
memberDeclaration();
}
}
- setState(54);
+ setState(56);
_errHandler.sync(this);
_la = _input.LA(1);
}
- setState(55);
+ setState(57);
match(T__2);
}
}
@@ -252,6 +255,9 @@ public class SimpleJavaParser extends Parser {
public MethodDeclarationContext methodDeclaration() {
return getRuleContext(MethodDeclarationContext.class,0);
}
+ public ConstructorDeclarationContext constructorDeclaration() {
+ return getRuleContext(ConstructorDeclarationContext.class,0);
+ }
public MemberDeclarationContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@@ -275,23 +281,30 @@ public class SimpleJavaParser extends Parser {
MemberDeclarationContext _localctx = new MemberDeclarationContext(_ctx, getState());
enterRule(_localctx, 4, RULE_memberDeclaration);
try {
- setState(59);
+ setState(62);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(57);
+ setState(59);
fieldDeclaration();
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(58);
+ setState(60);
methodDeclaration();
}
break;
+ case 3:
+ enterOuterAlt(_localctx, 3);
+ {
+ setState(61);
+ constructorDeclaration();
+ }
+ break;
}
}
catch (RecognitionException re) {
@@ -339,13 +352,13 @@ public class SimpleJavaParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(61);
- accessType();
- setState(62);
- type();
- setState(63);
- match(IDENTIFIER);
setState(64);
+ accessType();
+ setState(65);
+ type();
+ setState(66);
+ match(IDENTIFIER);
+ setState(67);
match(T__3);
}
}
@@ -404,45 +417,135 @@ public class SimpleJavaParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(66);
- accessType();
- setState(67);
- match(T__4);
- setState(68);
- type();
setState(69);
- match(IDENTIFIER);
+ accessType();
setState(70);
- match(T__5);
+ match(T__4);
+ setState(71);
+ type();
setState(72);
+ match(IDENTIFIER);
+ setState(73);
+ match(T__5);
+ setState(75);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) {
{
- setState(71);
+ setState(74);
parameterList();
}
}
- setState(74);
+ setState(77);
match(T__6);
- setState(75);
+ setState(78);
match(T__1);
- setState(79);
+ setState(82);
_errHandler.sync(this);
_la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) {
{
{
- setState(76);
+ setState(79);
statement();
}
}
- setState(81);
+ setState(84);
_errHandler.sync(this);
_la = _input.LA(1);
}
- setState(82);
+ setState(85);
+ match(T__2);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ @SuppressWarnings("CheckReturnValue")
+ public static class ConstructorDeclarationContext extends ParserRuleContext {
+ public AccessTypeContext accessType() {
+ return getRuleContext(AccessTypeContext.class,0);
+ }
+ public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public List statement() {
+ return getRuleContexts(StatementContext.class);
+ }
+ public StatementContext statement(int i) {
+ return getRuleContext(StatementContext.class,i);
+ }
+ public ConstructorDeclarationContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_constructorDeclaration; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterConstructorDeclaration(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitConstructorDeclaration(this);
+ }
+ @Override
+ public T accept(ParseTreeVisitor extends T> visitor) {
+ if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor extends T>)visitor).visitConstructorDeclaration(this);
+ else return visitor.visitChildren(this);
+ }
+ }
+
+ public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException {
+ ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState());
+ enterRule(_localctx, 10, RULE_constructorDeclaration);
+ int _la;
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(87);
+ accessType();
+ setState(88);
+ match(IDENTIFIER);
+ setState(89);
+ match(T__5);
+ setState(91);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) {
+ {
+ setState(90);
+ parameterList();
+ }
+ }
+
+ setState(93);
+ match(T__6);
+ setState(94);
+ match(T__1);
+ setState(98);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) {
+ {
+ {
+ setState(95);
+ statement();
+ }
+ }
+ setState(100);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ }
+ setState(101);
match(T__2);
}
}
@@ -486,26 +589,26 @@ public class SimpleJavaParser extends Parser {
public final ParameterListContext parameterList() throws RecognitionException {
ParameterListContext _localctx = new ParameterListContext(_ctx, getState());
- enterRule(_localctx, 10, RULE_parameterList);
+ enterRule(_localctx, 12, RULE_parameterList);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(84);
+ setState(103);
parameter();
- setState(89);
+ setState(108);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__7) {
{
{
- setState(85);
+ setState(104);
match(T__7);
- setState(86);
+ setState(105);
parameter();
}
}
- setState(91);
+ setState(110);
_errHandler.sync(this);
_la = _input.LA(1);
}
@@ -549,13 +652,13 @@ public class SimpleJavaParser extends Parser {
public final ParameterContext parameter() throws RecognitionException {
ParameterContext _localctx = new ParameterContext(_ctx, getState());
- enterRule(_localctx, 12, RULE_parameter);
+ enterRule(_localctx, 14, RULE_parameter);
try {
enterOuterAlt(_localctx, 1);
{
- setState(92);
+ setState(111);
type();
- setState(93);
+ setState(112);
match(IDENTIFIER);
}
}
@@ -593,12 +696,12 @@ public class SimpleJavaParser extends Parser {
public final TypeContext type() throws RecognitionException {
TypeContext _localctx = new TypeContext(_ctx, getState());
- enterRule(_localctx, 14, RULE_type);
+ enterRule(_localctx, 16, RULE_type);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(95);
+ setState(114);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) ) {
_errHandler.recoverInline(this);
@@ -644,12 +747,12 @@ public class SimpleJavaParser extends Parser {
public final AccessTypeContext accessType() throws RecognitionException {
AccessTypeContext _localctx = new AccessTypeContext(_ctx, getState());
- enterRule(_localctx, 16, RULE_accessType);
+ enterRule(_localctx, 18, RULE_accessType);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(97);
+ setState(116);
_la = _input.LA(1);
if ( !(_la==T__11 || _la==T__12) ) {
_errHandler.recoverInline(this);
@@ -713,9 +816,9 @@ public class SimpleJavaParser extends Parser {
public final StatementContext statement() throws RecognitionException {
StatementContext _localctx = new StatementContext(_ctx, getState());
- enterRule(_localctx, 18, RULE_statement);
+ enterRule(_localctx, 20, RULE_statement);
try {
- setState(105);
+ setState(124);
_errHandler.sync(this);
switch (_input.LA(1)) {
case T__8:
@@ -723,42 +826,42 @@ public class SimpleJavaParser extends Parser {
case T__10:
enterOuterAlt(_localctx, 1);
{
- setState(99);
+ setState(118);
variableDeclarationStatement();
}
break;
case IDENTIFIER:
enterOuterAlt(_localctx, 2);
{
- setState(100);
+ setState(119);
assignmentStatement();
}
break;
case T__14:
enterOuterAlt(_localctx, 3);
{
- setState(101);
+ setState(120);
ifStatement();
}
break;
case T__16:
enterOuterAlt(_localctx, 4);
{
- setState(102);
+ setState(121);
whileStatement();
}
break;
case T__17:
enterOuterAlt(_localctx, 5);
{
- setState(103);
+ setState(122);
returnStatement();
}
break;
case T__1:
enterOuterAlt(_localctx, 6);
{
- setState(104);
+ setState(123);
block();
}
break;
@@ -807,28 +910,28 @@ public class SimpleJavaParser extends Parser {
public final VariableDeclarationStatementContext variableDeclarationStatement() throws RecognitionException {
VariableDeclarationStatementContext _localctx = new VariableDeclarationStatementContext(_ctx, getState());
- enterRule(_localctx, 20, RULE_variableDeclarationStatement);
+ enterRule(_localctx, 22, RULE_variableDeclarationStatement);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(107);
+ setState(126);
type();
- setState(108);
+ setState(127);
match(IDENTIFIER);
- setState(111);
+ setState(130);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__13) {
{
- setState(109);
+ setState(128);
match(T__13);
- setState(110);
+ setState(129);
expression(0);
}
}
- setState(113);
+ setState(132);
match(T__3);
}
}
@@ -870,17 +973,17 @@ public class SimpleJavaParser extends Parser {
public final AssignmentStatementContext assignmentStatement() throws RecognitionException {
AssignmentStatementContext _localctx = new AssignmentStatementContext(_ctx, getState());
- enterRule(_localctx, 22, RULE_assignmentStatement);
+ enterRule(_localctx, 24, RULE_assignmentStatement);
try {
enterOuterAlt(_localctx, 1);
{
- setState(115);
+ setState(134);
match(IDENTIFIER);
- setState(116);
+ setState(135);
match(T__13);
- setState(117);
+ setState(136);
expression(0);
- setState(118);
+ setState(137);
match(T__3);
}
}
@@ -927,28 +1030,28 @@ public class SimpleJavaParser extends Parser {
public final IfStatementContext ifStatement() throws RecognitionException {
IfStatementContext _localctx = new IfStatementContext(_ctx, getState());
- enterRule(_localctx, 24, RULE_ifStatement);
+ enterRule(_localctx, 26, RULE_ifStatement);
try {
enterOuterAlt(_localctx, 1);
{
- setState(120);
+ setState(139);
match(T__14);
- setState(121);
+ setState(140);
match(T__5);
- setState(122);
+ setState(141);
expression(0);
- setState(123);
+ setState(142);
match(T__6);
- setState(124);
+ setState(143);
statement();
- setState(127);
+ setState(146);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) {
case 1:
{
- setState(125);
+ setState(144);
match(T__15);
- setState(126);
+ setState(145);
statement();
}
break;
@@ -995,19 +1098,19 @@ public class SimpleJavaParser extends Parser {
public final WhileStatementContext whileStatement() throws RecognitionException {
WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState());
- enterRule(_localctx, 26, RULE_whileStatement);
+ enterRule(_localctx, 28, RULE_whileStatement);
try {
enterOuterAlt(_localctx, 1);
{
- setState(129);
+ setState(148);
match(T__16);
- setState(130);
+ setState(149);
match(T__5);
- setState(131);
+ setState(150);
expression(0);
- setState(132);
+ setState(151);
match(T__6);
- setState(133);
+ setState(152);
statement();
}
}
@@ -1048,24 +1151,24 @@ public class SimpleJavaParser extends Parser {
public final ReturnStatementContext returnStatement() throws RecognitionException {
ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState());
- enterRule(_localctx, 28, RULE_returnStatement);
+ enterRule(_localctx, 30, RULE_returnStatement);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(135);
+ setState(154);
match(T__17);
- setState(137);
+ setState(156);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 270851375168L) != 0)) {
{
- setState(136);
+ setState(155);
expression(0);
}
}
- setState(139);
+ setState(158);
match(T__3);
}
}
@@ -1109,28 +1212,28 @@ public class SimpleJavaParser extends Parser {
public final BlockContext block() throws RecognitionException {
BlockContext _localctx = new BlockContext(_ctx, getState());
- enterRule(_localctx, 30, RULE_block);
+ enterRule(_localctx, 32, RULE_block);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(141);
+ setState(160);
match(T__1);
- setState(145);
+ setState(164);
_errHandler.sync(this);
_la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) {
{
{
- setState(142);
+ setState(161);
statement();
}
}
- setState(147);
+ setState(166);
_errHandler.sync(this);
_la = _input.LA(1);
}
- setState(148);
+ setState(167);
match(T__2);
}
}
@@ -1185,39 +1288,39 @@ public class SimpleJavaParser extends Parser {
int _parentState = getState();
ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState);
ExpressionContext _prevctx = _localctx;
- int _startState = 32;
- enterRecursionRule(_localctx, 32, RULE_expression, _p);
+ int _startState = 34;
+ enterRecursionRule(_localctx, 34, RULE_expression, _p);
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
- setState(161);
+ setState(180);
_errHandler.sync(this);
switch (_input.LA(1)) {
case T__27:
{
- setState(151);
+ setState(170);
match(T__27);
- setState(152);
+ setState(171);
expression(5);
}
break;
case T__31:
{
- setState(153);
+ setState(172);
match(T__31);
- setState(154);
+ setState(173);
expression(4);
}
break;
case T__5:
{
- setState(155);
+ setState(174);
match(T__5);
- setState(156);
+ setState(175);
expression(0);
- setState(157);
+ setState(176);
match(T__6);
}
break;
@@ -1226,13 +1329,13 @@ public class SimpleJavaParser extends Parser {
case T__34:
case INTEGERLITERAL:
{
- setState(159);
+ setState(178);
literal();
}
break;
case IDENTIFIER:
{
- setState(160);
+ setState(179);
match(IDENTIFIER);
}
break;
@@ -1240,24 +1343,24 @@ public class SimpleJavaParser extends Parser {
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
- setState(174);
+ setState(193);
_errHandler.sync(this);
- _alt = getInterpreter().adaptivePredict(_input,13,_ctx);
+ _alt = getInterpreter().adaptivePredict(_input,15,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( _parseListeners!=null ) triggerExitRuleEvent();
_prevctx = _localctx;
{
- setState(172);
+ setState(191);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,12,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) {
case 1:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx, _startState, RULE_expression);
- setState(163);
+ setState(182);
if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)");
- setState(164);
+ setState(183);
_la = _input.LA(1);
if ( !(_la==T__18 || _la==T__19) ) {
_errHandler.recoverInline(this);
@@ -1267,7 +1370,7 @@ public class SimpleJavaParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(165);
+ setState(184);
expression(9);
}
break;
@@ -1275,9 +1378,9 @@ public class SimpleJavaParser extends Parser {
{
_localctx = new ExpressionContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx, _startState, RULE_expression);
- setState(166);
+ setState(185);
if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)");
- setState(167);
+ setState(186);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 132120576L) != 0)) ) {
_errHandler.recoverInline(this);
@@ -1287,7 +1390,7 @@ public class SimpleJavaParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(168);
+ setState(187);
expression(8);
}
break;
@@ -1295,9 +1398,9 @@ public class SimpleJavaParser extends Parser {
{
_localctx = new ExpressionContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx, _startState, RULE_expression);
- setState(169);
+ setState(188);
if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
- setState(170);
+ setState(189);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 4160749568L) != 0)) ) {
_errHandler.recoverInline(this);
@@ -1307,16 +1410,16 @@ public class SimpleJavaParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(171);
+ setState(190);
expression(7);
}
break;
}
}
}
- setState(176);
+ setState(195);
_errHandler.sync(this);
- _alt = getInterpreter().adaptivePredict(_input,13,_ctx);
+ _alt = getInterpreter().adaptivePredict(_input,15,_ctx);
}
}
}
@@ -1361,15 +1464,15 @@ public class SimpleJavaParser extends Parser {
public final LiteralContext literal() throws RecognitionException {
LiteralContext _localctx = new LiteralContext(_ctx, getState());
- enterRule(_localctx, 34, RULE_literal);
+ enterRule(_localctx, 36, RULE_literal);
try {
- setState(180);
+ setState(199);
_errHandler.sync(this);
switch (_input.LA(1)) {
case INTEGERLITERAL:
enterOuterAlt(_localctx, 1);
{
- setState(177);
+ setState(196);
match(INTEGERLITERAL);
}
break;
@@ -1377,14 +1480,14 @@ public class SimpleJavaParser extends Parser {
case T__33:
enterOuterAlt(_localctx, 2);
{
- setState(178);
+ setState(197);
booleanLiteral();
}
break;
case T__34:
enterOuterAlt(_localctx, 3);
{
- setState(179);
+ setState(198);
charLiteral();
}
break;
@@ -1426,12 +1529,12 @@ public class SimpleJavaParser extends Parser {
public final BooleanLiteralContext booleanLiteral() throws RecognitionException {
BooleanLiteralContext _localctx = new BooleanLiteralContext(_ctx, getState());
- enterRule(_localctx, 36, RULE_booleanLiteral);
+ enterRule(_localctx, 38, RULE_booleanLiteral);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(182);
+ setState(201);
_la = _input.LA(1);
if ( !(_la==T__32 || _la==T__33) ) {
_errHandler.recoverInline(this);
@@ -1477,15 +1580,15 @@ public class SimpleJavaParser extends Parser {
public final CharLiteralContext charLiteral() throws RecognitionException {
CharLiteralContext _localctx = new CharLiteralContext(_ctx, getState());
- enterRule(_localctx, 38, RULE_charLiteral);
+ enterRule(_localctx, 40, RULE_charLiteral);
try {
enterOuterAlt(_localctx, 1);
{
- setState(184);
+ setState(203);
match(T__34);
- setState(185);
+ setState(204);
matchWildcard();
- setState(186);
+ setState(205);
match(T__34);
}
}
@@ -1502,7 +1605,7 @@ public class SimpleJavaParser extends Parser {
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
- case 16:
+ case 17:
return expression_sempred((ExpressionContext)_localctx, predIndex);
}
return true;
@@ -1520,118 +1623,132 @@ public class SimpleJavaParser extends Parser {
}
public static final String _serializedATN =
- "\u0004\u0001&\u00bd\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
+ "\u0004\u0001&\u00d0\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+
"\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+
"\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+
"\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+
"\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+
- "\u0002\u0013\u0007\u0013\u0001\u0000\u0004\u0000*\b\u0000\u000b\u0000"+
- "\f\u0000+\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
- "\u0005\u00013\b\u0001\n\u0001\f\u00016\t\u0001\u0001\u0001\u0001\u0001"+
- "\u0001\u0002\u0001\u0002\u0003\u0002<\b\u0002\u0001\u0003\u0001\u0003"+
- "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004"+
- "\u0001\u0004\u0001\u0004\u0001\u0004\u0003\u0004I\b\u0004\u0001\u0004"+
- "\u0001\u0004\u0001\u0004\u0005\u0004N\b\u0004\n\u0004\f\u0004Q\t\u0004"+
- "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0005\u0005"+
- "X\b\u0005\n\u0005\f\u0005[\t\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+
- "\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001"+
- "\t\u0001\t\u0001\t\u0003\tj\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0003"+
- "\np\b\n\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+
- "\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0003"+
- "\f\u0080\b\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e"+
- "\u0001\u000e\u0003\u000e\u008a\b\u000e\u0001\u000e\u0001\u000e\u0001\u000f"+
- "\u0001\u000f\u0005\u000f\u0090\b\u000f\n\u000f\f\u000f\u0093\t\u000f\u0001"+
- "\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+
- "\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+
- "\u0010\u0003\u0010\u00a2\b\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+
- "\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0005"+
- "\u0010\u00ad\b\u0010\n\u0010\f\u0010\u00b0\t\u0010\u0001\u0011\u0001\u0011"+
- "\u0001\u0011\u0003\u0011\u00b5\b\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+
- "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0000\u0001 \u0014\u0000"+
- "\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u001c"+
- "\u001e \"$&\u0000\u0006\u0001\u0000\t\u000b\u0001\u0000\f\r\u0001\u0000"+
- "\u0013\u0014\u0001\u0000\u0015\u001a\u0001\u0000\u001b\u001f\u0001\u0000"+
- "!\"\u00c0\u0000)\u0001\u0000\u0000\u0000\u0002-\u0001\u0000\u0000\u0000"+
- "\u0004;\u0001\u0000\u0000\u0000\u0006=\u0001\u0000\u0000\u0000\bB\u0001"+
- "\u0000\u0000\u0000\nT\u0001\u0000\u0000\u0000\f\\\u0001\u0000\u0000\u0000"+
- "\u000e_\u0001\u0000\u0000\u0000\u0010a\u0001\u0000\u0000\u0000\u0012i"+
- "\u0001\u0000\u0000\u0000\u0014k\u0001\u0000\u0000\u0000\u0016s\u0001\u0000"+
- "\u0000\u0000\u0018x\u0001\u0000\u0000\u0000\u001a\u0081\u0001\u0000\u0000"+
- "\u0000\u001c\u0087\u0001\u0000\u0000\u0000\u001e\u008d\u0001\u0000\u0000"+
- "\u0000 \u00a1\u0001\u0000\u0000\u0000\"\u00b4\u0001\u0000\u0000\u0000"+
- "$\u00b6\u0001\u0000\u0000\u0000&\u00b8\u0001\u0000\u0000\u0000(*\u0003"+
- "\u0002\u0001\u0000)(\u0001\u0000\u0000\u0000*+\u0001\u0000\u0000\u0000"+
- "+)\u0001\u0000\u0000\u0000+,\u0001\u0000\u0000\u0000,\u0001\u0001\u0000"+
- "\u0000\u0000-.\u0003\u0010\b\u0000./\u0005\u0001\u0000\u0000/0\u0005%"+
- "\u0000\u000004\u0005\u0002\u0000\u000013\u0003\u0004\u0002\u000021\u0001"+
- "\u0000\u0000\u000036\u0001\u0000\u0000\u000042\u0001\u0000\u0000\u0000"+
- "45\u0001\u0000\u0000\u000057\u0001\u0000\u0000\u000064\u0001\u0000\u0000"+
- "\u000078\u0005\u0003\u0000\u00008\u0003\u0001\u0000\u0000\u00009<\u0003"+
- "\u0006\u0003\u0000:<\u0003\b\u0004\u0000;9\u0001\u0000\u0000\u0000;:\u0001"+
- "\u0000\u0000\u0000<\u0005\u0001\u0000\u0000\u0000=>\u0003\u0010\b\u0000"+
- ">?\u0003\u000e\u0007\u0000?@\u0005%\u0000\u0000@A\u0005\u0004\u0000\u0000"+
- "A\u0007\u0001\u0000\u0000\u0000BC\u0003\u0010\b\u0000CD\u0005\u0005\u0000"+
- "\u0000DE\u0003\u000e\u0007\u0000EF\u0005%\u0000\u0000FH\u0005\u0006\u0000"+
- "\u0000GI\u0003\n\u0005\u0000HG\u0001\u0000\u0000\u0000HI\u0001\u0000\u0000"+
- "\u0000IJ\u0001\u0000\u0000\u0000JK\u0005\u0007\u0000\u0000KO\u0005\u0002"+
- "\u0000\u0000LN\u0003\u0012\t\u0000ML\u0001\u0000\u0000\u0000NQ\u0001\u0000"+
- "\u0000\u0000OM\u0001\u0000\u0000\u0000OP\u0001\u0000\u0000\u0000PR\u0001"+
- "\u0000\u0000\u0000QO\u0001\u0000\u0000\u0000RS\u0005\u0003\u0000\u0000"+
- "S\t\u0001\u0000\u0000\u0000TY\u0003\f\u0006\u0000UV\u0005\b\u0000\u0000"+
- "VX\u0003\f\u0006\u0000WU\u0001\u0000\u0000\u0000X[\u0001\u0000\u0000\u0000"+
- "YW\u0001\u0000\u0000\u0000YZ\u0001\u0000\u0000\u0000Z\u000b\u0001\u0000"+
- "\u0000\u0000[Y\u0001\u0000\u0000\u0000\\]\u0003\u000e\u0007\u0000]^\u0005"+
- "%\u0000\u0000^\r\u0001\u0000\u0000\u0000_`\u0007\u0000\u0000\u0000`\u000f"+
- "\u0001\u0000\u0000\u0000ab\u0007\u0001\u0000\u0000b\u0011\u0001\u0000"+
- "\u0000\u0000cj\u0003\u0014\n\u0000dj\u0003\u0016\u000b\u0000ej\u0003\u0018"+
- "\f\u0000fj\u0003\u001a\r\u0000gj\u0003\u001c\u000e\u0000hj\u0003\u001e"+
- "\u000f\u0000ic\u0001\u0000\u0000\u0000id\u0001\u0000\u0000\u0000ie\u0001"+
- "\u0000\u0000\u0000if\u0001\u0000\u0000\u0000ig\u0001\u0000\u0000\u0000"+
- "ih\u0001\u0000\u0000\u0000j\u0013\u0001\u0000\u0000\u0000kl\u0003\u000e"+
- "\u0007\u0000lo\u0005%\u0000\u0000mn\u0005\u000e\u0000\u0000np\u0003 \u0010"+
- "\u0000om\u0001\u0000\u0000\u0000op\u0001\u0000\u0000\u0000pq\u0001\u0000"+
- "\u0000\u0000qr\u0005\u0004\u0000\u0000r\u0015\u0001\u0000\u0000\u0000"+
- "st\u0005%\u0000\u0000tu\u0005\u000e\u0000\u0000uv\u0003 \u0010\u0000v"+
- "w\u0005\u0004\u0000\u0000w\u0017\u0001\u0000\u0000\u0000xy\u0005\u000f"+
- "\u0000\u0000yz\u0005\u0006\u0000\u0000z{\u0003 \u0010\u0000{|\u0005\u0007"+
- "\u0000\u0000|\u007f\u0003\u0012\t\u0000}~\u0005\u0010\u0000\u0000~\u0080"+
- "\u0003\u0012\t\u0000\u007f}\u0001\u0000\u0000\u0000\u007f\u0080\u0001"+
- "\u0000\u0000\u0000\u0080\u0019\u0001\u0000\u0000\u0000\u0081\u0082\u0005"+
- "\u0011\u0000\u0000\u0082\u0083\u0005\u0006\u0000\u0000\u0083\u0084\u0003"+
- " \u0010\u0000\u0084\u0085\u0005\u0007\u0000\u0000\u0085\u0086\u0003\u0012"+
- "\t\u0000\u0086\u001b\u0001\u0000\u0000\u0000\u0087\u0089\u0005\u0012\u0000"+
- "\u0000\u0088\u008a\u0003 \u0010\u0000\u0089\u0088\u0001\u0000\u0000\u0000"+
- "\u0089\u008a\u0001\u0000\u0000\u0000\u008a\u008b\u0001\u0000\u0000\u0000"+
- "\u008b\u008c\u0005\u0004\u0000\u0000\u008c\u001d\u0001\u0000\u0000\u0000"+
- "\u008d\u0091\u0005\u0002\u0000\u0000\u008e\u0090\u0003\u0012\t\u0000\u008f"+
- "\u008e\u0001\u0000\u0000\u0000\u0090\u0093\u0001\u0000\u0000\u0000\u0091"+
- "\u008f\u0001\u0000\u0000\u0000\u0091\u0092\u0001\u0000\u0000\u0000\u0092"+
- "\u0094\u0001\u0000\u0000\u0000\u0093\u0091\u0001\u0000\u0000\u0000\u0094"+
- "\u0095\u0005\u0003\u0000\u0000\u0095\u001f\u0001\u0000\u0000\u0000\u0096"+
- "\u0097\u0006\u0010\uffff\uffff\u0000\u0097\u0098\u0005\u001c\u0000\u0000"+
- "\u0098\u00a2\u0003 \u0010\u0005\u0099\u009a\u0005 \u0000\u0000\u009a\u00a2"+
- "\u0003 \u0010\u0004\u009b\u009c\u0005\u0006\u0000\u0000\u009c\u009d\u0003"+
- " \u0010\u0000\u009d\u009e\u0005\u0007\u0000\u0000\u009e\u00a2\u0001\u0000"+
- "\u0000\u0000\u009f\u00a2\u0003\"\u0011\u0000\u00a0\u00a2\u0005%\u0000"+
- "\u0000\u00a1\u0096\u0001\u0000\u0000\u0000\u00a1\u0099\u0001\u0000\u0000"+
- "\u0000\u00a1\u009b\u0001\u0000\u0000\u0000\u00a1\u009f\u0001\u0000\u0000"+
- "\u0000\u00a1\u00a0\u0001\u0000\u0000\u0000\u00a2\u00ae\u0001\u0000\u0000"+
- "\u0000\u00a3\u00a4\n\b\u0000\u0000\u00a4\u00a5\u0007\u0002\u0000\u0000"+
- "\u00a5\u00ad\u0003 \u0010\t\u00a6\u00a7\n\u0007\u0000\u0000\u00a7\u00a8"+
- "\u0007\u0003\u0000\u0000\u00a8\u00ad\u0003 \u0010\b\u00a9\u00aa\n\u0006"+
- "\u0000\u0000\u00aa\u00ab\u0007\u0004\u0000\u0000\u00ab\u00ad\u0003 \u0010"+
- "\u0007\u00ac\u00a3\u0001\u0000\u0000\u0000\u00ac\u00a6\u0001\u0000\u0000"+
- "\u0000\u00ac\u00a9\u0001\u0000\u0000\u0000\u00ad\u00b0\u0001\u0000\u0000"+
- "\u0000\u00ae\u00ac\u0001\u0000\u0000\u0000\u00ae\u00af\u0001\u0000\u0000"+
- "\u0000\u00af!\u0001\u0000\u0000\u0000\u00b0\u00ae\u0001\u0000\u0000\u0000"+
- "\u00b1\u00b5\u0005$\u0000\u0000\u00b2\u00b5\u0003$\u0012\u0000\u00b3\u00b5"+
- "\u0003&\u0013\u0000\u00b4\u00b1\u0001\u0000\u0000\u0000\u00b4\u00b2\u0001"+
- "\u0000\u0000\u0000\u00b4\u00b3\u0001\u0000\u0000\u0000\u00b5#\u0001\u0000"+
- "\u0000\u0000\u00b6\u00b7\u0007\u0005\u0000\u0000\u00b7%\u0001\u0000\u0000"+
- "\u0000\u00b8\u00b9\u0005#\u0000\u0000\u00b9\u00ba\t\u0000\u0000\u0000"+
- "\u00ba\u00bb\u0005#\u0000\u0000\u00bb\'\u0001\u0000\u0000\u0000\u000f"+
- "+4;HOYio\u007f\u0089\u0091\u00a1\u00ac\u00ae\u00b4";
+ "\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0001\u0000\u0004\u0000"+
+ ",\b\u0000\u000b\u0000\f\u0000-\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
+ "\u0001\u0001\u0001\u0005\u00015\b\u0001\n\u0001\f\u00018\t\u0001\u0001"+
+ "\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002?\b"+
+ "\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+
+ "\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0003"+
+ "\u0004L\b\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0005\u0004Q\b\u0004"+
+ "\n\u0004\f\u0004T\t\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+
+ "\u0001\u0005\u0001\u0005\u0003\u0005\\\b\u0005\u0001\u0005\u0001\u0005"+
+ "\u0001\u0005\u0005\u0005a\b\u0005\n\u0005\f\u0005d\t\u0005\u0001\u0005"+
+ "\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0005\u0006k\b\u0006"+
+ "\n\u0006\f\u0006n\t\u0006\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b"+
+ "\u0001\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+
+ "\n\u0003\n}\b\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0003"+
+ "\u000b\u0083\b\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001"+
+ "\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0003"+
+ "\r\u0093\b\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+
+ "\u0001\u000e\u0001\u000f\u0001\u000f\u0003\u000f\u009d\b\u000f\u0001\u000f"+
+ "\u0001\u000f\u0001\u0010\u0001\u0010\u0005\u0010\u00a3\b\u0010\n\u0010"+
+ "\f\u0010\u00a6\t\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011"+
+ "\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011"+
+ "\u0001\u0011\u0001\u0011\u0001\u0011\u0003\u0011\u00b5\b\u0011\u0001\u0011"+
+ "\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011"+
+ "\u0001\u0011\u0001\u0011\u0005\u0011\u00c0\b\u0011\n\u0011\f\u0011\u00c3"+
+ "\t\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0003\u0012\u00c8\b\u0012"+
+ "\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014"+
+ "\u0001\u0014\u0000\u0001\"\u0015\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010"+
+ "\u0012\u0014\u0016\u0018\u001a\u001c\u001e \"$&(\u0000\u0006\u0001\u0000"+
+ "\t\u000b\u0001\u0000\f\r\u0001\u0000\u0013\u0014\u0001\u0000\u0015\u001a"+
+ "\u0001\u0000\u001b\u001f\u0001\u0000!\"\u00d5\u0000+\u0001\u0000\u0000"+
+ "\u0000\u0002/\u0001\u0000\u0000\u0000\u0004>\u0001\u0000\u0000\u0000\u0006"+
+ "@\u0001\u0000\u0000\u0000\bE\u0001\u0000\u0000\u0000\nW\u0001\u0000\u0000"+
+ "\u0000\fg\u0001\u0000\u0000\u0000\u000eo\u0001\u0000\u0000\u0000\u0010"+
+ "r\u0001\u0000\u0000\u0000\u0012t\u0001\u0000\u0000\u0000\u0014|\u0001"+
+ "\u0000\u0000\u0000\u0016~\u0001\u0000\u0000\u0000\u0018\u0086\u0001\u0000"+
+ "\u0000\u0000\u001a\u008b\u0001\u0000\u0000\u0000\u001c\u0094\u0001\u0000"+
+ "\u0000\u0000\u001e\u009a\u0001\u0000\u0000\u0000 \u00a0\u0001\u0000\u0000"+
+ "\u0000\"\u00b4\u0001\u0000\u0000\u0000$\u00c7\u0001\u0000\u0000\u0000"+
+ "&\u00c9\u0001\u0000\u0000\u0000(\u00cb\u0001\u0000\u0000\u0000*,\u0003"+
+ "\u0002\u0001\u0000+*\u0001\u0000\u0000\u0000,-\u0001\u0000\u0000\u0000"+
+ "-+\u0001\u0000\u0000\u0000-.\u0001\u0000\u0000\u0000.\u0001\u0001\u0000"+
+ "\u0000\u0000/0\u0003\u0012\t\u000001\u0005\u0001\u0000\u000012\u0005%"+
+ "\u0000\u000026\u0005\u0002\u0000\u000035\u0003\u0004\u0002\u000043\u0001"+
+ "\u0000\u0000\u000058\u0001\u0000\u0000\u000064\u0001\u0000\u0000\u0000"+
+ "67\u0001\u0000\u0000\u000079\u0001\u0000\u0000\u000086\u0001\u0000\u0000"+
+ "\u00009:\u0005\u0003\u0000\u0000:\u0003\u0001\u0000\u0000\u0000;?\u0003"+
+ "\u0006\u0003\u0000\u0003\b\u0004\u0000=?\u0003\n\u0005\u0000>;\u0001"+
+ "\u0000\u0000\u0000><\u0001\u0000\u0000\u0000>=\u0001\u0000\u0000\u0000"+
+ "?\u0005\u0001\u0000\u0000\u0000@A\u0003\u0012\t\u0000AB\u0003\u0010\b"+
+ "\u0000BC\u0005%\u0000\u0000CD\u0005\u0004\u0000\u0000D\u0007\u0001\u0000"+
+ "\u0000\u0000EF\u0003\u0012\t\u0000FG\u0005\u0005\u0000\u0000GH\u0003\u0010"+
+ "\b\u0000HI\u0005%\u0000\u0000IK\u0005\u0006\u0000\u0000JL\u0003\f\u0006"+
+ "\u0000KJ\u0001\u0000\u0000\u0000KL\u0001\u0000\u0000\u0000LM\u0001\u0000"+
+ "\u0000\u0000MN\u0005\u0007\u0000\u0000NR\u0005\u0002\u0000\u0000OQ\u0003"+
+ "\u0014\n\u0000PO\u0001\u0000\u0000\u0000QT\u0001\u0000\u0000\u0000RP\u0001"+
+ "\u0000\u0000\u0000RS\u0001\u0000\u0000\u0000SU\u0001\u0000\u0000\u0000"+
+ "TR\u0001\u0000\u0000\u0000UV\u0005\u0003\u0000\u0000V\t\u0001\u0000\u0000"+
+ "\u0000WX\u0003\u0012\t\u0000XY\u0005%\u0000\u0000Y[\u0005\u0006\u0000"+
+ "\u0000Z\\\u0003\f\u0006\u0000[Z\u0001\u0000\u0000\u0000[\\\u0001\u0000"+
+ "\u0000\u0000\\]\u0001\u0000\u0000\u0000]^\u0005\u0007\u0000\u0000^b\u0005"+
+ "\u0002\u0000\u0000_a\u0003\u0014\n\u0000`_\u0001\u0000\u0000\u0000ad\u0001"+
+ "\u0000\u0000\u0000b`\u0001\u0000\u0000\u0000bc\u0001\u0000\u0000\u0000"+
+ "ce\u0001\u0000\u0000\u0000db\u0001\u0000\u0000\u0000ef\u0005\u0003\u0000"+
+ "\u0000f\u000b\u0001\u0000\u0000\u0000gl\u0003\u000e\u0007\u0000hi\u0005"+
+ "\b\u0000\u0000ik\u0003\u000e\u0007\u0000jh\u0001\u0000\u0000\u0000kn\u0001"+
+ "\u0000\u0000\u0000lj\u0001\u0000\u0000\u0000lm\u0001\u0000\u0000\u0000"+
+ "m\r\u0001\u0000\u0000\u0000nl\u0001\u0000\u0000\u0000op\u0003\u0010\b"+
+ "\u0000pq\u0005%\u0000\u0000q\u000f\u0001\u0000\u0000\u0000rs\u0007\u0000"+
+ "\u0000\u0000s\u0011\u0001\u0000\u0000\u0000tu\u0007\u0001\u0000\u0000"+
+ "u\u0013\u0001\u0000\u0000\u0000v}\u0003\u0016\u000b\u0000w}\u0003\u0018"+
+ "\f\u0000x}\u0003\u001a\r\u0000y}\u0003\u001c\u000e\u0000z}\u0003\u001e"+
+ "\u000f\u0000{}\u0003 \u0010\u0000|v\u0001\u0000\u0000\u0000|w\u0001\u0000"+
+ "\u0000\u0000|x\u0001\u0000\u0000\u0000|y\u0001\u0000\u0000\u0000|z\u0001"+
+ "\u0000\u0000\u0000|{\u0001\u0000\u0000\u0000}\u0015\u0001\u0000\u0000"+
+ "\u0000~\u007f\u0003\u0010\b\u0000\u007f\u0082\u0005%\u0000\u0000\u0080"+
+ "\u0081\u0005\u000e\u0000\u0000\u0081\u0083\u0003\"\u0011\u0000\u0082\u0080"+
+ "\u0001\u0000\u0000\u0000\u0082\u0083\u0001\u0000\u0000\u0000\u0083\u0084"+
+ "\u0001\u0000\u0000\u0000\u0084\u0085\u0005\u0004\u0000\u0000\u0085\u0017"+
+ "\u0001\u0000\u0000\u0000\u0086\u0087\u0005%\u0000\u0000\u0087\u0088\u0005"+
+ "\u000e\u0000\u0000\u0088\u0089\u0003\"\u0011\u0000\u0089\u008a\u0005\u0004"+
+ "\u0000\u0000\u008a\u0019\u0001\u0000\u0000\u0000\u008b\u008c\u0005\u000f"+
+ "\u0000\u0000\u008c\u008d\u0005\u0006\u0000\u0000\u008d\u008e\u0003\"\u0011"+
+ "\u0000\u008e\u008f\u0005\u0007\u0000\u0000\u008f\u0092\u0003\u0014\n\u0000"+
+ "\u0090\u0091\u0005\u0010\u0000\u0000\u0091\u0093\u0003\u0014\n\u0000\u0092"+
+ "\u0090\u0001\u0000\u0000\u0000\u0092\u0093\u0001\u0000\u0000\u0000\u0093"+
+ "\u001b\u0001\u0000\u0000\u0000\u0094\u0095\u0005\u0011\u0000\u0000\u0095"+
+ "\u0096\u0005\u0006\u0000\u0000\u0096\u0097\u0003\"\u0011\u0000\u0097\u0098"+
+ "\u0005\u0007\u0000\u0000\u0098\u0099\u0003\u0014\n\u0000\u0099\u001d\u0001"+
+ "\u0000\u0000\u0000\u009a\u009c\u0005\u0012\u0000\u0000\u009b\u009d\u0003"+
+ "\"\u0011\u0000\u009c\u009b\u0001\u0000\u0000\u0000\u009c\u009d\u0001\u0000"+
+ "\u0000\u0000\u009d\u009e\u0001\u0000\u0000\u0000\u009e\u009f\u0005\u0004"+
+ "\u0000\u0000\u009f\u001f\u0001\u0000\u0000\u0000\u00a0\u00a4\u0005\u0002"+
+ "\u0000\u0000\u00a1\u00a3\u0003\u0014\n\u0000\u00a2\u00a1\u0001\u0000\u0000"+
+ "\u0000\u00a3\u00a6\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000"+
+ "\u0000\u00a4\u00a5\u0001\u0000\u0000\u0000\u00a5\u00a7\u0001\u0000\u0000"+
+ "\u0000\u00a6\u00a4\u0001\u0000\u0000\u0000\u00a7\u00a8\u0005\u0003\u0000"+
+ "\u0000\u00a8!\u0001\u0000\u0000\u0000\u00a9\u00aa\u0006\u0011\uffff\uffff"+
+ "\u0000\u00aa\u00ab\u0005\u001c\u0000\u0000\u00ab\u00b5\u0003\"\u0011\u0005"+
+ "\u00ac\u00ad\u0005 \u0000\u0000\u00ad\u00b5\u0003\"\u0011\u0004\u00ae"+
+ "\u00af\u0005\u0006\u0000\u0000\u00af\u00b0\u0003\"\u0011\u0000\u00b0\u00b1"+
+ "\u0005\u0007\u0000\u0000\u00b1\u00b5\u0001\u0000\u0000\u0000\u00b2\u00b5"+
+ "\u0003$\u0012\u0000\u00b3\u00b5\u0005%\u0000\u0000\u00b4\u00a9\u0001\u0000"+
+ "\u0000\u0000\u00b4\u00ac\u0001\u0000\u0000\u0000\u00b4\u00ae\u0001\u0000"+
+ "\u0000\u0000\u00b4\u00b2\u0001\u0000\u0000\u0000\u00b4\u00b3\u0001\u0000"+
+ "\u0000\u0000\u00b5\u00c1\u0001\u0000\u0000\u0000\u00b6\u00b7\n\b\u0000"+
+ "\u0000\u00b7\u00b8\u0007\u0002\u0000\u0000\u00b8\u00c0\u0003\"\u0011\t"+
+ "\u00b9\u00ba\n\u0007\u0000\u0000\u00ba\u00bb\u0007\u0003\u0000\u0000\u00bb"+
+ "\u00c0\u0003\"\u0011\b\u00bc\u00bd\n\u0006\u0000\u0000\u00bd\u00be\u0007"+
+ "\u0004\u0000\u0000\u00be\u00c0\u0003\"\u0011\u0007\u00bf\u00b6\u0001\u0000"+
+ "\u0000\u0000\u00bf\u00b9\u0001\u0000\u0000\u0000\u00bf\u00bc\u0001\u0000"+
+ "\u0000\u0000\u00c0\u00c3\u0001\u0000\u0000\u0000\u00c1\u00bf\u0001\u0000"+
+ "\u0000\u0000\u00c1\u00c2\u0001\u0000\u0000\u0000\u00c2#\u0001\u0000\u0000"+
+ "\u0000\u00c3\u00c1\u0001\u0000\u0000\u0000\u00c4\u00c8\u0005$\u0000\u0000"+
+ "\u00c5\u00c8\u0003&\u0013\u0000\u00c6\u00c8\u0003(\u0014\u0000\u00c7\u00c4"+
+ "\u0001\u0000\u0000\u0000\u00c7\u00c5\u0001\u0000\u0000\u0000\u00c7\u00c6"+
+ "\u0001\u0000\u0000\u0000\u00c8%\u0001\u0000\u0000\u0000\u00c9\u00ca\u0007"+
+ "\u0005\u0000\u0000\u00ca\'\u0001\u0000\u0000\u0000\u00cb\u00cc\u0005#"+
+ "\u0000\u0000\u00cc\u00cd\t\u0000\u0000\u0000\u00cd\u00ce\u0005#\u0000"+
+ "\u0000\u00ce)\u0001\u0000\u0000\u0000\u0011-6>KR[bl|\u0082\u0092\u009c"+
+ "\u00a4\u00b4\u00bf\u00c1\u00c7";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
diff --git a/src/main/java/parser/generated/SimpleJavaVisitor.java b/src/main/java/parser/generated/SimpleJavaVisitor.java
index 0e5f589..1d10783 100644
--- a/src/main/java/parser/generated/SimpleJavaVisitor.java
+++ b/src/main/java/parser/generated/SimpleJavaVisitor.java
@@ -1,4 +1,4 @@
-// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
+// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
@@ -40,6 +40,12 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor {
* @return the visitor result
*/
T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
+ /**
+ * Visit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
+ * @param ctx the parse tree
+ * @return the visitor result
+ */
+ T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#parameterList}.
* @param ctx the parse tree
From 4acf4dfe249d7f639fa31b2e41832ef9f504e30f Mon Sep 17 00:00:00 2001
From: i22035
Date: Thu, 9 May 2024 13:47:38 +0200
Subject: [PATCH 3/4] Added Statements and Expressions for parser
---
src/main/java/ast/AssignmentNode.java | 14 ---
src/main/java/ast/BlockNode.java | 4 +
src/main/java/ast/ClassNode.java | 5 +-
src/main/java/ast/ConstructorNode.java | 2 +
src/main/java/ast/ExpressionNode.java | 11 ---
src/main/java/ast/FieldNode.java | 6 +-
.../{Identifier.java => IdentifierNode.java} | 8 +-
src/main/java/ast/MethodNode.java | 9 +-
src/main/java/ast/TypeNode.java | 2 +
.../ast/expression/BinaryExpressionNode.java | 13 +++
.../java/ast/expression/ExpressionNode.java | 7 ++
.../expression/IdentifierExpressionNode.java | 9 ++
.../ast/expression/UnaryExpressionNode.java | 11 +++
.../statement/AssignmentStatementNode.java | 13 +++
.../java/ast/statement/IfStatementNode.java | 15 ++++
.../ast/statement/ReturnStatementNode.java | 11 +++
.../ast/{ => statement}/StatementNode.java | 2 +-
.../VariableDeclarationStatementNode.java | 8 +-
.../ast/statement/WhileStatementNode.java | 13 +++
.../java/ast/{ => type}/AccessTypeNode.java | 4 +-
.../ast/{ => type}/EnumAccessTypeNode.java | 2 +-
.../java/ast/{ => type}/EnumTypeNode.java | 2 +-
src/main/java/bytecode/Mapper.java | 4 +-
src/main/java/parser/ASTBuilder.java | 90 +++++++++++++++----
src/main/java/semantic/SemanticAnalyzer.java | 4 +-
25 files changed, 208 insertions(+), 61 deletions(-)
delete mode 100644 src/main/java/ast/AssignmentNode.java
create mode 100644 src/main/java/ast/BlockNode.java
delete mode 100644 src/main/java/ast/ExpressionNode.java
rename src/main/java/ast/{Identifier.java => IdentifierNode.java} (67%)
create mode 100644 src/main/java/ast/expression/BinaryExpressionNode.java
create mode 100644 src/main/java/ast/expression/ExpressionNode.java
create mode 100644 src/main/java/ast/expression/IdentifierExpressionNode.java
create mode 100644 src/main/java/ast/expression/UnaryExpressionNode.java
create mode 100644 src/main/java/ast/statement/AssignmentStatementNode.java
create mode 100644 src/main/java/ast/statement/IfStatementNode.java
create mode 100644 src/main/java/ast/statement/ReturnStatementNode.java
rename src/main/java/ast/{ => statement}/StatementNode.java (77%)
rename src/main/java/ast/{ => statement}/VariableDeclarationStatementNode.java (73%)
create mode 100644 src/main/java/ast/statement/WhileStatementNode.java
rename src/main/java/ast/{ => type}/AccessTypeNode.java (85%)
rename src/main/java/ast/{ => type}/EnumAccessTypeNode.java (75%)
rename src/main/java/ast/{ => type}/EnumTypeNode.java (74%)
diff --git a/src/main/java/ast/AssignmentNode.java b/src/main/java/ast/AssignmentNode.java
deleted file mode 100644
index 38e7fb9..0000000
--- a/src/main/java/ast/AssignmentNode.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package ast;
-
-public class AssignmentNode extends StatementNode {
-
- public Identifier identifier;
-
- public ExpressionNode expression;
-
- public AssignmentNode(String identifier, ExpressionNode expression) {
- this.identifier = new Identifier(identifier);
- this.expression = expression;
- }
-
-}
diff --git a/src/main/java/ast/BlockNode.java b/src/main/java/ast/BlockNode.java
new file mode 100644
index 0000000..2dd5307
--- /dev/null
+++ b/src/main/java/ast/BlockNode.java
@@ -0,0 +1,4 @@
+package ast;
+
+public class BlockNode {
+}
diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java
index dd390ee..81dc844 100644
--- a/src/main/java/ast/ClassNode.java
+++ b/src/main/java/ast/ClassNode.java
@@ -1,10 +1,13 @@
package ast;
+import ast.type.AccessTypeNode;
+import ast.type.EnumAccessTypeNode;
+
import java.util.ArrayList;
import java.util.List;
public class ClassNode extends ASTNode{
- public Identifier identifier;
+ public IdentifierNode identifier;
public AccessTypeNode accessType;
public String name;
public List members = new ArrayList<>();
diff --git a/src/main/java/ast/ConstructorNode.java b/src/main/java/ast/ConstructorNode.java
index a824f5a..94108b8 100644
--- a/src/main/java/ast/ConstructorNode.java
+++ b/src/main/java/ast/ConstructorNode.java
@@ -1,5 +1,7 @@
package ast;
+import ast.type.AccessTypeNode;
+
public class ConstructorNode extends MethodNode{
public ConstructorNode(AccessTypeNode visibility, String name) {
super(visibility, name);
diff --git a/src/main/java/ast/ExpressionNode.java b/src/main/java/ast/ExpressionNode.java
deleted file mode 100644
index 9e6f2a8..0000000
--- a/src/main/java/ast/ExpressionNode.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package ast;
-
-public class ExpressionNode extends ASTNode {
-
- int Value;
-
- public ExpressionNode(int value) {
- this.Value = value;
- }
-
-}
diff --git a/src/main/java/ast/FieldNode.java b/src/main/java/ast/FieldNode.java
index 3d0d287..4e316c1 100644
--- a/src/main/java/ast/FieldNode.java
+++ b/src/main/java/ast/FieldNode.java
@@ -1,14 +1,16 @@
package ast;
+import ast.type.AccessTypeNode;
+
public class FieldNode extends MemberNode {
public AccessTypeNode accessTypeNode;
public TypeNode type;
- public Identifier identifier;
+ public IdentifierNode identifier;
public FieldNode(AccessTypeNode accessTypeNode, TypeNode type, String name){
this.accessTypeNode = accessTypeNode;
this.type = type;
- this.identifier = new Identifier(name);
+ this.identifier = new IdentifierNode(name);
}
}
diff --git a/src/main/java/ast/Identifier.java b/src/main/java/ast/IdentifierNode.java
similarity index 67%
rename from src/main/java/ast/Identifier.java
rename to src/main/java/ast/IdentifierNode.java
index 2f6fe73..3300633 100644
--- a/src/main/java/ast/Identifier.java
+++ b/src/main/java/ast/IdentifierNode.java
@@ -1,10 +1,10 @@
package ast;
-public class Identifier {
+public class IdentifierNode {
private String name;
- public Identifier(String name){
+ public IdentifierNode(String name){
this.name = name;
}
@@ -13,8 +13,8 @@ public class Identifier {
}
public boolean equals(Object obj) {
- if(obj instanceof Identifier){
- Identifier identifier = (Identifier) obj;
+ if(obj instanceof IdentifierNode){
+ IdentifierNode identifier = (IdentifierNode) obj;
if(name.equals(identifier.getName())){
return true;
} else {
diff --git a/src/main/java/ast/MethodNode.java b/src/main/java/ast/MethodNode.java
index d9058c5..2c4e1e9 100644
--- a/src/main/java/ast/MethodNode.java
+++ b/src/main/java/ast/MethodNode.java
@@ -1,10 +1,13 @@
package ast;
+import ast.statement.StatementNode;
+import ast.type.AccessTypeNode;
+
import java.util.ArrayList;
import java.util.List;
public class MethodNode extends MemberNode{
- public Identifier identifier;
+ public IdentifierNode identifier;
public AccessTypeNode visibility;
public TypeNode type;
public String name;
@@ -16,7 +19,7 @@ public class MethodNode extends MemberNode{
public MethodNode(AccessTypeNode visibility, TypeNode type, String name, ParameterListNode parameters,
List statements){
this.visibility = visibility;
- this.identifier = new Identifier(name);
+ this.identifier = new IdentifierNode(name);
this.type = type;
this.name = name;
this.parameters = parameters;
@@ -25,6 +28,6 @@ public class MethodNode extends MemberNode{
public MethodNode(AccessTypeNode visibility, String name){
this.visibility = visibility;
- this.identifier = new Identifier(name);
+ this.identifier = new IdentifierNode(name);
}
}
diff --git a/src/main/java/ast/TypeNode.java b/src/main/java/ast/TypeNode.java
index fd921b6..4733bc8 100644
--- a/src/main/java/ast/TypeNode.java
+++ b/src/main/java/ast/TypeNode.java
@@ -1,5 +1,7 @@
package ast;
+import ast.type.EnumTypeNode;
+
public class TypeNode extends ASTNode {
public EnumTypeNode enumTypeNode;
diff --git a/src/main/java/ast/expression/BinaryExpressionNode.java b/src/main/java/ast/expression/BinaryExpressionNode.java
new file mode 100644
index 0000000..e63bbca
--- /dev/null
+++ b/src/main/java/ast/expression/BinaryExpressionNode.java
@@ -0,0 +1,13 @@
+package ast.expression;
+
+public class BinaryExpressionNode extends ExpressionNode {
+ public ExpressionNode left;
+ public ExpressionNode right;
+ public String operator; // Stores the operator as a string (e.g., "+", "-", "&&")
+
+ public BinaryExpressionNode(ExpressionNode left, ExpressionNode right, String operator) {
+ this.left = left;
+ this.right = right;
+ this.operator = operator;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/ast/expression/ExpressionNode.java
new file mode 100644
index 0000000..eff9d29
--- /dev/null
+++ b/src/main/java/ast/expression/ExpressionNode.java
@@ -0,0 +1,7 @@
+package ast.expression;
+
+import ast.ASTNode;
+
+public class ExpressionNode extends ASTNode {
+
+}
diff --git a/src/main/java/ast/expression/IdentifierExpressionNode.java b/src/main/java/ast/expression/IdentifierExpressionNode.java
new file mode 100644
index 0000000..7631429
--- /dev/null
+++ b/src/main/java/ast/expression/IdentifierExpressionNode.java
@@ -0,0 +1,9 @@
+package ast.expression;
+
+public class IdentifierExpressionNode extends ExpressionNode {
+ public String name;
+
+ public IdentifierExpressionNode(String name) {
+ this.name = name;
+ }
+}
diff --git a/src/main/java/ast/expression/UnaryExpressionNode.java b/src/main/java/ast/expression/UnaryExpressionNode.java
new file mode 100644
index 0000000..0c77ef5
--- /dev/null
+++ b/src/main/java/ast/expression/UnaryExpressionNode.java
@@ -0,0 +1,11 @@
+package ast.expression;
+
+public class UnaryExpressionNode extends ExpressionNode {
+ public ExpressionNode expression;
+ public String operator; // Stores the operator (e.g., "-", "!")
+
+ public UnaryExpressionNode(ExpressionNode expression, String operator) {
+ this.expression = expression;
+ this.operator = operator;
+ }
+}
diff --git a/src/main/java/ast/statement/AssignmentStatementNode.java b/src/main/java/ast/statement/AssignmentStatementNode.java
new file mode 100644
index 0000000..97bcd45
--- /dev/null
+++ b/src/main/java/ast/statement/AssignmentStatementNode.java
@@ -0,0 +1,13 @@
+package ast.statement;
+
+import ast.expression.ExpressionNode;
+
+public class AssignmentStatementNode extends StatementNode {
+ public String identifier;
+ public ExpressionNode expression;
+
+ public AssignmentStatementNode(String identifier, ExpressionNode expression) {
+ this.identifier = identifier;
+ this.expression = expression;
+ }
+}
diff --git a/src/main/java/ast/statement/IfStatementNode.java b/src/main/java/ast/statement/IfStatementNode.java
new file mode 100644
index 0000000..93eec91
--- /dev/null
+++ b/src/main/java/ast/statement/IfStatementNode.java
@@ -0,0 +1,15 @@
+package ast.statement;
+
+import ast.expression.ExpressionNode;
+
+public class IfStatementNode extends StatementNode {
+ public ExpressionNode condition;
+ public StatementNode thenStatement;
+ public StatementNode elseStatement;
+
+ public IfStatementNode(ExpressionNode condition, StatementNode thenStatement, StatementNode elseStatement) {
+ this.condition = condition;
+ this.thenStatement = thenStatement;
+ this.elseStatement = elseStatement;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java
new file mode 100644
index 0000000..4ca4dfa
--- /dev/null
+++ b/src/main/java/ast/statement/ReturnStatementNode.java
@@ -0,0 +1,11 @@
+package ast.statement;
+
+import ast.expression.ExpressionNode;
+
+public class ReturnStatementNode extends StatementNode {
+ public ExpressionNode expression;
+
+ public ReturnStatementNode(ExpressionNode expression) {
+ this.expression = expression;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ast/StatementNode.java b/src/main/java/ast/statement/StatementNode.java
similarity index 77%
rename from src/main/java/ast/StatementNode.java
rename to src/main/java/ast/statement/StatementNode.java
index 059a96a..910a134 100644
--- a/src/main/java/ast/StatementNode.java
+++ b/src/main/java/ast/statement/StatementNode.java
@@ -1,4 +1,4 @@
-package ast;
+package ast.statement;
import ast.ASTNode;
diff --git a/src/main/java/ast/VariableDeclarationStatementNode.java b/src/main/java/ast/statement/VariableDeclarationStatementNode.java
similarity index 73%
rename from src/main/java/ast/VariableDeclarationStatementNode.java
rename to src/main/java/ast/statement/VariableDeclarationStatementNode.java
index 6222942..1095fd6 100644
--- a/src/main/java/ast/VariableDeclarationStatementNode.java
+++ b/src/main/java/ast/statement/VariableDeclarationStatementNode.java
@@ -1,10 +1,12 @@
-package ast;
+package ast.statement;
+
+import ast.TypeNode;
+import ast.expression.ExpressionNode;
public class VariableDeclarationStatementNode extends StatementNode {
public TypeNode type;
public String identifier;
- public ExpressionNode expression; // Nullable for cases without initialization
-
+ public ExpressionNode expression;
public VariableDeclarationStatementNode(TypeNode type, String identifier, ExpressionNode expression) {
this.type = type;
this.identifier = identifier;
diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/ast/statement/WhileStatementNode.java
new file mode 100644
index 0000000..e6a10b1
--- /dev/null
+++ b/src/main/java/ast/statement/WhileStatementNode.java
@@ -0,0 +1,13 @@
+package ast.statement;
+
+import ast.expression.ExpressionNode;
+
+public class WhileStatementNode extends StatementNode {
+ public ExpressionNode condition;
+ public StatementNode body;
+
+ public WhileStatementNode(ExpressionNode condition, StatementNode body) {
+ this.condition = condition;
+ this.body = body;
+ }
+}
diff --git a/src/main/java/ast/AccessTypeNode.java b/src/main/java/ast/type/AccessTypeNode.java
similarity index 85%
rename from src/main/java/ast/AccessTypeNode.java
rename to src/main/java/ast/type/AccessTypeNode.java
index 2ed2e55..ddacf68 100644
--- a/src/main/java/ast/AccessTypeNode.java
+++ b/src/main/java/ast/type/AccessTypeNode.java
@@ -1,4 +1,6 @@
-package ast;
+package ast.type;
+
+import ast.ASTNode;
public class AccessTypeNode extends ASTNode {
public EnumAccessTypeNode enumAccessTypeNode;
diff --git a/src/main/java/ast/EnumAccessTypeNode.java b/src/main/java/ast/type/EnumAccessTypeNode.java
similarity index 75%
rename from src/main/java/ast/EnumAccessTypeNode.java
rename to src/main/java/ast/type/EnumAccessTypeNode.java
index 2e6ffba..12cdda9 100644
--- a/src/main/java/ast/EnumAccessTypeNode.java
+++ b/src/main/java/ast/type/EnumAccessTypeNode.java
@@ -1,4 +1,4 @@
-package ast;
+package ast.type;
public enum EnumAccessTypeNode {
PUBLIC, PRIVATE
diff --git a/src/main/java/ast/EnumTypeNode.java b/src/main/java/ast/type/EnumTypeNode.java
similarity index 74%
rename from src/main/java/ast/EnumTypeNode.java
rename to src/main/java/ast/type/EnumTypeNode.java
index b80cd57..d858461 100644
--- a/src/main/java/ast/EnumTypeNode.java
+++ b/src/main/java/ast/type/EnumTypeNode.java
@@ -1,4 +1,4 @@
-package ast;
+package ast.type;
public enum EnumTypeNode {
INT, BOOLEAN, CHAR
diff --git a/src/main/java/bytecode/Mapper.java b/src/main/java/bytecode/Mapper.java
index 872f8e1..168e1e2 100644
--- a/src/main/java/bytecode/Mapper.java
+++ b/src/main/java/bytecode/Mapper.java
@@ -1,7 +1,7 @@
package bytecode;
-import ast.AccessTypeNode;
-import ast.EnumAccessTypeNode;
+import ast.type.AccessTypeNode;
+import ast.type.EnumAccessTypeNode;
import org.objectweb.asm.Opcodes;
public class Mapper {
diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/ASTBuilder.java
index e90ba95..c4f9374 100644
--- a/src/main/java/parser/ASTBuilder.java
+++ b/src/main/java/parser/ASTBuilder.java
@@ -1,12 +1,20 @@
package parser;
import ast.*;
+import ast.expression.BinaryExpressionNode;
+import ast.expression.ExpressionNode;
+import ast.expression.IdentifierExpressionNode;
+import ast.expression.UnaryExpressionNode;
+import ast.statement.*;
+import ast.type.AccessTypeNode;
+import ast.type.EnumAccessTypeNode;
+import ast.type.EnumTypeNode;
+import org.antlr.v4.runtime.tree.TerminalNode;
import parser.generated.SimpleJavaBaseVisitor;
import parser.generated.SimpleJavaParser;
import java.util.ArrayList;
import java.util.List;
-import parser.generated.SimpleJavaParser.LiteralContext;
public class ASTBuilder extends SimpleJavaBaseVisitor {
@Override
@@ -21,7 +29,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor {
@Override
public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) {
ClassNode classNode = new ClassNode((AccessTypeNode) visit(ctx.accessType()),ctx.IDENTIFIER().getText());
- classNode.identifier = new Identifier(ctx.IDENTIFIER().getText());
+ classNode.identifier = new IdentifierNode(ctx.IDENTIFIER().getText());
for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) {
classNode.addMember((MemberNode) visit(member));
}
@@ -108,26 +116,78 @@ public class ASTBuilder extends SimpleJavaBaseVisitor {
return null;
}
+ @Override
+ public ASTNode visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) {
+ TypeNode type = (TypeNode) visit(ctx.type());
+ String identifier = ctx.IDENTIFIER().getText();
+ ExpressionNode expression = null;
+ if (ctx.expression() != null) {
+ expression = (ExpressionNode) visit(ctx.expression());
+ }
+ return new VariableDeclarationStatementNode(type, identifier, expression);
+ }
+
@Override
public ASTNode visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) {
- ExpressionNode expressionNode = (ExpressionNode) visit(ctx.expression());
- return new AssignmentNode(ctx.IDENTIFIER().getText(), expressionNode);
+ String identifier = ctx.IDENTIFIER().getText();
+ ExpressionNode expression = (ExpressionNode) visit(ctx.expression());
+ return new AssignmentStatementNode(identifier, expression);
+ }
+
+ @Override
+ public ASTNode visitIfStatement(SimpleJavaParser.IfStatementContext ctx) {
+ ExpressionNode condition = (ExpressionNode) visit(ctx.expression());
+ StatementNode thenStatement = (StatementNode) visit(ctx.statement(0)); // The 'then' branch
+ StatementNode elseStatement = null;
+ if (ctx.statement().size() > 1) {
+ elseStatement = (StatementNode) visit(ctx.statement(1)); // The 'else' branch, if present
+ }
+ return new IfStatementNode(condition, thenStatement, elseStatement);
+ }
+
+ @Override
+ public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) {
+ ExpressionNode condition = (ExpressionNode) visit(ctx.expression()); // Visit the condition part of the while statement
+ StatementNode body = (StatementNode) visit(ctx.statement()); // Visit the body part of the while statement
+ return new WhileStatementNode(condition, body);
+ }
+
+ @Override
+ public ASTNode visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) {
+ ExpressionNode expression = null;
+ if (ctx.expression() != null) {
+ expression = (ExpressionNode) visit(ctx.expression()); // Visit the expression part of the return statement, if it exists
+ }
+ return new ReturnStatementNode(expression);
}
@Override
public ASTNode visitExpression(SimpleJavaParser.ExpressionContext ctx) {
- if(ctx.literal() != null){
- return visitLiteral(ctx.literal());
+ // Handle binary operations
+ if (ctx.getChildCount() == 3 && ctx.getChild(1) instanceof TerminalNode) {
+ ExpressionNode left = (ExpressionNode) visit(ctx.expression(0));
+ ExpressionNode right = (ExpressionNode) visit(ctx.expression(1));
+ String operator = ctx.getChild(1).getText();
+ return new BinaryExpressionNode(left, right, operator);
}
- return null;
- }
-
- @Override
- public ASTNode visitLiteral(SimpleJavaParser.LiteralContext ctx) {
- if(ctx.INTEGERLITERAL() != null){
- return new ExpressionNode(Integer.parseInt(ctx.INTEGERLITERAL().getSymbol().getText()));
+ // Handle unary operations
+ else if (ctx.getChildCount() == 2) {
+ String operator = ctx.getChild(0).getText();
+ ExpressionNode expression = (ExpressionNode) visit(ctx.expression(0));
+ return new UnaryExpressionNode(expression, operator);
+ }
+ // Handle parentheses
+ else if (ctx.getChildCount() == 3 && ctx.getChild(0).getText().equals("(")) {
+ return visit(ctx.expression(0)); // Simply return the inner expression
+ }
+ // Handle literals and identifiers
+ else if (ctx.literal() != null) {
+ return visit(ctx.literal());
+ }
+ else if (ctx.IDENTIFIER() != null) {
+ return new IdentifierExpressionNode(ctx.IDENTIFIER().getText());
}
- return null;
- }
+ return null; // Return null or throw an exception if no valid expression found
+ }
}
diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java
index 315a51e..940a0dc 100644
--- a/src/main/java/semantic/SemanticAnalyzer.java
+++ b/src/main/java/semantic/SemanticAnalyzer.java
@@ -8,7 +8,7 @@ import java.util.List;
public class SemanticAnalyzer {
- List usedIdentifier = new ArrayList<>();
+ List usedIdentifier = new ArrayList<>();
public void analyze(ASTNode node) {
if (node == null) return;
@@ -47,7 +47,7 @@ public class SemanticAnalyzer {
}
- public boolean identifierAlreadyUsed(Identifier identifier){
+ public boolean identifierAlreadyUsed(IdentifierNode identifier){
if(usedIdentifier.contains(identifier)){
return true;
} else {
From 6b7fc09f8f79c9271633ba8330a962ccb066c8c7 Mon Sep 17 00:00:00 2001
From: i22035
Date: Thu, 9 May 2024 13:55:45 +0200
Subject: [PATCH 4/4] Changed AST Tree
---
src/main/java/ast/ClassNode.java | 2 ++
src/main/java/ast/MemberNode.java | 4 ----
src/main/java/ast/{ => member}/ConstructorNode.java | 4 ++--
src/main/java/ast/{ => member}/FieldNode.java | 4 +++-
src/main/java/ast/member/MemberNode.java | 6 ++++++
src/main/java/ast/{ => member}/MethodNode.java | 7 +++++--
src/main/java/ast/{ => parameter}/ParameterListNode.java | 4 +++-
src/main/java/ast/{ => parameter}/ParameterNode.java | 5 ++++-
.../ast/statement/VariableDeclarationStatementNode.java | 2 +-
src/main/java/ast/{ => type}/TypeNode.java | 4 ++--
src/main/java/bytecode/ClassCodeGen.java | 6 +++---
src/main/java/bytecode/FieldCodeGen.java | 3 +--
src/main/java/bytecode/MethodCodeGen.java | 3 +--
src/main/java/parser/ASTBuilder.java | 6 ++++++
src/main/java/semantic/SemanticAnalyzer.java | 3 +++
15 files changed, 42 insertions(+), 21 deletions(-)
delete mode 100644 src/main/java/ast/MemberNode.java
rename src/main/java/ast/{ => member}/ConstructorNode.java (67%)
rename src/main/java/ast/{ => member}/FieldNode.java (84%)
create mode 100644 src/main/java/ast/member/MemberNode.java
rename src/main/java/ast/{ => member}/MethodNode.java (85%)
rename src/main/java/ast/{ => parameter}/ParameterListNode.java (85%)
rename src/main/java/ast/{ => parameter}/ParameterNode.java (76%)
rename src/main/java/ast/{ => type}/TypeNode.java (80%)
diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java
index 81dc844..2f27d08 100644
--- a/src/main/java/ast/ClassNode.java
+++ b/src/main/java/ast/ClassNode.java
@@ -1,5 +1,7 @@
package ast;
+import ast.member.ConstructorNode;
+import ast.member.MemberNode;
import ast.type.AccessTypeNode;
import ast.type.EnumAccessTypeNode;
diff --git a/src/main/java/ast/MemberNode.java b/src/main/java/ast/MemberNode.java
deleted file mode 100644
index c1086cd..0000000
--- a/src/main/java/ast/MemberNode.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package ast;
-
-public class MemberNode extends ASTNode{
-}
diff --git a/src/main/java/ast/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java
similarity index 67%
rename from src/main/java/ast/ConstructorNode.java
rename to src/main/java/ast/member/ConstructorNode.java
index 94108b8..b411ff1 100644
--- a/src/main/java/ast/ConstructorNode.java
+++ b/src/main/java/ast/member/ConstructorNode.java
@@ -1,8 +1,8 @@
-package ast;
+package ast.member;
import ast.type.AccessTypeNode;
-public class ConstructorNode extends MethodNode{
+public class ConstructorNode extends MethodNode {
public ConstructorNode(AccessTypeNode visibility, String name) {
super(visibility, name);
}
diff --git a/src/main/java/ast/FieldNode.java b/src/main/java/ast/member/FieldNode.java
similarity index 84%
rename from src/main/java/ast/FieldNode.java
rename to src/main/java/ast/member/FieldNode.java
index 4e316c1..53a5335 100644
--- a/src/main/java/ast/FieldNode.java
+++ b/src/main/java/ast/member/FieldNode.java
@@ -1,6 +1,8 @@
-package ast;
+package ast.member;
+import ast.IdentifierNode;
import ast.type.AccessTypeNode;
+import ast.type.TypeNode;
public class FieldNode extends MemberNode {
public AccessTypeNode accessTypeNode;
diff --git a/src/main/java/ast/member/MemberNode.java b/src/main/java/ast/member/MemberNode.java
new file mode 100644
index 0000000..aa823af
--- /dev/null
+++ b/src/main/java/ast/member/MemberNode.java
@@ -0,0 +1,6 @@
+package ast.member;
+
+import ast.ASTNode;
+
+public class MemberNode extends ASTNode {
+}
diff --git a/src/main/java/ast/MethodNode.java b/src/main/java/ast/member/MethodNode.java
similarity index 85%
rename from src/main/java/ast/MethodNode.java
rename to src/main/java/ast/member/MethodNode.java
index 2c4e1e9..4c937cc 100644
--- a/src/main/java/ast/MethodNode.java
+++ b/src/main/java/ast/member/MethodNode.java
@@ -1,12 +1,15 @@
-package ast;
+package ast.member;
+import ast.IdentifierNode;
+import ast.parameter.ParameterListNode;
import ast.statement.StatementNode;
import ast.type.AccessTypeNode;
+import ast.type.TypeNode;
import java.util.ArrayList;
import java.util.List;
-public class MethodNode extends MemberNode{
+public class MethodNode extends MemberNode {
public IdentifierNode identifier;
public AccessTypeNode visibility;
public TypeNode type;
diff --git a/src/main/java/ast/ParameterListNode.java b/src/main/java/ast/parameter/ParameterListNode.java
similarity index 85%
rename from src/main/java/ast/ParameterListNode.java
rename to src/main/java/ast/parameter/ParameterListNode.java
index c86014b..34c615a 100644
--- a/src/main/java/ast/ParameterListNode.java
+++ b/src/main/java/ast/parameter/ParameterListNode.java
@@ -1,4 +1,6 @@
-package ast;
+package ast.parameter;
+
+import ast.ASTNode;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/ast/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java
similarity index 76%
rename from src/main/java/ast/ParameterNode.java
rename to src/main/java/ast/parameter/ParameterNode.java
index fc2d84a..739ae21 100644
--- a/src/main/java/ast/ParameterNode.java
+++ b/src/main/java/ast/parameter/ParameterNode.java
@@ -1,4 +1,7 @@
-package ast;
+package ast.parameter;
+
+import ast.ASTNode;
+import ast.type.TypeNode;
public class ParameterNode extends ASTNode {
public TypeNode type;
diff --git a/src/main/java/ast/statement/VariableDeclarationStatementNode.java b/src/main/java/ast/statement/VariableDeclarationStatementNode.java
index 1095fd6..e7f6e32 100644
--- a/src/main/java/ast/statement/VariableDeclarationStatementNode.java
+++ b/src/main/java/ast/statement/VariableDeclarationStatementNode.java
@@ -1,6 +1,6 @@
package ast.statement;
-import ast.TypeNode;
+import ast.type.TypeNode;
import ast.expression.ExpressionNode;
public class VariableDeclarationStatementNode extends StatementNode {
diff --git a/src/main/java/ast/TypeNode.java b/src/main/java/ast/type/TypeNode.java
similarity index 80%
rename from src/main/java/ast/TypeNode.java
rename to src/main/java/ast/type/TypeNode.java
index 4733bc8..5b1c2a6 100644
--- a/src/main/java/ast/TypeNode.java
+++ b/src/main/java/ast/type/TypeNode.java
@@ -1,6 +1,6 @@
-package ast;
+package ast.type;
-import ast.type.EnumTypeNode;
+import ast.ASTNode;
public class TypeNode extends ASTNode {
public EnumTypeNode enumTypeNode;
diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java
index 203f3f3..1e931c0 100644
--- a/src/main/java/bytecode/ClassCodeGen.java
+++ b/src/main/java/bytecode/ClassCodeGen.java
@@ -1,9 +1,9 @@
package bytecode;
import ast.ClassNode;
-import ast.FieldNode;
-import ast.MemberNode;
-import ast.MethodNode;
+import ast.member.FieldNode;
+import ast.member.MemberNode;
+import ast.member.MethodNode;
import java.io.File;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
diff --git a/src/main/java/bytecode/FieldCodeGen.java b/src/main/java/bytecode/FieldCodeGen.java
index 5e08941..76e2921 100644
--- a/src/main/java/bytecode/FieldCodeGen.java
+++ b/src/main/java/bytecode/FieldCodeGen.java
@@ -1,9 +1,8 @@
package bytecode;
-import ast.FieldNode;
+import ast.member.FieldNode;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Opcodes;
public class FieldCodeGen {
diff --git a/src/main/java/bytecode/MethodCodeGen.java b/src/main/java/bytecode/MethodCodeGen.java
index 6f217ac..066905f 100644
--- a/src/main/java/bytecode/MethodCodeGen.java
+++ b/src/main/java/bytecode/MethodCodeGen.java
@@ -1,9 +1,8 @@
package bytecode;
-import ast.MethodNode;
+import ast.member.MethodNode;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
public class MethodCodeGen {
public void generateMethodCode(ClassWriter classWriter, MethodNode methodNode) {
diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/ASTBuilder.java
index c4f9374..b6beba4 100644
--- a/src/main/java/parser/ASTBuilder.java
+++ b/src/main/java/parser/ASTBuilder.java
@@ -5,10 +5,16 @@ import ast.expression.BinaryExpressionNode;
import ast.expression.ExpressionNode;
import ast.expression.IdentifierExpressionNode;
import ast.expression.UnaryExpressionNode;
+import ast.member.FieldNode;
+import ast.member.MemberNode;
+import ast.member.MethodNode;
+import ast.parameter.ParameterListNode;
+import ast.parameter.ParameterNode;
import ast.statement.*;
import ast.type.AccessTypeNode;
import ast.type.EnumAccessTypeNode;
import ast.type.EnumTypeNode;
+import ast.type.TypeNode;
import org.antlr.v4.runtime.tree.TerminalNode;
import parser.generated.SimpleJavaBaseVisitor;
import parser.generated.SimpleJavaParser;
diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java
index 940a0dc..3e9197f 100644
--- a/src/main/java/semantic/SemanticAnalyzer.java
+++ b/src/main/java/semantic/SemanticAnalyzer.java
@@ -2,6 +2,9 @@ package semantic;
import ast.*;
+import ast.member.ConstructorNode;
+import ast.member.FieldNode;
+import ast.member.MemberNode;
import java.util.ArrayList;
import java.util.List;