From 22a30d5956fa116521bba59f130aa075e9d2c312 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 31 May 2024 11:08:41 +0200 Subject: [PATCH 01/19] Added typecheck for Assignment --- src/main/java/ast/LiteralNode.java | 2 +- src/main/java/ast/type/BaseTypeNode.java | 13 +++ src/main/java/ast/type/This.java | 6 ++ src/main/java/semantic/SemanticAnalyzer.java | 49 +++++++++- src/main/java/semantic/SemanticVisitor.java | 3 + .../exeptions/TypeMismatchException.java | 9 ++ src/test/java/semantic/Mocker.java | 91 +++++++++++++++++++ src/test/java/semantic/SemanticTest.java | 82 ++++++----------- 8 files changed, 197 insertions(+), 58 deletions(-) create mode 100644 src/main/java/ast/type/This.java create mode 100644 src/main/java/semantic/exeptions/TypeMismatchException.java create mode 100644 src/test/java/semantic/Mocker.java diff --git a/src/main/java/ast/LiteralNode.java b/src/main/java/ast/LiteralNode.java index 3873465..4e7c466 100644 --- a/src/main/java/ast/LiteralNode.java +++ b/src/main/java/ast/LiteralNode.java @@ -24,6 +24,6 @@ public class LiteralNode implements ExpressionNode { @Override public TypeCheckResult accept(SemanticVisitor visitor) { - return null; + return visitor.analyze(this); } } diff --git a/src/main/java/ast/type/BaseTypeNode.java b/src/main/java/ast/type/BaseTypeNode.java index 2d871ab..eb9537c 100644 --- a/src/main/java/ast/type/BaseTypeNode.java +++ b/src/main/java/ast/type/BaseTypeNode.java @@ -10,4 +10,17 @@ public class BaseTypeNode implements ASTNode, TypeNode { this.enumType = enumType; } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BaseTypeNode other = (BaseTypeNode) obj; + if (enumType != other.enumType) + return false; + return true; + } } diff --git a/src/main/java/ast/type/This.java b/src/main/java/ast/type/This.java new file mode 100644 index 0000000..459eea5 --- /dev/null +++ b/src/main/java/ast/type/This.java @@ -0,0 +1,6 @@ +package ast.type; + +import ast.ASTNode; + +public class This implements ASTNode, TypeNode{ +} diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 9ccfe98..a7b1704 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -3,6 +3,7 @@ package semantic; import ast.*; import ast.expression.BinaryExpressionNode; +import ast.expression.ExpressionNode; import ast.expression.IdentifierExpressionNode; import ast.expression.UnaryExpressionNode; import ast.member.ConstructorNode; @@ -14,15 +15,23 @@ import ast.parameter.ParameterListNode; import ast.parameter.ParameterNode; import ast.statement.*; +import java.beans.Expression; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Objects; +import ast.type.BaseTypeNode; +import ast.type.EnumTypeNode; +import ast.type.This; +import ast.type.TypeNode; import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.TypeMismatchException; import typechecker.TypeCheckResult; public class SemanticAnalyzer implements SemanticVisitor { - private static ArrayList currentFields = new ArrayList<>(); + private static HashMap currentFields = new HashMap<>(); public static ArrayList errors = new ArrayList<>(); @@ -134,11 +143,11 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(FieldNode toCheck) { - if (currentFields.contains(toCheck.identifier)) { + if (currentFields.get(toCheck.identifier) != null) { errors.add(new AlreadyDeclearedException("Already declared " + toCheck.identifier)); return new TypeCheckResult(false, null); } else { - currentFields.add(toCheck.identifier); + currentFields.put(toCheck.identifier, toCheck.type); } return new TypeCheckResult(true, null); } @@ -155,12 +164,39 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(BinaryExpressionNode toCheck) { boolean valid = true; + ExpressionNode left = toCheck.left; + var resultLeft = left.accept(this); + ExpressionNode right = toCheck.right; + var resultRight = right.accept(this); + + switch (toCheck.operator) { + case ASSIGNMENT: + if(Objects.equals(resultRight.getType(), resultLeft.getType())){ + System.out.println("Correct Type"); + } else { + valid = false; + errors.add(new TypeMismatchException("Type Mismatch " + resultLeft.getType() + " and " + resultRight.getType())); + } + break; + case DOT: + return new TypeCheckResult(true, resultRight.getType()); + default: + throw new RuntimeException("Unexpected operator: " + toCheck.operator); + } + return new TypeCheckResult(valid, null); } @Override public TypeCheckResult analyze(IdentifierExpressionNode toCheck) { - return null; + if(toCheck.name == "this"){ + return new TypeCheckResult(true, new This()); + } else if (currentFields.get(toCheck.name) == null) { + errors.add(new AlreadyDeclearedException("Not declared " + toCheck.name + " in this scope")); + return new TypeCheckResult(false, null); + } else { + return new TypeCheckResult(false, currentFields.get(toCheck.name)); + } } @Override @@ -194,4 +230,9 @@ public class SemanticAnalyzer implements SemanticVisitor { return null; } + @Override + public TypeCheckResult analyze(LiteralNode toCheck) { + return new TypeCheckResult(true, new BaseTypeNode(EnumTypeNode.INT)); + } + } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index 66db83e..9a8c6b1 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -2,6 +2,7 @@ package semantic; import ast.ClassNode; +import ast.LiteralNode; import ast.ProgramNode; import ast.expression.BinaryExpressionNode; import ast.expression.IdentifierExpressionNode; @@ -36,4 +37,6 @@ public interface SemanticVisitor { TypeCheckResult analyze(ReturnStatementNode toCheck); TypeCheckResult analyze(WhileStatementNode toCheck); + + TypeCheckResult analyze(LiteralNode toCheck); } \ No newline at end of file diff --git a/src/main/java/semantic/exeptions/TypeMismatchException.java b/src/main/java/semantic/exeptions/TypeMismatchException.java new file mode 100644 index 0000000..93fb62b --- /dev/null +++ b/src/main/java/semantic/exeptions/TypeMismatchException.java @@ -0,0 +1,9 @@ +package semantic.exeptions; + +public class TypeMismatchException extends RuntimeException { + + public TypeMismatchException(String message) { + super(message); + } + +} diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java new file mode 100644 index 0000000..782ac7e --- /dev/null +++ b/src/test/java/semantic/Mocker.java @@ -0,0 +1,91 @@ +package semantic; + +import ast.ClassNode; +import ast.LiteralNode; +import ast.ProgramNode; +import ast.expression.BinaryExpressionNode; +import ast.expression.ExpressionNode; +import ast.expression.ExpresssionOperator; +import ast.expression.IdentifierExpressionNode; +import ast.member.FieldNode; +import ast.member.MemberNode; +import ast.member.MethodNode; +import ast.parameter.ParameterListNode; +import ast.parameter.ParameterNode; +import ast.statement.AssignmentStatementNode; +import ast.statement.StatementNode; +import ast.statement.VariableDeclarationStatementNode; +import ast.type.AccessTypeNode; +import ast.type.BaseTypeNode; +import ast.type.EnumAccessTypeNode; +import ast.type.EnumTypeNode; + +import java.util.ArrayList; +import java.util.List; + +public class Mocker { + + public static ProgramNode mockCorrectProgrammNode(){ + + ProgramNode programNode = new ProgramNode(); + List classList = new ArrayList(); + AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); + ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); + + MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar1"); + classNode.members.add(memberNode1); + + MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "objectVar"); + classNode.members.add(memberNode2); + + List parameterNodeList = new ArrayList(); + ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1"); + parameterNodeList.add(parameterNode1); + ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList); + + List statementNodeList = new ArrayList(); + + ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("this"); + ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar"); + + ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT); + + ExpressionNode expressionNodeRight = new LiteralNode(1); + + BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT); + + StatementNode statementNode1 = new AssignmentStatementNode(expressionNode); + statementNodeList.add(statementNode1); + + StatementNode statementNode2 = new VariableDeclarationStatementNode(new BaseTypeNode(EnumTypeNode.CHAR), "objectVar", new LiteralNode(1)); + statementNodeList.add(statementNode2); + + MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList ); + classNode.members.add(memberNode3); + + classList.add(classNode); + programNode.classes = classList; + + return programNode; + + } + + public static ProgramNode mockFieldNodeAlreadyDeclaredProgrammNode(){ + ProgramNode programNode = new ProgramNode(); + List classList = new ArrayList(); + AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); + ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); + + MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); + classNode.members.add(memberNode1); + + MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); + classNode.members.add(memberNode2); + + classList.add(classNode); + programNode.classes = classList; + + return programNode; + } + +} diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index 83287ca..c5990de 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -2,17 +2,8 @@ package semantic; import ast.*; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.expression.ExpresssionOperator; -import ast.expression.IdentifierExpressionNode; import ast.member.FieldNode; import ast.member.MemberNode; -import ast.member.MethodNode; -import ast.parameter.ParameterListNode; -import ast.parameter.ParameterNode; -import ast.statement.AssignmentStatementNode; -import ast.statement.StatementNode; import ast.type.AccessTypeNode; import ast.type.BaseTypeNode; import ast.type.EnumAccessTypeNode; @@ -36,22 +27,35 @@ public class SemanticTest { @Test public void alreadyDeclaredLocalFieldVar(){ - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); + //Arrange - MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); - classNode.members.add(memberNode1); + ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode(); - MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); - classNode.members.add(memberNode2); - - classList.add(classNode); - programNode.classes = classList; + //Act ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); + //Assert + + assertEquals(1, SemanticAnalyzer.errors.size()); + assertEquals(true, SemanticAnalyzer.errors.get(0) instanceof AlreadyDeclearedException); + assertEquals(null, typedAst); + + } + + @Test + public void typeMismatch(){ + + //Arrange + + ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode(); + + //Act + + ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); + + //Assert + assertEquals(1, SemanticAnalyzer.errors.size()); assertEquals(true, SemanticAnalyzer.errors.get(0) instanceof AlreadyDeclearedException); assertEquals(null, typedAst); @@ -61,44 +65,16 @@ public class SemanticTest { @Test public void shouldWorkWithNoError(){ - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); + //Arrange - MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar1"); - classNode.members.add(memberNode1); + ProgramNode programNode = Mocker.mockCorrectProgrammNode(); - MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2"); - classNode.members.add(memberNode2); - - List parameterNodeList = new ArrayList(); - ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1"); - parameterNodeList.add(parameterNode1); - ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList); - - List statementNodeList = new ArrayList(); - - ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("this"); - ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar"); - - ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT); - - ExpressionNode expressionNodeRight = new LiteralNode(1); - - BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT); - - StatementNode statementNode1 = new AssignmentStatementNode(expressionNode); - statementNodeList.add(statementNode1); - - MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList ); - classNode.members.add(memberNode3); - - classList.add(classNode); - programNode.classes = classList; + //Act ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); + //Assert + assertEquals(0, SemanticAnalyzer.errors.size()); assertEquals(programNode, typedAst); -- 2.34.1 From 56d316a6d0dd7a4b46841ff9ed2641093f40be2d Mon Sep 17 00:00:00 2001 From: Bruder John Date: Sat, 1 Jun 2024 18:37:13 +0200 Subject: [PATCH 02/19] Changed to InstVar --- .../ast/expression/ExpresssionOperator.java | 4 +- src/main/java/ast/expression/InstVar.java | 23 +++++++++ .../statement/AssignmentStatementNode.java | 11 +++-- src/main/java/ast/type/This.java | 9 +++- src/main/java/classFileOutput/Example.class | Bin 167 -> 0 bytes src/main/java/parser/ASTBuilder.java | 5 +- src/main/java/semantic/SemanticAnalyzer.java | 44 +++++++++++++----- src/main/java/semantic/SemanticVisitor.java | 3 ++ .../exeptions/NotDeclearedException.java | 9 ++++ src/test/java/semantic/Mocker.java | 19 ++------ 10 files changed, 92 insertions(+), 35 deletions(-) create mode 100644 src/main/java/ast/expression/InstVar.java create mode 100644 src/main/java/semantic/exeptions/NotDeclearedException.java diff --git a/src/main/java/ast/expression/ExpresssionOperator.java b/src/main/java/ast/expression/ExpresssionOperator.java index b1f62a3..42bc137 100644 --- a/src/main/java/ast/expression/ExpresssionOperator.java +++ b/src/main/java/ast/expression/ExpresssionOperator.java @@ -1,13 +1,13 @@ package ast.expression; public enum ExpresssionOperator { - DOT, // . + DOT, // . NICHT MEHR GEBRAUCHT PLUS, // + MINUS, // - MULTIPLY, // * DIVIDE, // / NOT, // ! - ASSIGNMENT, // = + ASSIGNMENT, // = (NICHT MEHR GEBRAUCHT ??) EQUALS, // == UNEQUALS, // != ERROR //TODO: Remove This diff --git a/src/main/java/ast/expression/InstVar.java b/src/main/java/ast/expression/InstVar.java new file mode 100644 index 0000000..51c7629 --- /dev/null +++ b/src/main/java/ast/expression/InstVar.java @@ -0,0 +1,23 @@ +package ast.expression; + +import ast.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; + +public class InstVar implements ExpressionNode, Visitable { + public String identifier; + public ExpressionNode expression; + public TypeNode type; + + + public InstVar(ExpressionNode expression, String identifier) { + this.identifier = identifier; + this.expression = expression; + } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } +} diff --git a/src/main/java/ast/statement/AssignmentStatementNode.java b/src/main/java/ast/statement/AssignmentStatementNode.java index f9fd38e..d76cc85 100644 --- a/src/main/java/ast/statement/AssignmentStatementNode.java +++ b/src/main/java/ast/statement/AssignmentStatementNode.java @@ -1,15 +1,20 @@ package ast.statement; import ast.expression.BinaryExpressionNode; +import ast.expression.ExpressionNode; +import ast.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; public class AssignmentStatementNode extends StatementNode implements Visitable { - public BinaryExpressionNode expression; + public ExpressionNode expressionLeft; + public ExpressionNode expressionRight; + public TypeNode type; - public AssignmentStatementNode(BinaryExpressionNode expression) { - this.expression = expression; + public AssignmentStatementNode(ExpressionNode expressionLeft, ExpressionNode expressionRight) { + this.expressionLeft = expressionLeft; + this.expressionRight = expressionRight; } @Override diff --git a/src/main/java/ast/type/This.java b/src/main/java/ast/type/This.java index 459eea5..4972ac8 100644 --- a/src/main/java/ast/type/This.java +++ b/src/main/java/ast/type/This.java @@ -1,6 +1,13 @@ package ast.type; import ast.ASTNode; +import ast.expression.ExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; -public class This implements ASTNode, TypeNode{ +public class This implements ASTNode, ExpressionNode { + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return null; + } } diff --git a/src/main/java/classFileOutput/Example.class b/src/main/java/classFileOutput/Example.class index 522ae9edd25429b756d2dd98d755bdedb11f81c3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 167 zcmW-Z%?`m(5QV>?KU4{C(b_cjVj~t^h@Jh#4Q;BGxDl^qC9&`T9!g9t=FB(eoXqF@ zdIK{?Lb$q{^QE#OB8*FOGg)QoW476qcJD&ELNG7t!Yzbul5S&sf(VaL5Tla|k+WB~ uw(is%1V731R84Q$94tadyXY4BL`oeceW5zkYw}OPpFZh5)M%>%;ue1AIvEN8 diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/ASTBuilder.java index 0f3b09c..c8dec84 100644 --- a/src/main/java/parser/ASTBuilder.java +++ b/src/main/java/parser/ASTBuilder.java @@ -138,9 +138,8 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { - - BinaryExpressionNode expression = (BinaryExpressionNode) visit(ctx.expression()); - return new AssignmentStatementNode(expression); + ExpressionNode expression = (ExpressionNode) visit(ctx.expression()); + return null; } @Override diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index a7b1704..ab1051b 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -2,11 +2,7 @@ package semantic; import ast.*; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.expression.IdentifierExpressionNode; -import ast.expression.UnaryExpressionNode; -import ast.member.ConstructorNode; +import ast.expression.*; import ast.member.FieldNode; import ast.member.MemberNode; @@ -14,8 +10,6 @@ import ast.member.MethodNode; import ast.parameter.ParameterListNode; import ast.parameter.ParameterNode; import ast.statement.*; - -import java.beans.Expression; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,6 +20,7 @@ import ast.type.EnumTypeNode; import ast.type.This; import ast.type.TypeNode; import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.NotDeclearedException; import semantic.exeptions.TypeMismatchException; import typechecker.TypeCheckResult; @@ -155,9 +150,20 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(AssignmentStatementNode assignmentStatementNode) { boolean valid = true; - BinaryExpressionNode binaryExpressionNode = assignmentStatementNode.expression; - var result = binaryExpressionNode.accept(this); - valid = valid && result.isValid(); + ExpressionNode expressionNodeLeft = assignmentStatementNode.expressionLeft; + var resultLeft = expressionNodeLeft.accept(this); + valid = valid && resultLeft.isValid(); + ExpressionNode expressionNodeRight = assignmentStatementNode.expressionRight; + var resultRight = expressionNodeRight.accept(this); + valid = valid && resultRight.isValid(); + + if(Objects.equals(resultLeft.getType(), resultRight.getType())){ + System.out.println("SAME TYPE"); + } else { + errors.add(new TypeMismatchException("Type mismatch")); + valid = false; + } + return new TypeCheckResult(valid, null); } @@ -190,7 +196,7 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(IdentifierExpressionNode toCheck) { if(toCheck.name == "this"){ - return new TypeCheckResult(true, new This()); + return new TypeCheckResult(true, null); } else if (currentFields.get(toCheck.name) == null) { errors.add(new AlreadyDeclearedException("Not declared " + toCheck.name + " in this scope")); return new TypeCheckResult(false, null); @@ -235,4 +241,20 @@ public class SemanticAnalyzer implements SemanticVisitor { return new TypeCheckResult(true, new BaseTypeNode(EnumTypeNode.INT)); } + @Override + public TypeCheckResult analyze(InstVar toCheck) { + boolean valid = true; + + if(toCheck.expression instanceof This){ + if(currentFields.get(toCheck.identifier) == null){ + errors.add(new NotDeclearedException("Not declared " + toCheck.identifier + " in this scope")); + valid = false; + } else { + TypeNode typeNode = currentFields.get(toCheck.identifier); + return new TypeCheckResult(valid, typeNode); + } + } + return new TypeCheckResult(valid, null); + } + } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index 9a8c6b1..fd69518 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -6,6 +6,7 @@ import ast.LiteralNode; import ast.ProgramNode; import ast.expression.BinaryExpressionNode; import ast.expression.IdentifierExpressionNode; +import ast.expression.InstVar; import ast.expression.UnaryExpressionNode; import ast.member.FieldNode; import ast.member.MethodNode; @@ -39,4 +40,6 @@ public interface SemanticVisitor { TypeCheckResult analyze(WhileStatementNode toCheck); TypeCheckResult analyze(LiteralNode toCheck); + + TypeCheckResult analyze(InstVar toCheck); } \ No newline at end of file diff --git a/src/main/java/semantic/exeptions/NotDeclearedException.java b/src/main/java/semantic/exeptions/NotDeclearedException.java new file mode 100644 index 0000000..aa223a0 --- /dev/null +++ b/src/main/java/semantic/exeptions/NotDeclearedException.java @@ -0,0 +1,9 @@ +package semantic.exeptions; + +public class NotDeclearedException extends RuntimeException { + + public NotDeclearedException(String message) { + super(message); + } + +} diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index 782ac7e..433d0ab 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -3,10 +3,7 @@ package semantic; import ast.ClassNode; import ast.LiteralNode; import ast.ProgramNode; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.expression.ExpresssionOperator; -import ast.expression.IdentifierExpressionNode; +import ast.expression.*; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; @@ -15,10 +12,7 @@ import ast.parameter.ParameterNode; import ast.statement.AssignmentStatementNode; import ast.statement.StatementNode; import ast.statement.VariableDeclarationStatementNode; -import ast.type.AccessTypeNode; -import ast.type.BaseTypeNode; -import ast.type.EnumAccessTypeNode; -import ast.type.EnumTypeNode; +import ast.type.*; import java.util.ArrayList; import java.util.List; @@ -45,16 +39,11 @@ public class Mocker { List statementNodeList = new ArrayList(); - ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("this"); - ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar"); - - ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT); + ExpressionNode expressionNodeLeft = new InstVar(new This(), "objectVar"); ExpressionNode expressionNodeRight = new LiteralNode(1); - BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT); - - StatementNode statementNode1 = new AssignmentStatementNode(expressionNode); + StatementNode statementNode1 = new AssignmentStatementNode(expressionNodeLeft, expressionNodeRight); statementNodeList.add(statementNode1); StatementNode statementNode2 = new VariableDeclarationStatementNode(new BaseTypeNode(EnumTypeNode.CHAR), "objectVar", new LiteralNode(1)); -- 2.34.1 From e552bd5ada5eec5467c1fd663c5a61def0a7721d Mon Sep 17 00:00:00 2001 From: Bruder John Date: Wed, 12 Jun 2024 17:33:59 +0200 Subject: [PATCH 03/19] Added Basic RefTypes to InstVar and SematicCheck --- .idea/codeStyles/codeStyleConfig.xml | 5 + pom.xml | 13 +- src/main/java/ast/ClassNode.java | 2 + .../java/ast/expression/ExpressionNode.java | 17 +++ src/main/java/ast/expression/InstVar.java | 1 + .../ast/{ => expression}/LiteralNode.java | 12 +- src/main/java/ast/expression/This.java | 26 ++++ src/main/java/ast/member/FieldNode.java | 2 + src/main/java/ast/member/MemberNode.java | 12 ++ src/main/java/ast/member/MethodNode.java | 2 + .../java/ast/parameter/ParameterListNode.java | 2 + .../java/ast/parameter/ParameterNode.java | 2 + .../statement/AssignmentStatementNode.java | 4 +- .../java/ast/statement/StatementNode.java | 14 ++ .../VariableDeclarationStatementNode.java | 3 + src/main/java/ast/type/AccessTypeNode.java | 2 + src/main/java/ast/type/BaseTypeNode.java | 2 + src/main/java/ast/type/ReferenceTypeNode.java | 30 ++++ src/main/java/ast/type/This.java | 13 -- src/main/java/ast/type/TypeNode.java | 12 ++ src/main/java/parser/ASTBuilder.java | 8 +- src/main/java/semantic/SemanticAnalyzer.java | 40 ++++-- src/main/java/semantic/SemanticVisitor.java | 5 +- .../java/semantic/context/ClassContext.java | 27 ++++ src/main/java/semantic/context/Context.java | 25 ++++ .../java/semantic/context/FieldContext.java | 22 +++ src/test/java/semantic/Mocker.java | 11 +- src/test/java/semantic/SemanticTest.java | 106 ++++++++++++-- .../resources/semantic/correctRefType.json | 70 +++++++++ .../resources/semantic/refTypeMismatch.json | 133 ++++++++++++++++++ src/test/resources/semantic/test.json | 1 + 31 files changed, 566 insertions(+), 58 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml rename src/main/java/ast/{ => expression}/LiteralNode.java (68%) create mode 100644 src/main/java/ast/expression/This.java delete mode 100644 src/main/java/ast/type/This.java create mode 100644 src/main/java/semantic/context/ClassContext.java create mode 100644 src/main/java/semantic/context/Context.java create mode 100644 src/main/java/semantic/context/FieldContext.java create mode 100644 src/test/resources/semantic/correctRefType.json create mode 100644 src/test/resources/semantic/refTypeMismatch.json create mode 100644 src/test/resources/semantic/test.json diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9ee63e3..d81162c 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,22 @@ antlr4-runtime 4.13.1 - org.ow2.asm asm 9.7 - + + com.fasterxml.jackson.core + jackson-databind + 2.16.0 + + + org.assertj + assertj-core + 3.26.0 + test + diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index f1f5a4c..26310f8 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -20,6 +20,8 @@ public class ClassNode implements ASTNode, Visitable { public List members = new ArrayList<>(); public boolean hasConstructor = false; + public ClassNode() {} + public ClassNode(AccessTypeNode accessType, String identifier){ this.accessType = accessType; this.identifier = identifier; diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/ast/expression/ExpressionNode.java index e790795..42be180 100644 --- a/src/main/java/ast/expression/ExpressionNode.java +++ b/src/main/java/ast/expression/ExpressionNode.java @@ -1,8 +1,25 @@ package ast.expression; import ast.ASTNode; +import ast.statement.AssignmentStatementNode; +import ast.statement.IfStatementNode; +import ast.statement.VariableDeclarationStatementNode; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; import visitor.Visitable; +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BinaryExpressionNode.class, name = "Binary"), + @JsonSubTypes.Type(value = This.class, name = "This"), + @JsonSubTypes.Type(value = InstVar.class, name = "InstVar"), + @JsonSubTypes.Type(value = IdentifierExpressionNode.class, name = "Identifier"), + @JsonSubTypes.Type(value = LiteralNode.class, name = "Literal"), + @JsonSubTypes.Type(value = UnaryExpressionNode.class, name = "Unary")} +) + public interface ExpressionNode extends ASTNode, Visitable { } diff --git a/src/main/java/ast/expression/InstVar.java b/src/main/java/ast/expression/InstVar.java index 51c7629..6ffbba3 100644 --- a/src/main/java/ast/expression/InstVar.java +++ b/src/main/java/ast/expression/InstVar.java @@ -10,6 +10,7 @@ public class InstVar implements ExpressionNode, Visitable { public ExpressionNode expression; public TypeNode type; + public InstVar(){} public InstVar(ExpressionNode expression, String identifier) { this.identifier = identifier; diff --git a/src/main/java/ast/LiteralNode.java b/src/main/java/ast/expression/LiteralNode.java similarity index 68% rename from src/main/java/ast/LiteralNode.java rename to src/main/java/ast/expression/LiteralNode.java index 4e7c466..d97f7df 100644 --- a/src/main/java/ast/LiteralNode.java +++ b/src/main/java/ast/expression/LiteralNode.java @@ -1,23 +1,25 @@ -package ast; +package ast.expression; -import ast.expression.ExpressionNode; +import ast.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; public class LiteralNode implements ExpressionNode { int value; - private String type; + private TypeNode type; + + public LiteralNode(){} public LiteralNode(int value) { this.value = value; } - public String getType() { + public TypeNode getType() { return type; } - public void setType(String type) { + public void setType(TypeNode type) { this.type = type; } diff --git a/src/main/java/ast/expression/This.java b/src/main/java/ast/expression/This.java new file mode 100644 index 0000000..29fc827 --- /dev/null +++ b/src/main/java/ast/expression/This.java @@ -0,0 +1,26 @@ +package ast.expression; + +import ast.ASTNode; +import ast.type.ReferenceTypeNode; +import ast.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; + +public class This implements ASTNode, ExpressionNode { + private TypeNode type; + + public This(){} + + public This(String className) { + type = new ReferenceTypeNode(className); + } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + public TypeNode getType() { + return type; + } +} diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index 60c5411..7273f6b 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -12,6 +12,8 @@ public class FieldNode implements MemberNode, Visitable { public TypeNode type; public String identifier; + public FieldNode(){} + public FieldNode(AccessTypeNode accessTypeNode, TypeNode type, String name){ this.accessTypeNode = accessTypeNode; this.type = type; diff --git a/src/main/java/ast/member/MemberNode.java b/src/main/java/ast/member/MemberNode.java index f186835..ace0d6d 100644 --- a/src/main/java/ast/member/MemberNode.java +++ b/src/main/java/ast/member/MemberNode.java @@ -1,6 +1,18 @@ package ast.member; import ast.ASTNode; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) +@JsonSubTypes({ + @JsonSubTypes.Type(value = MethodNode.class, name = "Method"), + + @JsonSubTypes.Type(value = FieldNode.class, name = "Field") } +) public interface MemberNode extends ASTNode { + } diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index bd67bc4..f3cba60 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -22,6 +22,8 @@ public class MethodNode implements MemberNode, Visitable { public List statements = new ArrayList<>(); + public MethodNode(){} + public MethodNode(AccessTypeNode visibility, TypeNode type, String identifier, ParameterListNode parameters, List statements){ this.visibility = visibility; diff --git a/src/main/java/ast/parameter/ParameterListNode.java b/src/main/java/ast/parameter/ParameterListNode.java index ff1c58d..76a39fb 100644 --- a/src/main/java/ast/parameter/ParameterListNode.java +++ b/src/main/java/ast/parameter/ParameterListNode.java @@ -8,6 +8,8 @@ import java.util.List; public class ParameterListNode implements ASTNode { public List parameters = new ArrayList<>(); + public ParameterListNode() {} + public ParameterListNode(List parameters){ this.parameters = parameters; } diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java index f3f5193..176e987 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -7,6 +7,8 @@ public class ParameterNode implements ASTNode { public TypeNode type; public String identifier; + public ParameterNode(){} + public ParameterNode(TypeNode type, String identifier) { this.type = type; this.identifier = identifier; diff --git a/src/main/java/ast/statement/AssignmentStatementNode.java b/src/main/java/ast/statement/AssignmentStatementNode.java index d76cc85..abd00a5 100644 --- a/src/main/java/ast/statement/AssignmentStatementNode.java +++ b/src/main/java/ast/statement/AssignmentStatementNode.java @@ -10,7 +10,9 @@ import visitor.Visitable; public class AssignmentStatementNode extends StatementNode implements Visitable { public ExpressionNode expressionLeft; public ExpressionNode expressionRight; - public TypeNode type; +// public TypeNode type; + + public AssignmentStatementNode(){} public AssignmentStatementNode(ExpressionNode expressionLeft, ExpressionNode expressionRight) { this.expressionLeft = expressionLeft; diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/ast/statement/StatementNode.java index eff1804..5a96ee5 100644 --- a/src/main/java/ast/statement/StatementNode.java +++ b/src/main/java/ast/statement/StatementNode.java @@ -1,8 +1,22 @@ package ast.statement; import ast.ASTNode; +import ast.type.BaseTypeNode; +import ast.type.ReferenceTypeNode; import visitor.Visitable; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) +@JsonSubTypes({ + @JsonSubTypes.Type(value = IfStatementNode.class, name = "IF"), + @JsonSubTypes.Type(value = AssignmentStatementNode.class, name = "Assignment"), + @JsonSubTypes.Type(value = VariableDeclarationStatementNode.class, name = "VariableDeclaration") } +) + public abstract class StatementNode implements ASTNode, Visitable { } diff --git a/src/main/java/ast/statement/VariableDeclarationStatementNode.java b/src/main/java/ast/statement/VariableDeclarationStatementNode.java index 4302177..9feb086 100644 --- a/src/main/java/ast/statement/VariableDeclarationStatementNode.java +++ b/src/main/java/ast/statement/VariableDeclarationStatementNode.java @@ -9,6 +9,9 @@ public class VariableDeclarationStatementNode extends StatementNode { public TypeNode type; public String identifier; public ExpressionNode expression; + + public VariableDeclarationStatementNode(){} + public VariableDeclarationStatementNode(TypeNode type, String identifier, ExpressionNode expression) { this.type = type; this.identifier = identifier; diff --git a/src/main/java/ast/type/AccessTypeNode.java b/src/main/java/ast/type/AccessTypeNode.java index ba156c1..4e0db89 100644 --- a/src/main/java/ast/type/AccessTypeNode.java +++ b/src/main/java/ast/type/AccessTypeNode.java @@ -5,6 +5,8 @@ import ast.ASTNode; public class AccessTypeNode implements ASTNode { public EnumAccessTypeNode enumAccessTypeNode; + public AccessTypeNode(){} + public AccessTypeNode(EnumAccessTypeNode enumAccessTypeNode) { this.enumAccessTypeNode = enumAccessTypeNode; } diff --git a/src/main/java/ast/type/BaseTypeNode.java b/src/main/java/ast/type/BaseTypeNode.java index eb9537c..8a9a4a6 100644 --- a/src/main/java/ast/type/BaseTypeNode.java +++ b/src/main/java/ast/type/BaseTypeNode.java @@ -6,6 +6,8 @@ public class BaseTypeNode implements ASTNode, TypeNode { public EnumTypeNode enumType; + public BaseTypeNode(){} + public BaseTypeNode(EnumTypeNode enumType) { this.enumType = enumType; } diff --git a/src/main/java/ast/type/ReferenceTypeNode.java b/src/main/java/ast/type/ReferenceTypeNode.java index 88225f3..91da6bc 100644 --- a/src/main/java/ast/type/ReferenceTypeNode.java +++ b/src/main/java/ast/type/ReferenceTypeNode.java @@ -3,4 +3,34 @@ package ast.type; import ast.ASTNode; public class ReferenceTypeNode implements ASTNode, TypeNode { + + private String identifier; + + public ReferenceTypeNode() {} + + public ReferenceTypeNode(String identifier) { + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ReferenceTypeNode other = (ReferenceTypeNode) obj; + if (identifier == null) { + if (other.identifier != null) + return false; + } else if (!identifier.equals(other.identifier)) + return false; + return true; + } + } diff --git a/src/main/java/ast/type/This.java b/src/main/java/ast/type/This.java deleted file mode 100644 index 4972ac8..0000000 --- a/src/main/java/ast/type/This.java +++ /dev/null @@ -1,13 +0,0 @@ -package ast.type; - -import ast.ASTNode; -import ast.expression.ExpressionNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class This implements ASTNode, ExpressionNode { - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return null; - } -} diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/TypeNode.java index 79be9c9..a855f09 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/ast/type/TypeNode.java @@ -2,5 +2,17 @@ package ast.type; import ast.ASTNode; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BaseTypeNode.class, name = "Base"), + + @JsonSubTypes.Type(value = ReferenceTypeNode.class, name = "Reference") } +) + public interface TypeNode extends ASTNode { } \ No newline at end of file diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/ASTBuilder.java index c8dec84..9110f2c 100644 --- a/src/main/java/parser/ASTBuilder.java +++ b/src/main/java/parser/ASTBuilder.java @@ -1,11 +1,7 @@ package parser; import ast.*; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.expression.ExpresssionOperator; -import ast.expression.IdentifierExpressionNode; -import ast.expression.UnaryExpressionNode; +import ast.expression.*; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; @@ -210,7 +206,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { int intValue = Integer.parseInt(literalContext.getText()); LiteralNode literalNode = new LiteralNode(intValue); - literalNode.setType("int"); + literalNode.setType(new BaseTypeNode(EnumTypeNode.INT)); return literalNode; } catch (NumberFormatException ignored) {} diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index ab1051b..2d95119 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -10,6 +10,9 @@ import ast.member.MethodNode; import ast.parameter.ParameterListNode; import ast.parameter.ParameterNode; import ast.statement.*; +import ast.type.ReferenceTypeNode; +import ast.expression.This; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -17,8 +20,8 @@ import java.util.Objects; import ast.type.BaseTypeNode; import ast.type.EnumTypeNode; -import ast.type.This; import ast.type.TypeNode; +import semantic.context.Context; import semantic.exeptions.AlreadyDeclearedException; import semantic.exeptions.NotDeclearedException; import semantic.exeptions.TypeMismatchException; @@ -30,6 +33,7 @@ public class SemanticAnalyzer implements SemanticVisitor { public static ArrayList errors = new ArrayList<>(); + private Context context; private static Scope currentScope; private static ClassNode currentClass; @@ -60,6 +64,7 @@ public class SemanticAnalyzer implements SemanticVisitor { var valid = true; currentScope = new Scope(); + context = new Context(node); List classes = node.classes; for (ClassNode classNode : classes) { @@ -74,7 +79,7 @@ public class SemanticAnalyzer implements SemanticVisitor { var valid = true; currentClass = classNode; - + currentFields.clear(); List members = classNode.members; for (MemberNode memberNode : members) { if (memberNode instanceof FieldNode fieldNode) { @@ -238,23 +243,38 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(LiteralNode toCheck) { - return new TypeCheckResult(true, new BaseTypeNode(EnumTypeNode.INT)); + return new TypeCheckResult(true, toCheck.getType()); } @Override public TypeCheckResult analyze(InstVar toCheck) { boolean valid = true; - if(toCheck.expression instanceof This){ - if(currentFields.get(toCheck.identifier) == null){ - errors.add(new NotDeclearedException("Not declared " + toCheck.identifier + " in this scope")); - valid = false; + var result = toCheck.expression.accept(this); + + if(result.getType() instanceof BaseTypeNode){ + throw new RuntimeException("BaseType has no Methods or Fields"); + } else { + //Get typ of Field + + var type = (ReferenceTypeNode)result.getType(); + var classContext = context.getClass(type.getIdentifier()); + + if(classContext == null){ + errors.add(new NotDeclearedException("Not declared " + type.getIdentifier() + " in this scope")); + return new TypeCheckResult(false, null); } else { - TypeNode typeNode = currentFields.get(toCheck.identifier); - return new TypeCheckResult(valid, typeNode); + var field = classContext.getField(toCheck.identifier); + + return new TypeCheckResult(valid, field.getType()); } } - return new TypeCheckResult(valid, null); + + } + + @Override + public TypeCheckResult analyze(This toCheck) { + return new TypeCheckResult(true, toCheck.getType()); } } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index fd69518..b66ea75 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -2,7 +2,7 @@ package semantic; import ast.ClassNode; -import ast.LiteralNode; +import ast.expression.LiteralNode; import ast.ProgramNode; import ast.expression.BinaryExpressionNode; import ast.expression.IdentifierExpressionNode; @@ -11,6 +11,7 @@ import ast.expression.UnaryExpressionNode; import ast.member.FieldNode; import ast.member.MethodNode; import ast.statement.*; +import ast.expression.This; import typechecker.TypeCheckResult; public interface SemanticVisitor { @@ -42,4 +43,6 @@ public interface SemanticVisitor { TypeCheckResult analyze(LiteralNode toCheck); TypeCheckResult analyze(InstVar toCheck); + + TypeCheckResult analyze(This toCheck); } \ No newline at end of file diff --git a/src/main/java/semantic/context/ClassContext.java b/src/main/java/semantic/context/ClassContext.java new file mode 100644 index 0000000..982866f --- /dev/null +++ b/src/main/java/semantic/context/ClassContext.java @@ -0,0 +1,27 @@ +package semantic.context; + +import ast.ClassNode; +import ast.member.FieldNode; +import java.util.HashMap; + +public class ClassContext { + + private HashMap fields; + + public ClassContext(ClassNode classNode) { + + fields = new HashMap<>(); + + classNode.members.forEach(member -> { + if(member instanceof FieldNode fieldNode) { + fields.put(fieldNode.identifier, new FieldContext(fieldNode)); + } + }); + + } + + public FieldContext getField(String name) { + return fields.get(name); + } + +} diff --git a/src/main/java/semantic/context/Context.java b/src/main/java/semantic/context/Context.java new file mode 100644 index 0000000..7006e65 --- /dev/null +++ b/src/main/java/semantic/context/Context.java @@ -0,0 +1,25 @@ +package semantic.context; + +import ast.ClassNode; +import ast.ProgramNode; +import java.util.HashMap; + +public class Context { + + private HashMap classes; + + public Context(ProgramNode programNode) { + classes = new HashMap<>(); + + programNode.classes.forEach(classNode -> { + ClassContext classContext = new ClassContext(classNode); + classes.put(classNode.identifier, classContext); + }); + + } + + public ClassContext getClass(String identifier) { + return classes.get(identifier); + } + +} diff --git a/src/main/java/semantic/context/FieldContext.java b/src/main/java/semantic/context/FieldContext.java new file mode 100644 index 0000000..447aa4e --- /dev/null +++ b/src/main/java/semantic/context/FieldContext.java @@ -0,0 +1,22 @@ +package semantic.context; + +import ast.member.FieldNode; +import ast.type.AccessTypeNode; +import ast.type.EnumAccessTypeNode; +import ast.type.TypeNode; + +public class FieldContext { + + private AccessTypeNode accessModifier; + private TypeNode type; + + public FieldContext(FieldNode field) { + accessModifier = field.accessTypeNode; + type = field.type; + } + + public TypeNode getType() { + return type; + } + +} diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index 433d0ab..4c303d8 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -1,7 +1,7 @@ package semantic; import ast.ClassNode; -import ast.LiteralNode; +import ast.expression.LiteralNode; import ast.ProgramNode; import ast.expression.*; import ast.member.FieldNode; @@ -39,16 +39,14 @@ public class Mocker { List statementNodeList = new ArrayList(); - ExpressionNode expressionNodeLeft = new InstVar(new This(), "objectVar"); + ExpressionNode expressionNodeLeft = new InstVar(new This("testClass"), "objectVar"); - ExpressionNode expressionNodeRight = new LiteralNode(1); + LiteralNode expressionNodeRight = new LiteralNode(); + expressionNodeRight.setType(new BaseTypeNode(EnumTypeNode.INT)); StatementNode statementNode1 = new AssignmentStatementNode(expressionNodeLeft, expressionNodeRight); statementNodeList.add(statementNode1); - StatementNode statementNode2 = new VariableDeclarationStatementNode(new BaseTypeNode(EnumTypeNode.CHAR), "objectVar", new LiteralNode(1)); - statementNodeList.add(statementNode2); - MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList ); classNode.members.add(memberNode3); @@ -76,5 +74,4 @@ public class Mocker { return programNode; } - } diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index c5990de..71604ee 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -2,20 +2,19 @@ package semantic; import ast.*; -import ast.member.FieldNode; -import ast.member.MemberNode; -import ast.type.AccessTypeNode; -import ast.type.BaseTypeNode; -import ast.type.EnumAccessTypeNode; -import ast.type.EnumTypeNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.assertj.core.api.MatcherAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.TypeMismatchException; -import java.util.ArrayList; -import java.util.List; +import java.io.File; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SemanticTest { @@ -25,7 +24,7 @@ public class SemanticTest { } @Test - public void alreadyDeclaredLocalFieldVar(){ + public void alreadyDeclaredLocalFieldVar() { //Arrange @@ -44,7 +43,7 @@ public class SemanticTest { } @Test - public void typeMismatch(){ + public void alreadyDecleared() { //Arrange @@ -57,13 +56,13 @@ public class SemanticTest { //Assert assertEquals(1, SemanticAnalyzer.errors.size()); - assertEquals(true, SemanticAnalyzer.errors.get(0) instanceof AlreadyDeclearedException); - assertEquals(null, typedAst); + assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + assertNull(typedAst); } @Test - public void shouldWorkWithNoError(){ + public void shouldWorkWithNoError() { //Arrange @@ -80,4 +79,85 @@ public class SemanticTest { } + @Test + public void refTypeCorrect() { + + //Arrange + + ObjectMapper objectMapper = new ObjectMapper(); + ProgramNode programNode = null; + try{ + programNode = objectMapper.readValue(new File("src/test/resources/semantic/correctRefType.json"), ProgramNode.class); + } catch (Exception e) { + e.printStackTrace(); + } + + //Act + + ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); + + //Assert + + assertEquals(0, SemanticAnalyzer.errors.size()); + assertEquals(programNode, typedAst); + + } + + @Test + public void jsonWriteTest() { + + ObjectMapper objectMapper = new ObjectMapper(); + + //Arrange + + ProgramNode programNode = Mocker.mockCorrectProgrammNode(); + try{ + objectMapper.writeValue(new File("src/test/resources/semantic/test.json"), programNode); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Test + public void jsonReadTest() { + + ObjectMapper objectMapper = new ObjectMapper(); + + ProgramNode programNode1 = null; + try{ + programNode1 = objectMapper.readValue(new File("src/test/resources/semantic/test.json"), ProgramNode.class); + } catch (Exception e) { + e.printStackTrace(); + } + + ProgramNode programNode2 = Mocker.mockCorrectProgrammNode(); + + } + + @Test + public void typeMismatch() { + + //Arrange + + ObjectMapper objectMapper = new ObjectMapper(); + ProgramNode programNode = null; + try{ + programNode = objectMapper.readValue(new File("src/test/resources/semantic/refTypeMismatch.json"), ProgramNode.class); + } catch (Exception e) { + e.printStackTrace(); + } + + //Act + + ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); + + //Assert + + assertEquals(1, SemanticAnalyzer.errors.size()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + assertNull(typedAst); + + } + } diff --git a/src/test/resources/semantic/correctRefType.json b/src/test/resources/semantic/correctRefType.json new file mode 100644 index 0000000..7e67bbc --- /dev/null +++ b/src/test/resources/semantic/correctRefType.json @@ -0,0 +1,70 @@ +{ + "classes": [ + { + "identifier": "testClass1", + "accessType": { + "enumAccessTypeNode": "PUBLIC" + }, + "members": [ + { + "@type": "Field", + "accessTypeNode": { + "enumAccessTypeNode": "PUBLIC" + }, + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "testVar1" + }, + { + "@type": "Method", + "visibility": { + "enumAccessTypeNode": "PUBLIC" + }, + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "testMethod", + "parameters": { + "parameters": [ + { + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "param1" + } + ] + }, + "statements": [ + { + "@type": "Assignment", + "expressionLeft": { + "@type": "InstVar", + "identifier": "testVar1", + "expression": { + "@type": "This", + "type": { + "@type": "Reference", + "identifier": "testClass1" + } + }, + "type": null + }, + "expressionRight": { + "@type": "Literal", + "type": { + "@type": "Base", + "enumType": "INT" + } + } + } + ] + } + ], + "hasConstructor": false + } + ] +} \ No newline at end of file diff --git a/src/test/resources/semantic/refTypeMismatch.json b/src/test/resources/semantic/refTypeMismatch.json new file mode 100644 index 0000000..e5ebcd3 --- /dev/null +++ b/src/test/resources/semantic/refTypeMismatch.json @@ -0,0 +1,133 @@ +{ + "classes": [ + { + "identifier": "testClass1", + "accessType": { + "enumAccessTypeNode": "PUBLIC" + }, + "members": [ + { + "@type": "Field", + "accessTypeNode": { + "enumAccessTypeNode": "PUBLIC" + }, + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "testVar1" + }, + { + "@type": "Method", + "visibility": { + "enumAccessTypeNode": "PUBLIC" + }, + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "testMethod", + "parameters": { + "parameters": [ + { + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "param1" + } + ] + }, + "statements": [ + { + "@type": "Assignment", + "expressionLeft": { + "@type": "InstVar", + "identifier": "testVar1", + "expression": { + "@type": "This", + "type": { + "@type": "Reference", + "identifier": "testClass1" + } + }, + "type": null + }, + "expressionRight": { + "@type": "Literal", + "type": { + "@type": "Base", + "enumType": "BOOLEAN" + } + } + } + ] + } + ], + "hasConstructor": false, + "methods": [ + { + "@type": "Method", + "visibility": { + "enumAccessTypeNode": "PUBLIC" + }, + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "testMethod", + "parameters": { + "parameters": [ + { + "type": { + "@type": "Base", + "enumType": "INT" + }, + "identifier": "param1" + } + ] + }, + "statements": [ + { + "@type": "Assignment", + "expressionLeft": { + "@type": "InstVar", + "identifier": "testVar", + "expression": { + "@type": "InstVar", + "identifier": "testVar", + "expression": { + "@type": "This", + "type": { + "@type": "Reference", + "identifier": "testClass2" + } + }, + "type": null + }, + "type": null + }, + "expressionRight": { + "@type": "Literal", + "type": null + }, + "type": null + }, + { + "@type": "VariableDeclaration", + "type": { + "@type": "Base", + "enumType": "CHAR" + }, + "identifier": "objectVar", + "expression": { + "@type": "Literal", + "type": null + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/test/resources/semantic/test.json b/src/test/resources/semantic/test.json new file mode 100644 index 0000000..7acc30f --- /dev/null +++ b/src/test/resources/semantic/test.json @@ -0,0 +1 @@ +{"classes":[{"identifier":"testClass","accessType":{"enumAccessTypeNode":"PUBLIC"},"members":[{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar1"},{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"objectVar"},{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}],"hasConstructor":false,"methods":[{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}]}]} \ No newline at end of file -- 2.34.1 From 8094a93582381aac2bc3577c91208e6fd84daf05 Mon Sep 17 00:00:00 2001 From: i22035 Date: Sat, 15 Jun 2024 13:15:55 +0200 Subject: [PATCH 04/19] Added new Grammar --- .idea/misc.xml | 10 + src/main/java/Main.java | 9 +- src/main/java/ast/ClassNode.java | 18 +- src/main/java/ast/IdentifierNode.java | 4 + src/main/java/ast/ProgramNode.java | 12 +- .../java/ast/type/AccessModifierNode.java | 14 + .../java/ast/type/EnumAccessModifierNode.java | 5 + src/main/java/bytecode/ByteCodeGenerator.java | 4 +- src/main/java/bytecode/ClassCodeGen.java | 10 +- src/main/java/bytecode/Mapper.java | 8 +- src/main/java/bytecode/MethodCodeGen.java | 10 +- .../java/bytecode/visitor/ClassVisitor.java | 1 - .../java/bytecode/visitor/MethodVisitor.java | 4 +- src/main/java/classFileOutput/Test.class | Bin 97 -> 148 bytes src/main/java/oldAst/ASTNode.java | 12 + src/main/java/{ast => oldAst}/BlockNode.java | 2 +- src/main/java/oldAst/ClassNode.java | 63 + src/main/java/oldAst/ProgramNode.java | 27 + .../expression/BinaryExpressionNode.java | 2 +- .../expression/ExpressionNode.java | 7 +- .../expression/ExpresssionOperator.java | 2 +- .../expression/IdentifierExpressionNode.java | 4 +- .../{ast => oldAst}/expression/InstVar.java | 4 +- .../expression/LiteralNode.java | 4 +- .../java/{ast => oldAst}/expression/This.java | 8 +- .../expression/UnaryExpressionNode.java | 2 +- .../member/ConstructorNode.java | 4 +- .../{ast => oldAst}/member/FieldNode.java | 6 +- .../{ast => oldAst}/member/MemberNode.java | 4 +- .../{ast => oldAst}/member/MethodNode.java | 10 +- .../parameter/ParameterListNode.java | 4 +- .../parameter/ParameterNode.java | 6 +- .../statement/AssignmentStatementNode.java | 6 +- .../statement/IfStatementNode.java | 4 +- .../statement/ReturnStatementNode.java | 4 +- .../statement/StatementNode.java | 6 +- .../VariableDeclarationStatementNode.java | 6 +- .../statement/WhileStatementNode.java | 4 +- .../{ast => oldAst}/type/AccessTypeNode.java | 4 +- .../{ast => oldAst}/type/BaseTypeNode.java | 4 +- .../type/EnumAccessTypeNode.java | 2 +- .../{ast => oldAst}/type/EnumTypeNode.java | 2 +- .../type/ReferenceTypeNode.java | 4 +- .../java/{ast => oldAst}/type/TypeNode.java | 4 +- src/main/java/parser/SimpleJava.g4 | 62 - .../parser/{ => astBuilder}/ASTBuilder.java | 22 +- .../java/parser/generated/SimpleJava.interp | 196 +- .../java/parser/generated/SimpleJava.tokens | 157 +- .../generated/SimpleJavaBaseListener.java | 434 +- .../generated/SimpleJavaBaseVisitor.java | 252 +- .../parser/generated/SimpleJavaLexer.interp | 235 +- .../parser/generated/SimpleJavaLexer.java | 399 +- .../parser/generated/SimpleJavaLexer.tokens | 157 +- .../parser/generated/SimpleJavaListener.java | 390 +- .../parser/generated/SimpleJavaParser.java | 3726 ++++++++++++----- .../parser/generated/SimpleJavaVisitor.java | 230 +- src/main/java/parser/grammar/SimpleJava.g4 | 168 + src/main/java/semantic/Scope.java | 2 +- src/main/java/semantic/SemanticAnalyzer.java | 25 +- .../java/semantic/context/ClassContext.java | 4 +- src/main/java/semantic/context/Context.java | 3 +- .../java/semantic/context/FieldContext.java | 7 +- .../java/typechecker/TypeCheckResult.java | 2 +- src/main/test/java/MainTest.java | 4 +- src/test/java/semantic/Mocker.java | 25 +- src/test/java/semantic/SemanticTest.java | 3 +- 66 files changed, 4857 insertions(+), 1976 deletions(-) create mode 100644 src/main/java/ast/IdentifierNode.java create mode 100644 src/main/java/ast/type/AccessModifierNode.java create mode 100644 src/main/java/ast/type/EnumAccessModifierNode.java create mode 100644 src/main/java/oldAst/ASTNode.java rename src/main/java/{ast => oldAst}/BlockNode.java (63%) create mode 100644 src/main/java/oldAst/ClassNode.java create mode 100644 src/main/java/oldAst/ProgramNode.java rename src/main/java/{ast => oldAst}/expression/BinaryExpressionNode.java (95%) rename src/main/java/{ast => oldAst}/expression/ExpressionNode.java (82%) rename src/main/java/{ast => oldAst}/expression/ExpresssionOperator.java (90%) rename src/main/java/{ast => oldAst}/expression/IdentifierExpressionNode.java (88%) rename src/main/java/{ast => oldAst}/expression/InstVar.java (90%) rename src/main/java/{ast => oldAst}/expression/LiteralNode.java (89%) rename src/main/java/{ast => oldAst}/expression/This.java (79%) rename src/main/java/{ast => oldAst}/expression/UnaryExpressionNode.java (95%) rename src/main/java/{ast => oldAst}/member/ConstructorNode.java (86%) rename src/main/java/{ast => oldAst}/member/FieldNode.java (89%) rename src/main/java/{ast => oldAst}/member/MemberNode.java (91%) rename src/main/java/{ast => oldAst}/member/MethodNode.java (91%) rename src/main/java/{ast => oldAst}/parameter/ParameterListNode.java (86%) rename src/main/java/{ast => oldAst}/parameter/ParameterNode.java (77%) rename src/main/java/{ast => oldAst}/statement/AssignmentStatementNode.java (82%) rename src/main/java/{ast => oldAst}/statement/IfStatementNode.java (89%) rename src/main/java/{ast => oldAst}/statement/ReturnStatementNode.java (85%) rename src/main/java/{ast => oldAst}/statement/StatementNode.java (86%) rename src/main/java/{ast => oldAst}/statement/VariableDeclarationStatementNode.java (86%) rename src/main/java/{ast => oldAst}/statement/WhileStatementNode.java (87%) rename src/main/java/{ast => oldAst}/type/AccessTypeNode.java (85%) rename src/main/java/{ast => oldAst}/type/BaseTypeNode.java (92%) rename src/main/java/{ast => oldAst}/type/EnumAccessTypeNode.java (72%) rename src/main/java/{ast => oldAst}/type/EnumTypeNode.java (71%) rename src/main/java/{ast => oldAst}/type/ReferenceTypeNode.java (94%) rename src/main/java/{ast => oldAst}/type/TypeNode.java (91%) delete mode 100644 src/main/java/parser/SimpleJava.g4 rename src/main/java/parser/{ => astBuilder}/ASTBuilder.java (96%) create mode 100644 src/main/java/parser/grammar/SimpleJava.g4 diff --git a/.idea/misc.xml b/.idea/misc.xml index bb14756..fe442df 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -13,6 +13,16 @@ diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 94d29cf..779e5d1 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,21 +1,18 @@ -import ast.ASTNode; +import oldAst.ASTNode; import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.Token; -import ast.ProgramNode; +import oldAst.ProgramNode; import bytecode.ByteCodeGenerator; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.CommonTokenStream; -import parser.ASTBuilder; +import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; import semantic.SemanticAnalyzer; -import bytecode.ByteCodeGenerator; import java.io.IOException; import java.nio.file.Paths; -import java.util.List; public class Main { public static void main(String[] args) throws Exception { diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index 26310f8..9690600 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -1,19 +1,19 @@ package ast; -import ast.member.ConstructorNode; -import ast.member.MemberNode; -import ast.member.MethodNode; -import ast.type.AccessTypeNode; -import ast.type.EnumAccessTypeNode; - -import java.util.ArrayList; -import java.util.List; - import bytecode.visitor.ClassVisitor; +import oldAst.ASTNode; +import oldAst.member.ConstructorNode; +import oldAst.member.MemberNode; +import oldAst.member.MethodNode; +import oldAst.type.AccessTypeNode; +import oldAst.type.EnumAccessTypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; +import java.util.ArrayList; +import java.util.List; + public class ClassNode implements ASTNode, Visitable { public String identifier; public AccessTypeNode accessType; diff --git a/src/main/java/ast/IdentifierNode.java b/src/main/java/ast/IdentifierNode.java new file mode 100644 index 0000000..cd09699 --- /dev/null +++ b/src/main/java/ast/IdentifierNode.java @@ -0,0 +1,4 @@ +package ast; + +public class IdentifierNode { +} diff --git a/src/main/java/ast/ProgramNode.java b/src/main/java/ast/ProgramNode.java index 1aac1b1..afed589 100644 --- a/src/main/java/ast/ProgramNode.java +++ b/src/main/java/ast/ProgramNode.java @@ -1,14 +1,16 @@ package ast; -import java.util.ArrayList; -import java.util.List; - +import ast.ASTNode; +import ast.ClassNode; import bytecode.visitor.ProgramVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; -public class ProgramNode implements ASTNode, Visitable{ +import java.util.ArrayList; +import java.util.List; + +public class ProgramNode implements ASTNode, Visitable { public List classes = new ArrayList<>(); public void addClass(ClassNode classNode) { @@ -24,4 +26,4 @@ public class ProgramNode implements ASTNode, Visitable{ public void accept(ProgramVisitor programVisitor) { programVisitor.visit(this); } -} \ No newline at end of file +} diff --git a/src/main/java/ast/type/AccessModifierNode.java b/src/main/java/ast/type/AccessModifierNode.java new file mode 100644 index 0000000..5bf3292 --- /dev/null +++ b/src/main/java/ast/type/AccessModifierNode.java @@ -0,0 +1,14 @@ +package ast.type; + +import oldAst.ASTNode; +import oldAst.type.EnumAccessTypeNode; + +public class AccessModifierNode implements ASTNode { + public EnumAccessModifierNode enumAccessModifierNode; + + public AccessModifierNode(){} + + public AccessModifierNode(EnumAccessModifierNode enumAccessTypeNode) { + this.enumAccessModifierNode = enumAccessTypeNode; + } +} diff --git a/src/main/java/ast/type/EnumAccessModifierNode.java b/src/main/java/ast/type/EnumAccessModifierNode.java new file mode 100644 index 0000000..a59e904 --- /dev/null +++ b/src/main/java/ast/type/EnumAccessModifierNode.java @@ -0,0 +1,5 @@ +package ast.type; + +public enum EnumAccessModifierNode { + PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC +} diff --git a/src/main/java/bytecode/ByteCodeGenerator.java b/src/main/java/bytecode/ByteCodeGenerator.java index 5494255..eeda3ae 100644 --- a/src/main/java/bytecode/ByteCodeGenerator.java +++ b/src/main/java/bytecode/ByteCodeGenerator.java @@ -1,7 +1,7 @@ package bytecode; -import ast.ProgramNode; -import ast.ClassNode; +import oldAst.ProgramNode; +import oldAst.ClassNode; import bytecode.visitor.ProgramVisitor; public class ByteCodeGenerator implements ProgramVisitor { diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index b0afa69..266f03c 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -1,10 +1,10 @@ package bytecode; -import ast.ClassNode; -import ast.member.FieldNode; -import ast.member.MemberNode; -import ast.member.MethodNode; -import ast.type.BaseTypeNode; +import oldAst.ClassNode; +import oldAst.member.FieldNode; +import oldAst.member.MemberNode; +import oldAst.member.MethodNode; +import oldAst.type.BaseTypeNode; import bytecode.visitor.ClassVisitor; import java.io.File; import org.objectweb.asm.ClassWriter; diff --git a/src/main/java/bytecode/Mapper.java b/src/main/java/bytecode/Mapper.java index 4f25846..91f4a2d 100644 --- a/src/main/java/bytecode/Mapper.java +++ b/src/main/java/bytecode/Mapper.java @@ -1,10 +1,10 @@ package bytecode; -import ast.parameter.ParameterListNode; -import ast.parameter.ParameterNode; -import ast.type.*; +import oldAst.parameter.ParameterListNode; +import oldAst.parameter.ParameterNode; +import oldAst.type.*; import org.objectweb.asm.Opcodes; -import ast.type.BaseTypeNode; +import oldAst.type.BaseTypeNode; public class Mapper { public int mapAccessTypeToOpcode(AccessTypeNode type) { diff --git a/src/main/java/bytecode/MethodCodeGen.java b/src/main/java/bytecode/MethodCodeGen.java index a4249f1..4fed389 100644 --- a/src/main/java/bytecode/MethodCodeGen.java +++ b/src/main/java/bytecode/MethodCodeGen.java @@ -1,11 +1,9 @@ package bytecode; -import ast.member.ConstructorNode; -import ast.member.MethodNode; -import ast.parameter.ParameterListNode; -import ast.parameter.ParameterNode; -import ast.type.BaseTypeNode; -import ast.type.EnumTypeNode; +import oldAst.member.ConstructorNode; +import oldAst.member.MethodNode; +import oldAst.parameter.ParameterNode; +import oldAst.type.BaseTypeNode; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; diff --git a/src/main/java/bytecode/visitor/ClassVisitor.java b/src/main/java/bytecode/visitor/ClassVisitor.java index 98ef25c..903775a 100644 --- a/src/main/java/bytecode/visitor/ClassVisitor.java +++ b/src/main/java/bytecode/visitor/ClassVisitor.java @@ -2,7 +2,6 @@ package bytecode.visitor; import ast.ClassNode; import ast.member.FieldNode; -import org.objectweb.asm.ClassWriter; public interface ClassVisitor { void visit(ClassNode classNode); diff --git a/src/main/java/bytecode/visitor/MethodVisitor.java b/src/main/java/bytecode/visitor/MethodVisitor.java index 70177ce..bda46ab 100644 --- a/src/main/java/bytecode/visitor/MethodVisitor.java +++ b/src/main/java/bytecode/visitor/MethodVisitor.java @@ -1,7 +1,7 @@ package bytecode.visitor; -import ast.member.ConstructorNode; -import ast.member.MethodNode; +import oldAst.member.ConstructorNode; +import oldAst.member.MethodNode; public interface MethodVisitor { void visit(ConstructorNode constructorNode); diff --git a/src/main/java/classFileOutput/Test.class b/src/main/java/classFileOutput/Test.class index 8ba4c23343d79136e322bf6f22591360f6985b92..98f27991c1557e7e05c706e183ff37e4f9036fe4 100644 GIT binary patch delta 109 zcmYeC!pL>%->!WO3=D=0JQKO}qj?xu8Q8cOSQywD8MsPPi%Wb{OEU6P7#UbKJUul% w85vld^HWk87#Wy=YCwPq$OdWwlH5R^AdqGR(yUtB88|kA!WO3=Ad=oD;e9H5eIKN>YnU7=a>;3``6xV49JEoq+?&Vr5_hvKRna CG6!1# diff --git a/src/main/java/oldAst/ASTNode.java b/src/main/java/oldAst/ASTNode.java new file mode 100644 index 0000000..1d8dcf5 --- /dev/null +++ b/src/main/java/oldAst/ASTNode.java @@ -0,0 +1,12 @@ +package oldAst; + +//import java.util.List; + +public interface ASTNode { + /** + * Please implement this method to return a list of children of each node. + */ + // public List getChildren(); +} + + diff --git a/src/main/java/ast/BlockNode.java b/src/main/java/oldAst/BlockNode.java similarity index 63% rename from src/main/java/ast/BlockNode.java rename to src/main/java/oldAst/BlockNode.java index 2dd5307..5c8a932 100644 --- a/src/main/java/ast/BlockNode.java +++ b/src/main/java/oldAst/BlockNode.java @@ -1,4 +1,4 @@ -package ast; +package oldAst; public class BlockNode { } diff --git a/src/main/java/oldAst/ClassNode.java b/src/main/java/oldAst/ClassNode.java new file mode 100644 index 0000000..34d08dc --- /dev/null +++ b/src/main/java/oldAst/ClassNode.java @@ -0,0 +1,63 @@ +package oldAst; + +import oldAst.member.ConstructorNode; +import oldAst.member.MemberNode; +import oldAst.member.MethodNode; +import oldAst.type.AccessTypeNode; +import oldAst.type.EnumAccessTypeNode; + +import java.util.ArrayList; +import java.util.List; + +import bytecode.visitor.ClassVisitor; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; + +public class ClassNode implements ASTNode, Visitable { + public String identifier; + public AccessTypeNode accessType; + public List members = new ArrayList<>(); + public boolean hasConstructor = false; + + public ClassNode() {} + + public ClassNode(AccessTypeNode accessType, String identifier){ + this.accessType = accessType; + this.identifier = identifier; + } + + public void addMember(MemberNode member) { + if (member instanceof ConstructorNode) { + this.hasConstructor = true; + } + members.add(member); + } + + public void ensureConstructor(){ + if(!hasConstructor) { + ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), identifier); + members.add(0,constructor); + } + } + + public List getMethods(){ + List methods = new ArrayList<>(); + for (MemberNode member : members) { + if (member instanceof MethodNode methodNode) { + methods.add(methodNode); + } + } + return methods; + } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public void accept(ClassVisitor classVisitor) { + classVisitor.visit(this); + } +} diff --git a/src/main/java/oldAst/ProgramNode.java b/src/main/java/oldAst/ProgramNode.java new file mode 100644 index 0000000..beb97d9 --- /dev/null +++ b/src/main/java/oldAst/ProgramNode.java @@ -0,0 +1,27 @@ +package oldAst; + +import java.util.ArrayList; +import java.util.List; + +import bytecode.visitor.ProgramVisitor; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; + +public class ProgramNode implements ASTNode, Visitable{ + public List classes = new ArrayList<>(); + + public void addClass(ClassNode classNode) { + classes.add(classNode); + } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public void accept(ProgramVisitor programVisitor) { + programVisitor.visit(this); + } +} \ No newline at end of file diff --git a/src/main/java/ast/expression/BinaryExpressionNode.java b/src/main/java/oldAst/expression/BinaryExpressionNode.java similarity index 95% rename from src/main/java/ast/expression/BinaryExpressionNode.java rename to src/main/java/oldAst/expression/BinaryExpressionNode.java index e4a0e41..bdb1467 100644 --- a/src/main/java/ast/expression/BinaryExpressionNode.java +++ b/src/main/java/oldAst/expression/BinaryExpressionNode.java @@ -1,4 +1,4 @@ -package ast.expression; +package oldAst.expression; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/oldAst/expression/ExpressionNode.java similarity index 82% rename from src/main/java/ast/expression/ExpressionNode.java rename to src/main/java/oldAst/expression/ExpressionNode.java index 42be180..27c43e3 100644 --- a/src/main/java/ast/expression/ExpressionNode.java +++ b/src/main/java/oldAst/expression/ExpressionNode.java @@ -1,9 +1,6 @@ -package ast.expression; +package oldAst.expression; -import ast.ASTNode; -import ast.statement.AssignmentStatementNode; -import ast.statement.IfStatementNode; -import ast.statement.VariableDeclarationStatementNode; +import oldAst.ASTNode; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/src/main/java/ast/expression/ExpresssionOperator.java b/src/main/java/oldAst/expression/ExpresssionOperator.java similarity index 90% rename from src/main/java/ast/expression/ExpresssionOperator.java rename to src/main/java/oldAst/expression/ExpresssionOperator.java index 42bc137..dfd7ef8 100644 --- a/src/main/java/ast/expression/ExpresssionOperator.java +++ b/src/main/java/oldAst/expression/ExpresssionOperator.java @@ -1,4 +1,4 @@ -package ast.expression; +package oldAst.expression; public enum ExpresssionOperator { DOT, // . NICHT MEHR GEBRAUCHT diff --git a/src/main/java/ast/expression/IdentifierExpressionNode.java b/src/main/java/oldAst/expression/IdentifierExpressionNode.java similarity index 88% rename from src/main/java/ast/expression/IdentifierExpressionNode.java rename to src/main/java/oldAst/expression/IdentifierExpressionNode.java index 1bb8d56..4552a82 100644 --- a/src/main/java/ast/expression/IdentifierExpressionNode.java +++ b/src/main/java/oldAst/expression/IdentifierExpressionNode.java @@ -1,6 +1,6 @@ -package ast.expression; +package oldAst.expression; -import ast.type.TypeNode; +import oldAst.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/expression/InstVar.java b/src/main/java/oldAst/expression/InstVar.java similarity index 90% rename from src/main/java/ast/expression/InstVar.java rename to src/main/java/oldAst/expression/InstVar.java index 6ffbba3..dc9a204 100644 --- a/src/main/java/ast/expression/InstVar.java +++ b/src/main/java/oldAst/expression/InstVar.java @@ -1,6 +1,6 @@ -package ast.expression; +package oldAst.expression; -import ast.type.TypeNode; +import oldAst.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; diff --git a/src/main/java/ast/expression/LiteralNode.java b/src/main/java/oldAst/expression/LiteralNode.java similarity index 89% rename from src/main/java/ast/expression/LiteralNode.java rename to src/main/java/oldAst/expression/LiteralNode.java index d97f7df..c53f04a 100644 --- a/src/main/java/ast/expression/LiteralNode.java +++ b/src/main/java/oldAst/expression/LiteralNode.java @@ -1,6 +1,6 @@ -package ast.expression; +package oldAst.expression; -import ast.type.TypeNode; +import oldAst.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/expression/This.java b/src/main/java/oldAst/expression/This.java similarity index 79% rename from src/main/java/ast/expression/This.java rename to src/main/java/oldAst/expression/This.java index 29fc827..1a0fbb3 100644 --- a/src/main/java/ast/expression/This.java +++ b/src/main/java/oldAst/expression/This.java @@ -1,8 +1,8 @@ -package ast.expression; +package oldAst.expression; -import ast.ASTNode; -import ast.type.ReferenceTypeNode; -import ast.type.TypeNode; +import oldAst.ASTNode; +import oldAst.type.ReferenceTypeNode; +import oldAst.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/expression/UnaryExpressionNode.java b/src/main/java/oldAst/expression/UnaryExpressionNode.java similarity index 95% rename from src/main/java/ast/expression/UnaryExpressionNode.java rename to src/main/java/oldAst/expression/UnaryExpressionNode.java index be1a660..17b0a9b 100644 --- a/src/main/java/ast/expression/UnaryExpressionNode.java +++ b/src/main/java/oldAst/expression/UnaryExpressionNode.java @@ -1,4 +1,4 @@ -package ast.expression; +package oldAst.expression; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/oldAst/member/ConstructorNode.java similarity index 86% rename from src/main/java/ast/member/ConstructorNode.java rename to src/main/java/oldAst/member/ConstructorNode.java index 998d727..9c3bc08 100644 --- a/src/main/java/ast/member/ConstructorNode.java +++ b/src/main/java/oldAst/member/ConstructorNode.java @@ -1,6 +1,6 @@ -package ast.member; +package oldAst.member; -import ast.type.AccessTypeNode; +import oldAst.type.AccessTypeNode; import bytecode.visitor.MethodVisitor; import visitor.Visitable; diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/oldAst/member/FieldNode.java similarity index 89% rename from src/main/java/ast/member/FieldNode.java rename to src/main/java/oldAst/member/FieldNode.java index 7273f6b..3f34f1d 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/oldAst/member/FieldNode.java @@ -1,7 +1,7 @@ -package ast.member; +package oldAst.member; -import ast.type.AccessTypeNode; -import ast.type.TypeNode; +import oldAst.type.AccessTypeNode; +import oldAst.type.TypeNode; import bytecode.visitor.ClassVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/member/MemberNode.java b/src/main/java/oldAst/member/MemberNode.java similarity index 91% rename from src/main/java/ast/member/MemberNode.java rename to src/main/java/oldAst/member/MemberNode.java index ace0d6d..56e01e3 100644 --- a/src/main/java/ast/member/MemberNode.java +++ b/src/main/java/oldAst/member/MemberNode.java @@ -1,6 +1,6 @@ -package ast.member; +package oldAst.member; -import ast.ASTNode; +import oldAst.ASTNode; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/oldAst/member/MethodNode.java similarity index 91% rename from src/main/java/ast/member/MethodNode.java rename to src/main/java/oldAst/member/MethodNode.java index f3cba60..34d14e1 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/oldAst/member/MethodNode.java @@ -1,13 +1,13 @@ -package ast.member; +package oldAst.member; -import ast.parameter.ParameterListNode; -import ast.statement.StatementNode; -import ast.type.AccessTypeNode; +import oldAst.parameter.ParameterListNode; +import oldAst.statement.StatementNode; +import oldAst.type.AccessTypeNode; import java.util.ArrayList; import java.util.List; -import ast.type.TypeNode; +import oldAst.type.TypeNode; import bytecode.visitor.MethodVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/parameter/ParameterListNode.java b/src/main/java/oldAst/parameter/ParameterListNode.java similarity index 86% rename from src/main/java/ast/parameter/ParameterListNode.java rename to src/main/java/oldAst/parameter/ParameterListNode.java index 76a39fb..b241791 100644 --- a/src/main/java/ast/parameter/ParameterListNode.java +++ b/src/main/java/oldAst/parameter/ParameterListNode.java @@ -1,6 +1,6 @@ -package ast.parameter; +package oldAst.parameter; -import ast.ASTNode; +import oldAst.ASTNode; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/oldAst/parameter/ParameterNode.java similarity index 77% rename from src/main/java/ast/parameter/ParameterNode.java rename to src/main/java/oldAst/parameter/ParameterNode.java index 176e987..976375c 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/oldAst/parameter/ParameterNode.java @@ -1,7 +1,7 @@ -package ast.parameter; +package oldAst.parameter; -import ast.ASTNode; -import ast.type.TypeNode; +import oldAst.ASTNode; +import oldAst.type.TypeNode; public class ParameterNode implements ASTNode { public TypeNode type; diff --git a/src/main/java/ast/statement/AssignmentStatementNode.java b/src/main/java/oldAst/statement/AssignmentStatementNode.java similarity index 82% rename from src/main/java/ast/statement/AssignmentStatementNode.java rename to src/main/java/oldAst/statement/AssignmentStatementNode.java index abd00a5..556fe5e 100644 --- a/src/main/java/ast/statement/AssignmentStatementNode.java +++ b/src/main/java/oldAst/statement/AssignmentStatementNode.java @@ -1,8 +1,6 @@ -package ast.statement; +package oldAst.statement; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.type.TypeNode; +import oldAst.expression.ExpressionNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; diff --git a/src/main/java/ast/statement/IfStatementNode.java b/src/main/java/oldAst/statement/IfStatementNode.java similarity index 89% rename from src/main/java/ast/statement/IfStatementNode.java rename to src/main/java/oldAst/statement/IfStatementNode.java index 3f585dd..6050e7a 100644 --- a/src/main/java/ast/statement/IfStatementNode.java +++ b/src/main/java/oldAst/statement/IfStatementNode.java @@ -1,6 +1,6 @@ -package ast.statement; +package oldAst.statement; -import ast.expression.ExpressionNode; +import oldAst.expression.ExpressionNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/oldAst/statement/ReturnStatementNode.java similarity index 85% rename from src/main/java/ast/statement/ReturnStatementNode.java rename to src/main/java/oldAst/statement/ReturnStatementNode.java index c5e4d6b..21db22d 100644 --- a/src/main/java/ast/statement/ReturnStatementNode.java +++ b/src/main/java/oldAst/statement/ReturnStatementNode.java @@ -1,6 +1,6 @@ -package ast.statement; +package oldAst.statement; -import ast.expression.ExpressionNode; +import oldAst.expression.ExpressionNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/oldAst/statement/StatementNode.java similarity index 86% rename from src/main/java/ast/statement/StatementNode.java rename to src/main/java/oldAst/statement/StatementNode.java index 5a96ee5..6ae0192 100644 --- a/src/main/java/ast/statement/StatementNode.java +++ b/src/main/java/oldAst/statement/StatementNode.java @@ -1,8 +1,6 @@ -package ast.statement; +package oldAst.statement; -import ast.ASTNode; -import ast.type.BaseTypeNode; -import ast.type.ReferenceTypeNode; +import oldAst.ASTNode; import visitor.Visitable; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/src/main/java/ast/statement/VariableDeclarationStatementNode.java b/src/main/java/oldAst/statement/VariableDeclarationStatementNode.java similarity index 86% rename from src/main/java/ast/statement/VariableDeclarationStatementNode.java rename to src/main/java/oldAst/statement/VariableDeclarationStatementNode.java index 9feb086..854b9e1 100644 --- a/src/main/java/ast/statement/VariableDeclarationStatementNode.java +++ b/src/main/java/oldAst/statement/VariableDeclarationStatementNode.java @@ -1,7 +1,7 @@ -package ast.statement; +package oldAst.statement; -import ast.expression.ExpressionNode; -import ast.type.TypeNode; +import oldAst.expression.ExpressionNode; +import oldAst.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/oldAst/statement/WhileStatementNode.java similarity index 87% rename from src/main/java/ast/statement/WhileStatementNode.java rename to src/main/java/oldAst/statement/WhileStatementNode.java index a3f4007..b3fcee5 100644 --- a/src/main/java/ast/statement/WhileStatementNode.java +++ b/src/main/java/oldAst/statement/WhileStatementNode.java @@ -1,6 +1,6 @@ -package ast.statement; +package oldAst.statement; -import ast.expression.ExpressionNode; +import oldAst.expression.ExpressionNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/type/AccessTypeNode.java b/src/main/java/oldAst/type/AccessTypeNode.java similarity index 85% rename from src/main/java/ast/type/AccessTypeNode.java rename to src/main/java/oldAst/type/AccessTypeNode.java index 4e0db89..e1f884f 100644 --- a/src/main/java/ast/type/AccessTypeNode.java +++ b/src/main/java/oldAst/type/AccessTypeNode.java @@ -1,6 +1,6 @@ -package ast.type; +package oldAst.type; -import ast.ASTNode; +import oldAst.ASTNode; public class AccessTypeNode implements ASTNode { public EnumAccessTypeNode enumAccessTypeNode; diff --git a/src/main/java/ast/type/BaseTypeNode.java b/src/main/java/oldAst/type/BaseTypeNode.java similarity index 92% rename from src/main/java/ast/type/BaseTypeNode.java rename to src/main/java/oldAst/type/BaseTypeNode.java index 8a9a4a6..2a1b23d 100644 --- a/src/main/java/ast/type/BaseTypeNode.java +++ b/src/main/java/oldAst/type/BaseTypeNode.java @@ -1,6 +1,6 @@ -package ast.type; +package oldAst.type; -import ast.ASTNode; +import oldAst.ASTNode; public class BaseTypeNode implements ASTNode, TypeNode { diff --git a/src/main/java/ast/type/EnumAccessTypeNode.java b/src/main/java/oldAst/type/EnumAccessTypeNode.java similarity index 72% rename from src/main/java/ast/type/EnumAccessTypeNode.java rename to src/main/java/oldAst/type/EnumAccessTypeNode.java index 12cdda9..c8625e5 100644 --- a/src/main/java/ast/type/EnumAccessTypeNode.java +++ b/src/main/java/oldAst/type/EnumAccessTypeNode.java @@ -1,4 +1,4 @@ -package ast.type; +package oldAst.type; public enum EnumAccessTypeNode { PUBLIC, PRIVATE diff --git a/src/main/java/ast/type/EnumTypeNode.java b/src/main/java/oldAst/type/EnumTypeNode.java similarity index 71% rename from src/main/java/ast/type/EnumTypeNode.java rename to src/main/java/oldAst/type/EnumTypeNode.java index d858461..1e84e81 100644 --- a/src/main/java/ast/type/EnumTypeNode.java +++ b/src/main/java/oldAst/type/EnumTypeNode.java @@ -1,4 +1,4 @@ -package ast.type; +package oldAst.type; public enum EnumTypeNode { INT, BOOLEAN, CHAR diff --git a/src/main/java/ast/type/ReferenceTypeNode.java b/src/main/java/oldAst/type/ReferenceTypeNode.java similarity index 94% rename from src/main/java/ast/type/ReferenceTypeNode.java rename to src/main/java/oldAst/type/ReferenceTypeNode.java index 91da6bc..b73f4dd 100644 --- a/src/main/java/ast/type/ReferenceTypeNode.java +++ b/src/main/java/oldAst/type/ReferenceTypeNode.java @@ -1,6 +1,6 @@ -package ast.type; +package oldAst.type; -import ast.ASTNode; +import oldAst.ASTNode; public class ReferenceTypeNode implements ASTNode, TypeNode { diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/oldAst/type/TypeNode.java similarity index 91% rename from src/main/java/ast/type/TypeNode.java rename to src/main/java/oldAst/type/TypeNode.java index a855f09..7248755 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/oldAst/type/TypeNode.java @@ -1,6 +1,6 @@ -package ast.type; +package oldAst.type; -import ast.ASTNode; +import oldAst.ASTNode; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonSubTypes; diff --git a/src/main/java/parser/SimpleJava.g4 b/src/main/java/parser/SimpleJava.g4 deleted file mode 100644 index 7d09aba..0000000 --- a/src/main/java/parser/SimpleJava.g4 +++ /dev/null @@ -1,62 +0,0 @@ -grammar SimpleJava; - -program : classDeclaration+; - -classDeclaration : accessType 'class' IDENTIFIER '{' memberDeclaration* '}'; - -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 ; - -type : 'int' | 'boolean' | 'char' ; -accessType : 'public' | 'private' ; - -statement - : variableDeclarationStatement - | assignmentStatement - | ifStatement - | whileStatement - | returnStatement - | block - ; - -variableDeclarationStatement : type IDENTIFIER ('=' expression)? ';' ; - -assignmentStatement : var '=' expression ';' ; - -var: IDENTIFIER; - -ifStatement : 'if' '(' expression ')' statement ('else' statement)? ; - -whileStatement : 'while' '(' expression ')' statement ; - -returnStatement : 'return' (expression)? ';' ; - -block : '{' statement* '}' ; - -expression - : expression ('&&' | '||') expression - | expression ('==' | '!=' | '<' | '<=' | '>' | '>=') expression - | expression ('+' | '-' | '*' | '/' | '%') expression - | '-' expression - | '!' expression - | '(' expression ')' - | literal - | IDENTIFIER - ; - -literal : INTEGERLITERAL | booleanLiteral | charLiteral ; - -INTEGERLITERAL : [0-9]+ ; -booleanLiteral : 'true' | 'false' ; -charLiteral : '\'' . '\'' ; -IDENTIFIER : [a-zA-Z][a-zA-Z0-9_]* ; - -WS : [ \t\r\n]+ -> skip; \ No newline at end of file diff --git a/src/main/java/parser/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java similarity index 96% rename from src/main/java/parser/ASTBuilder.java rename to src/main/java/parser/astBuilder/ASTBuilder.java index 9110f2c..69cad70 100644 --- a/src/main/java/parser/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -1,21 +1,21 @@ -package parser; +package parser.astBuilder; -import ast.*; -import ast.expression.*; -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.*; +import oldAst.*; +import oldAst.expression.*; +import oldAst.member.FieldNode; +import oldAst.member.MemberNode; +import oldAst.member.MethodNode; +import oldAst.parameter.ParameterListNode; +import oldAst.parameter.ParameterNode; +import oldAst.statement.*; +import oldAst.type.*; import org.antlr.v4.runtime.tree.TerminalNode; import java.util.ArrayList; import java.util.List; import parser.generated.*; import parser.generated.SimpleJavaParser.LiteralContext; -import ast.type.BaseTypeNode; +import oldAst.type.BaseTypeNode; public class ASTBuilder extends SimpleJavaBaseVisitor { @Override diff --git a/src/main/java/parser/generated/SimpleJava.interp b/src/main/java/parser/generated/SimpleJava.interp index c3cff60..c977686 100644 --- a/src/main/java/parser/generated/SimpleJava.interp +++ b/src/main/java/parser/generated/SimpleJava.interp @@ -1,40 +1,52 @@ token literal names: null -'class' -'{' -'}' -';' -'static' -'(' -')' -',' -'int' +'++' +'--' +'void' 'boolean' 'char' -'public' -'private' +'int' +null +'public static void main(String[] args)' +null +null +null +null '=' -'if' -'else' -'while' -'return' -'&&' -'||' -'==' -'!=' -'<' -'<=' -'>' -'>=' '+' '-' '*' -'/' '%' +'/' +'>' +'<' +'>=' +'<=' +'==' +'!=' '!' -'true' -'false' -'\'' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'for' +'return' +'new' +null +null +null +'null' +null null null null @@ -43,67 +55,101 @@ token symbolic names: null null null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -INTEGERLITERAL -IDENTIFIER +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Identifier WS +InlineComment +MultilineComment rule names: program classDeclaration memberDeclaration +constructorDeclaration fieldDeclaration methodDeclaration -constructorDeclaration parameterList parameter -type -accessType +argumentList statement -variableDeclarationStatement -assignmentStatement -var -ifStatement -whileStatement -returnStatement block +returnStatement +localVariableDeclaration +whileStatement +forStatement +ifElseStatement +ifStatement +elseStatement +statementExpression +assign +newDeclaration expression -literal -booleanLiteral -charLiteral +unaryExpression +notExpression +crementExpression +incrementExpression +prefixIncrementExpression +suffixIncrementExpression +decrementExpression +prefixDecrementExpression +suffixDecrementExpression +assignableExpression +memberAccess +binaryExpression +calculationExpression +dotExpression +dotSubtractionExpression +nonCalculationExpression +methodCall +target +chainedMethod +type +value +nonCalculationOperator atn: -[4, 1, 38, 212, 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, 2, 21, 7, 21, 1, 0, 4, 0, 46, 8, 0, 11, 0, 12, 0, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 55, 8, 1, 10, 1, 12, 1, 58, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 65, 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, 78, 8, 4, 1, 4, 1, 4, 1, 4, 5, 4, 83, 8, 4, 10, 4, 12, 4, 86, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 94, 8, 5, 1, 5, 1, 5, 1, 5, 5, 5, 99, 8, 5, 10, 5, 12, 5, 102, 9, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 5, 6, 109, 8, 6, 10, 6, 12, 6, 112, 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, 127, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 133, 8, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 151, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 3, 16, 161, 8, 16, 1, 16, 1, 16, 1, 17, 1, 17, 5, 17, 167, 8, 17, 10, 17, 12, 17, 170, 9, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 185, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 196, 8, 18, 10, 18, 12, 18, 199, 9, 18, 1, 19, 1, 19, 1, 19, 3, 19, 204, 8, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 0, 1, 36, 22, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 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, 216, 0, 45, 1, 0, 0, 0, 2, 49, 1, 0, 0, 0, 4, 64, 1, 0, 0, 0, 6, 66, 1, 0, 0, 0, 8, 71, 1, 0, 0, 0, 10, 89, 1, 0, 0, 0, 12, 105, 1, 0, 0, 0, 14, 113, 1, 0, 0, 0, 16, 116, 1, 0, 0, 0, 18, 118, 1, 0, 0, 0, 20, 126, 1, 0, 0, 0, 22, 128, 1, 0, 0, 0, 24, 136, 1, 0, 0, 0, 26, 141, 1, 0, 0, 0, 28, 143, 1, 0, 0, 0, 30, 152, 1, 0, 0, 0, 32, 158, 1, 0, 0, 0, 34, 164, 1, 0, 0, 0, 36, 184, 1, 0, 0, 0, 38, 203, 1, 0, 0, 0, 40, 205, 1, 0, 0, 0, 42, 207, 1, 0, 0, 0, 44, 46, 3, 2, 1, 0, 45, 44, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 1, 1, 0, 0, 0, 49, 50, 3, 18, 9, 0, 50, 51, 5, 1, 0, 0, 51, 52, 5, 37, 0, 0, 52, 56, 5, 2, 0, 0, 53, 55, 3, 4, 2, 0, 54, 53, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 59, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60, 5, 3, 0, 0, 60, 3, 1, 0, 0, 0, 61, 65, 3, 6, 3, 0, 62, 65, 3, 8, 4, 0, 63, 65, 3, 10, 5, 0, 64, 61, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 5, 1, 0, 0, 0, 66, 67, 3, 18, 9, 0, 67, 68, 3, 16, 8, 0, 68, 69, 5, 37, 0, 0, 69, 70, 5, 4, 0, 0, 70, 7, 1, 0, 0, 0, 71, 72, 3, 18, 9, 0, 72, 73, 5, 5, 0, 0, 73, 74, 3, 16, 8, 0, 74, 75, 5, 37, 0, 0, 75, 77, 5, 6, 0, 0, 76, 78, 3, 12, 6, 0, 77, 76, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 80, 5, 7, 0, 0, 80, 84, 5, 2, 0, 0, 81, 83, 3, 20, 10, 0, 82, 81, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 87, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 88, 5, 3, 0, 0, 88, 9, 1, 0, 0, 0, 89, 90, 3, 18, 9, 0, 90, 91, 5, 37, 0, 0, 91, 93, 5, 6, 0, 0, 92, 94, 3, 12, 6, 0, 93, 92, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 5, 7, 0, 0, 96, 100, 5, 2, 0, 0, 97, 99, 3, 20, 10, 0, 98, 97, 1, 0, 0, 0, 99, 102, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 103, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 103, 104, 5, 3, 0, 0, 104, 11, 1, 0, 0, 0, 105, 110, 3, 14, 7, 0, 106, 107, 5, 8, 0, 0, 107, 109, 3, 14, 7, 0, 108, 106, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 13, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 114, 3, 16, 8, 0, 114, 115, 5, 37, 0, 0, 115, 15, 1, 0, 0, 0, 116, 117, 7, 0, 0, 0, 117, 17, 1, 0, 0, 0, 118, 119, 7, 1, 0, 0, 119, 19, 1, 0, 0, 0, 120, 127, 3, 22, 11, 0, 121, 127, 3, 24, 12, 0, 122, 127, 3, 28, 14, 0, 123, 127, 3, 30, 15, 0, 124, 127, 3, 32, 16, 0, 125, 127, 3, 34, 17, 0, 126, 120, 1, 0, 0, 0, 126, 121, 1, 0, 0, 0, 126, 122, 1, 0, 0, 0, 126, 123, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 126, 125, 1, 0, 0, 0, 127, 21, 1, 0, 0, 0, 128, 129, 3, 16, 8, 0, 129, 132, 5, 37, 0, 0, 130, 131, 5, 14, 0, 0, 131, 133, 3, 36, 18, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 135, 5, 4, 0, 0, 135, 23, 1, 0, 0, 0, 136, 137, 3, 26, 13, 0, 137, 138, 5, 14, 0, 0, 138, 139, 3, 36, 18, 0, 139, 140, 5, 4, 0, 0, 140, 25, 1, 0, 0, 0, 141, 142, 5, 37, 0, 0, 142, 27, 1, 0, 0, 0, 143, 144, 5, 15, 0, 0, 144, 145, 5, 6, 0, 0, 145, 146, 3, 36, 18, 0, 146, 147, 5, 7, 0, 0, 147, 150, 3, 20, 10, 0, 148, 149, 5, 16, 0, 0, 149, 151, 3, 20, 10, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 29, 1, 0, 0, 0, 152, 153, 5, 17, 0, 0, 153, 154, 5, 6, 0, 0, 154, 155, 3, 36, 18, 0, 155, 156, 5, 7, 0, 0, 156, 157, 3, 20, 10, 0, 157, 31, 1, 0, 0, 0, 158, 160, 5, 18, 0, 0, 159, 161, 3, 36, 18, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 163, 5, 4, 0, 0, 163, 33, 1, 0, 0, 0, 164, 168, 5, 2, 0, 0, 165, 167, 3, 20, 10, 0, 166, 165, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 172, 5, 3, 0, 0, 172, 35, 1, 0, 0, 0, 173, 174, 6, 18, -1, 0, 174, 175, 5, 28, 0, 0, 175, 185, 3, 36, 18, 5, 176, 177, 5, 32, 0, 0, 177, 185, 3, 36, 18, 4, 178, 179, 5, 6, 0, 0, 179, 180, 3, 36, 18, 0, 180, 181, 5, 7, 0, 0, 181, 185, 1, 0, 0, 0, 182, 185, 3, 38, 19, 0, 183, 185, 5, 37, 0, 0, 184, 173, 1, 0, 0, 0, 184, 176, 1, 0, 0, 0, 184, 178, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 184, 183, 1, 0, 0, 0, 185, 197, 1, 0, 0, 0, 186, 187, 10, 8, 0, 0, 187, 188, 7, 2, 0, 0, 188, 196, 3, 36, 18, 9, 189, 190, 10, 7, 0, 0, 190, 191, 7, 3, 0, 0, 191, 196, 3, 36, 18, 8, 192, 193, 10, 6, 0, 0, 193, 194, 7, 4, 0, 0, 194, 196, 3, 36, 18, 7, 195, 186, 1, 0, 0, 0, 195, 189, 1, 0, 0, 0, 195, 192, 1, 0, 0, 0, 196, 199, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 37, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 200, 204, 5, 36, 0, 0, 201, 204, 3, 40, 20, 0, 202, 204, 3, 42, 21, 0, 203, 200, 1, 0, 0, 0, 203, 201, 1, 0, 0, 0, 203, 202, 1, 0, 0, 0, 204, 39, 1, 0, 0, 0, 205, 206, 7, 5, 0, 0, 206, 41, 1, 0, 0, 0, 207, 208, 5, 35, 0, 0, 208, 209, 9, 0, 0, 0, 209, 210, 5, 35, 0, 0, 210, 43, 1, 0, 0, 0, 17, 47, 56, 64, 77, 84, 93, 100, 110, 126, 132, 150, 160, 168, 184, 195, 197, 203] \ No newline at end of file +[4, 1, 50, 393, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 1, 0, 4, 0, 90, 8, 0, 11, 0, 12, 0, 91, 1, 1, 3, 1, 95, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 101, 8, 1, 10, 1, 12, 1, 104, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 111, 8, 2, 1, 3, 3, 3, 114, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 119, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 125, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 134, 8, 5, 1, 5, 1, 5, 3, 5, 138, 8, 5, 1, 5, 1, 5, 1, 5, 3, 5, 143, 8, 5, 1, 5, 1, 5, 3, 5, 147, 8, 5, 1, 6, 1, 6, 1, 6, 5, 6, 152, 8, 6, 10, 6, 12, 6, 155, 9, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 5, 8, 163, 8, 8, 10, 8, 12, 8, 166, 9, 8, 3, 8, 168, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 183, 8, 9, 1, 10, 1, 10, 5, 10, 187, 8, 10, 10, 10, 12, 10, 190, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 3, 11, 196, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 202, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 214, 8, 14, 1, 14, 1, 14, 3, 14, 218, 8, 14, 1, 14, 1, 14, 3, 14, 222, 8, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 229, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 244, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 3, 21, 258, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 270, 8, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 3, 24, 277, 8, 24, 1, 25, 1, 25, 3, 25, 281, 8, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 3, 28, 291, 8, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 3, 31, 301, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 308, 8, 32, 1, 32, 1, 32, 4, 32, 312, 8, 32, 11, 32, 12, 32, 313, 1, 32, 3, 32, 317, 8, 32, 1, 33, 1, 33, 3, 33, 321, 8, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 329, 8, 34, 10, 34, 12, 34, 332, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 340, 8, 35, 10, 35, 12, 35, 343, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 3, 36, 353, 8, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 3, 38, 360, 8, 38, 1, 38, 5, 38, 363, 8, 38, 10, 38, 12, 38, 366, 9, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 377, 8, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 0, 2, 68, 70, 44, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 0, 3, 2, 0, 4, 6, 47, 47, 1, 0, 43, 46, 1, 0, 11, 12, 404, 0, 89, 1, 0, 0, 0, 2, 94, 1, 0, 0, 0, 4, 110, 1, 0, 0, 0, 6, 113, 1, 0, 0, 0, 8, 124, 1, 0, 0, 0, 10, 146, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 156, 1, 0, 0, 0, 16, 167, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 184, 1, 0, 0, 0, 22, 193, 1, 0, 0, 0, 24, 197, 1, 0, 0, 0, 26, 203, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 226, 1, 0, 0, 0, 32, 230, 1, 0, 0, 0, 34, 236, 1, 0, 0, 0, 36, 243, 1, 0, 0, 0, 38, 245, 1, 0, 0, 0, 40, 249, 1, 0, 0, 0, 42, 257, 1, 0, 0, 0, 44, 269, 1, 0, 0, 0, 46, 271, 1, 0, 0, 0, 48, 276, 1, 0, 0, 0, 50, 280, 1, 0, 0, 0, 52, 282, 1, 0, 0, 0, 54, 285, 1, 0, 0, 0, 56, 290, 1, 0, 0, 0, 58, 292, 1, 0, 0, 0, 60, 295, 1, 0, 0, 0, 62, 300, 1, 0, 0, 0, 64, 316, 1, 0, 0, 0, 66, 320, 1, 0, 0, 0, 68, 322, 1, 0, 0, 0, 70, 333, 1, 0, 0, 0, 72, 352, 1, 0, 0, 0, 74, 354, 1, 0, 0, 0, 76, 359, 1, 0, 0, 0, 78, 376, 1, 0, 0, 0, 80, 380, 1, 0, 0, 0, 82, 386, 1, 0, 0, 0, 84, 388, 1, 0, 0, 0, 86, 390, 1, 0, 0, 0, 88, 90, 3, 2, 1, 0, 89, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 1, 1, 0, 0, 0, 93, 95, 5, 7, 0, 0, 94, 93, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 5, 35, 0, 0, 97, 98, 5, 47, 0, 0, 98, 102, 5, 31, 0, 0, 99, 101, 3, 4, 2, 0, 100, 99, 1, 0, 0, 0, 101, 104, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 105, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 106, 5, 32, 0, 0, 106, 3, 1, 0, 0, 0, 107, 111, 3, 6, 3, 0, 108, 111, 3, 8, 4, 0, 109, 111, 3, 10, 5, 0, 110, 107, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 109, 1, 0, 0, 0, 111, 5, 1, 0, 0, 0, 112, 114, 5, 7, 0, 0, 113, 112, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 5, 47, 0, 0, 116, 118, 5, 29, 0, 0, 117, 119, 3, 12, 6, 0, 118, 117, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 5, 30, 0, 0, 121, 122, 3, 20, 10, 0, 122, 7, 1, 0, 0, 0, 123, 125, 5, 7, 0, 0, 124, 123, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 3, 82, 41, 0, 127, 128, 5, 47, 0, 0, 128, 129, 5, 33, 0, 0, 129, 9, 1, 0, 0, 0, 130, 131, 5, 8, 0, 0, 131, 147, 3, 20, 10, 0, 132, 134, 5, 7, 0, 0, 133, 132, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 137, 1, 0, 0, 0, 135, 138, 3, 82, 41, 0, 136, 138, 5, 3, 0, 0, 137, 135, 1, 0, 0, 0, 137, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 5, 47, 0, 0, 140, 142, 5, 29, 0, 0, 141, 143, 3, 12, 6, 0, 142, 141, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 5, 30, 0, 0, 145, 147, 3, 20, 10, 0, 146, 130, 1, 0, 0, 0, 146, 133, 1, 0, 0, 0, 147, 11, 1, 0, 0, 0, 148, 153, 3, 14, 7, 0, 149, 150, 5, 34, 0, 0, 150, 152, 3, 14, 7, 0, 151, 149, 1, 0, 0, 0, 152, 155, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 153, 154, 1, 0, 0, 0, 154, 13, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 156, 157, 3, 82, 41, 0, 157, 158, 5, 47, 0, 0, 158, 15, 1, 0, 0, 0, 159, 164, 3, 42, 21, 0, 160, 161, 5, 34, 0, 0, 161, 163, 3, 42, 21, 0, 162, 160, 1, 0, 0, 0, 163, 166, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 168, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 167, 159, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 17, 1, 0, 0, 0, 169, 170, 3, 22, 11, 0, 170, 171, 5, 33, 0, 0, 171, 183, 1, 0, 0, 0, 172, 173, 3, 24, 12, 0, 173, 174, 5, 33, 0, 0, 174, 183, 1, 0, 0, 0, 175, 183, 3, 20, 10, 0, 176, 183, 3, 26, 13, 0, 177, 183, 3, 28, 14, 0, 178, 183, 3, 30, 15, 0, 179, 180, 3, 36, 18, 0, 180, 181, 5, 33, 0, 0, 181, 183, 1, 0, 0, 0, 182, 169, 1, 0, 0, 0, 182, 172, 1, 0, 0, 0, 182, 175, 1, 0, 0, 0, 182, 176, 1, 0, 0, 0, 182, 177, 1, 0, 0, 0, 182, 178, 1, 0, 0, 0, 182, 179, 1, 0, 0, 0, 183, 19, 1, 0, 0, 0, 184, 188, 5, 31, 0, 0, 185, 187, 3, 18, 9, 0, 186, 185, 1, 0, 0, 0, 187, 190, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 191, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 191, 192, 5, 32, 0, 0, 192, 21, 1, 0, 0, 0, 193, 195, 5, 41, 0, 0, 194, 196, 3, 42, 21, 0, 195, 194, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 23, 1, 0, 0, 0, 197, 198, 3, 82, 41, 0, 198, 201, 5, 47, 0, 0, 199, 200, 5, 13, 0, 0, 200, 202, 3, 42, 21, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0, 0, 203, 204, 5, 37, 0, 0, 204, 205, 5, 29, 0, 0, 205, 206, 3, 42, 21, 0, 206, 207, 5, 30, 0, 0, 207, 208, 3, 20, 10, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 40, 0, 0, 210, 213, 5, 29, 0, 0, 211, 214, 3, 36, 18, 0, 212, 214, 3, 24, 12, 0, 213, 211, 1, 0, 0, 0, 213, 212, 1, 0, 0, 0, 214, 215, 1, 0, 0, 0, 215, 217, 5, 33, 0, 0, 216, 218, 3, 42, 21, 0, 217, 216, 1, 0, 0, 0, 217, 218, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 221, 5, 33, 0, 0, 220, 222, 3, 36, 18, 0, 221, 220, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 223, 1, 0, 0, 0, 223, 224, 5, 30, 0, 0, 224, 225, 3, 18, 9, 0, 225, 29, 1, 0, 0, 0, 226, 228, 3, 32, 16, 0, 227, 229, 3, 34, 17, 0, 228, 227, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 31, 1, 0, 0, 0, 230, 231, 5, 38, 0, 0, 231, 232, 5, 29, 0, 0, 232, 233, 3, 42, 21, 0, 233, 234, 5, 30, 0, 0, 234, 235, 3, 18, 9, 0, 235, 33, 1, 0, 0, 0, 236, 237, 5, 39, 0, 0, 237, 238, 3, 18, 9, 0, 238, 35, 1, 0, 0, 0, 239, 244, 3, 38, 19, 0, 240, 244, 3, 40, 20, 0, 241, 244, 3, 76, 38, 0, 242, 244, 3, 48, 24, 0, 243, 239, 1, 0, 0, 0, 243, 240, 1, 0, 0, 0, 243, 241, 1, 0, 0, 0, 243, 242, 1, 0, 0, 0, 244, 37, 1, 0, 0, 0, 245, 246, 3, 62, 31, 0, 246, 247, 5, 13, 0, 0, 247, 248, 3, 42, 21, 0, 248, 39, 1, 0, 0, 0, 249, 250, 5, 42, 0, 0, 250, 251, 5, 47, 0, 0, 251, 252, 5, 29, 0, 0, 252, 253, 3, 16, 8, 0, 253, 254, 5, 30, 0, 0, 254, 41, 1, 0, 0, 0, 255, 258, 3, 44, 22, 0, 256, 258, 3, 66, 33, 0, 257, 255, 1, 0, 0, 0, 257, 256, 1, 0, 0, 0, 258, 43, 1, 0, 0, 0, 259, 270, 5, 36, 0, 0, 260, 270, 5, 47, 0, 0, 261, 270, 3, 64, 32, 0, 262, 270, 3, 84, 42, 0, 263, 270, 3, 46, 23, 0, 264, 270, 3, 36, 18, 0, 265, 266, 5, 29, 0, 0, 266, 267, 3, 42, 21, 0, 267, 268, 5, 30, 0, 0, 268, 270, 1, 0, 0, 0, 269, 259, 1, 0, 0, 0, 269, 260, 1, 0, 0, 0, 269, 261, 1, 0, 0, 0, 269, 262, 1, 0, 0, 0, 269, 263, 1, 0, 0, 0, 269, 264, 1, 0, 0, 0, 269, 265, 1, 0, 0, 0, 270, 45, 1, 0, 0, 0, 271, 272, 5, 25, 0, 0, 272, 273, 3, 42, 21, 0, 273, 47, 1, 0, 0, 0, 274, 277, 3, 50, 25, 0, 275, 277, 3, 56, 28, 0, 276, 274, 1, 0, 0, 0, 276, 275, 1, 0, 0, 0, 277, 49, 1, 0, 0, 0, 278, 281, 3, 52, 26, 0, 279, 281, 3, 54, 27, 0, 280, 278, 1, 0, 0, 0, 280, 279, 1, 0, 0, 0, 281, 51, 1, 0, 0, 0, 282, 283, 5, 1, 0, 0, 283, 284, 3, 62, 31, 0, 284, 53, 1, 0, 0, 0, 285, 286, 3, 62, 31, 0, 286, 287, 5, 1, 0, 0, 287, 55, 1, 0, 0, 0, 288, 291, 3, 58, 29, 0, 289, 291, 3, 60, 30, 0, 290, 288, 1, 0, 0, 0, 290, 289, 1, 0, 0, 0, 291, 57, 1, 0, 0, 0, 292, 293, 5, 2, 0, 0, 293, 294, 3, 62, 31, 0, 294, 59, 1, 0, 0, 0, 295, 296, 3, 62, 31, 0, 296, 297, 5, 2, 0, 0, 297, 61, 1, 0, 0, 0, 298, 301, 5, 47, 0, 0, 299, 301, 3, 64, 32, 0, 300, 298, 1, 0, 0, 0, 300, 299, 1, 0, 0, 0, 301, 63, 1, 0, 0, 0, 302, 303, 5, 36, 0, 0, 303, 304, 5, 28, 0, 0, 304, 317, 5, 47, 0, 0, 305, 306, 5, 36, 0, 0, 306, 308, 5, 28, 0, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 311, 1, 0, 0, 0, 309, 310, 5, 47, 0, 0, 310, 312, 5, 28, 0, 0, 311, 309, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 311, 1, 0, 0, 0, 313, 314, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 317, 5, 47, 0, 0, 316, 302, 1, 0, 0, 0, 316, 307, 1, 0, 0, 0, 317, 65, 1, 0, 0, 0, 318, 321, 3, 68, 34, 0, 319, 321, 3, 74, 37, 0, 320, 318, 1, 0, 0, 0, 320, 319, 1, 0, 0, 0, 321, 67, 1, 0, 0, 0, 322, 323, 6, 34, -1, 0, 323, 324, 3, 70, 35, 0, 324, 330, 1, 0, 0, 0, 325, 326, 10, 2, 0, 0, 326, 327, 5, 10, 0, 0, 327, 329, 3, 70, 35, 0, 328, 325, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 69, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 334, 6, 35, -1, 0, 334, 335, 3, 72, 36, 0, 335, 341, 1, 0, 0, 0, 336, 337, 10, 2, 0, 0, 337, 338, 5, 9, 0, 0, 338, 340, 3, 72, 36, 0, 339, 336, 1, 0, 0, 0, 340, 343, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 71, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 344, 353, 5, 44, 0, 0, 345, 353, 5, 47, 0, 0, 346, 353, 3, 64, 32, 0, 347, 348, 3, 76, 38, 0, 348, 349, 5, 29, 0, 0, 349, 350, 3, 68, 34, 0, 350, 351, 5, 30, 0, 0, 351, 353, 1, 0, 0, 0, 352, 344, 1, 0, 0, 0, 352, 345, 1, 0, 0, 0, 352, 346, 1, 0, 0, 0, 352, 347, 1, 0, 0, 0, 353, 73, 1, 0, 0, 0, 354, 355, 3, 44, 22, 0, 355, 356, 3, 86, 43, 0, 356, 357, 3, 42, 21, 0, 357, 75, 1, 0, 0, 0, 358, 360, 3, 78, 39, 0, 359, 358, 1, 0, 0, 0, 359, 360, 1, 0, 0, 0, 360, 364, 1, 0, 0, 0, 361, 363, 3, 80, 40, 0, 362, 361, 1, 0, 0, 0, 363, 366, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 365, 1, 0, 0, 0, 365, 367, 1, 0, 0, 0, 366, 364, 1, 0, 0, 0, 367, 368, 5, 47, 0, 0, 368, 369, 5, 29, 0, 0, 369, 370, 3, 16, 8, 0, 370, 371, 5, 30, 0, 0, 371, 77, 1, 0, 0, 0, 372, 377, 5, 36, 0, 0, 373, 377, 3, 64, 32, 0, 374, 377, 3, 40, 20, 0, 375, 377, 5, 47, 0, 0, 376, 372, 1, 0, 0, 0, 376, 373, 1, 0, 0, 0, 376, 374, 1, 0, 0, 0, 376, 375, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 379, 5, 28, 0, 0, 379, 79, 1, 0, 0, 0, 380, 381, 5, 47, 0, 0, 381, 382, 5, 29, 0, 0, 382, 383, 3, 16, 8, 0, 383, 384, 5, 30, 0, 0, 384, 385, 5, 28, 0, 0, 385, 81, 1, 0, 0, 0, 386, 387, 7, 0, 0, 0, 387, 83, 1, 0, 0, 0, 388, 389, 7, 1, 0, 0, 389, 85, 1, 0, 0, 0, 390, 391, 7, 2, 0, 0, 391, 87, 1, 0, 0, 0, 39, 91, 94, 102, 110, 113, 118, 124, 133, 137, 142, 146, 153, 164, 167, 182, 188, 195, 201, 213, 217, 221, 228, 243, 257, 269, 276, 280, 290, 300, 307, 313, 316, 320, 330, 341, 352, 359, 364, 376] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJava.tokens b/src/main/java/parser/generated/SimpleJava.tokens index fa21229..bed7437 100644 --- a/src/main/java/parser/generated/SimpleJava.tokens +++ b/src/main/java/parser/generated/SimpleJava.tokens @@ -1,73 +1,88 @@ T__0=1 T__1=2 -T__2=3 -T__3=4 -T__4=5 -T__5=6 -T__6=7 -T__7=8 -T__8=9 -T__9=10 -T__10=11 -T__11=12 -T__12=13 -T__13=14 -T__14=15 -T__15=16 -T__16=17 -T__17=18 -T__18=19 -T__19=20 -T__20=21 -T__21=22 -T__22=23 -T__23=24 -T__24=25 -T__25=26 -T__26=27 -T__27=28 -T__28=29 -T__29=30 -T__30=31 -T__31=32 -T__32=33 -T__33=34 -T__34=35 -INTEGERLITERAL=36 -IDENTIFIER=37 -WS=38 -'class'=1 -'{'=2 -'}'=3 -';'=4 -'static'=5 -'('=6 -')'=7 -','=8 -'int'=9 -'boolean'=10 -'char'=11 -'public'=12 -'private'=13 -'='=14 -'if'=15 -'else'=16 -'while'=17 -'return'=18 -'&&'=19 -'||'=20 -'=='=21 -'!='=22 -'<'=23 -'<='=24 -'>'=25 -'>='=26 -'+'=27 -'-'=28 -'*'=29 -'/'=30 -'%'=31 -'!'=32 -'true'=33 -'false'=34 -'\''=35 +Void=3 +Boolean=4 +Char=5 +Int=6 +AccessModifier=7 +MainMethodDeclaration=8 +DotOperator=9 +LineOperator=10 +ComparisonOperator=11 +LogicalOperator=12 +Assign=13 +Plus=14 +Minus=15 +Mult=16 +Modulo=17 +Div=18 +Greater=19 +Less=20 +GreaterEqual=21 +LessEqual=22 +Equal=23 +NotEqual=24 +Not=25 +And=26 +Or=27 +Dot=28 +OpenRoundBracket=29 +ClosedRoundBracket=30 +OpenCurlyBracket=31 +ClosedCurlyBracket=32 +Semicolon=33 +Comma=34 +Class=35 +This=36 +While=37 +If=38 +Else=39 +For=40 +Return=41 +New=42 +CharValue=43 +IntValue=44 +BooleanValue=45 +NullValue=46 +Identifier=47 +WS=48 +InlineComment=49 +MultilineComment=50 +'++'=1 +'--'=2 +'void'=3 +'boolean'=4 +'char'=5 +'int'=6 +'public static void main(String[] args)'=8 +'='=13 +'+'=14 +'-'=15 +'*'=16 +'%'=17 +'/'=18 +'>'=19 +'<'=20 +'>='=21 +'<='=22 +'=='=23 +'!='=24 +'!'=25 +'&&'=26 +'||'=27 +'.'=28 +'('=29 +')'=30 +'{'=31 +'}'=32 +';'=33 +','=34 +'class'=35 +'this'=36 +'while'=37 +'if'=38 +'else'=39 +'for'=40 +'return'=41 +'new'=42 +'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaBaseListener.java b/src/main/java/parser/generated/SimpleJavaBaseListener.java index 342f385..2bf9ddd 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/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.ParserRuleContext; @@ -48,6 +48,18 @@ public class SimpleJavaBaseListener implements SimpleJavaListener { *

The default implementation does nothing.

*/ @Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} * @@ -72,18 +84,6 @@ 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} * @@ -113,25 +113,13 @@ public class SimpleJavaBaseListener implements SimpleJavaListener { * *

The default implementation does nothing.

*/ - @Override public void enterType(SimpleJavaParser.TypeContext ctx) { } + @Override public void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitType(SimpleJavaParser.TypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAccessType(SimpleJavaParser.AccessTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAccessType(SimpleJavaParser.AccessTypeContext ctx) { } + @Override public void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } /** * {@inheritDoc} * @@ -149,61 +137,13 @@ public class SimpleJavaBaseListener implements SimpleJavaListener { * *

The default implementation does nothing.

*/ - @Override public void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { } + @Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterVar(SimpleJavaParser.VarContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitVar(SimpleJavaParser.VarContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } + @Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { } /** * {@inheritDoc} * @@ -221,13 +161,109 @@ public class SimpleJavaBaseListener implements SimpleJavaListener { * *

The default implementation does nothing.

*/ - @Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { } + @Override public void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { } + @Override public void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterForStatement(SimpleJavaParser.ForStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitForStatement(SimpleJavaParser.ForStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssign(SimpleJavaParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssign(SimpleJavaParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } /** * {@inheritDoc} * @@ -245,37 +281,265 @@ public class SimpleJavaBaseListener implements SimpleJavaListener { * *

The default implementation does nothing.

*/ - @Override public void enterLiteral(SimpleJavaParser.LiteralContext ctx) { } + @Override public void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitLiteral(SimpleJavaParser.LiteralContext ctx) { } + @Override public void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { } + @Override public void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { } + @Override public void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { } + @Override public void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } /** * {@inheritDoc} * *

The default implementation does nothing.

*/ - @Override public void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { } + @Override public void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMethodCall(SimpleJavaParser.MethodCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMethodCall(SimpleJavaParser.MethodCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTarget(SimpleJavaParser.TargetContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTarget(SimpleJavaParser.TargetContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterType(SimpleJavaParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitType(SimpleJavaParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterValue(SimpleJavaParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitValue(SimpleJavaParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } /** * {@inheritDoc} diff --git a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java index 4feb7ea..92fb64c 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/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; @@ -33,6 +33,13 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} * @@ -47,13 +54,6 @@ 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} * @@ -74,14 +74,7 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAccessType(SimpleJavaParser.AccessTypeContext ctx) { return visitChildren(ctx); } + @Override public T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * @@ -95,35 +88,7 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitVar(SimpleJavaParser.VarContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); } + @Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * @@ -137,7 +102,63 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); } + @Override public T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitForStatement(SimpleJavaParser.ForStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssign(SimpleJavaParser.AssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * @@ -151,19 +172,152 @@ public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implem *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitLiteral(SimpleJavaParser.LiteralContext ctx) { return visitChildren(ctx); } + @Override public T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { return visitChildren(ctx); } + @Override public T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { return visitChildren(ctx); } + @Override public T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMethodCall(SimpleJavaParser.MethodCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTarget(SimpleJavaParser.TargetContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitValue(SimpleJavaParser.ValueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { return visitChildren(ctx); } } \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.interp b/src/main/java/parser/generated/SimpleJavaLexer.interp index e2f453d..919e1fd 100644 --- a/src/main/java/parser/generated/SimpleJavaLexer.interp +++ b/src/main/java/parser/generated/SimpleJavaLexer.interp @@ -1,40 +1,52 @@ token literal names: null -'class' -'{' -'}' -';' -'static' -'(' -')' -',' -'int' +'++' +'--' +'void' 'boolean' 'char' -'public' -'private' +'int' +null +'public static void main(String[] args)' +null +null +null +null '=' -'if' -'else' -'while' -'return' -'&&' -'||' -'==' -'!=' -'<' -'<=' -'>' -'>=' '+' '-' '*' -'/' '%' +'/' +'>' +'<' +'>=' +'<=' +'==' +'!=' '!' -'true' -'false' -'\'' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'for' +'return' +'new' +null +null +null +'null' +null null null null @@ -43,82 +55,109 @@ token symbolic names: null null null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -INTEGERLITERAL -IDENTIFIER +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Identifier WS +InlineComment +MultilineComment rule names: T__0 T__1 -T__2 -T__3 -T__4 -T__5 -T__6 -T__7 -T__8 -T__9 -T__10 -T__11 -T__12 -T__13 -T__14 -T__15 -T__16 -T__17 -T__18 -T__19 -T__20 -T__21 -T__22 -T__23 -T__24 -T__25 -T__26 -T__27 -T__28 -T__29 -T__30 -T__31 -T__32 -T__33 -T__34 -INTEGERLITERAL -IDENTIFIER +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Alphabetic +Numeric +ValidIdentSymbols +Identifier WS +InlineComment +MultilineComment channel names: DEFAULT_TOKEN_CHANNEL @@ -128,4 +167,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 38, 223, 6, -1, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 4, 35, 206, 8, 35, 11, 35, 12, 35, 207, 1, 36, 1, 36, 5, 36, 212, 8, 36, 10, 36, 12, 36, 215, 9, 36, 1, 37, 4, 37, 218, 8, 37, 11, 37, 12, 37, 219, 1, 37, 1, 37, 0, 0, 38, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 1, 0, 4, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 225, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 83, 1, 0, 0, 0, 5, 85, 1, 0, 0, 0, 7, 87, 1, 0, 0, 0, 9, 89, 1, 0, 0, 0, 11, 96, 1, 0, 0, 0, 13, 98, 1, 0, 0, 0, 15, 100, 1, 0, 0, 0, 17, 102, 1, 0, 0, 0, 19, 106, 1, 0, 0, 0, 21, 114, 1, 0, 0, 0, 23, 119, 1, 0, 0, 0, 25, 126, 1, 0, 0, 0, 27, 134, 1, 0, 0, 0, 29, 136, 1, 0, 0, 0, 31, 139, 1, 0, 0, 0, 33, 144, 1, 0, 0, 0, 35, 150, 1, 0, 0, 0, 37, 157, 1, 0, 0, 0, 39, 160, 1, 0, 0, 0, 41, 163, 1, 0, 0, 0, 43, 166, 1, 0, 0, 0, 45, 169, 1, 0, 0, 0, 47, 171, 1, 0, 0, 0, 49, 174, 1, 0, 0, 0, 51, 176, 1, 0, 0, 0, 53, 179, 1, 0, 0, 0, 55, 181, 1, 0, 0, 0, 57, 183, 1, 0, 0, 0, 59, 185, 1, 0, 0, 0, 61, 187, 1, 0, 0, 0, 63, 189, 1, 0, 0, 0, 65, 191, 1, 0, 0, 0, 67, 196, 1, 0, 0, 0, 69, 202, 1, 0, 0, 0, 71, 205, 1, 0, 0, 0, 73, 209, 1, 0, 0, 0, 75, 217, 1, 0, 0, 0, 77, 78, 5, 99, 0, 0, 78, 79, 5, 108, 0, 0, 79, 80, 5, 97, 0, 0, 80, 81, 5, 115, 0, 0, 81, 82, 5, 115, 0, 0, 82, 2, 1, 0, 0, 0, 83, 84, 5, 123, 0, 0, 84, 4, 1, 0, 0, 0, 85, 86, 5, 125, 0, 0, 86, 6, 1, 0, 0, 0, 87, 88, 5, 59, 0, 0, 88, 8, 1, 0, 0, 0, 89, 90, 5, 115, 0, 0, 90, 91, 5, 116, 0, 0, 91, 92, 5, 97, 0, 0, 92, 93, 5, 116, 0, 0, 93, 94, 5, 105, 0, 0, 94, 95, 5, 99, 0, 0, 95, 10, 1, 0, 0, 0, 96, 97, 5, 40, 0, 0, 97, 12, 1, 0, 0, 0, 98, 99, 5, 41, 0, 0, 99, 14, 1, 0, 0, 0, 100, 101, 5, 44, 0, 0, 101, 16, 1, 0, 0, 0, 102, 103, 5, 105, 0, 0, 103, 104, 5, 110, 0, 0, 104, 105, 5, 116, 0, 0, 105, 18, 1, 0, 0, 0, 106, 107, 5, 98, 0, 0, 107, 108, 5, 111, 0, 0, 108, 109, 5, 111, 0, 0, 109, 110, 5, 108, 0, 0, 110, 111, 5, 101, 0, 0, 111, 112, 5, 97, 0, 0, 112, 113, 5, 110, 0, 0, 113, 20, 1, 0, 0, 0, 114, 115, 5, 99, 0, 0, 115, 116, 5, 104, 0, 0, 116, 117, 5, 97, 0, 0, 117, 118, 5, 114, 0, 0, 118, 22, 1, 0, 0, 0, 119, 120, 5, 112, 0, 0, 120, 121, 5, 117, 0, 0, 121, 122, 5, 98, 0, 0, 122, 123, 5, 108, 0, 0, 123, 124, 5, 105, 0, 0, 124, 125, 5, 99, 0, 0, 125, 24, 1, 0, 0, 0, 126, 127, 5, 112, 0, 0, 127, 128, 5, 114, 0, 0, 128, 129, 5, 105, 0, 0, 129, 130, 5, 118, 0, 0, 130, 131, 5, 97, 0, 0, 131, 132, 5, 116, 0, 0, 132, 133, 5, 101, 0, 0, 133, 26, 1, 0, 0, 0, 134, 135, 5, 61, 0, 0, 135, 28, 1, 0, 0, 0, 136, 137, 5, 105, 0, 0, 137, 138, 5, 102, 0, 0, 138, 30, 1, 0, 0, 0, 139, 140, 5, 101, 0, 0, 140, 141, 5, 108, 0, 0, 141, 142, 5, 115, 0, 0, 142, 143, 5, 101, 0, 0, 143, 32, 1, 0, 0, 0, 144, 145, 5, 119, 0, 0, 145, 146, 5, 104, 0, 0, 146, 147, 5, 105, 0, 0, 147, 148, 5, 108, 0, 0, 148, 149, 5, 101, 0, 0, 149, 34, 1, 0, 0, 0, 150, 151, 5, 114, 0, 0, 151, 152, 5, 101, 0, 0, 152, 153, 5, 116, 0, 0, 153, 154, 5, 117, 0, 0, 154, 155, 5, 114, 0, 0, 155, 156, 5, 110, 0, 0, 156, 36, 1, 0, 0, 0, 157, 158, 5, 38, 0, 0, 158, 159, 5, 38, 0, 0, 159, 38, 1, 0, 0, 0, 160, 161, 5, 124, 0, 0, 161, 162, 5, 124, 0, 0, 162, 40, 1, 0, 0, 0, 163, 164, 5, 61, 0, 0, 164, 165, 5, 61, 0, 0, 165, 42, 1, 0, 0, 0, 166, 167, 5, 33, 0, 0, 167, 168, 5, 61, 0, 0, 168, 44, 1, 0, 0, 0, 169, 170, 5, 60, 0, 0, 170, 46, 1, 0, 0, 0, 171, 172, 5, 60, 0, 0, 172, 173, 5, 61, 0, 0, 173, 48, 1, 0, 0, 0, 174, 175, 5, 62, 0, 0, 175, 50, 1, 0, 0, 0, 176, 177, 5, 62, 0, 0, 177, 178, 5, 61, 0, 0, 178, 52, 1, 0, 0, 0, 179, 180, 5, 43, 0, 0, 180, 54, 1, 0, 0, 0, 181, 182, 5, 45, 0, 0, 182, 56, 1, 0, 0, 0, 183, 184, 5, 42, 0, 0, 184, 58, 1, 0, 0, 0, 185, 186, 5, 47, 0, 0, 186, 60, 1, 0, 0, 0, 187, 188, 5, 37, 0, 0, 188, 62, 1, 0, 0, 0, 189, 190, 5, 33, 0, 0, 190, 64, 1, 0, 0, 0, 191, 192, 5, 116, 0, 0, 192, 193, 5, 114, 0, 0, 193, 194, 5, 117, 0, 0, 194, 195, 5, 101, 0, 0, 195, 66, 1, 0, 0, 0, 196, 197, 5, 102, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, 108, 0, 0, 199, 200, 5, 115, 0, 0, 200, 201, 5, 101, 0, 0, 201, 68, 1, 0, 0, 0, 202, 203, 5, 39, 0, 0, 203, 70, 1, 0, 0, 0, 204, 206, 7, 0, 0, 0, 205, 204, 1, 0, 0, 0, 206, 207, 1, 0, 0, 0, 207, 205, 1, 0, 0, 0, 207, 208, 1, 0, 0, 0, 208, 72, 1, 0, 0, 0, 209, 213, 7, 1, 0, 0, 210, 212, 7, 2, 0, 0, 211, 210, 1, 0, 0, 0, 212, 215, 1, 0, 0, 0, 213, 211, 1, 0, 0, 0, 213, 214, 1, 0, 0, 0, 214, 74, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 216, 218, 7, 3, 0, 0, 217, 216, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 221, 1, 0, 0, 0, 221, 222, 6, 37, 0, 0, 222, 76, 1, 0, 0, 0, 4, 0, 207, 213, 219, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 50, 408, 6, -1, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 176, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 3, 8, 220, 8, 8, 1, 9, 1, 9, 3, 9, 224, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 3, 10, 232, 8, 10, 1, 11, 1, 11, 3, 11, 236, 8, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 5, 42, 330, 8, 42, 10, 42, 12, 42, 333, 9, 42, 1, 42, 1, 42, 1, 43, 3, 43, 338, 8, 43, 1, 43, 4, 43, 341, 8, 43, 11, 43, 12, 43, 342, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 354, 8, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 3, 48, 368, 8, 48, 1, 49, 1, 49, 5, 49, 372, 8, 49, 10, 49, 12, 49, 375, 9, 49, 1, 50, 4, 50, 378, 8, 50, 11, 50, 12, 50, 379, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 5, 51, 388, 8, 51, 10, 51, 12, 51, 391, 9, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 5, 52, 399, 8, 52, 10, 52, 12, 52, 402, 9, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 400, 0, 53, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 0, 95, 0, 97, 0, 99, 47, 101, 48, 103, 49, 105, 50, 1, 0, 5, 2, 0, 10, 10, 13, 13, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 2, 0, 36, 36, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 426, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 1, 107, 1, 0, 0, 0, 3, 110, 1, 0, 0, 0, 5, 113, 1, 0, 0, 0, 7, 118, 1, 0, 0, 0, 9, 126, 1, 0, 0, 0, 11, 131, 1, 0, 0, 0, 13, 175, 1, 0, 0, 0, 15, 177, 1, 0, 0, 0, 17, 219, 1, 0, 0, 0, 19, 223, 1, 0, 0, 0, 21, 231, 1, 0, 0, 0, 23, 235, 1, 0, 0, 0, 25, 237, 1, 0, 0, 0, 27, 239, 1, 0, 0, 0, 29, 241, 1, 0, 0, 0, 31, 243, 1, 0, 0, 0, 33, 245, 1, 0, 0, 0, 35, 247, 1, 0, 0, 0, 37, 249, 1, 0, 0, 0, 39, 251, 1, 0, 0, 0, 41, 253, 1, 0, 0, 0, 43, 256, 1, 0, 0, 0, 45, 259, 1, 0, 0, 0, 47, 262, 1, 0, 0, 0, 49, 265, 1, 0, 0, 0, 51, 267, 1, 0, 0, 0, 53, 270, 1, 0, 0, 0, 55, 273, 1, 0, 0, 0, 57, 275, 1, 0, 0, 0, 59, 277, 1, 0, 0, 0, 61, 279, 1, 0, 0, 0, 63, 281, 1, 0, 0, 0, 65, 283, 1, 0, 0, 0, 67, 285, 1, 0, 0, 0, 69, 287, 1, 0, 0, 0, 71, 293, 1, 0, 0, 0, 73, 298, 1, 0, 0, 0, 75, 304, 1, 0, 0, 0, 77, 307, 1, 0, 0, 0, 79, 312, 1, 0, 0, 0, 81, 316, 1, 0, 0, 0, 83, 323, 1, 0, 0, 0, 85, 327, 1, 0, 0, 0, 87, 337, 1, 0, 0, 0, 89, 353, 1, 0, 0, 0, 91, 355, 1, 0, 0, 0, 93, 360, 1, 0, 0, 0, 95, 362, 1, 0, 0, 0, 97, 367, 1, 0, 0, 0, 99, 369, 1, 0, 0, 0, 101, 377, 1, 0, 0, 0, 103, 383, 1, 0, 0, 0, 105, 394, 1, 0, 0, 0, 107, 108, 5, 43, 0, 0, 108, 109, 5, 43, 0, 0, 109, 2, 1, 0, 0, 0, 110, 111, 5, 45, 0, 0, 111, 112, 5, 45, 0, 0, 112, 4, 1, 0, 0, 0, 113, 114, 5, 118, 0, 0, 114, 115, 5, 111, 0, 0, 115, 116, 5, 105, 0, 0, 116, 117, 5, 100, 0, 0, 117, 6, 1, 0, 0, 0, 118, 119, 5, 98, 0, 0, 119, 120, 5, 111, 0, 0, 120, 121, 5, 111, 0, 0, 121, 122, 5, 108, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 110, 0, 0, 125, 8, 1, 0, 0, 0, 126, 127, 5, 99, 0, 0, 127, 128, 5, 104, 0, 0, 128, 129, 5, 97, 0, 0, 129, 130, 5, 114, 0, 0, 130, 10, 1, 0, 0, 0, 131, 132, 5, 105, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 116, 0, 0, 134, 12, 1, 0, 0, 0, 135, 136, 5, 112, 0, 0, 136, 137, 5, 117, 0, 0, 137, 138, 5, 98, 0, 0, 138, 139, 5, 108, 0, 0, 139, 140, 5, 105, 0, 0, 140, 176, 5, 99, 0, 0, 141, 142, 5, 112, 0, 0, 142, 143, 5, 114, 0, 0, 143, 144, 5, 105, 0, 0, 144, 145, 5, 118, 0, 0, 145, 146, 5, 97, 0, 0, 146, 147, 5, 116, 0, 0, 147, 176, 5, 101, 0, 0, 148, 149, 5, 112, 0, 0, 149, 150, 5, 117, 0, 0, 150, 151, 5, 98, 0, 0, 151, 152, 5, 108, 0, 0, 152, 153, 5, 105, 0, 0, 153, 154, 5, 99, 0, 0, 154, 155, 5, 32, 0, 0, 155, 156, 5, 115, 0, 0, 156, 157, 5, 116, 0, 0, 157, 158, 5, 97, 0, 0, 158, 159, 5, 116, 0, 0, 159, 160, 5, 105, 0, 0, 160, 176, 5, 99, 0, 0, 161, 162, 5, 112, 0, 0, 162, 163, 5, 114, 0, 0, 163, 164, 5, 105, 0, 0, 164, 165, 5, 118, 0, 0, 165, 166, 5, 97, 0, 0, 166, 167, 5, 116, 0, 0, 167, 168, 5, 101, 0, 0, 168, 169, 5, 32, 0, 0, 169, 170, 5, 115, 0, 0, 170, 171, 5, 116, 0, 0, 171, 172, 5, 97, 0, 0, 172, 173, 5, 116, 0, 0, 173, 174, 5, 105, 0, 0, 174, 176, 5, 99, 0, 0, 175, 135, 1, 0, 0, 0, 175, 141, 1, 0, 0, 0, 175, 148, 1, 0, 0, 0, 175, 161, 1, 0, 0, 0, 176, 14, 1, 0, 0, 0, 177, 178, 5, 112, 0, 0, 178, 179, 5, 117, 0, 0, 179, 180, 5, 98, 0, 0, 180, 181, 5, 108, 0, 0, 181, 182, 5, 105, 0, 0, 182, 183, 5, 99, 0, 0, 183, 184, 5, 32, 0, 0, 184, 185, 5, 115, 0, 0, 185, 186, 5, 116, 0, 0, 186, 187, 5, 97, 0, 0, 187, 188, 5, 116, 0, 0, 188, 189, 5, 105, 0, 0, 189, 190, 5, 99, 0, 0, 190, 191, 5, 32, 0, 0, 191, 192, 5, 118, 0, 0, 192, 193, 5, 111, 0, 0, 193, 194, 5, 105, 0, 0, 194, 195, 5, 100, 0, 0, 195, 196, 5, 32, 0, 0, 196, 197, 5, 109, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, 105, 0, 0, 199, 200, 5, 110, 0, 0, 200, 201, 5, 40, 0, 0, 201, 202, 5, 83, 0, 0, 202, 203, 5, 116, 0, 0, 203, 204, 5, 114, 0, 0, 204, 205, 5, 105, 0, 0, 205, 206, 5, 110, 0, 0, 206, 207, 5, 103, 0, 0, 207, 208, 5, 91, 0, 0, 208, 209, 5, 93, 0, 0, 209, 210, 5, 32, 0, 0, 210, 211, 5, 97, 0, 0, 211, 212, 5, 114, 0, 0, 212, 213, 5, 103, 0, 0, 213, 214, 5, 115, 0, 0, 214, 215, 5, 41, 0, 0, 215, 16, 1, 0, 0, 0, 216, 220, 3, 31, 15, 0, 217, 220, 3, 35, 17, 0, 218, 220, 3, 33, 16, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 218, 1, 0, 0, 0, 220, 18, 1, 0, 0, 0, 221, 224, 3, 27, 13, 0, 222, 224, 3, 29, 14, 0, 223, 221, 1, 0, 0, 0, 223, 222, 1, 0, 0, 0, 224, 20, 1, 0, 0, 0, 225, 232, 3, 37, 18, 0, 226, 232, 3, 39, 19, 0, 227, 232, 3, 41, 20, 0, 228, 232, 3, 43, 21, 0, 229, 232, 3, 45, 22, 0, 230, 232, 3, 47, 23, 0, 231, 225, 1, 0, 0, 0, 231, 226, 1, 0, 0, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 22, 1, 0, 0, 0, 233, 236, 3, 51, 25, 0, 234, 236, 3, 53, 26, 0, 235, 233, 1, 0, 0, 0, 235, 234, 1, 0, 0, 0, 236, 24, 1, 0, 0, 0, 237, 238, 5, 61, 0, 0, 238, 26, 1, 0, 0, 0, 239, 240, 5, 43, 0, 0, 240, 28, 1, 0, 0, 0, 241, 242, 5, 45, 0, 0, 242, 30, 1, 0, 0, 0, 243, 244, 5, 42, 0, 0, 244, 32, 1, 0, 0, 0, 245, 246, 5, 37, 0, 0, 246, 34, 1, 0, 0, 0, 247, 248, 5, 47, 0, 0, 248, 36, 1, 0, 0, 0, 249, 250, 5, 62, 0, 0, 250, 38, 1, 0, 0, 0, 251, 252, 5, 60, 0, 0, 252, 40, 1, 0, 0, 0, 253, 254, 5, 62, 0, 0, 254, 255, 5, 61, 0, 0, 255, 42, 1, 0, 0, 0, 256, 257, 5, 60, 0, 0, 257, 258, 5, 61, 0, 0, 258, 44, 1, 0, 0, 0, 259, 260, 5, 61, 0, 0, 260, 261, 5, 61, 0, 0, 261, 46, 1, 0, 0, 0, 262, 263, 5, 33, 0, 0, 263, 264, 5, 61, 0, 0, 264, 48, 1, 0, 0, 0, 265, 266, 5, 33, 0, 0, 266, 50, 1, 0, 0, 0, 267, 268, 5, 38, 0, 0, 268, 269, 5, 38, 0, 0, 269, 52, 1, 0, 0, 0, 270, 271, 5, 124, 0, 0, 271, 272, 5, 124, 0, 0, 272, 54, 1, 0, 0, 0, 273, 274, 5, 46, 0, 0, 274, 56, 1, 0, 0, 0, 275, 276, 5, 40, 0, 0, 276, 58, 1, 0, 0, 0, 277, 278, 5, 41, 0, 0, 278, 60, 1, 0, 0, 0, 279, 280, 5, 123, 0, 0, 280, 62, 1, 0, 0, 0, 281, 282, 5, 125, 0, 0, 282, 64, 1, 0, 0, 0, 283, 284, 5, 59, 0, 0, 284, 66, 1, 0, 0, 0, 285, 286, 5, 44, 0, 0, 286, 68, 1, 0, 0, 0, 287, 288, 5, 99, 0, 0, 288, 289, 5, 108, 0, 0, 289, 290, 5, 97, 0, 0, 290, 291, 5, 115, 0, 0, 291, 292, 5, 115, 0, 0, 292, 70, 1, 0, 0, 0, 293, 294, 5, 116, 0, 0, 294, 295, 5, 104, 0, 0, 295, 296, 5, 105, 0, 0, 296, 297, 5, 115, 0, 0, 297, 72, 1, 0, 0, 0, 298, 299, 5, 119, 0, 0, 299, 300, 5, 104, 0, 0, 300, 301, 5, 105, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 101, 0, 0, 303, 74, 1, 0, 0, 0, 304, 305, 5, 105, 0, 0, 305, 306, 5, 102, 0, 0, 306, 76, 1, 0, 0, 0, 307, 308, 5, 101, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 115, 0, 0, 310, 311, 5, 101, 0, 0, 311, 78, 1, 0, 0, 0, 312, 313, 5, 102, 0, 0, 313, 314, 5, 111, 0, 0, 314, 315, 5, 114, 0, 0, 315, 80, 1, 0, 0, 0, 316, 317, 5, 114, 0, 0, 317, 318, 5, 101, 0, 0, 318, 319, 5, 116, 0, 0, 319, 320, 5, 117, 0, 0, 320, 321, 5, 114, 0, 0, 321, 322, 5, 110, 0, 0, 322, 82, 1, 0, 0, 0, 323, 324, 5, 110, 0, 0, 324, 325, 5, 101, 0, 0, 325, 326, 5, 119, 0, 0, 326, 84, 1, 0, 0, 0, 327, 331, 5, 39, 0, 0, 328, 330, 8, 0, 0, 0, 329, 328, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 334, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 39, 0, 0, 335, 86, 1, 0, 0, 0, 336, 338, 3, 29, 14, 0, 337, 336, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 340, 1, 0, 0, 0, 339, 341, 3, 95, 47, 0, 340, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 340, 1, 0, 0, 0, 342, 343, 1, 0, 0, 0, 343, 88, 1, 0, 0, 0, 344, 345, 5, 116, 0, 0, 345, 346, 5, 114, 0, 0, 346, 347, 5, 117, 0, 0, 347, 354, 5, 101, 0, 0, 348, 349, 5, 102, 0, 0, 349, 350, 5, 97, 0, 0, 350, 351, 5, 108, 0, 0, 351, 352, 5, 115, 0, 0, 352, 354, 5, 101, 0, 0, 353, 344, 1, 0, 0, 0, 353, 348, 1, 0, 0, 0, 354, 90, 1, 0, 0, 0, 355, 356, 5, 110, 0, 0, 356, 357, 5, 117, 0, 0, 357, 358, 5, 108, 0, 0, 358, 359, 5, 108, 0, 0, 359, 92, 1, 0, 0, 0, 360, 361, 7, 1, 0, 0, 361, 94, 1, 0, 0, 0, 362, 363, 7, 2, 0, 0, 363, 96, 1, 0, 0, 0, 364, 368, 3, 93, 46, 0, 365, 368, 3, 95, 47, 0, 366, 368, 7, 3, 0, 0, 367, 364, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 367, 366, 1, 0, 0, 0, 368, 98, 1, 0, 0, 0, 369, 373, 3, 93, 46, 0, 370, 372, 3, 97, 48, 0, 371, 370, 1, 0, 0, 0, 372, 375, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 373, 374, 1, 0, 0, 0, 374, 100, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 376, 378, 7, 4, 0, 0, 377, 376, 1, 0, 0, 0, 378, 379, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 6, 50, 0, 0, 382, 102, 1, 0, 0, 0, 383, 384, 5, 47, 0, 0, 384, 385, 5, 47, 0, 0, 385, 389, 1, 0, 0, 0, 386, 388, 8, 0, 0, 0, 387, 386, 1, 0, 0, 0, 388, 391, 1, 0, 0, 0, 389, 387, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 392, 1, 0, 0, 0, 391, 389, 1, 0, 0, 0, 392, 393, 6, 51, 0, 0, 393, 104, 1, 0, 0, 0, 394, 395, 5, 47, 0, 0, 395, 396, 5, 42, 0, 0, 396, 400, 1, 0, 0, 0, 397, 399, 9, 0, 0, 0, 398, 397, 1, 0, 0, 0, 399, 402, 1, 0, 0, 0, 400, 401, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 403, 1, 0, 0, 0, 402, 400, 1, 0, 0, 0, 403, 404, 5, 42, 0, 0, 404, 405, 5, 47, 0, 0, 405, 406, 1, 0, 0, 0, 406, 407, 6, 52, 0, 0, 407, 106, 1, 0, 0, 0, 15, 0, 175, 219, 223, 231, 235, 331, 337, 342, 353, 367, 373, 379, 389, 400, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.java b/src/main/java/parser/generated/SimpleJavaLexer.java index 979b0a4..cb01452 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/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; @@ -17,12 +17,15 @@ public class SimpleJavaLexer extends Lexer { protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, INTEGERLITERAL=36, IDENTIFIER=37, - WS=38; + T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, + DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, + Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, + Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, + And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, + ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, + If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, + BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, + MultilineComment=50; public static String[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" }; @@ -33,31 +36,40 @@ public class SimpleJavaLexer extends Lexer { private static String[] makeRuleNames() { return new String[] { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", - "T__33", "T__34", "INTEGERLITERAL", "IDENTIFIER", "WS" + "T__0", "T__1", "Void", "Boolean", "Char", "Int", "AccessModifier", "MainMethodDeclaration", + "DotOperator", "LineOperator", "ComparisonOperator", "LogicalOperator", + "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", "Greater", "Less", + "GreaterEqual", "LessEqual", "Equal", "NotEqual", "Not", "And", "Or", + "Dot", "OpenRoundBracket", "ClosedRoundBracket", "OpenCurlyBracket", + "ClosedCurlyBracket", "Semicolon", "Comma", "Class", "This", "While", + "If", "Else", "For", "Return", "New", "CharValue", "IntValue", "BooleanValue", + "NullValue", "Alphabetic", "Numeric", "ValidIdentSymbols", "Identifier", + "WS", "InlineComment", "MultilineComment" }; } public static final String[] ruleNames = makeRuleNames(); private static String[] makeLiteralNames() { return new String[] { - null, "'class'", "'{'", "'}'", "';'", "'static'", "'('", "')'", "','", - "'int'", "'boolean'", "'char'", "'public'", "'private'", "'='", "'if'", - "'else'", "'while'", "'return'", "'&&'", "'||'", "'=='", "'!='", "'<'", - "'<='", "'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'true'", - "'false'", "'''" + null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, + "'public static void main(String[] args)'", null, null, null, null, "'='", + "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", + "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", + "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", + "'new'", null, null, null, "'null'" }; } private static final String[] _LITERAL_NAMES = makeLiteralNames(); private static String[] makeSymbolicNames() { return new String[] { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - "INTEGERLITERAL", "IDENTIFIER", "WS" + null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", + "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", + "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", + "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", + "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", + "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" }; } private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); @@ -119,7 +131,7 @@ public class SimpleJavaLexer extends Lexer { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\u0004\u0000&\u00df\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ + "\u0004\u00002\u0198\u0006\uffff\uffff\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"+ @@ -130,43 +142,67 @@ public class SimpleJavaLexer extends Lexer { "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ - "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0001\u0000"+ - "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ - "\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004"+ - "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+ - "\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007"+ - "\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+ - "\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+ - "\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+ - "\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f"+ - "\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ - "\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001"+ - "\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001"+ - "\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001"+ - "\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001"+ - "\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+ - "\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001"+ - "\u0019\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001"+ - "\u001b\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+ - "\u001e\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001"+ - "!\u0001!\u0001!\u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001#\u0004#\u00ce"+ - "\b#\u000b#\f#\u00cf\u0001$\u0001$\u0005$\u00d4\b$\n$\f$\u00d7\t$\u0001"+ - "%\u0004%\u00da\b%\u000b%\f%\u00db\u0001%\u0001%\u0000\u0000&\u0001\u0001"+ + "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ + "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ + "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+ + "0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u0001\u0000"+ + "\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0003\u0006\u00b0\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\b\u0001\b\u0001\b\u0003\b\u00dc\b\b\u0001\t\u0001\t\u0003\t\u00e0"+ + "\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003\n\u00e8\b\n"+ + "\u0001\u000b\u0001\u000b\u0003\u000b\u00ec\b\u000b\u0001\f\u0001\f\u0001"+ + "\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+ + "\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+ + "\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+ + "\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017"+ + "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ + "\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001c"+ + "\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f"+ + "\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001$\u0001"+ + "$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001"+ + "&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001"+ + "(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0005*\u014a"+ + "\b*\n*\f*\u014d\t*\u0001*\u0001*\u0001+\u0003+\u0152\b+\u0001+\u0004+"+ + "\u0155\b+\u000b+\f+\u0156\u0001,\u0001,\u0001,\u0001,\u0001,\u0001,\u0001"+ + ",\u0001,\u0001,\u0003,\u0162\b,\u0001-\u0001-\u0001-\u0001-\u0001-\u0001"+ + ".\u0001.\u0001/\u0001/\u00010\u00010\u00010\u00030\u0170\b0\u00011\u0001"+ + "1\u00051\u0174\b1\n1\f1\u0177\t1\u00012\u00042\u017a\b2\u000b2\f2\u017b"+ + "\u00012\u00012\u00013\u00013\u00013\u00013\u00053\u0184\b3\n3\f3\u0187"+ + "\t3\u00013\u00013\u00014\u00014\u00014\u00014\u00054\u018f\b4\n4\f4\u0192"+ + "\t4\u00014\u00014\u00014\u00014\u00014\u0001\u0190\u00005\u0001\u0001"+ "\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+ "\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f"+ "\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u0018"+ - "1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&\u0001"+ - "\u0000\u0004\u0001\u000009\u0002\u0000AZaz\u0004\u000009AZ__az\u0003\u0000"+ - "\t\n\r\r \u00e1\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001"+ - "\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001"+ - "\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000"+ - "\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000"+ - "\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000"+ - "\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000"+ - "\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000"+ - "\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000"+ - "\u0000\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000"+ - "%\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+ + "1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\'O("+ + "Q)S*U+W,Y-[.]\u0000_\u0000a\u0000c/e0g1i2\u0001\u0000\u0005\u0002\u0000"+ + "\n\n\r\r\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0003\u0000\t\n"+ + "\r\r \u01aa\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000"+ + "\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000"+ + "\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000"+ + "\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000"+ + "\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000"+ + "\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000"+ + "\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000"+ + "\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000"+ + "\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%"+ + "\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+ "\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000"+ "\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u0000"+ "3\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001"+ @@ -174,84 +210,179 @@ public class SimpleJavaLexer extends Lexer { "\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001\u0000\u0000\u0000\u0000"+ "A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+ "\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+ - "\u0000\u0000K\u0001\u0000\u0000\u0000\u0001M\u0001\u0000\u0000\u0000\u0003"+ - "S\u0001\u0000\u0000\u0000\u0005U\u0001\u0000\u0000\u0000\u0007W\u0001"+ - "\u0000\u0000\u0000\tY\u0001\u0000\u0000\u0000\u000b`\u0001\u0000\u0000"+ - "\u0000\rb\u0001\u0000\u0000\u0000\u000fd\u0001\u0000\u0000\u0000\u0011"+ - "f\u0001\u0000\u0000\u0000\u0013j\u0001\u0000\u0000\u0000\u0015r\u0001"+ - "\u0000\u0000\u0000\u0017w\u0001\u0000\u0000\u0000\u0019~\u0001\u0000\u0000"+ - "\u0000\u001b\u0086\u0001\u0000\u0000\u0000\u001d\u0088\u0001\u0000\u0000"+ - "\u0000\u001f\u008b\u0001\u0000\u0000\u0000!\u0090\u0001\u0000\u0000\u0000"+ - "#\u0096\u0001\u0000\u0000\u0000%\u009d\u0001\u0000\u0000\u0000\'\u00a0"+ - "\u0001\u0000\u0000\u0000)\u00a3\u0001\u0000\u0000\u0000+\u00a6\u0001\u0000"+ - "\u0000\u0000-\u00a9\u0001\u0000\u0000\u0000/\u00ab\u0001\u0000\u0000\u0000"+ - "1\u00ae\u0001\u0000\u0000\u00003\u00b0\u0001\u0000\u0000\u00005\u00b3"+ - "\u0001\u0000\u0000\u00007\u00b5\u0001\u0000\u0000\u00009\u00b7\u0001\u0000"+ - "\u0000\u0000;\u00b9\u0001\u0000\u0000\u0000=\u00bb\u0001\u0000\u0000\u0000"+ - "?\u00bd\u0001\u0000\u0000\u0000A\u00bf\u0001\u0000\u0000\u0000C\u00c4"+ - "\u0001\u0000\u0000\u0000E\u00ca\u0001\u0000\u0000\u0000G\u00cd\u0001\u0000"+ - "\u0000\u0000I\u00d1\u0001\u0000\u0000\u0000K\u00d9\u0001\u0000\u0000\u0000"+ - "MN\u0005c\u0000\u0000NO\u0005l\u0000\u0000OP\u0005a\u0000\u0000PQ\u0005"+ - "s\u0000\u0000QR\u0005s\u0000\u0000R\u0002\u0001\u0000\u0000\u0000ST\u0005"+ - "{\u0000\u0000T\u0004\u0001\u0000\u0000\u0000UV\u0005}\u0000\u0000V\u0006"+ - "\u0001\u0000\u0000\u0000WX\u0005;\u0000\u0000X\b\u0001\u0000\u0000\u0000"+ - "YZ\u0005s\u0000\u0000Z[\u0005t\u0000\u0000[\\\u0005a\u0000\u0000\\]\u0005"+ - "t\u0000\u0000]^\u0005i\u0000\u0000^_\u0005c\u0000\u0000_\n\u0001\u0000"+ - "\u0000\u0000`a\u0005(\u0000\u0000a\f\u0001\u0000\u0000\u0000bc\u0005)"+ - "\u0000\u0000c\u000e\u0001\u0000\u0000\u0000de\u0005,\u0000\u0000e\u0010"+ - "\u0001\u0000\u0000\u0000fg\u0005i\u0000\u0000gh\u0005n\u0000\u0000hi\u0005"+ - "t\u0000\u0000i\u0012\u0001\u0000\u0000\u0000jk\u0005b\u0000\u0000kl\u0005"+ - "o\u0000\u0000lm\u0005o\u0000\u0000mn\u0005l\u0000\u0000no\u0005e\u0000"+ - "\u0000op\u0005a\u0000\u0000pq\u0005n\u0000\u0000q\u0014\u0001\u0000\u0000"+ - "\u0000rs\u0005c\u0000\u0000st\u0005h\u0000\u0000tu\u0005a\u0000\u0000"+ - "uv\u0005r\u0000\u0000v\u0016\u0001\u0000\u0000\u0000wx\u0005p\u0000\u0000"+ - "xy\u0005u\u0000\u0000yz\u0005b\u0000\u0000z{\u0005l\u0000\u0000{|\u0005"+ - "i\u0000\u0000|}\u0005c\u0000\u0000}\u0018\u0001\u0000\u0000\u0000~\u007f"+ - "\u0005p\u0000\u0000\u007f\u0080\u0005r\u0000\u0000\u0080\u0081\u0005i"+ - "\u0000\u0000\u0081\u0082\u0005v\u0000\u0000\u0082\u0083\u0005a\u0000\u0000"+ - "\u0083\u0084\u0005t\u0000\u0000\u0084\u0085\u0005e\u0000\u0000\u0085\u001a"+ - "\u0001\u0000\u0000\u0000\u0086\u0087\u0005=\u0000\u0000\u0087\u001c\u0001"+ - "\u0000\u0000\u0000\u0088\u0089\u0005i\u0000\u0000\u0089\u008a\u0005f\u0000"+ - "\u0000\u008a\u001e\u0001\u0000\u0000\u0000\u008b\u008c\u0005e\u0000\u0000"+ - "\u008c\u008d\u0005l\u0000\u0000\u008d\u008e\u0005s\u0000\u0000\u008e\u008f"+ - "\u0005e\u0000\u0000\u008f \u0001\u0000\u0000\u0000\u0090\u0091\u0005w"+ - "\u0000\u0000\u0091\u0092\u0005h\u0000\u0000\u0092\u0093\u0005i\u0000\u0000"+ - "\u0093\u0094\u0005l\u0000\u0000\u0094\u0095\u0005e\u0000\u0000\u0095\""+ - "\u0001\u0000\u0000\u0000\u0096\u0097\u0005r\u0000\u0000\u0097\u0098\u0005"+ - "e\u0000\u0000\u0098\u0099\u0005t\u0000\u0000\u0099\u009a\u0005u\u0000"+ - "\u0000\u009a\u009b\u0005r\u0000\u0000\u009b\u009c\u0005n\u0000\u0000\u009c"+ - "$\u0001\u0000\u0000\u0000\u009d\u009e\u0005&\u0000\u0000\u009e\u009f\u0005"+ - "&\u0000\u0000\u009f&\u0001\u0000\u0000\u0000\u00a0\u00a1\u0005|\u0000"+ - "\u0000\u00a1\u00a2\u0005|\u0000\u0000\u00a2(\u0001\u0000\u0000\u0000\u00a3"+ - "\u00a4\u0005=\u0000\u0000\u00a4\u00a5\u0005=\u0000\u0000\u00a5*\u0001"+ - "\u0000\u0000\u0000\u00a6\u00a7\u0005!\u0000\u0000\u00a7\u00a8\u0005=\u0000"+ - "\u0000\u00a8,\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005<\u0000\u0000\u00aa"+ - ".\u0001\u0000\u0000\u0000\u00ab\u00ac\u0005<\u0000\u0000\u00ac\u00ad\u0005"+ - "=\u0000\u0000\u00ad0\u0001\u0000\u0000\u0000\u00ae\u00af\u0005>\u0000"+ - "\u0000\u00af2\u0001\u0000\u0000\u0000\u00b0\u00b1\u0005>\u0000\u0000\u00b1"+ - "\u00b2\u0005=\u0000\u0000\u00b24\u0001\u0000\u0000\u0000\u00b3\u00b4\u0005"+ - "+\u0000\u0000\u00b46\u0001\u0000\u0000\u0000\u00b5\u00b6\u0005-\u0000"+ - "\u0000\u00b68\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005*\u0000\u0000\u00b8"+ - ":\u0001\u0000\u0000\u0000\u00b9\u00ba\u0005/\u0000\u0000\u00ba<\u0001"+ - "\u0000\u0000\u0000\u00bb\u00bc\u0005%\u0000\u0000\u00bc>\u0001\u0000\u0000"+ - "\u0000\u00bd\u00be\u0005!\u0000\u0000\u00be@\u0001\u0000\u0000\u0000\u00bf"+ - "\u00c0\u0005t\u0000\u0000\u00c0\u00c1\u0005r\u0000\u0000\u00c1\u00c2\u0005"+ - "u\u0000\u0000\u00c2\u00c3\u0005e\u0000\u0000\u00c3B\u0001\u0000\u0000"+ - "\u0000\u00c4\u00c5\u0005f\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6"+ - "\u00c7\u0005l\u0000\u0000\u00c7\u00c8\u0005s\u0000\u0000\u00c8\u00c9\u0005"+ - "e\u0000\u0000\u00c9D\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005\'\u0000"+ - "\u0000\u00cbF\u0001\u0000\u0000\u0000\u00cc\u00ce\u0007\u0000\u0000\u0000"+ - "\u00cd\u00cc\u0001\u0000\u0000\u0000\u00ce\u00cf\u0001\u0000\u0000\u0000"+ - "\u00cf\u00cd\u0001\u0000\u0000\u0000\u00cf\u00d0\u0001\u0000\u0000\u0000"+ - "\u00d0H\u0001\u0000\u0000\u0000\u00d1\u00d5\u0007\u0001\u0000\u0000\u00d2"+ - "\u00d4\u0007\u0002\u0000\u0000\u00d3\u00d2\u0001\u0000\u0000\u0000\u00d4"+ - "\u00d7\u0001\u0000\u0000\u0000\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d5"+ - "\u00d6\u0001\u0000\u0000\u0000\u00d6J\u0001\u0000\u0000\u0000\u00d7\u00d5"+ - "\u0001\u0000\u0000\u0000\u00d8\u00da\u0007\u0003\u0000\u0000\u00d9\u00d8"+ - "\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00d9"+ - "\u0001\u0000\u0000\u0000\u00db\u00dc\u0001\u0000\u0000\u0000\u00dc\u00dd"+ - "\u0001\u0000\u0000\u0000\u00dd\u00de\u0006%\u0000\u0000\u00deL\u0001\u0000"+ - "\u0000\u0000\u0004\u0000\u00cf\u00d5\u00db\u0001\u0006\u0000\u0000"; + "\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+ + "O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+ + "\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+ + "\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+ + "c\u0001\u0000\u0000\u0000\u0000e\u0001\u0000\u0000\u0000\u0000g\u0001"+ + "\u0000\u0000\u0000\u0000i\u0001\u0000\u0000\u0000\u0001k\u0001\u0000\u0000"+ + "\u0000\u0003n\u0001\u0000\u0000\u0000\u0005q\u0001\u0000\u0000\u0000\u0007"+ + "v\u0001\u0000\u0000\u0000\t~\u0001\u0000\u0000\u0000\u000b\u0083\u0001"+ + "\u0000\u0000\u0000\r\u00af\u0001\u0000\u0000\u0000\u000f\u00b1\u0001\u0000"+ + "\u0000\u0000\u0011\u00db\u0001\u0000\u0000\u0000\u0013\u00df\u0001\u0000"+ + "\u0000\u0000\u0015\u00e7\u0001\u0000\u0000\u0000\u0017\u00eb\u0001\u0000"+ + "\u0000\u0000\u0019\u00ed\u0001\u0000\u0000\u0000\u001b\u00ef\u0001\u0000"+ + "\u0000\u0000\u001d\u00f1\u0001\u0000\u0000\u0000\u001f\u00f3\u0001\u0000"+ + "\u0000\u0000!\u00f5\u0001\u0000\u0000\u0000#\u00f7\u0001\u0000\u0000\u0000"+ + "%\u00f9\u0001\u0000\u0000\u0000\'\u00fb\u0001\u0000\u0000\u0000)\u00fd"+ + "\u0001\u0000\u0000\u0000+\u0100\u0001\u0000\u0000\u0000-\u0103\u0001\u0000"+ + "\u0000\u0000/\u0106\u0001\u0000\u0000\u00001\u0109\u0001\u0000\u0000\u0000"+ + "3\u010b\u0001\u0000\u0000\u00005\u010e\u0001\u0000\u0000\u00007\u0111"+ + "\u0001\u0000\u0000\u00009\u0113\u0001\u0000\u0000\u0000;\u0115\u0001\u0000"+ + "\u0000\u0000=\u0117\u0001\u0000\u0000\u0000?\u0119\u0001\u0000\u0000\u0000"+ + "A\u011b\u0001\u0000\u0000\u0000C\u011d\u0001\u0000\u0000\u0000E\u011f"+ + "\u0001\u0000\u0000\u0000G\u0125\u0001\u0000\u0000\u0000I\u012a\u0001\u0000"+ + "\u0000\u0000K\u0130\u0001\u0000\u0000\u0000M\u0133\u0001\u0000\u0000\u0000"+ + "O\u0138\u0001\u0000\u0000\u0000Q\u013c\u0001\u0000\u0000\u0000S\u0143"+ + "\u0001\u0000\u0000\u0000U\u0147\u0001\u0000\u0000\u0000W\u0151\u0001\u0000"+ + "\u0000\u0000Y\u0161\u0001\u0000\u0000\u0000[\u0163\u0001\u0000\u0000\u0000"+ + "]\u0168\u0001\u0000\u0000\u0000_\u016a\u0001\u0000\u0000\u0000a\u016f"+ + "\u0001\u0000\u0000\u0000c\u0171\u0001\u0000\u0000\u0000e\u0179\u0001\u0000"+ + "\u0000\u0000g\u017f\u0001\u0000\u0000\u0000i\u018a\u0001\u0000\u0000\u0000"+ + "kl\u0005+\u0000\u0000lm\u0005+\u0000\u0000m\u0002\u0001\u0000\u0000\u0000"+ + "no\u0005-\u0000\u0000op\u0005-\u0000\u0000p\u0004\u0001\u0000\u0000\u0000"+ + "qr\u0005v\u0000\u0000rs\u0005o\u0000\u0000st\u0005i\u0000\u0000tu\u0005"+ + "d\u0000\u0000u\u0006\u0001\u0000\u0000\u0000vw\u0005b\u0000\u0000wx\u0005"+ + "o\u0000\u0000xy\u0005o\u0000\u0000yz\u0005l\u0000\u0000z{\u0005e\u0000"+ + "\u0000{|\u0005a\u0000\u0000|}\u0005n\u0000\u0000}\b\u0001\u0000\u0000"+ + "\u0000~\u007f\u0005c\u0000\u0000\u007f\u0080\u0005h\u0000\u0000\u0080"+ + "\u0081\u0005a\u0000\u0000\u0081\u0082\u0005r\u0000\u0000\u0082\n\u0001"+ + "\u0000\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+ + "\u0000\u0085\u0086\u0005t\u0000\u0000\u0086\f\u0001\u0000\u0000\u0000"+ + "\u0087\u0088\u0005p\u0000\u0000\u0088\u0089\u0005u\u0000\u0000\u0089\u008a"+ + "\u0005b\u0000\u0000\u008a\u008b\u0005l\u0000\u0000\u008b\u008c\u0005i"+ + "\u0000\u0000\u008c\u00b0\u0005c\u0000\u0000\u008d\u008e\u0005p\u0000\u0000"+ + "\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005i\u0000\u0000\u0090\u0091"+ + "\u0005v\u0000\u0000\u0091\u0092\u0005a\u0000\u0000\u0092\u0093\u0005t"+ + "\u0000\u0000\u0093\u00b0\u0005e\u0000\u0000\u0094\u0095\u0005p\u0000\u0000"+ + "\u0095\u0096\u0005u\u0000\u0000\u0096\u0097\u0005b\u0000\u0000\u0097\u0098"+ + "\u0005l\u0000\u0000\u0098\u0099\u0005i\u0000\u0000\u0099\u009a\u0005c"+ + "\u0000\u0000\u009a\u009b\u0005 \u0000\u0000\u009b\u009c\u0005s\u0000\u0000"+ + "\u009c\u009d\u0005t\u0000\u0000\u009d\u009e\u0005a\u0000\u0000\u009e\u009f"+ + "\u0005t\u0000\u0000\u009f\u00a0\u0005i\u0000\u0000\u00a0\u00b0\u0005c"+ + "\u0000\u0000\u00a1\u00a2\u0005p\u0000\u0000\u00a2\u00a3\u0005r\u0000\u0000"+ + "\u00a3\u00a4\u0005i\u0000\u0000\u00a4\u00a5\u0005v\u0000\u0000\u00a5\u00a6"+ + "\u0005a\u0000\u0000\u00a6\u00a7\u0005t\u0000\u0000\u00a7\u00a8\u0005e"+ + "\u0000\u0000\u00a8\u00a9\u0005 \u0000\u0000\u00a9\u00aa\u0005s\u0000\u0000"+ + "\u00aa\u00ab\u0005t\u0000\u0000\u00ab\u00ac\u0005a\u0000\u0000\u00ac\u00ad"+ + "\u0005t\u0000\u0000\u00ad\u00ae\u0005i\u0000\u0000\u00ae\u00b0\u0005c"+ + "\u0000\u0000\u00af\u0087\u0001\u0000\u0000\u0000\u00af\u008d\u0001\u0000"+ + "\u0000\u0000\u00af\u0094\u0001\u0000\u0000\u0000\u00af\u00a1\u0001\u0000"+ + "\u0000\u0000\u00b0\u000e\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005p\u0000"+ + "\u0000\u00b2\u00b3\u0005u\u0000\u0000\u00b3\u00b4\u0005b\u0000\u0000\u00b4"+ + "\u00b5\u0005l\u0000\u0000\u00b5\u00b6\u0005i\u0000\u0000\u00b6\u00b7\u0005"+ + "c\u0000\u0000\u00b7\u00b8\u0005 \u0000\u0000\u00b8\u00b9\u0005s\u0000"+ + "\u0000\u00b9\u00ba\u0005t\u0000\u0000\u00ba\u00bb\u0005a\u0000\u0000\u00bb"+ + "\u00bc\u0005t\u0000\u0000\u00bc\u00bd\u0005i\u0000\u0000\u00bd\u00be\u0005"+ + "c\u0000\u0000\u00be\u00bf\u0005 \u0000\u0000\u00bf\u00c0\u0005v\u0000"+ + "\u0000\u00c0\u00c1\u0005o\u0000\u0000\u00c1\u00c2\u0005i\u0000\u0000\u00c2"+ + "\u00c3\u0005d\u0000\u0000\u00c3\u00c4\u0005 \u0000\u0000\u00c4\u00c5\u0005"+ + "m\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6\u00c7\u0005i\u0000"+ + "\u0000\u00c7\u00c8\u0005n\u0000\u0000\u00c8\u00c9\u0005(\u0000\u0000\u00c9"+ + "\u00ca\u0005S\u0000\u0000\u00ca\u00cb\u0005t\u0000\u0000\u00cb\u00cc\u0005"+ + "r\u0000\u0000\u00cc\u00cd\u0005i\u0000\u0000\u00cd\u00ce\u0005n\u0000"+ + "\u0000\u00ce\u00cf\u0005g\u0000\u0000\u00cf\u00d0\u0005[\u0000\u0000\u00d0"+ + "\u00d1\u0005]\u0000\u0000\u00d1\u00d2\u0005 \u0000\u0000\u00d2\u00d3\u0005"+ + "a\u0000\u0000\u00d3\u00d4\u0005r\u0000\u0000\u00d4\u00d5\u0005g\u0000"+ + "\u0000\u00d5\u00d6\u0005s\u0000\u0000\u00d6\u00d7\u0005)\u0000\u0000\u00d7"+ + "\u0010\u0001\u0000\u0000\u0000\u00d8\u00dc\u0003\u001f\u000f\u0000\u00d9"+ + "\u00dc\u0003#\u0011\u0000\u00da\u00dc\u0003!\u0010\u0000\u00db\u00d8\u0001"+ + "\u0000\u0000\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00db\u00da\u0001"+ + "\u0000\u0000\u0000\u00dc\u0012\u0001\u0000\u0000\u0000\u00dd\u00e0\u0003"+ + "\u001b\r\u0000\u00de\u00e0\u0003\u001d\u000e\u0000\u00df\u00dd\u0001\u0000"+ + "\u0000\u0000\u00df\u00de\u0001\u0000\u0000\u0000\u00e0\u0014\u0001\u0000"+ + "\u0000\u0000\u00e1\u00e8\u0003%\u0012\u0000\u00e2\u00e8\u0003\'\u0013"+ + "\u0000\u00e3\u00e8\u0003)\u0014\u0000\u00e4\u00e8\u0003+\u0015\u0000\u00e5"+ + "\u00e8\u0003-\u0016\u0000\u00e6\u00e8\u0003/\u0017\u0000\u00e7\u00e1\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e2\u0001\u0000\u0000\u0000\u00e7\u00e3\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e4\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e6\u0001\u0000\u0000\u0000\u00e8\u0016\u0001"+ + "\u0000\u0000\u0000\u00e9\u00ec\u00033\u0019\u0000\u00ea\u00ec\u00035\u001a"+ + "\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb\u00ea\u0001\u0000\u0000"+ + "\u0000\u00ec\u0018\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005=\u0000\u0000"+ + "\u00ee\u001a\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005+\u0000\u0000\u00f0"+ + "\u001c\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005-\u0000\u0000\u00f2\u001e"+ + "\u0001\u0000\u0000\u0000\u00f3\u00f4\u0005*\u0000\u0000\u00f4 \u0001\u0000"+ + "\u0000\u0000\u00f5\u00f6\u0005%\u0000\u0000\u00f6\"\u0001\u0000\u0000"+ + "\u0000\u00f7\u00f8\u0005/\u0000\u0000\u00f8$\u0001\u0000\u0000\u0000\u00f9"+ + "\u00fa\u0005>\u0000\u0000\u00fa&\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005"+ + "<\u0000\u0000\u00fc(\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005>\u0000"+ + "\u0000\u00fe\u00ff\u0005=\u0000\u0000\u00ff*\u0001\u0000\u0000\u0000\u0100"+ + "\u0101\u0005<\u0000\u0000\u0101\u0102\u0005=\u0000\u0000\u0102,\u0001"+ + "\u0000\u0000\u0000\u0103\u0104\u0005=\u0000\u0000\u0104\u0105\u0005=\u0000"+ + "\u0000\u0105.\u0001\u0000\u0000\u0000\u0106\u0107\u0005!\u0000\u0000\u0107"+ + "\u0108\u0005=\u0000\u0000\u01080\u0001\u0000\u0000\u0000\u0109\u010a\u0005"+ + "!\u0000\u0000\u010a2\u0001\u0000\u0000\u0000\u010b\u010c\u0005&\u0000"+ + "\u0000\u010c\u010d\u0005&\u0000\u0000\u010d4\u0001\u0000\u0000\u0000\u010e"+ + "\u010f\u0005|\u0000\u0000\u010f\u0110\u0005|\u0000\u0000\u01106\u0001"+ + "\u0000\u0000\u0000\u0111\u0112\u0005.\u0000\u0000\u01128\u0001\u0000\u0000"+ + "\u0000\u0113\u0114\u0005(\u0000\u0000\u0114:\u0001\u0000\u0000\u0000\u0115"+ + "\u0116\u0005)\u0000\u0000\u0116<\u0001\u0000\u0000\u0000\u0117\u0118\u0005"+ + "{\u0000\u0000\u0118>\u0001\u0000\u0000\u0000\u0119\u011a\u0005}\u0000"+ + "\u0000\u011a@\u0001\u0000\u0000\u0000\u011b\u011c\u0005;\u0000\u0000\u011c"+ + "B\u0001\u0000\u0000\u0000\u011d\u011e\u0005,\u0000\u0000\u011eD\u0001"+ + "\u0000\u0000\u0000\u011f\u0120\u0005c\u0000\u0000\u0120\u0121\u0005l\u0000"+ + "\u0000\u0121\u0122\u0005a\u0000\u0000\u0122\u0123\u0005s\u0000\u0000\u0123"+ + "\u0124\u0005s\u0000\u0000\u0124F\u0001\u0000\u0000\u0000\u0125\u0126\u0005"+ + "t\u0000\u0000\u0126\u0127\u0005h\u0000\u0000\u0127\u0128\u0005i\u0000"+ + "\u0000\u0128\u0129\u0005s\u0000\u0000\u0129H\u0001\u0000\u0000\u0000\u012a"+ + "\u012b\u0005w\u0000\u0000\u012b\u012c\u0005h\u0000\u0000\u012c\u012d\u0005"+ + "i\u0000\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005e\u0000"+ + "\u0000\u012fJ\u0001\u0000\u0000\u0000\u0130\u0131\u0005i\u0000\u0000\u0131"+ + "\u0132\u0005f\u0000\u0000\u0132L\u0001\u0000\u0000\u0000\u0133\u0134\u0005"+ + "e\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136\u0005s\u0000"+ + "\u0000\u0136\u0137\u0005e\u0000\u0000\u0137N\u0001\u0000\u0000\u0000\u0138"+ + "\u0139\u0005f\u0000\u0000\u0139\u013a\u0005o\u0000\u0000\u013a\u013b\u0005"+ + "r\u0000\u0000\u013bP\u0001\u0000\u0000\u0000\u013c\u013d\u0005r\u0000"+ + "\u0000\u013d\u013e\u0005e\u0000\u0000\u013e\u013f\u0005t\u0000\u0000\u013f"+ + "\u0140\u0005u\u0000\u0000\u0140\u0141\u0005r\u0000\u0000\u0141\u0142\u0005"+ + "n\u0000\u0000\u0142R\u0001\u0000\u0000\u0000\u0143\u0144\u0005n\u0000"+ + "\u0000\u0144\u0145\u0005e\u0000\u0000\u0145\u0146\u0005w\u0000\u0000\u0146"+ + "T\u0001\u0000\u0000\u0000\u0147\u014b\u0005\'\u0000\u0000\u0148\u014a"+ + "\b\u0000\u0000\u0000\u0149\u0148\u0001\u0000\u0000\u0000\u014a\u014d\u0001"+ + "\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000\u014b\u014c\u0001"+ + "\u0000\u0000\u0000\u014c\u014e\u0001\u0000\u0000\u0000\u014d\u014b\u0001"+ + "\u0000\u0000\u0000\u014e\u014f\u0005\'\u0000\u0000\u014fV\u0001\u0000"+ + "\u0000\u0000\u0150\u0152\u0003\u001d\u000e\u0000\u0151\u0150\u0001\u0000"+ + "\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u0154\u0001\u0000"+ + "\u0000\u0000\u0153\u0155\u0003_/\u0000\u0154\u0153\u0001\u0000\u0000\u0000"+ + "\u0155\u0156\u0001\u0000\u0000\u0000\u0156\u0154\u0001\u0000\u0000\u0000"+ + "\u0156\u0157\u0001\u0000\u0000\u0000\u0157X\u0001\u0000\u0000\u0000\u0158"+ + "\u0159\u0005t\u0000\u0000\u0159\u015a\u0005r\u0000\u0000\u015a\u015b\u0005"+ + "u\u0000\u0000\u015b\u0162\u0005e\u0000\u0000\u015c\u015d\u0005f\u0000"+ + "\u0000\u015d\u015e\u0005a\u0000\u0000\u015e\u015f\u0005l\u0000\u0000\u015f"+ + "\u0160\u0005s\u0000\u0000\u0160\u0162\u0005e\u0000\u0000\u0161\u0158\u0001"+ + "\u0000\u0000\u0000\u0161\u015c\u0001\u0000\u0000\u0000\u0162Z\u0001\u0000"+ + "\u0000\u0000\u0163\u0164\u0005n\u0000\u0000\u0164\u0165\u0005u\u0000\u0000"+ + "\u0165\u0166\u0005l\u0000\u0000\u0166\u0167\u0005l\u0000\u0000\u0167\\"+ + "\u0001\u0000\u0000\u0000\u0168\u0169\u0007\u0001\u0000\u0000\u0169^\u0001"+ + "\u0000\u0000\u0000\u016a\u016b\u0007\u0002\u0000\u0000\u016b`\u0001\u0000"+ + "\u0000\u0000\u016c\u0170\u0003].\u0000\u016d\u0170\u0003_/\u0000\u016e"+ + "\u0170\u0007\u0003\u0000\u0000\u016f\u016c\u0001\u0000\u0000\u0000\u016f"+ + "\u016d\u0001\u0000\u0000\u0000\u016f\u016e\u0001\u0000\u0000\u0000\u0170"+ + "b\u0001\u0000\u0000\u0000\u0171\u0175\u0003].\u0000\u0172\u0174\u0003"+ + "a0\u0000\u0173\u0172\u0001\u0000\u0000\u0000\u0174\u0177\u0001\u0000\u0000"+ + "\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0176\u0001\u0000\u0000"+ + "\u0000\u0176d\u0001\u0000\u0000\u0000\u0177\u0175\u0001\u0000\u0000\u0000"+ + "\u0178\u017a\u0007\u0004\u0000\u0000\u0179\u0178\u0001\u0000\u0000\u0000"+ + "\u017a\u017b\u0001\u0000\u0000\u0000\u017b\u0179\u0001\u0000\u0000\u0000"+ + "\u017b\u017c\u0001\u0000\u0000\u0000\u017c\u017d\u0001\u0000\u0000\u0000"+ + "\u017d\u017e\u00062\u0000\u0000\u017ef\u0001\u0000\u0000\u0000\u017f\u0180"+ + "\u0005/\u0000\u0000\u0180\u0181\u0005/\u0000\u0000\u0181\u0185\u0001\u0000"+ + "\u0000\u0000\u0182\u0184\b\u0000\u0000\u0000\u0183\u0182\u0001\u0000\u0000"+ + "\u0000\u0184\u0187\u0001\u0000\u0000\u0000\u0185\u0183\u0001\u0000\u0000"+ + "\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0188\u0001\u0000\u0000"+ + "\u0000\u0187\u0185\u0001\u0000\u0000\u0000\u0188\u0189\u00063\u0000\u0000"+ + "\u0189h\u0001\u0000\u0000\u0000\u018a\u018b\u0005/\u0000\u0000\u018b\u018c"+ + "\u0005*\u0000\u0000\u018c\u0190\u0001\u0000\u0000\u0000\u018d\u018f\t"+ + "\u0000\u0000\u0000\u018e\u018d\u0001\u0000\u0000\u0000\u018f\u0192\u0001"+ + "\u0000\u0000\u0000\u0190\u0191\u0001\u0000\u0000\u0000\u0190\u018e\u0001"+ + "\u0000\u0000\u0000\u0191\u0193\u0001\u0000\u0000\u0000\u0192\u0190\u0001"+ + "\u0000\u0000\u0000\u0193\u0194\u0005*\u0000\u0000\u0194\u0195\u0005/\u0000"+ + "\u0000\u0195\u0196\u0001\u0000\u0000\u0000\u0196\u0197\u00064\u0000\u0000"+ + "\u0197j\u0001\u0000\u0000\u0000\u000f\u0000\u00af\u00db\u00df\u00e7\u00eb"+ + "\u014b\u0151\u0156\u0161\u016f\u0175\u017b\u0185\u0190\u0001\u0006\u0000"+ + "\u0000"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/parser/generated/SimpleJavaLexer.tokens b/src/main/java/parser/generated/SimpleJavaLexer.tokens index fa21229..bed7437 100644 --- a/src/main/java/parser/generated/SimpleJavaLexer.tokens +++ b/src/main/java/parser/generated/SimpleJavaLexer.tokens @@ -1,73 +1,88 @@ T__0=1 T__1=2 -T__2=3 -T__3=4 -T__4=5 -T__5=6 -T__6=7 -T__7=8 -T__8=9 -T__9=10 -T__10=11 -T__11=12 -T__12=13 -T__13=14 -T__14=15 -T__15=16 -T__16=17 -T__17=18 -T__18=19 -T__19=20 -T__20=21 -T__21=22 -T__22=23 -T__23=24 -T__24=25 -T__25=26 -T__26=27 -T__27=28 -T__28=29 -T__29=30 -T__30=31 -T__31=32 -T__32=33 -T__33=34 -T__34=35 -INTEGERLITERAL=36 -IDENTIFIER=37 -WS=38 -'class'=1 -'{'=2 -'}'=3 -';'=4 -'static'=5 -'('=6 -')'=7 -','=8 -'int'=9 -'boolean'=10 -'char'=11 -'public'=12 -'private'=13 -'='=14 -'if'=15 -'else'=16 -'while'=17 -'return'=18 -'&&'=19 -'||'=20 -'=='=21 -'!='=22 -'<'=23 -'<='=24 -'>'=25 -'>='=26 -'+'=27 -'-'=28 -'*'=29 -'/'=30 -'%'=31 -'!'=32 -'true'=33 -'false'=34 -'\''=35 +Void=3 +Boolean=4 +Char=5 +Int=6 +AccessModifier=7 +MainMethodDeclaration=8 +DotOperator=9 +LineOperator=10 +ComparisonOperator=11 +LogicalOperator=12 +Assign=13 +Plus=14 +Minus=15 +Mult=16 +Modulo=17 +Div=18 +Greater=19 +Less=20 +GreaterEqual=21 +LessEqual=22 +Equal=23 +NotEqual=24 +Not=25 +And=26 +Or=27 +Dot=28 +OpenRoundBracket=29 +ClosedRoundBracket=30 +OpenCurlyBracket=31 +ClosedCurlyBracket=32 +Semicolon=33 +Comma=34 +Class=35 +This=36 +While=37 +If=38 +Else=39 +For=40 +Return=41 +New=42 +CharValue=43 +IntValue=44 +BooleanValue=45 +NullValue=46 +Identifier=47 +WS=48 +InlineComment=49 +MultilineComment=50 +'++'=1 +'--'=2 +'void'=3 +'boolean'=4 +'char'=5 +'int'=6 +'public static void main(String[] args)'=8 +'='=13 +'+'=14 +'-'=15 +'*'=16 +'%'=17 +'/'=18 +'>'=19 +'<'=20 +'>='=21 +'<='=22 +'=='=23 +'!='=24 +'!'=25 +'&&'=26 +'||'=27 +'.'=28 +'('=29 +')'=30 +'{'=31 +'}'=32 +';'=33 +','=34 +'class'=35 +'this'=36 +'while'=37 +'if'=38 +'else'=39 +'for'=40 +'return'=41 +'new'=42 +'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaListener.java b/src/main/java/parser/generated/SimpleJavaListener.java index 6debbf6..7b22466 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/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.tree.ParseTreeListener; @@ -37,6 +37,16 @@ public interface SimpleJavaListener extends ParseTreeListener { * @param ctx the parse tree */ void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. * @param ctx the parse tree @@ -57,16 +67,6 @@ 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 @@ -88,25 +88,15 @@ public interface SimpleJavaListener extends ParseTreeListener { */ void exitParameter(SimpleJavaParser.ParameterContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#type}. + * Enter a parse tree produced by {@link SimpleJavaParser#argumentList}. * @param ctx the parse tree */ - void enterType(SimpleJavaParser.TypeContext ctx); + void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#type}. + * Exit a parse tree produced by {@link SimpleJavaParser#argumentList}. * @param ctx the parse tree */ - void exitType(SimpleJavaParser.TypeContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#accessType}. - * @param ctx the parse tree - */ - void enterAccessType(SimpleJavaParser.AccessTypeContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#accessType}. - * @param ctx the parse tree - */ - void exitAccessType(SimpleJavaParser.AccessTypeContext ctx); + void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx); /** * Enter a parse tree produced by {@link SimpleJavaParser#statement}. * @param ctx the parse tree @@ -118,55 +108,15 @@ public interface SimpleJavaListener extends ParseTreeListener { */ void exitStatement(SimpleJavaParser.StatementContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}. + * Enter a parse tree produced by {@link SimpleJavaParser#block}. * @param ctx the parse tree */ - void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx); + void enterBlock(SimpleJavaParser.BlockContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}. + * Exit a parse tree produced by {@link SimpleJavaParser#block}. * @param ctx the parse tree */ - void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#assignmentStatement}. - * @param ctx the parse tree - */ - void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}. - * @param ctx the parse tree - */ - void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#var}. - * @param ctx the parse tree - */ - void enterVar(SimpleJavaParser.VarContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#var}. - * @param ctx the parse tree - */ - void exitVar(SimpleJavaParser.VarContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - */ - void enterIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - */ - void exitIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - */ - void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - */ - void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + void exitBlock(SimpleJavaParser.BlockContext ctx); /** * Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}. * @param ctx the parse tree @@ -178,15 +128,95 @@ public interface SimpleJavaListener extends ParseTreeListener { */ void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#block}. + * Enter a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. * @param ctx the parse tree */ - void enterBlock(SimpleJavaParser.BlockContext ctx); + void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#block}. + * Exit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. * @param ctx the parse tree */ - void exitBlock(SimpleJavaParser.BlockContext ctx); + void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + */ + void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + */ + void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + */ + void enterForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + */ + void exitForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + */ + void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + */ + void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + */ + void enterIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + */ + void exitIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + */ + void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + */ + void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + */ + void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + */ + void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + */ + void enterAssign(SimpleJavaParser.AssignContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + */ + void exitAssign(SimpleJavaParser.AssignContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + */ + void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + */ + void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); /** * Enter a parse tree produced by {@link SimpleJavaParser#expression}. * @param ctx the parse tree @@ -198,33 +228,223 @@ public interface SimpleJavaListener extends ParseTreeListener { */ void exitExpression(SimpleJavaParser.ExpressionContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#literal}. + * Enter a parse tree produced by {@link SimpleJavaParser#unaryExpression}. * @param ctx the parse tree */ - void enterLiteral(SimpleJavaParser.LiteralContext ctx); + void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#literal}. + * Exit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. * @param ctx the parse tree */ - void exitLiteral(SimpleJavaParser.LiteralContext ctx); + void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#booleanLiteral}. + * Enter a parse tree produced by {@link SimpleJavaParser#notExpression}. * @param ctx the parse tree */ - void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx); + void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}. + * Exit a parse tree produced by {@link SimpleJavaParser#notExpression}. * @param ctx the parse tree */ - void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx); + void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx); /** - * Enter a parse tree produced by {@link SimpleJavaParser#charLiteral}. + * Enter a parse tree produced by {@link SimpleJavaParser#crementExpression}. * @param ctx the parse tree */ - void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx); + void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); /** - * Exit a parse tree produced by {@link SimpleJavaParser#charLiteral}. + * Exit a parse tree produced by {@link SimpleJavaParser#crementExpression}. * @param ctx the parse tree */ - void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx); + void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + */ + void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + */ + void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + */ + void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + */ + void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + */ + void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + */ + void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + */ + void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + */ + void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + */ + void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + */ + void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + */ + void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + */ + void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + */ + void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + */ + void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + */ + void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + */ + void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + */ + void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + */ + void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + */ + void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + */ + void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + */ + void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + */ + void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + */ + void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + */ + void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + */ + void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + */ + void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + */ + void enterMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + */ + void exitMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + */ + void enterTarget(SimpleJavaParser.TargetContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + */ + void exitTarget(SimpleJavaParser.TargetContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + */ + void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + */ + void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + */ + void enterType(SimpleJavaParser.TypeContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + */ + void exitType(SimpleJavaParser.TypeContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + */ + void enterValue(SimpleJavaParser.ValueContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + */ + void exitValue(SimpleJavaParser.ValueContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + */ + void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + */ + void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); } \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaParser.java b/src/main/java/parser/generated/SimpleJavaParser.java index 5b14132..3d93b3e 100644 --- a/src/main/java/parser/generated/SimpleJavaParser.java +++ b/src/main/java/parser/generated/SimpleJavaParser.java @@ -1,4 +1,4 @@ -// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; @@ -17,47 +17,68 @@ public class SimpleJavaParser extends Parser { protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, INTEGERLITERAL=36, IDENTIFIER=37, - WS=38; + T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, + DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, + Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, + Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, + And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, + ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, + If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, + BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, + MultilineComment=50; public static final int RULE_program = 0, RULE_classDeclaration = 1, RULE_memberDeclaration = 2, - 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_var = 13, RULE_ifStatement = 14, RULE_whileStatement = 15, RULE_returnStatement = 16, - RULE_block = 17, RULE_expression = 18, RULE_literal = 19, RULE_booleanLiteral = 20, - RULE_charLiteral = 21; + RULE_constructorDeclaration = 3, RULE_fieldDeclaration = 4, RULE_methodDeclaration = 5, + RULE_parameterList = 6, RULE_parameter = 7, RULE_argumentList = 8, RULE_statement = 9, + RULE_block = 10, RULE_returnStatement = 11, RULE_localVariableDeclaration = 12, + RULE_whileStatement = 13, RULE_forStatement = 14, RULE_ifElseStatement = 15, + RULE_ifStatement = 16, RULE_elseStatement = 17, RULE_statementExpression = 18, + RULE_assign = 19, RULE_newDeclaration = 20, RULE_expression = 21, RULE_unaryExpression = 22, + RULE_notExpression = 23, RULE_crementExpression = 24, RULE_incrementExpression = 25, + RULE_prefixIncrementExpression = 26, RULE_suffixIncrementExpression = 27, + RULE_decrementExpression = 28, RULE_prefixDecrementExpression = 29, RULE_suffixDecrementExpression = 30, + RULE_assignableExpression = 31, RULE_memberAccess = 32, RULE_binaryExpression = 33, + RULE_calculationExpression = 34, RULE_dotExpression = 35, RULE_dotSubtractionExpression = 36, + RULE_nonCalculationExpression = 37, RULE_methodCall = 38, RULE_target = 39, + RULE_chainedMethod = 40, RULE_type = 41, RULE_value = 42, RULE_nonCalculationOperator = 43; private static String[] makeRuleNames() { return new String[] { - "program", "classDeclaration", "memberDeclaration", "fieldDeclaration", - "methodDeclaration", "constructorDeclaration", "parameterList", "parameter", - "type", "accessType", "statement", "variableDeclarationStatement", "assignmentStatement", - "var", "ifStatement", "whileStatement", "returnStatement", "block", "expression", - "literal", "booleanLiteral", "charLiteral" + "program", "classDeclaration", "memberDeclaration", "constructorDeclaration", + "fieldDeclaration", "methodDeclaration", "parameterList", "parameter", + "argumentList", "statement", "block", "returnStatement", "localVariableDeclaration", + "whileStatement", "forStatement", "ifElseStatement", "ifStatement", "elseStatement", + "statementExpression", "assign", "newDeclaration", "expression", "unaryExpression", + "notExpression", "crementExpression", "incrementExpression", "prefixIncrementExpression", + "suffixIncrementExpression", "decrementExpression", "prefixDecrementExpression", + "suffixDecrementExpression", "assignableExpression", "memberAccess", + "binaryExpression", "calculationExpression", "dotExpression", "dotSubtractionExpression", + "nonCalculationExpression", "methodCall", "target", "chainedMethod", + "type", "value", "nonCalculationOperator" }; } public static final String[] ruleNames = makeRuleNames(); private static String[] makeLiteralNames() { return new String[] { - null, "'class'", "'{'", "'}'", "';'", "'static'", "'('", "')'", "','", - "'int'", "'boolean'", "'char'", "'public'", "'private'", "'='", "'if'", - "'else'", "'while'", "'return'", "'&&'", "'||'", "'=='", "'!='", "'<'", - "'<='", "'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'true'", - "'false'", "'''" + null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, + "'public static void main(String[] args)'", null, null, null, null, "'='", + "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", + "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", + "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", + "'new'", null, null, null, "'null'" }; } private static final String[] _LITERAL_NAMES = makeLiteralNames(); private static String[] makeSymbolicNames() { return new String[] { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - "INTEGERLITERAL", "IDENTIFIER", "WS" + null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", + "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", + "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", + "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", + "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", + "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" }; } private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); @@ -145,20 +166,20 @@ public class SimpleJavaParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(45); + setState(89); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(44); + setState(88); classDeclaration(); } } - setState(47); + setState(91); _errHandler.sync(this); _la = _input.LA(1); - } while ( _la==T__11 || _la==T__12 ); + } while ( _la==AccessModifier || _la==Class ); } } catch (RecognitionException re) { @@ -174,10 +195,11 @@ public class SimpleJavaParser extends Parser { @SuppressWarnings("CheckReturnValue") public static class ClassDeclarationContext extends ParserRuleContext { - public AccessTypeContext accessType() { - return getRuleContext(AccessTypeContext.class,0); - } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } + public TerminalNode Class() { return getToken(SimpleJavaParser.Class, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } public List memberDeclaration() { return getRuleContexts(MemberDeclarationContext.class); } @@ -210,30 +232,38 @@ public class SimpleJavaParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(49); - accessType(); - setState(50); - match(T__0); - setState(51); - match(IDENTIFIER); - setState(52); - match(T__1); - setState(56); + setState(94); _errHandler.sync(this); _la = _input.LA(1); - while (_la==T__11 || _la==T__12) { + if (_la==AccessModifier) { + { + setState(93); + match(AccessModifier); + } + } + + setState(96); + match(Class); + setState(97); + match(Identifier); + setState(98); + match(OpenCurlyBracket); + setState(102); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355832L) != 0)) { { { - setState(53); + setState(99); memberDeclaration(); } } - setState(58); + setState(104); _errHandler.sync(this); _la = _input.LA(1); } - setState(59); - match(T__2); + setState(105); + match(ClosedCurlyBracket); } } catch (RecognitionException re) { @@ -249,15 +279,15 @@ public class SimpleJavaParser extends Parser { @SuppressWarnings("CheckReturnValue") public static class MemberDeclarationContext extends ParserRuleContext { + public ConstructorDeclarationContext constructorDeclaration() { + return getRuleContext(ConstructorDeclarationContext.class,0); + } public FieldDeclarationContext fieldDeclaration() { return getRuleContext(FieldDeclarationContext.class,0); } 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); } @@ -281,28 +311,28 @@ public class SimpleJavaParser extends Parser { MemberDeclarationContext _localctx = new MemberDeclarationContext(_ctx, getState()); enterRule(_localctx, 4, RULE_memberDeclaration); try { - setState(64); + setState(110); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(61); - fieldDeclaration(); + setState(107); + constructorDeclaration(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(62); - methodDeclaration(); + setState(108); + fieldDeclaration(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(63); - constructorDeclaration(); + setState(109); + methodDeclaration(); } break; } @@ -318,173 +348,18 @@ public class SimpleJavaParser extends Parser { return _localctx; } - @SuppressWarnings("CheckReturnValue") - public static class FieldDeclarationContext extends ParserRuleContext { - public AccessTypeContext accessType() { - return getRuleContext(AccessTypeContext.class,0); - } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } - public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterFieldDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitFieldDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitFieldDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { - FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_fieldDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(66); - accessType(); - setState(67); - type(); - setState(68); - match(IDENTIFIER); - setState(69); - match(T__3); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MethodDeclarationContext extends ParserRuleContext { - public AccessTypeContext accessType() { - return getRuleContext(AccessTypeContext.class,0); - } - public TypeContext type() { - return getRuleContext(TypeContext.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 MethodDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_methodDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final MethodDeclarationContext methodDeclaration() throws RecognitionException { - MethodDeclarationContext _localctx = new MethodDeclarationContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_methodDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(71); - accessType(); - setState(72); - match(T__4); - setState(73); - type(); - setState(74); - match(IDENTIFIER); - setState(75); - match(T__5); - setState(77); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) { - { - setState(76); - parameterList(); - } - } - - setState(79); - match(T__6); - setState(80); - match(T__1); - setState(84); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) { - { - { - setState(81); - statement(); - } - } - setState(86); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(87); - 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 TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 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); } @@ -506,47 +381,229 @@ public class SimpleJavaParser extends Parser { public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException { ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_constructorDeclaration); + enterRule(_localctx, 6, RULE_constructorDeclaration); int _la; try { enterOuterAlt(_localctx, 1); { - setState(89); - accessType(); - setState(90); - match(IDENTIFIER); - setState(91); - match(T__5); - setState(93); + setState(113); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) { + if (_la==AccessModifier) { { - setState(92); + setState(112); + match(AccessModifier); + } + } + + setState(115); + match(Identifier); + setState(116); + match(OpenRoundBracket); + setState(118); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { + { + setState(117); parameterList(); } } - setState(95); - match(T__6); - setState(96); - match(T__1); - setState(100); + setState(120); + match(ClosedRoundBracket); + setState(121); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FieldDeclarationContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_fieldDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterFieldDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitFieldDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitFieldDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { + FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_fieldDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(124); _errHandler.sync(this); _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) { + if (_la==AccessModifier) { { + setState(123); + match(AccessModifier); + } + } + + setState(126); + type(); + setState(127); + match(Identifier); + setState(128); + match(Semicolon); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodDeclarationContext extends ParserRuleContext { + public TerminalNode MainMethodDeclaration() { return getToken(SimpleJavaParser.MainMethodDeclaration, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Void() { return getToken(SimpleJavaParser.Void, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public ParameterListContext parameterList() { + return getRuleContext(ParameterListContext.class,0); + } + public MethodDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final MethodDeclarationContext methodDeclaration() throws RecognitionException { + MethodDeclarationContext _localctx = new MethodDeclarationContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_methodDeclaration); + int _la; + try { + setState(146); + _errHandler.sync(this); + switch (_input.LA(1)) { + case MainMethodDeclaration: + enterOuterAlt(_localctx, 1); { - setState(97); - statement(); + setState(130); + match(MainMethodDeclaration); + setState(131); + block(); } - } - setState(102); + break; + case Void: + case Boolean: + case Char: + case Int: + case AccessModifier: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(133); _errHandler.sync(this); _la = _input.LA(1); - } - setState(103); - match(T__2); + if (_la==AccessModifier) { + { + setState(132); + match(AccessModifier); + } + } + + setState(137); + _errHandler.sync(this); + switch (_input.LA(1)) { + case Boolean: + case Char: + case Int: + case Identifier: + { + setState(135); + type(); + } + break; + case Void: + { + setState(136); + match(Void); + } + break; + default: + throw new NoViableAltException(this); + } + setState(139); + match(Identifier); + setState(140); + match(OpenRoundBracket); + setState(142); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { + { + setState(141); + parameterList(); + } + } + + setState(144); + match(ClosedRoundBracket); + setState(145); + block(); + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -568,6 +625,10 @@ public class SimpleJavaParser extends Parser { public ParameterContext parameter(int i) { return getRuleContext(ParameterContext.class,i); } + public List Comma() { return getTokens(SimpleJavaParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(SimpleJavaParser.Comma, i); + } public ParameterListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -594,21 +655,21 @@ public class SimpleJavaParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(105); + setState(148); parameter(); - setState(110); + setState(153); _errHandler.sync(this); _la = _input.LA(1); - while (_la==T__7) { + while (_la==Comma) { { { - setState(106); - match(T__7); - setState(107); + setState(149); + match(Comma); + setState(150); parameter(); } } - setState(112); + setState(155); _errHandler.sync(this); _la = _input.LA(1); } @@ -630,7 +691,7 @@ public class SimpleJavaParser extends Parser { public TypeContext type() { return getRuleContext(TypeContext.class,0); } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } public ParameterContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -656,10 +717,10 @@ public class SimpleJavaParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(113); + setState(156); type(); - setState(114); - match(IDENTIFIER); + setState(157); + match(Identifier); } } catch (RecognitionException re) { @@ -674,94 +735,69 @@ public class SimpleJavaParser extends Parser { } @SuppressWarnings("CheckReturnValue") - public static class TypeContext extends ParserRuleContext { - public TypeContext(ParserRuleContext parent, int invokingState) { + public static class ArgumentListContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List Comma() { return getTokens(SimpleJavaParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(SimpleJavaParser.Comma, i); + } + public ArgumentListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - @Override public int getRuleIndex() { return RULE_type; } + @Override public int getRuleIndex() { return RULE_argumentList; } @Override public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterType(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterArgumentList(this); } @Override public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitType(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitArgumentList(this); } @Override public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitType(this); + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitArgumentList(this); else return visitor.visitChildren(this); } } - public final TypeContext type() throws RecognitionException { - TypeContext _localctx = new TypeContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_type); + public final ArgumentListContext argumentList() throws RecognitionException { + ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_argumentList); int _la; try { enterOuterAlt(_localctx, 1); { - setState(116); + setState(167); + _errHandler.sync(this); _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 3584L) != 0)) ) { - _errHandler.recoverInline(this); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(159); + expression(); + setState(164); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Comma) { + { + { + setState(160); + match(Comma); + setState(161); + expression(); + } + } + setState(166); + _errHandler.sync(this); + _la = _input.LA(1); + } + } } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - @SuppressWarnings("CheckReturnValue") - public static class AccessTypeContext extends ParserRuleContext { - public AccessTypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_accessType; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAccessType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAccessType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAccessType(this); - else return visitor.visitChildren(this); - } - } - - public final AccessTypeContext accessType() throws RecognitionException { - AccessTypeContext _localctx = new AccessTypeContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_accessType); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(118); - _la = _input.LA(1); - if ( !(_la==T__11 || _la==T__12) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } } } catch (RecognitionException re) { @@ -777,23 +813,27 @@ public class SimpleJavaParser extends Parser { @SuppressWarnings("CheckReturnValue") public static class StatementContext extends ParserRuleContext { - public VariableDeclarationStatementContext variableDeclarationStatement() { - return getRuleContext(VariableDeclarationStatementContext.class,0); + public ReturnStatementContext returnStatement() { + return getRuleContext(ReturnStatementContext.class,0); } - public AssignmentStatementContext assignmentStatement() { - return getRuleContext(AssignmentStatementContext.class,0); + public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } + public LocalVariableDeclarationContext localVariableDeclaration() { + return getRuleContext(LocalVariableDeclarationContext.class,0); } - public IfStatementContext ifStatement() { - return getRuleContext(IfStatementContext.class,0); + public BlockContext block() { + return getRuleContext(BlockContext.class,0); } public WhileStatementContext whileStatement() { return getRuleContext(WhileStatementContext.class,0); } - public ReturnStatementContext returnStatement() { - return getRuleContext(ReturnStatementContext.class,0); + public ForStatementContext forStatement() { + return getRuleContext(ForStatementContext.class,0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); + public IfElseStatementContext ifElseStatement() { + return getRuleContext(IfElseStatementContext.class,0); + } + public StatementExpressionContext statementExpression() { + return getRuleContext(StatementExpressionContext.class,0); } public StatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); @@ -816,405 +856,66 @@ public class SimpleJavaParser extends Parser { public final StatementContext statement() throws RecognitionException { StatementContext _localctx = new StatementContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_statement); + enterRule(_localctx, 18, RULE_statement); try { - setState(126); + setState(182); _errHandler.sync(this); - switch (_input.LA(1)) { - case T__8: - case T__9: - case T__10: + switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { + case 1: enterOuterAlt(_localctx, 1); { - setState(120); - variableDeclarationStatement(); + setState(169); + returnStatement(); + setState(170); + match(Semicolon); } break; - case IDENTIFIER: + case 2: enterOuterAlt(_localctx, 2); { - setState(121); - assignmentStatement(); + setState(172); + localVariableDeclaration(); + setState(173); + match(Semicolon); } break; - case T__14: + case 3: enterOuterAlt(_localctx, 3); { - setState(122); - ifStatement(); - } - break; - case T__16: - enterOuterAlt(_localctx, 4); - { - setState(123); - whileStatement(); - } - break; - case T__17: - enterOuterAlt(_localctx, 5); - { - setState(124); - returnStatement(); - } - break; - case T__1: - enterOuterAlt(_localctx, 6); - { - setState(125); + setState(175); block(); } break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class VariableDeclarationStatementContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public VariableDeclarationStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_variableDeclarationStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterVariableDeclarationStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitVariableDeclarationStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitVariableDeclarationStatement(this); - else return visitor.visitChildren(this); - } - } - - public final VariableDeclarationStatementContext variableDeclarationStatement() throws RecognitionException { - VariableDeclarationStatementContext _localctx = new VariableDeclarationStatementContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_variableDeclarationStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(128); - type(); - setState(129); - match(IDENTIFIER); - setState(132); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__13) { + case 4: + enterOuterAlt(_localctx, 4); { - setState(130); - match(T__13); - setState(131); - expression(0); - } - } - - setState(134); - match(T__3); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AssignmentStatementContext extends ParserRuleContext { - public VarContext var() { - return getRuleContext(VarContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public AssignmentStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assignmentStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssignmentStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssignmentStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssignmentStatement(this); - else return visitor.visitChildren(this); - } - } - - public final AssignmentStatementContext assignmentStatement() throws RecognitionException { - AssignmentStatementContext _localctx = new AssignmentStatementContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_assignmentStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(136); - var(); - setState(137); - match(T__13); - setState(138); - expression(0); - setState(139); - match(T__3); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class VarContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } - public VarContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_var; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterVar(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitVar(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitVar(this); - else return visitor.visitChildren(this); - } - } - - public final VarContext var() throws RecognitionException { - VarContext _localctx = new VarContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_var); - try { - enterOuterAlt(_localctx, 1); - { - setState(141); - match(IDENTIFIER); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IfStatementContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public List statement() { - return getRuleContexts(StatementContext.class); - } - public StatementContext statement(int i) { - return getRuleContext(StatementContext.class,i); - } - public IfStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfStatement(this); - else return visitor.visitChildren(this); - } - } - - public final IfStatementContext ifStatement() throws RecognitionException { - IfStatementContext _localctx = new IfStatementContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_ifStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(143); - match(T__14); - setState(144); - match(T__5); - setState(145); - expression(0); - setState(146); - match(T__6); - setState(147); - statement(); - setState(150); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) { - case 1: - { - setState(148); - match(T__15); - setState(149); - statement(); + setState(176); + whileStatement(); } break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class WhileStatementContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public WhileStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_whileStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterWhileStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitWhileStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitWhileStatement(this); - else return visitor.visitChildren(this); - } - } - - public final WhileStatementContext whileStatement() throws RecognitionException { - WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_whileStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(152); - match(T__16); - setState(153); - match(T__5); - setState(154); - expression(0); - setState(155); - match(T__6); - setState(156); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReturnStatementContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ReturnStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_returnStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterReturnStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitReturnStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitReturnStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ReturnStatementContext returnStatement() throws RecognitionException { - ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_returnStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(158); - match(T__17); - setState(160); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 270851375168L) != 0)) { + case 5: + enterOuterAlt(_localctx, 5); { - setState(159); - expression(0); + setState(177); + forStatement(); } - } - - setState(162); - match(T__3); + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(178); + ifElseStatement(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(179); + statementExpression(); + setState(180); + match(Semicolon); + } + break; } } catch (RecognitionException re) { @@ -1230,6 +931,8 @@ public class SimpleJavaParser extends Parser { @SuppressWarnings("CheckReturnValue") public static class BlockContext extends ParserRuleContext { + public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } public List statement() { return getRuleContexts(StatementContext.class); } @@ -1257,29 +960,677 @@ public class SimpleJavaParser extends Parser { public final BlockContext block() throws RecognitionException { BlockContext _localctx = new BlockContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_block); + enterRule(_localctx, 20, RULE_block); int _la; try { enterOuterAlt(_localctx, 1); { - setState(164); - match(T__1); - setState(168); + setState(184); + match(OpenCurlyBracket); + setState(188); _errHandler.sync(this); _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 137439383044L) != 0)) { + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 148917253570678L) != 0)) { { { - setState(165); + setState(185); statement(); } } - setState(170); + setState(190); _errHandler.sync(this); _la = _input.LA(1); } - setState(171); - match(T__2); + setState(191); + match(ClosedCurlyBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReturnStatementContext extends ParserRuleContext { + public TerminalNode Return() { return getToken(SimpleJavaParser.Return, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ReturnStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_returnStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterReturnStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitReturnStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitReturnStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ReturnStatementContext returnStatement() throws RecognitionException { + ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_returnStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(193); + match(Return); + setState(195); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(194); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class LocalVariableDeclarationContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public LocalVariableDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_localVariableDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterLocalVariableDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitLocalVariableDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitLocalVariableDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final LocalVariableDeclarationContext localVariableDeclaration() throws RecognitionException { + LocalVariableDeclarationContext _localctx = new LocalVariableDeclarationContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_localVariableDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(197); + type(); + setState(198); + match(Identifier); + setState(201); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==Assign) { + { + setState(199); + match(Assign); + setState(200); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class WhileStatementContext extends ParserRuleContext { + public TerminalNode While() { return getToken(SimpleJavaParser.While, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public WhileStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_whileStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterWhileStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitWhileStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitWhileStatement(this); + else return visitor.visitChildren(this); + } + } + + public final WhileStatementContext whileStatement() throws RecognitionException { + WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_whileStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(203); + match(While); + setState(204); + match(OpenRoundBracket); + setState(205); + expression(); + setState(206); + match(ClosedRoundBracket); + setState(207); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ForStatementContext extends ParserRuleContext { + public TerminalNode For() { return getToken(SimpleJavaParser.For, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public List Semicolon() { return getTokens(SimpleJavaParser.Semicolon); } + public TerminalNode Semicolon(int i) { + return getToken(SimpleJavaParser.Semicolon, i); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public List statementExpression() { + return getRuleContexts(StatementExpressionContext.class); + } + public StatementExpressionContext statementExpression(int i) { + return getRuleContext(StatementExpressionContext.class,i); + } + public LocalVariableDeclarationContext localVariableDeclaration() { + return getRuleContext(LocalVariableDeclarationContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ForStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_forStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterForStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitForStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitForStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ForStatementContext forStatement() throws RecognitionException { + ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_forStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(209); + match(For); + setState(210); + match(OpenRoundBracket); + setState(213); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) { + case 1: + { + setState(211); + statementExpression(); + } + break; + case 2: + { + setState(212); + localVariableDeclaration(); + } + break; + } + setState(215); + match(Semicolon); + setState(217); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(216); + expression(); + } + } + + setState(219); + match(Semicolon); + setState(221); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 145204254343174L) != 0)) { + { + setState(220); + statementExpression(); + } + } + + setState(223); + match(ClosedRoundBracket); + setState(224); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfElseStatementContext extends ParserRuleContext { + public IfStatementContext ifStatement() { + return getRuleContext(IfStatementContext.class,0); + } + public ElseStatementContext elseStatement() { + return getRuleContext(ElseStatementContext.class,0); + } + public IfElseStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifElseStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfElseStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfElseStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfElseStatement(this); + else return visitor.visitChildren(this); + } + } + + public final IfElseStatementContext ifElseStatement() throws RecognitionException { + IfElseStatementContext _localctx = new IfElseStatementContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_ifElseStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(226); + ifStatement(); + setState(228); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { + case 1: + { + setState(227); + elseStatement(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfStatementContext extends ParserRuleContext { + public TerminalNode If() { return getToken(SimpleJavaParser.If, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public IfStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfStatement(this); + else return visitor.visitChildren(this); + } + } + + public final IfStatementContext ifStatement() throws RecognitionException { + IfStatementContext _localctx = new IfStatementContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_ifStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(230); + match(If); + setState(231); + match(OpenRoundBracket); + setState(232); + expression(); + setState(233); + match(ClosedRoundBracket); + setState(234); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ElseStatementContext extends ParserRuleContext { + public TerminalNode Else() { return getToken(SimpleJavaParser.Else, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public ElseStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_elseStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterElseStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitElseStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitElseStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ElseStatementContext elseStatement() throws RecognitionException { + ElseStatementContext _localctx = new ElseStatementContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_elseStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(236); + match(Else); + setState(237); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StatementExpressionContext extends ParserRuleContext { + public AssignContext assign() { + return getRuleContext(AssignContext.class,0); + } + public NewDeclarationContext newDeclaration() { + return getRuleContext(NewDeclarationContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public CrementExpressionContext crementExpression() { + return getRuleContext(CrementExpressionContext.class,0); + } + public StatementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterStatementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitStatementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitStatementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final StatementExpressionContext statementExpression() throws RecognitionException { + StatementExpressionContext _localctx = new StatementExpressionContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_statementExpression); + try { + setState(243); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(239); + assign(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(240); + newDeclaration(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(241); + methodCall(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(242); + crementExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public AssignContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assign; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssign(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssign(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + + public final AssignContext assign() throws RecognitionException { + AssignContext _localctx = new AssignContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_assign); + try { + enterOuterAlt(_localctx, 1); + { + setState(245); + assignableExpression(); + setState(246); + match(Assign); + setState(247); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NewDeclarationContext extends ParserRuleContext { + public TerminalNode New() { return getToken(SimpleJavaParser.New, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public NewDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_newDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNewDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNewDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNewDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final NewDeclarationContext newDeclaration() throws RecognitionException { + NewDeclarationContext _localctx = new NewDeclarationContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_newDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(249); + match(New); + setState(250); + match(Identifier); + setState(251); + match(OpenRoundBracket); + setState(252); + argumentList(); + setState(253); + match(ClosedRoundBracket); } } catch (RecognitionException re) { @@ -1295,16 +1646,12 @@ public class SimpleJavaParser extends Parser { @SuppressWarnings("CheckReturnValue") public static class ExpressionContext extends ParserRuleContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); + public UnaryExpressionContext unaryExpression() { + return getRuleContext(UnaryExpressionContext.class,0); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); + public BinaryExpressionContext binaryExpression() { + return getRuleContext(BinaryExpressionContext.class,0); } - public LiteralContext literal() { - return getRuleContext(LiteralContext.class,0); - } - public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); } public ExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -1325,147 +1672,26 @@ public class SimpleJavaParser extends Parser { } public final ExpressionContext expression() throws RecognitionException { - return expression(0); - } - - private ExpressionContext expression(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState); - ExpressionContext _prevctx = _localctx; - int _startState = 36; - enterRecursionRule(_localctx, 36, RULE_expression, _p); - int _la; + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_expression); try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(184); + setState(257); _errHandler.sync(this); - switch (_input.LA(1)) { - case T__27: + switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); { - setState(174); - match(T__27); - setState(175); - expression(5); + setState(255); + unaryExpression(); } break; - case T__31: + case 2: + enterOuterAlt(_localctx, 2); { - setState(176); - match(T__31); - setState(177); - expression(4); + setState(256); + binaryExpression(); } break; - case T__5: - { - setState(178); - match(T__5); - setState(179); - expression(0); - setState(180); - match(T__6); - } - break; - case T__32: - case T__33: - case T__34: - case INTEGERLITERAL: - { - setState(182); - literal(); - } - break; - case IDENTIFIER: - { - setState(183); - match(IDENTIFIER); - } - break; - default: - throw new NoViableAltException(this); - } - _ctx.stop = _input.LT(-1); - setState(197); - _errHandler.sync(this); - _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(195); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { - case 1: - { - _localctx = new ExpressionContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(186); - if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); - setState(187); - _la = _input.LA(1); - if ( !(_la==T__18 || _la==T__19) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(188); - expression(9); - } - break; - case 2: - { - _localctx = new ExpressionContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(189); - if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); - setState(190); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 132120576L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(191); - expression(8); - } - break; - case 3: - { - _localctx = new ExpressionContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(192); - if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); - setState(193); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 4160749568L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(194); - expression(7); - } - break; - } - } - } - setState(199); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,15,_ctx); - } } } catch (RecognitionException re) { @@ -1474,66 +1700,280 @@ public class SimpleJavaParser extends Parser { _errHandler.recover(this, re); } finally { - unrollRecursionContexts(_parentctx); + exitRule(); } return _localctx; } @SuppressWarnings("CheckReturnValue") - public static class LiteralContext extends ParserRuleContext { - public TerminalNode INTEGERLITERAL() { return getToken(SimpleJavaParser.INTEGERLITERAL, 0); } - public BooleanLiteralContext booleanLiteral() { - return getRuleContext(BooleanLiteralContext.class,0); + public static class UnaryExpressionContext extends ParserRuleContext { + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); } - public CharLiteralContext charLiteral() { - return getRuleContext(CharLiteralContext.class,0); + public ValueContext value() { + return getRuleContext(ValueContext.class,0); } - public LiteralContext(ParserRuleContext parent, int invokingState) { + public NotExpressionContext notExpression() { + return getRuleContext(NotExpressionContext.class,0); + } + public StatementExpressionContext statementExpression() { + return getRuleContext(StatementExpressionContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public UnaryExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - @Override public int getRuleIndex() { return RULE_literal; } + @Override public int getRuleIndex() { return RULE_unaryExpression; } @Override public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterUnaryExpression(this); } @Override public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitUnaryExpression(this); } @Override public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitLiteral(this); + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitUnaryExpression(this); else return visitor.visitChildren(this); } } - public final LiteralContext literal() throws RecognitionException { - LiteralContext _localctx = new LiteralContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_literal); + public final UnaryExpressionContext unaryExpression() throws RecognitionException { + UnaryExpressionContext _localctx = new UnaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_unaryExpression); try { - setState(203); + setState(269); _errHandler.sync(this); - switch (_input.LA(1)) { - case INTEGERLITERAL: + switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + case 1: enterOuterAlt(_localctx, 1); { - setState(200); - match(INTEGERLITERAL); + setState(259); + match(This); } break; - case T__32: - case T__33: + case 2: enterOuterAlt(_localctx, 2); { - setState(201); - booleanLiteral(); + setState(260); + match(Identifier); } break; - case T__34: + case 3: enterOuterAlt(_localctx, 3); { - setState(202); - charLiteral(); + setState(261); + memberAccess(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(262); + value(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(263); + notExpression(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(264); + statementExpression(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(265); + match(OpenRoundBracket); + setState(266); + expression(); + setState(267); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NotExpressionContext extends ParserRuleContext { + public TerminalNode Not() { return getToken(SimpleJavaParser.Not, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public NotExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_notExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNotExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNotExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNotExpression(this); + else return visitor.visitChildren(this); + } + } + + public final NotExpressionContext notExpression() throws RecognitionException { + NotExpressionContext _localctx = new NotExpressionContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_notExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(271); + match(Not); + setState(272); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CrementExpressionContext extends ParserRuleContext { + public IncrementExpressionContext incrementExpression() { + return getRuleContext(IncrementExpressionContext.class,0); + } + public DecrementExpressionContext decrementExpression() { + return getRuleContext(DecrementExpressionContext.class,0); + } + public CrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_crementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final CrementExpressionContext crementExpression() throws RecognitionException { + CrementExpressionContext _localctx = new CrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_crementExpression); + try { + setState(276); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(274); + incrementExpression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(275); + decrementExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IncrementExpressionContext extends ParserRuleContext { + public PrefixIncrementExpressionContext prefixIncrementExpression() { + return getRuleContext(PrefixIncrementExpressionContext.class,0); + } + public SuffixIncrementExpressionContext suffixIncrementExpression() { + return getRuleContext(SuffixIncrementExpressionContext.class,0); + } + public IncrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_incrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIncrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIncrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final IncrementExpressionContext incrementExpression() throws RecognitionException { + IncrementExpressionContext _localctx = new IncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_incrementExpression); + try { + setState(280); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__0: + enterOuterAlt(_localctx, 1); + { + setState(278); + prefixIncrementExpression(); + } + break; + case This: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(279); + suffixIncrementExpression(); } break; default: @@ -1552,36 +1992,1055 @@ public class SimpleJavaParser extends Parser { } @SuppressWarnings("CheckReturnValue") - public static class BooleanLiteralContext extends ParserRuleContext { - public BooleanLiteralContext(ParserRuleContext parent, int invokingState) { + public static class PrefixIncrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public PrefixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - @Override public int getRuleIndex() { return RULE_booleanLiteral; } + @Override public int getRuleIndex() { return RULE_prefixIncrementExpression; } @Override public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBooleanLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixIncrementExpression(this); } @Override public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBooleanLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixIncrementExpression(this); } @Override public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBooleanLiteral(this); + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixIncrementExpression(this); else return visitor.visitChildren(this); } } - public final BooleanLiteralContext booleanLiteral() throws RecognitionException { - BooleanLiteralContext _localctx = new BooleanLiteralContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_booleanLiteral); + public final PrefixIncrementExpressionContext prefixIncrementExpression() throws RecognitionException { + PrefixIncrementExpressionContext _localctx = new PrefixIncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_prefixIncrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(282); + match(T__0); + setState(283); + assignableExpression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SuffixIncrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public SuffixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_suffixIncrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixIncrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixIncrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final SuffixIncrementExpressionContext suffixIncrementExpression() throws RecognitionException { + SuffixIncrementExpressionContext _localctx = new SuffixIncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_suffixIncrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(285); + assignableExpression(); + setState(286); + match(T__0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DecrementExpressionContext extends ParserRuleContext { + public PrefixDecrementExpressionContext prefixDecrementExpression() { + return getRuleContext(PrefixDecrementExpressionContext.class,0); + } + public SuffixDecrementExpressionContext suffixDecrementExpression() { + return getRuleContext(SuffixDecrementExpressionContext.class,0); + } + public DecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_decrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DecrementExpressionContext decrementExpression() throws RecognitionException { + DecrementExpressionContext _localctx = new DecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_decrementExpression); + try { + setState(290); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__1: + enterOuterAlt(_localctx, 1); + { + setState(288); + prefixDecrementExpression(); + } + break; + case This: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(289); + suffixDecrementExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrefixDecrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public PrefixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_prefixDecrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final PrefixDecrementExpressionContext prefixDecrementExpression() throws RecognitionException { + PrefixDecrementExpressionContext _localctx = new PrefixDecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_prefixDecrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(292); + match(T__1); + setState(293); + assignableExpression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SuffixDecrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public SuffixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_suffixDecrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final SuffixDecrementExpressionContext suffixDecrementExpression() throws RecognitionException { + SuffixDecrementExpressionContext _localctx = new SuffixDecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_suffixDecrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(295); + assignableExpression(); + setState(296); + match(T__1); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignableExpressionContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public AssignableExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assignableExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssignableExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssignableExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssignableExpression(this); + else return visitor.visitChildren(this); + } + } + + public final AssignableExpressionContext assignableExpression() throws RecognitionException { + AssignableExpressionContext _localctx = new AssignableExpressionContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_assignableExpression); + try { + setState(300); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(298); + match(Identifier); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(299); + memberAccess(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MemberAccessContext extends ParserRuleContext { + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public List Dot() { return getTokens(SimpleJavaParser.Dot); } + public TerminalNode Dot(int i) { + return getToken(SimpleJavaParser.Dot, i); + } + public List Identifier() { return getTokens(SimpleJavaParser.Identifier); } + public TerminalNode Identifier(int i) { + return getToken(SimpleJavaParser.Identifier, i); + } + public MemberAccessContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_memberAccess; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMemberAccess(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMemberAccess(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMemberAccess(this); + else return visitor.visitChildren(this); + } + } + + public final MemberAccessContext memberAccess() throws RecognitionException { + MemberAccessContext _localctx = new MemberAccessContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_memberAccess); + int _la; + try { + int _alt; + setState(316); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,31,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(302); + match(This); + setState(303); + match(Dot); + setState(304); + match(Identifier); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(307); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==This) { + { + setState(305); + match(This); + setState(306); + match(Dot); + } + } + + setState(311); + _errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + setState(309); + match(Identifier); + setState(310); + match(Dot); + } + } + break; + default: + throw new NoViableAltException(this); + } + setState(313); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,30,_ctx); + } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); + setState(315); + match(Identifier); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BinaryExpressionContext extends ParserRuleContext { + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public NonCalculationExpressionContext nonCalculationExpression() { + return getRuleContext(NonCalculationExpressionContext.class,0); + } + public BinaryExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_binaryExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBinaryExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBinaryExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBinaryExpression(this); + else return visitor.visitChildren(this); + } + } + + public final BinaryExpressionContext binaryExpression() throws RecognitionException { + BinaryExpressionContext _localctx = new BinaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_binaryExpression); + try { + setState(320); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,32,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(318); + calculationExpression(0); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(319); + nonCalculationExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CalculationExpressionContext extends ParserRuleContext { + public DotExpressionContext dotExpression() { + return getRuleContext(DotExpressionContext.class,0); + } + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public TerminalNode LineOperator() { return getToken(SimpleJavaParser.LineOperator, 0); } + public CalculationExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_calculationExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCalculationExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCalculationExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCalculationExpression(this); + else return visitor.visitChildren(this); + } + } + + public final CalculationExpressionContext calculationExpression() throws RecognitionException { + return calculationExpression(0); + } + + private CalculationExpressionContext calculationExpression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + CalculationExpressionContext _localctx = new CalculationExpressionContext(_ctx, _parentState); + CalculationExpressionContext _prevctx = _localctx; + int _startState = 68; + enterRecursionRule(_localctx, 68, RULE_calculationExpression, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(323); + dotExpression(0); + } + _ctx.stop = _input.LT(-1); + setState(330); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,33,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new CalculationExpressionContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_calculationExpression); + setState(325); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(326); + match(LineOperator); + setState(327); + dotExpression(0); + } + } + } + setState(332); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,33,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotExpressionContext extends ParserRuleContext { + public DotSubtractionExpressionContext dotSubtractionExpression() { + return getRuleContext(DotSubtractionExpressionContext.class,0); + } + public DotExpressionContext dotExpression() { + return getRuleContext(DotExpressionContext.class,0); + } + public TerminalNode DotOperator() { return getToken(SimpleJavaParser.DotOperator, 0); } + public DotExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DotExpressionContext dotExpression() throws RecognitionException { + return dotExpression(0); + } + + private DotExpressionContext dotExpression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + DotExpressionContext _localctx = new DotExpressionContext(_ctx, _parentState); + DotExpressionContext _prevctx = _localctx; + int _startState = 70; + enterRecursionRule(_localctx, 70, RULE_dotExpression, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(334); + dotSubtractionExpression(); + } + _ctx.stop = _input.LT(-1); + setState(341); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,34,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new DotExpressionContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_dotExpression); + setState(336); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(337); + match(DotOperator); + setState(338); + dotSubtractionExpression(); + } + } + } + setState(343); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,34,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotSubtractionExpressionContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public DotSubtractionExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotSubtractionExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotSubtractionExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotSubtractionExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotSubtractionExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DotSubtractionExpressionContext dotSubtractionExpression() throws RecognitionException { + DotSubtractionExpressionContext _localctx = new DotSubtractionExpressionContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_dotSubtractionExpression); + try { + setState(352); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,35,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(344); + match(IntValue); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(345); + match(Identifier); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(346); + memberAccess(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(347); + methodCall(); + setState(348); + match(OpenRoundBracket); + setState(349); + calculationExpression(0); + setState(350); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalculationExpressionContext extends ParserRuleContext { + public UnaryExpressionContext unaryExpression() { + return getRuleContext(UnaryExpressionContext.class,0); + } + public NonCalculationOperatorContext nonCalculationOperator() { + return getRuleContext(NonCalculationOperatorContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public NonCalculationExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalculationExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationExpression(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalculationExpressionContext nonCalculationExpression() throws RecognitionException { + NonCalculationExpressionContext _localctx = new NonCalculationExpressionContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_nonCalculationExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(354); + unaryExpression(); + setState(355); + nonCalculationOperator(); + setState(356); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodCallContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TargetContext target() { + return getRuleContext(TargetContext.class,0); + } + public List chainedMethod() { + return getRuleContexts(ChainedMethodContext.class); + } + public ChainedMethodContext chainedMethod(int i) { + return getRuleContext(ChainedMethodContext.class,i); + } + public MethodCallContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodCall; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodCall(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodCall(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodCall(this); + else return visitor.visitChildren(this); + } + } + + public final MethodCallContext methodCall() throws RecognitionException { + MethodCallContext _localctx = new MethodCallContext(_ctx, getState()); + enterRule(_localctx, 76, RULE_methodCall); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(359); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { + case 1: + { + setState(358); + target(); + } + break; + } + setState(364); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(361); + chainedMethod(); + } + } + } + setState(366); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); + } + setState(367); + match(Identifier); + setState(368); + match(OpenRoundBracket); + setState(369); + argumentList(); + setState(370); + match(ClosedRoundBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TargetContext extends ParserRuleContext { + public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public NewDeclarationContext newDeclaration() { + return getRuleContext(NewDeclarationContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TargetContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_target; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterTarget(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitTarget(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitTarget(this); + else return visitor.visitChildren(this); + } + } + + public final TargetContext target() throws RecognitionException { + TargetContext _localctx = new TargetContext(_ctx, getState()); + enterRule(_localctx, 78, RULE_target); + try { + enterOuterAlt(_localctx, 1); + { + setState(376); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,38,_ctx) ) { + case 1: + { + setState(372); + match(This); + } + break; + case 2: + { + setState(373); + memberAccess(); + } + break; + case 3: + { + setState(374); + newDeclaration(); + } + break; + case 4: + { + setState(375); + match(Identifier); + } + break; + } + setState(378); + match(Dot); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ChainedMethodContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } + public ChainedMethodContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_chainedMethod; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterChainedMethod(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitChainedMethod(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitChainedMethod(this); + else return visitor.visitChildren(this); + } + } + + public final ChainedMethodContext chainedMethod() throws RecognitionException { + ChainedMethodContext _localctx = new ChainedMethodContext(_ctx, getState()); + enterRule(_localctx, 80, RULE_chainedMethod); + try { + enterOuterAlt(_localctx, 1); + { + setState(380); + match(Identifier); + setState(381); + match(OpenRoundBracket); + setState(382); + argumentList(); + setState(383); + match(ClosedRoundBracket); + setState(384); + match(Dot); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TypeContext extends ParserRuleContext { + public TerminalNode Int() { return getToken(SimpleJavaParser.Int, 0); } + public TerminalNode Boolean() { return getToken(SimpleJavaParser.Boolean, 0); } + public TerminalNode Char() { return getToken(SimpleJavaParser.Char, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_type; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterType(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitType(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + TypeContext _localctx = new TypeContext(_ctx, getState()); + enterRule(_localctx, 82, RULE_type); int _la; try { enterOuterAlt(_localctx, 1); { - setState(205); + setState(386); _la = _input.LA(1); - if ( !(_la==T__32 || _la==T__33) ) { + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) ) { _errHandler.recoverInline(this); } else { @@ -1603,38 +3062,100 @@ public class SimpleJavaParser extends Parser { } @SuppressWarnings("CheckReturnValue") - public static class CharLiteralContext extends ParserRuleContext { - public CharLiteralContext(ParserRuleContext parent, int invokingState) { + public static class ValueContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } + public TerminalNode BooleanValue() { return getToken(SimpleJavaParser.BooleanValue, 0); } + public TerminalNode CharValue() { return getToken(SimpleJavaParser.CharValue, 0); } + public TerminalNode NullValue() { return getToken(SimpleJavaParser.NullValue, 0); } + public ValueContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - @Override public int getRuleIndex() { return RULE_charLiteral; } + @Override public int getRuleIndex() { return RULE_value; } @Override public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCharLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterValue(this); } @Override public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCharLiteral(this); + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitValue(this); } @Override public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCharLiteral(this); + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitValue(this); else return visitor.visitChildren(this); } } - public final CharLiteralContext charLiteral() throws RecognitionException { - CharLiteralContext _localctx = new CharLiteralContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_charLiteral); + public final ValueContext value() throws RecognitionException { + ValueContext _localctx = new ValueContext(_ctx, getState()); + enterRule(_localctx, 84, RULE_value); + int _la; try { enterOuterAlt(_localctx, 1); { - setState(207); - match(T__34); - setState(208); - matchWildcard(); - setState(209); - match(T__34); + setState(388); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 131941395333120L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalculationOperatorContext extends ParserRuleContext { + public TerminalNode LogicalOperator() { return getToken(SimpleJavaParser.LogicalOperator, 0); } + public TerminalNode ComparisonOperator() { return getToken(SimpleJavaParser.ComparisonOperator, 0); } + public NonCalculationOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalculationOperator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationOperator(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalculationOperatorContext nonCalculationOperator() throws RecognitionException { + NonCalculationOperatorContext _localctx = new NonCalculationOperatorContext(_ctx, getState()); + enterRule(_localctx, 86, RULE_nonCalculationOperator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(390); + _la = _input.LA(1); + if ( !(_la==ComparisonOperator || _la==LogicalOperator) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } } } catch (RecognitionException re) { @@ -1650,152 +3171,271 @@ public class SimpleJavaParser extends Parser { public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { - case 18: - return expression_sempred((ExpressionContext)_localctx, predIndex); + case 34: + return calculationExpression_sempred((CalculationExpressionContext)_localctx, predIndex); + case 35: + return dotExpression_sempred((DotExpressionContext)_localctx, predIndex); } return true; } - private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { + private boolean calculationExpression_sempred(CalculationExpressionContext _localctx, int predIndex) { switch (predIndex) { case 0: - return precpred(_ctx, 8); + return precpred(_ctx, 2); + } + return true; + } + private boolean dotExpression_sempred(DotExpressionContext _localctx, int predIndex) { + switch (predIndex) { case 1: - return precpred(_ctx, 7); - case 2: - return precpred(_ctx, 6); + return precpred(_ctx, 2); } return true; } public static final String _serializedATN = - "\u0004\u0001&\u00d4\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0004\u00012\u0189\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\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ - "\u0001\u0000\u0004\u0000.\b\u0000\u000b\u0000\f\u0000/\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u00017\b\u0001\n\u0001"+ - "\f\u0001:\t\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+ - "\u0002\u0003\u0002A\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\u0004N\b\u0004\u0001\u0004\u0001\u0004\u0001"+ - "\u0004\u0005\u0004S\b\u0004\n\u0004\f\u0004V\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\u0005c\b\u0005\n\u0005"+ - "\f\u0005f\t\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001"+ - "\u0006\u0005\u0006m\b\u0006\n\u0006\f\u0006p\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\u007f\b\n\u0001\u000b\u0001\u000b\u0001"+ - "\u000b\u0001\u000b\u0003\u000b\u0085\b\u000b\u0001\u000b\u0001\u000b\u0001"+ - "\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e"+ - "\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e"+ - "\u0097\b\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f"+ - "\u0001\u000f\u0001\u0010\u0001\u0010\u0003\u0010\u00a1\b\u0010\u0001\u0010"+ - "\u0001\u0010\u0001\u0011\u0001\u0011\u0005\u0011\u00a7\b\u0011\n\u0011"+ - "\f\u0011\u00aa\t\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0001\u0012\u0003\u0012\u00b9\b\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0005\u0012\u00c4\b\u0012\n\u0012\f\u0012\u00c7"+ - "\t\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0003\u0013\u00cc\b\u0013"+ - "\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015"+ - "\u0001\u0015\u0000\u0001$\u0016\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!\"\u00d8\u0000-\u0001\u0000\u0000"+ - "\u0000\u00021\u0001\u0000\u0000\u0000\u0004@\u0001\u0000\u0000\u0000\u0006"+ - "B\u0001\u0000\u0000\u0000\bG\u0001\u0000\u0000\u0000\nY\u0001\u0000\u0000"+ - "\u0000\fi\u0001\u0000\u0000\u0000\u000eq\u0001\u0000\u0000\u0000\u0010"+ - "t\u0001\u0000\u0000\u0000\u0012v\u0001\u0000\u0000\u0000\u0014~\u0001"+ - "\u0000\u0000\u0000\u0016\u0080\u0001\u0000\u0000\u0000\u0018\u0088\u0001"+ - "\u0000\u0000\u0000\u001a\u008d\u0001\u0000\u0000\u0000\u001c\u008f\u0001"+ - "\u0000\u0000\u0000\u001e\u0098\u0001\u0000\u0000\u0000 \u009e\u0001\u0000"+ - "\u0000\u0000\"\u00a4\u0001\u0000\u0000\u0000$\u00b8\u0001\u0000\u0000"+ - "\u0000&\u00cb\u0001\u0000\u0000\u0000(\u00cd\u0001\u0000\u0000\u0000*"+ - "\u00cf\u0001\u0000\u0000\u0000,.\u0003\u0002\u0001\u0000-,\u0001\u0000"+ - "\u0000\u0000./\u0001\u0000\u0000\u0000/-\u0001\u0000\u0000\u0000/0\u0001"+ - "\u0000\u0000\u00000\u0001\u0001\u0000\u0000\u000012\u0003\u0012\t\u0000"+ - "23\u0005\u0001\u0000\u000034\u0005%\u0000\u000048\u0005\u0002\u0000\u0000"+ - "57\u0003\u0004\u0002\u000065\u0001\u0000\u0000\u00007:\u0001\u0000\u0000"+ - "\u000086\u0001\u0000\u0000\u000089\u0001\u0000\u0000\u00009;\u0001\u0000"+ - "\u0000\u0000:8\u0001\u0000\u0000\u0000;<\u0005\u0003\u0000\u0000<\u0003"+ - "\u0001\u0000\u0000\u0000=A\u0003\u0006\u0003\u0000>A\u0003\b\u0004\u0000"+ - "?A\u0003\n\u0005\u0000@=\u0001\u0000\u0000\u0000@>\u0001\u0000\u0000\u0000"+ - "@?\u0001\u0000\u0000\u0000A\u0005\u0001\u0000\u0000\u0000BC\u0003\u0012"+ - "\t\u0000CD\u0003\u0010\b\u0000DE\u0005%\u0000\u0000EF\u0005\u0004\u0000"+ - "\u0000F\u0007\u0001\u0000\u0000\u0000GH\u0003\u0012\t\u0000HI\u0005\u0005"+ - "\u0000\u0000IJ\u0003\u0010\b\u0000JK\u0005%\u0000\u0000KM\u0005\u0006"+ - "\u0000\u0000LN\u0003\f\u0006\u0000ML\u0001\u0000\u0000\u0000MN\u0001\u0000"+ - "\u0000\u0000NO\u0001\u0000\u0000\u0000OP\u0005\u0007\u0000\u0000PT\u0005"+ - "\u0002\u0000\u0000QS\u0003\u0014\n\u0000RQ\u0001\u0000\u0000\u0000SV\u0001"+ - "\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TU\u0001\u0000\u0000\u0000"+ - "UW\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000WX\u0005\u0003\u0000"+ - "\u0000X\t\u0001\u0000\u0000\u0000YZ\u0003\u0012\t\u0000Z[\u0005%\u0000"+ - "\u0000[]\u0005\u0006\u0000\u0000\\^\u0003\f\u0006\u0000]\\\u0001\u0000"+ - "\u0000\u0000]^\u0001\u0000\u0000\u0000^_\u0001\u0000\u0000\u0000_`\u0005"+ - "\u0007\u0000\u0000`d\u0005\u0002\u0000\u0000ac\u0003\u0014\n\u0000ba\u0001"+ - "\u0000\u0000\u0000cf\u0001\u0000\u0000\u0000db\u0001\u0000\u0000\u0000"+ - "de\u0001\u0000\u0000\u0000eg\u0001\u0000\u0000\u0000fd\u0001\u0000\u0000"+ - "\u0000gh\u0005\u0003\u0000\u0000h\u000b\u0001\u0000\u0000\u0000in\u0003"+ - "\u000e\u0007\u0000jk\u0005\b\u0000\u0000km\u0003\u000e\u0007\u0000lj\u0001"+ - "\u0000\u0000\u0000mp\u0001\u0000\u0000\u0000nl\u0001\u0000\u0000\u0000"+ - "no\u0001\u0000\u0000\u0000o\r\u0001\u0000\u0000\u0000pn\u0001\u0000\u0000"+ - "\u0000qr\u0003\u0010\b\u0000rs\u0005%\u0000\u0000s\u000f\u0001\u0000\u0000"+ - "\u0000tu\u0007\u0000\u0000\u0000u\u0011\u0001\u0000\u0000\u0000vw\u0007"+ - "\u0001\u0000\u0000w\u0013\u0001\u0000\u0000\u0000x\u007f\u0003\u0016\u000b"+ - "\u0000y\u007f\u0003\u0018\f\u0000z\u007f\u0003\u001c\u000e\u0000{\u007f"+ - "\u0003\u001e\u000f\u0000|\u007f\u0003 \u0010\u0000}\u007f\u0003\"\u0011"+ - "\u0000~x\u0001\u0000\u0000\u0000~y\u0001\u0000\u0000\u0000~z\u0001\u0000"+ - "\u0000\u0000~{\u0001\u0000\u0000\u0000~|\u0001\u0000\u0000\u0000~}\u0001"+ - "\u0000\u0000\u0000\u007f\u0015\u0001\u0000\u0000\u0000\u0080\u0081\u0003"+ - "\u0010\b\u0000\u0081\u0084\u0005%\u0000\u0000\u0082\u0083\u0005\u000e"+ - "\u0000\u0000\u0083\u0085\u0003$\u0012\u0000\u0084\u0082\u0001\u0000\u0000"+ - "\u0000\u0084\u0085\u0001\u0000\u0000\u0000\u0085\u0086\u0001\u0000\u0000"+ - "\u0000\u0086\u0087\u0005\u0004\u0000\u0000\u0087\u0017\u0001\u0000\u0000"+ - "\u0000\u0088\u0089\u0003\u001a\r\u0000\u0089\u008a\u0005\u000e\u0000\u0000"+ - "\u008a\u008b\u0003$\u0012\u0000\u008b\u008c\u0005\u0004\u0000\u0000\u008c"+ - "\u0019\u0001\u0000\u0000\u0000\u008d\u008e\u0005%\u0000\u0000\u008e\u001b"+ - "\u0001\u0000\u0000\u0000\u008f\u0090\u0005\u000f\u0000\u0000\u0090\u0091"+ - "\u0005\u0006\u0000\u0000\u0091\u0092\u0003$\u0012\u0000\u0092\u0093\u0005"+ - "\u0007\u0000\u0000\u0093\u0096\u0003\u0014\n\u0000\u0094\u0095\u0005\u0010"+ - "\u0000\u0000\u0095\u0097\u0003\u0014\n\u0000\u0096\u0094\u0001\u0000\u0000"+ - "\u0000\u0096\u0097\u0001\u0000\u0000\u0000\u0097\u001d\u0001\u0000\u0000"+ - "\u0000\u0098\u0099\u0005\u0011\u0000\u0000\u0099\u009a\u0005\u0006\u0000"+ - "\u0000\u009a\u009b\u0003$\u0012\u0000\u009b\u009c\u0005\u0007\u0000\u0000"+ - "\u009c\u009d\u0003\u0014\n\u0000\u009d\u001f\u0001\u0000\u0000\u0000\u009e"+ - "\u00a0\u0005\u0012\u0000\u0000\u009f\u00a1\u0003$\u0012\u0000\u00a0\u009f"+ - "\u0001\u0000\u0000\u0000\u00a0\u00a1\u0001\u0000\u0000\u0000\u00a1\u00a2"+ - "\u0001\u0000\u0000\u0000\u00a2\u00a3\u0005\u0004\u0000\u0000\u00a3!\u0001"+ - "\u0000\u0000\u0000\u00a4\u00a8\u0005\u0002\u0000\u0000\u00a5\u00a7\u0003"+ - "\u0014\n\u0000\u00a6\u00a5\u0001\u0000\u0000\u0000\u00a7\u00aa\u0001\u0000"+ - "\u0000\u0000\u00a8\u00a6\u0001\u0000\u0000\u0000\u00a8\u00a9\u0001\u0000"+ - "\u0000\u0000\u00a9\u00ab\u0001\u0000\u0000\u0000\u00aa\u00a8\u0001\u0000"+ - "\u0000\u0000\u00ab\u00ac\u0005\u0003\u0000\u0000\u00ac#\u0001\u0000\u0000"+ - "\u0000\u00ad\u00ae\u0006\u0012\uffff\uffff\u0000\u00ae\u00af\u0005\u001c"+ - "\u0000\u0000\u00af\u00b9\u0003$\u0012\u0005\u00b0\u00b1\u0005 \u0000\u0000"+ - "\u00b1\u00b9\u0003$\u0012\u0004\u00b2\u00b3\u0005\u0006\u0000\u0000\u00b3"+ - "\u00b4\u0003$\u0012\u0000\u00b4\u00b5\u0005\u0007\u0000\u0000\u00b5\u00b9"+ - "\u0001\u0000\u0000\u0000\u00b6\u00b9\u0003&\u0013\u0000\u00b7\u00b9\u0005"+ - "%\u0000\u0000\u00b8\u00ad\u0001\u0000\u0000\u0000\u00b8\u00b0\u0001\u0000"+ - "\u0000\u0000\u00b8\u00b2\u0001\u0000\u0000\u0000\u00b8\u00b6\u0001\u0000"+ - "\u0000\u0000\u00b8\u00b7\u0001\u0000\u0000\u0000\u00b9\u00c5\u0001\u0000"+ - "\u0000\u0000\u00ba\u00bb\n\b\u0000\u0000\u00bb\u00bc\u0007\u0002\u0000"+ - "\u0000\u00bc\u00c4\u0003$\u0012\t\u00bd\u00be\n\u0007\u0000\u0000\u00be"+ - "\u00bf\u0007\u0003\u0000\u0000\u00bf\u00c4\u0003$\u0012\b\u00c0\u00c1"+ - "\n\u0006\u0000\u0000\u00c1\u00c2\u0007\u0004\u0000\u0000\u00c2\u00c4\u0003"+ - "$\u0012\u0007\u00c3\u00ba\u0001\u0000\u0000\u0000\u00c3\u00bd\u0001\u0000"+ - "\u0000\u0000\u00c3\u00c0\u0001\u0000\u0000\u0000\u00c4\u00c7\u0001\u0000"+ - "\u0000\u0000\u00c5\u00c3\u0001\u0000\u0000\u0000\u00c5\u00c6\u0001\u0000"+ - "\u0000\u0000\u00c6%\u0001\u0000\u0000\u0000\u00c7\u00c5\u0001\u0000\u0000"+ - "\u0000\u00c8\u00cc\u0005$\u0000\u0000\u00c9\u00cc\u0003(\u0014\u0000\u00ca"+ - "\u00cc\u0003*\u0015\u0000\u00cb\u00c8\u0001\u0000\u0000\u0000\u00cb\u00c9"+ - "\u0001\u0000\u0000\u0000\u00cb\u00ca\u0001\u0000\u0000\u0000\u00cc\'\u0001"+ - "\u0000\u0000\u0000\u00cd\u00ce\u0007\u0005\u0000\u0000\u00ce)\u0001\u0000"+ - "\u0000\u0000\u00cf\u00d0\u0005#\u0000\u0000\u00d0\u00d1\t\u0000\u0000"+ - "\u0000\u00d1\u00d2\u0005#\u0000\u0000\u00d2+\u0001\u0000\u0000\u0000\u0011"+ - "/8@MT]dn~\u0084\u0096\u00a0\u00a8\u00b8\u00c3\u00c5\u00cb"; + "\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ + "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ + "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ + "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ + "#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002"+ + "(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007+\u0001\u0000\u0004\u0000"+ + "Z\b\u0000\u000b\u0000\f\u0000[\u0001\u0001\u0003\u0001_\b\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u0001e\b\u0001\n\u0001"+ + "\f\u0001h\t\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+ + "\u0002\u0003\u0002o\b\u0002\u0001\u0003\u0003\u0003r\b\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0003\u0003w\b\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0004\u0003\u0004}\b\u0004\u0001\u0004\u0001\u0004"+ + "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0003\u0005"+ + "\u0086\b\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008a\b\u0005\u0001"+ + "\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008f\b\u0005\u0001\u0005\u0001"+ + "\u0005\u0003\u0005\u0093\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0005"+ + "\u0006\u0098\b\u0006\n\u0006\f\u0006\u009b\t\u0006\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\b\u0001\b\u0001\b\u0005\b\u00a3\b\b\n\b\f\b\u00a6\t"+ + "\b\u0003\b\u00a8\b\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+ + "\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0003\t\u00b7\b\t\u0001"+ + "\n\u0001\n\u0005\n\u00bb\b\n\n\n\f\n\u00be\t\n\u0001\n\u0001\n\u0001\u000b"+ + "\u0001\u000b\u0003\u000b\u00c4\b\u000b\u0001\f\u0001\f\u0001\f\u0001\f"+ + "\u0003\f\u00ca\b\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e\u00d6\b\u000e\u0001"+ + "\u000e\u0001\u000e\u0003\u000e\u00da\b\u000e\u0001\u000e\u0001\u000e\u0003"+ + "\u000e\u00de\b\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ + "\u000f\u0003\u000f\u00e5\b\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+ + "\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ + "\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0003\u0012\u00f4\b\u0012\u0001"+ + "\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001"+ + "\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0003"+ + "\u0015\u0102\b\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001"+ + "\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0003"+ + "\u0016\u010e\b\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001"+ + "\u0018\u0003\u0018\u0115\b\u0018\u0001\u0019\u0001\u0019\u0003\u0019\u0119"+ + "\b\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001"+ + "\u001b\u0001\u001c\u0001\u001c\u0003\u001c\u0123\b\u001c\u0001\u001d\u0001"+ + "\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001"+ + "\u001f\u0003\u001f\u012d\b\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0003"+ + " \u0134\b \u0001 \u0001 \u0004 \u0138\b \u000b \f \u0139\u0001 \u0003"+ + " \u013d\b \u0001!\u0001!\u0003!\u0141\b!\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0005\"\u0149\b\"\n\"\f\"\u014c\t\"\u0001#\u0001#\u0001"+ + "#\u0001#\u0001#\u0001#\u0005#\u0154\b#\n#\f#\u0157\t#\u0001$\u0001$\u0001"+ + "$\u0001$\u0001$\u0001$\u0001$\u0001$\u0003$\u0161\b$\u0001%\u0001%\u0001"+ + "%\u0001%\u0001&\u0003&\u0168\b&\u0001&\u0005&\u016b\b&\n&\f&\u016e\t&"+ + "\u0001&\u0001&\u0001&\u0001&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0003"+ + "\'\u0179\b\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001(\u0001"+ + "(\u0001)\u0001)\u0001*\u0001*\u0001+\u0001+\u0001+\u0000\u0002DF,\u0000"+ + "\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u001c"+ + "\u001e \"$&(*,.02468:<>@BDFHJLNPRTV\u0000\u0003\u0002\u0000\u0004\u0006"+ + "//\u0001\u0000+.\u0001\u0000\u000b\f\u0194\u0000Y\u0001\u0000\u0000\u0000"+ + "\u0002^\u0001\u0000\u0000\u0000\u0004n\u0001\u0000\u0000\u0000\u0006q"+ + "\u0001\u0000\u0000\u0000\b|\u0001\u0000\u0000\u0000\n\u0092\u0001\u0000"+ + "\u0000\u0000\f\u0094\u0001\u0000\u0000\u0000\u000e\u009c\u0001\u0000\u0000"+ + "\u0000\u0010\u00a7\u0001\u0000\u0000\u0000\u0012\u00b6\u0001\u0000\u0000"+ + "\u0000\u0014\u00b8\u0001\u0000\u0000\u0000\u0016\u00c1\u0001\u0000\u0000"+ + "\u0000\u0018\u00c5\u0001\u0000\u0000\u0000\u001a\u00cb\u0001\u0000\u0000"+ + "\u0000\u001c\u00d1\u0001\u0000\u0000\u0000\u001e\u00e2\u0001\u0000\u0000"+ + "\u0000 \u00e6\u0001\u0000\u0000\u0000\"\u00ec\u0001\u0000\u0000\u0000"+ + "$\u00f3\u0001\u0000\u0000\u0000&\u00f5\u0001\u0000\u0000\u0000(\u00f9"+ + "\u0001\u0000\u0000\u0000*\u0101\u0001\u0000\u0000\u0000,\u010d\u0001\u0000"+ + "\u0000\u0000.\u010f\u0001\u0000\u0000\u00000\u0114\u0001\u0000\u0000\u0000"+ + "2\u0118\u0001\u0000\u0000\u00004\u011a\u0001\u0000\u0000\u00006\u011d"+ + "\u0001\u0000\u0000\u00008\u0122\u0001\u0000\u0000\u0000:\u0124\u0001\u0000"+ + "\u0000\u0000<\u0127\u0001\u0000\u0000\u0000>\u012c\u0001\u0000\u0000\u0000"+ + "@\u013c\u0001\u0000\u0000\u0000B\u0140\u0001\u0000\u0000\u0000D\u0142"+ + "\u0001\u0000\u0000\u0000F\u014d\u0001\u0000\u0000\u0000H\u0160\u0001\u0000"+ + "\u0000\u0000J\u0162\u0001\u0000\u0000\u0000L\u0167\u0001\u0000\u0000\u0000"+ + "N\u0178\u0001\u0000\u0000\u0000P\u017c\u0001\u0000\u0000\u0000R\u0182"+ + "\u0001\u0000\u0000\u0000T\u0184\u0001\u0000\u0000\u0000V\u0186\u0001\u0000"+ + "\u0000\u0000XZ\u0003\u0002\u0001\u0000YX\u0001\u0000\u0000\u0000Z[\u0001"+ + "\u0000\u0000\u0000[Y\u0001\u0000\u0000\u0000[\\\u0001\u0000\u0000\u0000"+ + "\\\u0001\u0001\u0000\u0000\u0000]_\u0005\u0007\u0000\u0000^]\u0001\u0000"+ + "\u0000\u0000^_\u0001\u0000\u0000\u0000_`\u0001\u0000\u0000\u0000`a\u0005"+ + "#\u0000\u0000ab\u0005/\u0000\u0000bf\u0005\u001f\u0000\u0000ce\u0003\u0004"+ + "\u0002\u0000dc\u0001\u0000\u0000\u0000eh\u0001\u0000\u0000\u0000fd\u0001"+ + "\u0000\u0000\u0000fg\u0001\u0000\u0000\u0000gi\u0001\u0000\u0000\u0000"+ + "hf\u0001\u0000\u0000\u0000ij\u0005 \u0000\u0000j\u0003\u0001\u0000\u0000"+ + "\u0000ko\u0003\u0006\u0003\u0000lo\u0003\b\u0004\u0000mo\u0003\n\u0005"+ + "\u0000nk\u0001\u0000\u0000\u0000nl\u0001\u0000\u0000\u0000nm\u0001\u0000"+ + "\u0000\u0000o\u0005\u0001\u0000\u0000\u0000pr\u0005\u0007\u0000\u0000"+ + "qp\u0001\u0000\u0000\u0000qr\u0001\u0000\u0000\u0000rs\u0001\u0000\u0000"+ + "\u0000st\u0005/\u0000\u0000tv\u0005\u001d\u0000\u0000uw\u0003\f\u0006"+ + "\u0000vu\u0001\u0000\u0000\u0000vw\u0001\u0000\u0000\u0000wx\u0001\u0000"+ + "\u0000\u0000xy\u0005\u001e\u0000\u0000yz\u0003\u0014\n\u0000z\u0007\u0001"+ + "\u0000\u0000\u0000{}\u0005\u0007\u0000\u0000|{\u0001\u0000\u0000\u0000"+ + "|}\u0001\u0000\u0000\u0000}~\u0001\u0000\u0000\u0000~\u007f\u0003R)\u0000"+ + "\u007f\u0080\u0005/\u0000\u0000\u0080\u0081\u0005!\u0000\u0000\u0081\t"+ + "\u0001\u0000\u0000\u0000\u0082\u0083\u0005\b\u0000\u0000\u0083\u0093\u0003"+ + "\u0014\n\u0000\u0084\u0086\u0005\u0007\u0000\u0000\u0085\u0084\u0001\u0000"+ + "\u0000\u0000\u0085\u0086\u0001\u0000\u0000\u0000\u0086\u0089\u0001\u0000"+ + "\u0000\u0000\u0087\u008a\u0003R)\u0000\u0088\u008a\u0005\u0003\u0000\u0000"+ + "\u0089\u0087\u0001\u0000\u0000\u0000\u0089\u0088\u0001\u0000\u0000\u0000"+ + "\u008a\u008b\u0001\u0000\u0000\u0000\u008b\u008c\u0005/\u0000\u0000\u008c"+ + "\u008e\u0005\u001d\u0000\u0000\u008d\u008f\u0003\f\u0006\u0000\u008e\u008d"+ + "\u0001\u0000\u0000\u0000\u008e\u008f\u0001\u0000\u0000\u0000\u008f\u0090"+ + "\u0001\u0000\u0000\u0000\u0090\u0091\u0005\u001e\u0000\u0000\u0091\u0093"+ + "\u0003\u0014\n\u0000\u0092\u0082\u0001\u0000\u0000\u0000\u0092\u0085\u0001"+ + "\u0000\u0000\u0000\u0093\u000b\u0001\u0000\u0000\u0000\u0094\u0099\u0003"+ + "\u000e\u0007\u0000\u0095\u0096\u0005\"\u0000\u0000\u0096\u0098\u0003\u000e"+ + "\u0007\u0000\u0097\u0095\u0001\u0000\u0000\u0000\u0098\u009b\u0001\u0000"+ + "\u0000\u0000\u0099\u0097\u0001\u0000\u0000\u0000\u0099\u009a\u0001\u0000"+ + "\u0000\u0000\u009a\r\u0001\u0000\u0000\u0000\u009b\u0099\u0001\u0000\u0000"+ + "\u0000\u009c\u009d\u0003R)\u0000\u009d\u009e\u0005/\u0000\u0000\u009e"+ + "\u000f\u0001\u0000\u0000\u0000\u009f\u00a4\u0003*\u0015\u0000\u00a0\u00a1"+ + "\u0005\"\u0000\u0000\u00a1\u00a3\u0003*\u0015\u0000\u00a2\u00a0\u0001"+ + "\u0000\u0000\u0000\u00a3\u00a6\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001"+ + "\u0000\u0000\u0000\u00a4\u00a5\u0001\u0000\u0000\u0000\u00a5\u00a8\u0001"+ + "\u0000\u0000\u0000\u00a6\u00a4\u0001\u0000\u0000\u0000\u00a7\u009f\u0001"+ + "\u0000\u0000\u0000\u00a7\u00a8\u0001\u0000\u0000\u0000\u00a8\u0011\u0001"+ + "\u0000\u0000\u0000\u00a9\u00aa\u0003\u0016\u000b\u0000\u00aa\u00ab\u0005"+ + "!\u0000\u0000\u00ab\u00b7\u0001\u0000\u0000\u0000\u00ac\u00ad\u0003\u0018"+ + "\f\u0000\u00ad\u00ae\u0005!\u0000\u0000\u00ae\u00b7\u0001\u0000\u0000"+ + "\u0000\u00af\u00b7\u0003\u0014\n\u0000\u00b0\u00b7\u0003\u001a\r\u0000"+ + "\u00b1\u00b7\u0003\u001c\u000e\u0000\u00b2\u00b7\u0003\u001e\u000f\u0000"+ + "\u00b3\u00b4\u0003$\u0012\u0000\u00b4\u00b5\u0005!\u0000\u0000\u00b5\u00b7"+ + "\u0001\u0000\u0000\u0000\u00b6\u00a9\u0001\u0000\u0000\u0000\u00b6\u00ac"+ + "\u0001\u0000\u0000\u0000\u00b6\u00af\u0001\u0000\u0000\u0000\u00b6\u00b0"+ + "\u0001\u0000\u0000\u0000\u00b6\u00b1\u0001\u0000\u0000\u0000\u00b6\u00b2"+ + "\u0001\u0000\u0000\u0000\u00b6\u00b3\u0001\u0000\u0000\u0000\u00b7\u0013"+ + "\u0001\u0000\u0000\u0000\u00b8\u00bc\u0005\u001f\u0000\u0000\u00b9\u00bb"+ + "\u0003\u0012\t\u0000\u00ba\u00b9\u0001\u0000\u0000\u0000\u00bb\u00be\u0001"+ + "\u0000\u0000\u0000\u00bc\u00ba\u0001\u0000\u0000\u0000\u00bc\u00bd\u0001"+ + "\u0000\u0000\u0000\u00bd\u00bf\u0001\u0000\u0000\u0000\u00be\u00bc\u0001"+ + "\u0000\u0000\u0000\u00bf\u00c0\u0005 \u0000\u0000\u00c0\u0015\u0001\u0000"+ + "\u0000\u0000\u00c1\u00c3\u0005)\u0000\u0000\u00c2\u00c4\u0003*\u0015\u0000"+ + "\u00c3\u00c2\u0001\u0000\u0000\u0000\u00c3\u00c4\u0001\u0000\u0000\u0000"+ + "\u00c4\u0017\u0001\u0000\u0000\u0000\u00c5\u00c6\u0003R)\u0000\u00c6\u00c9"+ + "\u0005/\u0000\u0000\u00c7\u00c8\u0005\r\u0000\u0000\u00c8\u00ca\u0003"+ + "*\u0015\u0000\u00c9\u00c7\u0001\u0000\u0000\u0000\u00c9\u00ca\u0001\u0000"+ + "\u0000\u0000\u00ca\u0019\u0001\u0000\u0000\u0000\u00cb\u00cc\u0005%\u0000"+ + "\u0000\u00cc\u00cd\u0005\u001d\u0000\u0000\u00cd\u00ce\u0003*\u0015\u0000"+ + "\u00ce\u00cf\u0005\u001e\u0000\u0000\u00cf\u00d0\u0003\u0014\n\u0000\u00d0"+ + "\u001b\u0001\u0000\u0000\u0000\u00d1\u00d2\u0005(\u0000\u0000\u00d2\u00d5"+ + "\u0005\u001d\u0000\u0000\u00d3\u00d6\u0003$\u0012\u0000\u00d4\u00d6\u0003"+ + "\u0018\f\u0000\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d5\u00d4\u0001\u0000"+ + "\u0000\u0000\u00d6\u00d7\u0001\u0000\u0000\u0000\u00d7\u00d9\u0005!\u0000"+ + "\u0000\u00d8\u00da\u0003*\u0015\u0000\u00d9\u00d8\u0001\u0000\u0000\u0000"+ + "\u00d9\u00da\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000"+ + "\u00db\u00dd\u0005!\u0000\u0000\u00dc\u00de\u0003$\u0012\u0000\u00dd\u00dc"+ + "\u0001\u0000\u0000\u0000\u00dd\u00de\u0001\u0000\u0000\u0000\u00de\u00df"+ + "\u0001\u0000\u0000\u0000\u00df\u00e0\u0005\u001e\u0000\u0000\u00e0\u00e1"+ + "\u0003\u0012\t\u0000\u00e1\u001d\u0001\u0000\u0000\u0000\u00e2\u00e4\u0003"+ + " \u0010\u0000\u00e3\u00e5\u0003\"\u0011\u0000\u00e4\u00e3\u0001\u0000"+ + "\u0000\u0000\u00e4\u00e5\u0001\u0000\u0000\u0000\u00e5\u001f\u0001\u0000"+ + "\u0000\u0000\u00e6\u00e7\u0005&\u0000\u0000\u00e7\u00e8\u0005\u001d\u0000"+ + "\u0000\u00e8\u00e9\u0003*\u0015\u0000\u00e9\u00ea\u0005\u001e\u0000\u0000"+ + "\u00ea\u00eb\u0003\u0012\t\u0000\u00eb!\u0001\u0000\u0000\u0000\u00ec"+ + "\u00ed\u0005\'\u0000\u0000\u00ed\u00ee\u0003\u0012\t\u0000\u00ee#\u0001"+ + "\u0000\u0000\u0000\u00ef\u00f4\u0003&\u0013\u0000\u00f0\u00f4\u0003(\u0014"+ + "\u0000\u00f1\u00f4\u0003L&\u0000\u00f2\u00f4\u00030\u0018\u0000\u00f3"+ + "\u00ef\u0001\u0000\u0000\u0000\u00f3\u00f0\u0001\u0000\u0000\u0000\u00f3"+ + "\u00f1\u0001\u0000\u0000\u0000\u00f3\u00f2\u0001\u0000\u0000\u0000\u00f4"+ + "%\u0001\u0000\u0000\u0000\u00f5\u00f6\u0003>\u001f\u0000\u00f6\u00f7\u0005"+ + "\r\u0000\u0000\u00f7\u00f8\u0003*\u0015\u0000\u00f8\'\u0001\u0000\u0000"+ + "\u0000\u00f9\u00fa\u0005*\u0000\u0000\u00fa\u00fb\u0005/\u0000\u0000\u00fb"+ + "\u00fc\u0005\u001d\u0000\u0000\u00fc\u00fd\u0003\u0010\b\u0000\u00fd\u00fe"+ + "\u0005\u001e\u0000\u0000\u00fe)\u0001\u0000\u0000\u0000\u00ff\u0102\u0003"+ + ",\u0016\u0000\u0100\u0102\u0003B!\u0000\u0101\u00ff\u0001\u0000\u0000"+ + "\u0000\u0101\u0100\u0001\u0000\u0000\u0000\u0102+\u0001\u0000\u0000\u0000"+ + "\u0103\u010e\u0005$\u0000\u0000\u0104\u010e\u0005/\u0000\u0000\u0105\u010e"+ + "\u0003@ \u0000\u0106\u010e\u0003T*\u0000\u0107\u010e\u0003.\u0017\u0000"+ + "\u0108\u010e\u0003$\u0012\u0000\u0109\u010a\u0005\u001d\u0000\u0000\u010a"+ + "\u010b\u0003*\u0015\u0000\u010b\u010c\u0005\u001e\u0000\u0000\u010c\u010e"+ + "\u0001\u0000\u0000\u0000\u010d\u0103\u0001\u0000\u0000\u0000\u010d\u0104"+ + "\u0001\u0000\u0000\u0000\u010d\u0105\u0001\u0000\u0000\u0000\u010d\u0106"+ + "\u0001\u0000\u0000\u0000\u010d\u0107\u0001\u0000\u0000\u0000\u010d\u0108"+ + "\u0001\u0000\u0000\u0000\u010d\u0109\u0001\u0000\u0000\u0000\u010e-\u0001"+ + "\u0000\u0000\u0000\u010f\u0110\u0005\u0019\u0000\u0000\u0110\u0111\u0003"+ + "*\u0015\u0000\u0111/\u0001\u0000\u0000\u0000\u0112\u0115\u00032\u0019"+ + "\u0000\u0113\u0115\u00038\u001c\u0000\u0114\u0112\u0001\u0000\u0000\u0000"+ + "\u0114\u0113\u0001\u0000\u0000\u0000\u01151\u0001\u0000\u0000\u0000\u0116"+ + "\u0119\u00034\u001a\u0000\u0117\u0119\u00036\u001b\u0000\u0118\u0116\u0001"+ + "\u0000\u0000\u0000\u0118\u0117\u0001\u0000\u0000\u0000\u01193\u0001\u0000"+ + "\u0000\u0000\u011a\u011b\u0005\u0001\u0000\u0000\u011b\u011c\u0003>\u001f"+ + "\u0000\u011c5\u0001\u0000\u0000\u0000\u011d\u011e\u0003>\u001f\u0000\u011e"+ + "\u011f\u0005\u0001\u0000\u0000\u011f7\u0001\u0000\u0000\u0000\u0120\u0123"+ + "\u0003:\u001d\u0000\u0121\u0123\u0003<\u001e\u0000\u0122\u0120\u0001\u0000"+ + "\u0000\u0000\u0122\u0121\u0001\u0000\u0000\u0000\u01239\u0001\u0000\u0000"+ + "\u0000\u0124\u0125\u0005\u0002\u0000\u0000\u0125\u0126\u0003>\u001f\u0000"+ + "\u0126;\u0001\u0000\u0000\u0000\u0127\u0128\u0003>\u001f\u0000\u0128\u0129"+ + "\u0005\u0002\u0000\u0000\u0129=\u0001\u0000\u0000\u0000\u012a\u012d\u0005"+ + "/\u0000\u0000\u012b\u012d\u0003@ \u0000\u012c\u012a\u0001\u0000\u0000"+ + "\u0000\u012c\u012b\u0001\u0000\u0000\u0000\u012d?\u0001\u0000\u0000\u0000"+ + "\u012e\u012f\u0005$\u0000\u0000\u012f\u0130\u0005\u001c\u0000\u0000\u0130"+ + "\u013d\u0005/\u0000\u0000\u0131\u0132\u0005$\u0000\u0000\u0132\u0134\u0005"+ + "\u001c\u0000\u0000\u0133\u0131\u0001\u0000\u0000\u0000\u0133\u0134\u0001"+ + "\u0000\u0000\u0000\u0134\u0137\u0001\u0000\u0000\u0000\u0135\u0136\u0005"+ + "/\u0000\u0000\u0136\u0138\u0005\u001c\u0000\u0000\u0137\u0135\u0001\u0000"+ + "\u0000\u0000\u0138\u0139\u0001\u0000\u0000\u0000\u0139\u0137\u0001\u0000"+ + "\u0000\u0000\u0139\u013a\u0001\u0000\u0000\u0000\u013a\u013b\u0001\u0000"+ + "\u0000\u0000\u013b\u013d\u0005/\u0000\u0000\u013c\u012e\u0001\u0000\u0000"+ + "\u0000\u013c\u0133\u0001\u0000\u0000\u0000\u013dA\u0001\u0000\u0000\u0000"+ + "\u013e\u0141\u0003D\"\u0000\u013f\u0141\u0003J%\u0000\u0140\u013e\u0001"+ + "\u0000\u0000\u0000\u0140\u013f\u0001\u0000\u0000\u0000\u0141C\u0001\u0000"+ + "\u0000\u0000\u0142\u0143\u0006\"\uffff\uffff\u0000\u0143\u0144\u0003F"+ + "#\u0000\u0144\u014a\u0001\u0000\u0000\u0000\u0145\u0146\n\u0002\u0000"+ + "\u0000\u0146\u0147\u0005\n\u0000\u0000\u0147\u0149\u0003F#\u0000\u0148"+ + "\u0145\u0001\u0000\u0000\u0000\u0149\u014c\u0001\u0000\u0000\u0000\u014a"+ + "\u0148\u0001\u0000\u0000\u0000\u014a\u014b\u0001\u0000\u0000\u0000\u014b"+ + "E\u0001\u0000\u0000\u0000\u014c\u014a\u0001\u0000\u0000\u0000\u014d\u014e"+ + "\u0006#\uffff\uffff\u0000\u014e\u014f\u0003H$\u0000\u014f\u0155\u0001"+ + "\u0000\u0000\u0000\u0150\u0151\n\u0002\u0000\u0000\u0151\u0152\u0005\t"+ + "\u0000\u0000\u0152\u0154\u0003H$\u0000\u0153\u0150\u0001\u0000\u0000\u0000"+ + "\u0154\u0157\u0001\u0000\u0000\u0000\u0155\u0153\u0001\u0000\u0000\u0000"+ + "\u0155\u0156\u0001\u0000\u0000\u0000\u0156G\u0001\u0000\u0000\u0000\u0157"+ + "\u0155\u0001\u0000\u0000\u0000\u0158\u0161\u0005,\u0000\u0000\u0159\u0161"+ + "\u0005/\u0000\u0000\u015a\u0161\u0003@ \u0000\u015b\u015c\u0003L&\u0000"+ + "\u015c\u015d\u0005\u001d\u0000\u0000\u015d\u015e\u0003D\"\u0000\u015e"+ + "\u015f\u0005\u001e\u0000\u0000\u015f\u0161\u0001\u0000\u0000\u0000\u0160"+ + "\u0158\u0001\u0000\u0000\u0000\u0160\u0159\u0001\u0000\u0000\u0000\u0160"+ + "\u015a\u0001\u0000\u0000\u0000\u0160\u015b\u0001\u0000\u0000\u0000\u0161"+ + "I\u0001\u0000\u0000\u0000\u0162\u0163\u0003,\u0016\u0000\u0163\u0164\u0003"+ + "V+\u0000\u0164\u0165\u0003*\u0015\u0000\u0165K\u0001\u0000\u0000\u0000"+ + "\u0166\u0168\u0003N\'\u0000\u0167\u0166\u0001\u0000\u0000\u0000\u0167"+ + "\u0168\u0001\u0000\u0000\u0000\u0168\u016c\u0001\u0000\u0000\u0000\u0169"+ + "\u016b\u0003P(\u0000\u016a\u0169\u0001\u0000\u0000\u0000\u016b\u016e\u0001"+ + "\u0000\u0000\u0000\u016c\u016a\u0001\u0000\u0000\u0000\u016c\u016d\u0001"+ + "\u0000\u0000\u0000\u016d\u016f\u0001\u0000\u0000\u0000\u016e\u016c\u0001"+ + "\u0000\u0000\u0000\u016f\u0170\u0005/\u0000\u0000\u0170\u0171\u0005\u001d"+ + "\u0000\u0000\u0171\u0172\u0003\u0010\b\u0000\u0172\u0173\u0005\u001e\u0000"+ + "\u0000\u0173M\u0001\u0000\u0000\u0000\u0174\u0179\u0005$\u0000\u0000\u0175"+ + "\u0179\u0003@ \u0000\u0176\u0179\u0003(\u0014\u0000\u0177\u0179\u0005"+ + "/\u0000\u0000\u0178\u0174\u0001\u0000\u0000\u0000\u0178\u0175\u0001\u0000"+ + "\u0000\u0000\u0178\u0176\u0001\u0000\u0000\u0000\u0178\u0177\u0001\u0000"+ + "\u0000\u0000\u0179\u017a\u0001\u0000\u0000\u0000\u017a\u017b\u0005\u001c"+ + "\u0000\u0000\u017bO\u0001\u0000\u0000\u0000\u017c\u017d\u0005/\u0000\u0000"+ + "\u017d\u017e\u0005\u001d\u0000\u0000\u017e\u017f\u0003\u0010\b\u0000\u017f"+ + "\u0180\u0005\u001e\u0000\u0000\u0180\u0181\u0005\u001c\u0000\u0000\u0181"+ + "Q\u0001\u0000\u0000\u0000\u0182\u0183\u0007\u0000\u0000\u0000\u0183S\u0001"+ + "\u0000\u0000\u0000\u0184\u0185\u0007\u0001\u0000\u0000\u0185U\u0001\u0000"+ + "\u0000\u0000\u0186\u0187\u0007\u0002\u0000\u0000\u0187W\u0001\u0000\u0000"+ + "\u0000\'[^fnqv|\u0085\u0089\u008e\u0092\u0099\u00a4\u00a7\u00b6\u00bc"+ + "\u00c3\u00c9\u00d5\u00d9\u00dd\u00e4\u00f3\u0101\u010d\u0114\u0118\u0122"+ + "\u012c\u0133\u0139\u013c\u0140\u014a\u0155\u0160\u0167\u016c\u0178"; 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 dd4ca0f..3b31f92 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/Johannes/Documents/Github/JavaCompiler/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/grammar/SimpleJava.g4 by ANTLR 4.13.1 package parser.generated; import org.antlr.v4.runtime.tree.ParseTreeVisitor; @@ -28,6 +28,12 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. * @param ctx the parse tree @@ -40,12 +46,6 @@ 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 @@ -59,17 +59,11 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor { */ T visitParameter(SimpleJavaParser.ParameterContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#type}. + * Visit a parse tree produced by {@link SimpleJavaParser#argumentList}. * @param ctx the parse tree * @return the visitor result */ - T visitType(SimpleJavaParser.TypeContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#accessType}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAccessType(SimpleJavaParser.AccessTypeContext ctx); + T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx); /** * Visit a parse tree produced by {@link SimpleJavaParser#statement}. * @param ctx the parse tree @@ -77,35 +71,11 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor { */ T visitStatement(SimpleJavaParser.StatementContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}. + * Visit a parse tree produced by {@link SimpleJavaParser#block}. * @param ctx the parse tree * @return the visitor result */ - T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#var}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVar(SimpleJavaParser.VarContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + T visitBlock(SimpleJavaParser.BlockContext ctx); /** * Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}. * @param ctx the parse tree @@ -113,11 +83,59 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor { */ T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#block}. + * Visit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. * @param ctx the parse tree * @return the visitor result */ - T visitBlock(SimpleJavaParser.BlockContext ctx); + T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(SimpleJavaParser.AssignContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); /** * Visit a parse tree produced by {@link SimpleJavaParser#expression}. * @param ctx the parse tree @@ -125,21 +143,135 @@ public interface SimpleJavaVisitor extends ParseTreeVisitor { */ T visitExpression(SimpleJavaParser.ExpressionContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#literal}. + * Visit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. * @param ctx the parse tree * @return the visitor result */ - T visitLiteral(SimpleJavaParser.LiteralContext ctx); + T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}. + * Visit a parse tree produced by {@link SimpleJavaParser#notExpression}. * @param ctx the parse tree * @return the visitor result */ - T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx); + T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx); /** - * Visit a parse tree produced by {@link SimpleJavaParser#charLiteral}. + * Visit a parse tree produced by {@link SimpleJavaParser#crementExpression}. * @param ctx the parse tree * @return the visitor result */ - T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx); + T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTarget(SimpleJavaParser.TargetContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitType(SimpleJavaParser.TypeContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValue(SimpleJavaParser.ValueContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); } \ No newline at end of file diff --git a/src/main/java/parser/grammar/SimpleJava.g4 b/src/main/java/parser/grammar/SimpleJava.g4 new file mode 100644 index 0000000..2a63966 --- /dev/null +++ b/src/main/java/parser/grammar/SimpleJava.g4 @@ -0,0 +1,168 @@ +grammar SimpleJava; + +// Programm-Konstrukte +program: classDeclaration+; + +classDeclaration: AccessModifier? 'class' Identifier OpenCurlyBracket memberDeclaration* ClosedCurlyBracket; +memberDeclaration: constructorDeclaration | fieldDeclaration | methodDeclaration; + +constructorDeclaration: AccessModifier? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; +fieldDeclaration: AccessModifier? type Identifier Semicolon; +methodDeclaration: MainMethodDeclaration block | AccessModifier? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; + +parameterList: parameter (Comma parameter)*; +parameter: type Identifier; +argumentList: (expression (Comma expression)*)?; + +// Anweisungen +statement: returnStatement Semicolon + | localVariableDeclaration Semicolon + | block + | whileStatement + | forStatement + | ifElseStatement + | statementExpression Semicolon; + +block: OpenCurlyBracket statement* ClosedCurlyBracket; + +returnStatement: Return (expression)?; +localVariableDeclaration: type Identifier (Assign expression)?; + +whileStatement: While OpenRoundBracket expression ClosedRoundBracket block; +forStatement: For OpenRoundBracket (statementExpression | localVariableDeclaration) Semicolon (expression)? Semicolon (statementExpression)? ClosedRoundBracket statement; + +ifElseStatement: ifStatement elseStatement?; +ifStatement: If OpenRoundBracket expression ClosedRoundBracket statement; +elseStatement: Else statement; + +statementExpression: assign | newDeclaration | methodCall | crementExpression; +assign: assignableExpression Assign expression; +newDeclaration: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; + +// Ausdrücke +expression: unaryExpression | binaryExpression; + +unaryExpression: This + | Identifier + | memberAccess + | value + | notExpression + | statementExpression + | OpenRoundBracket expression ClosedRoundBracket; + +notExpression: Not expression; + +crementExpression: incrementExpression | decrementExpression; + +incrementExpression: prefixIncrementExpression | suffixIncrementExpression; +prefixIncrementExpression: '++' assignableExpression; +suffixIncrementExpression: assignableExpression '++'; + +decrementExpression: prefixDecrementExpression | suffixDecrementExpression; +prefixDecrementExpression: '--' assignableExpression; +suffixDecrementExpression: assignableExpression '--'; + +assignableExpression: Identifier | memberAccess; + +memberAccess: This Dot Identifier + | (This Dot)? (Identifier Dot)+ Identifier; + +binaryExpression: calculationExpression | nonCalculationExpression; + +calculationExpression: calculationExpression LineOperator dotExpression + | dotExpression; + +dotExpression: dotExpression DotOperator dotSubtractionExpression + | dotSubtractionExpression; + +dotSubtractionExpression: IntValue + | Identifier + | memberAccess + | methodCall OpenRoundBracket calculationExpression ClosedRoundBracket; + +nonCalculationExpression: unaryExpression nonCalculationOperator expression; + +// Methodenaufrufe +methodCall: target? chainedMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; +target: (This | memberAccess | newDeclaration | Identifier) Dot; +chainedMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; + +// Typen +type: Int + | Boolean + | Char + | Identifier; + +Void: 'void'; +Boolean: 'boolean'; +Char: 'char'; +Int: 'int'; + +value: IntValue + | BooleanValue + | CharValue + | NullValue; + +// Zugriffsmodifikatoren +AccessModifier: 'public' | 'private' | 'public static' | 'private static'; +MainMethodDeclaration: 'public static void main(String[] args)'; + +// Operatoren +nonCalculationOperator: LogicalOperator | ComparisonOperator; + +DotOperator: Mult | Div | Modulo; +LineOperator: Plus | Minus; +ComparisonOperator: Greater | Less | GreaterEqual | LessEqual | Equal | NotEqual; +LogicalOperator: And | Or; + +Assign: '='; +Plus: '+'; +Minus: '-'; +Mult: '*'; +Modulo: '%'; +Div: '/'; +Greater: '>'; +Less: '<'; +GreaterEqual: '>='; +LessEqual: '<='; +Equal: '=='; +NotEqual: '!='; +Not: '!'; +And: '&&'; +Or: '||'; + +// Symbole +Dot: '.'; +OpenRoundBracket: '('; +ClosedRoundBracket: ')'; +OpenCurlyBracket: '{'; +ClosedCurlyBracket: '}'; +Semicolon: ';'; +Comma: ','; + +// Schlüsselwörter +Class: 'class'; +This: 'this'; +While: 'while'; +If: 'if'; +Else: 'else'; +For: 'for'; +Return: 'return'; +New: 'new'; + +// Werte +CharValue: '\'' ~[\r\n]* '\''; +IntValue: Minus? Numeric+; +BooleanValue: 'true' | 'false'; +NullValue: 'null'; + +// Bezeichner +fragment Alphabetic: [a-zA-Z]; +fragment Numeric: [0-9]; +fragment ValidIdentSymbols: Alphabetic | Numeric | '$' | '_'; +Identifier: Alphabetic ValidIdentSymbols*; + +// Whitespaces und Kommentare ignorieren +WS: [ \t\r\n]+ -> skip; +InlineComment: '//' ~[\r\n]* -> skip; +MultilineComment: '/*' .*? '*/' -> skip; \ No newline at end of file diff --git a/src/main/java/semantic/Scope.java b/src/main/java/semantic/Scope.java index 7cf4cc9..60e9d2b 100644 --- a/src/main/java/semantic/Scope.java +++ b/src/main/java/semantic/Scope.java @@ -1,6 +1,6 @@ package semantic; -import ast.type.TypeNode; +import oldAst.type.TypeNode; import java.util.HashMap; import java.util.Stack; diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 2d95119..3bce422 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -1,26 +1,25 @@ package semantic; -import ast.*; -import ast.expression.*; -import ast.member.FieldNode; -import ast.member.MemberNode; +import oldAst.*; +import oldAst.expression.*; +import oldAst.member.FieldNode; +import oldAst.member.MemberNode; -import ast.member.MethodNode; -import ast.parameter.ParameterListNode; -import ast.parameter.ParameterNode; -import ast.statement.*; -import ast.type.ReferenceTypeNode; -import ast.expression.This; +import oldAst.member.MethodNode; +import oldAst.parameter.ParameterListNode; +import oldAst.parameter.ParameterNode; +import oldAst.statement.*; +import oldAst.type.ReferenceTypeNode; +import oldAst.expression.This; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; -import ast.type.BaseTypeNode; -import ast.type.EnumTypeNode; -import ast.type.TypeNode; +import oldAst.type.BaseTypeNode; +import oldAst.type.TypeNode; import semantic.context.Context; import semantic.exeptions.AlreadyDeclearedException; import semantic.exeptions.NotDeclearedException; diff --git a/src/main/java/semantic/context/ClassContext.java b/src/main/java/semantic/context/ClassContext.java index 982866f..6b0d386 100644 --- a/src/main/java/semantic/context/ClassContext.java +++ b/src/main/java/semantic/context/ClassContext.java @@ -1,7 +1,7 @@ package semantic.context; -import ast.ClassNode; -import ast.member.FieldNode; +import oldAst.ClassNode; +import oldAst.member.FieldNode; import java.util.HashMap; public class ClassContext { diff --git a/src/main/java/semantic/context/Context.java b/src/main/java/semantic/context/Context.java index 7006e65..31ba3de 100644 --- a/src/main/java/semantic/context/Context.java +++ b/src/main/java/semantic/context/Context.java @@ -1,7 +1,6 @@ package semantic.context; -import ast.ClassNode; -import ast.ProgramNode; +import oldAst.ProgramNode; import java.util.HashMap; public class Context { diff --git a/src/main/java/semantic/context/FieldContext.java b/src/main/java/semantic/context/FieldContext.java index 447aa4e..2dad262 100644 --- a/src/main/java/semantic/context/FieldContext.java +++ b/src/main/java/semantic/context/FieldContext.java @@ -1,9 +1,8 @@ package semantic.context; -import ast.member.FieldNode; -import ast.type.AccessTypeNode; -import ast.type.EnumAccessTypeNode; -import ast.type.TypeNode; +import oldAst.member.FieldNode; +import oldAst.type.AccessTypeNode; +import oldAst.type.TypeNode; public class FieldContext { diff --git a/src/main/java/typechecker/TypeCheckResult.java b/src/main/java/typechecker/TypeCheckResult.java index 12143b2..a06d359 100644 --- a/src/main/java/typechecker/TypeCheckResult.java +++ b/src/main/java/typechecker/TypeCheckResult.java @@ -1,7 +1,7 @@ package typechecker; -import ast.type.TypeNode; +import oldAst.type.TypeNode; public class TypeCheckResult { diff --git a/src/main/test/java/MainTest.java b/src/main/test/java/MainTest.java index f9e848e..d4899fd 100644 --- a/src/main/test/java/MainTest.java +++ b/src/main/test/java/MainTest.java @@ -4,8 +4,8 @@ import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import parser.ASTBuilder; -import ast.ClassNode; -import ast.ProgramNode; +import oldAst.ClassNode; +import oldAst.ProgramNode; import bytecode.ByteCodeGenerator; import java.io.IOException; diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index 4c303d8..8ab9434 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -1,18 +1,17 @@ package semantic; -import ast.ClassNode; -import ast.expression.LiteralNode; -import ast.ProgramNode; -import ast.expression.*; -import ast.member.FieldNode; -import ast.member.MemberNode; -import ast.member.MethodNode; -import ast.parameter.ParameterListNode; -import ast.parameter.ParameterNode; -import ast.statement.AssignmentStatementNode; -import ast.statement.StatementNode; -import ast.statement.VariableDeclarationStatementNode; -import ast.type.*; +import oldAst.ClassNode; +import oldAst.expression.LiteralNode; +import oldAst.ProgramNode; +import oldAst.expression.*; +import oldAst.member.FieldNode; +import oldAst.member.MemberNode; +import oldAst.member.MethodNode; +import oldAst.parameter.ParameterListNode; +import oldAst.parameter.ParameterNode; +import oldAst.statement.AssignmentStatementNode; +import oldAst.statement.StatementNode; +import oldAst.type.*; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index 71604ee..cc413a2 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -1,9 +1,8 @@ package semantic; -import ast.*; +import oldAst.*; import com.fasterxml.jackson.databind.ObjectMapper; -import org.assertj.core.api.MatcherAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import semantic.exeptions.AlreadyDeclearedException; -- 2.34.1 From 330b92a79feb5eee6350ec68e135611dd9618137 Mon Sep 17 00:00:00 2001 From: i22035 Date: Sat, 15 Jun 2024 14:05:03 +0200 Subject: [PATCH 05/19] Deleted old grammar --- src/main/java/ast/ASTNode.java | 9 +- src/main/java/ast/ClassNode.java | 16 +- src/main/java/ast/ProgramNode.java | 2 - src/main/java/ast/member/ConstructorNode.java | 21 ++ .../{oldAst => ast}/member/FieldNode.java | 8 +- .../{oldAst => ast}/member/MemberNode.java | 8 +- .../{oldAst => ast}/member/MethodNode.java | 15 +- .../java/ast/type/AccessModifierNode.java | 13 +- .../java/ast/type/EnumAccessModifierNode.java | 5 - src/main/java/ast/type/TypeNode.java | 5 + src/main/java/bytecode/ByteCodeGenerator.java | 4 +- src/main/java/bytecode/ClassCodeGen.java | 10 +- src/main/java/bytecode/Mapper.java | 18 +- src/main/java/bytecode/MethodCodeGen.java | 8 +- .../java/bytecode/visitor/MethodVisitor.java | 4 +- src/main/java/oldAst/ASTNode.java | 12 -- src/main/java/oldAst/BlockNode.java | 4 - src/main/java/oldAst/ClassNode.java | 63 ------ src/main/java/oldAst/ProgramNode.java | 27 --- .../expression/BinaryExpressionNode.java | 22 -- .../oldAst/expression/ExpressionNode.java | 22 -- .../expression/ExpresssionOperator.java | 14 -- .../expression/IdentifierExpressionNode.java | 22 -- src/main/java/oldAst/expression/InstVar.java | 24 --- .../java/oldAst/expression/LiteralNode.java | 31 --- src/main/java/oldAst/expression/This.java | 26 --- .../expression/UnaryExpressionNode.java | 22 -- .../java/oldAst/member/ConstructorNode.java | 16 -- .../oldAst/parameter/ParameterListNode.java | 16 -- .../java/oldAst/parameter/ParameterNode.java | 16 -- .../statement/AssignmentStatementNode.java | 24 --- .../oldAst/statement/IfStatementNode.java | 22 -- .../oldAst/statement/ReturnStatementNode.java | 18 -- .../java/oldAst/statement/StatementNode.java | 20 -- .../VariableDeclarationStatementNode.java | 25 --- .../oldAst/statement/WhileStatementNode.java | 20 -- src/main/java/oldAst/type/AccessTypeNode.java | 13 -- src/main/java/oldAst/type/BaseTypeNode.java | 28 --- .../java/oldAst/type/EnumAccessTypeNode.java | 5 - src/main/java/oldAst/type/EnumTypeNode.java | 5 - .../java/oldAst/type/ReferenceTypeNode.java | 36 ---- src/main/java/oldAst/type/TypeNode.java | 18 -- .../java/parser/astBuilder/ASTBuilder.java | 195 +----------------- 43 files changed, 75 insertions(+), 837 deletions(-) create mode 100644 src/main/java/ast/member/ConstructorNode.java rename src/main/java/{oldAst => ast}/member/FieldNode.java (74%) rename src/main/java/{oldAst => ast}/member/MemberNode.java (82%) rename src/main/java/{oldAst => ast}/member/MethodNode.java (89%) delete mode 100644 src/main/java/ast/type/EnumAccessModifierNode.java create mode 100644 src/main/java/ast/type/TypeNode.java delete mode 100644 src/main/java/oldAst/ASTNode.java delete mode 100644 src/main/java/oldAst/BlockNode.java delete mode 100644 src/main/java/oldAst/ClassNode.java delete mode 100644 src/main/java/oldAst/ProgramNode.java delete mode 100644 src/main/java/oldAst/expression/BinaryExpressionNode.java delete mode 100644 src/main/java/oldAst/expression/ExpressionNode.java delete mode 100644 src/main/java/oldAst/expression/ExpresssionOperator.java delete mode 100644 src/main/java/oldAst/expression/IdentifierExpressionNode.java delete mode 100644 src/main/java/oldAst/expression/InstVar.java delete mode 100644 src/main/java/oldAst/expression/LiteralNode.java delete mode 100644 src/main/java/oldAst/expression/This.java delete mode 100644 src/main/java/oldAst/expression/UnaryExpressionNode.java delete mode 100644 src/main/java/oldAst/member/ConstructorNode.java delete mode 100644 src/main/java/oldAst/parameter/ParameterListNode.java delete mode 100644 src/main/java/oldAst/parameter/ParameterNode.java delete mode 100644 src/main/java/oldAst/statement/AssignmentStatementNode.java delete mode 100644 src/main/java/oldAst/statement/IfStatementNode.java delete mode 100644 src/main/java/oldAst/statement/ReturnStatementNode.java delete mode 100644 src/main/java/oldAst/statement/StatementNode.java delete mode 100644 src/main/java/oldAst/statement/VariableDeclarationStatementNode.java delete mode 100644 src/main/java/oldAst/statement/WhileStatementNode.java delete mode 100644 src/main/java/oldAst/type/AccessTypeNode.java delete mode 100644 src/main/java/oldAst/type/BaseTypeNode.java delete mode 100644 src/main/java/oldAst/type/EnumAccessTypeNode.java delete mode 100644 src/main/java/oldAst/type/EnumTypeNode.java delete mode 100644 src/main/java/oldAst/type/ReferenceTypeNode.java delete mode 100644 src/main/java/oldAst/type/TypeNode.java diff --git a/src/main/java/ast/ASTNode.java b/src/main/java/ast/ASTNode.java index 3ef48fa..b899ea2 100644 --- a/src/main/java/ast/ASTNode.java +++ b/src/main/java/ast/ASTNode.java @@ -1,12 +1,5 @@ package ast; -//import java.util.List; - -public interface ASTNode { - /** - * Please implement this method to return a list of children of each node. - */ - // public List getChildren(); -} +public interface ASTNode { } diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index 9690600..231d4c7 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -1,12 +1,10 @@ package ast; +import ast.type.AccessModifierNode; import bytecode.visitor.ClassVisitor; -import oldAst.ASTNode; -import oldAst.member.ConstructorNode; -import oldAst.member.MemberNode; -import oldAst.member.MethodNode; -import oldAst.type.AccessTypeNode; -import oldAst.type.EnumAccessTypeNode; +import ast.member.ConstructorNode; +import ast.member.MemberNode; +import ast.member.MethodNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; @@ -16,13 +14,13 @@ import java.util.List; public class ClassNode implements ASTNode, Visitable { public String identifier; - public AccessTypeNode accessType; + public AccessModifierNode accessType; public List members = new ArrayList<>(); public boolean hasConstructor = false; public ClassNode() {} - public ClassNode(AccessTypeNode accessType, String identifier){ + public ClassNode(AccessModifierNode accessType, String identifier){ this.accessType = accessType; this.identifier = identifier; } @@ -36,7 +34,7 @@ public class ClassNode implements ASTNode, Visitable { public void ensureConstructor(){ if(!hasConstructor) { - ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), identifier); + ConstructorNode constructor = new ConstructorNode(new AccessModifierNode(AccessModifierNode.PUBLIC), identifier); members.add(0,constructor); } } diff --git a/src/main/java/ast/ProgramNode.java b/src/main/java/ast/ProgramNode.java index afed589..f8ad19a 100644 --- a/src/main/java/ast/ProgramNode.java +++ b/src/main/java/ast/ProgramNode.java @@ -1,7 +1,5 @@ package ast; -import ast.ASTNode; -import ast.ClassNode; import bytecode.visitor.ProgramVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java new file mode 100644 index 0000000..380e9ba --- /dev/null +++ b/src/main/java/ast/member/ConstructorNode.java @@ -0,0 +1,21 @@ +package ast.member; + +import bytecode.visitor.MethodVisitor; +import visitor.Visitable; + +public class ConstructorNode extends MethodNode implements Visitable { + public AccessModifierNode accessType; + public String name; + public List parameters = new ArrayList<>(); + public BlockNode body; + + public ConstructorNode(AccessModifierNode accessType, String name) { + this.accessType = accessType; + this.name = name; + } + + @Override + public void accept(MethodVisitor methodVisitor) { + methodVisitor.visit(this); + } +} diff --git a/src/main/java/oldAst/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java similarity index 74% rename from src/main/java/oldAst/member/FieldNode.java rename to src/main/java/ast/member/FieldNode.java index 3f34f1d..e942bd3 100644 --- a/src/main/java/oldAst/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -1,20 +1,18 @@ -package oldAst.member; +package ast.member; -import oldAst.type.AccessTypeNode; -import oldAst.type.TypeNode; import bytecode.visitor.ClassVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; public class FieldNode implements MemberNode, Visitable { - public AccessTypeNode accessTypeNode; + public AccessModifierNode accessTypeNode; public TypeNode type; public String identifier; public FieldNode(){} - public FieldNode(AccessTypeNode accessTypeNode, TypeNode type, String name){ + public FieldNode(AccessModifierNode accessTypeNode, TypeNode type, String name){ this.accessTypeNode = accessTypeNode; this.type = type; this.identifier = name; diff --git a/src/main/java/oldAst/member/MemberNode.java b/src/main/java/ast/member/MemberNode.java similarity index 82% rename from src/main/java/oldAst/member/MemberNode.java rename to src/main/java/ast/member/MemberNode.java index 56e01e3..dd02551 100644 --- a/src/main/java/oldAst/member/MemberNode.java +++ b/src/main/java/ast/member/MemberNode.java @@ -1,9 +1,9 @@ -package oldAst.member; +package ast.member; -import oldAst.ASTNode; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import ast.ASTNode; @JsonIgnoreProperties(ignoreUnknown = true) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) @@ -13,6 +13,4 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonSubTypes.Type(value = FieldNode.class, name = "Field") } ) -public interface MemberNode extends ASTNode { - -} +public interface MemberNode extends ASTNode {} diff --git a/src/main/java/oldAst/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java similarity index 89% rename from src/main/java/oldAst/member/MethodNode.java rename to src/main/java/ast/member/MethodNode.java index 34d14e1..df50365 100644 --- a/src/main/java/oldAst/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -1,20 +1,15 @@ -package oldAst.member; +package ast.member; -import oldAst.parameter.ParameterListNode; -import oldAst.statement.StatementNode; -import oldAst.type.AccessTypeNode; - -import java.util.ArrayList; -import java.util.List; - -import oldAst.type.TypeNode; import bytecode.visitor.MethodVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; +import java.util.ArrayList; +import java.util.List; + public class MethodNode implements MemberNode, Visitable { - public AccessTypeNode visibility; + public AccessModifierNode accessModifier; public TypeNode type; public String identifier; diff --git a/src/main/java/ast/type/AccessModifierNode.java b/src/main/java/ast/type/AccessModifierNode.java index 5bf3292..0f7596e 100644 --- a/src/main/java/ast/type/AccessModifierNode.java +++ b/src/main/java/ast/type/AccessModifierNode.java @@ -1,14 +1,5 @@ package ast.type; -import oldAst.ASTNode; -import oldAst.type.EnumAccessTypeNode; - -public class AccessModifierNode implements ASTNode { - public EnumAccessModifierNode enumAccessModifierNode; - - public AccessModifierNode(){} - - public AccessModifierNode(EnumAccessModifierNode enumAccessTypeNode) { - this.enumAccessModifierNode = enumAccessTypeNode; - } +public enum AccessModifierNode { + PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC } diff --git a/src/main/java/ast/type/EnumAccessModifierNode.java b/src/main/java/ast/type/EnumAccessModifierNode.java deleted file mode 100644 index a59e904..0000000 --- a/src/main/java/ast/type/EnumAccessModifierNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package ast.type; - -public enum EnumAccessModifierNode { - PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC -} diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/TypeNode.java new file mode 100644 index 0000000..b24628d --- /dev/null +++ b/src/main/java/ast/type/TypeNode.java @@ -0,0 +1,5 @@ +package ast.type; + +public enum TypeNode { + INT, BOOLEAN, CHAR, IDENTIFIER +} diff --git a/src/main/java/bytecode/ByteCodeGenerator.java b/src/main/java/bytecode/ByteCodeGenerator.java index eeda3ae..5494255 100644 --- a/src/main/java/bytecode/ByteCodeGenerator.java +++ b/src/main/java/bytecode/ByteCodeGenerator.java @@ -1,7 +1,7 @@ package bytecode; -import oldAst.ProgramNode; -import oldAst.ClassNode; +import ast.ProgramNode; +import ast.ClassNode; import bytecode.visitor.ProgramVisitor; public class ByteCodeGenerator implements ProgramVisitor { diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index 266f03c..b0afa69 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -1,10 +1,10 @@ package bytecode; -import oldAst.ClassNode; -import oldAst.member.FieldNode; -import oldAst.member.MemberNode; -import oldAst.member.MethodNode; -import oldAst.type.BaseTypeNode; +import ast.ClassNode; +import ast.member.FieldNode; +import ast.member.MemberNode; +import ast.member.MethodNode; +import ast.type.BaseTypeNode; import bytecode.visitor.ClassVisitor; import java.io.File; import org.objectweb.asm.ClassWriter; diff --git a/src/main/java/bytecode/Mapper.java b/src/main/java/bytecode/Mapper.java index 91f4a2d..8116565 100644 --- a/src/main/java/bytecode/Mapper.java +++ b/src/main/java/bytecode/Mapper.java @@ -1,10 +1,10 @@ package bytecode; -import oldAst.parameter.ParameterListNode; -import oldAst.parameter.ParameterNode; -import oldAst.type.*; +import ast.parameter.ParameterListNode; +import ast.parameter.ParameterNode; +import ast.type.*; import org.objectweb.asm.Opcodes; -import oldAst.type.BaseTypeNode; +import ast.type.BaseTypeNode; public class Mapper { public int mapAccessTypeToOpcode(AccessTypeNode type) { @@ -20,23 +20,23 @@ public class Mapper { public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) { String descriptor = "("; for(ParameterNode parameterNode : parameterListNode.parameters) { - descriptor += getTypeChar(EnumTypeNode.INT); + descriptor += getTypeChar(TypeNode.INT); } descriptor += ")"; descriptor += getTypeChar(baseTypeNode.enumType); return descriptor; } - public String getTypeChar(EnumTypeNode enumTypeNode) { + public String getTypeChar(TypeNode enumTypeNode) { String typeChar = ""; switch (enumTypeNode) { - case EnumTypeNode.INT: + case TypeNode.INT: typeChar = "I"; break; - case EnumTypeNode.CHAR: + case TypeNode.CHAR: typeChar = "C"; break; - case EnumTypeNode.BOOLEAN: + case TypeNode.BOOLEAN: typeChar = "Z"; break; } diff --git a/src/main/java/bytecode/MethodCodeGen.java b/src/main/java/bytecode/MethodCodeGen.java index 4fed389..1cdf1e2 100644 --- a/src/main/java/bytecode/MethodCodeGen.java +++ b/src/main/java/bytecode/MethodCodeGen.java @@ -1,9 +1,9 @@ package bytecode; -import oldAst.member.ConstructorNode; -import oldAst.member.MethodNode; -import oldAst.parameter.ParameterNode; -import oldAst.type.BaseTypeNode; +import ast.member.ConstructorNode; +import ast.member.MethodNode; +import ast.parameter.ParameterNode; +import ast.type.BaseTypeNode; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; diff --git a/src/main/java/bytecode/visitor/MethodVisitor.java b/src/main/java/bytecode/visitor/MethodVisitor.java index bda46ab..70177ce 100644 --- a/src/main/java/bytecode/visitor/MethodVisitor.java +++ b/src/main/java/bytecode/visitor/MethodVisitor.java @@ -1,7 +1,7 @@ package bytecode.visitor; -import oldAst.member.ConstructorNode; -import oldAst.member.MethodNode; +import ast.member.ConstructorNode; +import ast.member.MethodNode; public interface MethodVisitor { void visit(ConstructorNode constructorNode); diff --git a/src/main/java/oldAst/ASTNode.java b/src/main/java/oldAst/ASTNode.java deleted file mode 100644 index 1d8dcf5..0000000 --- a/src/main/java/oldAst/ASTNode.java +++ /dev/null @@ -1,12 +0,0 @@ -package oldAst; - -//import java.util.List; - -public interface ASTNode { - /** - * Please implement this method to return a list of children of each node. - */ - // public List getChildren(); -} - - diff --git a/src/main/java/oldAst/BlockNode.java b/src/main/java/oldAst/BlockNode.java deleted file mode 100644 index 5c8a932..0000000 --- a/src/main/java/oldAst/BlockNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package oldAst; - -public class BlockNode { -} diff --git a/src/main/java/oldAst/ClassNode.java b/src/main/java/oldAst/ClassNode.java deleted file mode 100644 index 34d08dc..0000000 --- a/src/main/java/oldAst/ClassNode.java +++ /dev/null @@ -1,63 +0,0 @@ -package oldAst; - -import oldAst.member.ConstructorNode; -import oldAst.member.MemberNode; -import oldAst.member.MethodNode; -import oldAst.type.AccessTypeNode; -import oldAst.type.EnumAccessTypeNode; - -import java.util.ArrayList; -import java.util.List; - -import bytecode.visitor.ClassVisitor; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class ClassNode implements ASTNode, Visitable { - public String identifier; - public AccessTypeNode accessType; - public List members = new ArrayList<>(); - public boolean hasConstructor = false; - - public ClassNode() {} - - public ClassNode(AccessTypeNode accessType, String identifier){ - this.accessType = accessType; - this.identifier = identifier; - } - - public void addMember(MemberNode member) { - if (member instanceof ConstructorNode) { - this.hasConstructor = true; - } - members.add(member); - } - - public void ensureConstructor(){ - if(!hasConstructor) { - ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), identifier); - members.add(0,constructor); - } - } - - public List getMethods(){ - List methods = new ArrayList<>(); - for (MemberNode member : members) { - if (member instanceof MethodNode methodNode) { - methods.add(methodNode); - } - } - return methods; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - @Override - public void accept(ClassVisitor classVisitor) { - classVisitor.visit(this); - } -} diff --git a/src/main/java/oldAst/ProgramNode.java b/src/main/java/oldAst/ProgramNode.java deleted file mode 100644 index beb97d9..0000000 --- a/src/main/java/oldAst/ProgramNode.java +++ /dev/null @@ -1,27 +0,0 @@ -package oldAst; - -import java.util.ArrayList; -import java.util.List; - -import bytecode.visitor.ProgramVisitor; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class ProgramNode implements ASTNode, Visitable{ - public List classes = new ArrayList<>(); - - public void addClass(ClassNode classNode) { - classes.add(classNode); - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - @Override - public void accept(ProgramVisitor programVisitor) { - programVisitor.visit(this); - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/expression/BinaryExpressionNode.java b/src/main/java/oldAst/expression/BinaryExpressionNode.java deleted file mode 100644 index bdb1467..0000000 --- a/src/main/java/oldAst/expression/BinaryExpressionNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package oldAst.expression; - -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class BinaryExpressionNode implements ExpressionNode, Visitable { - public ExpressionNode left; - public ExpressionNode right; - public ExpresssionOperator operator; // Stores the operator as a string (e.g., "+", "-", "&&") - - public BinaryExpressionNode(ExpressionNode left, ExpressionNode right, ExpresssionOperator operator) { - this.left = left; - this.right = right; - this.operator = operator; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/expression/ExpressionNode.java b/src/main/java/oldAst/expression/ExpressionNode.java deleted file mode 100644 index 27c43e3..0000000 --- a/src/main/java/oldAst/expression/ExpressionNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package oldAst.expression; - -import oldAst.ASTNode; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import visitor.Visitable; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BinaryExpressionNode.class, name = "Binary"), - @JsonSubTypes.Type(value = This.class, name = "This"), - @JsonSubTypes.Type(value = InstVar.class, name = "InstVar"), - @JsonSubTypes.Type(value = IdentifierExpressionNode.class, name = "Identifier"), - @JsonSubTypes.Type(value = LiteralNode.class, name = "Literal"), - @JsonSubTypes.Type(value = UnaryExpressionNode.class, name = "Unary")} -) - -public interface ExpressionNode extends ASTNode, Visitable { - -} diff --git a/src/main/java/oldAst/expression/ExpresssionOperator.java b/src/main/java/oldAst/expression/ExpresssionOperator.java deleted file mode 100644 index dfd7ef8..0000000 --- a/src/main/java/oldAst/expression/ExpresssionOperator.java +++ /dev/null @@ -1,14 +0,0 @@ -package oldAst.expression; - -public enum ExpresssionOperator { - DOT, // . NICHT MEHR GEBRAUCHT - PLUS, // + - MINUS, // - - MULTIPLY, // * - DIVIDE, // / - NOT, // ! - ASSIGNMENT, // = (NICHT MEHR GEBRAUCHT ??) - EQUALS, // == - UNEQUALS, // != - ERROR //TODO: Remove This -} diff --git a/src/main/java/oldAst/expression/IdentifierExpressionNode.java b/src/main/java/oldAst/expression/IdentifierExpressionNode.java deleted file mode 100644 index 4552a82..0000000 --- a/src/main/java/oldAst/expression/IdentifierExpressionNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package oldAst.expression; - -import oldAst.type.TypeNode; -import semantic.SemanticVisitor; - -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class IdentifierExpressionNode implements ExpressionNode, Visitable { - public String name; - public TypeNode type; - - - public IdentifierExpressionNode(String name) { - this.name = name; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} diff --git a/src/main/java/oldAst/expression/InstVar.java b/src/main/java/oldAst/expression/InstVar.java deleted file mode 100644 index dc9a204..0000000 --- a/src/main/java/oldAst/expression/InstVar.java +++ /dev/null @@ -1,24 +0,0 @@ -package oldAst.expression; - -import oldAst.type.TypeNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class InstVar implements ExpressionNode, Visitable { - public String identifier; - public ExpressionNode expression; - public TypeNode type; - - public InstVar(){} - - public InstVar(ExpressionNode expression, String identifier) { - this.identifier = identifier; - this.expression = expression; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} diff --git a/src/main/java/oldAst/expression/LiteralNode.java b/src/main/java/oldAst/expression/LiteralNode.java deleted file mode 100644 index c53f04a..0000000 --- a/src/main/java/oldAst/expression/LiteralNode.java +++ /dev/null @@ -1,31 +0,0 @@ -package oldAst.expression; - -import oldAst.type.TypeNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class LiteralNode implements ExpressionNode { - - int value; - private TypeNode type; - - public LiteralNode(){} - - public LiteralNode(int value) { - this.value = value; - } - - public TypeNode getType() { - return type; - } - - public void setType(TypeNode type) { - this.type = type; - } - - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} diff --git a/src/main/java/oldAst/expression/This.java b/src/main/java/oldAst/expression/This.java deleted file mode 100644 index 1a0fbb3..0000000 --- a/src/main/java/oldAst/expression/This.java +++ /dev/null @@ -1,26 +0,0 @@ -package oldAst.expression; - -import oldAst.ASTNode; -import oldAst.type.ReferenceTypeNode; -import oldAst.type.TypeNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class This implements ASTNode, ExpressionNode { - private TypeNode type; - - public This(){} - - public This(String className) { - type = new ReferenceTypeNode(className); - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - public TypeNode getType() { - return type; - } -} diff --git a/src/main/java/oldAst/expression/UnaryExpressionNode.java b/src/main/java/oldAst/expression/UnaryExpressionNode.java deleted file mode 100644 index 17b0a9b..0000000 --- a/src/main/java/oldAst/expression/UnaryExpressionNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package oldAst.expression; - -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class UnaryExpressionNode implements ExpressionNode, Visitable { - public ExpressionNode expression; - public String operator; // Stores the operator (e.g., "-", "!") - - public UnaryExpressionNode(ExpressionNode expression, String operator) { - this.expression = expression; - this.operator = operator; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} - - diff --git a/src/main/java/oldAst/member/ConstructorNode.java b/src/main/java/oldAst/member/ConstructorNode.java deleted file mode 100644 index 9c3bc08..0000000 --- a/src/main/java/oldAst/member/ConstructorNode.java +++ /dev/null @@ -1,16 +0,0 @@ -package oldAst.member; - -import oldAst.type.AccessTypeNode; -import bytecode.visitor.MethodVisitor; -import visitor.Visitable; - -public class ConstructorNode extends MethodNode implements Visitable { - public ConstructorNode(AccessTypeNode visibility, String name) { - super(visibility, name); - } - - @Override - public void accept(MethodVisitor methodVisitor) { - methodVisitor.visit(this); - } -} diff --git a/src/main/java/oldAst/parameter/ParameterListNode.java b/src/main/java/oldAst/parameter/ParameterListNode.java deleted file mode 100644 index b241791..0000000 --- a/src/main/java/oldAst/parameter/ParameterListNode.java +++ /dev/null @@ -1,16 +0,0 @@ -package oldAst.parameter; - -import oldAst.ASTNode; - -import java.util.ArrayList; -import java.util.List; - -public class ParameterListNode implements ASTNode { - public List parameters = new ArrayList<>(); - - public ParameterListNode() {} - - public ParameterListNode(List parameters){ - this.parameters = parameters; - } -} diff --git a/src/main/java/oldAst/parameter/ParameterNode.java b/src/main/java/oldAst/parameter/ParameterNode.java deleted file mode 100644 index 976375c..0000000 --- a/src/main/java/oldAst/parameter/ParameterNode.java +++ /dev/null @@ -1,16 +0,0 @@ -package oldAst.parameter; - -import oldAst.ASTNode; -import oldAst.type.TypeNode; - -public class ParameterNode implements ASTNode { - public TypeNode type; - public String identifier; - - public ParameterNode(){} - - public ParameterNode(TypeNode type, String identifier) { - this.type = type; - this.identifier = identifier; - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/statement/AssignmentStatementNode.java b/src/main/java/oldAst/statement/AssignmentStatementNode.java deleted file mode 100644 index 556fe5e..0000000 --- a/src/main/java/oldAst/statement/AssignmentStatementNode.java +++ /dev/null @@ -1,24 +0,0 @@ -package oldAst.statement; - -import oldAst.expression.ExpressionNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - -public class AssignmentStatementNode extends StatementNode implements Visitable { - public ExpressionNode expressionLeft; - public ExpressionNode expressionRight; -// public TypeNode type; - - public AssignmentStatementNode(){} - - public AssignmentStatementNode(ExpressionNode expressionLeft, ExpressionNode expressionRight) { - this.expressionLeft = expressionLeft; - this.expressionRight = expressionRight; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} diff --git a/src/main/java/oldAst/statement/IfStatementNode.java b/src/main/java/oldAst/statement/IfStatementNode.java deleted file mode 100644 index 6050e7a..0000000 --- a/src/main/java/oldAst/statement/IfStatementNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package oldAst.statement; - -import oldAst.expression.ExpressionNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -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; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/statement/ReturnStatementNode.java b/src/main/java/oldAst/statement/ReturnStatementNode.java deleted file mode 100644 index 21db22d..0000000 --- a/src/main/java/oldAst/statement/ReturnStatementNode.java +++ /dev/null @@ -1,18 +0,0 @@ -package oldAst.statement; - -import oldAst.expression.ExpressionNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class ReturnStatementNode extends StatementNode { - public ExpressionNode expression; - - public ReturnStatementNode(ExpressionNode expression) { - this.expression = expression; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/statement/StatementNode.java b/src/main/java/oldAst/statement/StatementNode.java deleted file mode 100644 index 6ae0192..0000000 --- a/src/main/java/oldAst/statement/StatementNode.java +++ /dev/null @@ -1,20 +0,0 @@ -package oldAst.statement; - -import oldAst.ASTNode; -import visitor.Visitable; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) -@JsonSubTypes({ - @JsonSubTypes.Type(value = IfStatementNode.class, name = "IF"), - @JsonSubTypes.Type(value = AssignmentStatementNode.class, name = "Assignment"), - @JsonSubTypes.Type(value = VariableDeclarationStatementNode.class, name = "VariableDeclaration") } -) - -public abstract class StatementNode implements ASTNode, Visitable { -} - diff --git a/src/main/java/oldAst/statement/VariableDeclarationStatementNode.java b/src/main/java/oldAst/statement/VariableDeclarationStatementNode.java deleted file mode 100644 index 854b9e1..0000000 --- a/src/main/java/oldAst/statement/VariableDeclarationStatementNode.java +++ /dev/null @@ -1,25 +0,0 @@ -package oldAst.statement; - -import oldAst.expression.ExpressionNode; -import oldAst.type.TypeNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class VariableDeclarationStatementNode extends StatementNode { - public TypeNode type; - public String identifier; - public ExpressionNode expression; - - public VariableDeclarationStatementNode(){} - - public VariableDeclarationStatementNode(TypeNode type, String identifier, ExpressionNode expression) { - this.type = type; - this.identifier = identifier; - this.expression = expression; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} \ No newline at end of file diff --git a/src/main/java/oldAst/statement/WhileStatementNode.java b/src/main/java/oldAst/statement/WhileStatementNode.java deleted file mode 100644 index b3fcee5..0000000 --- a/src/main/java/oldAst/statement/WhileStatementNode.java +++ /dev/null @@ -1,20 +0,0 @@ -package oldAst.statement; - -import oldAst.expression.ExpressionNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; - -public class WhileStatementNode extends StatementNode { - public ExpressionNode condition; - public StatementNode body; - - public WhileStatementNode(ExpressionNode condition, StatementNode body) { - this.condition = condition; - this.body = body; - } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } -} diff --git a/src/main/java/oldAst/type/AccessTypeNode.java b/src/main/java/oldAst/type/AccessTypeNode.java deleted file mode 100644 index e1f884f..0000000 --- a/src/main/java/oldAst/type/AccessTypeNode.java +++ /dev/null @@ -1,13 +0,0 @@ -package oldAst.type; - -import oldAst.ASTNode; - -public class AccessTypeNode implements ASTNode { - public EnumAccessTypeNode enumAccessTypeNode; - - public AccessTypeNode(){} - - public AccessTypeNode(EnumAccessTypeNode enumAccessTypeNode) { - this.enumAccessTypeNode = enumAccessTypeNode; - } -} diff --git a/src/main/java/oldAst/type/BaseTypeNode.java b/src/main/java/oldAst/type/BaseTypeNode.java deleted file mode 100644 index 2a1b23d..0000000 --- a/src/main/java/oldAst/type/BaseTypeNode.java +++ /dev/null @@ -1,28 +0,0 @@ -package oldAst.type; - -import oldAst.ASTNode; - -public class BaseTypeNode implements ASTNode, TypeNode { - - public EnumTypeNode enumType; - - public BaseTypeNode(){} - - public BaseTypeNode(EnumTypeNode enumType) { - this.enumType = enumType; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - BaseTypeNode other = (BaseTypeNode) obj; - if (enumType != other.enumType) - return false; - return true; - } -} diff --git a/src/main/java/oldAst/type/EnumAccessTypeNode.java b/src/main/java/oldAst/type/EnumAccessTypeNode.java deleted file mode 100644 index c8625e5..0000000 --- a/src/main/java/oldAst/type/EnumAccessTypeNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package oldAst.type; - -public enum EnumAccessTypeNode { - PUBLIC, PRIVATE -} diff --git a/src/main/java/oldAst/type/EnumTypeNode.java b/src/main/java/oldAst/type/EnumTypeNode.java deleted file mode 100644 index 1e84e81..0000000 --- a/src/main/java/oldAst/type/EnumTypeNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package oldAst.type; - -public enum EnumTypeNode { - INT, BOOLEAN, CHAR -} diff --git a/src/main/java/oldAst/type/ReferenceTypeNode.java b/src/main/java/oldAst/type/ReferenceTypeNode.java deleted file mode 100644 index b73f4dd..0000000 --- a/src/main/java/oldAst/type/ReferenceTypeNode.java +++ /dev/null @@ -1,36 +0,0 @@ -package oldAst.type; - -import oldAst.ASTNode; - -public class ReferenceTypeNode implements ASTNode, TypeNode { - - private String identifier; - - public ReferenceTypeNode() {} - - public ReferenceTypeNode(String identifier) { - this.identifier = identifier; - } - - public String getIdentifier() { - return identifier; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ReferenceTypeNode other = (ReferenceTypeNode) obj; - if (identifier == null) { - if (other.identifier != null) - return false; - } else if (!identifier.equals(other.identifier)) - return false; - return true; - } - -} diff --git a/src/main/java/oldAst/type/TypeNode.java b/src/main/java/oldAst/type/TypeNode.java deleted file mode 100644 index 7248755..0000000 --- a/src/main/java/oldAst/type/TypeNode.java +++ /dev/null @@ -1,18 +0,0 @@ -package oldAst.type; - -import oldAst.ASTNode; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BaseTypeNode.class, name = "Base"), - - @JsonSubTypes.Type(value = ReferenceTypeNode.class, name = "Reference") } -) - -public interface TypeNode extends ASTNode { -} \ No newline at end of file diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 69cad70..5ac218f 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -1,21 +1,14 @@ package parser.astBuilder; -import oldAst.*; -import oldAst.expression.*; -import oldAst.member.FieldNode; -import oldAst.member.MemberNode; -import oldAst.member.MethodNode; -import oldAst.parameter.ParameterListNode; -import oldAst.parameter.ParameterNode; -import oldAst.statement.*; -import oldAst.type.*; +import ast.*; +import ast.member.FieldNode; +import ast.member.MemberNode; +import ast.member.MethodNode; +import ast.type.*; import org.antlr.v4.runtime.tree.TerminalNode; import java.util.ArrayList; -import java.util.List; import parser.generated.*; -import parser.generated.SimpleJavaParser.LiteralContext; -import oldAst.type.BaseTypeNode; public class ASTBuilder extends SimpleJavaBaseVisitor { @Override @@ -29,8 +22,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 = ctx.IDENTIFIER().getText(); + ClassNode classNode = new ClassNode((AccessModifierNode) visit(ctx.AccessModifier()),ctx.Identifier().getText()); for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) { classNode.addMember((MemberNode) visit(member)); } @@ -38,179 +30,4 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { return classNode; } - @Override - public ASTNode visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { - AccessTypeNode accessType = (AccessTypeNode) visit(ctx.accessType()); - TypeNode type = (TypeNode) visit(ctx.type()); - String identifier = ctx.IDENTIFIER().getText(); - return new FieldNode(accessType, type, identifier); - } - - @Override - public ASTNode visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { - AccessTypeNode accessType = (AccessTypeNode) visit(ctx.accessType()); - TypeNode returnType = (TypeNode) visit(ctx.type()); - String methodName = ctx.IDENTIFIER().getText(); - - ParameterListNode parameterListNode = null; - if(ctx.parameterList() != null) { - parameterListNode = (ParameterListNode) visit(ctx.parameterList()); - } - List statements = new ArrayList<>(); - for (SimpleJavaParser.StatementContext stmtCtx : ctx.statement()) { - statements.add((StatementNode) visit(stmtCtx)); - } - - MethodNode method = new MethodNode(accessType,returnType, methodName, parameterListNode, statements); - - return method; - } - - @Override - public ASTNode visitParameterList(SimpleJavaParser.ParameterListContext ctx) { - List parameters = new ArrayList<>(); - for (SimpleJavaParser.ParameterContext paramCtx : ctx.parameter()) { - parameters.add((ParameterNode) visitParameter(paramCtx)); - } - return new ParameterListNode(parameters); - } - - @Override - public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) { - TypeNode typeNode = (TypeNode) visit(ctx.type()); - String identifier = ctx.IDENTIFIER().getText(); - return new ParameterNode(typeNode, identifier); - } - - @Override - public ASTNode visitType(SimpleJavaParser.TypeContext ctx) { - String typeStr = ctx.getText(); - switch (typeStr) { - case "int": - return new BaseTypeNode(EnumTypeNode.INT); - case "boolean": - return new BaseTypeNode(EnumTypeNode.BOOLEAN); - case "char": - return new BaseTypeNode(EnumTypeNode.CHAR); - default: - throw new IllegalArgumentException("Unsupported type: " + typeStr); - } - } - - @Override - public ASTNode visitAccessType(SimpleJavaParser.AccessTypeContext ctx) { - String typeStr = ctx.getText(); - switch (typeStr) { - case "public": - return new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - case "private": - return new AccessTypeNode(EnumAccessTypeNode.PRIVATE); - default: - throw new IllegalArgumentException("Unsupported type: " + typeStr); - } - } - - @Override - public ASTNode visitStatement(SimpleJavaParser.StatementContext ctx) { - if (ctx.variableDeclarationStatement() != null) { - return visitVariableDeclarationStatement(ctx.variableDeclarationStatement()); - } else if (ctx.assignmentStatement() != null) { - return visitAssignmentStatement(ctx.assignmentStatement()); - } - - 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 expression = (ExpressionNode) visit(ctx.expression()); - return null; - } - - @Override - public ASTNode visitVar(SimpleJavaParser.VarContext ctx) { - return null; - } - - @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) { - // 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)); - return new BinaryExpressionNode(left, right, ExpresssionOperator.ERROR); - } - // 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 or throw an exception if no valid expression found - } - - @Override - public ASTNode visitLiteral(SimpleJavaParser.LiteralContext ctx) { - LiteralContext literalContext = (LiteralContext) ctx; - try { - int intValue = Integer.parseInt(literalContext.getText()); - LiteralNode literalNode = new LiteralNode(intValue); - - literalNode.setType(new BaseTypeNode(EnumTypeNode.INT)); - return literalNode; - } catch (NumberFormatException ignored) {} - - return null; // Return null or throw an exception if no valid expression found - } - } -- 2.34.1 From 3639b2a4f8b0e87e12cf12051aaf069a1fd04031 Mon Sep 17 00:00:00 2001 From: i22035 Date: Sat, 15 Jun 2024 16:59:35 +0200 Subject: [PATCH 06/19] Added new Parser Visitors --- src/main/java/ast/ClassNode.java | 14 +- src/main/java/ast/block/BlockNode.java | 17 + .../expression/AssignableExpressionNode.java | 4 + .../java/ast/expression/ExpressionNode.java | 4 + src/main/java/ast/member/ConstructorNode.java | 19 +- src/main/java/ast/member/FieldNode.java | 2 + .../java/ast/parameter/ParameterNode.java | 14 + .../java/ast/statement/ForStatementNode.java | 23 + .../LocalVariableDeclarationNode.java | 19 + .../ast/statement/ReturnStatementNode.java | 16 + .../java/ast/statement/StatementNode.java | 2 + .../ast/statement/WhileStatementNode.java | 15 + .../ifstatement/ElseStatementNode.java | 12 + .../ifstatement/IfElseStatementNode.java | 20 + .../ifstatement/IfStatementNode.java | 15 + .../AssignStatementExpressionNode.java | 15 + ...mentExpressionStatementExpressionNode.java | 20 + ...NewDeclarationStatementExpressionNode.java | 20 + .../ChainedMethodNode.java | 20 + .../MethodCallStatementExpressionNode.java | 29 + .../TargetNode.java | 7 + .../java/ast/type/AccessModifierNode.java | 27 +- .../java/ast/type/EnumAccessModifierNode.java | 6 + src/main/java/ast/type/EnumTypeNode.java | 5 + src/main/java/ast/type/TypeNode.java | 24 +- src/main/java/bytecode/Mapper.java | 11 +- .../java/parser/astBuilder/ASTBuilder.java | 161 +- .../java/parser/generated/SimpleJava.interp | 155 - .../java/parser/generated/SimpleJava.tokens | 88 - .../generated/SimpleJavaBaseListener.java | 568 --- .../generated/SimpleJavaBaseVisitor.java | 323 -- .../parser/generated/SimpleJavaLexer.interp | 170 - .../parser/generated/SimpleJavaLexer.java | 394 -- .../parser/generated/SimpleJavaLexer.tokens | 88 - .../parser/generated/SimpleJavaListener.java | 450 --- .../parser/generated/SimpleJavaParser.java | 3447 ----------------- .../parser/generated/SimpleJavaVisitor.java | 277 -- src/main/java/parser/grammar/SimpleJava.g4 | 8 +- src/main/java/semantic/SemanticVisitor.java | 1 + 39 files changed, 520 insertions(+), 5990 deletions(-) create mode 100644 src/main/java/ast/block/BlockNode.java create mode 100644 src/main/java/ast/expression/AssignableExpressionNode.java create mode 100644 src/main/java/ast/expression/ExpressionNode.java create mode 100644 src/main/java/ast/parameter/ParameterNode.java create mode 100644 src/main/java/ast/statement/ForStatementNode.java create mode 100644 src/main/java/ast/statement/LocalVariableDeclarationNode.java create mode 100644 src/main/java/ast/statement/ReturnStatementNode.java create mode 100644 src/main/java/ast/statement/StatementNode.java create mode 100644 src/main/java/ast/statement/WhileStatementNode.java create mode 100644 src/main/java/ast/statement/ifstatement/ElseStatementNode.java create mode 100644 src/main/java/ast/statement/ifstatement/IfElseStatementNode.java create mode 100644 src/main/java/ast/statement/ifstatement/IfStatementNode.java create mode 100644 src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java create mode 100644 src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java create mode 100644 src/main/java/ast/type/EnumAccessModifierNode.java create mode 100644 src/main/java/ast/type/EnumTypeNode.java delete mode 100644 src/main/java/parser/generated/SimpleJava.interp delete mode 100644 src/main/java/parser/generated/SimpleJava.tokens delete mode 100644 src/main/java/parser/generated/SimpleJavaBaseListener.java delete mode 100644 src/main/java/parser/generated/SimpleJavaBaseVisitor.java delete mode 100644 src/main/java/parser/generated/SimpleJavaLexer.interp delete mode 100644 src/main/java/parser/generated/SimpleJavaLexer.java delete mode 100644 src/main/java/parser/generated/SimpleJavaLexer.tokens delete mode 100644 src/main/java/parser/generated/SimpleJavaListener.java delete mode 100644 src/main/java/parser/generated/SimpleJavaParser.java delete mode 100644 src/main/java/parser/generated/SimpleJavaVisitor.java diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index 231d4c7..5914d4b 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -1,6 +1,7 @@ package ast; import ast.type.AccessModifierNode; +import ast.type.EnumAccessModifierNode; import bytecode.visitor.ClassVisitor; import ast.member.ConstructorNode; import ast.member.MemberNode; @@ -13,16 +14,17 @@ import java.util.ArrayList; import java.util.List; public class ClassNode implements ASTNode, Visitable { - public String identifier; public AccessModifierNode accessType; + public String identifier; public List members = new ArrayList<>(); - public boolean hasConstructor = false; + public boolean hasConstructor; public ClassNode() {} - public ClassNode(AccessModifierNode accessType, String identifier){ - this.accessType = accessType; + public ClassNode(String accessType, String identifier){ + this.accessType = new AccessModifierNode(accessType); this.identifier = identifier; + hasConstructor = false; } public void addMember(MemberNode member) { @@ -34,8 +36,8 @@ public class ClassNode implements ASTNode, Visitable { public void ensureConstructor(){ if(!hasConstructor) { - ConstructorNode constructor = new ConstructorNode(new AccessModifierNode(AccessModifierNode.PUBLIC), identifier); - members.add(0,constructor); + ConstructorNode constructor = new ConstructorNode("public", identifier, ); + members.addFirst(constructor); } } diff --git a/src/main/java/ast/block/BlockNode.java b/src/main/java/ast/block/BlockNode.java new file mode 100644 index 0000000..a5ff3f7 --- /dev/null +++ b/src/main/java/ast/block/BlockNode.java @@ -0,0 +1,17 @@ +package ast.block; + +import ast.ASTNode; +import ast.statement.StatementNode; + +import java.util.ArrayList; +import java.util.List; + +public class BlockNode implements ASTNode { + public List statements = new ArrayList<>(); + + public BlockNode() {} + + public void addStatement(StatementNode statement) { + statements.add(statement); + } +} diff --git a/src/main/java/ast/expression/AssignableExpressionNode.java b/src/main/java/ast/expression/AssignableExpressionNode.java new file mode 100644 index 0000000..6a65d10 --- /dev/null +++ b/src/main/java/ast/expression/AssignableExpressionNode.java @@ -0,0 +1,4 @@ +package ast.expression; + +public class AssignableExpressionNode { +} diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/ast/expression/ExpressionNode.java new file mode 100644 index 0000000..1566f3b --- /dev/null +++ b/src/main/java/ast/expression/ExpressionNode.java @@ -0,0 +1,4 @@ +package ast.expression; + +public class ExpressionNode { +} diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java index 380e9ba..7a7472f 100644 --- a/src/main/java/ast/member/ConstructorNode.java +++ b/src/main/java/ast/member/ConstructorNode.java @@ -1,17 +1,28 @@ package ast.member; +import ast.block.BlockNode; +import ast.parameter.ParameterNode; +import ast.type.AccessModifierNode; import bytecode.visitor.MethodVisitor; import visitor.Visitable; +import java.util.ArrayList; +import java.util.List; + public class ConstructorNode extends MethodNode implements Visitable { public AccessModifierNode accessType; - public String name; + public String identifier; public List parameters = new ArrayList<>(); public BlockNode body; - public ConstructorNode(AccessModifierNode accessType, String name) { - this.accessType = accessType; - this.name = name; + public ConstructorNode(String accessType, String identifier, BlockNode body) { + this.accessType = new AccessModifierNode(accessType); + this.identifier = identifier; + this.body = body; + } + + public void addParameter(ParameterNode parameterNode) { + parameters.add(parameterNode); } @Override diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index e942bd3..3ffd751 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -1,5 +1,7 @@ package ast.member; +import ast.type.AccessModifierNode; +import ast.type.TypeNode; import bytecode.visitor.ClassVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java new file mode 100644 index 0000000..3a6b5ec --- /dev/null +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -0,0 +1,14 @@ +package ast.parameter; + +import ast.ASTNode; +import ast.type.TypeNode; + +public class ParameterNode implements ASTNode { + TypeNode type; + String identifier; + + public ParameterNode(TypeNode type, String identifier) { + this.type = type; + this.identifier = identifier; + } +} diff --git a/src/main/java/ast/statement/ForStatementNode.java b/src/main/java/ast/statement/ForStatementNode.java new file mode 100644 index 0000000..5a4b442 --- /dev/null +++ b/src/main/java/ast/statement/ForStatementNode.java @@ -0,0 +1,23 @@ +package ast.statement; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +public class ForStatementNode implements ASTNode { + ExpressionNode statementExpressionInit; + StatementNode localVariableDeclarationInit; + ExpressionNode expression; + ExpressionNode statementExpression; + + public ForStatementNode(ExpressionNode statementExpressionInit, ExpressionNode expression, ExpressionNode statementExpression) { + this.statementExpressionInit = statementExpressionInit; + this.expression = expression; + this.statementExpression = statementExpression; + } + + public ForStatementNode(StatementNode localVariableDeclarationInit, ExpressionNode expression, ExpressionNode statementExpression) { + this.localVariableDeclarationInit = localVariableDeclarationInit; + this.expression = expression; + this.statementExpression = statementExpression; + } +} diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java new file mode 100644 index 0000000..5b3900f --- /dev/null +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -0,0 +1,19 @@ +package ast.statement; + +import ast.ASTNode; +import ast.expression.ExpressionNode; +import ast.type.TypeNode; + +public class LocalVariableDeclarationNode implements ASTNode { + TypeNode type; + String identifier; + String assign; + ExpressionNode expression; + + public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, ExpressionNode expression) { + this.type = type; + this.identifier = identifier; + this.assign = assign; + this.expression = expression; + } +} diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java new file mode 100644 index 0000000..ab111c5 --- /dev/null +++ b/src/main/java/ast/statement/ReturnStatementNode.java @@ -0,0 +1,16 @@ +package ast.statement; + +import ast.ASTNode; +import ast.expression.ExpressionNode; +import ast.type.TypeNode; + +import java.util.ArrayList; +import java.util.List; + +public class ReturnStatementNode implements ASTNode { + public ExpressionNode expression; + + public ReturnStatementNode(ExpressionNode expression) { + this.expression = expression; + } +} diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/ast/statement/StatementNode.java new file mode 100644 index 0000000..c47d30c --- /dev/null +++ b/src/main/java/ast/statement/StatementNode.java @@ -0,0 +1,2 @@ +package ast.statement;public class StatementNode { +} diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/ast/statement/WhileStatementNode.java new file mode 100644 index 0000000..72d017d --- /dev/null +++ b/src/main/java/ast/statement/WhileStatementNode.java @@ -0,0 +1,15 @@ +package ast.statement; + +import ast.ASTNode; +import ast.block.BlockNode; +import ast.expression.ExpressionNode; + +public class WhileStatementNode implements ASTNode { + ExpressionNode expression; + BlockNode block; + + public WhileStatementNode(ExpressionNode expression, BlockNode block) { + this.expression = expression; + this.block = block; + } +} diff --git a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java new file mode 100644 index 0000000..cedfefc --- /dev/null +++ b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java @@ -0,0 +1,12 @@ +package ast.statement.ifstatement; + +import ast.ASTNode; +import ast.block.BlockNode; + +public class ElseStatementNode implements ASTNode { + BlockNode block; + + public ElseStatementNode(BlockNode block) { + this.block = block; + } +} diff --git a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java new file mode 100644 index 0000000..dcdc6ca --- /dev/null +++ b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java @@ -0,0 +1,20 @@ +package ast.statement.ifstatement; + +import ast.ASTNode; + +import java.util.ArrayList; +import java.util.List; + +public class IfElseStatementNode implements ASTNode { + IfStatementNode ifStatement; + List elseStatements = new ArrayList<>(); + + public IfElseStatementNode(IfStatementNode ifStatement) { + this.ifStatement = ifStatement; + } + + public void addElseStatement(ElseStatementNode elseStatement) { + elseStatements.add(elseStatement); + } + +} diff --git a/src/main/java/ast/statement/ifstatement/IfStatementNode.java b/src/main/java/ast/statement/ifstatement/IfStatementNode.java new file mode 100644 index 0000000..4731758 --- /dev/null +++ b/src/main/java/ast/statement/ifstatement/IfStatementNode.java @@ -0,0 +1,15 @@ +package ast.statement.ifstatement; + +import ast.ASTNode; +import ast.block.BlockNode; +import ast.expression.ExpressionNode; + +public class IfStatementNode implements ASTNode { + ExpressionNode expression; + BlockNode block; + + public IfStatementNode(ExpressionNode expression, BlockNode block) { + this.expression = expression; + this.block = block; + } +} diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java new file mode 100644 index 0000000..007f240 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -0,0 +1,15 @@ +package ast.statement.statementexpression; + +import ast.ASTNode; +import ast.expression.AssignableExpressionNode; +import ast.expression.ExpressionNode; + +public class AssignStatementExpressionNode implements ASTNode { + AssignableExpressionNode assignable; + ExpressionNode expression; + + public AssignStatementExpressionNode(AssignableExpressionNode assignable, ExpressionNode expression) { + this.assignable = assignable; + this.expression = expression; + } +} diff --git a/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java new file mode 100644 index 0000000..de68102 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java @@ -0,0 +1,20 @@ +package ast.statement.statementexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +import java.util.ArrayList; +import java.util.List; + +public class CrementExpressionStatementExpressionNode implements ASTNode { + String identifier; + List expressions = new ArrayList<>(); + + public CrementExpressionStatementExpressionNode(String identifier) { + this.identifier = identifier; + } + + public void addExpression(ExpressionNode expression) { + expressions.add(expression); + } +} diff --git a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java new file mode 100644 index 0000000..6683b46 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java @@ -0,0 +1,20 @@ +package ast.statement.statementexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +import java.util.ArrayList; +import java.util.List; + +public class NewDeclarationStatementExpressionNode implements ASTNode { + String identifier; + List expressions = new ArrayList<>(); + + public NewDeclarationStatementExpressionNode(String identifier) { + this.identifier = identifier; + } + + public void addExpression(ExpressionNode expression) { + expressions.add(expression); + } +} diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java new file mode 100644 index 0000000..759f197 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java @@ -0,0 +1,20 @@ +package ast.statement.statementexpression.methodcallstatementnexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +import java.util.ArrayList; +import java.util.List; + +public class ChainedMethodNode implements ASTNode { + String identifier; + List expressions = new ArrayList<>(); + + public ChainedMethodNode(String identifier) { + this.identifier = identifier; + } + + public void addExpression(ExpressionNode expression) { + expressions.add(expression); + } +} diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java new file mode 100644 index 0000000..5fcaba1 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java @@ -0,0 +1,29 @@ +package ast.statement.statementexpression.methodcallstatementnexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +import java.util.ArrayList; +import java.util.List; + +public class MethodCallStatementExpressionNode implements ASTNode { + TargetNode target; + List chainedMethods = new ArrayList<>(); + String identifier; + List expressions = new ArrayList<>(); + + public MethodCallStatementExpressionNode(TargetNode target, String identifier) { + this.target = target; + this.identifier = identifier; + } + + public void addChainedMethod(ChainedMethodNode chainedMethode) { + chainedMethods.add(chainedMethode); + } + + public void addExpression(ExpressionNode expression) { + expressions.add(expression); + } + + +} diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java new file mode 100644 index 0000000..68f4526 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java @@ -0,0 +1,7 @@ +package ast.statement.statementexpression.methodcallstatementnexpression; + +public class TargetNode { + String thisTarget; + + +} diff --git a/src/main/java/ast/type/AccessModifierNode.java b/src/main/java/ast/type/AccessModifierNode.java index 0f7596e..14081db 100644 --- a/src/main/java/ast/type/AccessModifierNode.java +++ b/src/main/java/ast/type/AccessModifierNode.java @@ -1,5 +1,28 @@ package ast.type; -public enum AccessModifierNode { - PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC +public class AccessModifierNode { + EnumAccessModifierNode accessType; + + public AccessModifierNode(String accessModifier) { + setModifier(accessModifier); + } + + private void setModifier(String accessType) { + switch(accessType) { + case "public": + this.accessType = EnumAccessModifierNode.PUBLIC; + break; + case "public static": + this.accessType = EnumAccessModifierNode.PUBLIC_STATIC; + break; + case "private": + this.accessType = EnumAccessModifierNode.PRIVATE; + break; + case "private static": + this.accessType = EnumAccessModifierNode.PRIVATE_STATIC; + break; + default: + this.accessType = null; + } + } } diff --git a/src/main/java/ast/type/EnumAccessModifierNode.java b/src/main/java/ast/type/EnumAccessModifierNode.java new file mode 100644 index 0000000..dd07e6d --- /dev/null +++ b/src/main/java/ast/type/EnumAccessModifierNode.java @@ -0,0 +1,6 @@ +package ast.type; + +public enum EnumAccessModifierNode { + PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC +} + diff --git a/src/main/java/ast/type/EnumTypeNode.java b/src/main/java/ast/type/EnumTypeNode.java new file mode 100644 index 0000000..98c38ea --- /dev/null +++ b/src/main/java/ast/type/EnumTypeNode.java @@ -0,0 +1,5 @@ +package ast.type; + +public enum EnumTypeNode { + INT, BOOLEAN, CHAR, IDENTIFIER +} diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/TypeNode.java index b24628d..6336208 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/ast/type/TypeNode.java @@ -1,5 +1,25 @@ package ast.type; -public enum TypeNode { - INT, BOOLEAN, CHAR, IDENTIFIER +public class TypeNode { + EnumTypeNode type; + + public TypeNode(String type) { + setType(type); + } + + private void setType(String type) { + switch(type) { + case "int": + this.type = EnumTypeNode.INT; + break; + case "boolean": + this.type = EnumTypeNode.BOOLEAN; + break; + case "char": + this.type = EnumTypeNode.CHAR; + break; + default: + this.type = EnumTypeNode.IDENTIFIER; + } + } } diff --git a/src/main/java/bytecode/Mapper.java b/src/main/java/bytecode/Mapper.java index 8116565..faa4a67 100644 --- a/src/main/java/bytecode/Mapper.java +++ b/src/main/java/bytecode/Mapper.java @@ -1,6 +1,5 @@ package bytecode; -import ast.parameter.ParameterListNode; import ast.parameter.ParameterNode; import ast.type.*; import org.objectweb.asm.Opcodes; @@ -20,23 +19,23 @@ public class Mapper { public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) { String descriptor = "("; for(ParameterNode parameterNode : parameterListNode.parameters) { - descriptor += getTypeChar(TypeNode.INT); + descriptor += getTypeChar(EnumTypeNode.INT); } descriptor += ")"; descriptor += getTypeChar(baseTypeNode.enumType); return descriptor; } - public String getTypeChar(TypeNode enumTypeNode) { + public String getTypeChar(EnumTypeNode enumTypeNode) { String typeChar = ""; switch (enumTypeNode) { - case TypeNode.INT: + case EnumTypeNode.INT: typeChar = "I"; break; - case TypeNode.CHAR: + case EnumTypeNode.CHAR: typeChar = "C"; break; - case TypeNode.BOOLEAN: + case EnumTypeNode.BOOLEAN: typeChar = "Z"; break; } diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 5ac218f..cc54059 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -1,13 +1,22 @@ package parser.astBuilder; import ast.*; -import ast.member.FieldNode; +import ast.block.BlockNode; +import ast.expression.AssignableExpressionNode; +import ast.expression.ExpressionNode; +import ast.statement.ifstatement.ElseStatementNode; +import ast.statement.ifstatement.IfElseStatementNode; +import ast.member.ConstructorNode; import ast.member.MemberNode; -import ast.member.MethodNode; +import ast.parameter.ParameterNode; +import ast.statement.*; +import ast.statement.ifstatement.IfStatementNode; +import ast.statement.statementexpression.AssignStatementExpressionNode; +import ast.statement.statementexpression.CrementExpressionStatementExpressionNode; +import ast.statement.statementexpression.methodcallstatementnexpression.ChainedMethodNode; +import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; +import ast.statement.statementexpression.methodcallstatementnexpression.TargetNode; import ast.type.*; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.ArrayList; import parser.generated.*; public class ASTBuilder extends SimpleJavaBaseVisitor { @@ -22,7 +31,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { - ClassNode classNode = new ClassNode((AccessModifierNode) visit(ctx.AccessModifier()),ctx.Identifier().getText()); + ClassNode classNode = new ClassNode(ctx.AccessModifier().getText(), ctx.Identifier().getText()); for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) { classNode.addMember((MemberNode) visit(member)); } @@ -30,4 +39,144 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { return classNode; } + @Override + public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { + ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { + constructorNode.addParameter((ParameterNode) visit(parameter)); + } + return constructorNode; + } + + @Override + public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) { + return new ParameterNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); + } + + @Override + public ASTNode visitStatement(SimpleJavaParser.StatementContext ctx) { + if(ctx.returnStatement() != null) { + return visitReturnStatement(ctx.returnStatement()); + } else if(ctx.localVariableDeclaration() != null) { + return visitLocalVariableDeclaration(ctx.localVariableDeclaration()); + } else if(ctx.block() != null) { + return visitBlock(ctx.block()); + } else if(ctx.whileStatement() != null) { + return visitWhileStatement(ctx.whileStatement()); + } else if(ctx.forStatement() != null) { + return visitForStatement(ctx.forStatement()); + } else if(ctx.ifElseStatement() != null) { + return visitIfElseStatement(ctx.ifElseStatement()); + } else if(ctx.statementExpression() != null) { + return visitStatementExpression(ctx.statementExpression()); + } + return null; + } + + @Override + public ASTNode visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { + return new ReturnStatementNode((ExpressionNode) visit(ctx.expression())); + } + + @Override + public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { + return new LocalVariableDeclarationNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (ExpressionNode) visit(ctx.expression())); + } + + @Override + public ASTNode visitBlock(SimpleJavaParser.BlockContext ctx) { + BlockNode blockNode = new BlockNode(); + for(SimpleJavaParser.StatementContext statement : ctx.statement()) { + blockNode.addStatement((StatementNode) visit(statement)); + } + return blockNode; + } + + @Override + public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { + return new WhileStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); + } + + @Override + public ASTNode visitForStatement(SimpleJavaParser.ForStatementContext ctx) { + if(ctx.statementExpression(0) != null) { + return new ForStatementNode((ExpressionNode) visit(ctx.statementExpression(0)), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1))); + } else if(ctx.localVariableDeclaration() != null) { + return new ForStatementNode((StatementNode) visit(ctx.localVariableDeclaration()), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1))); + } + return null; + } + + @Override + public ASTNode visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { + IfElseStatementNode ifElseStatementNode = new IfElseStatementNode((IfStatementNode) visit(ctx.ifStatement())); + for(SimpleJavaParser.ElseStatementContext elseStatement : ctx.elseStatement()) { + ifElseStatementNode.addElseStatement((ElseStatementNode) visit(elseStatement)); + } + return ifElseStatementNode; + } + + @Override + public ASTNode visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { + return new IfStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); + } + + @Override + public ASTNode visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { + return new ElseStatementNode((BlockNode) visit(ctx.block())); + } + + @Override + public ASTNode visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { + if(ctx.assign() != null) { + return visitAssign(ctx.assign()); + } else if(ctx.newDeclaration() != null) { + return visitNewDeclaration(ctx.newDeclaration()); + } else if(ctx.methodCall() != null) { + return visitMethodCall(ctx.methodCall()); + } else if(ctx.crementExpression() != null) { + return visitCrementExpression(ctx.crementExpression()); + } + return null; + } + + @Override + public ASTNode visitAssign(SimpleJavaParser.AssignContext ctx) { + return new AssignStatementExpressionNode((AssignableExpressionNode) visit(ctx.assignableExpression()), (ExpressionNode) visit(ctx.expression())); + } + + @Override + public ASTNode visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { + CrementExpressionStatementExpressionNode crementExpressionStatementNode = new CrementExpressionStatementExpressionNode(ctx.Identifier().getText()); + for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { + crementExpressionStatementNode.addExpression((ExpressionNode) visit(expression)); + } + return crementExpressionStatementNode; + } + + @Override + public ASTNode visitMethodCall(SimpleJavaParser.MethodCallContext ctx) { + MethodCallStatementExpressionNode methodCallStatementExpressionNode = new MethodCallStatementExpressionNode((TargetNode) visit(ctx.target()), ctx.Identifier().getText()); + for(SimpleJavaParser.ChainedMethodContext chainedMethod : ctx.chainedMethod()) { + methodCallStatementExpressionNode.addChainedMethod((ChainedMethodNode) visit(chainedMethod)); + } + for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { + methodCallStatementExpressionNode.addExpression((ExpressionNode) visit(expression)); + } + return methodCallStatementExpressionNode; + } + + @Override + public ASTNode visitTarget(SimpleJavaParser.TargetContext ctx) { + + } + + @Override + public ASTNode visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { + ChainedMethodNode chainedMethodNode = new ChainedMethodNode(ctx.Identifier().getText()); + for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { + chainedMethodNode.addExpression((ExpressionNode) visit(expression)); + } + return chainedMethodNode; + } } diff --git a/src/main/java/parser/generated/SimpleJava.interp b/src/main/java/parser/generated/SimpleJava.interp deleted file mode 100644 index c977686..0000000 --- a/src/main/java/parser/generated/SimpleJava.interp +++ /dev/null @@ -1,155 +0,0 @@ -token literal names: -null -'++' -'--' -'void' -'boolean' -'char' -'int' -null -'public static void main(String[] args)' -null -null -null -null -'=' -'+' -'-' -'*' -'%' -'/' -'>' -'<' -'>=' -'<=' -'==' -'!=' -'!' -'&&' -'||' -'.' -'(' -')' -'{' -'}' -';' -',' -'class' -'this' -'while' -'if' -'else' -'for' -'return' -'new' -null -null -null -'null' -null -null -null -null - -token symbolic names: -null -null -null -Void -Boolean -Char -Int -AccessModifier -MainMethodDeclaration -DotOperator -LineOperator -ComparisonOperator -LogicalOperator -Assign -Plus -Minus -Mult -Modulo -Div -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -For -Return -New -CharValue -IntValue -BooleanValue -NullValue -Identifier -WS -InlineComment -MultilineComment - -rule names: -program -classDeclaration -memberDeclaration -constructorDeclaration -fieldDeclaration -methodDeclaration -parameterList -parameter -argumentList -statement -block -returnStatement -localVariableDeclaration -whileStatement -forStatement -ifElseStatement -ifStatement -elseStatement -statementExpression -assign -newDeclaration -expression -unaryExpression -notExpression -crementExpression -incrementExpression -prefixIncrementExpression -suffixIncrementExpression -decrementExpression -prefixDecrementExpression -suffixDecrementExpression -assignableExpression -memberAccess -binaryExpression -calculationExpression -dotExpression -dotSubtractionExpression -nonCalculationExpression -methodCall -target -chainedMethod -type -value -nonCalculationOperator - - -atn: -[4, 1, 50, 393, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 1, 0, 4, 0, 90, 8, 0, 11, 0, 12, 0, 91, 1, 1, 3, 1, 95, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 101, 8, 1, 10, 1, 12, 1, 104, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 111, 8, 2, 1, 3, 3, 3, 114, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 119, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 125, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 134, 8, 5, 1, 5, 1, 5, 3, 5, 138, 8, 5, 1, 5, 1, 5, 1, 5, 3, 5, 143, 8, 5, 1, 5, 1, 5, 3, 5, 147, 8, 5, 1, 6, 1, 6, 1, 6, 5, 6, 152, 8, 6, 10, 6, 12, 6, 155, 9, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 5, 8, 163, 8, 8, 10, 8, 12, 8, 166, 9, 8, 3, 8, 168, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 183, 8, 9, 1, 10, 1, 10, 5, 10, 187, 8, 10, 10, 10, 12, 10, 190, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 3, 11, 196, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 202, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 214, 8, 14, 1, 14, 1, 14, 3, 14, 218, 8, 14, 1, 14, 1, 14, 3, 14, 222, 8, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 229, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 244, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 3, 21, 258, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 270, 8, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 3, 24, 277, 8, 24, 1, 25, 1, 25, 3, 25, 281, 8, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 3, 28, 291, 8, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 3, 31, 301, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 308, 8, 32, 1, 32, 1, 32, 4, 32, 312, 8, 32, 11, 32, 12, 32, 313, 1, 32, 3, 32, 317, 8, 32, 1, 33, 1, 33, 3, 33, 321, 8, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 329, 8, 34, 10, 34, 12, 34, 332, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 340, 8, 35, 10, 35, 12, 35, 343, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 3, 36, 353, 8, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 3, 38, 360, 8, 38, 1, 38, 5, 38, 363, 8, 38, 10, 38, 12, 38, 366, 9, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 377, 8, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 0, 2, 68, 70, 44, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 0, 3, 2, 0, 4, 6, 47, 47, 1, 0, 43, 46, 1, 0, 11, 12, 404, 0, 89, 1, 0, 0, 0, 2, 94, 1, 0, 0, 0, 4, 110, 1, 0, 0, 0, 6, 113, 1, 0, 0, 0, 8, 124, 1, 0, 0, 0, 10, 146, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 156, 1, 0, 0, 0, 16, 167, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 184, 1, 0, 0, 0, 22, 193, 1, 0, 0, 0, 24, 197, 1, 0, 0, 0, 26, 203, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 226, 1, 0, 0, 0, 32, 230, 1, 0, 0, 0, 34, 236, 1, 0, 0, 0, 36, 243, 1, 0, 0, 0, 38, 245, 1, 0, 0, 0, 40, 249, 1, 0, 0, 0, 42, 257, 1, 0, 0, 0, 44, 269, 1, 0, 0, 0, 46, 271, 1, 0, 0, 0, 48, 276, 1, 0, 0, 0, 50, 280, 1, 0, 0, 0, 52, 282, 1, 0, 0, 0, 54, 285, 1, 0, 0, 0, 56, 290, 1, 0, 0, 0, 58, 292, 1, 0, 0, 0, 60, 295, 1, 0, 0, 0, 62, 300, 1, 0, 0, 0, 64, 316, 1, 0, 0, 0, 66, 320, 1, 0, 0, 0, 68, 322, 1, 0, 0, 0, 70, 333, 1, 0, 0, 0, 72, 352, 1, 0, 0, 0, 74, 354, 1, 0, 0, 0, 76, 359, 1, 0, 0, 0, 78, 376, 1, 0, 0, 0, 80, 380, 1, 0, 0, 0, 82, 386, 1, 0, 0, 0, 84, 388, 1, 0, 0, 0, 86, 390, 1, 0, 0, 0, 88, 90, 3, 2, 1, 0, 89, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 1, 1, 0, 0, 0, 93, 95, 5, 7, 0, 0, 94, 93, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 5, 35, 0, 0, 97, 98, 5, 47, 0, 0, 98, 102, 5, 31, 0, 0, 99, 101, 3, 4, 2, 0, 100, 99, 1, 0, 0, 0, 101, 104, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 105, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 106, 5, 32, 0, 0, 106, 3, 1, 0, 0, 0, 107, 111, 3, 6, 3, 0, 108, 111, 3, 8, 4, 0, 109, 111, 3, 10, 5, 0, 110, 107, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 109, 1, 0, 0, 0, 111, 5, 1, 0, 0, 0, 112, 114, 5, 7, 0, 0, 113, 112, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 5, 47, 0, 0, 116, 118, 5, 29, 0, 0, 117, 119, 3, 12, 6, 0, 118, 117, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 5, 30, 0, 0, 121, 122, 3, 20, 10, 0, 122, 7, 1, 0, 0, 0, 123, 125, 5, 7, 0, 0, 124, 123, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 3, 82, 41, 0, 127, 128, 5, 47, 0, 0, 128, 129, 5, 33, 0, 0, 129, 9, 1, 0, 0, 0, 130, 131, 5, 8, 0, 0, 131, 147, 3, 20, 10, 0, 132, 134, 5, 7, 0, 0, 133, 132, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 137, 1, 0, 0, 0, 135, 138, 3, 82, 41, 0, 136, 138, 5, 3, 0, 0, 137, 135, 1, 0, 0, 0, 137, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 5, 47, 0, 0, 140, 142, 5, 29, 0, 0, 141, 143, 3, 12, 6, 0, 142, 141, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 5, 30, 0, 0, 145, 147, 3, 20, 10, 0, 146, 130, 1, 0, 0, 0, 146, 133, 1, 0, 0, 0, 147, 11, 1, 0, 0, 0, 148, 153, 3, 14, 7, 0, 149, 150, 5, 34, 0, 0, 150, 152, 3, 14, 7, 0, 151, 149, 1, 0, 0, 0, 152, 155, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 153, 154, 1, 0, 0, 0, 154, 13, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 156, 157, 3, 82, 41, 0, 157, 158, 5, 47, 0, 0, 158, 15, 1, 0, 0, 0, 159, 164, 3, 42, 21, 0, 160, 161, 5, 34, 0, 0, 161, 163, 3, 42, 21, 0, 162, 160, 1, 0, 0, 0, 163, 166, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 168, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 167, 159, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 17, 1, 0, 0, 0, 169, 170, 3, 22, 11, 0, 170, 171, 5, 33, 0, 0, 171, 183, 1, 0, 0, 0, 172, 173, 3, 24, 12, 0, 173, 174, 5, 33, 0, 0, 174, 183, 1, 0, 0, 0, 175, 183, 3, 20, 10, 0, 176, 183, 3, 26, 13, 0, 177, 183, 3, 28, 14, 0, 178, 183, 3, 30, 15, 0, 179, 180, 3, 36, 18, 0, 180, 181, 5, 33, 0, 0, 181, 183, 1, 0, 0, 0, 182, 169, 1, 0, 0, 0, 182, 172, 1, 0, 0, 0, 182, 175, 1, 0, 0, 0, 182, 176, 1, 0, 0, 0, 182, 177, 1, 0, 0, 0, 182, 178, 1, 0, 0, 0, 182, 179, 1, 0, 0, 0, 183, 19, 1, 0, 0, 0, 184, 188, 5, 31, 0, 0, 185, 187, 3, 18, 9, 0, 186, 185, 1, 0, 0, 0, 187, 190, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 191, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 191, 192, 5, 32, 0, 0, 192, 21, 1, 0, 0, 0, 193, 195, 5, 41, 0, 0, 194, 196, 3, 42, 21, 0, 195, 194, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 23, 1, 0, 0, 0, 197, 198, 3, 82, 41, 0, 198, 201, 5, 47, 0, 0, 199, 200, 5, 13, 0, 0, 200, 202, 3, 42, 21, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0, 0, 203, 204, 5, 37, 0, 0, 204, 205, 5, 29, 0, 0, 205, 206, 3, 42, 21, 0, 206, 207, 5, 30, 0, 0, 207, 208, 3, 20, 10, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 40, 0, 0, 210, 213, 5, 29, 0, 0, 211, 214, 3, 36, 18, 0, 212, 214, 3, 24, 12, 0, 213, 211, 1, 0, 0, 0, 213, 212, 1, 0, 0, 0, 214, 215, 1, 0, 0, 0, 215, 217, 5, 33, 0, 0, 216, 218, 3, 42, 21, 0, 217, 216, 1, 0, 0, 0, 217, 218, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 221, 5, 33, 0, 0, 220, 222, 3, 36, 18, 0, 221, 220, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 223, 1, 0, 0, 0, 223, 224, 5, 30, 0, 0, 224, 225, 3, 18, 9, 0, 225, 29, 1, 0, 0, 0, 226, 228, 3, 32, 16, 0, 227, 229, 3, 34, 17, 0, 228, 227, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 31, 1, 0, 0, 0, 230, 231, 5, 38, 0, 0, 231, 232, 5, 29, 0, 0, 232, 233, 3, 42, 21, 0, 233, 234, 5, 30, 0, 0, 234, 235, 3, 18, 9, 0, 235, 33, 1, 0, 0, 0, 236, 237, 5, 39, 0, 0, 237, 238, 3, 18, 9, 0, 238, 35, 1, 0, 0, 0, 239, 244, 3, 38, 19, 0, 240, 244, 3, 40, 20, 0, 241, 244, 3, 76, 38, 0, 242, 244, 3, 48, 24, 0, 243, 239, 1, 0, 0, 0, 243, 240, 1, 0, 0, 0, 243, 241, 1, 0, 0, 0, 243, 242, 1, 0, 0, 0, 244, 37, 1, 0, 0, 0, 245, 246, 3, 62, 31, 0, 246, 247, 5, 13, 0, 0, 247, 248, 3, 42, 21, 0, 248, 39, 1, 0, 0, 0, 249, 250, 5, 42, 0, 0, 250, 251, 5, 47, 0, 0, 251, 252, 5, 29, 0, 0, 252, 253, 3, 16, 8, 0, 253, 254, 5, 30, 0, 0, 254, 41, 1, 0, 0, 0, 255, 258, 3, 44, 22, 0, 256, 258, 3, 66, 33, 0, 257, 255, 1, 0, 0, 0, 257, 256, 1, 0, 0, 0, 258, 43, 1, 0, 0, 0, 259, 270, 5, 36, 0, 0, 260, 270, 5, 47, 0, 0, 261, 270, 3, 64, 32, 0, 262, 270, 3, 84, 42, 0, 263, 270, 3, 46, 23, 0, 264, 270, 3, 36, 18, 0, 265, 266, 5, 29, 0, 0, 266, 267, 3, 42, 21, 0, 267, 268, 5, 30, 0, 0, 268, 270, 1, 0, 0, 0, 269, 259, 1, 0, 0, 0, 269, 260, 1, 0, 0, 0, 269, 261, 1, 0, 0, 0, 269, 262, 1, 0, 0, 0, 269, 263, 1, 0, 0, 0, 269, 264, 1, 0, 0, 0, 269, 265, 1, 0, 0, 0, 270, 45, 1, 0, 0, 0, 271, 272, 5, 25, 0, 0, 272, 273, 3, 42, 21, 0, 273, 47, 1, 0, 0, 0, 274, 277, 3, 50, 25, 0, 275, 277, 3, 56, 28, 0, 276, 274, 1, 0, 0, 0, 276, 275, 1, 0, 0, 0, 277, 49, 1, 0, 0, 0, 278, 281, 3, 52, 26, 0, 279, 281, 3, 54, 27, 0, 280, 278, 1, 0, 0, 0, 280, 279, 1, 0, 0, 0, 281, 51, 1, 0, 0, 0, 282, 283, 5, 1, 0, 0, 283, 284, 3, 62, 31, 0, 284, 53, 1, 0, 0, 0, 285, 286, 3, 62, 31, 0, 286, 287, 5, 1, 0, 0, 287, 55, 1, 0, 0, 0, 288, 291, 3, 58, 29, 0, 289, 291, 3, 60, 30, 0, 290, 288, 1, 0, 0, 0, 290, 289, 1, 0, 0, 0, 291, 57, 1, 0, 0, 0, 292, 293, 5, 2, 0, 0, 293, 294, 3, 62, 31, 0, 294, 59, 1, 0, 0, 0, 295, 296, 3, 62, 31, 0, 296, 297, 5, 2, 0, 0, 297, 61, 1, 0, 0, 0, 298, 301, 5, 47, 0, 0, 299, 301, 3, 64, 32, 0, 300, 298, 1, 0, 0, 0, 300, 299, 1, 0, 0, 0, 301, 63, 1, 0, 0, 0, 302, 303, 5, 36, 0, 0, 303, 304, 5, 28, 0, 0, 304, 317, 5, 47, 0, 0, 305, 306, 5, 36, 0, 0, 306, 308, 5, 28, 0, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 311, 1, 0, 0, 0, 309, 310, 5, 47, 0, 0, 310, 312, 5, 28, 0, 0, 311, 309, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 311, 1, 0, 0, 0, 313, 314, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 317, 5, 47, 0, 0, 316, 302, 1, 0, 0, 0, 316, 307, 1, 0, 0, 0, 317, 65, 1, 0, 0, 0, 318, 321, 3, 68, 34, 0, 319, 321, 3, 74, 37, 0, 320, 318, 1, 0, 0, 0, 320, 319, 1, 0, 0, 0, 321, 67, 1, 0, 0, 0, 322, 323, 6, 34, -1, 0, 323, 324, 3, 70, 35, 0, 324, 330, 1, 0, 0, 0, 325, 326, 10, 2, 0, 0, 326, 327, 5, 10, 0, 0, 327, 329, 3, 70, 35, 0, 328, 325, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 69, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 334, 6, 35, -1, 0, 334, 335, 3, 72, 36, 0, 335, 341, 1, 0, 0, 0, 336, 337, 10, 2, 0, 0, 337, 338, 5, 9, 0, 0, 338, 340, 3, 72, 36, 0, 339, 336, 1, 0, 0, 0, 340, 343, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 71, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 344, 353, 5, 44, 0, 0, 345, 353, 5, 47, 0, 0, 346, 353, 3, 64, 32, 0, 347, 348, 3, 76, 38, 0, 348, 349, 5, 29, 0, 0, 349, 350, 3, 68, 34, 0, 350, 351, 5, 30, 0, 0, 351, 353, 1, 0, 0, 0, 352, 344, 1, 0, 0, 0, 352, 345, 1, 0, 0, 0, 352, 346, 1, 0, 0, 0, 352, 347, 1, 0, 0, 0, 353, 73, 1, 0, 0, 0, 354, 355, 3, 44, 22, 0, 355, 356, 3, 86, 43, 0, 356, 357, 3, 42, 21, 0, 357, 75, 1, 0, 0, 0, 358, 360, 3, 78, 39, 0, 359, 358, 1, 0, 0, 0, 359, 360, 1, 0, 0, 0, 360, 364, 1, 0, 0, 0, 361, 363, 3, 80, 40, 0, 362, 361, 1, 0, 0, 0, 363, 366, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 365, 1, 0, 0, 0, 365, 367, 1, 0, 0, 0, 366, 364, 1, 0, 0, 0, 367, 368, 5, 47, 0, 0, 368, 369, 5, 29, 0, 0, 369, 370, 3, 16, 8, 0, 370, 371, 5, 30, 0, 0, 371, 77, 1, 0, 0, 0, 372, 377, 5, 36, 0, 0, 373, 377, 3, 64, 32, 0, 374, 377, 3, 40, 20, 0, 375, 377, 5, 47, 0, 0, 376, 372, 1, 0, 0, 0, 376, 373, 1, 0, 0, 0, 376, 374, 1, 0, 0, 0, 376, 375, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 379, 5, 28, 0, 0, 379, 79, 1, 0, 0, 0, 380, 381, 5, 47, 0, 0, 381, 382, 5, 29, 0, 0, 382, 383, 3, 16, 8, 0, 383, 384, 5, 30, 0, 0, 384, 385, 5, 28, 0, 0, 385, 81, 1, 0, 0, 0, 386, 387, 7, 0, 0, 0, 387, 83, 1, 0, 0, 0, 388, 389, 7, 1, 0, 0, 389, 85, 1, 0, 0, 0, 390, 391, 7, 2, 0, 0, 391, 87, 1, 0, 0, 0, 39, 91, 94, 102, 110, 113, 118, 124, 133, 137, 142, 146, 153, 164, 167, 182, 188, 195, 201, 213, 217, 221, 228, 243, 257, 269, 276, 280, 290, 300, 307, 313, 316, 320, 330, 341, 352, 359, 364, 376] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJava.tokens b/src/main/java/parser/generated/SimpleJava.tokens deleted file mode 100644 index bed7437..0000000 --- a/src/main/java/parser/generated/SimpleJava.tokens +++ /dev/null @@ -1,88 +0,0 @@ -T__0=1 -T__1=2 -Void=3 -Boolean=4 -Char=5 -Int=6 -AccessModifier=7 -MainMethodDeclaration=8 -DotOperator=9 -LineOperator=10 -ComparisonOperator=11 -LogicalOperator=12 -Assign=13 -Plus=14 -Minus=15 -Mult=16 -Modulo=17 -Div=18 -Greater=19 -Less=20 -GreaterEqual=21 -LessEqual=22 -Equal=23 -NotEqual=24 -Not=25 -And=26 -Or=27 -Dot=28 -OpenRoundBracket=29 -ClosedRoundBracket=30 -OpenCurlyBracket=31 -ClosedCurlyBracket=32 -Semicolon=33 -Comma=34 -Class=35 -This=36 -While=37 -If=38 -Else=39 -For=40 -Return=41 -New=42 -CharValue=43 -IntValue=44 -BooleanValue=45 -NullValue=46 -Identifier=47 -WS=48 -InlineComment=49 -MultilineComment=50 -'++'=1 -'--'=2 -'void'=3 -'boolean'=4 -'char'=5 -'int'=6 -'public static void main(String[] args)'=8 -'='=13 -'+'=14 -'-'=15 -'*'=16 -'%'=17 -'/'=18 -'>'=19 -'<'=20 -'>='=21 -'<='=22 -'=='=23 -'!='=24 -'!'=25 -'&&'=26 -'||'=27 -'.'=28 -'('=29 -')'=30 -'{'=31 -'}'=32 -';'=33 -','=34 -'class'=35 -'this'=36 -'while'=37 -'if'=38 -'else'=39 -'for'=40 -'return'=41 -'new'=42 -'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaBaseListener.java b/src/main/java/parser/generated/SimpleJavaBaseListener.java deleted file mode 100644 index 2bf9ddd..0000000 --- a/src/main/java/parser/generated/SimpleJavaBaseListener.java +++ /dev/null @@ -1,568 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 -package parser.generated; - -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.tree.ErrorNode; -import org.antlr.v4.runtime.tree.TerminalNode; - -/** - * This class provides an empty implementation of {@link SimpleJavaListener}, - * which can be extended to create a listener which only needs to handle a subset - * of the available methods. - */ -@SuppressWarnings("CheckReturnValue") -public class SimpleJavaBaseListener implements SimpleJavaListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterProgram(SimpleJavaParser.ProgramContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitProgram(SimpleJavaParser.ProgramContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} - * - *

The default implementation does nothing.

- */ - @Override public void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameterList(SimpleJavaParser.ParameterListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameterList(SimpleJavaParser.ParameterListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameter(SimpleJavaParser.ParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameter(SimpleJavaParser.ParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStatement(SimpleJavaParser.StatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStatement(SimpleJavaParser.StatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterForStatement(SimpleJavaParser.ForStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitForStatement(SimpleJavaParser.ForStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssign(SimpleJavaParser.AssignContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssign(SimpleJavaParser.AssignContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExpression(SimpleJavaParser.ExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExpression(SimpleJavaParser.ExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMethodCall(SimpleJavaParser.MethodCallContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMethodCall(SimpleJavaParser.MethodCallContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTarget(SimpleJavaParser.TargetContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTarget(SimpleJavaParser.TargetContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterType(SimpleJavaParser.TypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitType(SimpleJavaParser.TypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterValue(SimpleJavaParser.ValueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitValue(SimpleJavaParser.ValueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java deleted file mode 100644 index 92fb64c..0000000 --- a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java +++ /dev/null @@ -1,323 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 -package parser.generated; -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link SimpleJavaVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -@SuppressWarnings("CheckReturnValue") -public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implements SimpleJavaVisitor { - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitProgram(SimpleJavaParser.ProgramContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@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 visitParameterList(SimpleJavaParser.ParameterListContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitParameter(SimpleJavaParser.ParameterContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStatement(SimpleJavaParser.StatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitForStatement(SimpleJavaParser.ForStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAssign(SimpleJavaParser.AssignContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExpression(SimpleJavaParser.ExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMethodCall(SimpleJavaParser.MethodCallContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTarget(SimpleJavaParser.TargetContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitValue(SimpleJavaParser.ValueContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.interp b/src/main/java/parser/generated/SimpleJavaLexer.interp deleted file mode 100644 index 919e1fd..0000000 --- a/src/main/java/parser/generated/SimpleJavaLexer.interp +++ /dev/null @@ -1,170 +0,0 @@ -token literal names: -null -'++' -'--' -'void' -'boolean' -'char' -'int' -null -'public static void main(String[] args)' -null -null -null -null -'=' -'+' -'-' -'*' -'%' -'/' -'>' -'<' -'>=' -'<=' -'==' -'!=' -'!' -'&&' -'||' -'.' -'(' -')' -'{' -'}' -';' -',' -'class' -'this' -'while' -'if' -'else' -'for' -'return' -'new' -null -null -null -'null' -null -null -null -null - -token symbolic names: -null -null -null -Void -Boolean -Char -Int -AccessModifier -MainMethodDeclaration -DotOperator -LineOperator -ComparisonOperator -LogicalOperator -Assign -Plus -Minus -Mult -Modulo -Div -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -For -Return -New -CharValue -IntValue -BooleanValue -NullValue -Identifier -WS -InlineComment -MultilineComment - -rule names: -T__0 -T__1 -Void -Boolean -Char -Int -AccessModifier -MainMethodDeclaration -DotOperator -LineOperator -ComparisonOperator -LogicalOperator -Assign -Plus -Minus -Mult -Modulo -Div -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -For -Return -New -CharValue -IntValue -BooleanValue -NullValue -Alphabetic -Numeric -ValidIdentSymbols -Identifier -WS -InlineComment -MultilineComment - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 50, 408, 6, -1, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 176, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 3, 8, 220, 8, 8, 1, 9, 1, 9, 3, 9, 224, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 3, 10, 232, 8, 10, 1, 11, 1, 11, 3, 11, 236, 8, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 5, 42, 330, 8, 42, 10, 42, 12, 42, 333, 9, 42, 1, 42, 1, 42, 1, 43, 3, 43, 338, 8, 43, 1, 43, 4, 43, 341, 8, 43, 11, 43, 12, 43, 342, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 354, 8, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 3, 48, 368, 8, 48, 1, 49, 1, 49, 5, 49, 372, 8, 49, 10, 49, 12, 49, 375, 9, 49, 1, 50, 4, 50, 378, 8, 50, 11, 50, 12, 50, 379, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 5, 51, 388, 8, 51, 10, 51, 12, 51, 391, 9, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 5, 52, 399, 8, 52, 10, 52, 12, 52, 402, 9, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 400, 0, 53, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 0, 95, 0, 97, 0, 99, 47, 101, 48, 103, 49, 105, 50, 1, 0, 5, 2, 0, 10, 10, 13, 13, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 2, 0, 36, 36, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 426, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 1, 107, 1, 0, 0, 0, 3, 110, 1, 0, 0, 0, 5, 113, 1, 0, 0, 0, 7, 118, 1, 0, 0, 0, 9, 126, 1, 0, 0, 0, 11, 131, 1, 0, 0, 0, 13, 175, 1, 0, 0, 0, 15, 177, 1, 0, 0, 0, 17, 219, 1, 0, 0, 0, 19, 223, 1, 0, 0, 0, 21, 231, 1, 0, 0, 0, 23, 235, 1, 0, 0, 0, 25, 237, 1, 0, 0, 0, 27, 239, 1, 0, 0, 0, 29, 241, 1, 0, 0, 0, 31, 243, 1, 0, 0, 0, 33, 245, 1, 0, 0, 0, 35, 247, 1, 0, 0, 0, 37, 249, 1, 0, 0, 0, 39, 251, 1, 0, 0, 0, 41, 253, 1, 0, 0, 0, 43, 256, 1, 0, 0, 0, 45, 259, 1, 0, 0, 0, 47, 262, 1, 0, 0, 0, 49, 265, 1, 0, 0, 0, 51, 267, 1, 0, 0, 0, 53, 270, 1, 0, 0, 0, 55, 273, 1, 0, 0, 0, 57, 275, 1, 0, 0, 0, 59, 277, 1, 0, 0, 0, 61, 279, 1, 0, 0, 0, 63, 281, 1, 0, 0, 0, 65, 283, 1, 0, 0, 0, 67, 285, 1, 0, 0, 0, 69, 287, 1, 0, 0, 0, 71, 293, 1, 0, 0, 0, 73, 298, 1, 0, 0, 0, 75, 304, 1, 0, 0, 0, 77, 307, 1, 0, 0, 0, 79, 312, 1, 0, 0, 0, 81, 316, 1, 0, 0, 0, 83, 323, 1, 0, 0, 0, 85, 327, 1, 0, 0, 0, 87, 337, 1, 0, 0, 0, 89, 353, 1, 0, 0, 0, 91, 355, 1, 0, 0, 0, 93, 360, 1, 0, 0, 0, 95, 362, 1, 0, 0, 0, 97, 367, 1, 0, 0, 0, 99, 369, 1, 0, 0, 0, 101, 377, 1, 0, 0, 0, 103, 383, 1, 0, 0, 0, 105, 394, 1, 0, 0, 0, 107, 108, 5, 43, 0, 0, 108, 109, 5, 43, 0, 0, 109, 2, 1, 0, 0, 0, 110, 111, 5, 45, 0, 0, 111, 112, 5, 45, 0, 0, 112, 4, 1, 0, 0, 0, 113, 114, 5, 118, 0, 0, 114, 115, 5, 111, 0, 0, 115, 116, 5, 105, 0, 0, 116, 117, 5, 100, 0, 0, 117, 6, 1, 0, 0, 0, 118, 119, 5, 98, 0, 0, 119, 120, 5, 111, 0, 0, 120, 121, 5, 111, 0, 0, 121, 122, 5, 108, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 110, 0, 0, 125, 8, 1, 0, 0, 0, 126, 127, 5, 99, 0, 0, 127, 128, 5, 104, 0, 0, 128, 129, 5, 97, 0, 0, 129, 130, 5, 114, 0, 0, 130, 10, 1, 0, 0, 0, 131, 132, 5, 105, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 116, 0, 0, 134, 12, 1, 0, 0, 0, 135, 136, 5, 112, 0, 0, 136, 137, 5, 117, 0, 0, 137, 138, 5, 98, 0, 0, 138, 139, 5, 108, 0, 0, 139, 140, 5, 105, 0, 0, 140, 176, 5, 99, 0, 0, 141, 142, 5, 112, 0, 0, 142, 143, 5, 114, 0, 0, 143, 144, 5, 105, 0, 0, 144, 145, 5, 118, 0, 0, 145, 146, 5, 97, 0, 0, 146, 147, 5, 116, 0, 0, 147, 176, 5, 101, 0, 0, 148, 149, 5, 112, 0, 0, 149, 150, 5, 117, 0, 0, 150, 151, 5, 98, 0, 0, 151, 152, 5, 108, 0, 0, 152, 153, 5, 105, 0, 0, 153, 154, 5, 99, 0, 0, 154, 155, 5, 32, 0, 0, 155, 156, 5, 115, 0, 0, 156, 157, 5, 116, 0, 0, 157, 158, 5, 97, 0, 0, 158, 159, 5, 116, 0, 0, 159, 160, 5, 105, 0, 0, 160, 176, 5, 99, 0, 0, 161, 162, 5, 112, 0, 0, 162, 163, 5, 114, 0, 0, 163, 164, 5, 105, 0, 0, 164, 165, 5, 118, 0, 0, 165, 166, 5, 97, 0, 0, 166, 167, 5, 116, 0, 0, 167, 168, 5, 101, 0, 0, 168, 169, 5, 32, 0, 0, 169, 170, 5, 115, 0, 0, 170, 171, 5, 116, 0, 0, 171, 172, 5, 97, 0, 0, 172, 173, 5, 116, 0, 0, 173, 174, 5, 105, 0, 0, 174, 176, 5, 99, 0, 0, 175, 135, 1, 0, 0, 0, 175, 141, 1, 0, 0, 0, 175, 148, 1, 0, 0, 0, 175, 161, 1, 0, 0, 0, 176, 14, 1, 0, 0, 0, 177, 178, 5, 112, 0, 0, 178, 179, 5, 117, 0, 0, 179, 180, 5, 98, 0, 0, 180, 181, 5, 108, 0, 0, 181, 182, 5, 105, 0, 0, 182, 183, 5, 99, 0, 0, 183, 184, 5, 32, 0, 0, 184, 185, 5, 115, 0, 0, 185, 186, 5, 116, 0, 0, 186, 187, 5, 97, 0, 0, 187, 188, 5, 116, 0, 0, 188, 189, 5, 105, 0, 0, 189, 190, 5, 99, 0, 0, 190, 191, 5, 32, 0, 0, 191, 192, 5, 118, 0, 0, 192, 193, 5, 111, 0, 0, 193, 194, 5, 105, 0, 0, 194, 195, 5, 100, 0, 0, 195, 196, 5, 32, 0, 0, 196, 197, 5, 109, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, 105, 0, 0, 199, 200, 5, 110, 0, 0, 200, 201, 5, 40, 0, 0, 201, 202, 5, 83, 0, 0, 202, 203, 5, 116, 0, 0, 203, 204, 5, 114, 0, 0, 204, 205, 5, 105, 0, 0, 205, 206, 5, 110, 0, 0, 206, 207, 5, 103, 0, 0, 207, 208, 5, 91, 0, 0, 208, 209, 5, 93, 0, 0, 209, 210, 5, 32, 0, 0, 210, 211, 5, 97, 0, 0, 211, 212, 5, 114, 0, 0, 212, 213, 5, 103, 0, 0, 213, 214, 5, 115, 0, 0, 214, 215, 5, 41, 0, 0, 215, 16, 1, 0, 0, 0, 216, 220, 3, 31, 15, 0, 217, 220, 3, 35, 17, 0, 218, 220, 3, 33, 16, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 218, 1, 0, 0, 0, 220, 18, 1, 0, 0, 0, 221, 224, 3, 27, 13, 0, 222, 224, 3, 29, 14, 0, 223, 221, 1, 0, 0, 0, 223, 222, 1, 0, 0, 0, 224, 20, 1, 0, 0, 0, 225, 232, 3, 37, 18, 0, 226, 232, 3, 39, 19, 0, 227, 232, 3, 41, 20, 0, 228, 232, 3, 43, 21, 0, 229, 232, 3, 45, 22, 0, 230, 232, 3, 47, 23, 0, 231, 225, 1, 0, 0, 0, 231, 226, 1, 0, 0, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 22, 1, 0, 0, 0, 233, 236, 3, 51, 25, 0, 234, 236, 3, 53, 26, 0, 235, 233, 1, 0, 0, 0, 235, 234, 1, 0, 0, 0, 236, 24, 1, 0, 0, 0, 237, 238, 5, 61, 0, 0, 238, 26, 1, 0, 0, 0, 239, 240, 5, 43, 0, 0, 240, 28, 1, 0, 0, 0, 241, 242, 5, 45, 0, 0, 242, 30, 1, 0, 0, 0, 243, 244, 5, 42, 0, 0, 244, 32, 1, 0, 0, 0, 245, 246, 5, 37, 0, 0, 246, 34, 1, 0, 0, 0, 247, 248, 5, 47, 0, 0, 248, 36, 1, 0, 0, 0, 249, 250, 5, 62, 0, 0, 250, 38, 1, 0, 0, 0, 251, 252, 5, 60, 0, 0, 252, 40, 1, 0, 0, 0, 253, 254, 5, 62, 0, 0, 254, 255, 5, 61, 0, 0, 255, 42, 1, 0, 0, 0, 256, 257, 5, 60, 0, 0, 257, 258, 5, 61, 0, 0, 258, 44, 1, 0, 0, 0, 259, 260, 5, 61, 0, 0, 260, 261, 5, 61, 0, 0, 261, 46, 1, 0, 0, 0, 262, 263, 5, 33, 0, 0, 263, 264, 5, 61, 0, 0, 264, 48, 1, 0, 0, 0, 265, 266, 5, 33, 0, 0, 266, 50, 1, 0, 0, 0, 267, 268, 5, 38, 0, 0, 268, 269, 5, 38, 0, 0, 269, 52, 1, 0, 0, 0, 270, 271, 5, 124, 0, 0, 271, 272, 5, 124, 0, 0, 272, 54, 1, 0, 0, 0, 273, 274, 5, 46, 0, 0, 274, 56, 1, 0, 0, 0, 275, 276, 5, 40, 0, 0, 276, 58, 1, 0, 0, 0, 277, 278, 5, 41, 0, 0, 278, 60, 1, 0, 0, 0, 279, 280, 5, 123, 0, 0, 280, 62, 1, 0, 0, 0, 281, 282, 5, 125, 0, 0, 282, 64, 1, 0, 0, 0, 283, 284, 5, 59, 0, 0, 284, 66, 1, 0, 0, 0, 285, 286, 5, 44, 0, 0, 286, 68, 1, 0, 0, 0, 287, 288, 5, 99, 0, 0, 288, 289, 5, 108, 0, 0, 289, 290, 5, 97, 0, 0, 290, 291, 5, 115, 0, 0, 291, 292, 5, 115, 0, 0, 292, 70, 1, 0, 0, 0, 293, 294, 5, 116, 0, 0, 294, 295, 5, 104, 0, 0, 295, 296, 5, 105, 0, 0, 296, 297, 5, 115, 0, 0, 297, 72, 1, 0, 0, 0, 298, 299, 5, 119, 0, 0, 299, 300, 5, 104, 0, 0, 300, 301, 5, 105, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 101, 0, 0, 303, 74, 1, 0, 0, 0, 304, 305, 5, 105, 0, 0, 305, 306, 5, 102, 0, 0, 306, 76, 1, 0, 0, 0, 307, 308, 5, 101, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 115, 0, 0, 310, 311, 5, 101, 0, 0, 311, 78, 1, 0, 0, 0, 312, 313, 5, 102, 0, 0, 313, 314, 5, 111, 0, 0, 314, 315, 5, 114, 0, 0, 315, 80, 1, 0, 0, 0, 316, 317, 5, 114, 0, 0, 317, 318, 5, 101, 0, 0, 318, 319, 5, 116, 0, 0, 319, 320, 5, 117, 0, 0, 320, 321, 5, 114, 0, 0, 321, 322, 5, 110, 0, 0, 322, 82, 1, 0, 0, 0, 323, 324, 5, 110, 0, 0, 324, 325, 5, 101, 0, 0, 325, 326, 5, 119, 0, 0, 326, 84, 1, 0, 0, 0, 327, 331, 5, 39, 0, 0, 328, 330, 8, 0, 0, 0, 329, 328, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 334, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 39, 0, 0, 335, 86, 1, 0, 0, 0, 336, 338, 3, 29, 14, 0, 337, 336, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 340, 1, 0, 0, 0, 339, 341, 3, 95, 47, 0, 340, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 340, 1, 0, 0, 0, 342, 343, 1, 0, 0, 0, 343, 88, 1, 0, 0, 0, 344, 345, 5, 116, 0, 0, 345, 346, 5, 114, 0, 0, 346, 347, 5, 117, 0, 0, 347, 354, 5, 101, 0, 0, 348, 349, 5, 102, 0, 0, 349, 350, 5, 97, 0, 0, 350, 351, 5, 108, 0, 0, 351, 352, 5, 115, 0, 0, 352, 354, 5, 101, 0, 0, 353, 344, 1, 0, 0, 0, 353, 348, 1, 0, 0, 0, 354, 90, 1, 0, 0, 0, 355, 356, 5, 110, 0, 0, 356, 357, 5, 117, 0, 0, 357, 358, 5, 108, 0, 0, 358, 359, 5, 108, 0, 0, 359, 92, 1, 0, 0, 0, 360, 361, 7, 1, 0, 0, 361, 94, 1, 0, 0, 0, 362, 363, 7, 2, 0, 0, 363, 96, 1, 0, 0, 0, 364, 368, 3, 93, 46, 0, 365, 368, 3, 95, 47, 0, 366, 368, 7, 3, 0, 0, 367, 364, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 367, 366, 1, 0, 0, 0, 368, 98, 1, 0, 0, 0, 369, 373, 3, 93, 46, 0, 370, 372, 3, 97, 48, 0, 371, 370, 1, 0, 0, 0, 372, 375, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 373, 374, 1, 0, 0, 0, 374, 100, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 376, 378, 7, 4, 0, 0, 377, 376, 1, 0, 0, 0, 378, 379, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 6, 50, 0, 0, 382, 102, 1, 0, 0, 0, 383, 384, 5, 47, 0, 0, 384, 385, 5, 47, 0, 0, 385, 389, 1, 0, 0, 0, 386, 388, 8, 0, 0, 0, 387, 386, 1, 0, 0, 0, 388, 391, 1, 0, 0, 0, 389, 387, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 392, 1, 0, 0, 0, 391, 389, 1, 0, 0, 0, 392, 393, 6, 51, 0, 0, 393, 104, 1, 0, 0, 0, 394, 395, 5, 47, 0, 0, 395, 396, 5, 42, 0, 0, 396, 400, 1, 0, 0, 0, 397, 399, 9, 0, 0, 0, 398, 397, 1, 0, 0, 0, 399, 402, 1, 0, 0, 0, 400, 401, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 403, 1, 0, 0, 0, 402, 400, 1, 0, 0, 0, 403, 404, 5, 42, 0, 0, 404, 405, 5, 47, 0, 0, 405, 406, 1, 0, 0, 0, 406, 407, 6, 52, 0, 0, 407, 106, 1, 0, 0, 0, 15, 0, 175, 219, 223, 231, 235, 331, 337, 342, 353, 367, 373, 379, 389, 400, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.java b/src/main/java/parser/generated/SimpleJavaLexer.java deleted file mode 100644 index cb01452..0000000 --- a/src/main/java/parser/generated/SimpleJavaLexer.java +++ /dev/null @@ -1,394 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 -package parser.generated; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) -public class SimpleJavaLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, - DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, - Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, - Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, - And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, - ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, - If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, - BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, - MultilineComment=50; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[] { - "T__0", "T__1", "Void", "Boolean", "Char", "Int", "AccessModifier", "MainMethodDeclaration", - "DotOperator", "LineOperator", "ComparisonOperator", "LogicalOperator", - "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", "Greater", "Less", - "GreaterEqual", "LessEqual", "Equal", "NotEqual", "Not", "And", "Or", - "Dot", "OpenRoundBracket", "ClosedRoundBracket", "OpenCurlyBracket", - "ClosedCurlyBracket", "Semicolon", "Comma", "Class", "This", "While", - "If", "Else", "For", "Return", "New", "CharValue", "IntValue", "BooleanValue", - "NullValue", "Alphabetic", "Numeric", "ValidIdentSymbols", "Identifier", - "WS", "InlineComment", "MultilineComment" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, - "'public static void main(String[] args)'", null, null, null, null, "'='", - "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", - "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", - "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", - "'new'", null, null, null, "'null'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", - "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", - "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", - "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", - "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", - "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", - "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", - "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public SimpleJavaLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "SimpleJava.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\u0004\u00002\u0198\u0006\uffff\uffff\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\u0002\u0014\u0007\u0014\u0002"+ - "\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ - "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ - "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ - "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ - "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ - "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ - "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+ - "0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u0001\u0000"+ - "\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ - "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ - "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ - "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+ - "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0003\u0006\u00b0\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\b\u0001\b\u0001\b\u0003\b\u00dc\b\b\u0001\t\u0001\t\u0003\t\u00e0"+ - "\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003\n\u00e8\b\n"+ - "\u0001\u000b\u0001\u000b\u0003\u000b\u00ec\b\u000b\u0001\f\u0001\f\u0001"+ - "\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+ - "\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+ - "\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+ - "\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017"+ - "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ - "\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001c"+ - "\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f"+ - "\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001"+ - "\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001$\u0001"+ - "$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001"+ - "&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001"+ - "(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0005*\u014a"+ - "\b*\n*\f*\u014d\t*\u0001*\u0001*\u0001+\u0003+\u0152\b+\u0001+\u0004+"+ - "\u0155\b+\u000b+\f+\u0156\u0001,\u0001,\u0001,\u0001,\u0001,\u0001,\u0001"+ - ",\u0001,\u0001,\u0003,\u0162\b,\u0001-\u0001-\u0001-\u0001-\u0001-\u0001"+ - ".\u0001.\u0001/\u0001/\u00010\u00010\u00010\u00030\u0170\b0\u00011\u0001"+ - "1\u00051\u0174\b1\n1\f1\u0177\t1\u00012\u00042\u017a\b2\u000b2\f2\u017b"+ - "\u00012\u00012\u00013\u00013\u00013\u00013\u00053\u0184\b3\n3\f3\u0187"+ - "\t3\u00013\u00013\u00014\u00014\u00014\u00014\u00054\u018f\b4\n4\f4\u0192"+ - "\t4\u00014\u00014\u00014\u00014\u00014\u0001\u0190\u00005\u0001\u0001"+ - "\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+ - "\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f"+ - "\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u0018"+ - "1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\'O("+ - "Q)S*U+W,Y-[.]\u0000_\u0000a\u0000c/e0g1i2\u0001\u0000\u0005\u0002\u0000"+ - "\n\n\r\r\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0003\u0000\t\n"+ - "\r\r \u01aa\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000"+ - "\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000"+ - "\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000"+ - "\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000"+ - "\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000"+ - "\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000"+ - "\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000"+ - "\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000"+ - "\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%"+ - "\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+ - "\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000"+ - "\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u0000"+ - "3\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001"+ - "\u0000\u0000\u0000\u00009\u0001\u0000\u0000\u0000\u0000;\u0001\u0000\u0000"+ - "\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001\u0000\u0000\u0000\u0000"+ - "A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+ - "\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+ - "\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+ - "O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+ - "\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+ - "\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+ - "c\u0001\u0000\u0000\u0000\u0000e\u0001\u0000\u0000\u0000\u0000g\u0001"+ - "\u0000\u0000\u0000\u0000i\u0001\u0000\u0000\u0000\u0001k\u0001\u0000\u0000"+ - "\u0000\u0003n\u0001\u0000\u0000\u0000\u0005q\u0001\u0000\u0000\u0000\u0007"+ - "v\u0001\u0000\u0000\u0000\t~\u0001\u0000\u0000\u0000\u000b\u0083\u0001"+ - "\u0000\u0000\u0000\r\u00af\u0001\u0000\u0000\u0000\u000f\u00b1\u0001\u0000"+ - "\u0000\u0000\u0011\u00db\u0001\u0000\u0000\u0000\u0013\u00df\u0001\u0000"+ - "\u0000\u0000\u0015\u00e7\u0001\u0000\u0000\u0000\u0017\u00eb\u0001\u0000"+ - "\u0000\u0000\u0019\u00ed\u0001\u0000\u0000\u0000\u001b\u00ef\u0001\u0000"+ - "\u0000\u0000\u001d\u00f1\u0001\u0000\u0000\u0000\u001f\u00f3\u0001\u0000"+ - "\u0000\u0000!\u00f5\u0001\u0000\u0000\u0000#\u00f7\u0001\u0000\u0000\u0000"+ - "%\u00f9\u0001\u0000\u0000\u0000\'\u00fb\u0001\u0000\u0000\u0000)\u00fd"+ - "\u0001\u0000\u0000\u0000+\u0100\u0001\u0000\u0000\u0000-\u0103\u0001\u0000"+ - "\u0000\u0000/\u0106\u0001\u0000\u0000\u00001\u0109\u0001\u0000\u0000\u0000"+ - "3\u010b\u0001\u0000\u0000\u00005\u010e\u0001\u0000\u0000\u00007\u0111"+ - "\u0001\u0000\u0000\u00009\u0113\u0001\u0000\u0000\u0000;\u0115\u0001\u0000"+ - "\u0000\u0000=\u0117\u0001\u0000\u0000\u0000?\u0119\u0001\u0000\u0000\u0000"+ - "A\u011b\u0001\u0000\u0000\u0000C\u011d\u0001\u0000\u0000\u0000E\u011f"+ - "\u0001\u0000\u0000\u0000G\u0125\u0001\u0000\u0000\u0000I\u012a\u0001\u0000"+ - "\u0000\u0000K\u0130\u0001\u0000\u0000\u0000M\u0133\u0001\u0000\u0000\u0000"+ - "O\u0138\u0001\u0000\u0000\u0000Q\u013c\u0001\u0000\u0000\u0000S\u0143"+ - "\u0001\u0000\u0000\u0000U\u0147\u0001\u0000\u0000\u0000W\u0151\u0001\u0000"+ - "\u0000\u0000Y\u0161\u0001\u0000\u0000\u0000[\u0163\u0001\u0000\u0000\u0000"+ - "]\u0168\u0001\u0000\u0000\u0000_\u016a\u0001\u0000\u0000\u0000a\u016f"+ - "\u0001\u0000\u0000\u0000c\u0171\u0001\u0000\u0000\u0000e\u0179\u0001\u0000"+ - "\u0000\u0000g\u017f\u0001\u0000\u0000\u0000i\u018a\u0001\u0000\u0000\u0000"+ - "kl\u0005+\u0000\u0000lm\u0005+\u0000\u0000m\u0002\u0001\u0000\u0000\u0000"+ - "no\u0005-\u0000\u0000op\u0005-\u0000\u0000p\u0004\u0001\u0000\u0000\u0000"+ - "qr\u0005v\u0000\u0000rs\u0005o\u0000\u0000st\u0005i\u0000\u0000tu\u0005"+ - "d\u0000\u0000u\u0006\u0001\u0000\u0000\u0000vw\u0005b\u0000\u0000wx\u0005"+ - "o\u0000\u0000xy\u0005o\u0000\u0000yz\u0005l\u0000\u0000z{\u0005e\u0000"+ - "\u0000{|\u0005a\u0000\u0000|}\u0005n\u0000\u0000}\b\u0001\u0000\u0000"+ - "\u0000~\u007f\u0005c\u0000\u0000\u007f\u0080\u0005h\u0000\u0000\u0080"+ - "\u0081\u0005a\u0000\u0000\u0081\u0082\u0005r\u0000\u0000\u0082\n\u0001"+ - "\u0000\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+ - "\u0000\u0085\u0086\u0005t\u0000\u0000\u0086\f\u0001\u0000\u0000\u0000"+ - "\u0087\u0088\u0005p\u0000\u0000\u0088\u0089\u0005u\u0000\u0000\u0089\u008a"+ - "\u0005b\u0000\u0000\u008a\u008b\u0005l\u0000\u0000\u008b\u008c\u0005i"+ - "\u0000\u0000\u008c\u00b0\u0005c\u0000\u0000\u008d\u008e\u0005p\u0000\u0000"+ - "\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005i\u0000\u0000\u0090\u0091"+ - "\u0005v\u0000\u0000\u0091\u0092\u0005a\u0000\u0000\u0092\u0093\u0005t"+ - "\u0000\u0000\u0093\u00b0\u0005e\u0000\u0000\u0094\u0095\u0005p\u0000\u0000"+ - "\u0095\u0096\u0005u\u0000\u0000\u0096\u0097\u0005b\u0000\u0000\u0097\u0098"+ - "\u0005l\u0000\u0000\u0098\u0099\u0005i\u0000\u0000\u0099\u009a\u0005c"+ - "\u0000\u0000\u009a\u009b\u0005 \u0000\u0000\u009b\u009c\u0005s\u0000\u0000"+ - "\u009c\u009d\u0005t\u0000\u0000\u009d\u009e\u0005a\u0000\u0000\u009e\u009f"+ - "\u0005t\u0000\u0000\u009f\u00a0\u0005i\u0000\u0000\u00a0\u00b0\u0005c"+ - "\u0000\u0000\u00a1\u00a2\u0005p\u0000\u0000\u00a2\u00a3\u0005r\u0000\u0000"+ - "\u00a3\u00a4\u0005i\u0000\u0000\u00a4\u00a5\u0005v\u0000\u0000\u00a5\u00a6"+ - "\u0005a\u0000\u0000\u00a6\u00a7\u0005t\u0000\u0000\u00a7\u00a8\u0005e"+ - "\u0000\u0000\u00a8\u00a9\u0005 \u0000\u0000\u00a9\u00aa\u0005s\u0000\u0000"+ - "\u00aa\u00ab\u0005t\u0000\u0000\u00ab\u00ac\u0005a\u0000\u0000\u00ac\u00ad"+ - "\u0005t\u0000\u0000\u00ad\u00ae\u0005i\u0000\u0000\u00ae\u00b0\u0005c"+ - "\u0000\u0000\u00af\u0087\u0001\u0000\u0000\u0000\u00af\u008d\u0001\u0000"+ - "\u0000\u0000\u00af\u0094\u0001\u0000\u0000\u0000\u00af\u00a1\u0001\u0000"+ - "\u0000\u0000\u00b0\u000e\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005p\u0000"+ - "\u0000\u00b2\u00b3\u0005u\u0000\u0000\u00b3\u00b4\u0005b\u0000\u0000\u00b4"+ - "\u00b5\u0005l\u0000\u0000\u00b5\u00b6\u0005i\u0000\u0000\u00b6\u00b7\u0005"+ - "c\u0000\u0000\u00b7\u00b8\u0005 \u0000\u0000\u00b8\u00b9\u0005s\u0000"+ - "\u0000\u00b9\u00ba\u0005t\u0000\u0000\u00ba\u00bb\u0005a\u0000\u0000\u00bb"+ - "\u00bc\u0005t\u0000\u0000\u00bc\u00bd\u0005i\u0000\u0000\u00bd\u00be\u0005"+ - "c\u0000\u0000\u00be\u00bf\u0005 \u0000\u0000\u00bf\u00c0\u0005v\u0000"+ - "\u0000\u00c0\u00c1\u0005o\u0000\u0000\u00c1\u00c2\u0005i\u0000\u0000\u00c2"+ - "\u00c3\u0005d\u0000\u0000\u00c3\u00c4\u0005 \u0000\u0000\u00c4\u00c5\u0005"+ - "m\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6\u00c7\u0005i\u0000"+ - "\u0000\u00c7\u00c8\u0005n\u0000\u0000\u00c8\u00c9\u0005(\u0000\u0000\u00c9"+ - "\u00ca\u0005S\u0000\u0000\u00ca\u00cb\u0005t\u0000\u0000\u00cb\u00cc\u0005"+ - "r\u0000\u0000\u00cc\u00cd\u0005i\u0000\u0000\u00cd\u00ce\u0005n\u0000"+ - "\u0000\u00ce\u00cf\u0005g\u0000\u0000\u00cf\u00d0\u0005[\u0000\u0000\u00d0"+ - "\u00d1\u0005]\u0000\u0000\u00d1\u00d2\u0005 \u0000\u0000\u00d2\u00d3\u0005"+ - "a\u0000\u0000\u00d3\u00d4\u0005r\u0000\u0000\u00d4\u00d5\u0005g\u0000"+ - "\u0000\u00d5\u00d6\u0005s\u0000\u0000\u00d6\u00d7\u0005)\u0000\u0000\u00d7"+ - "\u0010\u0001\u0000\u0000\u0000\u00d8\u00dc\u0003\u001f\u000f\u0000\u00d9"+ - "\u00dc\u0003#\u0011\u0000\u00da\u00dc\u0003!\u0010\u0000\u00db\u00d8\u0001"+ - "\u0000\u0000\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00db\u00da\u0001"+ - "\u0000\u0000\u0000\u00dc\u0012\u0001\u0000\u0000\u0000\u00dd\u00e0\u0003"+ - "\u001b\r\u0000\u00de\u00e0\u0003\u001d\u000e\u0000\u00df\u00dd\u0001\u0000"+ - "\u0000\u0000\u00df\u00de\u0001\u0000\u0000\u0000\u00e0\u0014\u0001\u0000"+ - "\u0000\u0000\u00e1\u00e8\u0003%\u0012\u0000\u00e2\u00e8\u0003\'\u0013"+ - "\u0000\u00e3\u00e8\u0003)\u0014\u0000\u00e4\u00e8\u0003+\u0015\u0000\u00e5"+ - "\u00e8\u0003-\u0016\u0000\u00e6\u00e8\u0003/\u0017\u0000\u00e7\u00e1\u0001"+ - "\u0000\u0000\u0000\u00e7\u00e2\u0001\u0000\u0000\u0000\u00e7\u00e3\u0001"+ - "\u0000\u0000\u0000\u00e7\u00e4\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001"+ - "\u0000\u0000\u0000\u00e7\u00e6\u0001\u0000\u0000\u0000\u00e8\u0016\u0001"+ - "\u0000\u0000\u0000\u00e9\u00ec\u00033\u0019\u0000\u00ea\u00ec\u00035\u001a"+ - "\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb\u00ea\u0001\u0000\u0000"+ - "\u0000\u00ec\u0018\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005=\u0000\u0000"+ - "\u00ee\u001a\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005+\u0000\u0000\u00f0"+ - "\u001c\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005-\u0000\u0000\u00f2\u001e"+ - "\u0001\u0000\u0000\u0000\u00f3\u00f4\u0005*\u0000\u0000\u00f4 \u0001\u0000"+ - "\u0000\u0000\u00f5\u00f6\u0005%\u0000\u0000\u00f6\"\u0001\u0000\u0000"+ - "\u0000\u00f7\u00f8\u0005/\u0000\u0000\u00f8$\u0001\u0000\u0000\u0000\u00f9"+ - "\u00fa\u0005>\u0000\u0000\u00fa&\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005"+ - "<\u0000\u0000\u00fc(\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005>\u0000"+ - "\u0000\u00fe\u00ff\u0005=\u0000\u0000\u00ff*\u0001\u0000\u0000\u0000\u0100"+ - "\u0101\u0005<\u0000\u0000\u0101\u0102\u0005=\u0000\u0000\u0102,\u0001"+ - "\u0000\u0000\u0000\u0103\u0104\u0005=\u0000\u0000\u0104\u0105\u0005=\u0000"+ - "\u0000\u0105.\u0001\u0000\u0000\u0000\u0106\u0107\u0005!\u0000\u0000\u0107"+ - "\u0108\u0005=\u0000\u0000\u01080\u0001\u0000\u0000\u0000\u0109\u010a\u0005"+ - "!\u0000\u0000\u010a2\u0001\u0000\u0000\u0000\u010b\u010c\u0005&\u0000"+ - "\u0000\u010c\u010d\u0005&\u0000\u0000\u010d4\u0001\u0000\u0000\u0000\u010e"+ - "\u010f\u0005|\u0000\u0000\u010f\u0110\u0005|\u0000\u0000\u01106\u0001"+ - "\u0000\u0000\u0000\u0111\u0112\u0005.\u0000\u0000\u01128\u0001\u0000\u0000"+ - "\u0000\u0113\u0114\u0005(\u0000\u0000\u0114:\u0001\u0000\u0000\u0000\u0115"+ - "\u0116\u0005)\u0000\u0000\u0116<\u0001\u0000\u0000\u0000\u0117\u0118\u0005"+ - "{\u0000\u0000\u0118>\u0001\u0000\u0000\u0000\u0119\u011a\u0005}\u0000"+ - "\u0000\u011a@\u0001\u0000\u0000\u0000\u011b\u011c\u0005;\u0000\u0000\u011c"+ - "B\u0001\u0000\u0000\u0000\u011d\u011e\u0005,\u0000\u0000\u011eD\u0001"+ - "\u0000\u0000\u0000\u011f\u0120\u0005c\u0000\u0000\u0120\u0121\u0005l\u0000"+ - "\u0000\u0121\u0122\u0005a\u0000\u0000\u0122\u0123\u0005s\u0000\u0000\u0123"+ - "\u0124\u0005s\u0000\u0000\u0124F\u0001\u0000\u0000\u0000\u0125\u0126\u0005"+ - "t\u0000\u0000\u0126\u0127\u0005h\u0000\u0000\u0127\u0128\u0005i\u0000"+ - "\u0000\u0128\u0129\u0005s\u0000\u0000\u0129H\u0001\u0000\u0000\u0000\u012a"+ - "\u012b\u0005w\u0000\u0000\u012b\u012c\u0005h\u0000\u0000\u012c\u012d\u0005"+ - "i\u0000\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005e\u0000"+ - "\u0000\u012fJ\u0001\u0000\u0000\u0000\u0130\u0131\u0005i\u0000\u0000\u0131"+ - "\u0132\u0005f\u0000\u0000\u0132L\u0001\u0000\u0000\u0000\u0133\u0134\u0005"+ - "e\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136\u0005s\u0000"+ - "\u0000\u0136\u0137\u0005e\u0000\u0000\u0137N\u0001\u0000\u0000\u0000\u0138"+ - "\u0139\u0005f\u0000\u0000\u0139\u013a\u0005o\u0000\u0000\u013a\u013b\u0005"+ - "r\u0000\u0000\u013bP\u0001\u0000\u0000\u0000\u013c\u013d\u0005r\u0000"+ - "\u0000\u013d\u013e\u0005e\u0000\u0000\u013e\u013f\u0005t\u0000\u0000\u013f"+ - "\u0140\u0005u\u0000\u0000\u0140\u0141\u0005r\u0000\u0000\u0141\u0142\u0005"+ - "n\u0000\u0000\u0142R\u0001\u0000\u0000\u0000\u0143\u0144\u0005n\u0000"+ - "\u0000\u0144\u0145\u0005e\u0000\u0000\u0145\u0146\u0005w\u0000\u0000\u0146"+ - "T\u0001\u0000\u0000\u0000\u0147\u014b\u0005\'\u0000\u0000\u0148\u014a"+ - "\b\u0000\u0000\u0000\u0149\u0148\u0001\u0000\u0000\u0000\u014a\u014d\u0001"+ - "\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000\u014b\u014c\u0001"+ - "\u0000\u0000\u0000\u014c\u014e\u0001\u0000\u0000\u0000\u014d\u014b\u0001"+ - "\u0000\u0000\u0000\u014e\u014f\u0005\'\u0000\u0000\u014fV\u0001\u0000"+ - "\u0000\u0000\u0150\u0152\u0003\u001d\u000e\u0000\u0151\u0150\u0001\u0000"+ - "\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u0154\u0001\u0000"+ - "\u0000\u0000\u0153\u0155\u0003_/\u0000\u0154\u0153\u0001\u0000\u0000\u0000"+ - "\u0155\u0156\u0001\u0000\u0000\u0000\u0156\u0154\u0001\u0000\u0000\u0000"+ - "\u0156\u0157\u0001\u0000\u0000\u0000\u0157X\u0001\u0000\u0000\u0000\u0158"+ - "\u0159\u0005t\u0000\u0000\u0159\u015a\u0005r\u0000\u0000\u015a\u015b\u0005"+ - "u\u0000\u0000\u015b\u0162\u0005e\u0000\u0000\u015c\u015d\u0005f\u0000"+ - "\u0000\u015d\u015e\u0005a\u0000\u0000\u015e\u015f\u0005l\u0000\u0000\u015f"+ - "\u0160\u0005s\u0000\u0000\u0160\u0162\u0005e\u0000\u0000\u0161\u0158\u0001"+ - "\u0000\u0000\u0000\u0161\u015c\u0001\u0000\u0000\u0000\u0162Z\u0001\u0000"+ - "\u0000\u0000\u0163\u0164\u0005n\u0000\u0000\u0164\u0165\u0005u\u0000\u0000"+ - "\u0165\u0166\u0005l\u0000\u0000\u0166\u0167\u0005l\u0000\u0000\u0167\\"+ - "\u0001\u0000\u0000\u0000\u0168\u0169\u0007\u0001\u0000\u0000\u0169^\u0001"+ - "\u0000\u0000\u0000\u016a\u016b\u0007\u0002\u0000\u0000\u016b`\u0001\u0000"+ - "\u0000\u0000\u016c\u0170\u0003].\u0000\u016d\u0170\u0003_/\u0000\u016e"+ - "\u0170\u0007\u0003\u0000\u0000\u016f\u016c\u0001\u0000\u0000\u0000\u016f"+ - "\u016d\u0001\u0000\u0000\u0000\u016f\u016e\u0001\u0000\u0000\u0000\u0170"+ - "b\u0001\u0000\u0000\u0000\u0171\u0175\u0003].\u0000\u0172\u0174\u0003"+ - "a0\u0000\u0173\u0172\u0001\u0000\u0000\u0000\u0174\u0177\u0001\u0000\u0000"+ - "\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0176\u0001\u0000\u0000"+ - "\u0000\u0176d\u0001\u0000\u0000\u0000\u0177\u0175\u0001\u0000\u0000\u0000"+ - "\u0178\u017a\u0007\u0004\u0000\u0000\u0179\u0178\u0001\u0000\u0000\u0000"+ - "\u017a\u017b\u0001\u0000\u0000\u0000\u017b\u0179\u0001\u0000\u0000\u0000"+ - "\u017b\u017c\u0001\u0000\u0000\u0000\u017c\u017d\u0001\u0000\u0000\u0000"+ - "\u017d\u017e\u00062\u0000\u0000\u017ef\u0001\u0000\u0000\u0000\u017f\u0180"+ - "\u0005/\u0000\u0000\u0180\u0181\u0005/\u0000\u0000\u0181\u0185\u0001\u0000"+ - "\u0000\u0000\u0182\u0184\b\u0000\u0000\u0000\u0183\u0182\u0001\u0000\u0000"+ - "\u0000\u0184\u0187\u0001\u0000\u0000\u0000\u0185\u0183\u0001\u0000\u0000"+ - "\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0188\u0001\u0000\u0000"+ - "\u0000\u0187\u0185\u0001\u0000\u0000\u0000\u0188\u0189\u00063\u0000\u0000"+ - "\u0189h\u0001\u0000\u0000\u0000\u018a\u018b\u0005/\u0000\u0000\u018b\u018c"+ - "\u0005*\u0000\u0000\u018c\u0190\u0001\u0000\u0000\u0000\u018d\u018f\t"+ - "\u0000\u0000\u0000\u018e\u018d\u0001\u0000\u0000\u0000\u018f\u0192\u0001"+ - "\u0000\u0000\u0000\u0190\u0191\u0001\u0000\u0000\u0000\u0190\u018e\u0001"+ - "\u0000\u0000\u0000\u0191\u0193\u0001\u0000\u0000\u0000\u0192\u0190\u0001"+ - "\u0000\u0000\u0000\u0193\u0194\u0005*\u0000\u0000\u0194\u0195\u0005/\u0000"+ - "\u0000\u0195\u0196\u0001\u0000\u0000\u0000\u0196\u0197\u00064\u0000\u0000"+ - "\u0197j\u0001\u0000\u0000\u0000\u000f\u0000\u00af\u00db\u00df\u00e7\u00eb"+ - "\u014b\u0151\u0156\u0161\u016f\u0175\u017b\u0185\u0190\u0001\u0006\u0000"+ - "\u0000"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.tokens b/src/main/java/parser/generated/SimpleJavaLexer.tokens deleted file mode 100644 index bed7437..0000000 --- a/src/main/java/parser/generated/SimpleJavaLexer.tokens +++ /dev/null @@ -1,88 +0,0 @@ -T__0=1 -T__1=2 -Void=3 -Boolean=4 -Char=5 -Int=6 -AccessModifier=7 -MainMethodDeclaration=8 -DotOperator=9 -LineOperator=10 -ComparisonOperator=11 -LogicalOperator=12 -Assign=13 -Plus=14 -Minus=15 -Mult=16 -Modulo=17 -Div=18 -Greater=19 -Less=20 -GreaterEqual=21 -LessEqual=22 -Equal=23 -NotEqual=24 -Not=25 -And=26 -Or=27 -Dot=28 -OpenRoundBracket=29 -ClosedRoundBracket=30 -OpenCurlyBracket=31 -ClosedCurlyBracket=32 -Semicolon=33 -Comma=34 -Class=35 -This=36 -While=37 -If=38 -Else=39 -For=40 -Return=41 -New=42 -CharValue=43 -IntValue=44 -BooleanValue=45 -NullValue=46 -Identifier=47 -WS=48 -InlineComment=49 -MultilineComment=50 -'++'=1 -'--'=2 -'void'=3 -'boolean'=4 -'char'=5 -'int'=6 -'public static void main(String[] args)'=8 -'='=13 -'+'=14 -'-'=15 -'*'=16 -'%'=17 -'/'=18 -'>'=19 -'<'=20 -'>='=21 -'<='=22 -'=='=23 -'!='=24 -'!'=25 -'&&'=26 -'||'=27 -'.'=28 -'('=29 -')'=30 -'{'=31 -'}'=32 -';'=33 -','=34 -'class'=35 -'this'=36 -'while'=37 -'if'=38 -'else'=39 -'for'=40 -'return'=41 -'new'=42 -'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaListener.java b/src/main/java/parser/generated/SimpleJavaListener.java deleted file mode 100644 index 7b22466..0000000 --- a/src/main/java/parser/generated/SimpleJavaListener.java +++ /dev/null @@ -1,450 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 -package parser.generated; -import org.antlr.v4.runtime.tree.ParseTreeListener; - -/** - * This interface defines a complete listener for a parse tree produced by - * {@link SimpleJavaParser}. - */ -public interface SimpleJavaListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link SimpleJavaParser#program}. - * @param ctx the parse tree - */ - void enterProgram(SimpleJavaParser.ProgramContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#program}. - * @param ctx the parse tree - */ - void exitProgram(SimpleJavaParser.ProgramContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#classDeclaration}. - * @param ctx the parse tree - */ - void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#classDeclaration}. - * @param ctx the parse tree - */ - void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. - * @param ctx the parse tree - */ - void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. - * @param ctx the parse tree - */ - void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. - * @param ctx the parse tree - */ - void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}. - * @param ctx the parse tree - */ - void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. - * @param ctx the parse tree - */ - void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. - * @param ctx the parse tree - */ - void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#parameterList}. - * @param ctx the parse tree - */ - void enterParameterList(SimpleJavaParser.ParameterListContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#parameterList}. - * @param ctx the parse tree - */ - void exitParameterList(SimpleJavaParser.ParameterListContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#parameter}. - * @param ctx the parse tree - */ - void enterParameter(SimpleJavaParser.ParameterContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#parameter}. - * @param ctx the parse tree - */ - void exitParameter(SimpleJavaParser.ParameterContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#argumentList}. - * @param ctx the parse tree - */ - void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#argumentList}. - * @param ctx the parse tree - */ - void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#statement}. - * @param ctx the parse tree - */ - void enterStatement(SimpleJavaParser.StatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#statement}. - * @param ctx the parse tree - */ - void exitStatement(SimpleJavaParser.StatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#block}. - * @param ctx the parse tree - */ - void enterBlock(SimpleJavaParser.BlockContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#block}. - * @param ctx the parse tree - */ - void exitBlock(SimpleJavaParser.BlockContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}. - * @param ctx the parse tree - */ - void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#returnStatement}. - * @param ctx the parse tree - */ - void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. - * @param ctx the parse tree - */ - void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. - * @param ctx the parse tree - */ - void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - */ - void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - */ - void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#forStatement}. - * @param ctx the parse tree - */ - void enterForStatement(SimpleJavaParser.ForStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#forStatement}. - * @param ctx the parse tree - */ - void exitForStatement(SimpleJavaParser.ForStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. - * @param ctx the parse tree - */ - void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. - * @param ctx the parse tree - */ - void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - */ - void enterIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - */ - void exitIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#elseStatement}. - * @param ctx the parse tree - */ - void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#elseStatement}. - * @param ctx the parse tree - */ - void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#statementExpression}. - * @param ctx the parse tree - */ - void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#statementExpression}. - * @param ctx the parse tree - */ - void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#assign}. - * @param ctx the parse tree - */ - void enterAssign(SimpleJavaParser.AssignContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#assign}. - * @param ctx the parse tree - */ - void exitAssign(SimpleJavaParser.AssignContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#newDeclaration}. - * @param ctx the parse tree - */ - void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. - * @param ctx the parse tree - */ - void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#expression}. - * @param ctx the parse tree - */ - void enterExpression(SimpleJavaParser.ExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#expression}. - * @param ctx the parse tree - */ - void exitExpression(SimpleJavaParser.ExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#unaryExpression}. - * @param ctx the parse tree - */ - void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. - * @param ctx the parse tree - */ - void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#notExpression}. - * @param ctx the parse tree - */ - void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#notExpression}. - * @param ctx the parse tree - */ - void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#crementExpression}. - * @param ctx the parse tree - */ - void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#crementExpression}. - * @param ctx the parse tree - */ - void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#incrementExpression}. - * @param ctx the parse tree - */ - void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. - * @param ctx the parse tree - */ - void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. - * @param ctx the parse tree - */ - void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. - * @param ctx the parse tree - */ - void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. - * @param ctx the parse tree - */ - void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. - * @param ctx the parse tree - */ - void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#decrementExpression}. - * @param ctx the parse tree - */ - void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. - * @param ctx the parse tree - */ - void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. - * @param ctx the parse tree - */ - void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. - * @param ctx the parse tree - */ - void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. - * @param ctx the parse tree - */ - void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. - * @param ctx the parse tree - */ - void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#assignableExpression}. - * @param ctx the parse tree - */ - void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. - * @param ctx the parse tree - */ - void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#memberAccess}. - * @param ctx the parse tree - */ - void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#memberAccess}. - * @param ctx the parse tree - */ - void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#binaryExpression}. - * @param ctx the parse tree - */ - void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. - * @param ctx the parse tree - */ - void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#calculationExpression}. - * @param ctx the parse tree - */ - void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. - * @param ctx the parse tree - */ - void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#dotExpression}. - * @param ctx the parse tree - */ - void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#dotExpression}. - * @param ctx the parse tree - */ - void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. - * @param ctx the parse tree - */ - void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. - * @param ctx the parse tree - */ - void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. - * @param ctx the parse tree - */ - void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. - * @param ctx the parse tree - */ - void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#methodCall}. - * @param ctx the parse tree - */ - void enterMethodCall(SimpleJavaParser.MethodCallContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#methodCall}. - * @param ctx the parse tree - */ - void exitMethodCall(SimpleJavaParser.MethodCallContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#target}. - * @param ctx the parse tree - */ - void enterTarget(SimpleJavaParser.TargetContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#target}. - * @param ctx the parse tree - */ - void exitTarget(SimpleJavaParser.TargetContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#chainedMethod}. - * @param ctx the parse tree - */ - void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. - * @param ctx the parse tree - */ - void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#type}. - * @param ctx the parse tree - */ - void enterType(SimpleJavaParser.TypeContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#type}. - * @param ctx the parse tree - */ - void exitType(SimpleJavaParser.TypeContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#value}. - * @param ctx the parse tree - */ - void enterValue(SimpleJavaParser.ValueContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#value}. - * @param ctx the parse tree - */ - void exitValue(SimpleJavaParser.ValueContext ctx); - /** - * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. - * @param ctx the parse tree - */ - void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); - /** - * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. - * @param ctx the parse tree - */ - void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); -} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaParser.java b/src/main/java/parser/generated/SimpleJavaParser.java deleted file mode 100644 index 3d93b3e..0000000 --- a/src/main/java/parser/generated/SimpleJavaParser.java +++ /dev/null @@ -1,3447 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/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 { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, - DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, - Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, - Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, - And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, - ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, - If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, - BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, - MultilineComment=50; - public static final int - RULE_program = 0, RULE_classDeclaration = 1, RULE_memberDeclaration = 2, - RULE_constructorDeclaration = 3, RULE_fieldDeclaration = 4, RULE_methodDeclaration = 5, - RULE_parameterList = 6, RULE_parameter = 7, RULE_argumentList = 8, RULE_statement = 9, - RULE_block = 10, RULE_returnStatement = 11, RULE_localVariableDeclaration = 12, - RULE_whileStatement = 13, RULE_forStatement = 14, RULE_ifElseStatement = 15, - RULE_ifStatement = 16, RULE_elseStatement = 17, RULE_statementExpression = 18, - RULE_assign = 19, RULE_newDeclaration = 20, RULE_expression = 21, RULE_unaryExpression = 22, - RULE_notExpression = 23, RULE_crementExpression = 24, RULE_incrementExpression = 25, - RULE_prefixIncrementExpression = 26, RULE_suffixIncrementExpression = 27, - RULE_decrementExpression = 28, RULE_prefixDecrementExpression = 29, RULE_suffixDecrementExpression = 30, - RULE_assignableExpression = 31, RULE_memberAccess = 32, RULE_binaryExpression = 33, - RULE_calculationExpression = 34, RULE_dotExpression = 35, RULE_dotSubtractionExpression = 36, - RULE_nonCalculationExpression = 37, RULE_methodCall = 38, RULE_target = 39, - RULE_chainedMethod = 40, RULE_type = 41, RULE_value = 42, RULE_nonCalculationOperator = 43; - private static String[] makeRuleNames() { - return new String[] { - "program", "classDeclaration", "memberDeclaration", "constructorDeclaration", - "fieldDeclaration", "methodDeclaration", "parameterList", "parameter", - "argumentList", "statement", "block", "returnStatement", "localVariableDeclaration", - "whileStatement", "forStatement", "ifElseStatement", "ifStatement", "elseStatement", - "statementExpression", "assign", "newDeclaration", "expression", "unaryExpression", - "notExpression", "crementExpression", "incrementExpression", "prefixIncrementExpression", - "suffixIncrementExpression", "decrementExpression", "prefixDecrementExpression", - "suffixDecrementExpression", "assignableExpression", "memberAccess", - "binaryExpression", "calculationExpression", "dotExpression", "dotSubtractionExpression", - "nonCalculationExpression", "methodCall", "target", "chainedMethod", - "type", "value", "nonCalculationOperator" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, - "'public static void main(String[] args)'", null, null, null, null, "'='", - "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", - "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", - "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", - "'new'", null, null, null, "'null'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", - "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", - "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", - "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", - "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", - "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", - "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", - "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "SimpleJava.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public SimpleJavaParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @SuppressWarnings("CheckReturnValue") - public static class ProgramContext extends ParserRuleContext { - public List classDeclaration() { - return getRuleContexts(ClassDeclarationContext.class); - } - public ClassDeclarationContext classDeclaration(int i) { - return getRuleContext(ClassDeclarationContext.class,i); - } - public ProgramContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_program; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterProgram(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitProgram(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitProgram(this); - else return visitor.visitChildren(this); - } - } - - public final ProgramContext program() throws RecognitionException { - ProgramContext _localctx = new ProgramContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_program); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(89); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(88); - classDeclaration(); - } - } - setState(91); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==AccessModifier || _la==Class ); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ClassDeclarationContext extends ParserRuleContext { - public TerminalNode Class() { return getToken(SimpleJavaParser.Class, 0); } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } - public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } - public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } - public List memberDeclaration() { - return getRuleContexts(MemberDeclarationContext.class); - } - public MemberDeclarationContext memberDeclaration(int i) { - return getRuleContext(MemberDeclarationContext.class,i); - } - public ClassDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_classDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterClassDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitClassDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitClassDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ClassDeclarationContext classDeclaration() throws RecognitionException { - ClassDeclarationContext _localctx = new ClassDeclarationContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_classDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(94); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifier) { - { - setState(93); - match(AccessModifier); - } - } - - setState(96); - match(Class); - setState(97); - match(Identifier); - setState(98); - match(OpenCurlyBracket); - setState(102); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355832L) != 0)) { - { - { - setState(99); - memberDeclaration(); - } - } - setState(104); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(105); - match(ClosedCurlyBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MemberDeclarationContext extends ParserRuleContext { - public ConstructorDeclarationContext constructorDeclaration() { - return getRuleContext(ConstructorDeclarationContext.class,0); - } - public FieldDeclarationContext fieldDeclaration() { - return getRuleContext(FieldDeclarationContext.class,0); - } - public MethodDeclarationContext methodDeclaration() { - return getRuleContext(MethodDeclarationContext.class,0); - } - public MemberDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_memberDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMemberDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMemberDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMemberDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final MemberDeclarationContext memberDeclaration() throws RecognitionException { - MemberDeclarationContext _localctx = new MemberDeclarationContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_memberDeclaration); - try { - setState(110); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(107); - constructorDeclaration(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(108); - fieldDeclaration(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(109); - methodDeclaration(); - } - break; - } - } - 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 TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } - public ParameterListContext parameterList() { - return getRuleContext(ParameterListContext.class,0); - } - 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 visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitConstructorDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException { - ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_constructorDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(113); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifier) { - { - setState(112); - match(AccessModifier); - } - } - - setState(115); - match(Identifier); - setState(116); - match(OpenRoundBracket); - setState(118); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { - { - setState(117); - parameterList(); - } - } - - setState(120); - match(ClosedRoundBracket); - setState(121); - block(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class FieldDeclarationContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } - public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } - public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterFieldDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitFieldDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitFieldDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { - FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_fieldDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(124); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifier) { - { - setState(123); - match(AccessModifier); - } - } - - setState(126); - type(); - setState(127); - match(Identifier); - setState(128); - match(Semicolon); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MethodDeclarationContext extends ParserRuleContext { - public TerminalNode MainMethodDeclaration() { return getToken(SimpleJavaParser.MainMethodDeclaration, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Void() { return getToken(SimpleJavaParser.Void, 0); } - public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } - public ParameterListContext parameterList() { - return getRuleContext(ParameterListContext.class,0); - } - public MethodDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_methodDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final MethodDeclarationContext methodDeclaration() throws RecognitionException { - MethodDeclarationContext _localctx = new MethodDeclarationContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_methodDeclaration); - int _la; - try { - setState(146); - _errHandler.sync(this); - switch (_input.LA(1)) { - case MainMethodDeclaration: - enterOuterAlt(_localctx, 1); - { - setState(130); - match(MainMethodDeclaration); - setState(131); - block(); - } - break; - case Void: - case Boolean: - case Char: - case Int: - case AccessModifier: - case Identifier: - enterOuterAlt(_localctx, 2); - { - setState(133); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifier) { - { - setState(132); - match(AccessModifier); - } - } - - setState(137); - _errHandler.sync(this); - switch (_input.LA(1)) { - case Boolean: - case Char: - case Int: - case Identifier: - { - setState(135); - type(); - } - break; - case Void: - { - setState(136); - match(Void); - } - break; - default: - throw new NoViableAltException(this); - } - setState(139); - match(Identifier); - setState(140); - match(OpenRoundBracket); - setState(142); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { - { - setState(141); - parameterList(); - } - } - - setState(144); - match(ClosedRoundBracket); - setState(145); - block(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ParameterListContext extends ParserRuleContext { - public List parameter() { - return getRuleContexts(ParameterContext.class); - } - public ParameterContext parameter(int i) { - return getRuleContext(ParameterContext.class,i); - } - public List Comma() { return getTokens(SimpleJavaParser.Comma); } - public TerminalNode Comma(int i) { - return getToken(SimpleJavaParser.Comma, i); - } - public ParameterListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameterList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterParameterList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitParameterList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitParameterList(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterListContext parameterList() throws RecognitionException { - ParameterListContext _localctx = new ParameterListContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_parameterList); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(148); - parameter(); - setState(153); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==Comma) { - { - { - setState(149); - match(Comma); - setState(150); - parameter(); - } - } - setState(155); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ParameterContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public ParameterContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameter; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterParameter(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitParameter(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitParameter(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterContext parameter() throws RecognitionException { - ParameterContext _localctx = new ParameterContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_parameter); - try { - enterOuterAlt(_localctx, 1); - { - setState(156); - type(); - setState(157); - match(Identifier); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ArgumentListContext extends ParserRuleContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public List Comma() { return getTokens(SimpleJavaParser.Comma); } - public TerminalNode Comma(int i) { - return getToken(SimpleJavaParser.Comma, i); - } - public ArgumentListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_argumentList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterArgumentList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitArgumentList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitArgumentList(this); - else return visitor.visitChildren(this); - } - } - - public final ArgumentListContext argumentList() throws RecognitionException { - ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_argumentList); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(167); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { - { - setState(159); - expression(); - setState(164); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==Comma) { - { - { - setState(160); - match(Comma); - setState(161); - expression(); - } - } - setState(166); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class StatementContext extends ParserRuleContext { - public ReturnStatementContext returnStatement() { - return getRuleContext(ReturnStatementContext.class,0); - } - public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } - public LocalVariableDeclarationContext localVariableDeclaration() { - return getRuleContext(LocalVariableDeclarationContext.class,0); - } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public WhileStatementContext whileStatement() { - return getRuleContext(WhileStatementContext.class,0); - } - public ForStatementContext forStatement() { - return getRuleContext(ForStatementContext.class,0); - } - public IfElseStatementContext ifElseStatement() { - return getRuleContext(IfElseStatementContext.class,0); - } - public StatementExpressionContext statementExpression() { - return getRuleContext(StatementExpressionContext.class,0); - } - public StatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_statement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitStatement(this); - else return visitor.visitChildren(this); - } - } - - public final StatementContext statement() throws RecognitionException { - StatementContext _localctx = new StatementContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_statement); - try { - setState(182); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(169); - returnStatement(); - setState(170); - match(Semicolon); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(172); - localVariableDeclaration(); - setState(173); - match(Semicolon); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(175); - block(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(176); - whileStatement(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(177); - forStatement(); - } - break; - case 6: - enterOuterAlt(_localctx, 6); - { - setState(178); - ifElseStatement(); - } - break; - case 7: - enterOuterAlt(_localctx, 7); - { - setState(179); - statementExpression(); - setState(180); - match(Semicolon); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class BlockContext extends ParserRuleContext { - public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } - public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } - public List statement() { - return getRuleContexts(StatementContext.class); - } - public StatementContext statement(int i) { - return getRuleContext(StatementContext.class,i); - } - public BlockContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_block; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBlock(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBlock(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBlock(this); - else return visitor.visitChildren(this); - } - } - - public final BlockContext block() throws RecognitionException { - BlockContext _localctx = new BlockContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_block); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(184); - match(OpenCurlyBracket); - setState(188); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 148917253570678L) != 0)) { - { - { - setState(185); - statement(); - } - } - setState(190); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(191); - match(ClosedCurlyBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReturnStatementContext extends ParserRuleContext { - public TerminalNode Return() { return getToken(SimpleJavaParser.Return, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ReturnStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_returnStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterReturnStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitReturnStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitReturnStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ReturnStatementContext returnStatement() throws RecognitionException { - ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_returnStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(193); - match(Return); - setState(195); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { - { - setState(194); - expression(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class LocalVariableDeclarationContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public LocalVariableDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_localVariableDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterLocalVariableDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitLocalVariableDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitLocalVariableDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final LocalVariableDeclarationContext localVariableDeclaration() throws RecognitionException { - LocalVariableDeclarationContext _localctx = new LocalVariableDeclarationContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_localVariableDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(197); - type(); - setState(198); - match(Identifier); - setState(201); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==Assign) { - { - setState(199); - match(Assign); - setState(200); - expression(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class WhileStatementContext extends ParserRuleContext { - public TerminalNode While() { return getToken(SimpleJavaParser.While, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public WhileStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_whileStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterWhileStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitWhileStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitWhileStatement(this); - else return visitor.visitChildren(this); - } - } - - public final WhileStatementContext whileStatement() throws RecognitionException { - WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_whileStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(203); - match(While); - setState(204); - match(OpenRoundBracket); - setState(205); - expression(); - setState(206); - match(ClosedRoundBracket); - setState(207); - block(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ForStatementContext extends ParserRuleContext { - public TerminalNode For() { return getToken(SimpleJavaParser.For, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public List Semicolon() { return getTokens(SimpleJavaParser.Semicolon); } - public TerminalNode Semicolon(int i) { - return getToken(SimpleJavaParser.Semicolon, i); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public List statementExpression() { - return getRuleContexts(StatementExpressionContext.class); - } - public StatementExpressionContext statementExpression(int i) { - return getRuleContext(StatementExpressionContext.class,i); - } - public LocalVariableDeclarationContext localVariableDeclaration() { - return getRuleContext(LocalVariableDeclarationContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ForStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_forStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterForStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitForStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitForStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ForStatementContext forStatement() throws RecognitionException { - ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_forStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(209); - match(For); - setState(210); - match(OpenRoundBracket); - setState(213); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) { - case 1: - { - setState(211); - statementExpression(); - } - break; - case 2: - { - setState(212); - localVariableDeclaration(); - } - break; - } - setState(215); - match(Semicolon); - setState(217); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { - { - setState(216); - expression(); - } - } - - setState(219); - match(Semicolon); - setState(221); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 145204254343174L) != 0)) { - { - setState(220); - statementExpression(); - } - } - - setState(223); - match(ClosedRoundBracket); - setState(224); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IfElseStatementContext extends ParserRuleContext { - public IfStatementContext ifStatement() { - return getRuleContext(IfStatementContext.class,0); - } - public ElseStatementContext elseStatement() { - return getRuleContext(ElseStatementContext.class,0); - } - public IfElseStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifElseStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfElseStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfElseStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfElseStatement(this); - else return visitor.visitChildren(this); - } - } - - public final IfElseStatementContext ifElseStatement() throws RecognitionException { - IfElseStatementContext _localctx = new IfElseStatementContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_ifElseStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(226); - ifStatement(); - setState(228); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { - case 1: - { - setState(227); - elseStatement(); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IfStatementContext extends ParserRuleContext { - public TerminalNode If() { return getToken(SimpleJavaParser.If, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public IfStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfStatement(this); - else return visitor.visitChildren(this); - } - } - - public final IfStatementContext ifStatement() throws RecognitionException { - IfStatementContext _localctx = new IfStatementContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_ifStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(230); - match(If); - setState(231); - match(OpenRoundBracket); - setState(232); - expression(); - setState(233); - match(ClosedRoundBracket); - setState(234); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ElseStatementContext extends ParserRuleContext { - public TerminalNode Else() { return getToken(SimpleJavaParser.Else, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public ElseStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_elseStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterElseStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitElseStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitElseStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ElseStatementContext elseStatement() throws RecognitionException { - ElseStatementContext _localctx = new ElseStatementContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_elseStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(236); - match(Else); - setState(237); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class StatementExpressionContext extends ParserRuleContext { - public AssignContext assign() { - return getRuleContext(AssignContext.class,0); - } - public NewDeclarationContext newDeclaration() { - return getRuleContext(NewDeclarationContext.class,0); - } - public MethodCallContext methodCall() { - return getRuleContext(MethodCallContext.class,0); - } - public CrementExpressionContext crementExpression() { - return getRuleContext(CrementExpressionContext.class,0); - } - public StatementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_statementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterStatementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitStatementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitStatementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final StatementExpressionContext statementExpression() throws RecognitionException { - StatementExpressionContext _localctx = new StatementExpressionContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_statementExpression); - try { - setState(243); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(239); - assign(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(240); - newDeclaration(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(241); - methodCall(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(242); - crementExpression(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AssignContext extends ParserRuleContext { - public AssignableExpressionContext assignableExpression() { - return getRuleContext(AssignableExpressionContext.class,0); - } - public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public AssignContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assign; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssign(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssign(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssign(this); - else return visitor.visitChildren(this); - } - } - - public final AssignContext assign() throws RecognitionException { - AssignContext _localctx = new AssignContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_assign); - try { - enterOuterAlt(_localctx, 1); - { - setState(245); - assignableExpression(); - setState(246); - match(Assign); - setState(247); - expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NewDeclarationContext extends ParserRuleContext { - public TerminalNode New() { return getToken(SimpleJavaParser.New, 0); } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public NewDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_newDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNewDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNewDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNewDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final NewDeclarationContext newDeclaration() throws RecognitionException { - NewDeclarationContext _localctx = new NewDeclarationContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_newDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(249); - match(New); - setState(250); - match(Identifier); - setState(251); - match(OpenRoundBracket); - setState(252); - argumentList(); - setState(253); - match(ClosedRoundBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ExpressionContext extends ParserRuleContext { - public UnaryExpressionContext unaryExpression() { - return getRuleContext(UnaryExpressionContext.class,0); - } - public BinaryExpressionContext binaryExpression() { - return getRuleContext(BinaryExpressionContext.class,0); - } - public ExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitExpression(this); - else return visitor.visitChildren(this); - } - } - - public final ExpressionContext expression() throws RecognitionException { - ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_expression); - try { - setState(257); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(255); - unaryExpression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(256); - binaryExpression(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class UnaryExpressionContext extends ParserRuleContext { - public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public MemberAccessContext memberAccess() { - return getRuleContext(MemberAccessContext.class,0); - } - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public NotExpressionContext notExpression() { - return getRuleContext(NotExpressionContext.class,0); - } - public StatementExpressionContext statementExpression() { - return getRuleContext(StatementExpressionContext.class,0); - } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public UnaryExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_unaryExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterUnaryExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitUnaryExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitUnaryExpression(this); - else return visitor.visitChildren(this); - } - } - - public final UnaryExpressionContext unaryExpression() throws RecognitionException { - UnaryExpressionContext _localctx = new UnaryExpressionContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_unaryExpression); - try { - setState(269); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(259); - match(This); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(260); - match(Identifier); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(261); - memberAccess(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(262); - value(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(263); - notExpression(); - } - break; - case 6: - enterOuterAlt(_localctx, 6); - { - setState(264); - statementExpression(); - } - break; - case 7: - enterOuterAlt(_localctx, 7); - { - setState(265); - match(OpenRoundBracket); - setState(266); - expression(); - setState(267); - match(ClosedRoundBracket); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NotExpressionContext extends ParserRuleContext { - public TerminalNode Not() { return getToken(SimpleJavaParser.Not, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public NotExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_notExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNotExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNotExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNotExpression(this); - else return visitor.visitChildren(this); - } - } - - public final NotExpressionContext notExpression() throws RecognitionException { - NotExpressionContext _localctx = new NotExpressionContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_notExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(271); - match(Not); - setState(272); - expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class CrementExpressionContext extends ParserRuleContext { - public IncrementExpressionContext incrementExpression() { - return getRuleContext(IncrementExpressionContext.class,0); - } - public DecrementExpressionContext decrementExpression() { - return getRuleContext(DecrementExpressionContext.class,0); - } - public CrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_crementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final CrementExpressionContext crementExpression() throws RecognitionException { - CrementExpressionContext _localctx = new CrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_crementExpression); - try { - setState(276); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(274); - incrementExpression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(275); - decrementExpression(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IncrementExpressionContext extends ParserRuleContext { - public PrefixIncrementExpressionContext prefixIncrementExpression() { - return getRuleContext(PrefixIncrementExpressionContext.class,0); - } - public SuffixIncrementExpressionContext suffixIncrementExpression() { - return getRuleContext(SuffixIncrementExpressionContext.class,0); - } - public IncrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_incrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIncrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIncrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIncrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final IncrementExpressionContext incrementExpression() throws RecognitionException { - IncrementExpressionContext _localctx = new IncrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_incrementExpression); - try { - setState(280); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__0: - enterOuterAlt(_localctx, 1); - { - setState(278); - prefixIncrementExpression(); - } - break; - case This: - case Identifier: - enterOuterAlt(_localctx, 2); - { - setState(279); - suffixIncrementExpression(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PrefixIncrementExpressionContext extends ParserRuleContext { - public AssignableExpressionContext assignableExpression() { - return getRuleContext(AssignableExpressionContext.class,0); - } - public PrefixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_prefixIncrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixIncrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixIncrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixIncrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final PrefixIncrementExpressionContext prefixIncrementExpression() throws RecognitionException { - PrefixIncrementExpressionContext _localctx = new PrefixIncrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_prefixIncrementExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(282); - match(T__0); - setState(283); - assignableExpression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class SuffixIncrementExpressionContext extends ParserRuleContext { - public AssignableExpressionContext assignableExpression() { - return getRuleContext(AssignableExpressionContext.class,0); - } - public SuffixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_suffixIncrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixIncrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixIncrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixIncrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final SuffixIncrementExpressionContext suffixIncrementExpression() throws RecognitionException { - SuffixIncrementExpressionContext _localctx = new SuffixIncrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 54, RULE_suffixIncrementExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(285); - assignableExpression(); - setState(286); - match(T__0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DecrementExpressionContext extends ParserRuleContext { - public PrefixDecrementExpressionContext prefixDecrementExpression() { - return getRuleContext(PrefixDecrementExpressionContext.class,0); - } - public SuffixDecrementExpressionContext suffixDecrementExpression() { - return getRuleContext(SuffixDecrementExpressionContext.class,0); - } - public DecrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_decrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDecrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDecrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDecrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final DecrementExpressionContext decrementExpression() throws RecognitionException { - DecrementExpressionContext _localctx = new DecrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 56, RULE_decrementExpression); - try { - setState(290); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__1: - enterOuterAlt(_localctx, 1); - { - setState(288); - prefixDecrementExpression(); - } - break; - case This: - case Identifier: - enterOuterAlt(_localctx, 2); - { - setState(289); - suffixDecrementExpression(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PrefixDecrementExpressionContext extends ParserRuleContext { - public AssignableExpressionContext assignableExpression() { - return getRuleContext(AssignableExpressionContext.class,0); - } - public PrefixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_prefixDecrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixDecrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixDecrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixDecrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final PrefixDecrementExpressionContext prefixDecrementExpression() throws RecognitionException { - PrefixDecrementExpressionContext _localctx = new PrefixDecrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 58, RULE_prefixDecrementExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(292); - match(T__1); - setState(293); - assignableExpression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class SuffixDecrementExpressionContext extends ParserRuleContext { - public AssignableExpressionContext assignableExpression() { - return getRuleContext(AssignableExpressionContext.class,0); - } - public SuffixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_suffixDecrementExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixDecrementExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixDecrementExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixDecrementExpression(this); - else return visitor.visitChildren(this); - } - } - - public final SuffixDecrementExpressionContext suffixDecrementExpression() throws RecognitionException { - SuffixDecrementExpressionContext _localctx = new SuffixDecrementExpressionContext(_ctx, getState()); - enterRule(_localctx, 60, RULE_suffixDecrementExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(295); - assignableExpression(); - setState(296); - match(T__1); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AssignableExpressionContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public MemberAccessContext memberAccess() { - return getRuleContext(MemberAccessContext.class,0); - } - public AssignableExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assignableExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssignableExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssignableExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssignableExpression(this); - else return visitor.visitChildren(this); - } - } - - public final AssignableExpressionContext assignableExpression() throws RecognitionException { - AssignableExpressionContext _localctx = new AssignableExpressionContext(_ctx, getState()); - enterRule(_localctx, 62, RULE_assignableExpression); - try { - setState(300); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(298); - match(Identifier); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(299); - memberAccess(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MemberAccessContext extends ParserRuleContext { - public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } - public List Dot() { return getTokens(SimpleJavaParser.Dot); } - public TerminalNode Dot(int i) { - return getToken(SimpleJavaParser.Dot, i); - } - public List Identifier() { return getTokens(SimpleJavaParser.Identifier); } - public TerminalNode Identifier(int i) { - return getToken(SimpleJavaParser.Identifier, i); - } - public MemberAccessContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_memberAccess; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMemberAccess(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMemberAccess(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMemberAccess(this); - else return visitor.visitChildren(this); - } - } - - public final MemberAccessContext memberAccess() throws RecognitionException { - MemberAccessContext _localctx = new MemberAccessContext(_ctx, getState()); - enterRule(_localctx, 64, RULE_memberAccess); - int _la; - try { - int _alt; - setState(316); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,31,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(302); - match(This); - setState(303); - match(Dot); - setState(304); - match(Identifier); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(307); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==This) { - { - setState(305); - match(This); - setState(306); - match(Dot); - } - } - - setState(311); - _errHandler.sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - setState(309); - match(Identifier); - setState(310); - match(Dot); - } - } - break; - default: - throw new NoViableAltException(this); - } - setState(313); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,30,_ctx); - } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); - setState(315); - match(Identifier); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class BinaryExpressionContext extends ParserRuleContext { - public CalculationExpressionContext calculationExpression() { - return getRuleContext(CalculationExpressionContext.class,0); - } - public NonCalculationExpressionContext nonCalculationExpression() { - return getRuleContext(NonCalculationExpressionContext.class,0); - } - public BinaryExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_binaryExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBinaryExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBinaryExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBinaryExpression(this); - else return visitor.visitChildren(this); - } - } - - public final BinaryExpressionContext binaryExpression() throws RecognitionException { - BinaryExpressionContext _localctx = new BinaryExpressionContext(_ctx, getState()); - enterRule(_localctx, 66, RULE_binaryExpression); - try { - setState(320); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,32,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(318); - calculationExpression(0); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(319); - nonCalculationExpression(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class CalculationExpressionContext extends ParserRuleContext { - public DotExpressionContext dotExpression() { - return getRuleContext(DotExpressionContext.class,0); - } - public CalculationExpressionContext calculationExpression() { - return getRuleContext(CalculationExpressionContext.class,0); - } - public TerminalNode LineOperator() { return getToken(SimpleJavaParser.LineOperator, 0); } - public CalculationExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_calculationExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCalculationExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCalculationExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCalculationExpression(this); - else return visitor.visitChildren(this); - } - } - - public final CalculationExpressionContext calculationExpression() throws RecognitionException { - return calculationExpression(0); - } - - private CalculationExpressionContext calculationExpression(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - CalculationExpressionContext _localctx = new CalculationExpressionContext(_ctx, _parentState); - CalculationExpressionContext _prevctx = _localctx; - int _startState = 68; - enterRecursionRule(_localctx, 68, RULE_calculationExpression, _p); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - { - setState(323); - dotExpression(0); - } - _ctx.stop = _input.LT(-1); - setState(330); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,33,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new CalculationExpressionContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_calculationExpression); - setState(325); - if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(326); - match(LineOperator); - setState(327); - dotExpression(0); - } - } - } - setState(332); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,33,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DotExpressionContext extends ParserRuleContext { - public DotSubtractionExpressionContext dotSubtractionExpression() { - return getRuleContext(DotSubtractionExpressionContext.class,0); - } - public DotExpressionContext dotExpression() { - return getRuleContext(DotExpressionContext.class,0); - } - public TerminalNode DotOperator() { return getToken(SimpleJavaParser.DotOperator, 0); } - public DotExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_dotExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotExpression(this); - else return visitor.visitChildren(this); - } - } - - public final DotExpressionContext dotExpression() throws RecognitionException { - return dotExpression(0); - } - - private DotExpressionContext dotExpression(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - DotExpressionContext _localctx = new DotExpressionContext(_ctx, _parentState); - DotExpressionContext _prevctx = _localctx; - int _startState = 70; - enterRecursionRule(_localctx, 70, RULE_dotExpression, _p); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - { - setState(334); - dotSubtractionExpression(); - } - _ctx.stop = _input.LT(-1); - setState(341); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,34,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new DotExpressionContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_dotExpression); - setState(336); - if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(337); - match(DotOperator); - setState(338); - dotSubtractionExpression(); - } - } - } - setState(343); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,34,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DotSubtractionExpressionContext extends ParserRuleContext { - public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public MemberAccessContext memberAccess() { - return getRuleContext(MemberAccessContext.class,0); - } - public MethodCallContext methodCall() { - return getRuleContext(MethodCallContext.class,0); - } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public CalculationExpressionContext calculationExpression() { - return getRuleContext(CalculationExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public DotSubtractionExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_dotSubtractionExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotSubtractionExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotSubtractionExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotSubtractionExpression(this); - else return visitor.visitChildren(this); - } - } - - public final DotSubtractionExpressionContext dotSubtractionExpression() throws RecognitionException { - DotSubtractionExpressionContext _localctx = new DotSubtractionExpressionContext(_ctx, getState()); - enterRule(_localctx, 72, RULE_dotSubtractionExpression); - try { - setState(352); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,35,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(344); - match(IntValue); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(345); - match(Identifier); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(346); - memberAccess(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(347); - methodCall(); - setState(348); - match(OpenRoundBracket); - setState(349); - calculationExpression(0); - setState(350); - match(ClosedRoundBracket); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NonCalculationExpressionContext extends ParserRuleContext { - public UnaryExpressionContext unaryExpression() { - return getRuleContext(UnaryExpressionContext.class,0); - } - public NonCalculationOperatorContext nonCalculationOperator() { - return getRuleContext(NonCalculationOperatorContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public NonCalculationExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nonCalculationExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationExpression(this); - else return visitor.visitChildren(this); - } - } - - public final NonCalculationExpressionContext nonCalculationExpression() throws RecognitionException { - NonCalculationExpressionContext _localctx = new NonCalculationExpressionContext(_ctx, getState()); - enterRule(_localctx, 74, RULE_nonCalculationExpression); - try { - enterOuterAlt(_localctx, 1); - { - setState(354); - unaryExpression(); - setState(355); - nonCalculationOperator(); - setState(356); - expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MethodCallContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public TargetContext target() { - return getRuleContext(TargetContext.class,0); - } - public List chainedMethod() { - return getRuleContexts(ChainedMethodContext.class); - } - public ChainedMethodContext chainedMethod(int i) { - return getRuleContext(ChainedMethodContext.class,i); - } - public MethodCallContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_methodCall; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodCall(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodCall(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodCall(this); - else return visitor.visitChildren(this); - } - } - - public final MethodCallContext methodCall() throws RecognitionException { - MethodCallContext _localctx = new MethodCallContext(_ctx, getState()); - enterRule(_localctx, 76, RULE_methodCall); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(359); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { - case 1: - { - setState(358); - target(); - } - break; - } - setState(364); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,37,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(361); - chainedMethod(); - } - } - } - setState(366); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,37,_ctx); - } - setState(367); - match(Identifier); - setState(368); - match(OpenRoundBracket); - setState(369); - argumentList(); - setState(370); - match(ClosedRoundBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class TargetContext extends ParserRuleContext { - public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } - public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } - public MemberAccessContext memberAccess() { - return getRuleContext(MemberAccessContext.class,0); - } - public NewDeclarationContext newDeclaration() { - return getRuleContext(NewDeclarationContext.class,0); - } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TargetContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_target; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterTarget(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitTarget(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitTarget(this); - else return visitor.visitChildren(this); - } - } - - public final TargetContext target() throws RecognitionException { - TargetContext _localctx = new TargetContext(_ctx, getState()); - enterRule(_localctx, 78, RULE_target); - try { - enterOuterAlt(_localctx, 1); - { - setState(376); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,38,_ctx) ) { - case 1: - { - setState(372); - match(This); - } - break; - case 2: - { - setState(373); - memberAccess(); - } - break; - case 3: - { - setState(374); - newDeclaration(); - } - break; - case 4: - { - setState(375); - match(Identifier); - } - break; - } - setState(378); - match(Dot); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ChainedMethodContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } - public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } - public ChainedMethodContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_chainedMethod; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterChainedMethod(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitChainedMethod(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitChainedMethod(this); - else return visitor.visitChildren(this); - } - } - - public final ChainedMethodContext chainedMethod() throws RecognitionException { - ChainedMethodContext _localctx = new ChainedMethodContext(_ctx, getState()); - enterRule(_localctx, 80, RULE_chainedMethod); - try { - enterOuterAlt(_localctx, 1); - { - setState(380); - match(Identifier); - setState(381); - match(OpenRoundBracket); - setState(382); - argumentList(); - setState(383); - match(ClosedRoundBracket); - setState(384); - match(Dot); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class TypeContext extends ParserRuleContext { - public TerminalNode Int() { return getToken(SimpleJavaParser.Int, 0); } - public TerminalNode Boolean() { return getToken(SimpleJavaParser.Boolean, 0); } - public TerminalNode Char() { return getToken(SimpleJavaParser.Char, 0); } - public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } - public TypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_type; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitType(this); - else return visitor.visitChildren(this); - } - } - - public final TypeContext type() throws RecognitionException { - TypeContext _localctx = new TypeContext(_ctx, getState()); - enterRule(_localctx, 82, RULE_type); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(386); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValueContext extends ParserRuleContext { - public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } - public TerminalNode BooleanValue() { return getToken(SimpleJavaParser.BooleanValue, 0); } - public TerminalNode CharValue() { return getToken(SimpleJavaParser.CharValue, 0); } - public TerminalNode NullValue() { return getToken(SimpleJavaParser.NullValue, 0); } - public ValueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterValue(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitValue(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitValue(this); - else return visitor.visitChildren(this); - } - } - - public final ValueContext value() throws RecognitionException { - ValueContext _localctx = new ValueContext(_ctx, getState()); - enterRule(_localctx, 84, RULE_value); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(388); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 131941395333120L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NonCalculationOperatorContext extends ParserRuleContext { - public TerminalNode LogicalOperator() { return getToken(SimpleJavaParser.LogicalOperator, 0); } - public TerminalNode ComparisonOperator() { return getToken(SimpleJavaParser.ComparisonOperator, 0); } - public NonCalculationOperatorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nonCalculationOperator; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationOperator(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationOperator(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationOperator(this); - else return visitor.visitChildren(this); - } - } - - public final NonCalculationOperatorContext nonCalculationOperator() throws RecognitionException { - NonCalculationOperatorContext _localctx = new NonCalculationOperatorContext(_ctx, getState()); - enterRule(_localctx, 86, RULE_nonCalculationOperator); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(390); - _la = _input.LA(1); - if ( !(_la==ComparisonOperator || _la==LogicalOperator) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 34: - return calculationExpression_sempred((CalculationExpressionContext)_localctx, predIndex); - case 35: - return dotExpression_sempred((DotExpressionContext)_localctx, predIndex); - } - return true; - } - private boolean calculationExpression_sempred(CalculationExpressionContext _localctx, int predIndex) { - switch (predIndex) { - case 0: - return precpred(_ctx, 2); - } - return true; - } - private boolean dotExpression_sempred(DotExpressionContext _localctx, int predIndex) { - switch (predIndex) { - case 1: - return precpred(_ctx, 2); - } - return true; - } - - public static final String _serializedATN = - "\u0004\u00012\u0189\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\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ - "\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ - "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ - "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ - "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ - "#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002"+ - "(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007+\u0001\u0000\u0004\u0000"+ - "Z\b\u0000\u000b\u0000\f\u0000[\u0001\u0001\u0003\u0001_\b\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u0001e\b\u0001\n\u0001"+ - "\f\u0001h\t\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+ - "\u0002\u0003\u0002o\b\u0002\u0001\u0003\u0003\u0003r\b\u0003\u0001\u0003"+ - "\u0001\u0003\u0001\u0003\u0003\u0003w\b\u0003\u0001\u0003\u0001\u0003"+ - "\u0001\u0003\u0001\u0004\u0003\u0004}\b\u0004\u0001\u0004\u0001\u0004"+ - "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0003\u0005"+ - "\u0086\b\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008a\b\u0005\u0001"+ - "\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008f\b\u0005\u0001\u0005\u0001"+ - "\u0005\u0003\u0005\u0093\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0005"+ - "\u0006\u0098\b\u0006\n\u0006\f\u0006\u009b\t\u0006\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\b\u0001\b\u0001\b\u0005\b\u00a3\b\b\n\b\f\b\u00a6\t"+ - "\b\u0003\b\u00a8\b\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+ - "\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0003\t\u00b7\b\t\u0001"+ - "\n\u0001\n\u0005\n\u00bb\b\n\n\n\f\n\u00be\t\n\u0001\n\u0001\n\u0001\u000b"+ - "\u0001\u000b\u0003\u000b\u00c4\b\u000b\u0001\f\u0001\f\u0001\f\u0001\f"+ - "\u0003\f\u00ca\b\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001"+ - "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e\u00d6\b\u000e\u0001"+ - "\u000e\u0001\u000e\u0003\u000e\u00da\b\u000e\u0001\u000e\u0001\u000e\u0003"+ - "\u000e\u00de\b\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ - "\u000f\u0003\u000f\u00e5\b\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+ - "\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ - "\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0003\u0012\u00f4\b\u0012\u0001"+ - "\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001"+ - "\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0003"+ - "\u0015\u0102\b\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001"+ - "\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0003"+ - "\u0016\u010e\b\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001"+ - "\u0018\u0003\u0018\u0115\b\u0018\u0001\u0019\u0001\u0019\u0003\u0019\u0119"+ - "\b\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001"+ - "\u001b\u0001\u001c\u0001\u001c\u0003\u001c\u0123\b\u001c\u0001\u001d\u0001"+ - "\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001"+ - "\u001f\u0003\u001f\u012d\b\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0003"+ - " \u0134\b \u0001 \u0001 \u0004 \u0138\b \u000b \f \u0139\u0001 \u0003"+ - " \u013d\b \u0001!\u0001!\u0003!\u0141\b!\u0001\"\u0001\"\u0001\"\u0001"+ - "\"\u0001\"\u0001\"\u0005\"\u0149\b\"\n\"\f\"\u014c\t\"\u0001#\u0001#\u0001"+ - "#\u0001#\u0001#\u0001#\u0005#\u0154\b#\n#\f#\u0157\t#\u0001$\u0001$\u0001"+ - "$\u0001$\u0001$\u0001$\u0001$\u0001$\u0003$\u0161\b$\u0001%\u0001%\u0001"+ - "%\u0001%\u0001&\u0003&\u0168\b&\u0001&\u0005&\u016b\b&\n&\f&\u016e\t&"+ - "\u0001&\u0001&\u0001&\u0001&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0003"+ - "\'\u0179\b\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001(\u0001"+ - "(\u0001)\u0001)\u0001*\u0001*\u0001+\u0001+\u0001+\u0000\u0002DF,\u0000"+ - "\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u001c"+ - "\u001e \"$&(*,.02468:<>@BDFHJLNPRTV\u0000\u0003\u0002\u0000\u0004\u0006"+ - "//\u0001\u0000+.\u0001\u0000\u000b\f\u0194\u0000Y\u0001\u0000\u0000\u0000"+ - "\u0002^\u0001\u0000\u0000\u0000\u0004n\u0001\u0000\u0000\u0000\u0006q"+ - "\u0001\u0000\u0000\u0000\b|\u0001\u0000\u0000\u0000\n\u0092\u0001\u0000"+ - "\u0000\u0000\f\u0094\u0001\u0000\u0000\u0000\u000e\u009c\u0001\u0000\u0000"+ - "\u0000\u0010\u00a7\u0001\u0000\u0000\u0000\u0012\u00b6\u0001\u0000\u0000"+ - "\u0000\u0014\u00b8\u0001\u0000\u0000\u0000\u0016\u00c1\u0001\u0000\u0000"+ - "\u0000\u0018\u00c5\u0001\u0000\u0000\u0000\u001a\u00cb\u0001\u0000\u0000"+ - "\u0000\u001c\u00d1\u0001\u0000\u0000\u0000\u001e\u00e2\u0001\u0000\u0000"+ - "\u0000 \u00e6\u0001\u0000\u0000\u0000\"\u00ec\u0001\u0000\u0000\u0000"+ - "$\u00f3\u0001\u0000\u0000\u0000&\u00f5\u0001\u0000\u0000\u0000(\u00f9"+ - "\u0001\u0000\u0000\u0000*\u0101\u0001\u0000\u0000\u0000,\u010d\u0001\u0000"+ - "\u0000\u0000.\u010f\u0001\u0000\u0000\u00000\u0114\u0001\u0000\u0000\u0000"+ - "2\u0118\u0001\u0000\u0000\u00004\u011a\u0001\u0000\u0000\u00006\u011d"+ - "\u0001\u0000\u0000\u00008\u0122\u0001\u0000\u0000\u0000:\u0124\u0001\u0000"+ - "\u0000\u0000<\u0127\u0001\u0000\u0000\u0000>\u012c\u0001\u0000\u0000\u0000"+ - "@\u013c\u0001\u0000\u0000\u0000B\u0140\u0001\u0000\u0000\u0000D\u0142"+ - "\u0001\u0000\u0000\u0000F\u014d\u0001\u0000\u0000\u0000H\u0160\u0001\u0000"+ - "\u0000\u0000J\u0162\u0001\u0000\u0000\u0000L\u0167\u0001\u0000\u0000\u0000"+ - "N\u0178\u0001\u0000\u0000\u0000P\u017c\u0001\u0000\u0000\u0000R\u0182"+ - "\u0001\u0000\u0000\u0000T\u0184\u0001\u0000\u0000\u0000V\u0186\u0001\u0000"+ - "\u0000\u0000XZ\u0003\u0002\u0001\u0000YX\u0001\u0000\u0000\u0000Z[\u0001"+ - "\u0000\u0000\u0000[Y\u0001\u0000\u0000\u0000[\\\u0001\u0000\u0000\u0000"+ - "\\\u0001\u0001\u0000\u0000\u0000]_\u0005\u0007\u0000\u0000^]\u0001\u0000"+ - "\u0000\u0000^_\u0001\u0000\u0000\u0000_`\u0001\u0000\u0000\u0000`a\u0005"+ - "#\u0000\u0000ab\u0005/\u0000\u0000bf\u0005\u001f\u0000\u0000ce\u0003\u0004"+ - "\u0002\u0000dc\u0001\u0000\u0000\u0000eh\u0001\u0000\u0000\u0000fd\u0001"+ - "\u0000\u0000\u0000fg\u0001\u0000\u0000\u0000gi\u0001\u0000\u0000\u0000"+ - "hf\u0001\u0000\u0000\u0000ij\u0005 \u0000\u0000j\u0003\u0001\u0000\u0000"+ - "\u0000ko\u0003\u0006\u0003\u0000lo\u0003\b\u0004\u0000mo\u0003\n\u0005"+ - "\u0000nk\u0001\u0000\u0000\u0000nl\u0001\u0000\u0000\u0000nm\u0001\u0000"+ - "\u0000\u0000o\u0005\u0001\u0000\u0000\u0000pr\u0005\u0007\u0000\u0000"+ - "qp\u0001\u0000\u0000\u0000qr\u0001\u0000\u0000\u0000rs\u0001\u0000\u0000"+ - "\u0000st\u0005/\u0000\u0000tv\u0005\u001d\u0000\u0000uw\u0003\f\u0006"+ - "\u0000vu\u0001\u0000\u0000\u0000vw\u0001\u0000\u0000\u0000wx\u0001\u0000"+ - "\u0000\u0000xy\u0005\u001e\u0000\u0000yz\u0003\u0014\n\u0000z\u0007\u0001"+ - "\u0000\u0000\u0000{}\u0005\u0007\u0000\u0000|{\u0001\u0000\u0000\u0000"+ - "|}\u0001\u0000\u0000\u0000}~\u0001\u0000\u0000\u0000~\u007f\u0003R)\u0000"+ - "\u007f\u0080\u0005/\u0000\u0000\u0080\u0081\u0005!\u0000\u0000\u0081\t"+ - "\u0001\u0000\u0000\u0000\u0082\u0083\u0005\b\u0000\u0000\u0083\u0093\u0003"+ - "\u0014\n\u0000\u0084\u0086\u0005\u0007\u0000\u0000\u0085\u0084\u0001\u0000"+ - "\u0000\u0000\u0085\u0086\u0001\u0000\u0000\u0000\u0086\u0089\u0001\u0000"+ - "\u0000\u0000\u0087\u008a\u0003R)\u0000\u0088\u008a\u0005\u0003\u0000\u0000"+ - "\u0089\u0087\u0001\u0000\u0000\u0000\u0089\u0088\u0001\u0000\u0000\u0000"+ - "\u008a\u008b\u0001\u0000\u0000\u0000\u008b\u008c\u0005/\u0000\u0000\u008c"+ - "\u008e\u0005\u001d\u0000\u0000\u008d\u008f\u0003\f\u0006\u0000\u008e\u008d"+ - "\u0001\u0000\u0000\u0000\u008e\u008f\u0001\u0000\u0000\u0000\u008f\u0090"+ - "\u0001\u0000\u0000\u0000\u0090\u0091\u0005\u001e\u0000\u0000\u0091\u0093"+ - "\u0003\u0014\n\u0000\u0092\u0082\u0001\u0000\u0000\u0000\u0092\u0085\u0001"+ - "\u0000\u0000\u0000\u0093\u000b\u0001\u0000\u0000\u0000\u0094\u0099\u0003"+ - "\u000e\u0007\u0000\u0095\u0096\u0005\"\u0000\u0000\u0096\u0098\u0003\u000e"+ - "\u0007\u0000\u0097\u0095\u0001\u0000\u0000\u0000\u0098\u009b\u0001\u0000"+ - "\u0000\u0000\u0099\u0097\u0001\u0000\u0000\u0000\u0099\u009a\u0001\u0000"+ - "\u0000\u0000\u009a\r\u0001\u0000\u0000\u0000\u009b\u0099\u0001\u0000\u0000"+ - "\u0000\u009c\u009d\u0003R)\u0000\u009d\u009e\u0005/\u0000\u0000\u009e"+ - "\u000f\u0001\u0000\u0000\u0000\u009f\u00a4\u0003*\u0015\u0000\u00a0\u00a1"+ - "\u0005\"\u0000\u0000\u00a1\u00a3\u0003*\u0015\u0000\u00a2\u00a0\u0001"+ - "\u0000\u0000\u0000\u00a3\u00a6\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001"+ - "\u0000\u0000\u0000\u00a4\u00a5\u0001\u0000\u0000\u0000\u00a5\u00a8\u0001"+ - "\u0000\u0000\u0000\u00a6\u00a4\u0001\u0000\u0000\u0000\u00a7\u009f\u0001"+ - "\u0000\u0000\u0000\u00a7\u00a8\u0001\u0000\u0000\u0000\u00a8\u0011\u0001"+ - "\u0000\u0000\u0000\u00a9\u00aa\u0003\u0016\u000b\u0000\u00aa\u00ab\u0005"+ - "!\u0000\u0000\u00ab\u00b7\u0001\u0000\u0000\u0000\u00ac\u00ad\u0003\u0018"+ - "\f\u0000\u00ad\u00ae\u0005!\u0000\u0000\u00ae\u00b7\u0001\u0000\u0000"+ - "\u0000\u00af\u00b7\u0003\u0014\n\u0000\u00b0\u00b7\u0003\u001a\r\u0000"+ - "\u00b1\u00b7\u0003\u001c\u000e\u0000\u00b2\u00b7\u0003\u001e\u000f\u0000"+ - "\u00b3\u00b4\u0003$\u0012\u0000\u00b4\u00b5\u0005!\u0000\u0000\u00b5\u00b7"+ - "\u0001\u0000\u0000\u0000\u00b6\u00a9\u0001\u0000\u0000\u0000\u00b6\u00ac"+ - "\u0001\u0000\u0000\u0000\u00b6\u00af\u0001\u0000\u0000\u0000\u00b6\u00b0"+ - "\u0001\u0000\u0000\u0000\u00b6\u00b1\u0001\u0000\u0000\u0000\u00b6\u00b2"+ - "\u0001\u0000\u0000\u0000\u00b6\u00b3\u0001\u0000\u0000\u0000\u00b7\u0013"+ - "\u0001\u0000\u0000\u0000\u00b8\u00bc\u0005\u001f\u0000\u0000\u00b9\u00bb"+ - "\u0003\u0012\t\u0000\u00ba\u00b9\u0001\u0000\u0000\u0000\u00bb\u00be\u0001"+ - "\u0000\u0000\u0000\u00bc\u00ba\u0001\u0000\u0000\u0000\u00bc\u00bd\u0001"+ - "\u0000\u0000\u0000\u00bd\u00bf\u0001\u0000\u0000\u0000\u00be\u00bc\u0001"+ - "\u0000\u0000\u0000\u00bf\u00c0\u0005 \u0000\u0000\u00c0\u0015\u0001\u0000"+ - "\u0000\u0000\u00c1\u00c3\u0005)\u0000\u0000\u00c2\u00c4\u0003*\u0015\u0000"+ - "\u00c3\u00c2\u0001\u0000\u0000\u0000\u00c3\u00c4\u0001\u0000\u0000\u0000"+ - "\u00c4\u0017\u0001\u0000\u0000\u0000\u00c5\u00c6\u0003R)\u0000\u00c6\u00c9"+ - "\u0005/\u0000\u0000\u00c7\u00c8\u0005\r\u0000\u0000\u00c8\u00ca\u0003"+ - "*\u0015\u0000\u00c9\u00c7\u0001\u0000\u0000\u0000\u00c9\u00ca\u0001\u0000"+ - "\u0000\u0000\u00ca\u0019\u0001\u0000\u0000\u0000\u00cb\u00cc\u0005%\u0000"+ - "\u0000\u00cc\u00cd\u0005\u001d\u0000\u0000\u00cd\u00ce\u0003*\u0015\u0000"+ - "\u00ce\u00cf\u0005\u001e\u0000\u0000\u00cf\u00d0\u0003\u0014\n\u0000\u00d0"+ - "\u001b\u0001\u0000\u0000\u0000\u00d1\u00d2\u0005(\u0000\u0000\u00d2\u00d5"+ - "\u0005\u001d\u0000\u0000\u00d3\u00d6\u0003$\u0012\u0000\u00d4\u00d6\u0003"+ - "\u0018\f\u0000\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d5\u00d4\u0001\u0000"+ - "\u0000\u0000\u00d6\u00d7\u0001\u0000\u0000\u0000\u00d7\u00d9\u0005!\u0000"+ - "\u0000\u00d8\u00da\u0003*\u0015\u0000\u00d9\u00d8\u0001\u0000\u0000\u0000"+ - "\u00d9\u00da\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000"+ - "\u00db\u00dd\u0005!\u0000\u0000\u00dc\u00de\u0003$\u0012\u0000\u00dd\u00dc"+ - "\u0001\u0000\u0000\u0000\u00dd\u00de\u0001\u0000\u0000\u0000\u00de\u00df"+ - "\u0001\u0000\u0000\u0000\u00df\u00e0\u0005\u001e\u0000\u0000\u00e0\u00e1"+ - "\u0003\u0012\t\u0000\u00e1\u001d\u0001\u0000\u0000\u0000\u00e2\u00e4\u0003"+ - " \u0010\u0000\u00e3\u00e5\u0003\"\u0011\u0000\u00e4\u00e3\u0001\u0000"+ - "\u0000\u0000\u00e4\u00e5\u0001\u0000\u0000\u0000\u00e5\u001f\u0001\u0000"+ - "\u0000\u0000\u00e6\u00e7\u0005&\u0000\u0000\u00e7\u00e8\u0005\u001d\u0000"+ - "\u0000\u00e8\u00e9\u0003*\u0015\u0000\u00e9\u00ea\u0005\u001e\u0000\u0000"+ - "\u00ea\u00eb\u0003\u0012\t\u0000\u00eb!\u0001\u0000\u0000\u0000\u00ec"+ - "\u00ed\u0005\'\u0000\u0000\u00ed\u00ee\u0003\u0012\t\u0000\u00ee#\u0001"+ - "\u0000\u0000\u0000\u00ef\u00f4\u0003&\u0013\u0000\u00f0\u00f4\u0003(\u0014"+ - "\u0000\u00f1\u00f4\u0003L&\u0000\u00f2\u00f4\u00030\u0018\u0000\u00f3"+ - "\u00ef\u0001\u0000\u0000\u0000\u00f3\u00f0\u0001\u0000\u0000\u0000\u00f3"+ - "\u00f1\u0001\u0000\u0000\u0000\u00f3\u00f2\u0001\u0000\u0000\u0000\u00f4"+ - "%\u0001\u0000\u0000\u0000\u00f5\u00f6\u0003>\u001f\u0000\u00f6\u00f7\u0005"+ - "\r\u0000\u0000\u00f7\u00f8\u0003*\u0015\u0000\u00f8\'\u0001\u0000\u0000"+ - "\u0000\u00f9\u00fa\u0005*\u0000\u0000\u00fa\u00fb\u0005/\u0000\u0000\u00fb"+ - "\u00fc\u0005\u001d\u0000\u0000\u00fc\u00fd\u0003\u0010\b\u0000\u00fd\u00fe"+ - "\u0005\u001e\u0000\u0000\u00fe)\u0001\u0000\u0000\u0000\u00ff\u0102\u0003"+ - ",\u0016\u0000\u0100\u0102\u0003B!\u0000\u0101\u00ff\u0001\u0000\u0000"+ - "\u0000\u0101\u0100\u0001\u0000\u0000\u0000\u0102+\u0001\u0000\u0000\u0000"+ - "\u0103\u010e\u0005$\u0000\u0000\u0104\u010e\u0005/\u0000\u0000\u0105\u010e"+ - "\u0003@ \u0000\u0106\u010e\u0003T*\u0000\u0107\u010e\u0003.\u0017\u0000"+ - "\u0108\u010e\u0003$\u0012\u0000\u0109\u010a\u0005\u001d\u0000\u0000\u010a"+ - "\u010b\u0003*\u0015\u0000\u010b\u010c\u0005\u001e\u0000\u0000\u010c\u010e"+ - "\u0001\u0000\u0000\u0000\u010d\u0103\u0001\u0000\u0000\u0000\u010d\u0104"+ - "\u0001\u0000\u0000\u0000\u010d\u0105\u0001\u0000\u0000\u0000\u010d\u0106"+ - "\u0001\u0000\u0000\u0000\u010d\u0107\u0001\u0000\u0000\u0000\u010d\u0108"+ - "\u0001\u0000\u0000\u0000\u010d\u0109\u0001\u0000\u0000\u0000\u010e-\u0001"+ - "\u0000\u0000\u0000\u010f\u0110\u0005\u0019\u0000\u0000\u0110\u0111\u0003"+ - "*\u0015\u0000\u0111/\u0001\u0000\u0000\u0000\u0112\u0115\u00032\u0019"+ - "\u0000\u0113\u0115\u00038\u001c\u0000\u0114\u0112\u0001\u0000\u0000\u0000"+ - "\u0114\u0113\u0001\u0000\u0000\u0000\u01151\u0001\u0000\u0000\u0000\u0116"+ - "\u0119\u00034\u001a\u0000\u0117\u0119\u00036\u001b\u0000\u0118\u0116\u0001"+ - "\u0000\u0000\u0000\u0118\u0117\u0001\u0000\u0000\u0000\u01193\u0001\u0000"+ - "\u0000\u0000\u011a\u011b\u0005\u0001\u0000\u0000\u011b\u011c\u0003>\u001f"+ - "\u0000\u011c5\u0001\u0000\u0000\u0000\u011d\u011e\u0003>\u001f\u0000\u011e"+ - "\u011f\u0005\u0001\u0000\u0000\u011f7\u0001\u0000\u0000\u0000\u0120\u0123"+ - "\u0003:\u001d\u0000\u0121\u0123\u0003<\u001e\u0000\u0122\u0120\u0001\u0000"+ - "\u0000\u0000\u0122\u0121\u0001\u0000\u0000\u0000\u01239\u0001\u0000\u0000"+ - "\u0000\u0124\u0125\u0005\u0002\u0000\u0000\u0125\u0126\u0003>\u001f\u0000"+ - "\u0126;\u0001\u0000\u0000\u0000\u0127\u0128\u0003>\u001f\u0000\u0128\u0129"+ - "\u0005\u0002\u0000\u0000\u0129=\u0001\u0000\u0000\u0000\u012a\u012d\u0005"+ - "/\u0000\u0000\u012b\u012d\u0003@ \u0000\u012c\u012a\u0001\u0000\u0000"+ - "\u0000\u012c\u012b\u0001\u0000\u0000\u0000\u012d?\u0001\u0000\u0000\u0000"+ - "\u012e\u012f\u0005$\u0000\u0000\u012f\u0130\u0005\u001c\u0000\u0000\u0130"+ - "\u013d\u0005/\u0000\u0000\u0131\u0132\u0005$\u0000\u0000\u0132\u0134\u0005"+ - "\u001c\u0000\u0000\u0133\u0131\u0001\u0000\u0000\u0000\u0133\u0134\u0001"+ - "\u0000\u0000\u0000\u0134\u0137\u0001\u0000\u0000\u0000\u0135\u0136\u0005"+ - "/\u0000\u0000\u0136\u0138\u0005\u001c\u0000\u0000\u0137\u0135\u0001\u0000"+ - "\u0000\u0000\u0138\u0139\u0001\u0000\u0000\u0000\u0139\u0137\u0001\u0000"+ - "\u0000\u0000\u0139\u013a\u0001\u0000\u0000\u0000\u013a\u013b\u0001\u0000"+ - "\u0000\u0000\u013b\u013d\u0005/\u0000\u0000\u013c\u012e\u0001\u0000\u0000"+ - "\u0000\u013c\u0133\u0001\u0000\u0000\u0000\u013dA\u0001\u0000\u0000\u0000"+ - "\u013e\u0141\u0003D\"\u0000\u013f\u0141\u0003J%\u0000\u0140\u013e\u0001"+ - "\u0000\u0000\u0000\u0140\u013f\u0001\u0000\u0000\u0000\u0141C\u0001\u0000"+ - "\u0000\u0000\u0142\u0143\u0006\"\uffff\uffff\u0000\u0143\u0144\u0003F"+ - "#\u0000\u0144\u014a\u0001\u0000\u0000\u0000\u0145\u0146\n\u0002\u0000"+ - "\u0000\u0146\u0147\u0005\n\u0000\u0000\u0147\u0149\u0003F#\u0000\u0148"+ - "\u0145\u0001\u0000\u0000\u0000\u0149\u014c\u0001\u0000\u0000\u0000\u014a"+ - "\u0148\u0001\u0000\u0000\u0000\u014a\u014b\u0001\u0000\u0000\u0000\u014b"+ - "E\u0001\u0000\u0000\u0000\u014c\u014a\u0001\u0000\u0000\u0000\u014d\u014e"+ - "\u0006#\uffff\uffff\u0000\u014e\u014f\u0003H$\u0000\u014f\u0155\u0001"+ - "\u0000\u0000\u0000\u0150\u0151\n\u0002\u0000\u0000\u0151\u0152\u0005\t"+ - "\u0000\u0000\u0152\u0154\u0003H$\u0000\u0153\u0150\u0001\u0000\u0000\u0000"+ - "\u0154\u0157\u0001\u0000\u0000\u0000\u0155\u0153\u0001\u0000\u0000\u0000"+ - "\u0155\u0156\u0001\u0000\u0000\u0000\u0156G\u0001\u0000\u0000\u0000\u0157"+ - "\u0155\u0001\u0000\u0000\u0000\u0158\u0161\u0005,\u0000\u0000\u0159\u0161"+ - "\u0005/\u0000\u0000\u015a\u0161\u0003@ \u0000\u015b\u015c\u0003L&\u0000"+ - "\u015c\u015d\u0005\u001d\u0000\u0000\u015d\u015e\u0003D\"\u0000\u015e"+ - "\u015f\u0005\u001e\u0000\u0000\u015f\u0161\u0001\u0000\u0000\u0000\u0160"+ - "\u0158\u0001\u0000\u0000\u0000\u0160\u0159\u0001\u0000\u0000\u0000\u0160"+ - "\u015a\u0001\u0000\u0000\u0000\u0160\u015b\u0001\u0000\u0000\u0000\u0161"+ - "I\u0001\u0000\u0000\u0000\u0162\u0163\u0003,\u0016\u0000\u0163\u0164\u0003"+ - "V+\u0000\u0164\u0165\u0003*\u0015\u0000\u0165K\u0001\u0000\u0000\u0000"+ - "\u0166\u0168\u0003N\'\u0000\u0167\u0166\u0001\u0000\u0000\u0000\u0167"+ - "\u0168\u0001\u0000\u0000\u0000\u0168\u016c\u0001\u0000\u0000\u0000\u0169"+ - "\u016b\u0003P(\u0000\u016a\u0169\u0001\u0000\u0000\u0000\u016b\u016e\u0001"+ - "\u0000\u0000\u0000\u016c\u016a\u0001\u0000\u0000\u0000\u016c\u016d\u0001"+ - "\u0000\u0000\u0000\u016d\u016f\u0001\u0000\u0000\u0000\u016e\u016c\u0001"+ - "\u0000\u0000\u0000\u016f\u0170\u0005/\u0000\u0000\u0170\u0171\u0005\u001d"+ - "\u0000\u0000\u0171\u0172\u0003\u0010\b\u0000\u0172\u0173\u0005\u001e\u0000"+ - "\u0000\u0173M\u0001\u0000\u0000\u0000\u0174\u0179\u0005$\u0000\u0000\u0175"+ - "\u0179\u0003@ \u0000\u0176\u0179\u0003(\u0014\u0000\u0177\u0179\u0005"+ - "/\u0000\u0000\u0178\u0174\u0001\u0000\u0000\u0000\u0178\u0175\u0001\u0000"+ - "\u0000\u0000\u0178\u0176\u0001\u0000\u0000\u0000\u0178\u0177\u0001\u0000"+ - "\u0000\u0000\u0179\u017a\u0001\u0000\u0000\u0000\u017a\u017b\u0005\u001c"+ - "\u0000\u0000\u017bO\u0001\u0000\u0000\u0000\u017c\u017d\u0005/\u0000\u0000"+ - "\u017d\u017e\u0005\u001d\u0000\u0000\u017e\u017f\u0003\u0010\b\u0000\u017f"+ - "\u0180\u0005\u001e\u0000\u0000\u0180\u0181\u0005\u001c\u0000\u0000\u0181"+ - "Q\u0001\u0000\u0000\u0000\u0182\u0183\u0007\u0000\u0000\u0000\u0183S\u0001"+ - "\u0000\u0000\u0000\u0184\u0185\u0007\u0001\u0000\u0000\u0185U\u0001\u0000"+ - "\u0000\u0000\u0186\u0187\u0007\u0002\u0000\u0000\u0187W\u0001\u0000\u0000"+ - "\u0000\'[^fnqv|\u0085\u0089\u008e\u0092\u0099\u00a4\u00a7\u00b6\u00bc"+ - "\u00c3\u00c9\u00d5\u00d9\u00dd\u00e4\u00f3\u0101\u010d\u0114\u0118\u0122"+ - "\u012c\u0133\u0139\u013c\u0140\u014a\u0155\u0160\u0167\u016c\u0178"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaVisitor.java b/src/main/java/parser/generated/SimpleJavaVisitor.java deleted file mode 100644 index 3b31f92..0000000 --- a/src/main/java/parser/generated/SimpleJavaVisitor.java +++ /dev/null @@ -1,277 +0,0 @@ -// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 -package parser.generated; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link SimpleJavaParser}. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface SimpleJavaVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link SimpleJavaParser#program}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitProgram(SimpleJavaParser.ProgramContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#classDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#parameterList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameterList(SimpleJavaParser.ParameterListContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#parameter}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameter(SimpleJavaParser.ParameterContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#argumentList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStatement(SimpleJavaParser.StatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#block}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBlock(SimpleJavaParser.BlockContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#forStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitForStatement(SimpleJavaParser.ForStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfStatement(SimpleJavaParser.IfStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#elseStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#statementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#assign}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssign(SimpleJavaParser.AssignContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpression(SimpleJavaParser.ExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#notExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#crementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#memberAccess}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#dotExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#methodCall}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMethodCall(SimpleJavaParser.MethodCallContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#target}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTarget(SimpleJavaParser.TargetContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitType(SimpleJavaParser.TypeContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#value}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValue(SimpleJavaParser.ValueContext ctx); - /** - * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); -} \ No newline at end of file diff --git a/src/main/java/parser/grammar/SimpleJava.g4 b/src/main/java/parser/grammar/SimpleJava.g4 index 2a63966..333142f 100644 --- a/src/main/java/parser/grammar/SimpleJava.g4 +++ b/src/main/java/parser/grammar/SimpleJava.g4 @@ -29,11 +29,11 @@ returnStatement: Return (expression)?; localVariableDeclaration: type Identifier (Assign expression)?; whileStatement: While OpenRoundBracket expression ClosedRoundBracket block; -forStatement: For OpenRoundBracket (statementExpression | localVariableDeclaration) Semicolon (expression)? Semicolon (statementExpression)? ClosedRoundBracket statement; +forStatement: For OpenRoundBracket (statementExpression | localVariableDeclaration) Semicolon (expression)? Semicolon (statementExpression)? ClosedRoundBracket block; -ifElseStatement: ifStatement elseStatement?; -ifStatement: If OpenRoundBracket expression ClosedRoundBracket statement; -elseStatement: Else statement; +ifElseStatement: ifStatement elseStatement*; +ifStatement: If OpenRoundBracket expression ClosedRoundBracket block; +elseStatement: Else block; statementExpression: assign | newDeclaration | methodCall | crementExpression; assign: assignableExpression Assign expression; diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index b66ea75..8878777 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -12,6 +12,7 @@ import ast.member.FieldNode; import ast.member.MethodNode; import ast.statement.*; import ast.expression.This; +import ast.statement.ifstatement.IfStatementNode; import typechecker.TypeCheckResult; public interface SemanticVisitor { -- 2.34.1 From bf7a6422333fa03e8c3546e9f490e5bd4b185d6f Mon Sep 17 00:00:00 2001 From: i22035 Date: Sun, 16 Jun 2024 13:01:26 +0200 Subject: [PATCH 07/19] Added Expression Visitors --- .../expression/AssignableExpressionNode.java | 4 - .../binaryexpression/BinaryExpression.java | 4 + .../CalculationExpressionNode.java | 19 ++ .../binaryexpression/DotExpressionNode.java | 19 ++ .../DotSubstractionExpressionNode.java | 31 +++ .../NonCalculationExpressionNode.java | 17 ++ .../unaryexpression/MemberAccessNode.java | 19 ++ .../unaryexpression/NotExpressionNode.java | 12 + .../unaryexpression/UnaryExpressionNode.java | 46 ++++ .../AssignStatementExpressionNode.java | 1 - .../AssignableExpressionNode.java | 17 ++ ...mentExpressionStatementExpressionNode.java | 20 -- .../IncrementExpression.java | 5 + .../crementExpression/CrementType.java | 5 + .../DecrementExpressionNode.java | 13 ++ .../IncrementExpressionNode.java | 13 ++ .../TargetNode.java | 25 ++- src/main/java/ast/type/EnumValueNode.java | 5 + src/main/java/ast/type/ValueNode.java | 13 ++ .../java/parser/astBuilder/ASTBuilder.java | 207 +++++++++++++++++- src/main/java/semantic/SemanticVisitor.java | 2 +- 21 files changed, 462 insertions(+), 35 deletions(-) delete mode 100644 src/main/java/ast/expression/AssignableExpressionNode.java create mode 100644 src/main/java/ast/expression/binaryexpression/BinaryExpression.java create mode 100644 src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java create mode 100644 src/main/java/ast/expression/binaryexpression/DotExpressionNode.java create mode 100644 src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java create mode 100644 src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java create mode 100644 src/main/java/ast/expression/unaryexpression/MemberAccessNode.java create mode 100644 src/main/java/ast/expression/unaryexpression/NotExpressionNode.java create mode 100644 src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java delete mode 100644 src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/IncrementExpression.java create mode 100644 src/main/java/ast/statement/statementexpression/crementExpression/CrementType.java create mode 100644 src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java create mode 100644 src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java create mode 100644 src/main/java/ast/type/EnumValueNode.java create mode 100644 src/main/java/ast/type/ValueNode.java diff --git a/src/main/java/ast/expression/AssignableExpressionNode.java b/src/main/java/ast/expression/AssignableExpressionNode.java deleted file mode 100644 index 6a65d10..0000000 --- a/src/main/java/ast/expression/AssignableExpressionNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package ast.expression; - -public class AssignableExpressionNode { -} diff --git a/src/main/java/ast/expression/binaryexpression/BinaryExpression.java b/src/main/java/ast/expression/binaryexpression/BinaryExpression.java new file mode 100644 index 0000000..fb161f3 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/BinaryExpression.java @@ -0,0 +1,4 @@ +package ast.expression.binaryexpression; + +public class BinaryExpression { +} diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java new file mode 100644 index 0000000..ec3ab61 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -0,0 +1,19 @@ +package ast.expression.binaryexpression; + +import ast.ASTNode; + +public class CalculationExpressionNode implements ASTNode { + CalculationExpressionNode calculationExpression; + String operator; + DotExpressionNode dotExpression; + + public CalculationExpressionNode(CalculationExpressionNode calculationExpression, String operator, DotExpressionNode dotExpression) { + this.calculationExpression = calculationExpression; + this.operator = operator; + this.dotExpression = dotExpression; + } + + public CalculationExpressionNode(DotExpressionNode dotExpression) { + this.dotExpression = dotExpression; + } +} diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java new file mode 100644 index 0000000..1418fe5 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -0,0 +1,19 @@ +package ast.expression.binaryexpression; + +import ast.ASTNode; + +public class DotExpressionNode implements ASTNode { + DotExpressionNode dotExpression; + String operator; + DotSubstractionExpressionNode dotSubstractionExpression; + + public DotExpressionNode(DotExpressionNode dotExpression, String operator, DotSubstractionExpressionNode dotSubstractionExpression) { + this.dotExpression = dotExpression; + this.operator = operator; + this.dotSubstractionExpression = dotSubstractionExpression; + } + + public DotExpressionNode(DotSubstractionExpressionNode dotSubstractionExpression) { + this.dotSubstractionExpression = dotSubstractionExpression; + } +} diff --git a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java new file mode 100644 index 0000000..e32863c --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java @@ -0,0 +1,31 @@ +package ast.expression.binaryexpression; + +import ast.ASTNode; +import ast.expression.unaryexpression.MemberAccessNode; +import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; +import ast.type.ValueNode; + +public class DotSubstractionExpressionNode implements ASTNode { + ValueNode value; + String identifier; + MemberAccessNode memberAccess; + MethodCallStatementExpressionNode methodCall; + CalculationExpressionNode calculationExpression; + + public DotSubstractionExpressionNode(ValueNode value) { + this.value = value; + } + + public DotSubstractionExpressionNode(String identifier) { + this.identifier = identifier; + } + + public DotSubstractionExpressionNode(MemberAccessNode memberAccess) { + this.memberAccess = memberAccess; + } + + public DotSubstractionExpressionNode(MethodCallStatementExpressionNode methodCall, CalculationExpressionNode calculationExpression) { + this.methodCall = methodCall; + this.calculationExpression = calculationExpression; + } +} diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java new file mode 100644 index 0000000..1c1c674 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -0,0 +1,17 @@ +package ast.expression.binaryexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; +import ast.expression.unaryexpression.UnaryExpressionNode; + +public class NonCalculationExpressionNode implements ASTNode { + UnaryExpressionNode unaryExpression; + String operator; + ExpressionNode expression; + + public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, ExpressionNode expression) { + this.unaryExpression = unaryExpression; + this.operator = operator; + this.expression = expression; + } +} diff --git a/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java new file mode 100644 index 0000000..fb33d6e --- /dev/null +++ b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java @@ -0,0 +1,19 @@ +package ast.expression.unaryexpression; + +import ast.ASTNode; + +import java.util.ArrayList; +import java.util.List; + +public class MemberAccessNode implements ASTNode { + Boolean thisExpr; + List identifiers = new ArrayList<>(); + + public MemberAccessNode(Boolean thisExpr) { + this.thisExpr = thisExpr; + } + + public void addIdentifier(String identifier) { + identifiers.add(identifier); + } +} diff --git a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java new file mode 100644 index 0000000..e04a2fd --- /dev/null +++ b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java @@ -0,0 +1,12 @@ +package ast.expression.unaryexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; + +public class NotExpressionNode implements ASTNode { + ExpressionNode expression; + + public NotExpressionNode(ExpressionNode expression) { + this.expression = expression; + } +} diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java new file mode 100644 index 0000000..fdb694a --- /dev/null +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -0,0 +1,46 @@ +package ast.expression.unaryexpression; + +import ast.ASTNode; +import ast.expression.ExpressionNode; +import ast.statement.StatementNode; +import ast.type.ValueNode; + +import java.util.Objects; + +public class UnaryExpressionNode implements ASTNode { + String thisExp; + String identifier; + MemberAccessNode memberAccess; + ValueNode value; + NotExpressionNode notExpression; + StatementNode statement; + ExpressionNode expression; + + public UnaryExpressionNode(String value) { + if(Objects.equals(value, "this")) { + this.thisExp = "this"; + } else { + this.identifier = value; + } + } + + public UnaryExpressionNode(MemberAccessNode memberAccess) { + this.memberAccess = memberAccess; + } + + public UnaryExpressionNode(ValueNode value) { + this.value = value; + } + + public UnaryExpressionNode(NotExpressionNode notExpression) { + this.notExpression = notExpression; + } + + public UnaryExpressionNode(StatementNode statement) { + this.statement = statement; + } + + public UnaryExpressionNode(ExpressionNode expression) { + this.expression = expression; + } +} diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java index 007f240..d993f48 100644 --- a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -1,7 +1,6 @@ package ast.statement.statementexpression; import ast.ASTNode; -import ast.expression.AssignableExpressionNode; import ast.expression.ExpressionNode; public class AssignStatementExpressionNode implements ASTNode { diff --git a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java new file mode 100644 index 0000000..cf9b96e --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java @@ -0,0 +1,17 @@ +package ast.statement.statementexpression; + +import ast.ASTNode; +import ast.expression.unaryexpression.MemberAccessNode; + +public class AssignableExpressionNode implements ASTNode { + String identifier; + MemberAccessNode memberAccess; + + public AssignableExpressionNode(String identifier) { + this.identifier = identifier; + } + + public AssignableExpressionNode(MemberAccessNode memberAccess) { + this.memberAccess = memberAccess; + } +} diff --git a/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java deleted file mode 100644 index de68102..0000000 --- a/src/main/java/ast/statement/statementexpression/CrementExpressionStatementExpressionNode.java +++ /dev/null @@ -1,20 +0,0 @@ -package ast.statement.statementexpression; - -import ast.ASTNode; -import ast.expression.ExpressionNode; - -import java.util.ArrayList; -import java.util.List; - -public class CrementExpressionStatementExpressionNode implements ASTNode { - String identifier; - List expressions = new ArrayList<>(); - - public CrementExpressionStatementExpressionNode(String identifier) { - this.identifier = identifier; - } - - public void addExpression(ExpressionNode expression) { - expressions.add(expression); - } -} diff --git a/src/main/java/ast/statement/statementexpression/IncrementExpression.java b/src/main/java/ast/statement/statementexpression/IncrementExpression.java new file mode 100644 index 0000000..2a4d9fa --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/IncrementExpression.java @@ -0,0 +1,5 @@ +package ast.statement.statementexpression; + +public class IncrementExpression { + +} diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/CrementType.java b/src/main/java/ast/statement/statementexpression/crementExpression/CrementType.java new file mode 100644 index 0000000..d300bfb --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/crementExpression/CrementType.java @@ -0,0 +1,5 @@ +package ast.statement.statementexpression.crementExpression; + +public enum CrementType { + PREFIX, SUFFIX +} diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java new file mode 100644 index 0000000..5b4a9d9 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java @@ -0,0 +1,13 @@ +package ast.statement.statementexpression.crementExpression; + +import ast.ASTNode; +import ast.statement.statementexpression.AssignableExpressionNode; + +public class DecrementExpressionNode implements ASTNode { + CrementType crementType; + AssignableExpressionNode assignableExpression; + + public DecrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { + this.assignableExpression = assignableExpression; + } +} diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java new file mode 100644 index 0000000..a16233f --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java @@ -0,0 +1,13 @@ +package ast.statement.statementexpression.crementExpression; + +import ast.ASTNode; +import ast.statement.statementexpression.AssignableExpressionNode; + +public class IncrementExpressionNode implements ASTNode { + CrementType crementType; + AssignableExpressionNode assignableExpression; + + public IncrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { + this.assignableExpression = assignableExpression; + } +} diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java index 68f4526..d8c0c54 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java @@ -1,7 +1,28 @@ package ast.statement.statementexpression.methodcallstatementnexpression; -public class TargetNode { - String thisTarget; +import ast.ASTNode; +import ast.expression.unaryexpression.MemberAccessNode; +import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; +public class TargetNode implements ASTNode { + Boolean thisTar; + MemberAccessNode memberAccess; + NewDeclarationStatementExpressionNode newDeclaration; + String identifier; + public TargetNode(Boolean thisTar) { + this.thisTar = thisTar; + } + + public TargetNode(MemberAccessNode memberAccess) { + this.memberAccess = memberAccess; + } + + public TargetNode(NewDeclarationStatementExpressionNode newDeclaration) { + this.newDeclaration = newDeclaration; + } + + public TargetNode(String identifier) { + this.identifier = identifier; + } } diff --git a/src/main/java/ast/type/EnumValueNode.java b/src/main/java/ast/type/EnumValueNode.java new file mode 100644 index 0000000..eabb824 --- /dev/null +++ b/src/main/java/ast/type/EnumValueNode.java @@ -0,0 +1,5 @@ +package ast.type; + +public enum EnumValueNode { + INT_VALUE, BOOLEAN_VALUE, CHAR_VALUE, NULL_VALUE +} diff --git a/src/main/java/ast/type/ValueNode.java b/src/main/java/ast/type/ValueNode.java new file mode 100644 index 0000000..d188006 --- /dev/null +++ b/src/main/java/ast/type/ValueNode.java @@ -0,0 +1,13 @@ +package ast.type; + +import ast.ASTNode; + +public class ValueNode implements ASTNode { + EnumValueNode valueType; + String value; + + public ValueNode(EnumValueNode valueType, String value) { + this.valueType = valueType; + this.value = value; + } +} diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index cc54059..ea95f60 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -2,8 +2,14 @@ package parser.astBuilder; import ast.*; import ast.block.BlockNode; -import ast.expression.AssignableExpressionNode; -import ast.expression.ExpressionNode; +import ast.expression.*; +import ast.expression.binaryexpression.CalculationExpressionNode; +import ast.expression.binaryexpression.DotExpressionNode; +import ast.expression.binaryexpression.DotSubstractionExpressionNode; +import ast.expression.binaryexpression.NonCalculationExpressionNode; +import ast.expression.unaryexpression.MemberAccessNode; +import ast.expression.unaryexpression.NotExpressionNode; +import ast.expression.unaryexpression.UnaryExpressionNode; import ast.statement.ifstatement.ElseStatementNode; import ast.statement.ifstatement.IfElseStatementNode; import ast.member.ConstructorNode; @@ -12,11 +18,16 @@ import ast.parameter.ParameterNode; import ast.statement.*; import ast.statement.ifstatement.IfStatementNode; import ast.statement.statementexpression.AssignStatementExpressionNode; -import ast.statement.statementexpression.CrementExpressionStatementExpressionNode; +import ast.statement.statementexpression.AssignableExpressionNode; +import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; +import ast.statement.statementexpression.crementExpression.CrementType; +import ast.statement.statementexpression.crementExpression.DecrementExpressionNode; +import ast.statement.statementexpression.crementExpression.IncrementExpressionNode; import ast.statement.statementexpression.methodcallstatementnexpression.ChainedMethodNode; import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; import ast.statement.statementexpression.methodcallstatementnexpression.TargetNode; import ast.type.*; +import org.antlr.v4.runtime.tree.TerminalNode; import parser.generated.*; public class ASTBuilder extends SimpleJavaBaseVisitor { @@ -147,11 +158,11 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { - CrementExpressionStatementExpressionNode crementExpressionStatementNode = new CrementExpressionStatementExpressionNode(ctx.Identifier().getText()); + NewDeclarationStatementExpressionNode newDeclarationStatementExpressionNode = new NewDeclarationStatementExpressionNode(ctx.Identifier().getText()); for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { - crementExpressionStatementNode.addExpression((ExpressionNode) visit(expression)); + newDeclarationStatementExpressionNode.addExpression((ExpressionNode) visit(expression)); } - return crementExpressionStatementNode; + return newDeclarationStatementExpressionNode; } @Override @@ -168,7 +179,16 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitTarget(SimpleJavaParser.TargetContext ctx) { - + if(ctx.This() != null) { + return new TargetNode(true); + } else if(ctx.memberAccess() != null) { + return new TargetNode((MemberAccessNode) visit(ctx.memberAccess())); + } else if(ctx.newDeclaration() != null) { + return new TargetNode((NewDeclarationStatementExpressionNode) visit(ctx.newDeclaration())); + } else if(ctx.Identifier() != null) { + return new TargetNode(ctx.Identifier().getText()); + } + return null; } @Override @@ -179,4 +199,177 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { } return chainedMethodNode; } + + @Override + public ASTNode visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { + if(ctx.incrementExpression() != null) { + return visitIncrementExpression(ctx.incrementExpression()); + } else if(ctx.decrementExpression() != null) { + return visitDecrementExpression(ctx.decrementExpression()); + } + return null; + } + + @Override + public ASTNode visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { + if(ctx.prefixIncrementExpression() != null) { + return visitPrefixIncrementExpression(ctx.prefixIncrementExpression()); + } else if(ctx.suffixIncrementExpression() != null) { + return visitSuffixIncrementExpression(ctx.suffixIncrementExpression()); + } + return null; + } + + @Override + public ASTNode visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { + return new IncrementExpressionNode(CrementType.PREFIX, (AssignableExpressionNode) visit(ctx.assignableExpression())); + } + + @Override + public ASTNode visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { + return new IncrementExpressionNode(CrementType.SUFFIX, (AssignableExpressionNode) visit(ctx.assignableExpression())); + } + + @Override + public ASTNode visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { + if(ctx.prefixDecrementExpression() != null) { + return visitPrefixDecrementExpression(ctx.prefixDecrementExpression()); + } else if(ctx.suffixDecrementExpression() != null) { + return visitSuffixDecrementExpression(ctx.suffixDecrementExpression()); + } + return null; + } + + @Override + public ASTNode visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { + return new DecrementExpressionNode(CrementType.PREFIX, (AssignableExpressionNode) visit(ctx.assignableExpression())); + } + + @Override + public ASTNode visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { + return new DecrementExpressionNode(CrementType.SUFFIX, (AssignableExpressionNode) visit(ctx.assignableExpression())); + } + + @Override + public ASTNode visitExpression(SimpleJavaParser.ExpressionContext ctx) { + if(ctx.unaryExpression() != null) { + return visit(ctx.unaryExpression()); + } else if(ctx.binaryExpression() != null) { + return visit(ctx.binaryExpression()); + } + return null; + } + + @Override + public ASTNode visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { + if(ctx.This() != null) { + return new UnaryExpressionNode(ctx.This().getText()); + } else if(ctx.Identifier() != null) { + return new UnaryExpressionNode(ctx.Identifier().getText()); + } else if(ctx.memberAccess() != null) { + return new UnaryExpressionNode((MemberAccessNode) visitMemberAccess(ctx.memberAccess())); + } else if(ctx.value() != null) { + return new UnaryExpressionNode((ValueNode) visitValue(ctx.value())); + } else if(ctx.notExpression() != null) { + return new UnaryExpressionNode((NotExpressionNode) visitNotExpression(ctx.notExpression())); + } else if(ctx.statementExpression() != null) { + return new UnaryExpressionNode((StatementNode) visitStatementExpression(ctx.statementExpression())); + } else if(ctx.expression() != null) { + return new UnaryExpressionNode((ExpressionNode) visitExpression(ctx.expression())); + } + return null; + } + + @Override + public ASTNode visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { + MemberAccessNode memberAccessNode; + if(ctx.This() != null) { + memberAccessNode = new MemberAccessNode(true); + } else { + memberAccessNode = new MemberAccessNode(false); + } + for (TerminalNode identifierNode : ctx.Identifier()) { + memberAccessNode.addIdentifier(identifierNode.getText()); + } + return memberAccessNode; + } + + @Override + public ASTNode visitValue(SimpleJavaParser.ValueContext ctx) { + if(ctx.IntValue() != null) { + return new ValueNode(EnumValueNode.INT_VALUE, ctx.IntValue().getText()); + } else if(ctx.BooleanValue() != null) { + return new ValueNode(EnumValueNode.BOOLEAN_VALUE, ctx.BooleanValue().getText()); + } else if(ctx.CharValue() != null) { + return new ValueNode(EnumValueNode.CHAR_VALUE, ctx.CharValue().getText()); + } else if(ctx.NullValue() != null) { + return new ValueNode(EnumValueNode.NULL_VALUE, ctx.NullValue().getText()); + } + return null; + } + + @Override + public ASTNode visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { + return new NotExpressionNode((ExpressionNode) visitExpression(ctx.expression())); + } + + + @Override + public ASTNode visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { + if(ctx.calculationExpression() != null) { + return visit(ctx.calculationExpression()); + } else if(ctx.nonCalculationExpression() != null) { + return visit(ctx.nonCalculationExpression()); + } + return null; + } + + @Override + public ASTNode visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { + if(ctx.calculationExpression() != null) { + return new CalculationExpressionNode((CalculationExpressionNode) visit(ctx.calculationExpression()), ctx.LineOperator().getText(), (DotExpressionNode) visit(ctx.dotExpression())); + } else if(ctx.dotExpression() != null) { + return new CalculationExpressionNode((DotExpressionNode) visit(ctx.dotExpression())); + } + return null; + } + + @Override + public ASTNode visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { + if(ctx.dotExpression() != null) { + return new DotExpressionNode((DotExpressionNode) visit(ctx.dotExpression()), ctx.DotOperator().getText(), (DotSubstractionExpressionNode) visit(ctx.dotSubtractionExpression())); + } else if(ctx.dotSubtractionExpression() != null) { + return new DotExpressionNode((DotSubstractionExpressionNode) visit(ctx.dotSubtractionExpression())); + } + return null; + } + + @Override + public ASTNode visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { + if(ctx.IntValue() != null) { + return new DotSubstractionExpressionNode(new ValueNode(EnumValueNode.INT_VALUE, ctx.IntValue().getText())); + } else if(ctx.Identifier() != null) { + return new DotSubstractionExpressionNode(ctx.Identifier().getText()); + } else if(ctx.memberAccess() != null) { + return new DotSubstractionExpressionNode((MemberAccessNode) visit(ctx.memberAccess())); + } else if(ctx.methodCall() != null && ctx.calculationExpression() != null) { + return new DotSubstractionExpressionNode((MethodCallStatementExpressionNode) visit(ctx.methodCall()), (CalculationExpressionNode) visit(ctx.calculationExpression())); + } + return null; + } + + @Override + public ASTNode visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { + return new NonCalculationExpressionNode((UnaryExpressionNode) visit(ctx.unaryExpression()), ctx.nonCalculationOperator().getText(), (ExpressionNode) visit(ctx.expression())); + } + + @Override + public ASTNode visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { + if(ctx.Identifier() != null) { + return new AssignableExpressionNode(ctx.Identifier().getText()); + } else if(ctx.memberAccess() != null) { + return new AssignableExpressionNode((MemberAccessNode) visit(ctx.memberAccess())); + } + return null; + } } diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index 8878777..7139261 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -7,7 +7,7 @@ import ast.ProgramNode; import ast.expression.BinaryExpressionNode; import ast.expression.IdentifierExpressionNode; import ast.expression.InstVar; -import ast.expression.UnaryExpressionNode; +import ast.expression.unaryexpression.UnaryExpressionNode; import ast.member.FieldNode; import ast.member.MethodNode; import ast.statement.*; -- 2.34.1 From 978b5a2b4aa945e44fd5aca422b1e9496ef596f0 Mon Sep 17 00:00:00 2001 From: i22035 Date: Wed, 19 Jun 2024 21:19:09 +0200 Subject: [PATCH 08/19] Fixed MethodNode and Visitor --- src/main/java/ast/ClassNode.java | 2 +- src/main/java/ast/member/ConstructorNode.java | 13 +- src/main/java/ast/member/FieldNode.java | 2 - src/main/java/ast/member/MethodNode.java | 40 +- .../java/parser/astBuilder/ASTBuilder.java | 24 +- .../java/parser/generated/SimpleJava.interp | 155 + .../java/parser/generated/SimpleJava.tokens | 88 + .../generated/SimpleJavaBaseListener.java | 568 +++ .../generated/SimpleJavaBaseVisitor.java | 323 ++ .../parser/generated/SimpleJavaLexer.interp | 170 + .../parser/generated/SimpleJavaLexer.java | 394 ++ .../parser/generated/SimpleJavaLexer.tokens | 88 + .../parser/generated/SimpleJavaListener.java | 450 +++ .../parser/generated/SimpleJavaParser.java | 3457 +++++++++++++++++ .../parser/generated/SimpleJavaVisitor.java | 277 ++ 15 files changed, 6028 insertions(+), 23 deletions(-) create mode 100644 src/main/java/parser/generated/SimpleJava.interp create mode 100644 src/main/java/parser/generated/SimpleJava.tokens create mode 100644 src/main/java/parser/generated/SimpleJavaBaseListener.java create mode 100644 src/main/java/parser/generated/SimpleJavaBaseVisitor.java create mode 100644 src/main/java/parser/generated/SimpleJavaLexer.interp create mode 100644 src/main/java/parser/generated/SimpleJavaLexer.java create mode 100644 src/main/java/parser/generated/SimpleJavaLexer.tokens create mode 100644 src/main/java/parser/generated/SimpleJavaListener.java create mode 100644 src/main/java/parser/generated/SimpleJavaParser.java create mode 100644 src/main/java/parser/generated/SimpleJavaVisitor.java diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index 5914d4b..a21044a 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -36,7 +36,7 @@ public class ClassNode implements ASTNode, Visitable { public void ensureConstructor(){ if(!hasConstructor) { - ConstructorNode constructor = new ConstructorNode("public", identifier, ); + ConstructorNode constructor = new ConstructorNode(new AccessModifierNode("public"), identifier); members.addFirst(constructor); } } diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java index 7a7472f..c78f8d4 100644 --- a/src/main/java/ast/member/ConstructorNode.java +++ b/src/main/java/ast/member/ConstructorNode.java @@ -9,14 +9,19 @@ import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class ConstructorNode extends MethodNode implements Visitable { +public class ConstructorNode extends MethodNode { public AccessModifierNode accessType; public String identifier; public List parameters = new ArrayList<>(); public BlockNode body; - public ConstructorNode(String accessType, String identifier, BlockNode body) { - this.accessType = new AccessModifierNode(accessType); + public ConstructorNode(AccessModifierNode accessType, String identifier) { + this.accessType = accessType; + this.identifier = identifier; + } + + public ConstructorNode(AccessModifierNode accessType, String identifier, BlockNode body) { + this.accessType = accessType; this.identifier = identifier; this.body = body; } @@ -25,8 +30,10 @@ public class ConstructorNode extends MethodNode implements Visitable { parameters.add(parameterNode); } + /* @Override public void accept(MethodVisitor methodVisitor) { methodVisitor.visit(this); } + */ } diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index 3ffd751..2518d58 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -12,8 +12,6 @@ public class FieldNode implements MemberNode, Visitable { public TypeNode type; public String identifier; - public FieldNode(){} - public FieldNode(AccessModifierNode accessTypeNode, TypeNode type, String name){ this.accessTypeNode = accessTypeNode; this.type = type; diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index df50365..e508629 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -1,5 +1,9 @@ package ast.member; +import ast.block.BlockNode; +import ast.parameter.ParameterNode; +import ast.type.AccessModifierNode; +import ast.type.TypeNode; import bytecode.visitor.MethodVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -8,31 +12,33 @@ import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class MethodNode implements MemberNode, Visitable { - public AccessModifierNode accessModifier; - public TypeNode type; - public String identifier; +public class MethodNode implements MemberNode { + AccessModifierNode accesModifier; + TypeNode type; + Boolean voidType; + String identifier; + List parameters; + BlockNode block; - public ParameterListNode parameters; + public MethodNode() {} - public List statements = new ArrayList<>(); + public MethodNode(BlockNode block){ + this.block = block; + } - public MethodNode(){} - - public MethodNode(AccessTypeNode visibility, TypeNode type, String identifier, ParameterListNode parameters, - List statements){ - this.visibility = visibility; + public MethodNode(AccessModifierNode accessModifier, TypeNode type, Boolean voidType, String identifier, BlockNode block){ + this.accesModifier = accessModifier; this.type = type; + this.voidType = voidType; this.identifier = identifier; - this.parameters = parameters; - this.statements = statements; + this.block = block; } - public MethodNode(AccessTypeNode visibility, String identifier){ - this.visibility = visibility; - this.identifier = identifier; + public void addParameter(ParameterNode parameter) { + this.parameters.add(parameter); } + /* public boolean isSame(MethodNode methodNode){ boolean isSame = false; if(methodNode.identifier.equals(identifier)){ @@ -58,4 +64,6 @@ public class MethodNode implements MemberNode, Visitable { public void accept(MethodVisitor methodVisitor) { methodVisitor.visit(this); } + */ + } diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index ea95f60..7760b5c 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -10,6 +10,7 @@ import ast.expression.binaryexpression.NonCalculationExpressionNode; import ast.expression.unaryexpression.MemberAccessNode; import ast.expression.unaryexpression.NotExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; +import ast.member.MethodNode; import ast.statement.ifstatement.ElseStatementNode; import ast.statement.ifstatement.IfElseStatementNode; import ast.member.ConstructorNode; @@ -52,13 +53,34 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { - ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + ConstructorNode constructorNode = new ConstructorNode((AccessModifierNode) visit(ctx.AccessModifier()), ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { constructorNode.addParameter((ParameterNode) visit(parameter)); } return constructorNode; } + @Override + public ASTNode visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { + if(ctx.MainMethodDeclaration() != null) { + return new MethodNode((BlockNode) visit(ctx.block())); + } else { + if(ctx.type() != null) { + MethodNode methodNode = new MethodNode((AccessModifierNode) visit(ctx.AccessModifier()), (TypeNode) visit(ctx.type()), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { + methodNode.addParameter((ParameterNode) visit(parameter)); + } + return methodNode; + } else { + MethodNode methodNode = new MethodNode((AccessModifierNode) visit(ctx.AccessModifier()), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { + methodNode.addParameter((ParameterNode) visit(parameter)); + } + return methodNode; + } + } + } + @Override public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) { return new ParameterNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); diff --git a/src/main/java/parser/generated/SimpleJava.interp b/src/main/java/parser/generated/SimpleJava.interp new file mode 100644 index 0000000..c21e97d --- /dev/null +++ b/src/main/java/parser/generated/SimpleJava.interp @@ -0,0 +1,155 @@ +token literal names: +null +'++' +'--' +'void' +'boolean' +'char' +'int' +null +'public static void main(String[] args)' +null +null +null +null +'=' +'+' +'-' +'*' +'%' +'/' +'>' +'<' +'>=' +'<=' +'==' +'!=' +'!' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'for' +'return' +'new' +null +null +null +'null' +null +null +null +null + +token symbolic names: +null +null +null +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Identifier +WS +InlineComment +MultilineComment + +rule names: +program +classDeclaration +memberDeclaration +constructorDeclaration +fieldDeclaration +methodDeclaration +parameterList +parameter +argumentList +statement +block +returnStatement +localVariableDeclaration +whileStatement +forStatement +ifElseStatement +ifStatement +elseStatement +statementExpression +assign +newDeclaration +expression +unaryExpression +notExpression +crementExpression +incrementExpression +prefixIncrementExpression +suffixIncrementExpression +decrementExpression +prefixDecrementExpression +suffixDecrementExpression +assignableExpression +memberAccess +binaryExpression +calculationExpression +dotExpression +dotSubtractionExpression +nonCalculationExpression +methodCall +target +chainedMethod +type +value +nonCalculationOperator + + +atn: +[4, 1, 50, 396, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 1, 0, 4, 0, 90, 8, 0, 11, 0, 12, 0, 91, 1, 1, 3, 1, 95, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 101, 8, 1, 10, 1, 12, 1, 104, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 111, 8, 2, 1, 3, 3, 3, 114, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 119, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 125, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 134, 8, 5, 1, 5, 1, 5, 3, 5, 138, 8, 5, 1, 5, 1, 5, 1, 5, 3, 5, 143, 8, 5, 1, 5, 1, 5, 3, 5, 147, 8, 5, 1, 6, 1, 6, 1, 6, 5, 6, 152, 8, 6, 10, 6, 12, 6, 155, 9, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 5, 8, 163, 8, 8, 10, 8, 12, 8, 166, 9, 8, 3, 8, 168, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 183, 8, 9, 1, 10, 1, 10, 5, 10, 187, 8, 10, 10, 10, 12, 10, 190, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 3, 11, 196, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 202, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 214, 8, 14, 1, 14, 1, 14, 3, 14, 218, 8, 14, 1, 14, 1, 14, 3, 14, 222, 8, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 5, 15, 229, 8, 15, 10, 15, 12, 15, 232, 9, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 247, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 3, 21, 261, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 273, 8, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 3, 24, 280, 8, 24, 1, 25, 1, 25, 3, 25, 284, 8, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 3, 28, 294, 8, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 3, 31, 304, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 311, 8, 32, 1, 32, 1, 32, 4, 32, 315, 8, 32, 11, 32, 12, 32, 316, 1, 32, 3, 32, 320, 8, 32, 1, 33, 1, 33, 3, 33, 324, 8, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 332, 8, 34, 10, 34, 12, 34, 335, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 343, 8, 35, 10, 35, 12, 35, 346, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 3, 36, 356, 8, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 3, 38, 363, 8, 38, 1, 38, 5, 38, 366, 8, 38, 10, 38, 12, 38, 369, 9, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 380, 8, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 0, 2, 68, 70, 44, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 0, 3, 2, 0, 4, 6, 47, 47, 1, 0, 43, 46, 1, 0, 11, 12, 407, 0, 89, 1, 0, 0, 0, 2, 94, 1, 0, 0, 0, 4, 110, 1, 0, 0, 0, 6, 113, 1, 0, 0, 0, 8, 124, 1, 0, 0, 0, 10, 146, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 156, 1, 0, 0, 0, 16, 167, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 184, 1, 0, 0, 0, 22, 193, 1, 0, 0, 0, 24, 197, 1, 0, 0, 0, 26, 203, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 226, 1, 0, 0, 0, 32, 233, 1, 0, 0, 0, 34, 239, 1, 0, 0, 0, 36, 246, 1, 0, 0, 0, 38, 248, 1, 0, 0, 0, 40, 252, 1, 0, 0, 0, 42, 260, 1, 0, 0, 0, 44, 272, 1, 0, 0, 0, 46, 274, 1, 0, 0, 0, 48, 279, 1, 0, 0, 0, 50, 283, 1, 0, 0, 0, 52, 285, 1, 0, 0, 0, 54, 288, 1, 0, 0, 0, 56, 293, 1, 0, 0, 0, 58, 295, 1, 0, 0, 0, 60, 298, 1, 0, 0, 0, 62, 303, 1, 0, 0, 0, 64, 319, 1, 0, 0, 0, 66, 323, 1, 0, 0, 0, 68, 325, 1, 0, 0, 0, 70, 336, 1, 0, 0, 0, 72, 355, 1, 0, 0, 0, 74, 357, 1, 0, 0, 0, 76, 362, 1, 0, 0, 0, 78, 379, 1, 0, 0, 0, 80, 383, 1, 0, 0, 0, 82, 389, 1, 0, 0, 0, 84, 391, 1, 0, 0, 0, 86, 393, 1, 0, 0, 0, 88, 90, 3, 2, 1, 0, 89, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 1, 1, 0, 0, 0, 93, 95, 5, 7, 0, 0, 94, 93, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 5, 35, 0, 0, 97, 98, 5, 47, 0, 0, 98, 102, 5, 31, 0, 0, 99, 101, 3, 4, 2, 0, 100, 99, 1, 0, 0, 0, 101, 104, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 105, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 106, 5, 32, 0, 0, 106, 3, 1, 0, 0, 0, 107, 111, 3, 6, 3, 0, 108, 111, 3, 8, 4, 0, 109, 111, 3, 10, 5, 0, 110, 107, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 109, 1, 0, 0, 0, 111, 5, 1, 0, 0, 0, 112, 114, 5, 7, 0, 0, 113, 112, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 5, 47, 0, 0, 116, 118, 5, 29, 0, 0, 117, 119, 3, 12, 6, 0, 118, 117, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 5, 30, 0, 0, 121, 122, 3, 20, 10, 0, 122, 7, 1, 0, 0, 0, 123, 125, 5, 7, 0, 0, 124, 123, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 3, 82, 41, 0, 127, 128, 5, 47, 0, 0, 128, 129, 5, 33, 0, 0, 129, 9, 1, 0, 0, 0, 130, 131, 5, 8, 0, 0, 131, 147, 3, 20, 10, 0, 132, 134, 5, 7, 0, 0, 133, 132, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 137, 1, 0, 0, 0, 135, 138, 3, 82, 41, 0, 136, 138, 5, 3, 0, 0, 137, 135, 1, 0, 0, 0, 137, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 5, 47, 0, 0, 140, 142, 5, 29, 0, 0, 141, 143, 3, 12, 6, 0, 142, 141, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 5, 30, 0, 0, 145, 147, 3, 20, 10, 0, 146, 130, 1, 0, 0, 0, 146, 133, 1, 0, 0, 0, 147, 11, 1, 0, 0, 0, 148, 153, 3, 14, 7, 0, 149, 150, 5, 34, 0, 0, 150, 152, 3, 14, 7, 0, 151, 149, 1, 0, 0, 0, 152, 155, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 153, 154, 1, 0, 0, 0, 154, 13, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 156, 157, 3, 82, 41, 0, 157, 158, 5, 47, 0, 0, 158, 15, 1, 0, 0, 0, 159, 164, 3, 42, 21, 0, 160, 161, 5, 34, 0, 0, 161, 163, 3, 42, 21, 0, 162, 160, 1, 0, 0, 0, 163, 166, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 168, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 167, 159, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 17, 1, 0, 0, 0, 169, 170, 3, 22, 11, 0, 170, 171, 5, 33, 0, 0, 171, 183, 1, 0, 0, 0, 172, 173, 3, 24, 12, 0, 173, 174, 5, 33, 0, 0, 174, 183, 1, 0, 0, 0, 175, 183, 3, 20, 10, 0, 176, 183, 3, 26, 13, 0, 177, 183, 3, 28, 14, 0, 178, 183, 3, 30, 15, 0, 179, 180, 3, 36, 18, 0, 180, 181, 5, 33, 0, 0, 181, 183, 1, 0, 0, 0, 182, 169, 1, 0, 0, 0, 182, 172, 1, 0, 0, 0, 182, 175, 1, 0, 0, 0, 182, 176, 1, 0, 0, 0, 182, 177, 1, 0, 0, 0, 182, 178, 1, 0, 0, 0, 182, 179, 1, 0, 0, 0, 183, 19, 1, 0, 0, 0, 184, 188, 5, 31, 0, 0, 185, 187, 3, 18, 9, 0, 186, 185, 1, 0, 0, 0, 187, 190, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 191, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 191, 192, 5, 32, 0, 0, 192, 21, 1, 0, 0, 0, 193, 195, 5, 41, 0, 0, 194, 196, 3, 42, 21, 0, 195, 194, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 23, 1, 0, 0, 0, 197, 198, 3, 82, 41, 0, 198, 201, 5, 47, 0, 0, 199, 200, 5, 13, 0, 0, 200, 202, 3, 42, 21, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0, 0, 203, 204, 5, 37, 0, 0, 204, 205, 5, 29, 0, 0, 205, 206, 3, 42, 21, 0, 206, 207, 5, 30, 0, 0, 207, 208, 3, 20, 10, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 40, 0, 0, 210, 213, 5, 29, 0, 0, 211, 214, 3, 36, 18, 0, 212, 214, 3, 24, 12, 0, 213, 211, 1, 0, 0, 0, 213, 212, 1, 0, 0, 0, 214, 215, 1, 0, 0, 0, 215, 217, 5, 33, 0, 0, 216, 218, 3, 42, 21, 0, 217, 216, 1, 0, 0, 0, 217, 218, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 221, 5, 33, 0, 0, 220, 222, 3, 36, 18, 0, 221, 220, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 223, 1, 0, 0, 0, 223, 224, 5, 30, 0, 0, 224, 225, 3, 20, 10, 0, 225, 29, 1, 0, 0, 0, 226, 230, 3, 32, 16, 0, 227, 229, 3, 34, 17, 0, 228, 227, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 31, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 5, 38, 0, 0, 234, 235, 5, 29, 0, 0, 235, 236, 3, 42, 21, 0, 236, 237, 5, 30, 0, 0, 237, 238, 3, 20, 10, 0, 238, 33, 1, 0, 0, 0, 239, 240, 5, 39, 0, 0, 240, 241, 3, 20, 10, 0, 241, 35, 1, 0, 0, 0, 242, 247, 3, 38, 19, 0, 243, 247, 3, 40, 20, 0, 244, 247, 3, 76, 38, 0, 245, 247, 3, 48, 24, 0, 246, 242, 1, 0, 0, 0, 246, 243, 1, 0, 0, 0, 246, 244, 1, 0, 0, 0, 246, 245, 1, 0, 0, 0, 247, 37, 1, 0, 0, 0, 248, 249, 3, 62, 31, 0, 249, 250, 5, 13, 0, 0, 250, 251, 3, 42, 21, 0, 251, 39, 1, 0, 0, 0, 252, 253, 5, 42, 0, 0, 253, 254, 5, 47, 0, 0, 254, 255, 5, 29, 0, 0, 255, 256, 3, 16, 8, 0, 256, 257, 5, 30, 0, 0, 257, 41, 1, 0, 0, 0, 258, 261, 3, 44, 22, 0, 259, 261, 3, 66, 33, 0, 260, 258, 1, 0, 0, 0, 260, 259, 1, 0, 0, 0, 261, 43, 1, 0, 0, 0, 262, 273, 5, 36, 0, 0, 263, 273, 5, 47, 0, 0, 264, 273, 3, 64, 32, 0, 265, 273, 3, 84, 42, 0, 266, 273, 3, 46, 23, 0, 267, 273, 3, 36, 18, 0, 268, 269, 5, 29, 0, 0, 269, 270, 3, 42, 21, 0, 270, 271, 5, 30, 0, 0, 271, 273, 1, 0, 0, 0, 272, 262, 1, 0, 0, 0, 272, 263, 1, 0, 0, 0, 272, 264, 1, 0, 0, 0, 272, 265, 1, 0, 0, 0, 272, 266, 1, 0, 0, 0, 272, 267, 1, 0, 0, 0, 272, 268, 1, 0, 0, 0, 273, 45, 1, 0, 0, 0, 274, 275, 5, 25, 0, 0, 275, 276, 3, 42, 21, 0, 276, 47, 1, 0, 0, 0, 277, 280, 3, 50, 25, 0, 278, 280, 3, 56, 28, 0, 279, 277, 1, 0, 0, 0, 279, 278, 1, 0, 0, 0, 280, 49, 1, 0, 0, 0, 281, 284, 3, 52, 26, 0, 282, 284, 3, 54, 27, 0, 283, 281, 1, 0, 0, 0, 283, 282, 1, 0, 0, 0, 284, 51, 1, 0, 0, 0, 285, 286, 5, 1, 0, 0, 286, 287, 3, 62, 31, 0, 287, 53, 1, 0, 0, 0, 288, 289, 3, 62, 31, 0, 289, 290, 5, 1, 0, 0, 290, 55, 1, 0, 0, 0, 291, 294, 3, 58, 29, 0, 292, 294, 3, 60, 30, 0, 293, 291, 1, 0, 0, 0, 293, 292, 1, 0, 0, 0, 294, 57, 1, 0, 0, 0, 295, 296, 5, 2, 0, 0, 296, 297, 3, 62, 31, 0, 297, 59, 1, 0, 0, 0, 298, 299, 3, 62, 31, 0, 299, 300, 5, 2, 0, 0, 300, 61, 1, 0, 0, 0, 301, 304, 5, 47, 0, 0, 302, 304, 3, 64, 32, 0, 303, 301, 1, 0, 0, 0, 303, 302, 1, 0, 0, 0, 304, 63, 1, 0, 0, 0, 305, 306, 5, 36, 0, 0, 306, 307, 5, 28, 0, 0, 307, 320, 5, 47, 0, 0, 308, 309, 5, 36, 0, 0, 309, 311, 5, 28, 0, 0, 310, 308, 1, 0, 0, 0, 310, 311, 1, 0, 0, 0, 311, 314, 1, 0, 0, 0, 312, 313, 5, 47, 0, 0, 313, 315, 5, 28, 0, 0, 314, 312, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 316, 317, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 320, 5, 47, 0, 0, 319, 305, 1, 0, 0, 0, 319, 310, 1, 0, 0, 0, 320, 65, 1, 0, 0, 0, 321, 324, 3, 68, 34, 0, 322, 324, 3, 74, 37, 0, 323, 321, 1, 0, 0, 0, 323, 322, 1, 0, 0, 0, 324, 67, 1, 0, 0, 0, 325, 326, 6, 34, -1, 0, 326, 327, 3, 70, 35, 0, 327, 333, 1, 0, 0, 0, 328, 329, 10, 2, 0, 0, 329, 330, 5, 10, 0, 0, 330, 332, 3, 70, 35, 0, 331, 328, 1, 0, 0, 0, 332, 335, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 333, 334, 1, 0, 0, 0, 334, 69, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 336, 337, 6, 35, -1, 0, 337, 338, 3, 72, 36, 0, 338, 344, 1, 0, 0, 0, 339, 340, 10, 2, 0, 0, 340, 341, 5, 9, 0, 0, 341, 343, 3, 72, 36, 0, 342, 339, 1, 0, 0, 0, 343, 346, 1, 0, 0, 0, 344, 342, 1, 0, 0, 0, 344, 345, 1, 0, 0, 0, 345, 71, 1, 0, 0, 0, 346, 344, 1, 0, 0, 0, 347, 356, 5, 44, 0, 0, 348, 356, 5, 47, 0, 0, 349, 356, 3, 64, 32, 0, 350, 351, 3, 76, 38, 0, 351, 352, 5, 29, 0, 0, 352, 353, 3, 68, 34, 0, 353, 354, 5, 30, 0, 0, 354, 356, 1, 0, 0, 0, 355, 347, 1, 0, 0, 0, 355, 348, 1, 0, 0, 0, 355, 349, 1, 0, 0, 0, 355, 350, 1, 0, 0, 0, 356, 73, 1, 0, 0, 0, 357, 358, 3, 44, 22, 0, 358, 359, 3, 86, 43, 0, 359, 360, 3, 42, 21, 0, 360, 75, 1, 0, 0, 0, 361, 363, 3, 78, 39, 0, 362, 361, 1, 0, 0, 0, 362, 363, 1, 0, 0, 0, 363, 367, 1, 0, 0, 0, 364, 366, 3, 80, 40, 0, 365, 364, 1, 0, 0, 0, 366, 369, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 367, 368, 1, 0, 0, 0, 368, 370, 1, 0, 0, 0, 369, 367, 1, 0, 0, 0, 370, 371, 5, 47, 0, 0, 371, 372, 5, 29, 0, 0, 372, 373, 3, 16, 8, 0, 373, 374, 5, 30, 0, 0, 374, 77, 1, 0, 0, 0, 375, 380, 5, 36, 0, 0, 376, 380, 3, 64, 32, 0, 377, 380, 3, 40, 20, 0, 378, 380, 5, 47, 0, 0, 379, 375, 1, 0, 0, 0, 379, 376, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 379, 378, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 5, 28, 0, 0, 382, 79, 1, 0, 0, 0, 383, 384, 5, 47, 0, 0, 384, 385, 5, 29, 0, 0, 385, 386, 3, 16, 8, 0, 386, 387, 5, 30, 0, 0, 387, 388, 5, 28, 0, 0, 388, 81, 1, 0, 0, 0, 389, 390, 7, 0, 0, 0, 390, 83, 1, 0, 0, 0, 391, 392, 7, 1, 0, 0, 392, 85, 1, 0, 0, 0, 393, 394, 7, 2, 0, 0, 394, 87, 1, 0, 0, 0, 39, 91, 94, 102, 110, 113, 118, 124, 133, 137, 142, 146, 153, 164, 167, 182, 188, 195, 201, 213, 217, 221, 230, 246, 260, 272, 279, 283, 293, 303, 310, 316, 319, 323, 333, 344, 355, 362, 367, 379] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJava.tokens b/src/main/java/parser/generated/SimpleJava.tokens new file mode 100644 index 0000000..bed7437 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJava.tokens @@ -0,0 +1,88 @@ +T__0=1 +T__1=2 +Void=3 +Boolean=4 +Char=5 +Int=6 +AccessModifier=7 +MainMethodDeclaration=8 +DotOperator=9 +LineOperator=10 +ComparisonOperator=11 +LogicalOperator=12 +Assign=13 +Plus=14 +Minus=15 +Mult=16 +Modulo=17 +Div=18 +Greater=19 +Less=20 +GreaterEqual=21 +LessEqual=22 +Equal=23 +NotEqual=24 +Not=25 +And=26 +Or=27 +Dot=28 +OpenRoundBracket=29 +ClosedRoundBracket=30 +OpenCurlyBracket=31 +ClosedCurlyBracket=32 +Semicolon=33 +Comma=34 +Class=35 +This=36 +While=37 +If=38 +Else=39 +For=40 +Return=41 +New=42 +CharValue=43 +IntValue=44 +BooleanValue=45 +NullValue=46 +Identifier=47 +WS=48 +InlineComment=49 +MultilineComment=50 +'++'=1 +'--'=2 +'void'=3 +'boolean'=4 +'char'=5 +'int'=6 +'public static void main(String[] args)'=8 +'='=13 +'+'=14 +'-'=15 +'*'=16 +'%'=17 +'/'=18 +'>'=19 +'<'=20 +'>='=21 +'<='=22 +'=='=23 +'!='=24 +'!'=25 +'&&'=26 +'||'=27 +'.'=28 +'('=29 +')'=30 +'{'=31 +'}'=32 +';'=33 +','=34 +'class'=35 +'this'=36 +'while'=37 +'if'=38 +'else'=39 +'for'=40 +'return'=41 +'new'=42 +'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaBaseListener.java b/src/main/java/parser/generated/SimpleJavaBaseListener.java new file mode 100644 index 0000000..2bf9ddd --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaBaseListener.java @@ -0,0 +1,568 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 +package parser.generated; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link SimpleJavaListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class SimpleJavaBaseListener implements SimpleJavaListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterProgram(SimpleJavaParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitProgram(SimpleJavaParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameterList(SimpleJavaParser.ParameterListContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameterList(SimpleJavaParser.ParameterListContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameter(SimpleJavaParser.ParameterContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameter(SimpleJavaParser.ParameterContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStatement(SimpleJavaParser.StatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStatement(SimpleJavaParser.StatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterForStatement(SimpleJavaParser.ForStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitForStatement(SimpleJavaParser.ForStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssign(SimpleJavaParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssign(SimpleJavaParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExpression(SimpleJavaParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExpression(SimpleJavaParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMethodCall(SimpleJavaParser.MethodCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMethodCall(SimpleJavaParser.MethodCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTarget(SimpleJavaParser.TargetContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTarget(SimpleJavaParser.TargetContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterType(SimpleJavaParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitType(SimpleJavaParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterValue(SimpleJavaParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitValue(SimpleJavaParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaBaseVisitor.java b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java new file mode 100644 index 0000000..92fb64c --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaBaseVisitor.java @@ -0,0 +1,323 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 +package parser.generated; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link SimpleJavaVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class SimpleJavaBaseVisitor extends AbstractParseTreeVisitor implements SimpleJavaVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitProgram(SimpleJavaParser.ProgramContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@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 visitParameterList(SimpleJavaParser.ParameterListContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameter(SimpleJavaParser.ParameterContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStatement(SimpleJavaParser.StatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitForStatement(SimpleJavaParser.ForStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssign(SimpleJavaParser.AssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression(SimpleJavaParser.ExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMethodCall(SimpleJavaParser.MethodCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTarget(SimpleJavaParser.TargetContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitValue(SimpleJavaParser.ValueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.interp b/src/main/java/parser/generated/SimpleJavaLexer.interp new file mode 100644 index 0000000..919e1fd --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaLexer.interp @@ -0,0 +1,170 @@ +token literal names: +null +'++' +'--' +'void' +'boolean' +'char' +'int' +null +'public static void main(String[] args)' +null +null +null +null +'=' +'+' +'-' +'*' +'%' +'/' +'>' +'<' +'>=' +'<=' +'==' +'!=' +'!' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'for' +'return' +'new' +null +null +null +'null' +null +null +null +null + +token symbolic names: +null +null +null +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Identifier +WS +InlineComment +MultilineComment + +rule names: +T__0 +T__1 +Void +Boolean +Char +Int +AccessModifier +MainMethodDeclaration +DotOperator +LineOperator +ComparisonOperator +LogicalOperator +Assign +Plus +Minus +Mult +Modulo +Div +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +For +Return +New +CharValue +IntValue +BooleanValue +NullValue +Alphabetic +Numeric +ValidIdentSymbols +Identifier +WS +InlineComment +MultilineComment + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 50, 408, 6, -1, 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, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 176, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 3, 8, 220, 8, 8, 1, 9, 1, 9, 3, 9, 224, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 3, 10, 232, 8, 10, 1, 11, 1, 11, 3, 11, 236, 8, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 5, 42, 330, 8, 42, 10, 42, 12, 42, 333, 9, 42, 1, 42, 1, 42, 1, 43, 3, 43, 338, 8, 43, 1, 43, 4, 43, 341, 8, 43, 11, 43, 12, 43, 342, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 354, 8, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 3, 48, 368, 8, 48, 1, 49, 1, 49, 5, 49, 372, 8, 49, 10, 49, 12, 49, 375, 9, 49, 1, 50, 4, 50, 378, 8, 50, 11, 50, 12, 50, 379, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 5, 51, 388, 8, 51, 10, 51, 12, 51, 391, 9, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 5, 52, 399, 8, 52, 10, 52, 12, 52, 402, 9, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 400, 0, 53, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 0, 95, 0, 97, 0, 99, 47, 101, 48, 103, 49, 105, 50, 1, 0, 5, 2, 0, 10, 10, 13, 13, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 2, 0, 36, 36, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 426, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 1, 107, 1, 0, 0, 0, 3, 110, 1, 0, 0, 0, 5, 113, 1, 0, 0, 0, 7, 118, 1, 0, 0, 0, 9, 126, 1, 0, 0, 0, 11, 131, 1, 0, 0, 0, 13, 175, 1, 0, 0, 0, 15, 177, 1, 0, 0, 0, 17, 219, 1, 0, 0, 0, 19, 223, 1, 0, 0, 0, 21, 231, 1, 0, 0, 0, 23, 235, 1, 0, 0, 0, 25, 237, 1, 0, 0, 0, 27, 239, 1, 0, 0, 0, 29, 241, 1, 0, 0, 0, 31, 243, 1, 0, 0, 0, 33, 245, 1, 0, 0, 0, 35, 247, 1, 0, 0, 0, 37, 249, 1, 0, 0, 0, 39, 251, 1, 0, 0, 0, 41, 253, 1, 0, 0, 0, 43, 256, 1, 0, 0, 0, 45, 259, 1, 0, 0, 0, 47, 262, 1, 0, 0, 0, 49, 265, 1, 0, 0, 0, 51, 267, 1, 0, 0, 0, 53, 270, 1, 0, 0, 0, 55, 273, 1, 0, 0, 0, 57, 275, 1, 0, 0, 0, 59, 277, 1, 0, 0, 0, 61, 279, 1, 0, 0, 0, 63, 281, 1, 0, 0, 0, 65, 283, 1, 0, 0, 0, 67, 285, 1, 0, 0, 0, 69, 287, 1, 0, 0, 0, 71, 293, 1, 0, 0, 0, 73, 298, 1, 0, 0, 0, 75, 304, 1, 0, 0, 0, 77, 307, 1, 0, 0, 0, 79, 312, 1, 0, 0, 0, 81, 316, 1, 0, 0, 0, 83, 323, 1, 0, 0, 0, 85, 327, 1, 0, 0, 0, 87, 337, 1, 0, 0, 0, 89, 353, 1, 0, 0, 0, 91, 355, 1, 0, 0, 0, 93, 360, 1, 0, 0, 0, 95, 362, 1, 0, 0, 0, 97, 367, 1, 0, 0, 0, 99, 369, 1, 0, 0, 0, 101, 377, 1, 0, 0, 0, 103, 383, 1, 0, 0, 0, 105, 394, 1, 0, 0, 0, 107, 108, 5, 43, 0, 0, 108, 109, 5, 43, 0, 0, 109, 2, 1, 0, 0, 0, 110, 111, 5, 45, 0, 0, 111, 112, 5, 45, 0, 0, 112, 4, 1, 0, 0, 0, 113, 114, 5, 118, 0, 0, 114, 115, 5, 111, 0, 0, 115, 116, 5, 105, 0, 0, 116, 117, 5, 100, 0, 0, 117, 6, 1, 0, 0, 0, 118, 119, 5, 98, 0, 0, 119, 120, 5, 111, 0, 0, 120, 121, 5, 111, 0, 0, 121, 122, 5, 108, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 110, 0, 0, 125, 8, 1, 0, 0, 0, 126, 127, 5, 99, 0, 0, 127, 128, 5, 104, 0, 0, 128, 129, 5, 97, 0, 0, 129, 130, 5, 114, 0, 0, 130, 10, 1, 0, 0, 0, 131, 132, 5, 105, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 116, 0, 0, 134, 12, 1, 0, 0, 0, 135, 136, 5, 112, 0, 0, 136, 137, 5, 117, 0, 0, 137, 138, 5, 98, 0, 0, 138, 139, 5, 108, 0, 0, 139, 140, 5, 105, 0, 0, 140, 176, 5, 99, 0, 0, 141, 142, 5, 112, 0, 0, 142, 143, 5, 114, 0, 0, 143, 144, 5, 105, 0, 0, 144, 145, 5, 118, 0, 0, 145, 146, 5, 97, 0, 0, 146, 147, 5, 116, 0, 0, 147, 176, 5, 101, 0, 0, 148, 149, 5, 112, 0, 0, 149, 150, 5, 117, 0, 0, 150, 151, 5, 98, 0, 0, 151, 152, 5, 108, 0, 0, 152, 153, 5, 105, 0, 0, 153, 154, 5, 99, 0, 0, 154, 155, 5, 32, 0, 0, 155, 156, 5, 115, 0, 0, 156, 157, 5, 116, 0, 0, 157, 158, 5, 97, 0, 0, 158, 159, 5, 116, 0, 0, 159, 160, 5, 105, 0, 0, 160, 176, 5, 99, 0, 0, 161, 162, 5, 112, 0, 0, 162, 163, 5, 114, 0, 0, 163, 164, 5, 105, 0, 0, 164, 165, 5, 118, 0, 0, 165, 166, 5, 97, 0, 0, 166, 167, 5, 116, 0, 0, 167, 168, 5, 101, 0, 0, 168, 169, 5, 32, 0, 0, 169, 170, 5, 115, 0, 0, 170, 171, 5, 116, 0, 0, 171, 172, 5, 97, 0, 0, 172, 173, 5, 116, 0, 0, 173, 174, 5, 105, 0, 0, 174, 176, 5, 99, 0, 0, 175, 135, 1, 0, 0, 0, 175, 141, 1, 0, 0, 0, 175, 148, 1, 0, 0, 0, 175, 161, 1, 0, 0, 0, 176, 14, 1, 0, 0, 0, 177, 178, 5, 112, 0, 0, 178, 179, 5, 117, 0, 0, 179, 180, 5, 98, 0, 0, 180, 181, 5, 108, 0, 0, 181, 182, 5, 105, 0, 0, 182, 183, 5, 99, 0, 0, 183, 184, 5, 32, 0, 0, 184, 185, 5, 115, 0, 0, 185, 186, 5, 116, 0, 0, 186, 187, 5, 97, 0, 0, 187, 188, 5, 116, 0, 0, 188, 189, 5, 105, 0, 0, 189, 190, 5, 99, 0, 0, 190, 191, 5, 32, 0, 0, 191, 192, 5, 118, 0, 0, 192, 193, 5, 111, 0, 0, 193, 194, 5, 105, 0, 0, 194, 195, 5, 100, 0, 0, 195, 196, 5, 32, 0, 0, 196, 197, 5, 109, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, 105, 0, 0, 199, 200, 5, 110, 0, 0, 200, 201, 5, 40, 0, 0, 201, 202, 5, 83, 0, 0, 202, 203, 5, 116, 0, 0, 203, 204, 5, 114, 0, 0, 204, 205, 5, 105, 0, 0, 205, 206, 5, 110, 0, 0, 206, 207, 5, 103, 0, 0, 207, 208, 5, 91, 0, 0, 208, 209, 5, 93, 0, 0, 209, 210, 5, 32, 0, 0, 210, 211, 5, 97, 0, 0, 211, 212, 5, 114, 0, 0, 212, 213, 5, 103, 0, 0, 213, 214, 5, 115, 0, 0, 214, 215, 5, 41, 0, 0, 215, 16, 1, 0, 0, 0, 216, 220, 3, 31, 15, 0, 217, 220, 3, 35, 17, 0, 218, 220, 3, 33, 16, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 218, 1, 0, 0, 0, 220, 18, 1, 0, 0, 0, 221, 224, 3, 27, 13, 0, 222, 224, 3, 29, 14, 0, 223, 221, 1, 0, 0, 0, 223, 222, 1, 0, 0, 0, 224, 20, 1, 0, 0, 0, 225, 232, 3, 37, 18, 0, 226, 232, 3, 39, 19, 0, 227, 232, 3, 41, 20, 0, 228, 232, 3, 43, 21, 0, 229, 232, 3, 45, 22, 0, 230, 232, 3, 47, 23, 0, 231, 225, 1, 0, 0, 0, 231, 226, 1, 0, 0, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 22, 1, 0, 0, 0, 233, 236, 3, 51, 25, 0, 234, 236, 3, 53, 26, 0, 235, 233, 1, 0, 0, 0, 235, 234, 1, 0, 0, 0, 236, 24, 1, 0, 0, 0, 237, 238, 5, 61, 0, 0, 238, 26, 1, 0, 0, 0, 239, 240, 5, 43, 0, 0, 240, 28, 1, 0, 0, 0, 241, 242, 5, 45, 0, 0, 242, 30, 1, 0, 0, 0, 243, 244, 5, 42, 0, 0, 244, 32, 1, 0, 0, 0, 245, 246, 5, 37, 0, 0, 246, 34, 1, 0, 0, 0, 247, 248, 5, 47, 0, 0, 248, 36, 1, 0, 0, 0, 249, 250, 5, 62, 0, 0, 250, 38, 1, 0, 0, 0, 251, 252, 5, 60, 0, 0, 252, 40, 1, 0, 0, 0, 253, 254, 5, 62, 0, 0, 254, 255, 5, 61, 0, 0, 255, 42, 1, 0, 0, 0, 256, 257, 5, 60, 0, 0, 257, 258, 5, 61, 0, 0, 258, 44, 1, 0, 0, 0, 259, 260, 5, 61, 0, 0, 260, 261, 5, 61, 0, 0, 261, 46, 1, 0, 0, 0, 262, 263, 5, 33, 0, 0, 263, 264, 5, 61, 0, 0, 264, 48, 1, 0, 0, 0, 265, 266, 5, 33, 0, 0, 266, 50, 1, 0, 0, 0, 267, 268, 5, 38, 0, 0, 268, 269, 5, 38, 0, 0, 269, 52, 1, 0, 0, 0, 270, 271, 5, 124, 0, 0, 271, 272, 5, 124, 0, 0, 272, 54, 1, 0, 0, 0, 273, 274, 5, 46, 0, 0, 274, 56, 1, 0, 0, 0, 275, 276, 5, 40, 0, 0, 276, 58, 1, 0, 0, 0, 277, 278, 5, 41, 0, 0, 278, 60, 1, 0, 0, 0, 279, 280, 5, 123, 0, 0, 280, 62, 1, 0, 0, 0, 281, 282, 5, 125, 0, 0, 282, 64, 1, 0, 0, 0, 283, 284, 5, 59, 0, 0, 284, 66, 1, 0, 0, 0, 285, 286, 5, 44, 0, 0, 286, 68, 1, 0, 0, 0, 287, 288, 5, 99, 0, 0, 288, 289, 5, 108, 0, 0, 289, 290, 5, 97, 0, 0, 290, 291, 5, 115, 0, 0, 291, 292, 5, 115, 0, 0, 292, 70, 1, 0, 0, 0, 293, 294, 5, 116, 0, 0, 294, 295, 5, 104, 0, 0, 295, 296, 5, 105, 0, 0, 296, 297, 5, 115, 0, 0, 297, 72, 1, 0, 0, 0, 298, 299, 5, 119, 0, 0, 299, 300, 5, 104, 0, 0, 300, 301, 5, 105, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 101, 0, 0, 303, 74, 1, 0, 0, 0, 304, 305, 5, 105, 0, 0, 305, 306, 5, 102, 0, 0, 306, 76, 1, 0, 0, 0, 307, 308, 5, 101, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 115, 0, 0, 310, 311, 5, 101, 0, 0, 311, 78, 1, 0, 0, 0, 312, 313, 5, 102, 0, 0, 313, 314, 5, 111, 0, 0, 314, 315, 5, 114, 0, 0, 315, 80, 1, 0, 0, 0, 316, 317, 5, 114, 0, 0, 317, 318, 5, 101, 0, 0, 318, 319, 5, 116, 0, 0, 319, 320, 5, 117, 0, 0, 320, 321, 5, 114, 0, 0, 321, 322, 5, 110, 0, 0, 322, 82, 1, 0, 0, 0, 323, 324, 5, 110, 0, 0, 324, 325, 5, 101, 0, 0, 325, 326, 5, 119, 0, 0, 326, 84, 1, 0, 0, 0, 327, 331, 5, 39, 0, 0, 328, 330, 8, 0, 0, 0, 329, 328, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 334, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 39, 0, 0, 335, 86, 1, 0, 0, 0, 336, 338, 3, 29, 14, 0, 337, 336, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 340, 1, 0, 0, 0, 339, 341, 3, 95, 47, 0, 340, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 340, 1, 0, 0, 0, 342, 343, 1, 0, 0, 0, 343, 88, 1, 0, 0, 0, 344, 345, 5, 116, 0, 0, 345, 346, 5, 114, 0, 0, 346, 347, 5, 117, 0, 0, 347, 354, 5, 101, 0, 0, 348, 349, 5, 102, 0, 0, 349, 350, 5, 97, 0, 0, 350, 351, 5, 108, 0, 0, 351, 352, 5, 115, 0, 0, 352, 354, 5, 101, 0, 0, 353, 344, 1, 0, 0, 0, 353, 348, 1, 0, 0, 0, 354, 90, 1, 0, 0, 0, 355, 356, 5, 110, 0, 0, 356, 357, 5, 117, 0, 0, 357, 358, 5, 108, 0, 0, 358, 359, 5, 108, 0, 0, 359, 92, 1, 0, 0, 0, 360, 361, 7, 1, 0, 0, 361, 94, 1, 0, 0, 0, 362, 363, 7, 2, 0, 0, 363, 96, 1, 0, 0, 0, 364, 368, 3, 93, 46, 0, 365, 368, 3, 95, 47, 0, 366, 368, 7, 3, 0, 0, 367, 364, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 367, 366, 1, 0, 0, 0, 368, 98, 1, 0, 0, 0, 369, 373, 3, 93, 46, 0, 370, 372, 3, 97, 48, 0, 371, 370, 1, 0, 0, 0, 372, 375, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 373, 374, 1, 0, 0, 0, 374, 100, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 376, 378, 7, 4, 0, 0, 377, 376, 1, 0, 0, 0, 378, 379, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 6, 50, 0, 0, 382, 102, 1, 0, 0, 0, 383, 384, 5, 47, 0, 0, 384, 385, 5, 47, 0, 0, 385, 389, 1, 0, 0, 0, 386, 388, 8, 0, 0, 0, 387, 386, 1, 0, 0, 0, 388, 391, 1, 0, 0, 0, 389, 387, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 392, 1, 0, 0, 0, 391, 389, 1, 0, 0, 0, 392, 393, 6, 51, 0, 0, 393, 104, 1, 0, 0, 0, 394, 395, 5, 47, 0, 0, 395, 396, 5, 42, 0, 0, 396, 400, 1, 0, 0, 0, 397, 399, 9, 0, 0, 0, 398, 397, 1, 0, 0, 0, 399, 402, 1, 0, 0, 0, 400, 401, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 403, 1, 0, 0, 0, 402, 400, 1, 0, 0, 0, 403, 404, 5, 42, 0, 0, 404, 405, 5, 47, 0, 0, 405, 406, 1, 0, 0, 0, 406, 407, 6, 52, 0, 0, 407, 106, 1, 0, 0, 0, 15, 0, 175, 219, 223, 231, 235, 331, 337, 342, 353, 367, 373, 379, 389, 400, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.java b/src/main/java/parser/generated/SimpleJavaLexer.java new file mode 100644 index 0000000..cb01452 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaLexer.java @@ -0,0 +1,394 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 +package parser.generated; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class SimpleJavaLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, + DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, + Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, + Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, + And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, + ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, + If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, + BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, + MultilineComment=50; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "Void", "Boolean", "Char", "Int", "AccessModifier", "MainMethodDeclaration", + "DotOperator", "LineOperator", "ComparisonOperator", "LogicalOperator", + "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", "Greater", "Less", + "GreaterEqual", "LessEqual", "Equal", "NotEqual", "Not", "And", "Or", + "Dot", "OpenRoundBracket", "ClosedRoundBracket", "OpenCurlyBracket", + "ClosedCurlyBracket", "Semicolon", "Comma", "Class", "This", "While", + "If", "Else", "For", "Return", "New", "CharValue", "IntValue", "BooleanValue", + "NullValue", "Alphabetic", "Numeric", "ValidIdentSymbols", "Identifier", + "WS", "InlineComment", "MultilineComment" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, + "'public static void main(String[] args)'", null, null, null, null, "'='", + "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", + "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", + "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", + "'new'", null, null, null, "'null'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", + "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", + "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", + "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", + "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", + "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public SimpleJavaLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "SimpleJava.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u00002\u0198\u0006\uffff\uffff\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\u0002\u0014\u0007\u0014\u0002"+ + "\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ + "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ + "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ + "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ + "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ + "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ + "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+ + "0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u0001\u0000"+ + "\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0003\u0006\u00b0\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\b\u0001\b\u0001\b\u0003\b\u00dc\b\b\u0001\t\u0001\t\u0003\t\u00e0"+ + "\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003\n\u00e8\b\n"+ + "\u0001\u000b\u0001\u000b\u0003\u000b\u00ec\b\u000b\u0001\f\u0001\f\u0001"+ + "\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+ + "\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+ + "\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+ + "\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017"+ + "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ + "\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001c"+ + "\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f"+ + "\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001$\u0001"+ + "$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001"+ + "&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001"+ + "(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0005*\u014a"+ + "\b*\n*\f*\u014d\t*\u0001*\u0001*\u0001+\u0003+\u0152\b+\u0001+\u0004+"+ + "\u0155\b+\u000b+\f+\u0156\u0001,\u0001,\u0001,\u0001,\u0001,\u0001,\u0001"+ + ",\u0001,\u0001,\u0003,\u0162\b,\u0001-\u0001-\u0001-\u0001-\u0001-\u0001"+ + ".\u0001.\u0001/\u0001/\u00010\u00010\u00010\u00030\u0170\b0\u00011\u0001"+ + "1\u00051\u0174\b1\n1\f1\u0177\t1\u00012\u00042\u017a\b2\u000b2\f2\u017b"+ + "\u00012\u00012\u00013\u00013\u00013\u00013\u00053\u0184\b3\n3\f3\u0187"+ + "\t3\u00013\u00013\u00014\u00014\u00014\u00014\u00054\u018f\b4\n4\f4\u0192"+ + "\t4\u00014\u00014\u00014\u00014\u00014\u0001\u0190\u00005\u0001\u0001"+ + "\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+ + "\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f"+ + "\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u0018"+ + "1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\'O("+ + "Q)S*U+W,Y-[.]\u0000_\u0000a\u0000c/e0g1i2\u0001\u0000\u0005\u0002\u0000"+ + "\n\n\r\r\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0003\u0000\t\n"+ + "\r\r \u01aa\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000"+ + "\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000"+ + "\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000"+ + "\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000"+ + "\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000"+ + "\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000"+ + "\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000"+ + "\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000"+ + "\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%"+ + "\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+ + "\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000"+ + "\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u0000"+ + "3\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001"+ + "\u0000\u0000\u0000\u00009\u0001\u0000\u0000\u0000\u0000;\u0001\u0000\u0000"+ + "\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001\u0000\u0000\u0000\u0000"+ + "A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+ + "\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+ + "\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+ + "O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+ + "\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+ + "\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+ + "c\u0001\u0000\u0000\u0000\u0000e\u0001\u0000\u0000\u0000\u0000g\u0001"+ + "\u0000\u0000\u0000\u0000i\u0001\u0000\u0000\u0000\u0001k\u0001\u0000\u0000"+ + "\u0000\u0003n\u0001\u0000\u0000\u0000\u0005q\u0001\u0000\u0000\u0000\u0007"+ + "v\u0001\u0000\u0000\u0000\t~\u0001\u0000\u0000\u0000\u000b\u0083\u0001"+ + "\u0000\u0000\u0000\r\u00af\u0001\u0000\u0000\u0000\u000f\u00b1\u0001\u0000"+ + "\u0000\u0000\u0011\u00db\u0001\u0000\u0000\u0000\u0013\u00df\u0001\u0000"+ + "\u0000\u0000\u0015\u00e7\u0001\u0000\u0000\u0000\u0017\u00eb\u0001\u0000"+ + "\u0000\u0000\u0019\u00ed\u0001\u0000\u0000\u0000\u001b\u00ef\u0001\u0000"+ + "\u0000\u0000\u001d\u00f1\u0001\u0000\u0000\u0000\u001f\u00f3\u0001\u0000"+ + "\u0000\u0000!\u00f5\u0001\u0000\u0000\u0000#\u00f7\u0001\u0000\u0000\u0000"+ + "%\u00f9\u0001\u0000\u0000\u0000\'\u00fb\u0001\u0000\u0000\u0000)\u00fd"+ + "\u0001\u0000\u0000\u0000+\u0100\u0001\u0000\u0000\u0000-\u0103\u0001\u0000"+ + "\u0000\u0000/\u0106\u0001\u0000\u0000\u00001\u0109\u0001\u0000\u0000\u0000"+ + "3\u010b\u0001\u0000\u0000\u00005\u010e\u0001\u0000\u0000\u00007\u0111"+ + "\u0001\u0000\u0000\u00009\u0113\u0001\u0000\u0000\u0000;\u0115\u0001\u0000"+ + "\u0000\u0000=\u0117\u0001\u0000\u0000\u0000?\u0119\u0001\u0000\u0000\u0000"+ + "A\u011b\u0001\u0000\u0000\u0000C\u011d\u0001\u0000\u0000\u0000E\u011f"+ + "\u0001\u0000\u0000\u0000G\u0125\u0001\u0000\u0000\u0000I\u012a\u0001\u0000"+ + "\u0000\u0000K\u0130\u0001\u0000\u0000\u0000M\u0133\u0001\u0000\u0000\u0000"+ + "O\u0138\u0001\u0000\u0000\u0000Q\u013c\u0001\u0000\u0000\u0000S\u0143"+ + "\u0001\u0000\u0000\u0000U\u0147\u0001\u0000\u0000\u0000W\u0151\u0001\u0000"+ + "\u0000\u0000Y\u0161\u0001\u0000\u0000\u0000[\u0163\u0001\u0000\u0000\u0000"+ + "]\u0168\u0001\u0000\u0000\u0000_\u016a\u0001\u0000\u0000\u0000a\u016f"+ + "\u0001\u0000\u0000\u0000c\u0171\u0001\u0000\u0000\u0000e\u0179\u0001\u0000"+ + "\u0000\u0000g\u017f\u0001\u0000\u0000\u0000i\u018a\u0001\u0000\u0000\u0000"+ + "kl\u0005+\u0000\u0000lm\u0005+\u0000\u0000m\u0002\u0001\u0000\u0000\u0000"+ + "no\u0005-\u0000\u0000op\u0005-\u0000\u0000p\u0004\u0001\u0000\u0000\u0000"+ + "qr\u0005v\u0000\u0000rs\u0005o\u0000\u0000st\u0005i\u0000\u0000tu\u0005"+ + "d\u0000\u0000u\u0006\u0001\u0000\u0000\u0000vw\u0005b\u0000\u0000wx\u0005"+ + "o\u0000\u0000xy\u0005o\u0000\u0000yz\u0005l\u0000\u0000z{\u0005e\u0000"+ + "\u0000{|\u0005a\u0000\u0000|}\u0005n\u0000\u0000}\b\u0001\u0000\u0000"+ + "\u0000~\u007f\u0005c\u0000\u0000\u007f\u0080\u0005h\u0000\u0000\u0080"+ + "\u0081\u0005a\u0000\u0000\u0081\u0082\u0005r\u0000\u0000\u0082\n\u0001"+ + "\u0000\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+ + "\u0000\u0085\u0086\u0005t\u0000\u0000\u0086\f\u0001\u0000\u0000\u0000"+ + "\u0087\u0088\u0005p\u0000\u0000\u0088\u0089\u0005u\u0000\u0000\u0089\u008a"+ + "\u0005b\u0000\u0000\u008a\u008b\u0005l\u0000\u0000\u008b\u008c\u0005i"+ + "\u0000\u0000\u008c\u00b0\u0005c\u0000\u0000\u008d\u008e\u0005p\u0000\u0000"+ + "\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005i\u0000\u0000\u0090\u0091"+ + "\u0005v\u0000\u0000\u0091\u0092\u0005a\u0000\u0000\u0092\u0093\u0005t"+ + "\u0000\u0000\u0093\u00b0\u0005e\u0000\u0000\u0094\u0095\u0005p\u0000\u0000"+ + "\u0095\u0096\u0005u\u0000\u0000\u0096\u0097\u0005b\u0000\u0000\u0097\u0098"+ + "\u0005l\u0000\u0000\u0098\u0099\u0005i\u0000\u0000\u0099\u009a\u0005c"+ + "\u0000\u0000\u009a\u009b\u0005 \u0000\u0000\u009b\u009c\u0005s\u0000\u0000"+ + "\u009c\u009d\u0005t\u0000\u0000\u009d\u009e\u0005a\u0000\u0000\u009e\u009f"+ + "\u0005t\u0000\u0000\u009f\u00a0\u0005i\u0000\u0000\u00a0\u00b0\u0005c"+ + "\u0000\u0000\u00a1\u00a2\u0005p\u0000\u0000\u00a2\u00a3\u0005r\u0000\u0000"+ + "\u00a3\u00a4\u0005i\u0000\u0000\u00a4\u00a5\u0005v\u0000\u0000\u00a5\u00a6"+ + "\u0005a\u0000\u0000\u00a6\u00a7\u0005t\u0000\u0000\u00a7\u00a8\u0005e"+ + "\u0000\u0000\u00a8\u00a9\u0005 \u0000\u0000\u00a9\u00aa\u0005s\u0000\u0000"+ + "\u00aa\u00ab\u0005t\u0000\u0000\u00ab\u00ac\u0005a\u0000\u0000\u00ac\u00ad"+ + "\u0005t\u0000\u0000\u00ad\u00ae\u0005i\u0000\u0000\u00ae\u00b0\u0005c"+ + "\u0000\u0000\u00af\u0087\u0001\u0000\u0000\u0000\u00af\u008d\u0001\u0000"+ + "\u0000\u0000\u00af\u0094\u0001\u0000\u0000\u0000\u00af\u00a1\u0001\u0000"+ + "\u0000\u0000\u00b0\u000e\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005p\u0000"+ + "\u0000\u00b2\u00b3\u0005u\u0000\u0000\u00b3\u00b4\u0005b\u0000\u0000\u00b4"+ + "\u00b5\u0005l\u0000\u0000\u00b5\u00b6\u0005i\u0000\u0000\u00b6\u00b7\u0005"+ + "c\u0000\u0000\u00b7\u00b8\u0005 \u0000\u0000\u00b8\u00b9\u0005s\u0000"+ + "\u0000\u00b9\u00ba\u0005t\u0000\u0000\u00ba\u00bb\u0005a\u0000\u0000\u00bb"+ + "\u00bc\u0005t\u0000\u0000\u00bc\u00bd\u0005i\u0000\u0000\u00bd\u00be\u0005"+ + "c\u0000\u0000\u00be\u00bf\u0005 \u0000\u0000\u00bf\u00c0\u0005v\u0000"+ + "\u0000\u00c0\u00c1\u0005o\u0000\u0000\u00c1\u00c2\u0005i\u0000\u0000\u00c2"+ + "\u00c3\u0005d\u0000\u0000\u00c3\u00c4\u0005 \u0000\u0000\u00c4\u00c5\u0005"+ + "m\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6\u00c7\u0005i\u0000"+ + "\u0000\u00c7\u00c8\u0005n\u0000\u0000\u00c8\u00c9\u0005(\u0000\u0000\u00c9"+ + "\u00ca\u0005S\u0000\u0000\u00ca\u00cb\u0005t\u0000\u0000\u00cb\u00cc\u0005"+ + "r\u0000\u0000\u00cc\u00cd\u0005i\u0000\u0000\u00cd\u00ce\u0005n\u0000"+ + "\u0000\u00ce\u00cf\u0005g\u0000\u0000\u00cf\u00d0\u0005[\u0000\u0000\u00d0"+ + "\u00d1\u0005]\u0000\u0000\u00d1\u00d2\u0005 \u0000\u0000\u00d2\u00d3\u0005"+ + "a\u0000\u0000\u00d3\u00d4\u0005r\u0000\u0000\u00d4\u00d5\u0005g\u0000"+ + "\u0000\u00d5\u00d6\u0005s\u0000\u0000\u00d6\u00d7\u0005)\u0000\u0000\u00d7"+ + "\u0010\u0001\u0000\u0000\u0000\u00d8\u00dc\u0003\u001f\u000f\u0000\u00d9"+ + "\u00dc\u0003#\u0011\u0000\u00da\u00dc\u0003!\u0010\u0000\u00db\u00d8\u0001"+ + "\u0000\u0000\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00db\u00da\u0001"+ + "\u0000\u0000\u0000\u00dc\u0012\u0001\u0000\u0000\u0000\u00dd\u00e0\u0003"+ + "\u001b\r\u0000\u00de\u00e0\u0003\u001d\u000e\u0000\u00df\u00dd\u0001\u0000"+ + "\u0000\u0000\u00df\u00de\u0001\u0000\u0000\u0000\u00e0\u0014\u0001\u0000"+ + "\u0000\u0000\u00e1\u00e8\u0003%\u0012\u0000\u00e2\u00e8\u0003\'\u0013"+ + "\u0000\u00e3\u00e8\u0003)\u0014\u0000\u00e4\u00e8\u0003+\u0015\u0000\u00e5"+ + "\u00e8\u0003-\u0016\u0000\u00e6\u00e8\u0003/\u0017\u0000\u00e7\u00e1\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e2\u0001\u0000\u0000\u0000\u00e7\u00e3\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e4\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e6\u0001\u0000\u0000\u0000\u00e8\u0016\u0001"+ + "\u0000\u0000\u0000\u00e9\u00ec\u00033\u0019\u0000\u00ea\u00ec\u00035\u001a"+ + "\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb\u00ea\u0001\u0000\u0000"+ + "\u0000\u00ec\u0018\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005=\u0000\u0000"+ + "\u00ee\u001a\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005+\u0000\u0000\u00f0"+ + "\u001c\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005-\u0000\u0000\u00f2\u001e"+ + "\u0001\u0000\u0000\u0000\u00f3\u00f4\u0005*\u0000\u0000\u00f4 \u0001\u0000"+ + "\u0000\u0000\u00f5\u00f6\u0005%\u0000\u0000\u00f6\"\u0001\u0000\u0000"+ + "\u0000\u00f7\u00f8\u0005/\u0000\u0000\u00f8$\u0001\u0000\u0000\u0000\u00f9"+ + "\u00fa\u0005>\u0000\u0000\u00fa&\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005"+ + "<\u0000\u0000\u00fc(\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005>\u0000"+ + "\u0000\u00fe\u00ff\u0005=\u0000\u0000\u00ff*\u0001\u0000\u0000\u0000\u0100"+ + "\u0101\u0005<\u0000\u0000\u0101\u0102\u0005=\u0000\u0000\u0102,\u0001"+ + "\u0000\u0000\u0000\u0103\u0104\u0005=\u0000\u0000\u0104\u0105\u0005=\u0000"+ + "\u0000\u0105.\u0001\u0000\u0000\u0000\u0106\u0107\u0005!\u0000\u0000\u0107"+ + "\u0108\u0005=\u0000\u0000\u01080\u0001\u0000\u0000\u0000\u0109\u010a\u0005"+ + "!\u0000\u0000\u010a2\u0001\u0000\u0000\u0000\u010b\u010c\u0005&\u0000"+ + "\u0000\u010c\u010d\u0005&\u0000\u0000\u010d4\u0001\u0000\u0000\u0000\u010e"+ + "\u010f\u0005|\u0000\u0000\u010f\u0110\u0005|\u0000\u0000\u01106\u0001"+ + "\u0000\u0000\u0000\u0111\u0112\u0005.\u0000\u0000\u01128\u0001\u0000\u0000"+ + "\u0000\u0113\u0114\u0005(\u0000\u0000\u0114:\u0001\u0000\u0000\u0000\u0115"+ + "\u0116\u0005)\u0000\u0000\u0116<\u0001\u0000\u0000\u0000\u0117\u0118\u0005"+ + "{\u0000\u0000\u0118>\u0001\u0000\u0000\u0000\u0119\u011a\u0005}\u0000"+ + "\u0000\u011a@\u0001\u0000\u0000\u0000\u011b\u011c\u0005;\u0000\u0000\u011c"+ + "B\u0001\u0000\u0000\u0000\u011d\u011e\u0005,\u0000\u0000\u011eD\u0001"+ + "\u0000\u0000\u0000\u011f\u0120\u0005c\u0000\u0000\u0120\u0121\u0005l\u0000"+ + "\u0000\u0121\u0122\u0005a\u0000\u0000\u0122\u0123\u0005s\u0000\u0000\u0123"+ + "\u0124\u0005s\u0000\u0000\u0124F\u0001\u0000\u0000\u0000\u0125\u0126\u0005"+ + "t\u0000\u0000\u0126\u0127\u0005h\u0000\u0000\u0127\u0128\u0005i\u0000"+ + "\u0000\u0128\u0129\u0005s\u0000\u0000\u0129H\u0001\u0000\u0000\u0000\u012a"+ + "\u012b\u0005w\u0000\u0000\u012b\u012c\u0005h\u0000\u0000\u012c\u012d\u0005"+ + "i\u0000\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005e\u0000"+ + "\u0000\u012fJ\u0001\u0000\u0000\u0000\u0130\u0131\u0005i\u0000\u0000\u0131"+ + "\u0132\u0005f\u0000\u0000\u0132L\u0001\u0000\u0000\u0000\u0133\u0134\u0005"+ + "e\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136\u0005s\u0000"+ + "\u0000\u0136\u0137\u0005e\u0000\u0000\u0137N\u0001\u0000\u0000\u0000\u0138"+ + "\u0139\u0005f\u0000\u0000\u0139\u013a\u0005o\u0000\u0000\u013a\u013b\u0005"+ + "r\u0000\u0000\u013bP\u0001\u0000\u0000\u0000\u013c\u013d\u0005r\u0000"+ + "\u0000\u013d\u013e\u0005e\u0000\u0000\u013e\u013f\u0005t\u0000\u0000\u013f"+ + "\u0140\u0005u\u0000\u0000\u0140\u0141\u0005r\u0000\u0000\u0141\u0142\u0005"+ + "n\u0000\u0000\u0142R\u0001\u0000\u0000\u0000\u0143\u0144\u0005n\u0000"+ + "\u0000\u0144\u0145\u0005e\u0000\u0000\u0145\u0146\u0005w\u0000\u0000\u0146"+ + "T\u0001\u0000\u0000\u0000\u0147\u014b\u0005\'\u0000\u0000\u0148\u014a"+ + "\b\u0000\u0000\u0000\u0149\u0148\u0001\u0000\u0000\u0000\u014a\u014d\u0001"+ + "\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000\u014b\u014c\u0001"+ + "\u0000\u0000\u0000\u014c\u014e\u0001\u0000\u0000\u0000\u014d\u014b\u0001"+ + "\u0000\u0000\u0000\u014e\u014f\u0005\'\u0000\u0000\u014fV\u0001\u0000"+ + "\u0000\u0000\u0150\u0152\u0003\u001d\u000e\u0000\u0151\u0150\u0001\u0000"+ + "\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u0154\u0001\u0000"+ + "\u0000\u0000\u0153\u0155\u0003_/\u0000\u0154\u0153\u0001\u0000\u0000\u0000"+ + "\u0155\u0156\u0001\u0000\u0000\u0000\u0156\u0154\u0001\u0000\u0000\u0000"+ + "\u0156\u0157\u0001\u0000\u0000\u0000\u0157X\u0001\u0000\u0000\u0000\u0158"+ + "\u0159\u0005t\u0000\u0000\u0159\u015a\u0005r\u0000\u0000\u015a\u015b\u0005"+ + "u\u0000\u0000\u015b\u0162\u0005e\u0000\u0000\u015c\u015d\u0005f\u0000"+ + "\u0000\u015d\u015e\u0005a\u0000\u0000\u015e\u015f\u0005l\u0000\u0000\u015f"+ + "\u0160\u0005s\u0000\u0000\u0160\u0162\u0005e\u0000\u0000\u0161\u0158\u0001"+ + "\u0000\u0000\u0000\u0161\u015c\u0001\u0000\u0000\u0000\u0162Z\u0001\u0000"+ + "\u0000\u0000\u0163\u0164\u0005n\u0000\u0000\u0164\u0165\u0005u\u0000\u0000"+ + "\u0165\u0166\u0005l\u0000\u0000\u0166\u0167\u0005l\u0000\u0000\u0167\\"+ + "\u0001\u0000\u0000\u0000\u0168\u0169\u0007\u0001\u0000\u0000\u0169^\u0001"+ + "\u0000\u0000\u0000\u016a\u016b\u0007\u0002\u0000\u0000\u016b`\u0001\u0000"+ + "\u0000\u0000\u016c\u0170\u0003].\u0000\u016d\u0170\u0003_/\u0000\u016e"+ + "\u0170\u0007\u0003\u0000\u0000\u016f\u016c\u0001\u0000\u0000\u0000\u016f"+ + "\u016d\u0001\u0000\u0000\u0000\u016f\u016e\u0001\u0000\u0000\u0000\u0170"+ + "b\u0001\u0000\u0000\u0000\u0171\u0175\u0003].\u0000\u0172\u0174\u0003"+ + "a0\u0000\u0173\u0172\u0001\u0000\u0000\u0000\u0174\u0177\u0001\u0000\u0000"+ + "\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0176\u0001\u0000\u0000"+ + "\u0000\u0176d\u0001\u0000\u0000\u0000\u0177\u0175\u0001\u0000\u0000\u0000"+ + "\u0178\u017a\u0007\u0004\u0000\u0000\u0179\u0178\u0001\u0000\u0000\u0000"+ + "\u017a\u017b\u0001\u0000\u0000\u0000\u017b\u0179\u0001\u0000\u0000\u0000"+ + "\u017b\u017c\u0001\u0000\u0000\u0000\u017c\u017d\u0001\u0000\u0000\u0000"+ + "\u017d\u017e\u00062\u0000\u0000\u017ef\u0001\u0000\u0000\u0000\u017f\u0180"+ + "\u0005/\u0000\u0000\u0180\u0181\u0005/\u0000\u0000\u0181\u0185\u0001\u0000"+ + "\u0000\u0000\u0182\u0184\b\u0000\u0000\u0000\u0183\u0182\u0001\u0000\u0000"+ + "\u0000\u0184\u0187\u0001\u0000\u0000\u0000\u0185\u0183\u0001\u0000\u0000"+ + "\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0188\u0001\u0000\u0000"+ + "\u0000\u0187\u0185\u0001\u0000\u0000\u0000\u0188\u0189\u00063\u0000\u0000"+ + "\u0189h\u0001\u0000\u0000\u0000\u018a\u018b\u0005/\u0000\u0000\u018b\u018c"+ + "\u0005*\u0000\u0000\u018c\u0190\u0001\u0000\u0000\u0000\u018d\u018f\t"+ + "\u0000\u0000\u0000\u018e\u018d\u0001\u0000\u0000\u0000\u018f\u0192\u0001"+ + "\u0000\u0000\u0000\u0190\u0191\u0001\u0000\u0000\u0000\u0190\u018e\u0001"+ + "\u0000\u0000\u0000\u0191\u0193\u0001\u0000\u0000\u0000\u0192\u0190\u0001"+ + "\u0000\u0000\u0000\u0193\u0194\u0005*\u0000\u0000\u0194\u0195\u0005/\u0000"+ + "\u0000\u0195\u0196\u0001\u0000\u0000\u0000\u0196\u0197\u00064\u0000\u0000"+ + "\u0197j\u0001\u0000\u0000\u0000\u000f\u0000\u00af\u00db\u00df\u00e7\u00eb"+ + "\u014b\u0151\u0156\u0161\u016f\u0175\u017b\u0185\u0190\u0001\u0006\u0000"+ + "\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaLexer.tokens b/src/main/java/parser/generated/SimpleJavaLexer.tokens new file mode 100644 index 0000000..bed7437 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaLexer.tokens @@ -0,0 +1,88 @@ +T__0=1 +T__1=2 +Void=3 +Boolean=4 +Char=5 +Int=6 +AccessModifier=7 +MainMethodDeclaration=8 +DotOperator=9 +LineOperator=10 +ComparisonOperator=11 +LogicalOperator=12 +Assign=13 +Plus=14 +Minus=15 +Mult=16 +Modulo=17 +Div=18 +Greater=19 +Less=20 +GreaterEqual=21 +LessEqual=22 +Equal=23 +NotEqual=24 +Not=25 +And=26 +Or=27 +Dot=28 +OpenRoundBracket=29 +ClosedRoundBracket=30 +OpenCurlyBracket=31 +ClosedCurlyBracket=32 +Semicolon=33 +Comma=34 +Class=35 +This=36 +While=37 +If=38 +Else=39 +For=40 +Return=41 +New=42 +CharValue=43 +IntValue=44 +BooleanValue=45 +NullValue=46 +Identifier=47 +WS=48 +InlineComment=49 +MultilineComment=50 +'++'=1 +'--'=2 +'void'=3 +'boolean'=4 +'char'=5 +'int'=6 +'public static void main(String[] args)'=8 +'='=13 +'+'=14 +'-'=15 +'*'=16 +'%'=17 +'/'=18 +'>'=19 +'<'=20 +'>='=21 +'<='=22 +'=='=23 +'!='=24 +'!'=25 +'&&'=26 +'||'=27 +'.'=28 +'('=29 +')'=30 +'{'=31 +'}'=32 +';'=33 +','=34 +'class'=35 +'this'=36 +'while'=37 +'if'=38 +'else'=39 +'for'=40 +'return'=41 +'new'=42 +'null'=46 diff --git a/src/main/java/parser/generated/SimpleJavaListener.java b/src/main/java/parser/generated/SimpleJavaListener.java new file mode 100644 index 0000000..7b22466 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaListener.java @@ -0,0 +1,450 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 +package parser.generated; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link SimpleJavaParser}. + */ +public interface SimpleJavaListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link SimpleJavaParser#program}. + * @param ctx the parse tree + */ + void enterProgram(SimpleJavaParser.ProgramContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#program}. + * @param ctx the parse tree + */ + void exitProgram(SimpleJavaParser.ProgramContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#classDeclaration}. + * @param ctx the parse tree + */ + void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#classDeclaration}. + * @param ctx the parse tree + */ + void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. + * @param ctx the parse tree + */ + void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. + * @param ctx the parse tree + */ + void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. + * @param ctx the parse tree + */ + void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}. + * @param ctx the parse tree + */ + void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. + * @param ctx the parse tree + */ + void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. + * @param ctx the parse tree + */ + void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#parameterList}. + * @param ctx the parse tree + */ + void enterParameterList(SimpleJavaParser.ParameterListContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#parameterList}. + * @param ctx the parse tree + */ + void exitParameterList(SimpleJavaParser.ParameterListContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#parameter}. + * @param ctx the parse tree + */ + void enterParameter(SimpleJavaParser.ParameterContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#parameter}. + * @param ctx the parse tree + */ + void exitParameter(SimpleJavaParser.ParameterContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#argumentList}. + * @param ctx the parse tree + */ + void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#argumentList}. + * @param ctx the parse tree + */ + void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#statement}. + * @param ctx the parse tree + */ + void enterStatement(SimpleJavaParser.StatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#statement}. + * @param ctx the parse tree + */ + void exitStatement(SimpleJavaParser.StatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#block}. + * @param ctx the parse tree + */ + void enterBlock(SimpleJavaParser.BlockContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#block}. + * @param ctx the parse tree + */ + void exitBlock(SimpleJavaParser.BlockContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}. + * @param ctx the parse tree + */ + void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#returnStatement}. + * @param ctx the parse tree + */ + void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. + * @param ctx the parse tree + */ + void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. + * @param ctx the parse tree + */ + void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + */ + void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + */ + void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + */ + void enterForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + */ + void exitForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + */ + void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + */ + void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + */ + void enterIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + */ + void exitIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + */ + void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + */ + void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + */ + void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + */ + void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + */ + void enterAssign(SimpleJavaParser.AssignContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + */ + void exitAssign(SimpleJavaParser.AssignContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + */ + void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + */ + void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(SimpleJavaParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(SimpleJavaParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#unaryExpression}. + * @param ctx the parse tree + */ + void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. + * @param ctx the parse tree + */ + void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#notExpression}. + * @param ctx the parse tree + */ + void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#notExpression}. + * @param ctx the parse tree + */ + void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#crementExpression}. + * @param ctx the parse tree + */ + void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#crementExpression}. + * @param ctx the parse tree + */ + void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + */ + void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + */ + void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + */ + void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + */ + void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + */ + void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + */ + void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + */ + void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + */ + void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + */ + void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + */ + void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + */ + void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + */ + void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + */ + void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + */ + void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + */ + void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + */ + void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + */ + void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + */ + void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + */ + void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + */ + void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + */ + void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + */ + void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + */ + void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + */ + void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + */ + void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + */ + void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + */ + void enterMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + */ + void exitMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + */ + void enterTarget(SimpleJavaParser.TargetContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + */ + void exitTarget(SimpleJavaParser.TargetContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + */ + void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + */ + void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + */ + void enterType(SimpleJavaParser.TypeContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + */ + void exitType(SimpleJavaParser.TypeContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + */ + void enterValue(SimpleJavaParser.ValueContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + */ + void exitValue(SimpleJavaParser.ValueContext ctx); + /** + * Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + */ + void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); + /** + * Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + */ + void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); +} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaParser.java b/src/main/java/parser/generated/SimpleJavaParser.java new file mode 100644 index 0000000..0c2fa56 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaParser.java @@ -0,0 +1,3457 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/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 { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8, + DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12, + Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19, + Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25, + And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31, + ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37, + If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44, + BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49, + MultilineComment=50; + public static final int + RULE_program = 0, RULE_classDeclaration = 1, RULE_memberDeclaration = 2, + RULE_constructorDeclaration = 3, RULE_fieldDeclaration = 4, RULE_methodDeclaration = 5, + RULE_parameterList = 6, RULE_parameter = 7, RULE_argumentList = 8, RULE_statement = 9, + RULE_block = 10, RULE_returnStatement = 11, RULE_localVariableDeclaration = 12, + RULE_whileStatement = 13, RULE_forStatement = 14, RULE_ifElseStatement = 15, + RULE_ifStatement = 16, RULE_elseStatement = 17, RULE_statementExpression = 18, + RULE_assign = 19, RULE_newDeclaration = 20, RULE_expression = 21, RULE_unaryExpression = 22, + RULE_notExpression = 23, RULE_crementExpression = 24, RULE_incrementExpression = 25, + RULE_prefixIncrementExpression = 26, RULE_suffixIncrementExpression = 27, + RULE_decrementExpression = 28, RULE_prefixDecrementExpression = 29, RULE_suffixDecrementExpression = 30, + RULE_assignableExpression = 31, RULE_memberAccess = 32, RULE_binaryExpression = 33, + RULE_calculationExpression = 34, RULE_dotExpression = 35, RULE_dotSubtractionExpression = 36, + RULE_nonCalculationExpression = 37, RULE_methodCall = 38, RULE_target = 39, + RULE_chainedMethod = 40, RULE_type = 41, RULE_value = 42, RULE_nonCalculationOperator = 43; + private static String[] makeRuleNames() { + return new String[] { + "program", "classDeclaration", "memberDeclaration", "constructorDeclaration", + "fieldDeclaration", "methodDeclaration", "parameterList", "parameter", + "argumentList", "statement", "block", "returnStatement", "localVariableDeclaration", + "whileStatement", "forStatement", "ifElseStatement", "ifStatement", "elseStatement", + "statementExpression", "assign", "newDeclaration", "expression", "unaryExpression", + "notExpression", "crementExpression", "incrementExpression", "prefixIncrementExpression", + "suffixIncrementExpression", "decrementExpression", "prefixDecrementExpression", + "suffixDecrementExpression", "assignableExpression", "memberAccess", + "binaryExpression", "calculationExpression", "dotExpression", "dotSubtractionExpression", + "nonCalculationExpression", "methodCall", "target", "chainedMethod", + "type", "value", "nonCalculationOperator" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null, + "'public static void main(String[] args)'", null, null, null, null, "'='", + "'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='", + "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'", + "','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'", + "'new'", null, null, null, "'null'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier", + "MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator", + "LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div", + "Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual", + "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue", + "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "SimpleJava.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public SimpleJavaParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class ProgramContext extends ParserRuleContext { + public List classDeclaration() { + return getRuleContexts(ClassDeclarationContext.class); + } + public ClassDeclarationContext classDeclaration(int i) { + return getRuleContext(ClassDeclarationContext.class,i); + } + public ProgramContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_program; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterProgram(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitProgram(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitProgram(this); + else return visitor.visitChildren(this); + } + } + + public final ProgramContext program() throws RecognitionException { + ProgramContext _localctx = new ProgramContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_program); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(89); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(88); + classDeclaration(); + } + } + setState(91); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==AccessModifier || _la==Class ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ClassDeclarationContext extends ParserRuleContext { + public TerminalNode Class() { return getToken(SimpleJavaParser.Class, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public List memberDeclaration() { + return getRuleContexts(MemberDeclarationContext.class); + } + public MemberDeclarationContext memberDeclaration(int i) { + return getRuleContext(MemberDeclarationContext.class,i); + } + public ClassDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_classDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterClassDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitClassDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitClassDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ClassDeclarationContext classDeclaration() throws RecognitionException { + ClassDeclarationContext _localctx = new ClassDeclarationContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_classDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(94); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifier) { + { + setState(93); + match(AccessModifier); + } + } + + setState(96); + match(Class); + setState(97); + match(Identifier); + setState(98); + match(OpenCurlyBracket); + setState(102); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355832L) != 0)) { + { + { + setState(99); + memberDeclaration(); + } + } + setState(104); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(105); + match(ClosedCurlyBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MemberDeclarationContext extends ParserRuleContext { + public ConstructorDeclarationContext constructorDeclaration() { + return getRuleContext(ConstructorDeclarationContext.class,0); + } + public FieldDeclarationContext fieldDeclaration() { + return getRuleContext(FieldDeclarationContext.class,0); + } + public MethodDeclarationContext methodDeclaration() { + return getRuleContext(MethodDeclarationContext.class,0); + } + public MemberDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_memberDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMemberDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMemberDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMemberDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final MemberDeclarationContext memberDeclaration() throws RecognitionException { + MemberDeclarationContext _localctx = new MemberDeclarationContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_memberDeclaration); + try { + setState(110); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(107); + constructorDeclaration(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(108); + fieldDeclaration(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(109); + methodDeclaration(); + } + break; + } + } + 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 TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public ParameterListContext parameterList() { + return getRuleContext(ParameterListContext.class,0); + } + 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 visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitConstructorDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException { + ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_constructorDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(113); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifier) { + { + setState(112); + match(AccessModifier); + } + } + + setState(115); + match(Identifier); + setState(116); + match(OpenRoundBracket); + setState(118); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { + { + setState(117); + parameterList(); + } + } + + setState(120); + match(ClosedRoundBracket); + setState(121); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FieldDeclarationContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_fieldDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterFieldDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitFieldDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitFieldDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { + FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_fieldDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(124); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifier) { + { + setState(123); + match(AccessModifier); + } + } + + setState(126); + type(); + setState(127); + match(Identifier); + setState(128); + match(Semicolon); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodDeclarationContext extends ParserRuleContext { + public TerminalNode MainMethodDeclaration() { return getToken(SimpleJavaParser.MainMethodDeclaration, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Void() { return getToken(SimpleJavaParser.Void, 0); } + public TerminalNode AccessModifier() { return getToken(SimpleJavaParser.AccessModifier, 0); } + public ParameterListContext parameterList() { + return getRuleContext(ParameterListContext.class,0); + } + public MethodDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final MethodDeclarationContext methodDeclaration() throws RecognitionException { + MethodDeclarationContext _localctx = new MethodDeclarationContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_methodDeclaration); + int _la; + try { + setState(146); + _errHandler.sync(this); + switch (_input.LA(1)) { + case MainMethodDeclaration: + enterOuterAlt(_localctx, 1); + { + setState(130); + match(MainMethodDeclaration); + setState(131); + block(); + } + break; + case Void: + case Boolean: + case Char: + case Int: + case AccessModifier: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(133); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifier) { + { + setState(132); + match(AccessModifier); + } + } + + setState(137); + _errHandler.sync(this); + switch (_input.LA(1)) { + case Boolean: + case Char: + case Int: + case Identifier: + { + setState(135); + type(); + } + break; + case Void: + { + setState(136); + match(Void); + } + break; + default: + throw new NoViableAltException(this); + } + setState(139); + match(Identifier); + setState(140); + match(OpenRoundBracket); + setState(142); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) { + { + setState(141); + parameterList(); + } + } + + setState(144); + match(ClosedRoundBracket); + setState(145); + block(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParameterListContext extends ParserRuleContext { + public List parameter() { + return getRuleContexts(ParameterContext.class); + } + public ParameterContext parameter(int i) { + return getRuleContext(ParameterContext.class,i); + } + public List Comma() { return getTokens(SimpleJavaParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(SimpleJavaParser.Comma, i); + } + public ParameterListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameterList; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterParameterList(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitParameterList(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitParameterList(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterListContext parameterList() throws RecognitionException { + ParameterListContext _localctx = new ParameterListContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_parameterList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(148); + parameter(); + setState(153); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Comma) { + { + { + setState(149); + match(Comma); + setState(150); + parameter(); + } + } + setState(155); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParameterContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public ParameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameter; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterParameter(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitParameter(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitParameter(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterContext parameter() throws RecognitionException { + ParameterContext _localctx = new ParameterContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_parameter); + try { + enterOuterAlt(_localctx, 1); + { + setState(156); + type(); + setState(157); + match(Identifier); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArgumentListContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List Comma() { return getTokens(SimpleJavaParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(SimpleJavaParser.Comma, i); + } + public ArgumentListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_argumentList; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterArgumentList(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitArgumentList(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitArgumentList(this); + else return visitor.visitChildren(this); + } + } + + public final ArgumentListContext argumentList() throws RecognitionException { + ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_argumentList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(167); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(159); + expression(); + setState(164); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Comma) { + { + { + setState(160); + match(Comma); + setState(161); + expression(); + } + } + setState(166); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StatementContext extends ParserRuleContext { + public ReturnStatementContext returnStatement() { + return getRuleContext(ReturnStatementContext.class,0); + } + public TerminalNode Semicolon() { return getToken(SimpleJavaParser.Semicolon, 0); } + public LocalVariableDeclarationContext localVariableDeclaration() { + return getRuleContext(LocalVariableDeclarationContext.class,0); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public WhileStatementContext whileStatement() { + return getRuleContext(WhileStatementContext.class,0); + } + public ForStatementContext forStatement() { + return getRuleContext(ForStatementContext.class,0); + } + public IfElseStatementContext ifElseStatement() { + return getRuleContext(IfElseStatementContext.class,0); + } + public StatementExpressionContext statementExpression() { + return getRuleContext(StatementExpressionContext.class,0); + } + public StatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitStatement(this); + else return visitor.visitChildren(this); + } + } + + public final StatementContext statement() throws RecognitionException { + StatementContext _localctx = new StatementContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_statement); + try { + setState(182); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(169); + returnStatement(); + setState(170); + match(Semicolon); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(172); + localVariableDeclaration(); + setState(173); + match(Semicolon); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(175); + block(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(176); + whileStatement(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(177); + forStatement(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(178); + ifElseStatement(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(179); + statementExpression(); + setState(180); + match(Semicolon); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BlockContext extends ParserRuleContext { + public TerminalNode OpenCurlyBracket() { return getToken(SimpleJavaParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(SimpleJavaParser.ClosedCurlyBracket, 0); } + public List statement() { + return getRuleContexts(StatementContext.class); + } + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class,i); + } + public BlockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_block; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBlock(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBlock(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBlock(this); + else return visitor.visitChildren(this); + } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(184); + match(OpenCurlyBracket); + setState(188); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 148917253570678L) != 0)) { + { + { + setState(185); + statement(); + } + } + setState(190); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(191); + match(ClosedCurlyBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReturnStatementContext extends ParserRuleContext { + public TerminalNode Return() { return getToken(SimpleJavaParser.Return, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ReturnStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_returnStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterReturnStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitReturnStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitReturnStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ReturnStatementContext returnStatement() throws RecognitionException { + ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_returnStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(193); + match(Return); + setState(195); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(194); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class LocalVariableDeclarationContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public LocalVariableDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_localVariableDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterLocalVariableDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitLocalVariableDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitLocalVariableDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final LocalVariableDeclarationContext localVariableDeclaration() throws RecognitionException { + LocalVariableDeclarationContext _localctx = new LocalVariableDeclarationContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_localVariableDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(197); + type(); + setState(198); + match(Identifier); + setState(201); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==Assign) { + { + setState(199); + match(Assign); + setState(200); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class WhileStatementContext extends ParserRuleContext { + public TerminalNode While() { return getToken(SimpleJavaParser.While, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public WhileStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_whileStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterWhileStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitWhileStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitWhileStatement(this); + else return visitor.visitChildren(this); + } + } + + public final WhileStatementContext whileStatement() throws RecognitionException { + WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_whileStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(203); + match(While); + setState(204); + match(OpenRoundBracket); + setState(205); + expression(); + setState(206); + match(ClosedRoundBracket); + setState(207); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ForStatementContext extends ParserRuleContext { + public TerminalNode For() { return getToken(SimpleJavaParser.For, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public List Semicolon() { return getTokens(SimpleJavaParser.Semicolon); } + public TerminalNode Semicolon(int i) { + return getToken(SimpleJavaParser.Semicolon, i); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public List statementExpression() { + return getRuleContexts(StatementExpressionContext.class); + } + public StatementExpressionContext statementExpression(int i) { + return getRuleContext(StatementExpressionContext.class,i); + } + public LocalVariableDeclarationContext localVariableDeclaration() { + return getRuleContext(LocalVariableDeclarationContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ForStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_forStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterForStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitForStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitForStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ForStatementContext forStatement() throws RecognitionException { + ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_forStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(209); + match(For); + setState(210); + match(OpenRoundBracket); + setState(213); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) { + case 1: + { + setState(211); + statementExpression(); + } + break; + case 2: + { + setState(212); + localVariableDeclaration(); + } + break; + } + setState(215); + match(Semicolon); + setState(217); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 277146220101638L) != 0)) { + { + setState(216); + expression(); + } + } + + setState(219); + match(Semicolon); + setState(221); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 145204254343174L) != 0)) { + { + setState(220); + statementExpression(); + } + } + + setState(223); + match(ClosedRoundBracket); + setState(224); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfElseStatementContext extends ParserRuleContext { + public IfStatementContext ifStatement() { + return getRuleContext(IfStatementContext.class,0); + } + public List elseStatement() { + return getRuleContexts(ElseStatementContext.class); + } + public ElseStatementContext elseStatement(int i) { + return getRuleContext(ElseStatementContext.class,i); + } + public IfElseStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifElseStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfElseStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfElseStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfElseStatement(this); + else return visitor.visitChildren(this); + } + } + + public final IfElseStatementContext ifElseStatement() throws RecognitionException { + IfElseStatementContext _localctx = new IfElseStatementContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_ifElseStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(226); + ifStatement(); + setState(230); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Else) { + { + { + setState(227); + elseStatement(); + } + } + setState(232); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfStatementContext extends ParserRuleContext { + public TerminalNode If() { return getToken(SimpleJavaParser.If, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public IfStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIfStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIfStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIfStatement(this); + else return visitor.visitChildren(this); + } + } + + public final IfStatementContext ifStatement() throws RecognitionException { + IfStatementContext _localctx = new IfStatementContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_ifStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(233); + match(If); + setState(234); + match(OpenRoundBracket); + setState(235); + expression(); + setState(236); + match(ClosedRoundBracket); + setState(237); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ElseStatementContext extends ParserRuleContext { + public TerminalNode Else() { return getToken(SimpleJavaParser.Else, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public ElseStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_elseStatement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterElseStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitElseStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitElseStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ElseStatementContext elseStatement() throws RecognitionException { + ElseStatementContext _localctx = new ElseStatementContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_elseStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(239); + match(Else); + setState(240); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StatementExpressionContext extends ParserRuleContext { + public AssignContext assign() { + return getRuleContext(AssignContext.class,0); + } + public NewDeclarationContext newDeclaration() { + return getRuleContext(NewDeclarationContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public CrementExpressionContext crementExpression() { + return getRuleContext(CrementExpressionContext.class,0); + } + public StatementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterStatementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitStatementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitStatementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final StatementExpressionContext statementExpression() throws RecognitionException { + StatementExpressionContext _localctx = new StatementExpressionContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_statementExpression); + try { + setState(246); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(242); + assign(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(243); + newDeclaration(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(244); + methodCall(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(245); + crementExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public TerminalNode Assign() { return getToken(SimpleJavaParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public AssignContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assign; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssign(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssign(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + + public final AssignContext assign() throws RecognitionException { + AssignContext _localctx = new AssignContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_assign); + try { + enterOuterAlt(_localctx, 1); + { + setState(248); + assignableExpression(); + setState(249); + match(Assign); + setState(250); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NewDeclarationContext extends ParserRuleContext { + public TerminalNode New() { return getToken(SimpleJavaParser.New, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public NewDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_newDeclaration; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNewDeclaration(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNewDeclaration(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNewDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final NewDeclarationContext newDeclaration() throws RecognitionException { + NewDeclarationContext _localctx = new NewDeclarationContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_newDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(252); + match(New); + setState(253); + match(Identifier); + setState(254); + match(OpenRoundBracket); + setState(255); + argumentList(); + setState(256); + match(ClosedRoundBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public UnaryExpressionContext unaryExpression() { + return getRuleContext(UnaryExpressionContext.class,0); + } + public BinaryExpressionContext binaryExpression() { + return getRuleContext(BinaryExpressionContext.class,0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_expression); + try { + setState(260); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(258); + unaryExpression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(259); + binaryExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class UnaryExpressionContext extends ParserRuleContext { + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public ValueContext value() { + return getRuleContext(ValueContext.class,0); + } + public NotExpressionContext notExpression() { + return getRuleContext(NotExpressionContext.class,0); + } + public StatementExpressionContext statementExpression() { + return getRuleContext(StatementExpressionContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public UnaryExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_unaryExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterUnaryExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitUnaryExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitUnaryExpression(this); + else return visitor.visitChildren(this); + } + } + + public final UnaryExpressionContext unaryExpression() throws RecognitionException { + UnaryExpressionContext _localctx = new UnaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_unaryExpression); + try { + setState(272); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(262); + match(This); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(263); + match(Identifier); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(264); + memberAccess(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(265); + value(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(266); + notExpression(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(267); + statementExpression(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(268); + match(OpenRoundBracket); + setState(269); + expression(); + setState(270); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NotExpressionContext extends ParserRuleContext { + public TerminalNode Not() { return getToken(SimpleJavaParser.Not, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public NotExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_notExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNotExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNotExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNotExpression(this); + else return visitor.visitChildren(this); + } + } + + public final NotExpressionContext notExpression() throws RecognitionException { + NotExpressionContext _localctx = new NotExpressionContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_notExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(274); + match(Not); + setState(275); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CrementExpressionContext extends ParserRuleContext { + public IncrementExpressionContext incrementExpression() { + return getRuleContext(IncrementExpressionContext.class,0); + } + public DecrementExpressionContext decrementExpression() { + return getRuleContext(DecrementExpressionContext.class,0); + } + public CrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_crementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final CrementExpressionContext crementExpression() throws RecognitionException { + CrementExpressionContext _localctx = new CrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_crementExpression); + try { + setState(279); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(277); + incrementExpression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(278); + decrementExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IncrementExpressionContext extends ParserRuleContext { + public PrefixIncrementExpressionContext prefixIncrementExpression() { + return getRuleContext(PrefixIncrementExpressionContext.class,0); + } + public SuffixIncrementExpressionContext suffixIncrementExpression() { + return getRuleContext(SuffixIncrementExpressionContext.class,0); + } + public IncrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_incrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterIncrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitIncrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final IncrementExpressionContext incrementExpression() throws RecognitionException { + IncrementExpressionContext _localctx = new IncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_incrementExpression); + try { + setState(283); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__0: + enterOuterAlt(_localctx, 1); + { + setState(281); + prefixIncrementExpression(); + } + break; + case This: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(282); + suffixIncrementExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrefixIncrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public PrefixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_prefixIncrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixIncrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixIncrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final PrefixIncrementExpressionContext prefixIncrementExpression() throws RecognitionException { + PrefixIncrementExpressionContext _localctx = new PrefixIncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_prefixIncrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(285); + match(T__0); + setState(286); + assignableExpression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SuffixIncrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public SuffixIncrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_suffixIncrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixIncrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixIncrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final SuffixIncrementExpressionContext suffixIncrementExpression() throws RecognitionException { + SuffixIncrementExpressionContext _localctx = new SuffixIncrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_suffixIncrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(288); + assignableExpression(); + setState(289); + match(T__0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DecrementExpressionContext extends ParserRuleContext { + public PrefixDecrementExpressionContext prefixDecrementExpression() { + return getRuleContext(PrefixDecrementExpressionContext.class,0); + } + public SuffixDecrementExpressionContext suffixDecrementExpression() { + return getRuleContext(SuffixDecrementExpressionContext.class,0); + } + public DecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_decrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DecrementExpressionContext decrementExpression() throws RecognitionException { + DecrementExpressionContext _localctx = new DecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_decrementExpression); + try { + setState(293); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__1: + enterOuterAlt(_localctx, 1); + { + setState(291); + prefixDecrementExpression(); + } + break; + case This: + case Identifier: + enterOuterAlt(_localctx, 2); + { + setState(292); + suffixDecrementExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrefixDecrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public PrefixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_prefixDecrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterPrefixDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitPrefixDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitPrefixDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final PrefixDecrementExpressionContext prefixDecrementExpression() throws RecognitionException { + PrefixDecrementExpressionContext _localctx = new PrefixDecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_prefixDecrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(295); + match(T__1); + setState(296); + assignableExpression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SuffixDecrementExpressionContext extends ParserRuleContext { + public AssignableExpressionContext assignableExpression() { + return getRuleContext(AssignableExpressionContext.class,0); + } + public SuffixDecrementExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_suffixDecrementExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterSuffixDecrementExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitSuffixDecrementExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitSuffixDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + + public final SuffixDecrementExpressionContext suffixDecrementExpression() throws RecognitionException { + SuffixDecrementExpressionContext _localctx = new SuffixDecrementExpressionContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_suffixDecrementExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(298); + assignableExpression(); + setState(299); + match(T__1); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignableExpressionContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public AssignableExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assignableExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterAssignableExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitAssignableExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitAssignableExpression(this); + else return visitor.visitChildren(this); + } + } + + public final AssignableExpressionContext assignableExpression() throws RecognitionException { + AssignableExpressionContext _localctx = new AssignableExpressionContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_assignableExpression); + try { + setState(303); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(301); + match(Identifier); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(302); + memberAccess(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MemberAccessContext extends ParserRuleContext { + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public List Dot() { return getTokens(SimpleJavaParser.Dot); } + public TerminalNode Dot(int i) { + return getToken(SimpleJavaParser.Dot, i); + } + public List Identifier() { return getTokens(SimpleJavaParser.Identifier); } + public TerminalNode Identifier(int i) { + return getToken(SimpleJavaParser.Identifier, i); + } + public MemberAccessContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_memberAccess; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMemberAccess(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMemberAccess(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMemberAccess(this); + else return visitor.visitChildren(this); + } + } + + public final MemberAccessContext memberAccess() throws RecognitionException { + MemberAccessContext _localctx = new MemberAccessContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_memberAccess); + int _la; + try { + int _alt; + setState(319); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,31,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(305); + match(This); + setState(306); + match(Dot); + setState(307); + match(Identifier); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(310); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==This) { + { + setState(308); + match(This); + setState(309); + match(Dot); + } + } + + setState(314); + _errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + setState(312); + match(Identifier); + setState(313); + match(Dot); + } + } + break; + default: + throw new NoViableAltException(this); + } + setState(316); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,30,_ctx); + } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); + setState(318); + match(Identifier); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BinaryExpressionContext extends ParserRuleContext { + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public NonCalculationExpressionContext nonCalculationExpression() { + return getRuleContext(NonCalculationExpressionContext.class,0); + } + public BinaryExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_binaryExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterBinaryExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitBinaryExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitBinaryExpression(this); + else return visitor.visitChildren(this); + } + } + + public final BinaryExpressionContext binaryExpression() throws RecognitionException { + BinaryExpressionContext _localctx = new BinaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_binaryExpression); + try { + setState(323); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,32,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(321); + calculationExpression(0); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(322); + nonCalculationExpression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CalculationExpressionContext extends ParserRuleContext { + public DotExpressionContext dotExpression() { + return getRuleContext(DotExpressionContext.class,0); + } + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public TerminalNode LineOperator() { return getToken(SimpleJavaParser.LineOperator, 0); } + public CalculationExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_calculationExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterCalculationExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitCalculationExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitCalculationExpression(this); + else return visitor.visitChildren(this); + } + } + + public final CalculationExpressionContext calculationExpression() throws RecognitionException { + return calculationExpression(0); + } + + private CalculationExpressionContext calculationExpression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + CalculationExpressionContext _localctx = new CalculationExpressionContext(_ctx, _parentState); + CalculationExpressionContext _prevctx = _localctx; + int _startState = 68; + enterRecursionRule(_localctx, 68, RULE_calculationExpression, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(326); + dotExpression(0); + } + _ctx.stop = _input.LT(-1); + setState(333); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,33,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new CalculationExpressionContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_calculationExpression); + setState(328); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(329); + match(LineOperator); + setState(330); + dotExpression(0); + } + } + } + setState(335); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,33,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotExpressionContext extends ParserRuleContext { + public DotSubtractionExpressionContext dotSubtractionExpression() { + return getRuleContext(DotSubtractionExpressionContext.class,0); + } + public DotExpressionContext dotExpression() { + return getRuleContext(DotExpressionContext.class,0); + } + public TerminalNode DotOperator() { return getToken(SimpleJavaParser.DotOperator, 0); } + public DotExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DotExpressionContext dotExpression() throws RecognitionException { + return dotExpression(0); + } + + private DotExpressionContext dotExpression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + DotExpressionContext _localctx = new DotExpressionContext(_ctx, _parentState); + DotExpressionContext _prevctx = _localctx; + int _startState = 70; + enterRecursionRule(_localctx, 70, RULE_dotExpression, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(337); + dotSubtractionExpression(); + } + _ctx.stop = _input.LT(-1); + setState(344); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,34,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new DotExpressionContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_dotExpression); + setState(339); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(340); + match(DotOperator); + setState(341); + dotSubtractionExpression(); + } + } + } + setState(346); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,34,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotSubtractionExpressionContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public CalculationExpressionContext calculationExpression() { + return getRuleContext(CalculationExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public DotSubtractionExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotSubtractionExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterDotSubtractionExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitDotSubtractionExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitDotSubtractionExpression(this); + else return visitor.visitChildren(this); + } + } + + public final DotSubtractionExpressionContext dotSubtractionExpression() throws RecognitionException { + DotSubtractionExpressionContext _localctx = new DotSubtractionExpressionContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_dotSubtractionExpression); + try { + setState(355); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,35,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(347); + match(IntValue); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(348); + match(Identifier); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(349); + memberAccess(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(350); + methodCall(); + setState(351); + match(OpenRoundBracket); + setState(352); + calculationExpression(0); + setState(353); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalculationExpressionContext extends ParserRuleContext { + public UnaryExpressionContext unaryExpression() { + return getRuleContext(UnaryExpressionContext.class,0); + } + public NonCalculationOperatorContext nonCalculationOperator() { + return getRuleContext(NonCalculationOperatorContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public NonCalculationExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalculationExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationExpression(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalculationExpressionContext nonCalculationExpression() throws RecognitionException { + NonCalculationExpressionContext _localctx = new NonCalculationExpressionContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_nonCalculationExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(357); + unaryExpression(); + setState(358); + nonCalculationOperator(); + setState(359); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodCallContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TargetContext target() { + return getRuleContext(TargetContext.class,0); + } + public List chainedMethod() { + return getRuleContexts(ChainedMethodContext.class); + } + public ChainedMethodContext chainedMethod(int i) { + return getRuleContext(ChainedMethodContext.class,i); + } + public MethodCallContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodCall; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterMethodCall(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitMethodCall(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitMethodCall(this); + else return visitor.visitChildren(this); + } + } + + public final MethodCallContext methodCall() throws RecognitionException { + MethodCallContext _localctx = new MethodCallContext(_ctx, getState()); + enterRule(_localctx, 76, RULE_methodCall); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(362); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { + case 1: + { + setState(361); + target(); + } + break; + } + setState(367); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(364); + chainedMethod(); + } + } + } + setState(369); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); + } + setState(370); + match(Identifier); + setState(371); + match(OpenRoundBracket); + setState(372); + argumentList(); + setState(373); + match(ClosedRoundBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TargetContext extends ParserRuleContext { + public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } + public TerminalNode This() { return getToken(SimpleJavaParser.This, 0); } + public MemberAccessContext memberAccess() { + return getRuleContext(MemberAccessContext.class,0); + } + public NewDeclarationContext newDeclaration() { + return getRuleContext(NewDeclarationContext.class,0); + } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TargetContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_target; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterTarget(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitTarget(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitTarget(this); + else return visitor.visitChildren(this); + } + } + + public final TargetContext target() throws RecognitionException { + TargetContext _localctx = new TargetContext(_ctx, getState()); + enterRule(_localctx, 78, RULE_target); + try { + enterOuterAlt(_localctx, 1); + { + setState(379); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,38,_ctx) ) { + case 1: + { + setState(375); + match(This); + } + break; + case 2: + { + setState(376); + memberAccess(); + } + break; + case 3: + { + setState(377); + newDeclaration(); + } + break; + case 4: + { + setState(378); + match(Identifier); + } + break; + } + setState(381); + match(Dot); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ChainedMethodContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(SimpleJavaParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(SimpleJavaParser.ClosedRoundBracket, 0); } + public TerminalNode Dot() { return getToken(SimpleJavaParser.Dot, 0); } + public ChainedMethodContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_chainedMethod; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterChainedMethod(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitChainedMethod(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitChainedMethod(this); + else return visitor.visitChildren(this); + } + } + + public final ChainedMethodContext chainedMethod() throws RecognitionException { + ChainedMethodContext _localctx = new ChainedMethodContext(_ctx, getState()); + enterRule(_localctx, 80, RULE_chainedMethod); + try { + enterOuterAlt(_localctx, 1); + { + setState(383); + match(Identifier); + setState(384); + match(OpenRoundBracket); + setState(385); + argumentList(); + setState(386); + match(ClosedRoundBracket); + setState(387); + match(Dot); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TypeContext extends ParserRuleContext { + public TerminalNode Int() { return getToken(SimpleJavaParser.Int, 0); } + public TerminalNode Boolean() { return getToken(SimpleJavaParser.Boolean, 0); } + public TerminalNode Char() { return getToken(SimpleJavaParser.Char, 0); } + public TerminalNode Identifier() { return getToken(SimpleJavaParser.Identifier, 0); } + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_type; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterType(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitType(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + TypeContext _localctx = new TypeContext(_ctx, getState()); + enterRule(_localctx, 82, RULE_type); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(389); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 140737488355440L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(SimpleJavaParser.IntValue, 0); } + public TerminalNode BooleanValue() { return getToken(SimpleJavaParser.BooleanValue, 0); } + public TerminalNode CharValue() { return getToken(SimpleJavaParser.CharValue, 0); } + public TerminalNode NullValue() { return getToken(SimpleJavaParser.NullValue, 0); } + public ValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_value; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterValue(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitValue(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitValue(this); + else return visitor.visitChildren(this); + } + } + + public final ValueContext value() throws RecognitionException { + ValueContext _localctx = new ValueContext(_ctx, getState()); + enterRule(_localctx, 84, RULE_value); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(391); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 131941395333120L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalculationOperatorContext extends ParserRuleContext { + public TerminalNode LogicalOperator() { return getToken(SimpleJavaParser.LogicalOperator, 0); } + public TerminalNode ComparisonOperator() { return getToken(SimpleJavaParser.ComparisonOperator, 0); } + public NonCalculationOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalculationOperator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterNonCalculationOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitNonCalculationOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor)visitor).visitNonCalculationOperator(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalculationOperatorContext nonCalculationOperator() throws RecognitionException { + NonCalculationOperatorContext _localctx = new NonCalculationOperatorContext(_ctx, getState()); + enterRule(_localctx, 86, RULE_nonCalculationOperator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(393); + _la = _input.LA(1); + if ( !(_la==ComparisonOperator || _la==LogicalOperator) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 34: + return calculationExpression_sempred((CalculationExpressionContext)_localctx, predIndex); + case 35: + return dotExpression_sempred((DotExpressionContext)_localctx, predIndex); + } + return true; + } + private boolean calculationExpression_sempred(CalculationExpressionContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 2); + } + return true; + } + private boolean dotExpression_sempred(DotExpressionContext _localctx, int predIndex) { + switch (predIndex) { + case 1: + return precpred(_ctx, 2); + } + return true; + } + + public static final String _serializedATN = + "\u0004\u00012\u018c\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\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ + "\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ + "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ + "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ + "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ + "#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002"+ + "(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007+\u0001\u0000\u0004\u0000"+ + "Z\b\u0000\u000b\u0000\f\u0000[\u0001\u0001\u0003\u0001_\b\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u0001e\b\u0001\n\u0001"+ + "\f\u0001h\t\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+ + "\u0002\u0003\u0002o\b\u0002\u0001\u0003\u0003\u0003r\b\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0003\u0003w\b\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0004\u0003\u0004}\b\u0004\u0001\u0004\u0001\u0004"+ + "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0003\u0005"+ + "\u0086\b\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008a\b\u0005\u0001"+ + "\u0005\u0001\u0005\u0001\u0005\u0003\u0005\u008f\b\u0005\u0001\u0005\u0001"+ + "\u0005\u0003\u0005\u0093\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0005"+ + "\u0006\u0098\b\u0006\n\u0006\f\u0006\u009b\t\u0006\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\b\u0001\b\u0001\b\u0005\b\u00a3\b\b\n\b\f\b\u00a6\t"+ + "\b\u0003\b\u00a8\b\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+ + "\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0003\t\u00b7\b\t\u0001"+ + "\n\u0001\n\u0005\n\u00bb\b\n\n\n\f\n\u00be\t\n\u0001\n\u0001\n\u0001\u000b"+ + "\u0001\u000b\u0003\u000b\u00c4\b\u000b\u0001\f\u0001\f\u0001\f\u0001\f"+ + "\u0003\f\u00ca\b\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e\u00d6\b\u000e\u0001"+ + "\u000e\u0001\u000e\u0003\u000e\u00da\b\u000e\u0001\u000e\u0001\u000e\u0003"+ + "\u000e\u00de\b\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ + "\u000f\u0005\u000f\u00e5\b\u000f\n\u000f\f\u000f\u00e8\t\u000f\u0001\u0010"+ + "\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011"+ + "\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ + "\u0003\u0012\u00f7\b\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014"+ + "\u0001\u0015\u0001\u0015\u0003\u0015\u0105\b\u0015\u0001\u0016\u0001\u0016"+ + "\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016"+ + "\u0001\u0016\u0001\u0016\u0003\u0016\u0111\b\u0016\u0001\u0017\u0001\u0017"+ + "\u0001\u0017\u0001\u0018\u0001\u0018\u0003\u0018\u0118\b\u0018\u0001\u0019"+ + "\u0001\u0019\u0003\u0019\u011c\b\u0019\u0001\u001a\u0001\u001a\u0001\u001a"+ + "\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0003\u001c"+ + "\u0126\b\u001c\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e"+ + "\u0001\u001e\u0001\u001f\u0001\u001f\u0003\u001f\u0130\b\u001f\u0001 "+ + "\u0001 \u0001 \u0001 \u0001 \u0003 \u0137\b \u0001 \u0001 \u0004 \u013b"+ + "\b \u000b \f \u013c\u0001 \u0003 \u0140\b \u0001!\u0001!\u0003!\u0144"+ + "\b!\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0005\"\u014c\b\""+ + "\n\"\f\"\u014f\t\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005#\u0157"+ + "\b#\n#\f#\u015a\t#\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001"+ + "$\u0003$\u0164\b$\u0001%\u0001%\u0001%\u0001%\u0001&\u0003&\u016b\b&\u0001"+ + "&\u0005&\u016e\b&\n&\f&\u0171\t&\u0001&\u0001&\u0001&\u0001&\u0001&\u0001"+ + "\'\u0001\'\u0001\'\u0001\'\u0003\'\u017c\b\'\u0001\'\u0001\'\u0001(\u0001"+ + "(\u0001(\u0001(\u0001(\u0001(\u0001)\u0001)\u0001*\u0001*\u0001+\u0001"+ + "+\u0001+\u0000\u0002DF,\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012"+ + "\u0014\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFHJLNPRTV\u0000"+ + "\u0003\u0002\u0000\u0004\u0006//\u0001\u0000+.\u0001\u0000\u000b\f\u0197"+ + "\u0000Y\u0001\u0000\u0000\u0000\u0002^\u0001\u0000\u0000\u0000\u0004n"+ + "\u0001\u0000\u0000\u0000\u0006q\u0001\u0000\u0000\u0000\b|\u0001\u0000"+ + "\u0000\u0000\n\u0092\u0001\u0000\u0000\u0000\f\u0094\u0001\u0000\u0000"+ + "\u0000\u000e\u009c\u0001\u0000\u0000\u0000\u0010\u00a7\u0001\u0000\u0000"+ + "\u0000\u0012\u00b6\u0001\u0000\u0000\u0000\u0014\u00b8\u0001\u0000\u0000"+ + "\u0000\u0016\u00c1\u0001\u0000\u0000\u0000\u0018\u00c5\u0001\u0000\u0000"+ + "\u0000\u001a\u00cb\u0001\u0000\u0000\u0000\u001c\u00d1\u0001\u0000\u0000"+ + "\u0000\u001e\u00e2\u0001\u0000\u0000\u0000 \u00e9\u0001\u0000\u0000\u0000"+ + "\"\u00ef\u0001\u0000\u0000\u0000$\u00f6\u0001\u0000\u0000\u0000&\u00f8"+ + "\u0001\u0000\u0000\u0000(\u00fc\u0001\u0000\u0000\u0000*\u0104\u0001\u0000"+ + "\u0000\u0000,\u0110\u0001\u0000\u0000\u0000.\u0112\u0001\u0000\u0000\u0000"+ + "0\u0117\u0001\u0000\u0000\u00002\u011b\u0001\u0000\u0000\u00004\u011d"+ + "\u0001\u0000\u0000\u00006\u0120\u0001\u0000\u0000\u00008\u0125\u0001\u0000"+ + "\u0000\u0000:\u0127\u0001\u0000\u0000\u0000<\u012a\u0001\u0000\u0000\u0000"+ + ">\u012f\u0001\u0000\u0000\u0000@\u013f\u0001\u0000\u0000\u0000B\u0143"+ + "\u0001\u0000\u0000\u0000D\u0145\u0001\u0000\u0000\u0000F\u0150\u0001\u0000"+ + "\u0000\u0000H\u0163\u0001\u0000\u0000\u0000J\u0165\u0001\u0000\u0000\u0000"+ + "L\u016a\u0001\u0000\u0000\u0000N\u017b\u0001\u0000\u0000\u0000P\u017f"+ + "\u0001\u0000\u0000\u0000R\u0185\u0001\u0000\u0000\u0000T\u0187\u0001\u0000"+ + "\u0000\u0000V\u0189\u0001\u0000\u0000\u0000XZ\u0003\u0002\u0001\u0000"+ + "YX\u0001\u0000\u0000\u0000Z[\u0001\u0000\u0000\u0000[Y\u0001\u0000\u0000"+ + "\u0000[\\\u0001\u0000\u0000\u0000\\\u0001\u0001\u0000\u0000\u0000]_\u0005"+ + "\u0007\u0000\u0000^]\u0001\u0000\u0000\u0000^_\u0001\u0000\u0000\u0000"+ + "_`\u0001\u0000\u0000\u0000`a\u0005#\u0000\u0000ab\u0005/\u0000\u0000b"+ + "f\u0005\u001f\u0000\u0000ce\u0003\u0004\u0002\u0000dc\u0001\u0000\u0000"+ + "\u0000eh\u0001\u0000\u0000\u0000fd\u0001\u0000\u0000\u0000fg\u0001\u0000"+ + "\u0000\u0000gi\u0001\u0000\u0000\u0000hf\u0001\u0000\u0000\u0000ij\u0005"+ + " \u0000\u0000j\u0003\u0001\u0000\u0000\u0000ko\u0003\u0006\u0003\u0000"+ + "lo\u0003\b\u0004\u0000mo\u0003\n\u0005\u0000nk\u0001\u0000\u0000\u0000"+ + "nl\u0001\u0000\u0000\u0000nm\u0001\u0000\u0000\u0000o\u0005\u0001\u0000"+ + "\u0000\u0000pr\u0005\u0007\u0000\u0000qp\u0001\u0000\u0000\u0000qr\u0001"+ + "\u0000\u0000\u0000rs\u0001\u0000\u0000\u0000st\u0005/\u0000\u0000tv\u0005"+ + "\u001d\u0000\u0000uw\u0003\f\u0006\u0000vu\u0001\u0000\u0000\u0000vw\u0001"+ + "\u0000\u0000\u0000wx\u0001\u0000\u0000\u0000xy\u0005\u001e\u0000\u0000"+ + "yz\u0003\u0014\n\u0000z\u0007\u0001\u0000\u0000\u0000{}\u0005\u0007\u0000"+ + "\u0000|{\u0001\u0000\u0000\u0000|}\u0001\u0000\u0000\u0000}~\u0001\u0000"+ + "\u0000\u0000~\u007f\u0003R)\u0000\u007f\u0080\u0005/\u0000\u0000\u0080"+ + "\u0081\u0005!\u0000\u0000\u0081\t\u0001\u0000\u0000\u0000\u0082\u0083"+ + "\u0005\b\u0000\u0000\u0083\u0093\u0003\u0014\n\u0000\u0084\u0086\u0005"+ + "\u0007\u0000\u0000\u0085\u0084\u0001\u0000\u0000\u0000\u0085\u0086\u0001"+ + "\u0000\u0000\u0000\u0086\u0089\u0001\u0000\u0000\u0000\u0087\u008a\u0003"+ + "R)\u0000\u0088\u008a\u0005\u0003\u0000\u0000\u0089\u0087\u0001\u0000\u0000"+ + "\u0000\u0089\u0088\u0001\u0000\u0000\u0000\u008a\u008b\u0001\u0000\u0000"+ + "\u0000\u008b\u008c\u0005/\u0000\u0000\u008c\u008e\u0005\u001d\u0000\u0000"+ + "\u008d\u008f\u0003\f\u0006\u0000\u008e\u008d\u0001\u0000\u0000\u0000\u008e"+ + "\u008f\u0001\u0000\u0000\u0000\u008f\u0090\u0001\u0000\u0000\u0000\u0090"+ + "\u0091\u0005\u001e\u0000\u0000\u0091\u0093\u0003\u0014\n\u0000\u0092\u0082"+ + "\u0001\u0000\u0000\u0000\u0092\u0085\u0001\u0000\u0000\u0000\u0093\u000b"+ + "\u0001\u0000\u0000\u0000\u0094\u0099\u0003\u000e\u0007\u0000\u0095\u0096"+ + "\u0005\"\u0000\u0000\u0096\u0098\u0003\u000e\u0007\u0000\u0097\u0095\u0001"+ + "\u0000\u0000\u0000\u0098\u009b\u0001\u0000\u0000\u0000\u0099\u0097\u0001"+ + "\u0000\u0000\u0000\u0099\u009a\u0001\u0000\u0000\u0000\u009a\r\u0001\u0000"+ + "\u0000\u0000\u009b\u0099\u0001\u0000\u0000\u0000\u009c\u009d\u0003R)\u0000"+ + "\u009d\u009e\u0005/\u0000\u0000\u009e\u000f\u0001\u0000\u0000\u0000\u009f"+ + "\u00a4\u0003*\u0015\u0000\u00a0\u00a1\u0005\"\u0000\u0000\u00a1\u00a3"+ + "\u0003*\u0015\u0000\u00a2\u00a0\u0001\u0000\u0000\u0000\u00a3\u00a6\u0001"+ + "\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000\u0000\u00a4\u00a5\u0001"+ + "\u0000\u0000\u0000\u00a5\u00a8\u0001\u0000\u0000\u0000\u00a6\u00a4\u0001"+ + "\u0000\u0000\u0000\u00a7\u009f\u0001\u0000\u0000\u0000\u00a7\u00a8\u0001"+ + "\u0000\u0000\u0000\u00a8\u0011\u0001\u0000\u0000\u0000\u00a9\u00aa\u0003"+ + "\u0016\u000b\u0000\u00aa\u00ab\u0005!\u0000\u0000\u00ab\u00b7\u0001\u0000"+ + "\u0000\u0000\u00ac\u00ad\u0003\u0018\f\u0000\u00ad\u00ae\u0005!\u0000"+ + "\u0000\u00ae\u00b7\u0001\u0000\u0000\u0000\u00af\u00b7\u0003\u0014\n\u0000"+ + "\u00b0\u00b7\u0003\u001a\r\u0000\u00b1\u00b7\u0003\u001c\u000e\u0000\u00b2"+ + "\u00b7\u0003\u001e\u000f\u0000\u00b3\u00b4\u0003$\u0012\u0000\u00b4\u00b5"+ + "\u0005!\u0000\u0000\u00b5\u00b7\u0001\u0000\u0000\u0000\u00b6\u00a9\u0001"+ + "\u0000\u0000\u0000\u00b6\u00ac\u0001\u0000\u0000\u0000\u00b6\u00af\u0001"+ + "\u0000\u0000\u0000\u00b6\u00b0\u0001\u0000\u0000\u0000\u00b6\u00b1\u0001"+ + "\u0000\u0000\u0000\u00b6\u00b2\u0001\u0000\u0000\u0000\u00b6\u00b3\u0001"+ + "\u0000\u0000\u0000\u00b7\u0013\u0001\u0000\u0000\u0000\u00b8\u00bc\u0005"+ + "\u001f\u0000\u0000\u00b9\u00bb\u0003\u0012\t\u0000\u00ba\u00b9\u0001\u0000"+ + "\u0000\u0000\u00bb\u00be\u0001\u0000\u0000\u0000\u00bc\u00ba\u0001\u0000"+ + "\u0000\u0000\u00bc\u00bd\u0001\u0000\u0000\u0000\u00bd\u00bf\u0001\u0000"+ + "\u0000\u0000\u00be\u00bc\u0001\u0000\u0000\u0000\u00bf\u00c0\u0005 \u0000"+ + "\u0000\u00c0\u0015\u0001\u0000\u0000\u0000\u00c1\u00c3\u0005)\u0000\u0000"+ + "\u00c2\u00c4\u0003*\u0015\u0000\u00c3\u00c2\u0001\u0000\u0000\u0000\u00c3"+ + "\u00c4\u0001\u0000\u0000\u0000\u00c4\u0017\u0001\u0000\u0000\u0000\u00c5"+ + "\u00c6\u0003R)\u0000\u00c6\u00c9\u0005/\u0000\u0000\u00c7\u00c8\u0005"+ + "\r\u0000\u0000\u00c8\u00ca\u0003*\u0015\u0000\u00c9\u00c7\u0001\u0000"+ + "\u0000\u0000\u00c9\u00ca\u0001\u0000\u0000\u0000\u00ca\u0019\u0001\u0000"+ + "\u0000\u0000\u00cb\u00cc\u0005%\u0000\u0000\u00cc\u00cd\u0005\u001d\u0000"+ + "\u0000\u00cd\u00ce\u0003*\u0015\u0000\u00ce\u00cf\u0005\u001e\u0000\u0000"+ + "\u00cf\u00d0\u0003\u0014\n\u0000\u00d0\u001b\u0001\u0000\u0000\u0000\u00d1"+ + "\u00d2\u0005(\u0000\u0000\u00d2\u00d5\u0005\u001d\u0000\u0000\u00d3\u00d6"+ + "\u0003$\u0012\u0000\u00d4\u00d6\u0003\u0018\f\u0000\u00d5\u00d3\u0001"+ + "\u0000\u0000\u0000\u00d5\u00d4\u0001\u0000\u0000\u0000\u00d6\u00d7\u0001"+ + "\u0000\u0000\u0000\u00d7\u00d9\u0005!\u0000\u0000\u00d8\u00da\u0003*\u0015"+ + "\u0000\u00d9\u00d8\u0001\u0000\u0000\u0000\u00d9\u00da\u0001\u0000\u0000"+ + "\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00dd\u0005!\u0000\u0000"+ + "\u00dc\u00de\u0003$\u0012\u0000\u00dd\u00dc\u0001\u0000\u0000\u0000\u00dd"+ + "\u00de\u0001\u0000\u0000\u0000\u00de\u00df\u0001\u0000\u0000\u0000\u00df"+ + "\u00e0\u0005\u001e\u0000\u0000\u00e0\u00e1\u0003\u0014\n\u0000\u00e1\u001d"+ + "\u0001\u0000\u0000\u0000\u00e2\u00e6\u0003 \u0010\u0000\u00e3\u00e5\u0003"+ + "\"\u0011\u0000\u00e4\u00e3\u0001\u0000\u0000\u0000\u00e5\u00e8\u0001\u0000"+ + "\u0000\u0000\u00e6\u00e4\u0001\u0000\u0000\u0000\u00e6\u00e7\u0001\u0000"+ + "\u0000\u0000\u00e7\u001f\u0001\u0000\u0000\u0000\u00e8\u00e6\u0001\u0000"+ + "\u0000\u0000\u00e9\u00ea\u0005&\u0000\u0000\u00ea\u00eb\u0005\u001d\u0000"+ + "\u0000\u00eb\u00ec\u0003*\u0015\u0000\u00ec\u00ed\u0005\u001e\u0000\u0000"+ + "\u00ed\u00ee\u0003\u0014\n\u0000\u00ee!\u0001\u0000\u0000\u0000\u00ef"+ + "\u00f0\u0005\'\u0000\u0000\u00f0\u00f1\u0003\u0014\n\u0000\u00f1#\u0001"+ + "\u0000\u0000\u0000\u00f2\u00f7\u0003&\u0013\u0000\u00f3\u00f7\u0003(\u0014"+ + "\u0000\u00f4\u00f7\u0003L&\u0000\u00f5\u00f7\u00030\u0018\u0000\u00f6"+ + "\u00f2\u0001\u0000\u0000\u0000\u00f6\u00f3\u0001\u0000\u0000\u0000\u00f6"+ + "\u00f4\u0001\u0000\u0000\u0000\u00f6\u00f5\u0001\u0000\u0000\u0000\u00f7"+ + "%\u0001\u0000\u0000\u0000\u00f8\u00f9\u0003>\u001f\u0000\u00f9\u00fa\u0005"+ + "\r\u0000\u0000\u00fa\u00fb\u0003*\u0015\u0000\u00fb\'\u0001\u0000\u0000"+ + "\u0000\u00fc\u00fd\u0005*\u0000\u0000\u00fd\u00fe\u0005/\u0000\u0000\u00fe"+ + "\u00ff\u0005\u001d\u0000\u0000\u00ff\u0100\u0003\u0010\b\u0000\u0100\u0101"+ + "\u0005\u001e\u0000\u0000\u0101)\u0001\u0000\u0000\u0000\u0102\u0105\u0003"+ + ",\u0016\u0000\u0103\u0105\u0003B!\u0000\u0104\u0102\u0001\u0000\u0000"+ + "\u0000\u0104\u0103\u0001\u0000\u0000\u0000\u0105+\u0001\u0000\u0000\u0000"+ + "\u0106\u0111\u0005$\u0000\u0000\u0107\u0111\u0005/\u0000\u0000\u0108\u0111"+ + "\u0003@ \u0000\u0109\u0111\u0003T*\u0000\u010a\u0111\u0003.\u0017\u0000"+ + "\u010b\u0111\u0003$\u0012\u0000\u010c\u010d\u0005\u001d\u0000\u0000\u010d"+ + "\u010e\u0003*\u0015\u0000\u010e\u010f\u0005\u001e\u0000\u0000\u010f\u0111"+ + "\u0001\u0000\u0000\u0000\u0110\u0106\u0001\u0000\u0000\u0000\u0110\u0107"+ + "\u0001\u0000\u0000\u0000\u0110\u0108\u0001\u0000\u0000\u0000\u0110\u0109"+ + "\u0001\u0000\u0000\u0000\u0110\u010a\u0001\u0000\u0000\u0000\u0110\u010b"+ + "\u0001\u0000\u0000\u0000\u0110\u010c\u0001\u0000\u0000\u0000\u0111-\u0001"+ + "\u0000\u0000\u0000\u0112\u0113\u0005\u0019\u0000\u0000\u0113\u0114\u0003"+ + "*\u0015\u0000\u0114/\u0001\u0000\u0000\u0000\u0115\u0118\u00032\u0019"+ + "\u0000\u0116\u0118\u00038\u001c\u0000\u0117\u0115\u0001\u0000\u0000\u0000"+ + "\u0117\u0116\u0001\u0000\u0000\u0000\u01181\u0001\u0000\u0000\u0000\u0119"+ + "\u011c\u00034\u001a\u0000\u011a\u011c\u00036\u001b\u0000\u011b\u0119\u0001"+ + "\u0000\u0000\u0000\u011b\u011a\u0001\u0000\u0000\u0000\u011c3\u0001\u0000"+ + "\u0000\u0000\u011d\u011e\u0005\u0001\u0000\u0000\u011e\u011f\u0003>\u001f"+ + "\u0000\u011f5\u0001\u0000\u0000\u0000\u0120\u0121\u0003>\u001f\u0000\u0121"+ + "\u0122\u0005\u0001\u0000\u0000\u01227\u0001\u0000\u0000\u0000\u0123\u0126"+ + "\u0003:\u001d\u0000\u0124\u0126\u0003<\u001e\u0000\u0125\u0123\u0001\u0000"+ + "\u0000\u0000\u0125\u0124\u0001\u0000\u0000\u0000\u01269\u0001\u0000\u0000"+ + "\u0000\u0127\u0128\u0005\u0002\u0000\u0000\u0128\u0129\u0003>\u001f\u0000"+ + "\u0129;\u0001\u0000\u0000\u0000\u012a\u012b\u0003>\u001f\u0000\u012b\u012c"+ + "\u0005\u0002\u0000\u0000\u012c=\u0001\u0000\u0000\u0000\u012d\u0130\u0005"+ + "/\u0000\u0000\u012e\u0130\u0003@ \u0000\u012f\u012d\u0001\u0000\u0000"+ + "\u0000\u012f\u012e\u0001\u0000\u0000\u0000\u0130?\u0001\u0000\u0000\u0000"+ + "\u0131\u0132\u0005$\u0000\u0000\u0132\u0133\u0005\u001c\u0000\u0000\u0133"+ + "\u0140\u0005/\u0000\u0000\u0134\u0135\u0005$\u0000\u0000\u0135\u0137\u0005"+ + "\u001c\u0000\u0000\u0136\u0134\u0001\u0000\u0000\u0000\u0136\u0137\u0001"+ + "\u0000\u0000\u0000\u0137\u013a\u0001\u0000\u0000\u0000\u0138\u0139\u0005"+ + "/\u0000\u0000\u0139\u013b\u0005\u001c\u0000\u0000\u013a\u0138\u0001\u0000"+ + "\u0000\u0000\u013b\u013c\u0001\u0000\u0000\u0000\u013c\u013a\u0001\u0000"+ + "\u0000\u0000\u013c\u013d\u0001\u0000\u0000\u0000\u013d\u013e\u0001\u0000"+ + "\u0000\u0000\u013e\u0140\u0005/\u0000\u0000\u013f\u0131\u0001\u0000\u0000"+ + "\u0000\u013f\u0136\u0001\u0000\u0000\u0000\u0140A\u0001\u0000\u0000\u0000"+ + "\u0141\u0144\u0003D\"\u0000\u0142\u0144\u0003J%\u0000\u0143\u0141\u0001"+ + "\u0000\u0000\u0000\u0143\u0142\u0001\u0000\u0000\u0000\u0144C\u0001\u0000"+ + "\u0000\u0000\u0145\u0146\u0006\"\uffff\uffff\u0000\u0146\u0147\u0003F"+ + "#\u0000\u0147\u014d\u0001\u0000\u0000\u0000\u0148\u0149\n\u0002\u0000"+ + "\u0000\u0149\u014a\u0005\n\u0000\u0000\u014a\u014c\u0003F#\u0000\u014b"+ + "\u0148\u0001\u0000\u0000\u0000\u014c\u014f\u0001\u0000\u0000\u0000\u014d"+ + "\u014b\u0001\u0000\u0000\u0000\u014d\u014e\u0001\u0000\u0000\u0000\u014e"+ + "E\u0001\u0000\u0000\u0000\u014f\u014d\u0001\u0000\u0000\u0000\u0150\u0151"+ + "\u0006#\uffff\uffff\u0000\u0151\u0152\u0003H$\u0000\u0152\u0158\u0001"+ + "\u0000\u0000\u0000\u0153\u0154\n\u0002\u0000\u0000\u0154\u0155\u0005\t"+ + "\u0000\u0000\u0155\u0157\u0003H$\u0000\u0156\u0153\u0001\u0000\u0000\u0000"+ + "\u0157\u015a\u0001\u0000\u0000\u0000\u0158\u0156\u0001\u0000\u0000\u0000"+ + "\u0158\u0159\u0001\u0000\u0000\u0000\u0159G\u0001\u0000\u0000\u0000\u015a"+ + "\u0158\u0001\u0000\u0000\u0000\u015b\u0164\u0005,\u0000\u0000\u015c\u0164"+ + "\u0005/\u0000\u0000\u015d\u0164\u0003@ \u0000\u015e\u015f\u0003L&\u0000"+ + "\u015f\u0160\u0005\u001d\u0000\u0000\u0160\u0161\u0003D\"\u0000\u0161"+ + "\u0162\u0005\u001e\u0000\u0000\u0162\u0164\u0001\u0000\u0000\u0000\u0163"+ + "\u015b\u0001\u0000\u0000\u0000\u0163\u015c\u0001\u0000\u0000\u0000\u0163"+ + "\u015d\u0001\u0000\u0000\u0000\u0163\u015e\u0001\u0000\u0000\u0000\u0164"+ + "I\u0001\u0000\u0000\u0000\u0165\u0166\u0003,\u0016\u0000\u0166\u0167\u0003"+ + "V+\u0000\u0167\u0168\u0003*\u0015\u0000\u0168K\u0001\u0000\u0000\u0000"+ + "\u0169\u016b\u0003N\'\u0000\u016a\u0169\u0001\u0000\u0000\u0000\u016a"+ + "\u016b\u0001\u0000\u0000\u0000\u016b\u016f\u0001\u0000\u0000\u0000\u016c"+ + "\u016e\u0003P(\u0000\u016d\u016c\u0001\u0000\u0000\u0000\u016e\u0171\u0001"+ + "\u0000\u0000\u0000\u016f\u016d\u0001\u0000\u0000\u0000\u016f\u0170\u0001"+ + "\u0000\u0000\u0000\u0170\u0172\u0001\u0000\u0000\u0000\u0171\u016f\u0001"+ + "\u0000\u0000\u0000\u0172\u0173\u0005/\u0000\u0000\u0173\u0174\u0005\u001d"+ + "\u0000\u0000\u0174\u0175\u0003\u0010\b\u0000\u0175\u0176\u0005\u001e\u0000"+ + "\u0000\u0176M\u0001\u0000\u0000\u0000\u0177\u017c\u0005$\u0000\u0000\u0178"+ + "\u017c\u0003@ \u0000\u0179\u017c\u0003(\u0014\u0000\u017a\u017c\u0005"+ + "/\u0000\u0000\u017b\u0177\u0001\u0000\u0000\u0000\u017b\u0178\u0001\u0000"+ + "\u0000\u0000\u017b\u0179\u0001\u0000\u0000\u0000\u017b\u017a\u0001\u0000"+ + "\u0000\u0000\u017c\u017d\u0001\u0000\u0000\u0000\u017d\u017e\u0005\u001c"+ + "\u0000\u0000\u017eO\u0001\u0000\u0000\u0000\u017f\u0180\u0005/\u0000\u0000"+ + "\u0180\u0181\u0005\u001d\u0000\u0000\u0181\u0182\u0003\u0010\b\u0000\u0182"+ + "\u0183\u0005\u001e\u0000\u0000\u0183\u0184\u0005\u001c\u0000\u0000\u0184"+ + "Q\u0001\u0000\u0000\u0000\u0185\u0186\u0007\u0000\u0000\u0000\u0186S\u0001"+ + "\u0000\u0000\u0000\u0187\u0188\u0007\u0001\u0000\u0000\u0188U\u0001\u0000"+ + "\u0000\u0000\u0189\u018a\u0007\u0002\u0000\u0000\u018aW\u0001\u0000\u0000"+ + "\u0000\'[^fnqv|\u0085\u0089\u008e\u0092\u0099\u00a4\u00a7\u00b6\u00bc"+ + "\u00c3\u00c9\u00d5\u00d9\u00dd\u00e6\u00f6\u0104\u0110\u0117\u011b\u0125"+ + "\u012f\u0136\u013c\u013f\u0143\u014d\u0158\u0163\u016a\u016f\u017b"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/parser/generated/SimpleJavaVisitor.java b/src/main/java/parser/generated/SimpleJavaVisitor.java new file mode 100644 index 0000000..3b31f92 --- /dev/null +++ b/src/main/java/parser/generated/SimpleJavaVisitor.java @@ -0,0 +1,277 @@ +// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1 +package parser.generated; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link SimpleJavaParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface SimpleJavaVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link SimpleJavaParser#program}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitProgram(SimpleJavaParser.ProgramContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#classDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext 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#fieldDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#parameterList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameterList(SimpleJavaParser.ParameterListContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#parameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameter(SimpleJavaParser.ParameterContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#argumentList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(SimpleJavaParser.StatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#block}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(SimpleJavaParser.BlockContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#forStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitForStatement(SimpleJavaParser.ForStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfStatement(SimpleJavaParser.IfStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#elseStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#statementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#assign}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(SimpleJavaParser.AssignContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#newDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(SimpleJavaParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#unaryExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#notExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#crementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#incrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#decrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#assignableExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#memberAccess}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#binaryExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#calculationExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#dotExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#methodCall}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMethodCall(SimpleJavaParser.MethodCallContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#target}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTarget(SimpleJavaParser.TargetContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#chainedMethod}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitType(SimpleJavaParser.TypeContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#value}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValue(SimpleJavaParser.ValueContext ctx); + /** + * Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx); +} \ No newline at end of file -- 2.34.1 From fd8c3b066ab7efa11693cebcf847d8d185c12eb4 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 20 Jun 2024 11:43:58 +0200 Subject: [PATCH 09/19] Trying to change to new AST --- src/main/java/Main.java | 3 +- src/main/java/ast/member/MethodNode.java | 9 +- .../ast/statement/ReturnStatementNode.java | 4 - src/main/java/bytecode/ClassCodeGen.java | 11 +- src/main/java/bytecode/Mapper.java | 69 ++++---- src/main/java/bytecode/MethodCodeGen.java | 94 +++++----- src/main/java/semantic/Scope.java | 2 +- src/main/java/semantic/SemanticAnalyzer.java | 160 +----------------- src/main/java/semantic/SemanticVisitor.java | 29 +--- .../java/semantic/context/ClassContext.java | 4 +- src/main/java/semantic/context/Context.java | 2 +- .../java/semantic/context/FieldContext.java | 7 +- .../java/typechecker/TypeCheckResult.java | 2 +- src/test/java/semantic/Mocker.java | 72 ++------ src/test/java/semantic/SemanticTest.java | 150 +--------------- .../java/semantic/endToTAST/CorrectTest.java | 41 +++++ .../resources/semantic/endToTAST/Test.java | 7 + 17 files changed, 171 insertions(+), 495 deletions(-) create mode 100644 src/test/java/semantic/endToTAST/CorrectTest.java create mode 100644 src/test/resources/semantic/endToTAST/Test.java diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 779e5d1..61e2711 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,6 +1,5 @@ -import oldAst.ASTNode; +import ast.*; import org.antlr.v4.runtime.*; -import oldAst.ProgramNode; import bytecode.ByteCodeGenerator; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index e508629..2d79ee5 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -9,16 +9,15 @@ import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; -import java.util.ArrayList; import java.util.List; -public class MethodNode implements MemberNode { +public class MethodNode implements MemberNode, Visitable { AccessModifierNode accesModifier; TypeNode type; Boolean voidType; String identifier; List parameters; - BlockNode block; + public BlockNode block; public MethodNode() {} @@ -55,6 +54,8 @@ public class MethodNode implements MemberNode { return isSame; } + */ + @Override public TypeCheckResult accept(SemanticVisitor visitor) { return visitor.analyze(this); @@ -64,6 +65,6 @@ public class MethodNode implements MemberNode { public void accept(MethodVisitor methodVisitor) { methodVisitor.visit(this); } - */ + } diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java index ab111c5..ec80fb0 100644 --- a/src/main/java/ast/statement/ReturnStatementNode.java +++ b/src/main/java/ast/statement/ReturnStatementNode.java @@ -2,10 +2,6 @@ package ast.statement; import ast.ASTNode; import ast.expression.ExpressionNode; -import ast.type.TypeNode; - -import java.util.ArrayList; -import java.util.List; public class ReturnStatementNode implements ASTNode { public ExpressionNode expression; diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index b0afa69..c65c3c6 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -4,11 +4,10 @@ import ast.ClassNode; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; -import ast.type.BaseTypeNode; +import ast.type.TypeNode; import bytecode.visitor.ClassVisitor; import java.io.File; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; import java.io.FileOutputStream; import java.io.IOException; @@ -25,8 +24,8 @@ public class ClassCodeGen implements ClassVisitor { @Override public void visit(ClassNode classNode) { classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null, - "java/lang/Object", null); +// classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null, +// "java/lang/Object", null); for (MemberNode memberNode : classNode.members) { if (memberNode instanceof FieldNode) { @@ -45,8 +44,8 @@ public class ClassCodeGen implements ClassVisitor { @Override public void visit(FieldNode fieldNode) { - if(fieldNode.type instanceof BaseTypeNode baseTypeNode){ - classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null ); + if(fieldNode.type instanceof TypeNode baseTypeNode){ +// classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null ); } classWriter.visitEnd(); } diff --git a/src/main/java/bytecode/Mapper.java b/src/main/java/bytecode/Mapper.java index faa4a67..5dad54c 100644 --- a/src/main/java/bytecode/Mapper.java +++ b/src/main/java/bytecode/Mapper.java @@ -1,44 +1,41 @@ package bytecode; -import ast.parameter.ParameterNode; import ast.type.*; -import org.objectweb.asm.Opcodes; -import ast.type.BaseTypeNode; public class Mapper { - public int mapAccessTypeToOpcode(AccessTypeNode type) { - switch (type.enumAccessTypeNode) { - case EnumAccessTypeNode.PUBLIC: - return Opcodes.ACC_PUBLIC; - case EnumAccessTypeNode.PRIVATE: - return Opcodes.ACC_PRIVATE; - } - return 0; - } +// public int mapAccessTypeToOpcode(AccessModifierNode type) { +// switch (type.enumAccessTypeNode) { +// case EnumAccessTypeNode.PUBLIC: +// return Opcodes.ACC_PUBLIC; +// case EnumAccessTypeNode.PRIVATE: +// return Opcodes.ACC_PRIVATE; +// } +// return 0; +// } - public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) { - String descriptor = "("; - for(ParameterNode parameterNode : parameterListNode.parameters) { - descriptor += getTypeChar(EnumTypeNode.INT); - } - descriptor += ")"; - descriptor += getTypeChar(baseTypeNode.enumType); - return descriptor; - } +// public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) { +// String descriptor = "("; +// for(ParameterNode parameterNode : parameterListNode.parameters) { +// descriptor += getTypeChar(EnumTypeNode.INT); +// } +// descriptor += ")"; +// descriptor += getTypeChar(baseTypeNode.enumType); +// return descriptor; +// } - public String getTypeChar(EnumTypeNode enumTypeNode) { - String typeChar = ""; - switch (enumTypeNode) { - case EnumTypeNode.INT: - typeChar = "I"; - break; - case EnumTypeNode.CHAR: - typeChar = "C"; - break; - case EnumTypeNode.BOOLEAN: - typeChar = "Z"; - break; - } - return typeChar; - } +// public String getTypeChar(TypeEnum enumTypeNode) { +// String typeChar = ""; +// switch (enumTypeNode) { +// case TypeEnum.INT: +// typeChar = "I"; +// break; +// case TypeEnum.CHAR: +// typeChar = "C"; +// break; +// case TypeEnum.BOOLEAN: +// typeChar = "Z"; +// break; +// } +// return typeChar; +// } } diff --git a/src/main/java/bytecode/MethodCodeGen.java b/src/main/java/bytecode/MethodCodeGen.java index 1cdf1e2..358d540 100644 --- a/src/main/java/bytecode/MethodCodeGen.java +++ b/src/main/java/bytecode/MethodCodeGen.java @@ -2,12 +2,8 @@ package bytecode; import ast.member.ConstructorNode; import ast.member.MethodNode; -import ast.parameter.ParameterNode; -import ast.type.BaseTypeNode; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; import java.util.ArrayList; import java.util.List; @@ -31,12 +27,12 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor { @Override public void visit(ConstructorNode constructorNode) { - methodVisitor = - classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.visibility), - "", - "()V", - null, - null); +// methodVisitor = +// classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.visibility), +// "", +// "()V", +// null, +// null); methodVisitor.visitCode(); methodVisitor.visitVarInsn(ALOAD, 0); methodVisitor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); @@ -47,52 +43,52 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor { @Override public void visit(MethodNode methodNode) { - if (methodNode.type instanceof BaseTypeNode baseTypeNode) { - methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.visibility), - methodNode.identifier, - mapper.generateMethodDescriptor(baseTypeNode, methodNode.parameters), - null, - null); +// if (methodNode.type instanceof BaseTypeNode baseTypeNode) { +// methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.visibility), +// methodNode.identifier, +// mapper.generateMethodDescriptor(baseTypeNode, methodNode.parameters), +// null, +// null); methodVisitor.visitCode(); localVaribales.add("this"); - for (ParameterNode parameterNode : methodNode.parameters.parameters) { - localVaribales.add(parameterNode.identifier); - } +// for (ParameterNode parameterNode : methodNode.parameters.parameters) { +// localVaribales.add(parameterNode.identifier); +// } //test(); methodVisitor.visitMaxs(1, localVaribales.size()); methodVisitor.visitEnd(); - } +// } } - public void test() { - Label start = new Label(); - Label loop = new Label(); - Label end = new Label(); - methodVisitor.visitLabel(start); - //methodVisitor.visitVarInsn(Opcodes.ICONST_M1, 99); - //methodVisitor.visitInsn(Opcodes.ICONST_5); - methodVisitor.visitLdcInsn(99); - // methodVisitor.visitInsn(Opcodes.ICONST_0); - //methodVisitor.visitVarInsn(Opcodes.ILOAD, 2); - methodVisitor.visitVarInsn(Opcodes.ISTORE, 1); - methodVisitor.visitLabel(loop); - methodVisitor.visitVarInsn(Opcodes.ILOAD, 1); - methodVisitor.visitInsn(Opcodes.ICONST_5); - methodVisitor.visitJumpInsn(Opcodes.IF_ICMPGE, end); - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, - "java/lang/System", "out", - "Ljava/io/PrintStream;"); - methodVisitor.visitLdcInsn("Bytecode"); - methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, - "java/io/PrintStream", "println", - "(Ljava/lang/String;)V", false); - methodVisitor.visitIincInsn(1, 1); - methodVisitor.visitJumpInsn(Opcodes.GOTO, loop); - methodVisitor.visitLabel(end); - methodVisitor.visitVarInsn(Opcodes.ILOAD, 1); - methodVisitor.visitInsn(Opcodes.IRETURN); - methodVisitor.visitEnd(); - } +// public void test() { +// Label start = new Label(); +// Label loop = new Label(); +// Label end = new Label(); +// methodVisitor.visitLabel(start); +// //methodVisitor.visitVarInsn(Opcodes.ICONST_M1, 99); +// //methodVisitor.visitInsn(Opcodes.ICONST_5); +// methodVisitor.visitLdcInsn(99); +// // methodVisitor.visitInsn(Opcodes.ICONST_0); +// //methodVisitor.visitVarInsn(Opcodes.ILOAD, 2); +// methodVisitor.visitVarInsn(Opcodes.ISTORE, 1); +// methodVisitor.visitLabel(loop); +// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1); +// methodVisitor.visitInsn(Opcodes.ICONST_5); +// methodVisitor.visitJumpInsn(Opcodes.IF_ICMPGE, end); +// methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, +// "java/lang/System", "out", +// "Ljava/io/PrintStream;"); +// methodVisitor.visitLdcInsn("Bytecode"); +// methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, +// "java/io/PrintStream", "println", +// "(Ljava/lang/String;)V", false); +// methodVisitor.visitIincInsn(1, 1); +// methodVisitor.visitJumpInsn(Opcodes.GOTO, loop); +// methodVisitor.visitLabel(end); +// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1); +// methodVisitor.visitInsn(Opcodes.IRETURN); +// methodVisitor.visitEnd(); +// } } diff --git a/src/main/java/semantic/Scope.java b/src/main/java/semantic/Scope.java index 60e9d2b..7cf4cc9 100644 --- a/src/main/java/semantic/Scope.java +++ b/src/main/java/semantic/Scope.java @@ -1,6 +1,6 @@ package semantic; -import oldAst.type.TypeNode; +import ast.type.TypeNode; import java.util.HashMap; import java.util.Stack; diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 3bce422..d3526f4 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -1,25 +1,16 @@ package semantic; -import oldAst.*; -import oldAst.expression.*; -import oldAst.member.FieldNode; -import oldAst.member.MemberNode; - -import oldAst.member.MethodNode; -import oldAst.parameter.ParameterListNode; -import oldAst.parameter.ParameterNode; -import oldAst.statement.*; -import oldAst.type.ReferenceTypeNode; -import oldAst.expression.This; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; -import oldAst.type.BaseTypeNode; -import oldAst.type.TypeNode; +import ast.*; +import ast.member.*; +import ast.statement.*; +import ast.statement.ifstatement.IfStatementNode; +import ast.type.*; import semantic.context.Context; import semantic.exeptions.AlreadyDeclearedException; import semantic.exeptions.NotDeclearedException; @@ -90,10 +81,7 @@ public class SemanticAnalyzer implements SemanticVisitor { for(MethodNode methode : currentClass.getMethods()){ if(methode.equals(methodNode)) break; - if(methode.isSame(methodNode)){ - errors.add(new AlreadyDeclearedException("This method has already been declared")); - valid = false; - } + } var result = methodNode.accept(this); valid = valid && result.isValid(); @@ -110,32 +98,6 @@ public class SemanticAnalyzer implements SemanticVisitor { currentScope.pushScope(); - //Parameter - ParameterListNode parameterListNode = methodNode.parameters; - if (parameterListNode != null) { - List parameters = parameterListNode.parameters; - for (ParameterNode parameter : parameters) { - if (currentScope.contains(parameter.identifier)) { - errors.add(new AlreadyDeclearedException("Duplicated Parameter " + parameter.identifier)); - return new TypeCheckResult(false, null); - } else { - currentScope.addLocalVar(parameter.identifier, parameter.type); - } - } - } - - //Statements - List statements = methodNode.statements; - for (StatementNode statement : statements) { - if (statement instanceof AssignmentStatementNode assignmentStatementNode) { - var result = assignmentStatementNode.accept(this); - valid = valid && result.isValid(); - } else if (statement instanceof VariableDeclarationStatementNode variableDeclarationStatementNode) { - var result = variableDeclarationStatementNode.accept(this); - valid = valid && result.isValid(); - } - } - currentScope.popScope(); return new TypeCheckResult(valid, null); } @@ -151,80 +113,6 @@ public class SemanticAnalyzer implements SemanticVisitor { return new TypeCheckResult(true, null); } - @Override - public TypeCheckResult analyze(AssignmentStatementNode assignmentStatementNode) { - boolean valid = true; - ExpressionNode expressionNodeLeft = assignmentStatementNode.expressionLeft; - var resultLeft = expressionNodeLeft.accept(this); - valid = valid && resultLeft.isValid(); - ExpressionNode expressionNodeRight = assignmentStatementNode.expressionRight; - var resultRight = expressionNodeRight.accept(this); - valid = valid && resultRight.isValid(); - - if(Objects.equals(resultLeft.getType(), resultRight.getType())){ - System.out.println("SAME TYPE"); - } else { - errors.add(new TypeMismatchException("Type mismatch")); - valid = false; - } - - return new TypeCheckResult(valid, null); - } - - @Override - public TypeCheckResult analyze(BinaryExpressionNode toCheck) { - boolean valid = true; - ExpressionNode left = toCheck.left; - var resultLeft = left.accept(this); - ExpressionNode right = toCheck.right; - var resultRight = right.accept(this); - - switch (toCheck.operator) { - case ASSIGNMENT: - if(Objects.equals(resultRight.getType(), resultLeft.getType())){ - System.out.println("Correct Type"); - } else { - valid = false; - errors.add(new TypeMismatchException("Type Mismatch " + resultLeft.getType() + " and " + resultRight.getType())); - } - break; - case DOT: - return new TypeCheckResult(true, resultRight.getType()); - default: - throw new RuntimeException("Unexpected operator: " + toCheck.operator); - } - - return new TypeCheckResult(valid, null); - } - - @Override - public TypeCheckResult analyze(IdentifierExpressionNode toCheck) { - if(toCheck.name == "this"){ - return new TypeCheckResult(true, null); - } else if (currentFields.get(toCheck.name) == null) { - errors.add(new AlreadyDeclearedException("Not declared " + toCheck.name + " in this scope")); - return new TypeCheckResult(false, null); - } else { - return new TypeCheckResult(false, currentFields.get(toCheck.name)); - } - } - - @Override - public TypeCheckResult analyze(UnaryExpressionNode toCheck) { - return null; - } - - @Override - public TypeCheckResult analyze(VariableDeclarationStatementNode toCheck) { - if (currentScope.contains(toCheck.identifier)) { - errors.add(new AlreadyDeclearedException("Already declared " + toCheck.identifier + " in this scope")); - return new TypeCheckResult(false, null); - } else { - currentScope.addLocalVar(toCheck.identifier, toCheck.type); - } - return new TypeCheckResult(true, null); - } - @Override public TypeCheckResult analyze(IfStatementNode toCheck) { return null; @@ -240,40 +128,4 @@ public class SemanticAnalyzer implements SemanticVisitor { return null; } - @Override - public TypeCheckResult analyze(LiteralNode toCheck) { - return new TypeCheckResult(true, toCheck.getType()); - } - - @Override - public TypeCheckResult analyze(InstVar toCheck) { - boolean valid = true; - - var result = toCheck.expression.accept(this); - - if(result.getType() instanceof BaseTypeNode){ - throw new RuntimeException("BaseType has no Methods or Fields"); - } else { - //Get typ of Field - - var type = (ReferenceTypeNode)result.getType(); - var classContext = context.getClass(type.getIdentifier()); - - if(classContext == null){ - errors.add(new NotDeclearedException("Not declared " + type.getIdentifier() + " in this scope")); - return new TypeCheckResult(false, null); - } else { - var field = classContext.getField(toCheck.identifier); - - return new TypeCheckResult(valid, field.getType()); - } - } - - } - - @Override - public TypeCheckResult analyze(This toCheck) { - return new TypeCheckResult(true, toCheck.getType()); - } - } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index 7139261..6bdc9a8 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -1,18 +1,10 @@ package semantic; -import ast.ClassNode; -import ast.expression.LiteralNode; -import ast.ProgramNode; -import ast.expression.BinaryExpressionNode; -import ast.expression.IdentifierExpressionNode; -import ast.expression.InstVar; -import ast.expression.unaryexpression.UnaryExpressionNode; -import ast.member.FieldNode; -import ast.member.MethodNode; +import ast.*; +import ast.member.*; import ast.statement.*; -import ast.expression.This; -import ast.statement.ifstatement.IfStatementNode; +import ast.statement.ifstatement.*; import typechecker.TypeCheckResult; public interface SemanticVisitor { @@ -25,25 +17,10 @@ public interface SemanticVisitor { TypeCheckResult analyze(FieldNode toCheck); - TypeCheckResult analyze(AssignmentStatementNode toCheck); - - TypeCheckResult analyze(BinaryExpressionNode toCheck); - - TypeCheckResult analyze(IdentifierExpressionNode toCheck); - - TypeCheckResult analyze(UnaryExpressionNode toCheck); - - TypeCheckResult analyze(VariableDeclarationStatementNode toCheck); - TypeCheckResult analyze(IfStatementNode toCheck); TypeCheckResult analyze(ReturnStatementNode toCheck); TypeCheckResult analyze(WhileStatementNode toCheck); - TypeCheckResult analyze(LiteralNode toCheck); - - TypeCheckResult analyze(InstVar toCheck); - - TypeCheckResult analyze(This toCheck); } \ No newline at end of file diff --git a/src/main/java/semantic/context/ClassContext.java b/src/main/java/semantic/context/ClassContext.java index 6b0d386..982866f 100644 --- a/src/main/java/semantic/context/ClassContext.java +++ b/src/main/java/semantic/context/ClassContext.java @@ -1,7 +1,7 @@ package semantic.context; -import oldAst.ClassNode; -import oldAst.member.FieldNode; +import ast.ClassNode; +import ast.member.FieldNode; import java.util.HashMap; public class ClassContext { diff --git a/src/main/java/semantic/context/Context.java b/src/main/java/semantic/context/Context.java index 31ba3de..d6431ef 100644 --- a/src/main/java/semantic/context/Context.java +++ b/src/main/java/semantic/context/Context.java @@ -1,6 +1,6 @@ package semantic.context; -import oldAst.ProgramNode; +import ast.ProgramNode; import java.util.HashMap; public class Context { diff --git a/src/main/java/semantic/context/FieldContext.java b/src/main/java/semantic/context/FieldContext.java index 2dad262..35c1f46 100644 --- a/src/main/java/semantic/context/FieldContext.java +++ b/src/main/java/semantic/context/FieldContext.java @@ -1,12 +1,11 @@ package semantic.context; -import oldAst.member.FieldNode; -import oldAst.type.AccessTypeNode; -import oldAst.type.TypeNode; +import ast.member.FieldNode; +import ast.type.*; public class FieldContext { - private AccessTypeNode accessModifier; + private AccessModifierNode accessModifier; private TypeNode type; public FieldContext(FieldNode field) { diff --git a/src/main/java/typechecker/TypeCheckResult.java b/src/main/java/typechecker/TypeCheckResult.java index a06d359..12143b2 100644 --- a/src/main/java/typechecker/TypeCheckResult.java +++ b/src/main/java/typechecker/TypeCheckResult.java @@ -1,7 +1,7 @@ package typechecker; -import oldAst.type.TypeNode; +import ast.type.TypeNode; public class TypeCheckResult { diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index 8ab9434..a60e83b 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -1,76 +1,36 @@ package semantic; -import oldAst.ClassNode; -import oldAst.expression.LiteralNode; -import oldAst.ProgramNode; -import oldAst.expression.*; -import oldAst.member.FieldNode; -import oldAst.member.MemberNode; -import oldAst.member.MethodNode; -import oldAst.parameter.ParameterListNode; -import oldAst.parameter.ParameterNode; -import oldAst.statement.AssignmentStatementNode; -import oldAst.statement.StatementNode; -import oldAst.type.*; +import ast.*; +import ast.block.BlockNode; +import ast.member.MethodNode; import java.util.ArrayList; import java.util.List; +import static parser.generated.SimpleJavaParser.Identifier; + public class Mocker { - public static ProgramNode mockCorrectProgrammNode(){ + public static ProgramNode mockCorrectClass(){ + ProgramNode p = new ProgramNode(); - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); + ClassNode c = new ClassNode(); + c.identifier = "testClass"; - MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar1"); - classNode.members.add(memberNode1); + MethodNode m = new MethodNode(); - MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "objectVar"); - classNode.members.add(memberNode2); + BlockNode b = new BlockNode(); - List parameterNodeList = new ArrayList(); - ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1"); - parameterNodeList.add(parameterNode1); - ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList); - List statementNodeList = new ArrayList(); - ExpressionNode expressionNodeLeft = new InstVar(new This("testClass"), "objectVar"); +// b.statements.add(); - LiteralNode expressionNodeRight = new LiteralNode(); - expressionNodeRight.setType(new BaseTypeNode(EnumTypeNode.INT)); + m.block = b; - StatementNode statementNode1 = new AssignmentStatementNode(expressionNodeLeft, expressionNodeRight); - statementNodeList.add(statementNode1); - - MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList ); - classNode.members.add(memberNode3); - - classList.add(classNode); - programNode.classes = classList; - - return programNode; + c.members.add(m); + p.classes.add(c); + return p; } - public static ProgramNode mockFieldNodeAlreadyDeclaredProgrammNode(){ - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); - - MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); - classNode.members.add(memberNode1); - - MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); - classNode.members.add(memberNode2); - - classList.add(classNode); - programNode.classes = classList; - - return programNode; - } } diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index cc413a2..8554022 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -1,161 +1,13 @@ package semantic; - -import oldAst.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import semantic.exeptions.AlreadyDeclearedException; -import semantic.exeptions.TypeMismatchException; - -import java.io.File; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; public class SemanticTest { - @BeforeEach - public void init() { - SemanticAnalyzer.clearAnalyzier(); - } - @Test - public void alreadyDeclaredLocalFieldVar() { + public void correctClass(){ - //Arrange - ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode(); - - //Act - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - //Assert - - assertEquals(1, SemanticAnalyzer.errors.size()); - assertEquals(true, SemanticAnalyzer.errors.get(0) instanceof AlreadyDeclearedException); - assertEquals(null, typedAst); - - } - - @Test - public void alreadyDecleared() { - - //Arrange - - ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode(); - - //Act - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - //Assert - - assertEquals(1, SemanticAnalyzer.errors.size()); - assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); - assertNull(typedAst); - - } - - @Test - public void shouldWorkWithNoError() { - - //Arrange - - ProgramNode programNode = Mocker.mockCorrectProgrammNode(); - - //Act - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - //Assert - - assertEquals(0, SemanticAnalyzer.errors.size()); - assertEquals(programNode, typedAst); - - } - - @Test - public void refTypeCorrect() { - - //Arrange - - ObjectMapper objectMapper = new ObjectMapper(); - ProgramNode programNode = null; - try{ - programNode = objectMapper.readValue(new File("src/test/resources/semantic/correctRefType.json"), ProgramNode.class); - } catch (Exception e) { - e.printStackTrace(); - } - - //Act - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - //Assert - - assertEquals(0, SemanticAnalyzer.errors.size()); - assertEquals(programNode, typedAst); - - } - - @Test - public void jsonWriteTest() { - - ObjectMapper objectMapper = new ObjectMapper(); - - //Arrange - - ProgramNode programNode = Mocker.mockCorrectProgrammNode(); - try{ - objectMapper.writeValue(new File("src/test/resources/semantic/test.json"), programNode); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @Test - public void jsonReadTest() { - - ObjectMapper objectMapper = new ObjectMapper(); - - ProgramNode programNode1 = null; - try{ - programNode1 = objectMapper.readValue(new File("src/test/resources/semantic/test.json"), ProgramNode.class); - } catch (Exception e) { - e.printStackTrace(); - } - - ProgramNode programNode2 = Mocker.mockCorrectProgrammNode(); - - } - - @Test - public void typeMismatch() { - - //Arrange - - ObjectMapper objectMapper = new ObjectMapper(); - ProgramNode programNode = null; - try{ - programNode = objectMapper.readValue(new File("src/test/resources/semantic/refTypeMismatch.json"), ProgramNode.class); - } catch (Exception e) { - e.printStackTrace(); - } - - //Act - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - //Assert - - assertEquals(1, SemanticAnalyzer.errors.size()); - assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); - assertNull(typedAst); } diff --git a/src/test/java/semantic/endToTAST/CorrectTest.java b/src/test/java/semantic/endToTAST/CorrectTest.java new file mode 100644 index 0000000..a8280fe --- /dev/null +++ b/src/test/java/semantic/endToTAST/CorrectTest.java @@ -0,0 +1,41 @@ +package semantic.endToTAST; + +import ast.ProgramNode; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTree; +import org.junit.jupiter.api.Test; +import parser.astBuilder.ASTBuilder; +import parser.generated.SimpleJavaLexer; +import parser.generated.SimpleJavaParser; + +import java.io.IOException; +import java.nio.file.Paths; + +public class CorrectTest { + + @Test + public void first(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/Test.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); // parse the input + + /* ------------------------- AST builder -> AST ------------------------- */ + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + System.out.println("Test"); + + } + +} diff --git a/src/test/resources/semantic/endToTAST/Test.java b/src/test/resources/semantic/endToTAST/Test.java new file mode 100644 index 0000000..bd4e673 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/Test.java @@ -0,0 +1,7 @@ +public class Test { + + public void test(){ + + } + +} \ No newline at end of file -- 2.34.1 From 0ec65af9f95e450c3f094ae395fb79be9d50960c Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 20 Jun 2024 16:53:31 +0200 Subject: [PATCH 10/19] Added Method Check --- src/main/java/ast/block/BlockNode.java | 11 ++- .../java/ast/expression/ExpressionNode.java | 4 +- .../unaryexpression/UnaryExpressionNode.java | 2 +- src/main/java/ast/member/MethodNode.java | 38 ++++---- .../java/ast/parameter/ParameterNode.java | 15 ++- .../LocalVariableDeclarationNode.java | 2 +- .../java/ast/statement/StatementNode.java | 6 +- src/main/java/ast/type/TypeNode.java | 6 ++ .../java/parser/astBuilder/ASTBuilder.java | 2 +- src/main/java/semantic/SemanticAnalyzer.java | 54 ++++++++++- src/main/java/semantic/SemanticVisitor.java | 7 ++ src/test/java/semantic/Mocker.java | 92 +++++++++++++++++-- src/test/java/semantic/SemanticTest.java | 51 +++++++++- .../java/semantic/endToTAST/CorrectTest.java | 10 ++ .../resources/semantic/endToTAST/Test.java | 5 +- 15 files changed, 261 insertions(+), 44 deletions(-) diff --git a/src/main/java/ast/block/BlockNode.java b/src/main/java/ast/block/BlockNode.java index a5ff3f7..67d9e81 100644 --- a/src/main/java/ast/block/BlockNode.java +++ b/src/main/java/ast/block/BlockNode.java @@ -2,11 +2,14 @@ package ast.block; import ast.ASTNode; import ast.statement.StatementNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class BlockNode implements ASTNode { +public class BlockNode implements ASTNode, Visitable { public List statements = new ArrayList<>(); public BlockNode() {} @@ -14,4 +17,10 @@ public class BlockNode implements ASTNode { public void addStatement(StatementNode statement) { statements.add(statement); } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/ast/expression/ExpressionNode.java index 1566f3b..282b9b7 100644 --- a/src/main/java/ast/expression/ExpressionNode.java +++ b/src/main/java/ast/expression/ExpressionNode.java @@ -1,4 +1,6 @@ package ast.expression; -public class ExpressionNode { +import ast.ASTNode; + +public class ExpressionNode implements ASTNode { } diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java index fdb694a..38c014d 100644 --- a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -7,7 +7,7 @@ import ast.type.ValueNode; import java.util.Objects; -public class UnaryExpressionNode implements ASTNode { +public class UnaryExpressionNode extends ExpressionNode { String thisExp; String identifier; MemberAccessNode memberAccess; diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index 2d79ee5..bedfac2 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -9,14 +9,15 @@ import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; +import java.util.ArrayList; import java.util.List; public class MethodNode implements MemberNode, Visitable { AccessModifierNode accesModifier; - TypeNode type; + public TypeNode type; Boolean voidType; - String identifier; - List parameters; + public String identifier; + private List parameters = new ArrayList<>(); public BlockNode block; public MethodNode() {} @@ -37,24 +38,23 @@ public class MethodNode implements MemberNode, Visitable { this.parameters.add(parameter); } - /* - public boolean isSame(MethodNode methodNode){ - boolean isSame = false; - if(methodNode.identifier.equals(identifier)){ - if(parameters != null && methodNode.parameters != null){ - if(parameters.parameters.size() == methodNode.parameters.parameters.size()){ - for(int i = 0; i < parameters.parameters.size(); i++){ - if(parameters.parameters.get(i).identifier.equals(methodNode.parameters.parameters.get(i).identifier)){ - isSame = true; - } - } - } - } - } - return isSame; + public List getParameters() { + return parameters; } - */ + public boolean isSame(MethodNode methodNode){ + if (!this.identifier.equals(methodNode.identifier) || this.type.equals(methodNode.type) + || this.getParameters().size() != methodNode.getParameters().size()) { + return false; + } + + for (int i = 0; i < this.getParameters().size(); i++) { + if (this.getParameters().get(i).type.equals(methodNode.getParameters().get(i).type)) { + return false; + } + } + return true; + } @Override public TypeCheckResult accept(SemanticVisitor visitor) { diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java index 3a6b5ec..9050f30 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -2,13 +2,22 @@ package ast.parameter; import ast.ASTNode; import ast.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; -public class ParameterNode implements ASTNode { - TypeNode type; - String identifier; +public class ParameterNode implements ASTNode, Visitable { + public TypeNode type; + public String identifier; public ParameterNode(TypeNode type, String identifier) { this.type = type; this.identifier = identifier; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java index 5b3900f..edee12b 100644 --- a/src/main/java/ast/statement/LocalVariableDeclarationNode.java +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -4,7 +4,7 @@ import ast.ASTNode; import ast.expression.ExpressionNode; import ast.type.TypeNode; -public class LocalVariableDeclarationNode implements ASTNode { +public class LocalVariableDeclarationNode extends StatementNode { TypeNode type; String identifier; String assign; diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/ast/statement/StatementNode.java index c47d30c..e4e3862 100644 --- a/src/main/java/ast/statement/StatementNode.java +++ b/src/main/java/ast/statement/StatementNode.java @@ -1,2 +1,6 @@ -package ast.statement;public class StatementNode { +package ast.statement; + +import ast.ASTNode; + +public class StatementNode implements ASTNode { } diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/TypeNode.java index 6336208..adb4892 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/ast/type/TypeNode.java @@ -22,4 +22,10 @@ public class TypeNode { this.type = EnumTypeNode.IDENTIFIER; } } + + + public boolean equals(TypeNode o) { + return !o.type.equals(this.type); + } + } diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 7760b5c..fa59e98 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -74,7 +74,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { } else { MethodNode methodNode = new MethodNode((AccessModifierNode) visit(ctx.AccessModifier()), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { - methodNode.addParameter((ParameterNode) visit(parameter)); +// methodNode.addParameter((ParameterNode) visit(parameter)); } return methodNode; } diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index d3526f4..8c7e833 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -7,13 +7,14 @@ import java.util.List; import java.util.Objects; import ast.*; +import ast.block.BlockNode; import ast.member.*; +import ast.parameter.ParameterNode; import ast.statement.*; import ast.statement.ifstatement.IfStatementNode; import ast.type.*; import semantic.context.Context; import semantic.exeptions.AlreadyDeclearedException; -import semantic.exeptions.NotDeclearedException; import semantic.exeptions.TypeMismatchException; import typechecker.TypeCheckResult; @@ -96,10 +97,47 @@ public class SemanticAnalyzer implements SemanticVisitor { public TypeCheckResult analyze(MethodNode methodNode) { var valid = true; - currentScope.pushScope(); + for (var otherMethod : currentClass.getMethods()) { + if (Objects.equals(otherMethod , methodNode)) + break; + if (otherMethod.isSame(methodNode)) { + errors.add(new AlreadyDeclearedException( + "Method " + methodNode.identifier + " is already defined in class " + + currentClass.identifier)); + valid = false; + } + } + currentScope.pushScope(); + for (var parameter : methodNode.getParameters()) { + var result = parameter.accept(this); + valid = valid && result.isValid(); + currentScope.addLocalVar(parameter.identifier, parameter.type); + } + // Check if this method is already declared + +// currentMethodReturnType = methodDecl.getType(); +// currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ + + // gesetzt ist, ist dieser der Rückgabewert der Methode + var result = methodNode.block.accept(this); + valid = valid && result.isValid(); currentScope.popScope(); - return new TypeCheckResult(valid, null); + var resultType = result.getType(); + + /* + if (resultType == null) { + resultType = new BaseType(Primitives.VOID); + } + if (!resultType.equals(methodDecl.getType())) { + errors.add(new TypeMismatchException("Method-Declaration " + methodDecl.getIdentifier() + " with type " + + methodDecl.getType() + " has at least one Mismatching return Type:" + + TypeHelper.generateLocationString(methodDecl.line, methodDecl.column, fileName))); + valid = false; + } + + */ + return new TypeCheckResult(valid, resultType); } @Override @@ -128,4 +166,14 @@ public class SemanticAnalyzer implements SemanticVisitor { return null; } + @Override + public TypeCheckResult analyze(ParameterNode toCheck) { + return new TypeCheckResult(true, null); + } + + @Override + public TypeCheckResult analyze(BlockNode toCheck) { + return new TypeCheckResult(true, null); + } + } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index 6bdc9a8..aca196b 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -2,7 +2,9 @@ package semantic; import ast.*; +import ast.block.BlockNode; import ast.member.*; +import ast.parameter.ParameterNode; import ast.statement.*; import ast.statement.ifstatement.*; import typechecker.TypeCheckResult; @@ -23,4 +25,9 @@ public interface SemanticVisitor { TypeCheckResult analyze(WhileStatementNode toCheck); + TypeCheckResult analyze(ParameterNode toCheck); + + TypeCheckResult analyze(BlockNode toCheck); + + } \ No newline at end of file diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index a60e83b..5a5e014 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -2,7 +2,13 @@ package semantic; import ast.*; import ast.block.BlockNode; +import ast.member.FieldNode; import ast.member.MethodNode; +import ast.parameter.ParameterNode; +import ast.statement.StatementNode; +import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; +import ast.type.AccessModifierNode; +import ast.type.TypeNode; import java.util.ArrayList; import java.util.List; @@ -11,26 +17,94 @@ import static parser.generated.SimpleJavaParser.Identifier; public class Mocker { - public static ProgramNode mockCorrectClass(){ + public static ASTNode mockTwoSameFields(){ ProgramNode p = new ProgramNode(); ClassNode c = new ClassNode(); c.identifier = "testClass"; - MethodNode m = new MethodNode(); + FieldNode f1 = new FieldNode(new AccessModifierNode("public"), new TypeNode("int"), "a"); - BlockNode b = new BlockNode(); + c.members.add(f1); + FieldNode f2 = new FieldNode(new AccessModifierNode("public"), new TypeNode("int"), "a"); - -// b.statements.add(); - - m.block = b; - - c.members.add(m); + c.members.add(f2); p.classes.add(c); return p; } + public static ASTNode mockSimpleMethod(){ + ProgramNode p = new ProgramNode(); + + ClassNode c = new ClassNode(); + + MethodNode methodNode = new MethodNode(); + + //Parameter + ParameterNode parameterNode = new ParameterNode(new TypeNode("int"), "a"); + + methodNode.addParameter(parameterNode); + + //Statements + + //Block + methodNode.block = new BlockNode(); + + c.members.add(methodNode); + + p.classes.add(c); + + return p; + } + + public static ASTNode mockTwoSameMethods(){ + ProgramNode p = new ProgramNode(); + + ClassNode c = new ClassNode(); + + MethodNode methodNode = new MethodNode(); + methodNode.block = new BlockNode(); + methodNode.type = new TypeNode("int"); + + methodNode.identifier = "testMethod"; + + c.members.add(methodNode); + + MethodNode methodNode1 = new MethodNode(); + methodNode1.block = new BlockNode(); + methodNode1.type = new TypeNode("int"); + + methodNode1.identifier = "testMethod"; + + c.members.add(methodNode1); + + p.classes.add(c); + + return p; + } + + public static ASTNode mockTwoDifferentMethods(){ + ProgramNode p = new ProgramNode(); + + ClassNode c = new ClassNode(); + + MethodNode methodNode = new MethodNode(); + methodNode.block = new BlockNode(); + methodNode.identifier = "testMethod"; + + c.members.add(methodNode); + + MethodNode methodNode1 = new MethodNode(); + methodNode1.block = new BlockNode(); + methodNode1.identifier = "testMethod1"; + + c.members.add(methodNode1); + + p.classes.add(c); + + return p; + } + } diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index 8554022..7ebc7ad 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -1,14 +1,63 @@ package semantic; +import ast.ASTNode; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import semantic.exeptions.AlreadyDeclearedException; + +import static org.junit.jupiter.api.Assertions.*; public class SemanticTest { + @BeforeEach + public void setup(){ + SemanticAnalyzer.clearAnalyzier(); + } + @Test - public void correctClass(){ + public void twoFieldsSameName() { + ASTNode ast = Mocker.mockTwoSameFields(); + ASTNode tast = SemanticAnalyzer.generateTast(ast); + + assertEquals(SemanticAnalyzer.errors.size(), 1); + assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + assertNull(tast); } + @Test + public void simpleMethod(){ + + ASTNode ast = Mocker.mockSimpleMethod(); + + ASTNode tast = SemanticAnalyzer.generateTast(ast); + + assertEquals(SemanticAnalyzer.errors.size(), 0); + assertNotNull(tast); + + } + + @Test + public void twoSameMethods(){ + ASTNode ast = Mocker.mockTwoSameMethods(); + + ASTNode tast = SemanticAnalyzer.generateTast(ast); + + assertEquals(1, SemanticAnalyzer.errors.size()); + assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + assertNull(tast); + } + + @Test + public void twoDifferentMethods(){ + ASTNode ast = Mocker.mockTwoDifferentMethods(); + + ASTNode tast = SemanticAnalyzer.generateTast(ast); + + assertEquals(SemanticAnalyzer.errors.size(), 0); + assertNotNull(tast); + } + } diff --git a/src/test/java/semantic/endToTAST/CorrectTest.java b/src/test/java/semantic/endToTAST/CorrectTest.java index a8280fe..e3a7a08 100644 --- a/src/test/java/semantic/endToTAST/CorrectTest.java +++ b/src/test/java/semantic/endToTAST/CorrectTest.java @@ -1,5 +1,6 @@ package semantic.endToTAST; +import ast.ASTNode; import ast.ProgramNode; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -9,10 +10,13 @@ import org.junit.jupiter.api.Test; import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; +import semantic.SemanticAnalyzer; import java.io.IOException; import java.nio.file.Paths; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class CorrectTest { @Test @@ -36,6 +40,12 @@ public class CorrectTest { System.out.println("Test"); + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + System.out.println("Errors: " + SemanticAnalyzer.errors.size()); + + assertEquals(SemanticAnalyzer.errors.size(), 0); + } } diff --git a/src/test/resources/semantic/endToTAST/Test.java b/src/test/resources/semantic/endToTAST/Test.java index bd4e673..d067998 100644 --- a/src/test/resources/semantic/endToTAST/Test.java +++ b/src/test/resources/semantic/endToTAST/Test.java @@ -1,7 +1,6 @@ public class Test { - public void test(){ - - } + public boolean b; + public boolean b; } \ No newline at end of file -- 2.34.1 From d3e9fa9b43d844b3d0e5090341e22e820a937d12 Mon Sep 17 00:00:00 2001 From: i22035 Date: Thu, 20 Jun 2024 17:52:54 +0200 Subject: [PATCH 11/19] Added Public to Attributes --- src/main/java/ast/IdentifierNode.java | 4 ---- .../CalculationExpressionNode.java | 6 +++--- .../binaryexpression/DotExpressionNode.java | 6 +++--- .../DotSubstractionExpressionNode.java | 10 +++++----- .../NonCalculationExpressionNode.java | 6 +++--- .../unaryexpression/MemberAccessNode.java | 4 ++-- .../unaryexpression/NotExpressionNode.java | 2 +- .../unaryexpression/UnaryExpressionNode.java | 14 +++++++------- src/main/java/ast/member/MethodNode.java | 12 ++++++------ src/main/java/ast/parameter/ParameterNode.java | 4 ++-- src/main/java/ast/statement/ForStatementNode.java | 8 ++++---- .../statement/LocalVariableDeclarationNode.java | 8 ++++---- src/main/java/ast/statement/StatementNode.java | 4 +++- .../java/ast/statement/WhileStatementNode.java | 4 ++-- .../statement/ifstatement/ElseStatementNode.java | 2 +- .../statement/ifstatement/IfElseStatementNode.java | 4 ++-- .../ast/statement/ifstatement/IfStatementNode.java | 4 ++-- .../AssignStatementExpressionNode.java | 4 ++-- .../AssignableExpressionNode.java | 4 ++-- .../statementexpression/IncrementExpression.java | 5 ----- .../NewDeclarationStatementExpressionNode.java | 4 ++-- .../crementExpression/DecrementExpressionNode.java | 4 ++-- .../crementExpression/IncrementExpressionNode.java | 4 ++-- .../ChainedMethodNode.java | 4 ++-- .../MethodCallStatementExpressionNode.java | 8 ++++---- .../methodcallstatementnexpression/TargetNode.java | 8 ++++---- src/main/java/ast/type/AccessModifierNode.java | 2 +- src/main/java/ast/type/TypeNode.java | 2 +- src/main/java/ast/type/ValueNode.java | 4 ++-- 29 files changed, 74 insertions(+), 81 deletions(-) delete mode 100644 src/main/java/ast/IdentifierNode.java delete mode 100644 src/main/java/ast/statement/statementexpression/IncrementExpression.java diff --git a/src/main/java/ast/IdentifierNode.java b/src/main/java/ast/IdentifierNode.java deleted file mode 100644 index cd09699..0000000 --- a/src/main/java/ast/IdentifierNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package ast; - -public class IdentifierNode { -} diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java index ec3ab61..4d29cf5 100644 --- a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -3,9 +3,9 @@ package ast.expression.binaryexpression; import ast.ASTNode; public class CalculationExpressionNode implements ASTNode { - CalculationExpressionNode calculationExpression; - String operator; - DotExpressionNode dotExpression; + public CalculationExpressionNode calculationExpression; + public String operator; + public DotExpressionNode dotExpression; public CalculationExpressionNode(CalculationExpressionNode calculationExpression, String operator, DotExpressionNode dotExpression) { this.calculationExpression = calculationExpression; diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java index 1418fe5..5a0f5bb 100644 --- a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -3,9 +3,9 @@ package ast.expression.binaryexpression; import ast.ASTNode; public class DotExpressionNode implements ASTNode { - DotExpressionNode dotExpression; - String operator; - DotSubstractionExpressionNode dotSubstractionExpression; + public DotExpressionNode dotExpression; + public String operator; + public DotSubstractionExpressionNode dotSubstractionExpression; public DotExpressionNode(DotExpressionNode dotExpression, String operator, DotSubstractionExpressionNode dotSubstractionExpression) { this.dotExpression = dotExpression; diff --git a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java index e32863c..848ea14 100644 --- a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java @@ -6,11 +6,11 @@ import ast.statement.statementexpression.methodcallstatementnexpression.MethodCa import ast.type.ValueNode; public class DotSubstractionExpressionNode implements ASTNode { - ValueNode value; - String identifier; - MemberAccessNode memberAccess; - MethodCallStatementExpressionNode methodCall; - CalculationExpressionNode calculationExpression; + public ValueNode value; + public String identifier; + public MemberAccessNode memberAccess; + public MethodCallStatementExpressionNode methodCall; + public CalculationExpressionNode calculationExpression; public DotSubstractionExpressionNode(ValueNode value) { this.value = value; diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java index 1c1c674..ab3f3bd 100644 --- a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -5,9 +5,9 @@ import ast.expression.ExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; public class NonCalculationExpressionNode implements ASTNode { - UnaryExpressionNode unaryExpression; - String operator; - ExpressionNode expression; + public UnaryExpressionNode unaryExpression; + public String operator; + public ExpressionNode expression; public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, ExpressionNode expression) { this.unaryExpression = unaryExpression; diff --git a/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java index fb33d6e..1a50aa9 100644 --- a/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java +++ b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java @@ -6,8 +6,8 @@ import java.util.ArrayList; import java.util.List; public class MemberAccessNode implements ASTNode { - Boolean thisExpr; - List identifiers = new ArrayList<>(); + public Boolean thisExpr; + public List identifiers = new ArrayList<>(); public MemberAccessNode(Boolean thisExpr) { this.thisExpr = thisExpr; diff --git a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java index e04a2fd..9f3192a 100644 --- a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java @@ -4,7 +4,7 @@ import ast.ASTNode; import ast.expression.ExpressionNode; public class NotExpressionNode implements ASTNode { - ExpressionNode expression; + public ExpressionNode expression; public NotExpressionNode(ExpressionNode expression) { this.expression = expression; diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java index fdb694a..db9ab53 100644 --- a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -8,13 +8,13 @@ import ast.type.ValueNode; import java.util.Objects; public class UnaryExpressionNode implements ASTNode { - String thisExp; - String identifier; - MemberAccessNode memberAccess; - ValueNode value; - NotExpressionNode notExpression; - StatementNode statement; - ExpressionNode expression; + public String thisExp; + public String identifier; + public MemberAccessNode memberAccess; + public ValueNode value; + public NotExpressionNode notExpression; + public StatementNode statement; + public ExpressionNode expression; public UnaryExpressionNode(String value) { if(Objects.equals(value, "this")) { diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index e508629..18932af 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -13,12 +13,12 @@ import java.util.ArrayList; import java.util.List; public class MethodNode implements MemberNode { - AccessModifierNode accesModifier; - TypeNode type; - Boolean voidType; - String identifier; - List parameters; - BlockNode block; + public AccessModifierNode accesModifier; + public TypeNode type; + public Boolean voidType; + public String identifier; + public List parameters; + public BlockNode block; public MethodNode() {} diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java index 3a6b5ec..1969e85 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -4,8 +4,8 @@ import ast.ASTNode; import ast.type.TypeNode; public class ParameterNode implements ASTNode { - TypeNode type; - String identifier; + public TypeNode type; + public String identifier; public ParameterNode(TypeNode type, String identifier) { this.type = type; diff --git a/src/main/java/ast/statement/ForStatementNode.java b/src/main/java/ast/statement/ForStatementNode.java index 5a4b442..7b3219e 100644 --- a/src/main/java/ast/statement/ForStatementNode.java +++ b/src/main/java/ast/statement/ForStatementNode.java @@ -4,10 +4,10 @@ import ast.ASTNode; import ast.expression.ExpressionNode; public class ForStatementNode implements ASTNode { - ExpressionNode statementExpressionInit; - StatementNode localVariableDeclarationInit; - ExpressionNode expression; - ExpressionNode statementExpression; + public ExpressionNode statementExpressionInit; + public StatementNode localVariableDeclarationInit; + public ExpressionNode expression; + public ExpressionNode statementExpression; public ForStatementNode(ExpressionNode statementExpressionInit, ExpressionNode expression, ExpressionNode statementExpression) { this.statementExpressionInit = statementExpressionInit; diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java index 5b3900f..7c0ddaf 100644 --- a/src/main/java/ast/statement/LocalVariableDeclarationNode.java +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -5,10 +5,10 @@ import ast.expression.ExpressionNode; import ast.type.TypeNode; public class LocalVariableDeclarationNode implements ASTNode { - TypeNode type; - String identifier; - String assign; - ExpressionNode expression; + public TypeNode type; + public String identifier; + public String assign; + public ExpressionNode expression; public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, ExpressionNode expression) { this.type = type; diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/ast/statement/StatementNode.java index c47d30c..544b8b8 100644 --- a/src/main/java/ast/statement/StatementNode.java +++ b/src/main/java/ast/statement/StatementNode.java @@ -1,2 +1,4 @@ -package ast.statement;public class StatementNode { +package ast.statement; + +public class StatementNode { } diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/ast/statement/WhileStatementNode.java index 72d017d..8a34d66 100644 --- a/src/main/java/ast/statement/WhileStatementNode.java +++ b/src/main/java/ast/statement/WhileStatementNode.java @@ -5,8 +5,8 @@ import ast.block.BlockNode; import ast.expression.ExpressionNode; public class WhileStatementNode implements ASTNode { - ExpressionNode expression; - BlockNode block; + public ExpressionNode expression; + public BlockNode block; public WhileStatementNode(ExpressionNode expression, BlockNode block) { this.expression = expression; diff --git a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java index cedfefc..18f4e0e 100644 --- a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java @@ -4,7 +4,7 @@ import ast.ASTNode; import ast.block.BlockNode; public class ElseStatementNode implements ASTNode { - BlockNode block; + public BlockNode block; public ElseStatementNode(BlockNode block) { this.block = block; diff --git a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java index dcdc6ca..9b7ac8e 100644 --- a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java @@ -6,8 +6,8 @@ import java.util.ArrayList; import java.util.List; public class IfElseStatementNode implements ASTNode { - IfStatementNode ifStatement; - List elseStatements = new ArrayList<>(); + public IfStatementNode ifStatement; + public List elseStatements = new ArrayList<>(); public IfElseStatementNode(IfStatementNode ifStatement) { this.ifStatement = ifStatement; diff --git a/src/main/java/ast/statement/ifstatement/IfStatementNode.java b/src/main/java/ast/statement/ifstatement/IfStatementNode.java index 4731758..2b383fc 100644 --- a/src/main/java/ast/statement/ifstatement/IfStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfStatementNode.java @@ -5,8 +5,8 @@ import ast.block.BlockNode; import ast.expression.ExpressionNode; public class IfStatementNode implements ASTNode { - ExpressionNode expression; - BlockNode block; + public ExpressionNode expression; + public BlockNode block; public IfStatementNode(ExpressionNode expression, BlockNode block) { this.expression = expression; diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java index d993f48..8dbad08 100644 --- a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -4,8 +4,8 @@ import ast.ASTNode; import ast.expression.ExpressionNode; public class AssignStatementExpressionNode implements ASTNode { - AssignableExpressionNode assignable; - ExpressionNode expression; + public AssignableExpressionNode assignable; + public ExpressionNode expression; public AssignStatementExpressionNode(AssignableExpressionNode assignable, ExpressionNode expression) { this.assignable = assignable; diff --git a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java index cf9b96e..e9d0d30 100644 --- a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java @@ -4,8 +4,8 @@ import ast.ASTNode; import ast.expression.unaryexpression.MemberAccessNode; public class AssignableExpressionNode implements ASTNode { - String identifier; - MemberAccessNode memberAccess; + public String identifier; + public MemberAccessNode memberAccess; public AssignableExpressionNode(String identifier) { this.identifier = identifier; diff --git a/src/main/java/ast/statement/statementexpression/IncrementExpression.java b/src/main/java/ast/statement/statementexpression/IncrementExpression.java deleted file mode 100644 index 2a4d9fa..0000000 --- a/src/main/java/ast/statement/statementexpression/IncrementExpression.java +++ /dev/null @@ -1,5 +0,0 @@ -package ast.statement.statementexpression; - -public class IncrementExpression { - -} diff --git a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java index 6683b46..69a61c2 100644 --- a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java @@ -7,8 +7,8 @@ import java.util.ArrayList; import java.util.List; public class NewDeclarationStatementExpressionNode implements ASTNode { - String identifier; - List expressions = new ArrayList<>(); + public String identifier; + public List expressions = new ArrayList<>(); public NewDeclarationStatementExpressionNode(String identifier) { this.identifier = identifier; diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java index 5b4a9d9..0d09c5d 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java @@ -4,8 +4,8 @@ import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; public class DecrementExpressionNode implements ASTNode { - CrementType crementType; - AssignableExpressionNode assignableExpression; + public CrementType crementType; + public AssignableExpressionNode assignableExpression; public DecrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { this.assignableExpression = assignableExpression; diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java index a16233f..815482d 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java @@ -4,8 +4,8 @@ import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; public class IncrementExpressionNode implements ASTNode { - CrementType crementType; - AssignableExpressionNode assignableExpression; + public CrementType crementType; + public AssignableExpressionNode assignableExpression; public IncrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { this.assignableExpression = assignableExpression; diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java index 759f197..a196f73 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java @@ -7,8 +7,8 @@ import java.util.ArrayList; import java.util.List; public class ChainedMethodNode implements ASTNode { - String identifier; - List expressions = new ArrayList<>(); + public String identifier; + public List expressions = new ArrayList<>(); public ChainedMethodNode(String identifier) { this.identifier = identifier; diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java index 5fcaba1..1dc6a07 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java @@ -7,10 +7,10 @@ import java.util.ArrayList; import java.util.List; public class MethodCallStatementExpressionNode implements ASTNode { - TargetNode target; - List chainedMethods = new ArrayList<>(); - String identifier; - List expressions = new ArrayList<>(); + public TargetNode target; + public List chainedMethods = new ArrayList<>(); + public String identifier; + public List expressions = new ArrayList<>(); public MethodCallStatementExpressionNode(TargetNode target, String identifier) { this.target = target; diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java index d8c0c54..7a18125 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/TargetNode.java @@ -5,10 +5,10 @@ import ast.expression.unaryexpression.MemberAccessNode; import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; public class TargetNode implements ASTNode { - Boolean thisTar; - MemberAccessNode memberAccess; - NewDeclarationStatementExpressionNode newDeclaration; - String identifier; + public Boolean thisTar; + public MemberAccessNode memberAccess; + public NewDeclarationStatementExpressionNode newDeclaration; + public String identifier; public TargetNode(Boolean thisTar) { this.thisTar = thisTar; diff --git a/src/main/java/ast/type/AccessModifierNode.java b/src/main/java/ast/type/AccessModifierNode.java index 14081db..45f9172 100644 --- a/src/main/java/ast/type/AccessModifierNode.java +++ b/src/main/java/ast/type/AccessModifierNode.java @@ -1,7 +1,7 @@ package ast.type; public class AccessModifierNode { - EnumAccessModifierNode accessType; + public EnumAccessModifierNode accessType; public AccessModifierNode(String accessModifier) { setModifier(accessModifier); diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/TypeNode.java index 6336208..8a831cc 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/ast/type/TypeNode.java @@ -1,7 +1,7 @@ package ast.type; public class TypeNode { - EnumTypeNode type; + public EnumTypeNode type; public TypeNode(String type) { setType(type); diff --git a/src/main/java/ast/type/ValueNode.java b/src/main/java/ast/type/ValueNode.java index d188006..b51f799 100644 --- a/src/main/java/ast/type/ValueNode.java +++ b/src/main/java/ast/type/ValueNode.java @@ -3,8 +3,8 @@ package ast.type; import ast.ASTNode; public class ValueNode implements ASTNode { - EnumValueNode valueType; - String value; + public EnumValueNode valueType; + public String value; public ValueNode(EnumValueNode valueType, String value) { this.valueType = valueType; -- 2.34.1 From 50a52a1e87b890b6e75d86f4018ac76e011132d2 Mon Sep 17 00:00:00 2001 From: i22035 Date: Thu, 20 Jun 2024 18:44:42 +0200 Subject: [PATCH 12/19] Added Interface --- src/main/java/Main.java | 18 +++++----- src/main/java/ast/ClassNode.java | 17 +-------- src/main/java/ast/ProgramNode.java | 16 +-------- src/main/java/ast/block/BlockNode.java | 6 ++-- .../java/ast/expression/ExpressionNode.java | 4 --- .../java/ast/expression/IExpressionNode.java | 5 +++ .../binaryexpression/BinaryExpression.java | 4 --- .../BinaryExpressionNode.java | 7 ++++ .../CalculationExpressionNode.java | 2 +- .../binaryexpression/DotExpressionNode.java | 2 +- .../DotSubstractionExpressionNode.java | 2 +- .../NonCalculationExpressionNode.java | 8 ++--- .../unaryexpression/NotExpressionNode.java | 6 ++-- .../unaryexpression/UnaryExpressionNode.java | 15 ++++---- src/main/java/ast/member/ConstructorNode.java | 12 ++----- src/main/java/ast/member/FieldNode.java | 16 +-------- src/main/java/ast/member/MethodNode.java | 12 +++---- .../java/ast/statement/ForStatementNode.java | 16 ++++----- .../java/ast/statement/IStatementNode.java | 6 ++++ .../LocalVariableDeclarationNode.java | 8 ++--- .../ast/statement/ReturnStatementNode.java | 12 +++---- .../java/ast/statement/StatementNode.java | 4 --- .../ast/statement/WhileStatementNode.java | 8 ++--- .../ifstatement/ElseStatementNode.java | 3 +- .../ifstatement/IfElseStatementNode.java | 3 +- .../ifstatement/IfStatementNode.java | 9 ++--- .../AssignStatementExpressionNode.java | 8 ++--- .../AssignableExpressionNode.java | 2 +- .../IStatementExpressionNode.java | 5 +++ ...NewDeclarationStatementExpressionNode.java | 8 ++--- .../DecrementExpressionNode.java | 3 +- .../IncrementExpressionNode.java | 3 +- .../ChainedMethodNode.java | 6 ++-- .../MethodCallStatementExpressionNode.java | 9 ++--- .../java/parser/astBuilder/ASTBuilder.java | 36 +++++++++---------- src/main/resources/CompilerInput.java | 5 ++- 36 files changed, 131 insertions(+), 175 deletions(-) delete mode 100644 src/main/java/ast/expression/ExpressionNode.java create mode 100644 src/main/java/ast/expression/IExpressionNode.java delete mode 100644 src/main/java/ast/expression/binaryexpression/BinaryExpression.java create mode 100644 src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java create mode 100644 src/main/java/ast/statement/IStatementNode.java delete mode 100644 src/main/java/ast/statement/StatementNode.java create mode 100644 src/main/java/ast/statement/statementexpression/IStatementExpressionNode.java diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 779e5d1..0551ed9 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,7 +1,7 @@ -import oldAst.ASTNode; +import ast.ASTNode; import org.antlr.v4.runtime.*; -import oldAst.ProgramNode; -import bytecode.ByteCodeGenerator; +import ast.ProgramNode; +//import bytecode.ByteCodeGenerator; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.tree.ParseTree; @@ -9,7 +9,7 @@ import org.antlr.v4.runtime.CommonTokenStream; import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; -import semantic.SemanticAnalyzer; +//import semantic.SemanticAnalyzer; import java.io.IOException; import java.nio.file.Paths; @@ -60,7 +60,7 @@ public class Main { /* ------------------------- AST builder -> AST ------------------------- */ ASTBuilder astBuilder = new ASTBuilder(); ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); - + System.out.println(abstractSyntaxTree); // Printing the AST // System.out.println("-------------------- AST builder -> AST --------------------"); // // System.out.println("AST: " + ast.toString()); @@ -70,8 +70,8 @@ public class Main { /* * ------------------------- Semantic Analyzer -> Tast ------------------------- */ - SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); - ProgramNode typedAst = (ProgramNode) semanticAnalyzer.generateTast(abstractSyntaxTree); + //SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); + //ProgramNode typedAst = (ProgramNode) semanticAnalyzer.generateTast(abstractSyntaxTree); // Printing the Tast System.out.println("Tast generated"); @@ -80,9 +80,9 @@ public class Main { * ------------------------- Bytecode Generator -> Bytecode * ------------------------- */ - ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(); + //ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(); //byteCodeGenerator.generateByteCode(abstractSyntaxTree); - byteCodeGenerator.visit(typedAst); + //byteCodeGenerator.visit(typedAst); System.out.println("Bytecode generated"); } diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index a21044a..783d4f8 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -1,19 +1,14 @@ package ast; import ast.type.AccessModifierNode; -import ast.type.EnumAccessModifierNode; -import bytecode.visitor.ClassVisitor; import ast.member.ConstructorNode; import ast.member.MemberNode; import ast.member.MethodNode; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class ClassNode implements ASTNode, Visitable { +public class ClassNode implements ASTNode { public AccessModifierNode accessType; public String identifier; public List members = new ArrayList<>(); @@ -50,14 +45,4 @@ public class ClassNode implements ASTNode, Visitable { } return methods; } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - @Override - public void accept(ClassVisitor classVisitor) { - classVisitor.visit(this); - } } diff --git a/src/main/java/ast/ProgramNode.java b/src/main/java/ast/ProgramNode.java index f8ad19a..9174692 100644 --- a/src/main/java/ast/ProgramNode.java +++ b/src/main/java/ast/ProgramNode.java @@ -1,27 +1,13 @@ package ast; -import bytecode.visitor.ProgramVisitor; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; - import java.util.ArrayList; import java.util.List; -public class ProgramNode implements ASTNode, Visitable { +public class ProgramNode implements ASTNode { public List classes = new ArrayList<>(); public void addClass(ClassNode classNode) { classes.add(classNode); } - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - @Override - public void accept(ProgramVisitor programVisitor) { - programVisitor.visit(this); - } } diff --git a/src/main/java/ast/block/BlockNode.java b/src/main/java/ast/block/BlockNode.java index a5ff3f7..9de2e5c 100644 --- a/src/main/java/ast/block/BlockNode.java +++ b/src/main/java/ast/block/BlockNode.java @@ -1,17 +1,17 @@ package ast.block; import ast.ASTNode; -import ast.statement.StatementNode; +import ast.statement.IStatementNode; import java.util.ArrayList; import java.util.List; public class BlockNode implements ASTNode { - public List statements = new ArrayList<>(); + public List statements = new ArrayList<>(); public BlockNode() {} - public void addStatement(StatementNode statement) { + public void addStatement(IStatementNode statement) { statements.add(statement); } } diff --git a/src/main/java/ast/expression/ExpressionNode.java b/src/main/java/ast/expression/ExpressionNode.java deleted file mode 100644 index 1566f3b..0000000 --- a/src/main/java/ast/expression/ExpressionNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package ast.expression; - -public class ExpressionNode { -} diff --git a/src/main/java/ast/expression/IExpressionNode.java b/src/main/java/ast/expression/IExpressionNode.java new file mode 100644 index 0000000..775ac7a --- /dev/null +++ b/src/main/java/ast/expression/IExpressionNode.java @@ -0,0 +1,5 @@ +package ast.expression; + +import ast.ASTNode; + +public interface IExpressionNode extends ASTNode {} diff --git a/src/main/java/ast/expression/binaryexpression/BinaryExpression.java b/src/main/java/ast/expression/binaryexpression/BinaryExpression.java deleted file mode 100644 index fb161f3..0000000 --- a/src/main/java/ast/expression/binaryexpression/BinaryExpression.java +++ /dev/null @@ -1,4 +0,0 @@ -package ast.expression.binaryexpression; - -public class BinaryExpression { -} diff --git a/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java new file mode 100644 index 0000000..4afdff4 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java @@ -0,0 +1,7 @@ +package ast.expression.binaryexpression; + +import ast.expression.IExpressionNode; + +import java.beans.Expression; + +public class BinaryExpressionNode implements IExpressionNode {} diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java index 4d29cf5..442d44e 100644 --- a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -2,7 +2,7 @@ package ast.expression.binaryexpression; import ast.ASTNode; -public class CalculationExpressionNode implements ASTNode { +public class CalculationExpressionNode extends BinaryExpressionNode { public CalculationExpressionNode calculationExpression; public String operator; public DotExpressionNode dotExpression; diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java index 5a0f5bb..c335d52 100644 --- a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -2,7 +2,7 @@ package ast.expression.binaryexpression; import ast.ASTNode; -public class DotExpressionNode implements ASTNode { +public class DotExpressionNode extends BinaryExpressionNode { public DotExpressionNode dotExpression; public String operator; public DotSubstractionExpressionNode dotSubstractionExpression; diff --git a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java index 848ea14..69d467d 100644 --- a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java @@ -5,7 +5,7 @@ import ast.expression.unaryexpression.MemberAccessNode; import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; import ast.type.ValueNode; -public class DotSubstractionExpressionNode implements ASTNode { +public class DotSubstractionExpressionNode extends BinaryExpressionNode { public ValueNode value; public String identifier; public MemberAccessNode memberAccess; diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java index ab3f3bd..84f96c8 100644 --- a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -1,15 +1,15 @@ package ast.expression.binaryexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; -public class NonCalculationExpressionNode implements ASTNode { +public class NonCalculationExpressionNode extends BinaryExpressionNode { public UnaryExpressionNode unaryExpression; public String operator; - public ExpressionNode expression; + public IExpressionNode expression; - public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, ExpressionNode expression) { + public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, IExpressionNode expression) { this.unaryExpression = unaryExpression; this.operator = operator; this.expression = expression; diff --git a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java index 9f3192a..e1e269d 100644 --- a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java @@ -1,12 +1,12 @@ package ast.expression.unaryexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; public class NotExpressionNode implements ASTNode { - public ExpressionNode expression; + public IExpressionNode expression; - public NotExpressionNode(ExpressionNode expression) { + public NotExpressionNode(IExpressionNode expression) { this.expression = expression; } } diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java index db9ab53..6c23545 100644 --- a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -1,20 +1,19 @@ package ast.expression.unaryexpression; -import ast.ASTNode; -import ast.expression.ExpressionNode; -import ast.statement.StatementNode; +import ast.expression.IExpressionNode; +import ast.statement.IStatementNode; import ast.type.ValueNode; import java.util.Objects; -public class UnaryExpressionNode implements ASTNode { +public class UnaryExpressionNode implements IExpressionNode { public String thisExp; public String identifier; public MemberAccessNode memberAccess; public ValueNode value; public NotExpressionNode notExpression; - public StatementNode statement; - public ExpressionNode expression; + public IStatementNode statement; + public IExpressionNode expression; public UnaryExpressionNode(String value) { if(Objects.equals(value, "this")) { @@ -36,11 +35,11 @@ public class UnaryExpressionNode implements ASTNode { this.notExpression = notExpression; } - public UnaryExpressionNode(StatementNode statement) { + public UnaryExpressionNode(IStatementNode statement) { this.statement = statement; } - public UnaryExpressionNode(ExpressionNode expression) { + public UnaryExpressionNode(IExpressionNode expression) { this.expression = expression; } } diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java index c78f8d4..0f7a200 100644 --- a/src/main/java/ast/member/ConstructorNode.java +++ b/src/main/java/ast/member/ConstructorNode.java @@ -3,8 +3,6 @@ package ast.member; import ast.block.BlockNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; -import bytecode.visitor.MethodVisitor; -import visitor.Visitable; import java.util.ArrayList; import java.util.List; @@ -20,8 +18,8 @@ public class ConstructorNode extends MethodNode { this.identifier = identifier; } - public ConstructorNode(AccessModifierNode accessType, String identifier, BlockNode body) { - this.accessType = accessType; + public ConstructorNode(String accessType, String identifier, BlockNode body) { + this.accessType = new AccessModifierNode(accessType); this.identifier = identifier; this.body = body; } @@ -30,10 +28,4 @@ public class ConstructorNode extends MethodNode { parameters.add(parameterNode); } - /* - @Override - public void accept(MethodVisitor methodVisitor) { - methodVisitor.visit(this); - } - */ } diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index 2518d58..aaaa0fe 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -2,12 +2,8 @@ package ast.member; import ast.type.AccessModifierNode; import ast.type.TypeNode; -import bytecode.visitor.ClassVisitor; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; -public class FieldNode implements MemberNode, Visitable { +public class FieldNode implements MemberNode { public AccessModifierNode accessTypeNode; public TypeNode type; public String identifier; @@ -17,14 +13,4 @@ public class FieldNode implements MemberNode, Visitable { this.type = type; this.identifier = name; } - - @Override - public TypeCheckResult accept(SemanticVisitor visitor) { - return visitor.analyze(this); - } - - @Override - public void accept(ClassVisitor classVisitor) { - classVisitor.visit(this); - } } diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index 18932af..b435dca 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -4,10 +4,6 @@ import ast.block.BlockNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; import ast.type.TypeNode; -import bytecode.visitor.MethodVisitor; -import semantic.SemanticVisitor; -import typechecker.TypeCheckResult; -import visitor.Visitable; import java.util.ArrayList; import java.util.List; @@ -17,7 +13,7 @@ public class MethodNode implements MemberNode { public TypeNode type; public Boolean voidType; public String identifier; - public List parameters; + public List parameters = new ArrayList<>(); public BlockNode block; public MethodNode() {} @@ -26,9 +22,9 @@ public class MethodNode implements MemberNode { this.block = block; } - public MethodNode(AccessModifierNode accessModifier, TypeNode type, Boolean voidType, String identifier, BlockNode block){ - this.accesModifier = accessModifier; - this.type = type; + public MethodNode(String accessModifier, String type, Boolean voidType, String identifier, BlockNode block){ + this.accesModifier = new AccessModifierNode(accessModifier); + this.type = new TypeNode(type); this.voidType = voidType; this.identifier = identifier; this.block = block; diff --git a/src/main/java/ast/statement/ForStatementNode.java b/src/main/java/ast/statement/ForStatementNode.java index 7b3219e..e71534d 100644 --- a/src/main/java/ast/statement/ForStatementNode.java +++ b/src/main/java/ast/statement/ForStatementNode.java @@ -1,21 +1,21 @@ package ast.statement; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; -public class ForStatementNode implements ASTNode { - public ExpressionNode statementExpressionInit; - public StatementNode localVariableDeclarationInit; - public ExpressionNode expression; - public ExpressionNode statementExpression; +public class ForStatementNode implements IStatementNode { + public IExpressionNode statementExpressionInit; + public IStatementNode localVariableDeclarationInit; + public IExpressionNode expression; + public IExpressionNode statementExpression; - public ForStatementNode(ExpressionNode statementExpressionInit, ExpressionNode expression, ExpressionNode statementExpression) { + public ForStatementNode(IExpressionNode statementExpressionInit, IExpressionNode expression, IExpressionNode statementExpression) { this.statementExpressionInit = statementExpressionInit; this.expression = expression; this.statementExpression = statementExpression; } - public ForStatementNode(StatementNode localVariableDeclarationInit, ExpressionNode expression, ExpressionNode statementExpression) { + public ForStatementNode(IStatementNode localVariableDeclarationInit, IExpressionNode expression, IExpressionNode statementExpression) { this.localVariableDeclarationInit = localVariableDeclarationInit; this.expression = expression; this.statementExpression = statementExpression; diff --git a/src/main/java/ast/statement/IStatementNode.java b/src/main/java/ast/statement/IStatementNode.java new file mode 100644 index 0000000..d920bb9 --- /dev/null +++ b/src/main/java/ast/statement/IStatementNode.java @@ -0,0 +1,6 @@ +package ast.statement; + +import ast.ASTNode; + +public interface IStatementNode extends ASTNode { +} diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java index 7c0ddaf..21c6cc3 100644 --- a/src/main/java/ast/statement/LocalVariableDeclarationNode.java +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -1,16 +1,16 @@ package ast.statement; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; import ast.type.TypeNode; -public class LocalVariableDeclarationNode implements ASTNode { +public class LocalVariableDeclarationNode implements IStatementNode { public TypeNode type; public String identifier; public String assign; - public ExpressionNode expression; + public IExpressionNode expression; - public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, ExpressionNode expression) { + public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, IExpressionNode expression) { this.type = type; this.identifier = identifier; this.assign = assign; diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java index ab111c5..4da2ecb 100644 --- a/src/main/java/ast/statement/ReturnStatementNode.java +++ b/src/main/java/ast/statement/ReturnStatementNode.java @@ -1,16 +1,12 @@ package ast.statement; import ast.ASTNode; -import ast.expression.ExpressionNode; -import ast.type.TypeNode; +import ast.expression.IExpressionNode; -import java.util.ArrayList; -import java.util.List; +public class ReturnStatementNode implements IStatementNode { + public IExpressionNode expression; -public class ReturnStatementNode implements ASTNode { - public ExpressionNode expression; - - public ReturnStatementNode(ExpressionNode expression) { + public ReturnStatementNode(IExpressionNode expression) { this.expression = expression; } } diff --git a/src/main/java/ast/statement/StatementNode.java b/src/main/java/ast/statement/StatementNode.java deleted file mode 100644 index 544b8b8..0000000 --- a/src/main/java/ast/statement/StatementNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package ast.statement; - -public class StatementNode { -} diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/ast/statement/WhileStatementNode.java index 8a34d66..b1c1c13 100644 --- a/src/main/java/ast/statement/WhileStatementNode.java +++ b/src/main/java/ast/statement/WhileStatementNode.java @@ -2,13 +2,13 @@ package ast.statement; import ast.ASTNode; import ast.block.BlockNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; -public class WhileStatementNode implements ASTNode { - public ExpressionNode expression; +public class WhileStatementNode implements IStatementNode { + public IExpressionNode expression; public BlockNode block; - public WhileStatementNode(ExpressionNode expression, BlockNode block) { + public WhileStatementNode(IExpressionNode expression, BlockNode block) { this.expression = expression; this.block = block; } diff --git a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java index 18f4e0e..74bc6c2 100644 --- a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java @@ -2,8 +2,9 @@ package ast.statement.ifstatement; import ast.ASTNode; import ast.block.BlockNode; +import ast.statement.IStatementNode; -public class ElseStatementNode implements ASTNode { +public class ElseStatementNode implements IStatementNode { public BlockNode block; public ElseStatementNode(BlockNode block) { diff --git a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java index 9b7ac8e..75827fd 100644 --- a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java @@ -1,11 +1,12 @@ package ast.statement.ifstatement; import ast.ASTNode; +import ast.statement.IStatementNode; import java.util.ArrayList; import java.util.List; -public class IfElseStatementNode implements ASTNode { +public class IfElseStatementNode implements IStatementNode { public IfStatementNode ifStatement; public List elseStatements = new ArrayList<>(); diff --git a/src/main/java/ast/statement/ifstatement/IfStatementNode.java b/src/main/java/ast/statement/ifstatement/IfStatementNode.java index 2b383fc..d0815e3 100644 --- a/src/main/java/ast/statement/ifstatement/IfStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfStatementNode.java @@ -2,13 +2,14 @@ package ast.statement.ifstatement; import ast.ASTNode; import ast.block.BlockNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; +import ast.statement.IStatementNode; -public class IfStatementNode implements ASTNode { - public ExpressionNode expression; +public class IfStatementNode implements IStatementNode { + public IExpressionNode expression; public BlockNode block; - public IfStatementNode(ExpressionNode expression, BlockNode block) { + public IfStatementNode(IExpressionNode expression, BlockNode block) { this.expression = expression; this.block = block; } diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java index 8dbad08..286d180 100644 --- a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -1,13 +1,13 @@ package ast.statement.statementexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; -public class AssignStatementExpressionNode implements ASTNode { +public class AssignStatementExpressionNode implements IStatementExpressionNode { public AssignableExpressionNode assignable; - public ExpressionNode expression; + public IExpressionNode expression; - public AssignStatementExpressionNode(AssignableExpressionNode assignable, ExpressionNode expression) { + public AssignStatementExpressionNode(AssignableExpressionNode assignable, IExpressionNode expression) { this.assignable = assignable; this.expression = expression; } diff --git a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java index e9d0d30..d669fb4 100644 --- a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java @@ -3,7 +3,7 @@ package ast.statement.statementexpression; import ast.ASTNode; import ast.expression.unaryexpression.MemberAccessNode; -public class AssignableExpressionNode implements ASTNode { +public class AssignableExpressionNode implements IStatementExpressionNode { public String identifier; public MemberAccessNode memberAccess; diff --git a/src/main/java/ast/statement/statementexpression/IStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/IStatementExpressionNode.java new file mode 100644 index 0000000..30998f6 --- /dev/null +++ b/src/main/java/ast/statement/statementexpression/IStatementExpressionNode.java @@ -0,0 +1,5 @@ +package ast.statement.statementexpression; + +import ast.statement.IStatementNode; + +public interface IStatementExpressionNode extends IStatementNode {} diff --git a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java index 69a61c2..fa3f86d 100644 --- a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java @@ -1,20 +1,20 @@ package ast.statement.statementexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; import java.util.ArrayList; import java.util.List; -public class NewDeclarationStatementExpressionNode implements ASTNode { +public class NewDeclarationStatementExpressionNode implements IStatementExpressionNode { public String identifier; - public List expressions = new ArrayList<>(); + public List expressions = new ArrayList<>(); public NewDeclarationStatementExpressionNode(String identifier) { this.identifier = identifier; } - public void addExpression(ExpressionNode expression) { + public void addExpression(IExpressionNode expression) { expressions.add(expression); } } diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java index 0d09c5d..d14107d 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java @@ -2,8 +2,9 @@ package ast.statement.statementexpression.crementExpression; import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; +import ast.statement.statementexpression.IStatementExpressionNode; -public class DecrementExpressionNode implements ASTNode { +public class DecrementExpressionNode implements IStatementExpressionNode { public CrementType crementType; public AssignableExpressionNode assignableExpression; diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java index 815482d..8bf8c16 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java @@ -2,8 +2,9 @@ package ast.statement.statementexpression.crementExpression; import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; +import ast.statement.statementexpression.IStatementExpressionNode; -public class IncrementExpressionNode implements ASTNode { +public class IncrementExpressionNode implements IStatementExpressionNode { public CrementType crementType; public AssignableExpressionNode assignableExpression; diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java index a196f73..c20e9bc 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/ChainedMethodNode.java @@ -1,20 +1,20 @@ package ast.statement.statementexpression.methodcallstatementnexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; import java.util.ArrayList; import java.util.List; public class ChainedMethodNode implements ASTNode { public String identifier; - public List expressions = new ArrayList<>(); + public List expressions = new ArrayList<>(); public ChainedMethodNode(String identifier) { this.identifier = identifier; } - public void addExpression(ExpressionNode expression) { + public void addExpression(IExpressionNode expression) { expressions.add(expression); } } diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java index 1dc6a07..5646f07 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java @@ -1,16 +1,17 @@ package ast.statement.statementexpression.methodcallstatementnexpression; import ast.ASTNode; -import ast.expression.ExpressionNode; +import ast.expression.IExpressionNode; +import ast.statement.statementexpression.IStatementExpressionNode; import java.util.ArrayList; import java.util.List; -public class MethodCallStatementExpressionNode implements ASTNode { +public class MethodCallStatementExpressionNode implements IStatementExpressionNode { public TargetNode target; public List chainedMethods = new ArrayList<>(); public String identifier; - public List expressions = new ArrayList<>(); + public List expressions = new ArrayList<>(); public MethodCallStatementExpressionNode(TargetNode target, String identifier) { this.target = target; @@ -21,7 +22,7 @@ public class MethodCallStatementExpressionNode implements ASTNode { chainedMethods.add(chainedMethode); } - public void addExpression(ExpressionNode expression) { + public void addExpression(IExpressionNode expression) { expressions.add(expression); } diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 7760b5c..eae8647 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -53,7 +53,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { - ConstructorNode constructorNode = new ConstructorNode((AccessModifierNode) visit(ctx.AccessModifier()), ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { constructorNode.addParameter((ParameterNode) visit(parameter)); } @@ -66,13 +66,13 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { return new MethodNode((BlockNode) visit(ctx.block())); } else { if(ctx.type() != null) { - MethodNode methodNode = new MethodNode((AccessModifierNode) visit(ctx.AccessModifier()), (TypeNode) visit(ctx.type()), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), ctx.type().getText(), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { methodNode.addParameter((ParameterNode) visit(parameter)); } return methodNode; } else { - MethodNode methodNode = new MethodNode((AccessModifierNode) visit(ctx.AccessModifier()), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { methodNode.addParameter((ParameterNode) visit(parameter)); } @@ -108,34 +108,34 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { - return new ReturnStatementNode((ExpressionNode) visit(ctx.expression())); + return new ReturnStatementNode((IExpressionNode) visit(ctx.expression())); } @Override public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { - return new LocalVariableDeclarationNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (ExpressionNode) visit(ctx.expression())); + return new LocalVariableDeclarationNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression())); } @Override public ASTNode visitBlock(SimpleJavaParser.BlockContext ctx) { BlockNode blockNode = new BlockNode(); for(SimpleJavaParser.StatementContext statement : ctx.statement()) { - blockNode.addStatement((StatementNode) visit(statement)); + blockNode.addStatement((IStatementNode) visit(statement)); } return blockNode; } @Override public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { - return new WhileStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); + return new WhileStatementNode((IExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); } @Override public ASTNode visitForStatement(SimpleJavaParser.ForStatementContext ctx) { if(ctx.statementExpression(0) != null) { - return new ForStatementNode((ExpressionNode) visit(ctx.statementExpression(0)), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1))); + return new ForStatementNode((IExpressionNode) visit(ctx.statementExpression(0)), (IExpressionNode) visit(ctx.expression()), (IExpressionNode) visit(ctx.statementExpression(1))); } else if(ctx.localVariableDeclaration() != null) { - return new ForStatementNode((StatementNode) visit(ctx.localVariableDeclaration()), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1))); + return new ForStatementNode((IStatementNode) visit(ctx.localVariableDeclaration()), (IExpressionNode) visit(ctx.expression()), (IExpressionNode) visit(ctx.statementExpression(1))); } return null; } @@ -151,7 +151,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { - return new IfStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); + return new IfStatementNode((IExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block())); } @Override @@ -175,14 +175,14 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitAssign(SimpleJavaParser.AssignContext ctx) { - return new AssignStatementExpressionNode((AssignableExpressionNode) visit(ctx.assignableExpression()), (ExpressionNode) visit(ctx.expression())); + return new AssignStatementExpressionNode((AssignableExpressionNode) visit(ctx.assignableExpression()), (IExpressionNode) visit(ctx.expression())); } @Override public ASTNode visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { NewDeclarationStatementExpressionNode newDeclarationStatementExpressionNode = new NewDeclarationStatementExpressionNode(ctx.Identifier().getText()); for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { - newDeclarationStatementExpressionNode.addExpression((ExpressionNode) visit(expression)); + newDeclarationStatementExpressionNode.addExpression((IExpressionNode) visit(expression)); } return newDeclarationStatementExpressionNode; } @@ -194,7 +194,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { methodCallStatementExpressionNode.addChainedMethod((ChainedMethodNode) visit(chainedMethod)); } for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { - methodCallStatementExpressionNode.addExpression((ExpressionNode) visit(expression)); + methodCallStatementExpressionNode.addExpression((IExpressionNode) visit(expression)); } return methodCallStatementExpressionNode; } @@ -217,7 +217,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { public ASTNode visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { ChainedMethodNode chainedMethodNode = new ChainedMethodNode(ctx.Identifier().getText()); for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) { - chainedMethodNode.addExpression((ExpressionNode) visit(expression)); + chainedMethodNode.addExpression((IExpressionNode) visit(expression)); } return chainedMethodNode; } @@ -295,9 +295,9 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { } else if(ctx.notExpression() != null) { return new UnaryExpressionNode((NotExpressionNode) visitNotExpression(ctx.notExpression())); } else if(ctx.statementExpression() != null) { - return new UnaryExpressionNode((StatementNode) visitStatementExpression(ctx.statementExpression())); + return new UnaryExpressionNode((IStatementNode) visitStatementExpression(ctx.statementExpression())); } else if(ctx.expression() != null) { - return new UnaryExpressionNode((ExpressionNode) visitExpression(ctx.expression())); + return new UnaryExpressionNode((IExpressionNode) visitExpression(ctx.expression())); } return null; } @@ -332,7 +332,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { - return new NotExpressionNode((ExpressionNode) visitExpression(ctx.expression())); + return new NotExpressionNode((IExpressionNode) visitExpression(ctx.expression())); } @@ -382,7 +382,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { - return new NonCalculationExpressionNode((UnaryExpressionNode) visit(ctx.unaryExpression()), ctx.nonCalculationOperator().getText(), (ExpressionNode) visit(ctx.expression())); + return new NonCalculationExpressionNode((UnaryExpressionNode) visit(ctx.unaryExpression()), ctx.nonCalculationOperator().getText(), (IExpressionNode) visit(ctx.expression())); } @Override diff --git a/src/main/resources/CompilerInput.java b/src/main/resources/CompilerInput.java index 1cbe5ca..ba8a8e5 100644 --- a/src/main/resources/CompilerInput.java +++ b/src/main/resources/CompilerInput.java @@ -11,8 +11,7 @@ public class Example { public class Test { public static int testMethod(char x, int a){ - - - + x = x + a; + return x; } } \ No newline at end of file -- 2.34.1 From b9ada16dd1bd9c9dc17f736aea6625cf6e839c32 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 15:23:48 +0200 Subject: [PATCH 13/19] Fixed SemanticCheck for new AST and added Some Test --- src/main/java/ast/ClassNode.java | 11 +- src/main/java/ast/ProgramNode.java | 10 +- src/main/java/ast/block/BlockNode.java | 6 +- .../java/ast/expression/IExpressionNode.java | 8 +- .../BinaryExpressionNode.java | 16 +- .../CalculationExpressionNode.java | 15 +- .../binaryexpression/DotExpressionNode.java | 15 +- .../DotSubstractionExpressionNode.java | 15 +- .../NonCalculationExpressionNode.java | 15 +- .../unaryexpression/MemberAccessNode.java | 1 + .../unaryexpression/NotExpressionNode.java | 1 + .../unaryexpression/UnaryExpressionNode.java | 19 ++ src/main/java/ast/member/FieldNode.java | 13 +- src/main/java/ast/member/MethodNode.java | 22 +- .../java/ast/parameter/ParameterNode.java | 2 +- .../java/ast/statement/ForStatementNode.java | 8 + .../java/ast/statement/IStatementNode.java | 3 +- .../LocalVariableDeclarationNode.java | 11 +- .../ast/statement/ReturnStatementNode.java | 8 + .../ast/statement/WhileStatementNode.java | 8 + .../ifstatement/ElseStatementNode.java | 8 + .../ifstatement/IfElseStatementNode.java | 7 + .../ifstatement/IfStatementNode.java | 8 + .../AssignStatementExpressionNode.java | 9 + .../AssignableExpressionNode.java | 10 + ...NewDeclarationStatementExpressionNode.java | 8 + .../DecrementExpressionNode.java | 8 + .../IncrementExpressionNode.java | 8 + .../MethodCallStatementExpressionNode.java | 6 + src/main/java/ast/type/type/BaseType.java | 4 + .../java/ast/type/type/ReferenceType.java | 4 + .../java/ast/type/{ => type}/TypeNode.java | 4 +- src/main/java/bytecode/ByteCodeGenerator.java | 2 +- src/main/java/bytecode/ClassCodeGen.java | 2 +- .../java/parser/astBuilder/ASTBuilder.java | 9 +- src/main/java/semantic/Scope.java | 5 +- src/main/java/semantic/SemanticAnalyzer.java | 227 +++++++++++++++-- src/main/java/semantic/SemanticVisitor.java | 39 +++ .../java/semantic/context/FieldContext.java | 1 + .../exeptions/AlreadyDefinedException.java | 9 + .../java/typechecker/TypeCheckResult.java | 2 +- src/test/java/semantic/EndToTAST.java | 231 ++++++++++++++++++ src/test/java/semantic/Mocker.java | 17 +- src/test/java/semantic/SemanticTest.java | 28 +-- .../java/semantic/endToTAST/CorrectTest.java | 51 ---- .../semantic/endToTAST/CorrectInstVar.java | 18 ++ .../semantic/endToTAST/CorrectTest.java | 16 ++ .../endToTAST/FieldAlreadyDecleared.java | 10 + .../semantic/endToTAST/NotDecleared.java | 6 + .../endToTAST/ParameterAlreadyDecleared.java | 7 + .../resources/semantic/endToTAST/Test.java | 6 - .../endToTAST/TypeMismatchIntBool.java | 10 + .../endToTAST/TypeMismatchRefType.java | 16 ++ 53 files changed, 868 insertions(+), 135 deletions(-) create mode 100644 src/main/java/ast/type/type/BaseType.java create mode 100644 src/main/java/ast/type/type/ReferenceType.java rename src/main/java/ast/type/{ => type}/TypeNode.java (92%) create mode 100644 src/main/java/semantic/exeptions/AlreadyDefinedException.java create mode 100644 src/test/java/semantic/EndToTAST.java delete mode 100644 src/test/java/semantic/endToTAST/CorrectTest.java create mode 100644 src/test/resources/semantic/endToTAST/CorrectInstVar.java create mode 100644 src/test/resources/semantic/endToTAST/CorrectTest.java create mode 100644 src/test/resources/semantic/endToTAST/FieldAlreadyDecleared.java create mode 100644 src/test/resources/semantic/endToTAST/NotDecleared.java create mode 100644 src/test/resources/semantic/endToTAST/ParameterAlreadyDecleared.java delete mode 100644 src/test/resources/semantic/endToTAST/Test.java create mode 100644 src/test/resources/semantic/endToTAST/TypeMismatchIntBool.java create mode 100644 src/test/resources/semantic/endToTAST/TypeMismatchRefType.java diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index 783d4f8..75f92b1 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -4,11 +4,14 @@ import ast.type.AccessModifierNode; import ast.member.ConstructorNode; import ast.member.MemberNode; import ast.member.MethodNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class ClassNode implements ASTNode { +public class ClassNode implements ASTNode, Visitable { public AccessModifierNode accessType; public String identifier; public List members = new ArrayList<>(); @@ -45,4 +48,10 @@ public class ClassNode implements ASTNode { } return methods; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/ProgramNode.java b/src/main/java/ast/ProgramNode.java index 9174692..7fbe3e0 100644 --- a/src/main/java/ast/ProgramNode.java +++ b/src/main/java/ast/ProgramNode.java @@ -1,13 +1,21 @@ package ast; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; + import java.util.ArrayList; import java.util.List; -public class ProgramNode implements ASTNode { +public class ProgramNode implements ASTNode, Visitable { public List classes = new ArrayList<>(); public void addClass(ClassNode classNode) { classes.add(classNode); } + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } } diff --git a/src/main/java/ast/block/BlockNode.java b/src/main/java/ast/block/BlockNode.java index 73d99de..9987cf9 100644 --- a/src/main/java/ast/block/BlockNode.java +++ b/src/main/java/ast/block/BlockNode.java @@ -2,11 +2,15 @@ package ast.block; import ast.ASTNode; import ast.statement.IStatementNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; +import java.beans.Visibility; import java.util.ArrayList; import java.util.List; -public class BlockNode implements ASTNode { +public class BlockNode implements ASTNode, Visitable { public List statements = new ArrayList<>(); public BlockNode() {} diff --git a/src/main/java/ast/expression/IExpressionNode.java b/src/main/java/ast/expression/IExpressionNode.java index 775ac7a..c4c72f5 100644 --- a/src/main/java/ast/expression/IExpressionNode.java +++ b/src/main/java/ast/expression/IExpressionNode.java @@ -1,5 +1,11 @@ package ast.expression; import ast.ASTNode; +import ast.type.type.TypeNode; +import visitor.Visitable; -public interface IExpressionNode extends ASTNode {} +public interface IExpressionNode extends ASTNode, Visitable { + + TypeNode getType(); + +} diff --git a/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java index 4afdff4..d4db5ab 100644 --- a/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java @@ -1,7 +1,19 @@ package ast.expression.binaryexpression; import ast.expression.IExpressionNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; -import java.beans.Expression; +public class BinaryExpressionNode implements IExpressionNode { -public class BinaryExpressionNode implements IExpressionNode {} + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return null; + } +} diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java index 442d44e..53adaa2 100644 --- a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -1,6 +1,8 @@ package ast.expression.binaryexpression; -import ast.ASTNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class CalculationExpressionNode extends BinaryExpressionNode { public CalculationExpressionNode calculationExpression; @@ -16,4 +18,15 @@ public class CalculationExpressionNode extends BinaryExpressionNode { public CalculationExpressionNode(DotExpressionNode dotExpression) { this.dotExpression = dotExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return null; + } + } diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java index c335d52..9ea8170 100644 --- a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -1,6 +1,8 @@ package ast.expression.binaryexpression; -import ast.ASTNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class DotExpressionNode extends BinaryExpressionNode { public DotExpressionNode dotExpression; @@ -16,4 +18,15 @@ public class DotExpressionNode extends BinaryExpressionNode { public DotExpressionNode(DotSubstractionExpressionNode dotSubstractionExpression) { this.dotSubstractionExpression = dotSubstractionExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return null; + } + } diff --git a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java index 69d467d..17c9604 100644 --- a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java @@ -1,9 +1,11 @@ package ast.expression.binaryexpression; -import ast.ASTNode; import ast.expression.unaryexpression.MemberAccessNode; import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; +import ast.type.type.TypeNode; import ast.type.ValueNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class DotSubstractionExpressionNode extends BinaryExpressionNode { public ValueNode value; @@ -28,4 +30,15 @@ public class DotSubstractionExpressionNode extends BinaryExpressionNode { this.methodCall = methodCall; this.calculationExpression = calculationExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return null; + } + } diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java index 84f96c8..8051bd2 100644 --- a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -1,8 +1,10 @@ package ast.expression.binaryexpression; -import ast.ASTNode; import ast.expression.IExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class NonCalculationExpressionNode extends BinaryExpressionNode { public UnaryExpressionNode unaryExpression; @@ -14,4 +16,15 @@ public class NonCalculationExpressionNode extends BinaryExpressionNode { this.operator = operator; this.expression = expression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return null; + } + } diff --git a/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java index 1a50aa9..f5f7090 100644 --- a/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java +++ b/src/main/java/ast/expression/unaryexpression/MemberAccessNode.java @@ -16,4 +16,5 @@ public class MemberAccessNode implements ASTNode { public void addIdentifier(String identifier) { identifiers.add(identifier); } + } diff --git a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java index e1e269d..f225f39 100644 --- a/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/NotExpressionNode.java @@ -9,4 +9,5 @@ public class NotExpressionNode implements ASTNode { public NotExpressionNode(IExpressionNode expression) { this.expression = expression; } + } diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java index 6c23545..74be5ff 100644 --- a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -2,7 +2,10 @@ package ast.expression.unaryexpression; import ast.expression.IExpressionNode; import ast.statement.IStatementNode; +import ast.type.type.TypeNode; import ast.type.ValueNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; import java.util.Objects; @@ -14,6 +17,7 @@ public class UnaryExpressionNode implements IExpressionNode { public NotExpressionNode notExpression; public IStatementNode statement; public IExpressionNode expression; + private TypeNode type; public UnaryExpressionNode(String value) { if(Objects.equals(value, "this")) { @@ -42,4 +46,19 @@ public class UnaryExpressionNode implements IExpressionNode { public UnaryExpressionNode(IExpressionNode expression) { this.expression = expression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + + @Override + public TypeNode getType() { + return type; + } + + public void setType(TypeNode type) { + this.type = type; + } + } diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index aaaa0fe..4377f09 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -1,9 +1,12 @@ package ast.member; import ast.type.AccessModifierNode; -import ast.type.TypeNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; -public class FieldNode implements MemberNode { +public class FieldNode implements MemberNode, Visitable { public AccessModifierNode accessTypeNode; public TypeNode type; public String identifier; @@ -13,4 +16,10 @@ public class FieldNode implements MemberNode { this.type = type; this.identifier = name; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index c6b4337..e318068 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -3,16 +3,21 @@ package ast.member; import ast.block.BlockNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; -import ast.type.TypeNode; +import ast.type.type.TypeNode; +import bytecode.visitor.MethodVisitor; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; import java.util.ArrayList; import java.util.List; +import java.util.Objects; -public class MethodNode implements MemberNode { +public class MethodNode implements MemberNode, Visitable { public AccessModifierNode accesModifier; public TypeNode type; public Boolean voidType; - public String identifier; + private String identifier; public List parameters = new ArrayList<>(); public BlockNode block; @@ -39,8 +44,8 @@ public class MethodNode implements MemberNode { } public boolean isSame(MethodNode methodNode){ - if (!this.identifier.equals(methodNode.identifier) || this.type.equals(methodNode.type) - || this.getParameters().size() != methodNode.getParameters().size()) { + if (!(Objects.equals(this.identifier, methodNode.getIdentifier())) || type.equals(methodNode.type) + || getParameters().size() != methodNode.getParameters().size()) { return false; } @@ -62,5 +67,12 @@ public class MethodNode implements MemberNode { methodVisitor.visit(this); } + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } } diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java index 9050f30..4c81620 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -1,7 +1,7 @@ package ast.parameter; import ast.ASTNode; -import ast.type.TypeNode; +import ast.type.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; diff --git a/src/main/java/ast/statement/ForStatementNode.java b/src/main/java/ast/statement/ForStatementNode.java index e71534d..3d4ad16 100644 --- a/src/main/java/ast/statement/ForStatementNode.java +++ b/src/main/java/ast/statement/ForStatementNode.java @@ -2,6 +2,8 @@ package ast.statement; import ast.ASTNode; import ast.expression.IExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class ForStatementNode implements IStatementNode { public IExpressionNode statementExpressionInit; @@ -20,4 +22,10 @@ public class ForStatementNode implements IStatementNode { this.expression = expression; this.statementExpression = statementExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/IStatementNode.java b/src/main/java/ast/statement/IStatementNode.java index d920bb9..c726bb3 100644 --- a/src/main/java/ast/statement/IStatementNode.java +++ b/src/main/java/ast/statement/IStatementNode.java @@ -1,6 +1,7 @@ package ast.statement; import ast.ASTNode; +import visitor.Visitable; -public interface IStatementNode extends ASTNode { +public interface IStatementNode extends ASTNode, Visitable { } diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java index 21c6cc3..3493c3b 100644 --- a/src/main/java/ast/statement/LocalVariableDeclarationNode.java +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -1,8 +1,9 @@ package ast.statement; -import ast.ASTNode; import ast.expression.IExpressionNode; -import ast.type.TypeNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class LocalVariableDeclarationNode implements IStatementNode { public TypeNode type; @@ -16,4 +17,10 @@ public class LocalVariableDeclarationNode implements IStatementNode { this.assign = assign; this.expression = expression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java index 4da2ecb..66d3846 100644 --- a/src/main/java/ast/statement/ReturnStatementNode.java +++ b/src/main/java/ast/statement/ReturnStatementNode.java @@ -2,6 +2,8 @@ package ast.statement; import ast.ASTNode; import ast.expression.IExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class ReturnStatementNode implements IStatementNode { public IExpressionNode expression; @@ -9,4 +11,10 @@ public class ReturnStatementNode implements IStatementNode { public ReturnStatementNode(IExpressionNode expression) { this.expression = expression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/WhileStatementNode.java b/src/main/java/ast/statement/WhileStatementNode.java index b1c1c13..3aabb73 100644 --- a/src/main/java/ast/statement/WhileStatementNode.java +++ b/src/main/java/ast/statement/WhileStatementNode.java @@ -3,6 +3,8 @@ package ast.statement; import ast.ASTNode; import ast.block.BlockNode; import ast.expression.IExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class WhileStatementNode implements IStatementNode { public IExpressionNode expression; @@ -12,4 +14,10 @@ public class WhileStatementNode implements IStatementNode { this.expression = expression; this.block = block; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java index 74bc6c2..709fe2f 100644 --- a/src/main/java/ast/statement/ifstatement/ElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/ElseStatementNode.java @@ -3,6 +3,8 @@ package ast.statement.ifstatement; import ast.ASTNode; import ast.block.BlockNode; import ast.statement.IStatementNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class ElseStatementNode implements IStatementNode { public BlockNode block; @@ -10,4 +12,10 @@ public class ElseStatementNode implements IStatementNode { public ElseStatementNode(BlockNode block) { this.block = block; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java index 75827fd..6967f75 100644 --- a/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfElseStatementNode.java @@ -2,6 +2,8 @@ package ast.statement.ifstatement; import ast.ASTNode; import ast.statement.IStatementNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; import java.util.ArrayList; import java.util.List; @@ -18,4 +20,9 @@ public class IfElseStatementNode implements IStatementNode { elseStatements.add(elseStatement); } + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/ifstatement/IfStatementNode.java b/src/main/java/ast/statement/ifstatement/IfStatementNode.java index d0815e3..7bcbabf 100644 --- a/src/main/java/ast/statement/ifstatement/IfStatementNode.java +++ b/src/main/java/ast/statement/ifstatement/IfStatementNode.java @@ -4,6 +4,8 @@ import ast.ASTNode; import ast.block.BlockNode; import ast.expression.IExpressionNode; import ast.statement.IStatementNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class IfStatementNode implements IStatementNode { public IExpressionNode expression; @@ -13,4 +15,10 @@ public class IfStatementNode implements IStatementNode { this.expression = expression; this.block = block; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java index 286d180..19b34e5 100644 --- a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -2,6 +2,9 @@ package ast.statement.statementexpression; import ast.ASTNode; import ast.expression.IExpressionNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class AssignStatementExpressionNode implements IStatementExpressionNode { public AssignableExpressionNode assignable; @@ -11,4 +14,10 @@ public class AssignStatementExpressionNode implements IStatementExpressionNode { this.assignable = assignable; this.expression = expression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java index d669fb4..9ccdfec 100644 --- a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java @@ -2,9 +2,13 @@ package ast.statement.statementexpression; import ast.ASTNode; import ast.expression.unaryexpression.MemberAccessNode; +import ast.type.type.TypeNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class AssignableExpressionNode implements IStatementExpressionNode { public String identifier; + public MemberAccessNode memberAccess; public AssignableExpressionNode(String identifier) { @@ -14,4 +18,10 @@ public class AssignableExpressionNode implements IStatementExpressionNode { public AssignableExpressionNode(MemberAccessNode memberAccess) { this.memberAccess = memberAccess; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java index fa3f86d..20541bb 100644 --- a/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/NewDeclarationStatementExpressionNode.java @@ -2,6 +2,8 @@ package ast.statement.statementexpression; import ast.ASTNode; import ast.expression.IExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; import java.util.ArrayList; import java.util.List; @@ -17,4 +19,10 @@ public class NewDeclarationStatementExpressionNode implements IStatementExpressi public void addExpression(IExpressionNode expression) { expressions.add(expression); } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java index d14107d..372b4ea 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/DecrementExpressionNode.java @@ -3,6 +3,8 @@ package ast.statement.statementexpression.crementExpression; import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; import ast.statement.statementexpression.IStatementExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class DecrementExpressionNode implements IStatementExpressionNode { public CrementType crementType; @@ -11,4 +13,10 @@ public class DecrementExpressionNode implements IStatementExpressionNode { public DecrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { this.assignableExpression = assignableExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java index 8bf8c16..a87934d 100644 --- a/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/crementExpression/IncrementExpressionNode.java @@ -3,6 +3,8 @@ package ast.statement.statementexpression.crementExpression; import ast.ASTNode; import ast.statement.statementexpression.AssignableExpressionNode; import ast.statement.statementexpression.IStatementExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; public class IncrementExpressionNode implements IStatementExpressionNode { public CrementType crementType; @@ -11,4 +13,10 @@ public class IncrementExpressionNode implements IStatementExpressionNode { public IncrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) { this.assignableExpression = assignableExpression; } + + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } + } diff --git a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java index 5646f07..6a2f69b 100644 --- a/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/methodcallstatementnexpression/MethodCallStatementExpressionNode.java @@ -3,6 +3,8 @@ package ast.statement.statementexpression.methodcallstatementnexpression; import ast.ASTNode; import ast.expression.IExpressionNode; import ast.statement.statementexpression.IStatementExpressionNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; import java.util.ArrayList; import java.util.List; @@ -26,5 +28,9 @@ public class MethodCallStatementExpressionNode implements IStatementExpressionNo expressions.add(expression); } + @Override + public TypeCheckResult accept(SemanticVisitor visitor) { + return visitor.analyze(this); + } } diff --git a/src/main/java/ast/type/type/BaseType.java b/src/main/java/ast/type/type/BaseType.java new file mode 100644 index 0000000..d88fd99 --- /dev/null +++ b/src/main/java/ast/type/type/BaseType.java @@ -0,0 +1,4 @@ +package ast.type.type; + +public class BaseType { +} diff --git a/src/main/java/ast/type/type/ReferenceType.java b/src/main/java/ast/type/type/ReferenceType.java new file mode 100644 index 0000000..4078c3f --- /dev/null +++ b/src/main/java/ast/type/type/ReferenceType.java @@ -0,0 +1,4 @@ +package ast.type.type; + +public class ReferenceType { +} diff --git a/src/main/java/ast/type/TypeNode.java b/src/main/java/ast/type/type/TypeNode.java similarity index 92% rename from src/main/java/ast/type/TypeNode.java rename to src/main/java/ast/type/type/TypeNode.java index 6e5d192..55bf1b2 100644 --- a/src/main/java/ast/type/TypeNode.java +++ b/src/main/java/ast/type/type/TypeNode.java @@ -1,4 +1,6 @@ -package ast.type; +package ast.type.type; + +import ast.type.EnumTypeNode; public class TypeNode { public EnumTypeNode type; diff --git a/src/main/java/bytecode/ByteCodeGenerator.java b/src/main/java/bytecode/ByteCodeGenerator.java index 5494255..d85935a 100644 --- a/src/main/java/bytecode/ByteCodeGenerator.java +++ b/src/main/java/bytecode/ByteCodeGenerator.java @@ -10,7 +10,7 @@ public class ByteCodeGenerator implements ProgramVisitor { public void visit(ProgramNode programNode) { for (ClassNode classDeclarationNode : programNode.classes) { ClassCodeGen classCodeGen = new ClassCodeGen(); - classDeclarationNode.accept(classCodeGen); +// classDeclarationNode.accept(classCodeGen); } } } diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index c65c3c6..c666881 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -4,7 +4,7 @@ import ast.ClassNode; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; -import ast.type.TypeNode; +import ast.type.type.TypeNode; import bytecode.visitor.ClassVisitor; import java.io.File; import org.objectweb.asm.ClassWriter; diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 8fc6c4f..642355b 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -10,6 +10,7 @@ import ast.expression.binaryexpression.NonCalculationExpressionNode; import ast.expression.unaryexpression.MemberAccessNode; import ast.expression.unaryexpression.NotExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; +import ast.member.FieldNode; import ast.member.MethodNode; import ast.statement.ifstatement.ElseStatementNode; import ast.statement.ifstatement.IfElseStatementNode; @@ -28,6 +29,7 @@ import ast.statement.statementexpression.methodcallstatementnexpression.ChainedM import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; import ast.statement.statementexpression.methodcallstatementnexpression.TargetNode; import ast.type.*; +import ast.type.type.TypeNode; import org.antlr.v4.runtime.tree.TerminalNode; import parser.generated.*; @@ -74,13 +76,18 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { } else { MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { -// methodNode.addParameter((ParameterNode) visit(parameter)); + methodNode.addParameter((ParameterNode) visit(parameter)); } return methodNode; } } } + @Override + public ASTNode visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { + return new FieldNode(new AccessModifierNode(ctx.AccessModifier().getText()), new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); + } + @Override public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) { return new ParameterNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); diff --git a/src/main/java/semantic/Scope.java b/src/main/java/semantic/Scope.java index 7cf4cc9..724aed4 100644 --- a/src/main/java/semantic/Scope.java +++ b/src/main/java/semantic/Scope.java @@ -1,6 +1,7 @@ package semantic; -import ast.type.TypeNode; +import ast.type.type.TypeNode; +import semantic.exeptions.AlreadyDeclearedException; import java.util.HashMap; import java.util.Stack; @@ -15,7 +16,7 @@ public class Scope { public void addLocalVar(String name, TypeNode type) { if (this.contains(name)) { - throw new RuntimeException("Variable " + name + " already exists in this scope"); + throw new AlreadyDeclearedException("Variable " + name + " already exists in this scope"); } localVars.peek().put(name, type); } diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 8c7e833..739f04e 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -8,13 +8,28 @@ import java.util.Objects; import ast.*; import ast.block.BlockNode; +import ast.expression.IExpressionNode; +import ast.expression.binaryexpression.*; +import ast.expression.unaryexpression.UnaryExpressionNode; import ast.member.*; import ast.parameter.ParameterNode; import ast.statement.*; +import ast.statement.ifstatement.ElseStatementNode; +import ast.statement.ifstatement.IfElseStatementNode; import ast.statement.ifstatement.IfStatementNode; -import ast.type.*; +import ast.statement.statementexpression.AssignStatementExpressionNode; +import ast.statement.statementexpression.AssignableExpressionNode; +import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; +import ast.statement.statementexpression.crementExpression.DecrementExpressionNode; +import ast.statement.statementexpression.crementExpression.IncrementExpressionNode; +import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; +import ast.type.type.BaseType; +import ast.type.type.ReferenceType; +import ast.type.type.TypeNode; import semantic.context.Context; import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.AlreadyDefinedException; +import semantic.exeptions.NotDeclearedException; import semantic.exeptions.TypeMismatchException; import typechecker.TypeCheckResult; @@ -24,9 +39,10 @@ public class SemanticAnalyzer implements SemanticVisitor { public static ArrayList errors = new ArrayList<>(); - private Context context; + private static Context context; private static Scope currentScope; private static ClassNode currentClass; + private static TypeNode currentNullType; public static ASTNode generateTast(ASTNode node) { SemanticAnalyzer semanticCheck = new SemanticAnalyzer(); @@ -42,7 +58,7 @@ public class SemanticAnalyzer implements SemanticVisitor { return null; } - public static void clearAnalyzier(){ + public static void clearAnalyzer() { currentFields.clear(); errors.clear(); currentScope = null; @@ -79,8 +95,8 @@ public class SemanticAnalyzer implements SemanticVisitor { valid = valid && result.isValid(); } else if (memberNode instanceof MethodNode methodNode) { //Methods - for(MethodNode methode : currentClass.getMethods()){ - if(methode.equals(methodNode)) + for (MethodNode methode : currentClass.getMethods()) { + if (methode.equals(methodNode)) break; } @@ -98,11 +114,11 @@ public class SemanticAnalyzer implements SemanticVisitor { var valid = true; for (var otherMethod : currentClass.getMethods()) { - if (Objects.equals(otherMethod , methodNode)) + if (Objects.equals(otherMethod, methodNode)) break; if (otherMethod.isSame(methodNode)) { errors.add(new AlreadyDeclearedException( - "Method " + methodNode.identifier + " is already defined in class " + "Method " + methodNode.getIdentifier() + " is already defined in class " + currentClass.identifier)); valid = false; } @@ -112,31 +128,41 @@ public class SemanticAnalyzer implements SemanticVisitor { for (var parameter : methodNode.getParameters()) { var result = parameter.accept(this); valid = valid && result.isValid(); - currentScope.addLocalVar(parameter.identifier, parameter.type); + try { + currentScope.addLocalVar(parameter.identifier, parameter.type); + } catch (AlreadyDeclearedException e) { + errors.add(new AlreadyDeclearedException(parameter.identifier)); + } + } // Check if this method is already declared // currentMethodReturnType = methodDecl.getType(); // currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ - // gesetzt ist, ist dieser der Rückgabewert der Methode - var result = methodNode.block.accept(this); - valid = valid && result.isValid(); - currentScope.popScope(); - var resultType = result.getType(); + TypeNode resultType = new TypeNode("void"); - /* - if (resultType == null) { - resultType = new BaseType(Primitives.VOID); - } - if (!resultType.equals(methodDecl.getType())) { - errors.add(new TypeMismatchException("Method-Declaration " + methodDecl.getIdentifier() + " with type " - + methodDecl.getType() + " has at least one Mismatching return Type:" - + TypeHelper.generateLocationString(methodDecl.line, methodDecl.column, fileName))); - valid = false; + if (methodNode.block != null) { + // gesetzt ist, ist dieser der Rückgabewert der Methode + var result = methodNode.block.accept(this); + valid = valid && result.isValid(); + currentScope.popScope(); + resultType = result.getType(); + + /* + if (resultType == null) { + resultType = new BaseType(Primitives.VOID); + } + if (!resultType.equals(methodDecl.getType())) { + errors.add(new TypeMismatchException("Method-Declaration " + methodDecl.getIdentifier() + " with type " + + methodDecl.getType() + " has at least one Mismatching return Type:" + + TypeHelper.generateLocationString(methodDecl.line, methodDecl.column, fileName))); + valid = false; + } + + */ } - */ return new TypeCheckResult(valid, resultType); } @@ -168,12 +194,165 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(ParameterNode toCheck) { + + return new TypeCheckResult(true, null); } @Override - public TypeCheckResult analyze(BlockNode toCheck) { + public TypeCheckResult analyze(BlockNode blockNode) { + + for (IStatementNode statementNode : blockNode.statements) { + statementNode.accept(this); + } return new TypeCheckResult(true, null); } + @Override + public TypeCheckResult analyze(AssignableExpressionNode toCheck) { + return new TypeCheckResult(true, currentFields.get(toCheck.identifier)); + + } + + @Override + public TypeCheckResult analyze(ElseStatementNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(ForStatementNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(AssignStatementExpressionNode toCheck) { + AssignableExpressionNode assignable = toCheck.assignable; + var oldNullType = currentNullType; + currentNullType = currentFields.get(toCheck.assignable.identifier); + IExpressionNode rExpression = toCheck.expression; + currentNullType = oldNullType; + var valid = true; + + // This check currently handles things like : + /** + * private int i; + * void foo(int i){ + * i = i; + * } + */ + if (assignable.equals(rExpression)) { + errors.add(new TypeMismatchException("Cannot assign to self")); + valid = false; + } + + var lResult = assignable.accept(this); + currentNullType = lResult.getType(); + var rResult = rExpression.accept(this); + + if (!Objects.equals(currentFields.get(toCheck.assignable.identifier), rExpression.getType())) { + errors.add(new TypeMismatchException( + "Mismatch types in Assign-Statement: cannot convert from \"" + lResult.getType() + "\" to \"" + + rResult.getType() + "\"")); + valid = false; + } +// else { +// toCheck.setType(assignable.getType()); +// } + valid = valid && lResult.isValid() && rResult.isValid(); + currentNullType = null; + return new TypeCheckResult(valid, null); // return type is null to get the return type sufficently + } + + @Override + public TypeCheckResult analyze(DecrementExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(IfElseStatementNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(MethodCallStatementExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(LocalVariableDeclarationNode localVarDecl) { + var valid = true; + + if (localVarDecl.expression != null) { + TypeCheckResult result = localVarDecl.expression.accept(this); + + var resultType = localVarDecl.expression.getType(); + valid = result.isValid() && valid; + + if (!Objects.equals(resultType, localVarDecl.type)) { + errors.add(new TypeMismatchException( + "Type mismatch: cannot convert from " + resultType + " to " + localVarDecl.type)); + valid = false; + } + + } + + try { + currentScope.addLocalVar(localVarDecl.identifier, localVarDecl.type); + } catch (AlreadyDefinedException e) { + errors.add(new AlreadyDefinedException(e.getMessage())); + valid = false; + } + return new TypeCheckResult(valid, null); + } + + @Override + public TypeCheckResult analyze(NewDeclarationStatementExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(IncrementExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(BinaryExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(CalculationExpressionNode calcNode) { + if(calcNode.calculationExpression != null){ + calcNode.calculationExpression.accept(this); + } + return null; + } + + @Override + public TypeCheckResult analyze(DotExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(DotSubstractionExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(NonCalculationExpressionNode toCheck) { + return null; + } + + @Override + public TypeCheckResult analyze(UnaryExpressionNode unary) { + var valid = true; + + if (!currentScope.contains(unary.identifier)) { + errors.add(new NotDeclearedException("Not declared " + unary.identifier)); + return new TypeCheckResult(false, null); + } + + return new TypeCheckResult(valid, unary.getType()); + } + } \ No newline at end of file diff --git a/src/main/java/semantic/SemanticVisitor.java b/src/main/java/semantic/SemanticVisitor.java index aca196b..6b6942f 100644 --- a/src/main/java/semantic/SemanticVisitor.java +++ b/src/main/java/semantic/SemanticVisitor.java @@ -3,10 +3,18 @@ package semantic; import ast.*; import ast.block.BlockNode; +import ast.expression.binaryexpression.*; +import ast.expression.unaryexpression.UnaryExpressionNode; import ast.member.*; import ast.parameter.ParameterNode; import ast.statement.*; import ast.statement.ifstatement.*; +import ast.statement.statementexpression.AssignStatementExpressionNode; +import ast.statement.statementexpression.AssignableExpressionNode; +import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; +import ast.statement.statementexpression.crementExpression.DecrementExpressionNode; +import ast.statement.statementexpression.crementExpression.IncrementExpressionNode; +import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; import typechecker.TypeCheckResult; public interface SemanticVisitor { @@ -29,5 +37,36 @@ public interface SemanticVisitor { TypeCheckResult analyze(BlockNode toCheck); + TypeCheckResult analyze(AssignableExpressionNode toCheck); + + TypeCheckResult analyze(ElseStatementNode toCheck); + + TypeCheckResult analyze(ForStatementNode toCheck); + + TypeCheckResult analyze(AssignStatementExpressionNode toCheck); + + TypeCheckResult analyze(DecrementExpressionNode toCheck); + + TypeCheckResult analyze(IfElseStatementNode toCheck); + + TypeCheckResult analyze(MethodCallStatementExpressionNode toCheck); + + TypeCheckResult analyze(LocalVariableDeclarationNode toCheck); + + TypeCheckResult analyze(NewDeclarationStatementExpressionNode toCheck); + + TypeCheckResult analyze(IncrementExpressionNode toCheck); + + TypeCheckResult analyze(BinaryExpressionNode toCheck); + + TypeCheckResult analyze(CalculationExpressionNode toCheck); + + TypeCheckResult analyze(DotExpressionNode toCheck); + + TypeCheckResult analyze(DotSubstractionExpressionNode toCheck); + + TypeCheckResult analyze(NonCalculationExpressionNode toCheck); + + TypeCheckResult analyze(UnaryExpressionNode toCheck); } \ No newline at end of file diff --git a/src/main/java/semantic/context/FieldContext.java b/src/main/java/semantic/context/FieldContext.java index 35c1f46..6c594c9 100644 --- a/src/main/java/semantic/context/FieldContext.java +++ b/src/main/java/semantic/context/FieldContext.java @@ -2,6 +2,7 @@ package semantic.context; import ast.member.FieldNode; import ast.type.*; +import ast.type.type.TypeNode; public class FieldContext { diff --git a/src/main/java/semantic/exeptions/AlreadyDefinedException.java b/src/main/java/semantic/exeptions/AlreadyDefinedException.java new file mode 100644 index 0000000..441a5d9 --- /dev/null +++ b/src/main/java/semantic/exeptions/AlreadyDefinedException.java @@ -0,0 +1,9 @@ +package semantic.exeptions; + +public class AlreadyDefinedException extends RuntimeException { + + public AlreadyDefinedException(String message) { + super(message); + } + +} diff --git a/src/main/java/typechecker/TypeCheckResult.java b/src/main/java/typechecker/TypeCheckResult.java index 12143b2..21c12df 100644 --- a/src/main/java/typechecker/TypeCheckResult.java +++ b/src/main/java/typechecker/TypeCheckResult.java @@ -1,7 +1,7 @@ package typechecker; -import ast.type.TypeNode; +import ast.type.type.TypeNode; public class TypeCheckResult { diff --git a/src/test/java/semantic/EndToTAST.java b/src/test/java/semantic/EndToTAST.java new file mode 100644 index 0000000..2d14077 --- /dev/null +++ b/src/test/java/semantic/EndToTAST.java @@ -0,0 +1,231 @@ +package semantic; + +import ast.ASTNode; +import ast.ProgramNode; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTree; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import parser.astBuilder.ASTBuilder; +import parser.generated.SimpleJavaLexer; +import parser.generated.SimpleJavaParser; +import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.NotDeclearedException; +import semantic.exeptions.TypeMismatchException; + +import java.io.IOException; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.*; + +public class EndToTAST { + + @BeforeEach + public void setup(){ + SemanticAnalyzer.clearAnalyzer(); + } + + @Test + public void CorrectTest(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/CorrectTest.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); // parse the input + + /* ------------------------- AST builder -> AST ------------------------- */ + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertEquals(SemanticAnalyzer.errors.size(), 0); + assertNotNull(tast); + + } + + @Test + public void notDecleared() { + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/NotDecleared.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); // parse the input + + /* ------------------------- AST builder -> AST ------------------------- */ + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(NotDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void typeMismatch(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/TypeMismatchIntBool.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void parameterAlreadyDecleared(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/ParameterAlreadyDecleared.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void fieldAlreadyDecleared(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/FieldAlreadyDecleared.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void correctInstVarTest(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/CorrectInstVar.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + + @Test + public void typeMismatchRefType(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/TypeMismatchRefType.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void correctRetType(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/TypeMismatchRefType.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + + } + +} diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index 5a5e014..c38a37e 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -5,15 +5,8 @@ import ast.block.BlockNode; import ast.member.FieldNode; import ast.member.MethodNode; import ast.parameter.ParameterNode; -import ast.statement.StatementNode; -import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; import ast.type.AccessModifierNode; -import ast.type.TypeNode; - -import java.util.ArrayList; -import java.util.List; - -import static parser.generated.SimpleJavaParser.Identifier; +import ast.type.type.TypeNode; public class Mocker { @@ -68,7 +61,7 @@ public class Mocker { methodNode.block = new BlockNode(); methodNode.type = new TypeNode("int"); - methodNode.identifier = "testMethod"; + methodNode.setIdentifier("testMethod"); c.members.add(methodNode); @@ -76,7 +69,7 @@ public class Mocker { methodNode1.block = new BlockNode(); methodNode1.type = new TypeNode("int"); - methodNode1.identifier = "testMethod"; + methodNode1.setIdentifier("testMethod"); c.members.add(methodNode1); @@ -92,13 +85,13 @@ public class Mocker { MethodNode methodNode = new MethodNode(); methodNode.block = new BlockNode(); - methodNode.identifier = "testMethod"; + methodNode.setIdentifier("testMethod"); c.members.add(methodNode); MethodNode methodNode1 = new MethodNode(); methodNode1.block = new BlockNode(); - methodNode1.identifier = "testMethod1"; + methodNode1.setIdentifier("testMethod1"); c.members.add(methodNode1); diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index 7ebc7ad..7000876 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -9,20 +9,17 @@ import static org.junit.jupiter.api.Assertions.*; public class SemanticTest { - @BeforeEach - public void setup(){ - SemanticAnalyzer.clearAnalyzier(); - } @Test public void twoFieldsSameName() { ASTNode ast = Mocker.mockTwoSameFields(); - ASTNode tast = SemanticAnalyzer.generateTast(ast); + SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); + ASTNode tast = semanticAnalyzer.generateTast(ast); - assertEquals(SemanticAnalyzer.errors.size(), 1); - assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + assertEquals(semanticAnalyzer.errors.size(), 1); + assertInstanceOf(AlreadyDeclearedException.class, semanticAnalyzer.errors.getFirst()); assertNull(tast); } @@ -32,9 +29,10 @@ public class SemanticTest { ASTNode ast = Mocker.mockSimpleMethod(); - ASTNode tast = SemanticAnalyzer.generateTast(ast); + SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); + ASTNode tast = semanticAnalyzer.generateTast(ast); - assertEquals(SemanticAnalyzer.errors.size(), 0); + assertEquals(semanticAnalyzer.errors.size(), 0); assertNotNull(tast); } @@ -43,10 +41,11 @@ public class SemanticTest { public void twoSameMethods(){ ASTNode ast = Mocker.mockTwoSameMethods(); - ASTNode tast = SemanticAnalyzer.generateTast(ast); + SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); + ASTNode tast = semanticAnalyzer.generateTast(ast); - assertEquals(1, SemanticAnalyzer.errors.size()); - assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); + assertEquals(1, semanticAnalyzer.errors.size()); + assertInstanceOf(AlreadyDeclearedException.class, semanticAnalyzer.errors.getFirst()); assertNull(tast); } @@ -54,9 +53,10 @@ public class SemanticTest { public void twoDifferentMethods(){ ASTNode ast = Mocker.mockTwoDifferentMethods(); - ASTNode tast = SemanticAnalyzer.generateTast(ast); + SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); + ASTNode tast = semanticAnalyzer.generateTast(ast); - assertEquals(SemanticAnalyzer.errors.size(), 0); + assertEquals(semanticAnalyzer.errors.size(), 0); assertNotNull(tast); } diff --git a/src/test/java/semantic/endToTAST/CorrectTest.java b/src/test/java/semantic/endToTAST/CorrectTest.java deleted file mode 100644 index e3a7a08..0000000 --- a/src/test/java/semantic/endToTAST/CorrectTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package semantic.endToTAST; - -import ast.ASTNode; -import ast.ProgramNode; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.jupiter.api.Test; -import parser.astBuilder.ASTBuilder; -import parser.generated.SimpleJavaLexer; -import parser.generated.SimpleJavaParser; -import semantic.SemanticAnalyzer; - -import java.io.IOException; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class CorrectTest { - - @Test - public void first(){ - - CharStream codeCharStream = null; - try { - codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/Test.java")); - } catch (IOException e) { - throw new RuntimeException(e); - } - SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); - CommonTokenStream tokenStream = new CommonTokenStream(lexer); - - SimpleJavaParser parser = new SimpleJavaParser(tokenStream); - ParseTree parseTree = parser.program(); // parse the input - - /* ------------------------- AST builder -> AST ------------------------- */ - ASTBuilder astBuilder = new ASTBuilder(); - ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); - - System.out.println("Test"); - - ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); - - System.out.println("Errors: " + SemanticAnalyzer.errors.size()); - - assertEquals(SemanticAnalyzer.errors.size(), 0); - - } - -} diff --git a/src/test/resources/semantic/endToTAST/CorrectInstVar.java b/src/test/resources/semantic/endToTAST/CorrectInstVar.java new file mode 100644 index 0000000..5c20dab --- /dev/null +++ b/src/test/resources/semantic/endToTAST/CorrectInstVar.java @@ -0,0 +1,18 @@ +public class Test { + + public Example ex; + + public static int testMethod(char x){ + + int b = this.ex.a; + + return x; + } + +} + +public class Example { + + public int a; + +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/CorrectTest.java b/src/test/resources/semantic/endToTAST/CorrectTest.java new file mode 100644 index 0000000..8e3bf62 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/CorrectTest.java @@ -0,0 +1,16 @@ +public class Example { + + public int a; + + public static int testMethod(char x){ + + } + +} + +public class Test { + + public static int testMethod(char x, int a){ + return x; + } +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/FieldAlreadyDecleared.java b/src/test/resources/semantic/endToTAST/FieldAlreadyDecleared.java new file mode 100644 index 0000000..535a592 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/FieldAlreadyDecleared.java @@ -0,0 +1,10 @@ +public class Example { + + public int a; + public int a; + + public static int testMethod(char a){ + + } + +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/NotDecleared.java b/src/test/resources/semantic/endToTAST/NotDecleared.java new file mode 100644 index 0000000..4aba5f8 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/NotDecleared.java @@ -0,0 +1,6 @@ +public class Test { + public static int testMethod(int x){ + int a = b; + return x; + } +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/ParameterAlreadyDecleared.java b/src/test/resources/semantic/endToTAST/ParameterAlreadyDecleared.java new file mode 100644 index 0000000..d2b3425 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/ParameterAlreadyDecleared.java @@ -0,0 +1,7 @@ +public class Example { + + public static int testMethod(char a, int a){ + + } + +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/Test.java b/src/test/resources/semantic/endToTAST/Test.java deleted file mode 100644 index d067998..0000000 --- a/src/test/resources/semantic/endToTAST/Test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test { - - public boolean b; - public boolean b; - -} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/TypeMismatchIntBool.java b/src/test/resources/semantic/endToTAST/TypeMismatchIntBool.java new file mode 100644 index 0000000..9b609b6 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/TypeMismatchIntBool.java @@ -0,0 +1,10 @@ +public class Test { + + public boolean b; + + public static int testMethod(int a){ + + b = a; + + } +} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/TypeMismatchRefType.java b/src/test/resources/semantic/endToTAST/TypeMismatchRefType.java new file mode 100644 index 0000000..a7b8cc9 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/TypeMismatchRefType.java @@ -0,0 +1,16 @@ +public class Test { + + public static int testMethod(ExampleA exampleA, ExampleB exampleB){ + + exampleA = exampleB; + + } +} + +public class ExampleA{ + public int a; +} + +public class ExampleB{ + public int a; +} \ No newline at end of file -- 2.34.1 From cf41babcb7818c523c6efa4de0deb5f07492d33b Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 16:42:27 +0200 Subject: [PATCH 14/19] Added BaseType And refferenz Type --- .../java/ast/expression/IExpressionNode.java | 4 +- .../BinaryExpressionNode.java | 4 +- .../CalculationExpressionNode.java | 4 +- .../binaryexpression/DotExpressionNode.java | 4 +- .../DotSubstractionExpressionNode.java | 4 +- .../NonCalculationExpressionNode.java | 4 +- .../unaryexpression/UnaryExpressionNode.java | 8 +- src/main/java/ast/member/ConstructorNode.java | 5 +- src/main/java/ast/member/FieldNode.java | 6 +- src/main/java/ast/member/MethodNode.java | 16 ++- .../java/ast/parameter/ParameterNode.java | 6 +- .../LocalVariableDeclarationNode.java | 6 +- .../AssignStatementExpressionNode.java | 2 - .../AssignableExpressionNode.java | 2 - src/main/java/ast/type/type/BaseType.java | 28 ++++- src/main/java/ast/type/type/ITypeNode.java | 5 + .../java/ast/type/type/ReferenceType.java | 31 +++++- src/main/java/ast/type/type/TypeEnum.java | 9 ++ src/main/java/ast/type/type/TypeNode.java | 33 ------ src/main/java/bytecode/ClassCodeGen.java | 4 +- .../java/parser/astBuilder/ASTBuilder.java | 21 +++- src/main/java/semantic/Scope.java | 19 +++- src/main/java/semantic/SemanticAnalyzer.java | 105 +++++++++--------- .../java/semantic/context/FieldContext.java | 6 +- .../exeptions/MultipleReturnTypes.java | 9 ++ .../java/typechecker/TypeCheckResult.java | 8 +- src/test/java/semantic/EndToTAST.java | 52 ++++++++- src/test/java/semantic/Mocker.java | 12 +- .../semantic/endToTAST/CorrectRetType.java | 7 ++ .../semantic/endToTAST/CorrectTest.java | 4 +- .../semantic/endToTAST/MultipleRetTypes.java | 8 ++ .../semantic/endToTAST/retTypeMismatch.java | 7 ++ 32 files changed, 296 insertions(+), 147 deletions(-) create mode 100644 src/main/java/ast/type/type/ITypeNode.java create mode 100644 src/main/java/ast/type/type/TypeEnum.java delete mode 100644 src/main/java/ast/type/type/TypeNode.java create mode 100644 src/main/java/semantic/exeptions/MultipleReturnTypes.java create mode 100644 src/test/resources/semantic/endToTAST/CorrectRetType.java create mode 100644 src/test/resources/semantic/endToTAST/MultipleRetTypes.java create mode 100644 src/test/resources/semantic/endToTAST/retTypeMismatch.java diff --git a/src/main/java/ast/expression/IExpressionNode.java b/src/main/java/ast/expression/IExpressionNode.java index c4c72f5..28b45e3 100644 --- a/src/main/java/ast/expression/IExpressionNode.java +++ b/src/main/java/ast/expression/IExpressionNode.java @@ -1,11 +1,11 @@ package ast.expression; import ast.ASTNode; -import ast.type.type.TypeNode; +import ast.type.type.ITypeNode; import visitor.Visitable; public interface IExpressionNode extends ASTNode, Visitable { - TypeNode getType(); + ITypeNode getType(); } diff --git a/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java index d4db5ab..655a3f5 100644 --- a/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/BinaryExpressionNode.java @@ -1,7 +1,7 @@ package ast.expression.binaryexpression; import ast.expression.IExpressionNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -13,7 +13,7 @@ public class BinaryExpressionNode implements IExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return null; } } diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java index 53adaa2..70451d8 100644 --- a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -1,6 +1,6 @@ package ast.expression.binaryexpression; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -25,7 +25,7 @@ public class CalculationExpressionNode extends BinaryExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return null; } diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java index 9ea8170..cc5f2c6 100644 --- a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -1,6 +1,6 @@ package ast.expression.binaryexpression; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -25,7 +25,7 @@ public class DotExpressionNode extends BinaryExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return null; } diff --git a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java index 17c9604..1b43a9f 100644 --- a/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotSubstractionExpressionNode.java @@ -2,7 +2,7 @@ package ast.expression.binaryexpression; import ast.expression.unaryexpression.MemberAccessNode; import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import ast.type.ValueNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -37,7 +37,7 @@ public class DotSubstractionExpressionNode extends BinaryExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return null; } diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java index 8051bd2..5cdebc2 100644 --- a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -2,7 +2,7 @@ package ast.expression.binaryexpression; import ast.expression.IExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -23,7 +23,7 @@ public class NonCalculationExpressionNode extends BinaryExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return null; } diff --git a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java index 74be5ff..4393e84 100644 --- a/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java +++ b/src/main/java/ast/expression/unaryexpression/UnaryExpressionNode.java @@ -2,7 +2,7 @@ package ast.expression.unaryexpression; import ast.expression.IExpressionNode; import ast.statement.IStatementNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import ast.type.ValueNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -17,7 +17,7 @@ public class UnaryExpressionNode implements IExpressionNode { public NotExpressionNode notExpression; public IStatementNode statement; public IExpressionNode expression; - private TypeNode type; + private ITypeNode type; public UnaryExpressionNode(String value) { if(Objects.equals(value, "this")) { @@ -53,11 +53,11 @@ public class UnaryExpressionNode implements IExpressionNode { } @Override - public TypeNode getType() { + public ITypeNode getType() { return type; } - public void setType(TypeNode type) { + public void setType(ITypeNode type) { this.type = type; } diff --git a/src/main/java/ast/member/ConstructorNode.java b/src/main/java/ast/member/ConstructorNode.java index 0f7a200..52d7604 100644 --- a/src/main/java/ast/member/ConstructorNode.java +++ b/src/main/java/ast/member/ConstructorNode.java @@ -3,11 +3,14 @@ package ast.member; import ast.block.BlockNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; +import semantic.SemanticVisitor; +import typechecker.TypeCheckResult; +import visitor.Visitable; import java.util.ArrayList; import java.util.List; -public class ConstructorNode extends MethodNode { +public class ConstructorNode extends MethodNode { public AccessModifierNode accessType; public String identifier; public List parameters = new ArrayList<>(); diff --git a/src/main/java/ast/member/FieldNode.java b/src/main/java/ast/member/FieldNode.java index 4377f09..f269c40 100644 --- a/src/main/java/ast/member/FieldNode.java +++ b/src/main/java/ast/member/FieldNode.java @@ -1,17 +1,17 @@ package ast.member; import ast.type.AccessModifierNode; -import ast.type.type.TypeNode; +import ast.type.type.ITypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; public class FieldNode implements MemberNode, Visitable { public AccessModifierNode accessTypeNode; - public TypeNode type; + public ITypeNode type; public String identifier; - public FieldNode(AccessModifierNode accessTypeNode, TypeNode type, String name){ + public FieldNode(AccessModifierNode accessTypeNode, ITypeNode type, String name){ this.accessTypeNode = accessTypeNode; this.type = type; this.identifier = name; diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index e318068..ecfd598 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -3,7 +3,7 @@ package ast.member; import ast.block.BlockNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import bytecode.visitor.MethodVisitor; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; @@ -15,7 +15,7 @@ import java.util.Objects; public class MethodNode implements MemberNode, Visitable { public AccessModifierNode accesModifier; - public TypeNode type; + private ITypeNode type; public Boolean voidType; private String identifier; public List parameters = new ArrayList<>(); @@ -27,9 +27,9 @@ public class MethodNode implements MemberNode, Visitable { this.block = block; } - public MethodNode(String accessModifier, String type, Boolean voidType, String identifier, BlockNode block){ + public MethodNode(String accessModifier, ITypeNode type, Boolean voidType, String identifier, BlockNode block){ this.accesModifier = new AccessModifierNode(accessModifier); - this.type = new TypeNode(type); + this.type = type; this.voidType = voidType; this.identifier = identifier; this.block = block; @@ -71,6 +71,14 @@ public class MethodNode implements MemberNode, Visitable { return identifier; } + public ITypeNode getType() { + return type; + } + + public void setType(ITypeNode type) { + this.type = type; + } + public void setIdentifier(String identifier) { this.identifier = identifier; } diff --git a/src/main/java/ast/parameter/ParameterNode.java b/src/main/java/ast/parameter/ParameterNode.java index 4c81620..257eb68 100644 --- a/src/main/java/ast/parameter/ParameterNode.java +++ b/src/main/java/ast/parameter/ParameterNode.java @@ -1,16 +1,16 @@ package ast.parameter; import ast.ASTNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; public class ParameterNode implements ASTNode, Visitable { - public TypeNode type; + public ITypeNode type; public String identifier; - public ParameterNode(TypeNode type, String identifier) { + public ParameterNode(ITypeNode type, String identifier) { this.type = type; this.identifier = identifier; } diff --git a/src/main/java/ast/statement/LocalVariableDeclarationNode.java b/src/main/java/ast/statement/LocalVariableDeclarationNode.java index 3493c3b..3ab54e0 100644 --- a/src/main/java/ast/statement/LocalVariableDeclarationNode.java +++ b/src/main/java/ast/statement/LocalVariableDeclarationNode.java @@ -1,17 +1,17 @@ package ast.statement; import ast.expression.IExpressionNode; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; public class LocalVariableDeclarationNode implements IStatementNode { - public TypeNode type; + public ITypeNode type; public String identifier; public String assign; public IExpressionNode expression; - public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, IExpressionNode expression) { + public LocalVariableDeclarationNode(ITypeNode type, String identifier, String assign, IExpressionNode expression) { this.type = type; this.identifier = identifier; this.assign = assign; diff --git a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java index 19b34e5..df8fe79 100644 --- a/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignStatementExpressionNode.java @@ -1,8 +1,6 @@ package ast.statement.statementexpression; -import ast.ASTNode; import ast.expression.IExpressionNode; -import ast.type.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java index 9ccdfec..0fb9fa9 100644 --- a/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java +++ b/src/main/java/ast/statement/statementexpression/AssignableExpressionNode.java @@ -1,8 +1,6 @@ package ast.statement.statementexpression; -import ast.ASTNode; import ast.expression.unaryexpression.MemberAccessNode; -import ast.type.type.TypeNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; diff --git a/src/main/java/ast/type/type/BaseType.java b/src/main/java/ast/type/type/BaseType.java index d88fd99..fdfb293 100644 --- a/src/main/java/ast/type/type/BaseType.java +++ b/src/main/java/ast/type/type/BaseType.java @@ -1,4 +1,30 @@ package ast.type.type; -public class BaseType { +public class BaseType implements ITypeNode { + + private TypeEnum typeEnum; + + public BaseType(TypeEnum typeEnum) { + this.typeEnum = typeEnum; + } + + public TypeEnum getTypeEnum() { + return typeEnum; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BaseType other = (BaseType) obj; + if (typeEnum != other.typeEnum) + return false; + return true; + } + + } diff --git a/src/main/java/ast/type/type/ITypeNode.java b/src/main/java/ast/type/type/ITypeNode.java new file mode 100644 index 0000000..e449e3c --- /dev/null +++ b/src/main/java/ast/type/type/ITypeNode.java @@ -0,0 +1,5 @@ +package ast.type.type; + +public interface ITypeNode { + +} diff --git a/src/main/java/ast/type/type/ReferenceType.java b/src/main/java/ast/type/type/ReferenceType.java index 4078c3f..2292046 100644 --- a/src/main/java/ast/type/type/ReferenceType.java +++ b/src/main/java/ast/type/type/ReferenceType.java @@ -1,4 +1,33 @@ package ast.type.type; -public class ReferenceType { +public class ReferenceType implements ITypeNode{ + + private String identifier; + + public ReferenceType(String identifier) { + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ReferenceType other = (ReferenceType) obj; + if (identifier == null) { + if (other.identifier != null) + return false; + } else if (!identifier.equals(other.identifier)) + return false; + return true; + } + + } diff --git a/src/main/java/ast/type/type/TypeEnum.java b/src/main/java/ast/type/type/TypeEnum.java new file mode 100644 index 0000000..d46fac3 --- /dev/null +++ b/src/main/java/ast/type/type/TypeEnum.java @@ -0,0 +1,9 @@ +package ast.type.type; + +public enum TypeEnum { + VOID, + INT, + CHAR, + BOOL; + +} diff --git a/src/main/java/ast/type/type/TypeNode.java b/src/main/java/ast/type/type/TypeNode.java deleted file mode 100644 index 55bf1b2..0000000 --- a/src/main/java/ast/type/type/TypeNode.java +++ /dev/null @@ -1,33 +0,0 @@ -package ast.type.type; - -import ast.type.EnumTypeNode; - -public class TypeNode { - public EnumTypeNode type; - - public TypeNode(String type) { - setType(type); - } - - private void setType(String type) { - switch(type) { - case "int": - this.type = EnumTypeNode.INT; - break; - case "boolean": - this.type = EnumTypeNode.BOOLEAN; - break; - case "char": - this.type = EnumTypeNode.CHAR; - break; - default: - this.type = EnumTypeNode.IDENTIFIER; - } - } - - - public boolean equals(TypeNode o) { - return !o.type.equals(this.type); - } - -} diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index c666881..c911199 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -4,7 +4,7 @@ import ast.ClassNode; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; -import ast.type.type.TypeNode; +import ast.type.type.BaseType; import bytecode.visitor.ClassVisitor; import java.io.File; import org.objectweb.asm.ClassWriter; @@ -44,7 +44,7 @@ public class ClassCodeGen implements ClassVisitor { @Override public void visit(FieldNode fieldNode) { - if(fieldNode.type instanceof TypeNode baseTypeNode){ + if(fieldNode.type instanceof BaseType baseTypeNode){ // classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null ); } classWriter.visitEnd(); diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 642355b..31a8b82 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -29,7 +29,7 @@ import ast.statement.statementexpression.methodcallstatementnexpression.ChainedM import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; import ast.statement.statementexpression.methodcallstatementnexpression.TargetNode; import ast.type.*; -import ast.type.type.TypeNode; +import ast.type.type.*; import org.antlr.v4.runtime.tree.TerminalNode; import parser.generated.*; @@ -68,7 +68,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { return new MethodNode((BlockNode) visit(ctx.block())); } else { if(ctx.type() != null) { - MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), ctx.type().getText(), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); + MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), createTypeNode(ctx.type().getText()), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { methodNode.addParameter((ParameterNode) visit(parameter)); } @@ -85,12 +85,12 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { - return new FieldNode(new AccessModifierNode(ctx.AccessModifier().getText()), new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); + return new FieldNode(new AccessModifierNode(ctx.AccessModifier().getText()), createTypeNode(ctx.type().getText()), ctx.Identifier().getText()); } @Override public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) { - return new ParameterNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText()); + return new ParameterNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText()); } @Override @@ -120,7 +120,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { - return new LocalVariableDeclarationNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression())); + return new LocalVariableDeclarationNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression())); } @Override @@ -401,4 +401,15 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { } return null; } + + public ITypeNode createTypeNode(String identifier){ + return switch (identifier) { + case "int" -> new BaseType(TypeEnum.INT); + case "boolean" -> new BaseType(TypeEnum.BOOL); + case "char" -> new BaseType(TypeEnum.CHAR); + case "void" -> new BaseType(TypeEnum.VOID); + default -> new ReferenceType(identifier); + }; + } + } diff --git a/src/main/java/semantic/Scope.java b/src/main/java/semantic/Scope.java index 724aed4..39dd2f8 100644 --- a/src/main/java/semantic/Scope.java +++ b/src/main/java/semantic/Scope.java @@ -1,6 +1,6 @@ package semantic; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.exeptions.AlreadyDeclearedException; import java.util.HashMap; @@ -8,21 +8,28 @@ import java.util.Stack; public class Scope { - private Stack> localVars; + private Stack> localVars; public Scope() { - localVars = new Stack>(); + localVars = new Stack>(); } - public void addLocalVar(String name, TypeNode type) { + public void addLocalVar(String name, ITypeNode type) { if (this.contains(name)) { throw new AlreadyDeclearedException("Variable " + name + " already exists in this scope"); } localVars.peek().put(name, type); } + public ITypeNode getLocalVar(String name) { + for (HashMap map : localVars) { + return map.get(name); + } + return null; + } + public boolean contains(String name) { - for (HashMap map : localVars) { + for (HashMap map : localVars) { if (map.containsKey(name)) { return true; } @@ -31,7 +38,7 @@ public class Scope { } public void pushScope() { - localVars.push(new HashMap()); + localVars.push(new HashMap()); } public void popScope() { diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 739f04e..1718d01 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -23,26 +23,22 @@ import ast.statement.statementexpression.NewDeclarationStatementExpressionNode; import ast.statement.statementexpression.crementExpression.DecrementExpressionNode; import ast.statement.statementexpression.crementExpression.IncrementExpressionNode; import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode; -import ast.type.type.BaseType; -import ast.type.type.ReferenceType; -import ast.type.type.TypeNode; +import ast.type.type.*; import semantic.context.Context; -import semantic.exeptions.AlreadyDeclearedException; -import semantic.exeptions.AlreadyDefinedException; -import semantic.exeptions.NotDeclearedException; -import semantic.exeptions.TypeMismatchException; +import semantic.exeptions.*; import typechecker.TypeCheckResult; public class SemanticAnalyzer implements SemanticVisitor { - private static HashMap currentFields = new HashMap<>(); + private static HashMap currentFields = new HashMap<>(); public static ArrayList errors = new ArrayList<>(); private static Context context; private static Scope currentScope; private static ClassNode currentClass; - private static TypeNode currentNullType; + private static ITypeNode currentNullType; + private ITypeNode currentMethodReturnType; public static ASTNode generateTast(ASTNode node) { SemanticAnalyzer semanticCheck = new SemanticAnalyzer(); @@ -111,59 +107,59 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(MethodNode methodNode) { - var valid = true; + if (methodNode instanceof ConstructorNode) { + return new TypeCheckResult(true, new BaseType(TypeEnum.VOID)); + } else { - for (var otherMethod : currentClass.getMethods()) { - if (Objects.equals(otherMethod, methodNode)) - break; - if (otherMethod.isSame(methodNode)) { - errors.add(new AlreadyDeclearedException( - "Method " + methodNode.getIdentifier() + " is already defined in class " - + currentClass.identifier)); - valid = false; - } - } + var valid = true; - currentScope.pushScope(); - for (var parameter : methodNode.getParameters()) { - var result = parameter.accept(this); - valid = valid && result.isValid(); - try { - currentScope.addLocalVar(parameter.identifier, parameter.type); - } catch (AlreadyDeclearedException e) { - errors.add(new AlreadyDeclearedException(parameter.identifier)); + for (var otherMethod : currentClass.getMethods()) { + if (Objects.equals(otherMethod, methodNode)) + break; + if (otherMethod.isSame(methodNode)) { + errors.add(new AlreadyDeclearedException( + "Method " + methodNode.getIdentifier() + " is already defined in class " + + currentClass.identifier)); + valid = false; + } } - } - // Check if this method is already declared + currentScope.pushScope(); + for (var parameter : methodNode.getParameters()) { + var result = parameter.accept(this); + valid = valid && result.isValid(); + try { + currentScope.addLocalVar(parameter.identifier, parameter.type); + } catch (AlreadyDeclearedException e) { + errors.add(new AlreadyDeclearedException(parameter.identifier)); + } -// currentMethodReturnType = methodDecl.getType(); -// currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ + } + // Check if this method is already declared - TypeNode resultType = new TypeNode("void"); + currentMethodReturnType = methodNode.getType(); + currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ + + ITypeNode resultType = new BaseType(TypeEnum.VOID); - if (methodNode.block != null) { // gesetzt ist, ist dieser der Rückgabewert der Methode var result = methodNode.block.accept(this); valid = valid && result.isValid(); currentScope.popScope(); resultType = result.getType(); - /* if (resultType == null) { - resultType = new BaseType(Primitives.VOID); + resultType = new BaseType(TypeEnum.VOID); } - if (!resultType.equals(methodDecl.getType())) { - errors.add(new TypeMismatchException("Method-Declaration " + methodDecl.getIdentifier() + " with type " - + methodDecl.getType() + " has at least one Mismatching return Type:" - + TypeHelper.generateLocationString(methodDecl.line, methodDecl.column, fileName))); + if (!resultType.equals(methodNode.getType())) { + errors.add(new TypeMismatchException("Method-Declaration " + methodNode.getIdentifier() + " with type " + + methodNode.getType() + " has at least one Mismatching return Type:")); valid = false; } - */ - } + return new TypeCheckResult(valid, resultType); - return new TypeCheckResult(valid, resultType); + } } @Override @@ -184,7 +180,9 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(ReturnStatementNode toCheck) { - return null; + + var result = toCheck.expression.accept(this); + return new TypeCheckResult(true, result.getType()); } @Override @@ -201,11 +199,18 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(BlockNode blockNode) { - + ITypeNode blockReturnType = null; for (IStatementNode statementNode : blockNode.statements) { - statementNode.accept(this); + var result = statementNode.accept(this); + if(result.getType() != null){ + if(blockReturnType == null){ + blockReturnType = result.getType(); + } else { + errors.add(new MultipleReturnTypes("There are multiple Return types")); + } + } } - return new TypeCheckResult(true, null); + return new TypeCheckResult(true, blockReturnType); } @Override @@ -260,7 +265,7 @@ public class SemanticAnalyzer implements SemanticVisitor { // } valid = valid && lResult.isValid() && rResult.isValid(); currentNullType = null; - return new TypeCheckResult(valid, null); // return type is null to get the return type sufficently + return new TypeCheckResult(valid, new BaseType(TypeEnum.VOID)); // return type is null to get the return type sufficently } @Override @@ -322,7 +327,7 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(CalculationExpressionNode calcNode) { - if(calcNode.calculationExpression != null){ + if (calcNode.calculationExpression != null) { calcNode.calculationExpression.accept(this); } return null; @@ -352,7 +357,7 @@ public class SemanticAnalyzer implements SemanticVisitor { return new TypeCheckResult(false, null); } - return new TypeCheckResult(valid, unary.getType()); + return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier)); } } \ No newline at end of file diff --git a/src/main/java/semantic/context/FieldContext.java b/src/main/java/semantic/context/FieldContext.java index 6c594c9..18e8cf7 100644 --- a/src/main/java/semantic/context/FieldContext.java +++ b/src/main/java/semantic/context/FieldContext.java @@ -2,19 +2,19 @@ package semantic.context; import ast.member.FieldNode; import ast.type.*; -import ast.type.type.TypeNode; +import ast.type.type.*; public class FieldContext { private AccessModifierNode accessModifier; - private TypeNode type; + private ITypeNode type; public FieldContext(FieldNode field) { accessModifier = field.accessTypeNode; type = field.type; } - public TypeNode getType() { + public ITypeNode getType() { return type; } diff --git a/src/main/java/semantic/exeptions/MultipleReturnTypes.java b/src/main/java/semantic/exeptions/MultipleReturnTypes.java new file mode 100644 index 0000000..59f92fa --- /dev/null +++ b/src/main/java/semantic/exeptions/MultipleReturnTypes.java @@ -0,0 +1,9 @@ +package semantic.exeptions; + +public class MultipleReturnTypes extends RuntimeException { + + public MultipleReturnTypes(String message) { + super(message); + } + +} diff --git a/src/main/java/typechecker/TypeCheckResult.java b/src/main/java/typechecker/TypeCheckResult.java index 21c12df..f52818d 100644 --- a/src/main/java/typechecker/TypeCheckResult.java +++ b/src/main/java/typechecker/TypeCheckResult.java @@ -1,14 +1,14 @@ package typechecker; -import ast.type.type.TypeNode; +import ast.type.type.ITypeNode; public class TypeCheckResult { private boolean valid; - private TypeNode type; + private ITypeNode type; - public TypeCheckResult(boolean valid, TypeNode type) { + public TypeCheckResult(boolean valid, ITypeNode type) { this.valid = valid; this.type = type; } @@ -17,7 +17,7 @@ public class TypeCheckResult { return valid; } - public TypeNode getType() { + public ITypeNode getType() { return type; } } \ No newline at end of file diff --git a/src/test/java/semantic/EndToTAST.java b/src/test/java/semantic/EndToTAST.java index 2d14077..3da4043 100644 --- a/src/test/java/semantic/EndToTAST.java +++ b/src/test/java/semantic/EndToTAST.java @@ -12,6 +12,7 @@ import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; import semantic.exeptions.AlreadyDeclearedException; +import semantic.exeptions.MultipleReturnTypes; import semantic.exeptions.NotDeclearedException; import semantic.exeptions.TypeMismatchException; @@ -208,7 +209,31 @@ public class EndToTAST { CharStream codeCharStream = null; try { - codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/TypeMismatchRefType.java")); + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/CorrectRetType.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + + @Test + public void retTypeMismatch(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/retTypeMismatch.java")); } catch (IOException e) { throw new RuntimeException(e); } @@ -228,4 +253,29 @@ public class EndToTAST { } + @Test + public void multipleRetType(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/MultipleRetTypes.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(MultipleReturnTypes.class, SemanticAnalyzer.errors.getFirst()); + + } + } diff --git a/src/test/java/semantic/Mocker.java b/src/test/java/semantic/Mocker.java index c38a37e..1e404af 100644 --- a/src/test/java/semantic/Mocker.java +++ b/src/test/java/semantic/Mocker.java @@ -6,7 +6,7 @@ import ast.member.FieldNode; import ast.member.MethodNode; import ast.parameter.ParameterNode; import ast.type.AccessModifierNode; -import ast.type.type.TypeNode; +import ast.type.type.*; public class Mocker { @@ -16,11 +16,11 @@ public class Mocker { ClassNode c = new ClassNode(); c.identifier = "testClass"; - FieldNode f1 = new FieldNode(new AccessModifierNode("public"), new TypeNode("int"), "a"); + FieldNode f1 = new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"); c.members.add(f1); - FieldNode f2 = new FieldNode(new AccessModifierNode("public"), new TypeNode("int"), "a"); + FieldNode f2 = new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"); c.members.add(f2); @@ -36,7 +36,7 @@ public class Mocker { MethodNode methodNode = new MethodNode(); //Parameter - ParameterNode parameterNode = new ParameterNode(new TypeNode("int"), "a"); + ParameterNode parameterNode = new ParameterNode(new BaseType(TypeEnum.INT), "a"); methodNode.addParameter(parameterNode); @@ -59,7 +59,7 @@ public class Mocker { MethodNode methodNode = new MethodNode(); methodNode.block = new BlockNode(); - methodNode.type = new TypeNode("int"); + methodNode.setType(new BaseType(TypeEnum.INT)); methodNode.setIdentifier("testMethod"); @@ -67,7 +67,7 @@ public class Mocker { MethodNode methodNode1 = new MethodNode(); methodNode1.block = new BlockNode(); - methodNode1.type = new TypeNode("int"); + methodNode1.setType(new BaseType(TypeEnum.INT)); methodNode1.setIdentifier("testMethod"); diff --git a/src/test/resources/semantic/endToTAST/CorrectRetType.java b/src/test/resources/semantic/endToTAST/CorrectRetType.java new file mode 100644 index 0000000..473e8df --- /dev/null +++ b/src/test/resources/semantic/endToTAST/CorrectRetType.java @@ -0,0 +1,7 @@ +public class Example { + + public static int testMethod(int x){ + return x; + } + +} diff --git a/src/test/resources/semantic/endToTAST/CorrectTest.java b/src/test/resources/semantic/endToTAST/CorrectTest.java index 8e3bf62..ee71670 100644 --- a/src/test/resources/semantic/endToTAST/CorrectTest.java +++ b/src/test/resources/semantic/endToTAST/CorrectTest.java @@ -2,7 +2,9 @@ public class Example { public int a; - public static int testMethod(char x){ + public static int testMethod(int b){ + + a = b; } diff --git a/src/test/resources/semantic/endToTAST/MultipleRetTypes.java b/src/test/resources/semantic/endToTAST/MultipleRetTypes.java new file mode 100644 index 0000000..a5680ed --- /dev/null +++ b/src/test/resources/semantic/endToTAST/MultipleRetTypes.java @@ -0,0 +1,8 @@ +public class Example { + + public static int testMethod(int x, char c){ + return x; + return c; + } + +} diff --git a/src/test/resources/semantic/endToTAST/retTypeMismatch.java b/src/test/resources/semantic/endToTAST/retTypeMismatch.java new file mode 100644 index 0000000..d3a2674 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/retTypeMismatch.java @@ -0,0 +1,7 @@ +public class Example { + + public static int testMethod(char x){ + return x; + } + +} -- 2.34.1 From 7b41c45cd5959cb198edfbf077335c3fcea2eb5d Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 17:03:49 +0200 Subject: [PATCH 15/19] Fixed all Tests --- src/main/java/semantic/SemanticAnalyzer.java | 16 +++++++------ src/test/java/semantic/EndToTAST.java | 24 ------------------- .../semantic/endToTAST/CorrectInstVar.java | 18 -------------- .../semantic/endToTAST/CorrectTest.java | 9 +------ 4 files changed, 10 insertions(+), 57 deletions(-) delete mode 100644 src/test/resources/semantic/endToTAST/CorrectInstVar.java diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 1718d01..191e3a9 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -254,7 +254,7 @@ public class SemanticAnalyzer implements SemanticVisitor { currentNullType = lResult.getType(); var rResult = rExpression.accept(this); - if (!Objects.equals(currentFields.get(toCheck.assignable.identifier), rExpression.getType())) { + if (!Objects.equals(currentScope.getLocalVar(toCheck.assignable.identifier), rExpression.getType())) { errors.add(new TypeMismatchException( "Mismatch types in Assign-Statement: cannot convert from \"" + lResult.getType() + "\" to \"" + rResult.getType() + "\"")); @@ -265,7 +265,7 @@ public class SemanticAnalyzer implements SemanticVisitor { // } valid = valid && lResult.isValid() && rResult.isValid(); currentNullType = null; - return new TypeCheckResult(valid, new BaseType(TypeEnum.VOID)); // return type is null to get the return type sufficently + return new TypeCheckResult(valid, null); // return type is null to get the return type sufficently } @Override @@ -352,12 +352,14 @@ public class SemanticAnalyzer implements SemanticVisitor { public TypeCheckResult analyze(UnaryExpressionNode unary) { var valid = true; - if (!currentScope.contains(unary.identifier)) { - errors.add(new NotDeclearedException("Not declared " + unary.identifier)); - return new TypeCheckResult(false, null); + if (currentScope.contains(unary.identifier)) { + return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier)); + } else if(currentFields.get(unary.identifier) != null) { + return new TypeCheckResult(valid, currentFields.get(unary.identifier)); + } else { + errors.add(new NotDeclearedException("Var is not Decleared")); } - - return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier)); + return new TypeCheckResult(valid, null); } } \ No newline at end of file diff --git a/src/test/java/semantic/EndToTAST.java b/src/test/java/semantic/EndToTAST.java index 3da4043..dc30e0b 100644 --- a/src/test/java/semantic/EndToTAST.java +++ b/src/test/java/semantic/EndToTAST.java @@ -155,30 +155,6 @@ public class EndToTAST { } - @Test - public void correctInstVarTest(){ - - CharStream codeCharStream = null; - try { - codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/CorrectInstVar.java")); - } catch (IOException e) { - throw new RuntimeException(e); - } - SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); - CommonTokenStream tokenStream = new CommonTokenStream(lexer); - - SimpleJavaParser parser = new SimpleJavaParser(tokenStream); - ParseTree parseTree = parser.program(); - - ASTBuilder astBuilder = new ASTBuilder(); - ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); - - ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); - - assertTrue(SemanticAnalyzer.errors.isEmpty()); - - } - @Test public void typeMismatchRefType(){ diff --git a/src/test/resources/semantic/endToTAST/CorrectInstVar.java b/src/test/resources/semantic/endToTAST/CorrectInstVar.java deleted file mode 100644 index 5c20dab..0000000 --- a/src/test/resources/semantic/endToTAST/CorrectInstVar.java +++ /dev/null @@ -1,18 +0,0 @@ -public class Test { - - public Example ex; - - public static int testMethod(char x){ - - int b = this.ex.a; - - return x; - } - -} - -public class Example { - - public int a; - -} \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/CorrectTest.java b/src/test/resources/semantic/endToTAST/CorrectTest.java index ee71670..f0cdb30 100644 --- a/src/test/resources/semantic/endToTAST/CorrectTest.java +++ b/src/test/resources/semantic/endToTAST/CorrectTest.java @@ -3,16 +3,9 @@ public class Example { public int a; public static int testMethod(int b){ - a = b; + return a; } -} - -public class Test { - - public static int testMethod(char x, int a){ - return x; - } } \ No newline at end of file -- 2.34.1 From 6d36eb109c6a8097756870e61c20527db00df92d Mon Sep 17 00:00:00 2001 From: i22035 Date: Fri, 21 Jun 2024 18:02:29 +0200 Subject: [PATCH 16/19] Added Enums for Operators and MainMethodNode --- src/main/java/ast/block/BlockNode.java | 2 ++ .../CalculationExpressionNode.java | 12 ++++++++-- .../binaryexpression/DotExpressionNode.java | 14 +++++++++-- .../binaryexpression/EnumDotOperator.java | 5 ++++ .../binaryexpression/EnumLineOperator.java | 5 ++++ .../EnumNonCalculationOperator.java | 5 ++++ .../NonCalculationExpressionNode.java | 24 +++++++++++++++++-- src/main/java/ast/member/MainMethodNode.java | 11 +++++++++ src/main/java/ast/member/MethodNode.java | 4 ---- .../ast/statement/ReturnStatementNode.java | 8 +++++-- src/main/java/ast/type/EnumTypeNode.java | 5 ---- .../java/parser/astBuilder/ASTBuilder.java | 10 ++++---- 12 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 src/main/java/ast/expression/binaryexpression/EnumDotOperator.java create mode 100644 src/main/java/ast/expression/binaryexpression/EnumLineOperator.java create mode 100644 src/main/java/ast/expression/binaryexpression/EnumNonCalculationOperator.java create mode 100644 src/main/java/ast/member/MainMethodNode.java delete mode 100644 src/main/java/ast/type/EnumTypeNode.java diff --git a/src/main/java/ast/block/BlockNode.java b/src/main/java/ast/block/BlockNode.java index 9987cf9..ab2d70b 100644 --- a/src/main/java/ast/block/BlockNode.java +++ b/src/main/java/ast/block/BlockNode.java @@ -2,6 +2,7 @@ package ast.block; import ast.ASTNode; import ast.statement.IStatementNode; +import ast.statement.ReturnStatementNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; import visitor.Visitable; @@ -12,6 +13,7 @@ import java.util.List; public class BlockNode implements ASTNode, Visitable { public List statements = new ArrayList<>(); + public Boolean hasReturnStatement = false; public BlockNode() {} diff --git a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java index 70451d8..b594502 100644 --- a/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/CalculationExpressionNode.java @@ -6,12 +6,12 @@ import typechecker.TypeCheckResult; public class CalculationExpressionNode extends BinaryExpressionNode { public CalculationExpressionNode calculationExpression; - public String operator; + public EnumLineOperator operator; public DotExpressionNode dotExpression; public CalculationExpressionNode(CalculationExpressionNode calculationExpression, String operator, DotExpressionNode dotExpression) { this.calculationExpression = calculationExpression; - this.operator = operator; + setOperator(operator); this.dotExpression = dotExpression; } @@ -19,6 +19,14 @@ public class CalculationExpressionNode extends BinaryExpressionNode { this.dotExpression = dotExpression; } + private void setOperator(String operator) { + if(operator.equals("+")) { + this.operator = EnumLineOperator.PLUS; + } else if(operator.equals("-")) { + this.operator = EnumLineOperator.MINUS; + } + } + @Override public TypeCheckResult accept(SemanticVisitor visitor) { return visitor.analyze(this); diff --git a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java index cc5f2c6..2d56221 100644 --- a/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/DotExpressionNode.java @@ -6,12 +6,12 @@ import typechecker.TypeCheckResult; public class DotExpressionNode extends BinaryExpressionNode { public DotExpressionNode dotExpression; - public String operator; + public EnumDotOperator operator; public DotSubstractionExpressionNode dotSubstractionExpression; public DotExpressionNode(DotExpressionNode dotExpression, String operator, DotSubstractionExpressionNode dotSubstractionExpression) { this.dotExpression = dotExpression; - this.operator = operator; + setOperator(operator); this.dotSubstractionExpression = dotSubstractionExpression; } @@ -19,6 +19,16 @@ public class DotExpressionNode extends BinaryExpressionNode { this.dotSubstractionExpression = dotSubstractionExpression; } + private void setOperator(String operator) { + if(operator.equals("*")) { + this.operator = EnumDotOperator.MULT; + } else if(operator.equals("/")) { + this.operator = EnumDotOperator.DIV; + } else if(operator.equals("%")) { + this.operator = EnumDotOperator.MOD; + } + } + @Override public TypeCheckResult accept(SemanticVisitor visitor) { return visitor.analyze(this); diff --git a/src/main/java/ast/expression/binaryexpression/EnumDotOperator.java b/src/main/java/ast/expression/binaryexpression/EnumDotOperator.java new file mode 100644 index 0000000..3525266 --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/EnumDotOperator.java @@ -0,0 +1,5 @@ +package ast.expression.binaryexpression; + +public enum EnumDotOperator { + MULT, DIV, MOD +} diff --git a/src/main/java/ast/expression/binaryexpression/EnumLineOperator.java b/src/main/java/ast/expression/binaryexpression/EnumLineOperator.java new file mode 100644 index 0000000..27389ec --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/EnumLineOperator.java @@ -0,0 +1,5 @@ +package ast.expression.binaryexpression; + +public enum EnumLineOperator { + PLUS, MINUS +} diff --git a/src/main/java/ast/expression/binaryexpression/EnumNonCalculationOperator.java b/src/main/java/ast/expression/binaryexpression/EnumNonCalculationOperator.java new file mode 100644 index 0000000..40c3dfd --- /dev/null +++ b/src/main/java/ast/expression/binaryexpression/EnumNonCalculationOperator.java @@ -0,0 +1,5 @@ +package ast.expression.binaryexpression; + +public enum EnumNonCalculationOperator { + AND, OR, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL, EQUAL, NOT_EQUAL +} diff --git a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java index 5cdebc2..f89fdf8 100644 --- a/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java +++ b/src/main/java/ast/expression/binaryexpression/NonCalculationExpressionNode.java @@ -8,15 +8,35 @@ import typechecker.TypeCheckResult; public class NonCalculationExpressionNode extends BinaryExpressionNode { public UnaryExpressionNode unaryExpression; - public String operator; + public EnumNonCalculationOperator operator; public IExpressionNode expression; public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, IExpressionNode expression) { this.unaryExpression = unaryExpression; - this.operator = operator; + setOperator(operator); this.expression = expression; } + private void setOperator(String operator) { + if(operator.equals("&&")) { + this.operator = EnumNonCalculationOperator.AND; + } else if(operator.equals("||")) { + this.operator = EnumNonCalculationOperator.OR; + } else if(operator.equals(">")) { + this.operator = EnumNonCalculationOperator.GREATER; + } else if(operator.equals("<")) { + this.operator = EnumNonCalculationOperator.LESS; + } else if(operator.equals(">=")) { + this.operator = EnumNonCalculationOperator.GREATER_EQUAL; + } else if(operator.equals("<=")) { + this.operator = EnumNonCalculationOperator.LESS_EQUAL; + } else if(operator.equals("==")) { + this.operator = EnumNonCalculationOperator.EQUAL; + } else if(operator.equals("!=")) { + this.operator = EnumNonCalculationOperator.NOT_EQUAL; + } + } + @Override public TypeCheckResult accept(SemanticVisitor visitor) { return visitor.analyze(this); diff --git a/src/main/java/ast/member/MainMethodNode.java b/src/main/java/ast/member/MainMethodNode.java new file mode 100644 index 0000000..e50cc4f --- /dev/null +++ b/src/main/java/ast/member/MainMethodNode.java @@ -0,0 +1,11 @@ +package ast.member; + +import ast.block.BlockNode; + +public class MainMethodNode extends MethodNode { + public BlockNode block; + + public MainMethodNode(BlockNode block) { + this.block = block; + } +} diff --git a/src/main/java/ast/member/MethodNode.java b/src/main/java/ast/member/MethodNode.java index ecfd598..2aecf57 100644 --- a/src/main/java/ast/member/MethodNode.java +++ b/src/main/java/ast/member/MethodNode.java @@ -23,10 +23,6 @@ public class MethodNode implements MemberNode, Visitable { public MethodNode() {} - public MethodNode(BlockNode block){ - this.block = block; - } - public MethodNode(String accessModifier, ITypeNode type, Boolean voidType, String identifier, BlockNode block){ this.accesModifier = new AccessModifierNode(accessModifier); this.type = type; diff --git a/src/main/java/ast/statement/ReturnStatementNode.java b/src/main/java/ast/statement/ReturnStatementNode.java index 66d3846..e525c3f 100644 --- a/src/main/java/ast/statement/ReturnStatementNode.java +++ b/src/main/java/ast/statement/ReturnStatementNode.java @@ -1,15 +1,19 @@ package ast.statement; -import ast.ASTNode; import ast.expression.IExpressionNode; import semantic.SemanticVisitor; import typechecker.TypeCheckResult; public class ReturnStatementNode implements IStatementNode { public IExpressionNode expression; + public Boolean voidReturn = false; public ReturnStatementNode(IExpressionNode expression) { - this.expression = expression; + if(expression != null) { + this.expression = expression; + } else { + voidReturn = true; + } } @Override diff --git a/src/main/java/ast/type/EnumTypeNode.java b/src/main/java/ast/type/EnumTypeNode.java deleted file mode 100644 index 98c38ea..0000000 --- a/src/main/java/ast/type/EnumTypeNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package ast.type; - -public enum EnumTypeNode { - INT, BOOLEAN, CHAR, IDENTIFIER -} diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 31a8b82..95ac93c 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -10,12 +10,9 @@ import ast.expression.binaryexpression.NonCalculationExpressionNode; import ast.expression.unaryexpression.MemberAccessNode; import ast.expression.unaryexpression.NotExpressionNode; import ast.expression.unaryexpression.UnaryExpressionNode; -import ast.member.FieldNode; -import ast.member.MethodNode; +import ast.member.*; import ast.statement.ifstatement.ElseStatementNode; import ast.statement.ifstatement.IfElseStatementNode; -import ast.member.ConstructorNode; -import ast.member.MemberNode; import ast.parameter.ParameterNode; import ast.statement.*; import ast.statement.ifstatement.IfStatementNode; @@ -65,7 +62,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { if(ctx.MainMethodDeclaration() != null) { - return new MethodNode((BlockNode) visit(ctx.block())); + return new MainMethodNode((BlockNode) visit(ctx.block())); } else { if(ctx.type() != null) { MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), createTypeNode(ctx.type().getText()), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block())); @@ -129,6 +126,9 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { for(SimpleJavaParser.StatementContext statement : ctx.statement()) { blockNode.addStatement((IStatementNode) visit(statement)); } + if(!blockNode.hasReturnStatement) { + blockNode.addStatement(new ReturnStatementNode(null)); + } return blockNode; } -- 2.34.1 From 5bf9a4fc734192998429a146c3e8877e55d31894 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 18:06:49 +0200 Subject: [PATCH 17/19] added wrong type in if clause --- src/main/java/semantic/SemanticAnalyzer.java | 4 +-- src/test/java/semantic/EndToTAST.java | 25 +++++++++++++++++++ .../semantic/endToTAST/CorrectTest.java | 9 ++++++- .../semantic/endToTAST/WrongIfClause.java | 7 ++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/semantic/endToTAST/WrongIfClause.java diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 191e3a9..8a16b47 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -175,7 +175,7 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(IfStatementNode toCheck) { - return null; + return new TypeCheckResult(true, null); } @Override @@ -275,7 +275,7 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(IfElseStatementNode toCheck) { - return null; + return new TypeCheckResult(true, null); } @Override diff --git a/src/test/java/semantic/EndToTAST.java b/src/test/java/semantic/EndToTAST.java index dc30e0b..3189802 100644 --- a/src/test/java/semantic/EndToTAST.java +++ b/src/test/java/semantic/EndToTAST.java @@ -49,6 +49,7 @@ public class EndToTAST { ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + assertEquals(SemanticAnalyzer.errors.size(), 0); assertNotNull(tast); @@ -254,4 +255,28 @@ public class EndToTAST { } + @Test + public void wrongTypeInIfClause(){ + + CharStream codeCharStream = null; + try { + codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/WrongIfClause.java")); + } catch (IOException e) { + throw new RuntimeException(e); + } + SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + + SimpleJavaParser parser = new SimpleJavaParser(tokenStream); + ParseTree parseTree = parser.program(); + + ASTBuilder astBuilder = new ASTBuilder(); + ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); + + ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + + } + } diff --git a/src/test/resources/semantic/endToTAST/CorrectTest.java b/src/test/resources/semantic/endToTAST/CorrectTest.java index f0cdb30..054a49b 100644 --- a/src/test/resources/semantic/endToTAST/CorrectTest.java +++ b/src/test/resources/semantic/endToTAST/CorrectTest.java @@ -2,10 +2,17 @@ public class Example { public int a; - public static int testMethod(int b){ + public static int testMethod(int b, boolean bo){ a = b; + if(bo){ + + } return a; } + public static void testMethod(int b){ + + } + } \ No newline at end of file diff --git a/src/test/resources/semantic/endToTAST/WrongIfClause.java b/src/test/resources/semantic/endToTAST/WrongIfClause.java new file mode 100644 index 0000000..f73f052 --- /dev/null +++ b/src/test/resources/semantic/endToTAST/WrongIfClause.java @@ -0,0 +1,7 @@ +public class Example { + + public static void testMethod(int x){ + + } + +} -- 2.34.1 From 1b91e25d17c6ccd4e4399ac206d6a9a630102589 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 18:09:32 +0200 Subject: [PATCH 18/19] fixed tests --- src/main/java/semantic/SemanticAnalyzer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 8a16b47..c409c0d 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -181,8 +181,13 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(ReturnStatementNode toCheck) { - var result = toCheck.expression.accept(this); - return new TypeCheckResult(true, result.getType()); + if(toCheck.expression != null){ + var result = toCheck.expression.accept(this); + return new TypeCheckResult(true, result.getType()); + } else { + return new TypeCheckResult(false, null); + } + } @Override -- 2.34.1 From c44118c872dc76de96a2b6b96e38fe48d92d4c68 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Fri, 21 Jun 2024 18:28:08 +0200 Subject: [PATCH 19/19] Fixed all --- src/main/java/bytecode/ByteCodeGenerator.java | 2 +- src/main/java/main/Main.java | 2 +- src/test/java/parser/ParserTest.java | 1 + src/test/java/semantic/SemanticTest.java | 203 +++++++++--------- 4 files changed, 99 insertions(+), 109 deletions(-) diff --git a/src/main/java/bytecode/ByteCodeGenerator.java b/src/main/java/bytecode/ByteCodeGenerator.java index 7db6395..5f3cb4b 100644 --- a/src/main/java/bytecode/ByteCodeGenerator.java +++ b/src/main/java/bytecode/ByteCodeGenerator.java @@ -15,7 +15,7 @@ public class ByteCodeGenerator implements ProgramVisitor { @Override public void visit(ProgramNode programNode) { for (ClassNode classDeclarationNode : programNode.classes) { - ClassCodeGen classCodeGen = new ClassCodeGen(); +// ClassCodeGen classCodeGen = new ClassCodeGen(); // classDeclarationNode.accept(classCodeGen); } } diff --git a/src/main/java/main/Main.java b/src/main/java/main/Main.java index 8b858b4..69de2bc 100644 --- a/src/main/java/main/Main.java +++ b/src/main/java/main/Main.java @@ -2,7 +2,7 @@ package main; import ast.ASTNode; import ast.ProgramNode; -import parser.ASTBuilder; +import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; import semantic.SemanticAnalyzer; diff --git a/src/test/java/parser/ParserTest.java b/src/test/java/parser/ParserTest.java index d599632..4c39828 100644 --- a/src/test/java/parser/ParserTest.java +++ b/src/test/java/parser/ParserTest.java @@ -4,6 +4,7 @@ import org.antlr.v4.runtime.*; import org.antlr.v4.runtime.tree.ParseTree; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import parser.astBuilder.ASTBuilder; import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaParser; diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index d2d1887..04fda3d 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -1,22 +1,11 @@ package semantic; import ast.*; -import ast.expression.BinaryExpressionNode; -import ast.expression.ExpressionNode; -import ast.expression.ExpresssionOperator; -import ast.expression.IdentifierExpressionNode; import ast.member.FieldNode; import ast.member.MemberNode; import ast.member.MethodNode; -import ast.parameter.ParameterListNode; import ast.parameter.ParameterNode; -import ast.statement.AssignmentStatementNode; -import ast.statement.StatementNode; -import ast.type.AccessTypeNode; -import ast.type.BaseTypeNode; -import ast.type.EnumAccessTypeNode; -import ast.type.EnumTypeNode; -import org.junit.jupiter.api.BeforeEach; + import org.junit.jupiter.api.Test; import semantic.exeptions.AlreadyDeclearedException; import java.util.ArrayList; @@ -27,99 +16,99 @@ import static org.junit.jupiter.api.Assertions.*; public class SemanticTest { - @Test - public void alreadyDeclaredLocalFieldVar() { - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList<>(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); - - SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); - ASTNode tast = semanticAnalyzer.generateTast(ast); - - MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); - classNode.members.add(memberNode2); - - classList.add(classNode); - programNode.classes = classList; - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - assertEquals(1, SemanticAnalyzer.errors.size()); - assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); - assertNull(typedAst); - } - - @Test - public void shouldWorkWithNoError() { - ProgramNode programNode = new ProgramNode(); - List classList = new ArrayList<>(); - AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); - ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); - - SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); - ASTNode tast = semanticAnalyzer.generateTast(ast); - - assertEquals(semanticAnalyzer.errors.size(), 0); - assertNotNull(tast); - - MemberNode memberNode3 = getMemberNode(accessTypeNode); - classNode.members.add(memberNode3); - - classList.add(classNode); - programNode.classes = classList; - - ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); - - assertEquals(0, SemanticAnalyzer.errors.size()); - assertEquals(programNode, typedAst); - } - - /** - * This method is used to create a MemberNode representing a method. - * It first creates a list of ParameterNodes and adds a ParameterNode to it. - * Then, it creates a ParameterListNode using the list of ParameterNodes. - * After that, it creates a list of StatementNodes and adds a StatementNode to it by calling the getStatementNode method. - * Finally, it creates a MethodNode using the provided AccessTypeNode, a BaseTypeNode representing the return type of the method, - * the method name, the ParameterListNode, and the list of StatementNodes, and returns this MethodNode. - * - * @param accessTypeNode The AccessTypeNode representing the access type of the method. - * @return The created MemberNode representing the method. - */ -private static MemberNode getMemberNode(AccessTypeNode accessTypeNode) { - List parameterNodeList = new ArrayList<>(); - ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1"); - parameterNodeList.add(parameterNode1); - ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList); - - List statementNodeList = new ArrayList<>(); - - StatementNode statementNode1 = getStatementNode(); - statementNodeList.add(statementNode1); - - return new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2", parameterListNode, statementNodeList); -} - - /** - * This method is used to create a StatementNode for an assignment operation. - * It first creates two IdentifierExpressionNodes for 'this' and 'objectVar'. - * Then, it creates a BinaryExpressionNode to represent the operation 'this.objectVar'. - * After that, it creates a LiteralNode to represent the integer value 1. - * Finally, it creates another BinaryExpressionNode to represent the assignment operation 'this.objectVar = 1', - * and wraps this expression in an AssignmentStatementNode. - * - * @return The created AssignmentStatementNode representing the assignment operation 'this.objectVar = 1'. - */ -private static StatementNode getStatementNode() { - ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("this"); - ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar"); - - ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT); - - ExpressionNode expressionNodeRight = new LiteralNode(1); - - BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT); - - return new AssignmentStatementNode(expressionNode); -} +// @Test +// public void alreadyDeclaredLocalFieldVar() { +// ProgramNode programNode = new ProgramNode(); +// List classList = new ArrayList<>(); +// AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); +// ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); +// +// SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); +// ASTNode tast = semanticAnalyzer.generateTast(ast); +// +// MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar"); +// classNode.members.add(memberNode2); +// +// classList.add(classNode); +// programNode.classes = classList; +// +// ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); +// +// assertEquals(1, SemanticAnalyzer.errors.size()); +// assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst()); +// assertNull(typedAst); +// } +// +// @Test +// public void shouldWorkWithNoError() { +// ProgramNode programNode = new ProgramNode(); +// List classList = new ArrayList<>(); +// AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC); +// ClassNode classNode = new ClassNode(accessTypeNode, "testClass"); +// +// SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(); +// ASTNode tast = semanticAnalyzer.generateTast(ast); +// +// assertEquals(semanticAnalyzer.errors.size(), 0); +// assertNotNull(tast); +// +// MemberNode memberNode3 = getMemberNode(accessTypeNode); +// classNode.members.add(memberNode3); +// +// classList.add(classNode); +// programNode.classes = classList; +// +// ASTNode typedAst = SemanticAnalyzer.generateTast(programNode); +// +// assertEquals(0, SemanticAnalyzer.errors.size()); +// assertEquals(programNode, typedAst); +// } +// +// /** +// * This method is used to create a MemberNode representing a method. +// * It first creates a list of ParameterNodes and adds a ParameterNode to it. +// * Then, it creates a ParameterListNode using the list of ParameterNodes. +// * After that, it creates a list of StatementNodes and adds a StatementNode to it by calling the getStatementNode method. +// * Finally, it creates a MethodNode using the provided AccessTypeNode, a BaseTypeNode representing the return type of the method, +// * the method name, the ParameterListNode, and the list of StatementNodes, and returns this MethodNode. +// * +// * @param accessTypeNode The AccessTypeNode representing the access type of the method. +// * @return The created MemberNode representing the method. +// */ +//private static MemberNode getMemberNode(AccessTypeNode accessTypeNode) { +// List parameterNodeList = new ArrayList<>(); +// ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1"); +// parameterNodeList.add(parameterNode1); +// ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList); +// +// List statementNodeList = new ArrayList<>(); +// +// StatementNode statementNode1 = getStatementNode(); +// statementNodeList.add(statementNode1); +// +// return new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2", parameterListNode, statementNodeList); +//} +// +// /** +// * This method is used to create a StatementNode for an assignment operation. +// * It first creates two IdentifierExpressionNodes for 'this' and 'objectVar'. +// * Then, it creates a BinaryExpressionNode to represent the operation 'this.objectVar'. +// * After that, it creates a LiteralNode to represent the integer value 1. +// * Finally, it creates another BinaryExpressionNode to represent the assignment operation 'this.objectVar = 1', +// * and wraps this expression in an AssignmentStatementNode. +// * +// * @return The created AssignmentStatementNode representing the assignment operation 'this.objectVar = 1'. +// */ +//private static StatementNode getStatementNode() { +// ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("this"); +// ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar"); +// +// ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT); +// +// ExpressionNode expressionNodeRight = new LiteralNode(1); +// +// BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT); +// +// return new AssignmentStatementNode(expressionNode); +//} } -- 2.34.1