Compare commits

..

6 Commits

Author SHA1 Message Date
bf7a642233 Added Expression Visitors
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-06-16 13:01:26 +02:00
3639b2a4f8 Added new Parser Visitors
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-06-15 16:59:35 +02:00
330b92a79f Deleted old grammar
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-06-15 14:05:03 +02:00
8094a93582 Added new Grammar
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-06-15 13:15:55 +02:00
0271313a05 Merge branch 'johns-branch' of https://gitea.hb.dhbw-stuttgart.de/i22005/NichtHaskell2.0 into parser 2024-06-15 12:49:47 +02:00
1c77a99f54 Merge pull request 'johns-branch' (#9) from johns-branch into main
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Reviewed-on: #9
Reviewed-by: i22007 <i22007@hb.dhbw-stuttgart.de>
2024-05-30 17:11:50 +00:00
89 changed files with 1175 additions and 4099 deletions

10
.idea/misc.xml generated
View File

@ -13,6 +13,16 @@
<option name="language" value="" />
<option name="generateVisitor" value="true" />
</PerGrammarGenerationSettings>
<PerGrammarGenerationSettings>
<option name="fileName" value="$PROJECT_DIR$/src/main/java/parser/grammar/SimpleJava.g4" />
<option name="autoGen" value="true" />
<option name="outputDir" value="C:\Users\Maxi\Documents\DHBW\Compilerbau\NichtHaskell2.0\src\main\java" />
<option name="libDir" value="" />
<option name="encoding" value="" />
<option name="pkg" value="parser.generated" />
<option name="language" value="" />
<option name="generateVisitor" value="true" />
</PerGrammarGenerationSettings>
</list>
</option>
</component>

View File

@ -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 {

View File

@ -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<ASTNode> getChildren();
}
public interface ASTNode { }

View File

@ -1,4 +0,0 @@
package ast;
public class BlockNode {
}

View File

@ -1,30 +1,30 @@
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 ast.type.AccessTypeNode;
import ast.type.EnumAccessTypeNode;
import java.util.ArrayList;
import java.util.List;
import bytecode.visitor.ClassVisitor;
import semantic.SemanticVisitor;
import typechecker.TypeCheckResult;
import visitor.Visitable;
import java.util.ArrayList;
import java.util.List;
public class ClassNode implements ASTNode, Visitable {
public AccessModifierNode accessType;
public String identifier;
public AccessTypeNode accessType;
public List<MemberNode> members = new ArrayList<>();
public boolean hasConstructor = false;
public boolean hasConstructor;
public ClassNode() {}
public ClassNode(AccessTypeNode 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) {
@ -36,8 +36,8 @@ public class ClassNode implements ASTNode, Visitable {
public void ensureConstructor(){
if(!hasConstructor) {
ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), identifier);
members.add(0,constructor);
ConstructorNode constructor = new ConstructorNode("public", identifier, );
members.addFirst(constructor);
}
}

View File

@ -0,0 +1,4 @@
package ast;
public class IdentifierNode {
}

View File

@ -1,13 +1,13 @@
package ast;
import java.util.ArrayList;
import java.util.List;
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 List<ClassNode> classes = new ArrayList<>();

View File

@ -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<StatementNode> statements = new ArrayList<>();
public BlockNode() {}
public void addStatement(StatementNode statement) {
statements.add(statement);
}
}

View File

@ -1,22 +0,0 @@
package ast.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);
}
}

View File

@ -1,25 +1,4 @@
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 {
public class ExpressionNode {
}

View File

@ -1,14 +0,0 @@
package ast.expression;
public enum ExpresssionOperator {
DOT, // . NICHT MEHR GEBRAUCHT
PLUS, // +
MINUS, // -
MULTIPLY, // *
DIVIDE, // /
NOT, // !
ASSIGNMENT, // = (NICHT MEHR GEBRAUCHT ??)
EQUALS, // ==
UNEQUALS, // !=
ERROR //TODO: Remove This
}

View File

@ -1,22 +0,0 @@
package ast.expression;
import ast.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);
}
}

View File

@ -1,24 +0,0 @@
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(){}
public InstVar(ExpressionNode expression, String identifier) {
this.identifier = identifier;
this.expression = expression;
}
@Override
public TypeCheckResult accept(SemanticVisitor visitor) {
return visitor.analyze(this);
}
}

View File

@ -1,31 +0,0 @@
package ast.expression;
import ast.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);
}
}

View File

@ -1,26 +0,0 @@
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;
}
}

View File

@ -1,22 +0,0 @@
package ast.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);
}
}

View File

@ -0,0 +1,4 @@
package ast.expression.binaryexpression;
public class BinaryExpression {
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<String> identifiers = new ArrayList<>();
public MemberAccessNode(Boolean thisExpr) {
this.thisExpr = thisExpr;
}
public void addIdentifier(String identifier) {
identifiers.add(identifier);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,12 +1,28 @@
package ast.member;
import ast.type.AccessTypeNode;
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 ConstructorNode(AccessTypeNode visibility, String name) {
super(visibility, name);
public AccessModifierNode accessType;
public String identifier;
public List<ParameterNode> parameters = new ArrayList<>();
public BlockNode body;
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

View File

@ -1,6 +1,6 @@
package ast.member;
import ast.type.AccessTypeNode;
import ast.type.AccessModifierNode;
import ast.type.TypeNode;
import bytecode.visitor.ClassVisitor;
import semantic.SemanticVisitor;
@ -8,13 +8,13 @@ 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;

View File

@ -1,9 +1,9 @@
package ast.member;
import ast.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 {}

View File

@ -1,20 +1,15 @@
package ast.member;
import ast.parameter.ParameterListNode;
import ast.statement.StatementNode;
import ast.type.AccessTypeNode;
import java.util.ArrayList;
import java.util.List;
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;
public class MethodNode implements MemberNode, Visitable {
public AccessTypeNode visibility;
public AccessModifierNode accessModifier;
public TypeNode type;
public String identifier;

View File

@ -1,16 +0,0 @@
package ast.parameter;
import ast.ASTNode;
import java.util.ArrayList;
import java.util.List;
public class ParameterListNode implements ASTNode {
public List<ParameterNode> parameters = new ArrayList<>();
public ParameterListNode() {}
public ParameterListNode(List<ParameterNode> parameters){
this.parameters = parameters;
}
}

View File

@ -4,10 +4,8 @@ import ast.ASTNode;
import ast.type.TypeNode;
public class ParameterNode implements ASTNode {
public TypeNode type;
public String identifier;
public ParameterNode(){}
TypeNode type;
String identifier;
public ParameterNode(TypeNode type, String identifier) {
this.type = type;

View File

@ -1,26 +0,0 @@
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 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);
}
}

View File

@ -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;
}
}

View File

@ -1,22 +0,0 @@
package ast.statement;
import ast.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);
}
}

View File

@ -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;
}
}

View File

@ -1,18 +1,16 @@
package ast.statement;
import ast.ASTNode;
import ast.expression.ExpressionNode;
import semantic.SemanticVisitor;
import typechecker.TypeCheckResult;
import ast.type.TypeNode;
public class ReturnStatementNode extends StatementNode {
import java.util.ArrayList;
import java.util.List;
public class ReturnStatementNode implements ASTNode {
public ExpressionNode expression;
public ReturnStatementNode(ExpressionNode expression) {
this.expression = expression;
}
@Override
public TypeCheckResult accept(SemanticVisitor visitor) {
return visitor.analyze(this);
}
}

View File

@ -1,22 +1,2 @@
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 {
package ast.statement;public class StatementNode {
}

View File

@ -1,25 +0,0 @@
package ast.statement;
import ast.expression.ExpressionNode;
import ast.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);
}
}

View File

@ -1,20 +1,15 @@
package ast.statement;
import ast.ASTNode;
import ast.block.BlockNode;
import ast.expression.ExpressionNode;
import semantic.SemanticVisitor;
import typechecker.TypeCheckResult;
public class WhileStatementNode extends StatementNode {
public ExpressionNode condition;
public StatementNode body;
public class WhileStatementNode implements ASTNode {
ExpressionNode expression;
BlockNode block;
public WhileStatementNode(ExpressionNode condition, StatementNode body) {
this.condition = condition;
this.body = body;
}
@Override
public TypeCheckResult accept(SemanticVisitor visitor) {
return visitor.analyze(this);
public WhileStatementNode(ExpressionNode expression, BlockNode block) {
this.expression = expression;
this.block = block;
}
}

View File

@ -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;
}
}

View File

@ -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<ElseStatementNode> elseStatements = new ArrayList<>();
public IfElseStatementNode(IfStatementNode ifStatement) {
this.ifStatement = ifStatement;
}
public void addElseStatement(ElseStatementNode elseStatement) {
elseStatements.add(elseStatement);
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,14 @@
package ast.statement.statementexpression;
import ast.ASTNode;
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;
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,5 @@
package ast.statement.statementexpression;
public class IncrementExpression {
}

View File

@ -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<ExpressionNode> expressions = new ArrayList<>();
public NewDeclarationStatementExpressionNode(String identifier) {
this.identifier = identifier;
}
public void addExpression(ExpressionNode expression) {
expressions.add(expression);
}
}

View File

@ -0,0 +1,5 @@
package ast.statement.statementexpression.crementExpression;
public enum CrementType {
PREFIX, SUFFIX
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<ExpressionNode> expressions = new ArrayList<>();
public ChainedMethodNode(String identifier) {
this.identifier = identifier;
}
public void addExpression(ExpressionNode expression) {
expressions.add(expression);
}
}

View File

@ -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<ChainedMethodNode> chainedMethods = new ArrayList<>();
String identifier;
List<ExpressionNode> 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);
}
}

View File

@ -0,0 +1,28 @@
package ast.statement.statementexpression.methodcallstatementnexpression;
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;
}
}

View File

@ -0,0 +1,28 @@
package ast.type;
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;
}
}
}

View File

@ -1,13 +0,0 @@
package ast.type;
import ast.ASTNode;
public class AccessTypeNode implements ASTNode {
public EnumAccessTypeNode enumAccessTypeNode;
public AccessTypeNode(){}
public AccessTypeNode(EnumAccessTypeNode enumAccessTypeNode) {
this.enumAccessTypeNode = enumAccessTypeNode;
}
}

View File

@ -1,28 +0,0 @@
package ast.type;
import ast.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;
}
}

View File

@ -0,0 +1,6 @@
package ast.type;
public enum EnumAccessModifierNode {
PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC
}

View File

@ -1,5 +0,0 @@
package ast.type;
public enum EnumAccessTypeNode {
PUBLIC, PRIVATE
}

View File

@ -1,5 +1,5 @@
package ast.type;
public enum EnumTypeNode {
INT, BOOLEAN, CHAR
INT, BOOLEAN, CHAR, IDENTIFIER
}

View File

@ -0,0 +1,5 @@
package ast.type;
public enum EnumValueNode {
INT_VALUE, BOOLEAN_VALUE, CHAR_VALUE, NULL_VALUE
}

View File

@ -1,36 +0,0 @@
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;
}
}

View File

@ -1,18 +1,25 @@
package ast.type;
import ast.ASTNode;
public class TypeNode {
EnumTypeNode type;
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 {
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;
}
}
}

View File

@ -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;
}
}

View File

@ -1,6 +1,5 @@
package bytecode;
import ast.parameter.ParameterListNode;
import ast.parameter.ParameterNode;
import ast.type.*;
import org.objectweb.asm.Opcodes;

View File

@ -2,10 +2,8 @@ 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 org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;

View File

@ -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);

View File

@ -1,216 +0,0 @@
package parser;
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 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;
public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
@Override
public ASTNode visitProgram(SimpleJavaParser.ProgramContext ctx) {
ProgramNode program = new ProgramNode();
for (SimpleJavaParser.ClassDeclarationContext classDeclCtx : ctx.classDeclaration()) {
program.addClass((ClassNode) visit(classDeclCtx));
}
return program;
}
@Override
public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) {
ClassNode classNode = new ClassNode((AccessTypeNode) visit(ctx.accessType()),ctx.IDENTIFIER().getText());
classNode.identifier = ctx.IDENTIFIER().getText();
for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) {
classNode.addMember((MemberNode) visit(member));
}
classNode.ensureConstructor();
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<StatementNode> 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<ParameterNode> 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
}
}

View File

@ -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;

View File

@ -0,0 +1,375 @@
package parser.astBuilder;
import ast.*;
import ast.block.BlockNode;
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;
import ast.member.MemberNode;
import ast.parameter.ParameterNode;
import ast.statement.*;
import ast.statement.ifstatement.IfStatementNode;
import ast.statement.statementexpression.AssignStatementExpressionNode;
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<ASTNode> {
@Override
public ASTNode visitProgram(SimpleJavaParser.ProgramContext ctx) {
ProgramNode program = new ProgramNode();
for (SimpleJavaParser.ClassDeclarationContext classDeclCtx : ctx.classDeclaration()) {
program.addClass((ClassNode) visit(classDeclCtx));
}
return program;
}
@Override
public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) {
ClassNode classNode = new ClassNode(ctx.AccessModifier().getText(), ctx.Identifier().getText());
for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) {
classNode.addMember((MemberNode) visit(member));
}
classNode.ensureConstructor();
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) {
NewDeclarationStatementExpressionNode newDeclarationStatementExpressionNode = new NewDeclarationStatementExpressionNode(ctx.Identifier().getText());
for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) {
newDeclarationStatementExpressionNode.addExpression((ExpressionNode) visit(expression));
}
return newDeclarationStatementExpressionNode;
}
@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) {
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
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;
}
@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;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,73 +0,0 @@
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

View File

@ -1,304 +0,0 @@
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/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}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterProgram(SimpleJavaParser.ProgramContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitProgram(SimpleJavaParser.ProgramContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameterList(SimpleJavaParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameterList(SimpleJavaParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameter(SimpleJavaParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameter(SimpleJavaParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterType(SimpleJavaParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitType(SimpleJavaParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAccessType(SimpleJavaParser.AccessTypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAccessType(SimpleJavaParser.AccessTypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStatement(SimpleJavaParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStatement(SimpleJavaParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVar(SimpleJavaParser.VarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVar(SimpleJavaParser.VarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterExpression(SimpleJavaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitExpression(SimpleJavaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLiteral(SimpleJavaParser.LiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLiteral(SimpleJavaParser.LiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}

View File

@ -1,169 +0,0 @@
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
@SuppressWarnings("CheckReturnValue")
public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SimpleJavaVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitProgram(SimpleJavaParser.ProgramContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameterList(SimpleJavaParser.ParameterListContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameter(SimpleJavaParser.ParameterContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAccessType(SimpleJavaParser.AccessTypeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStatement(SimpleJavaParser.StatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVar(SimpleJavaParser.VarContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitExpression(SimpleJavaParser.ExpressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLiteral(SimpleJavaParser.LiteralContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { return visitChildren(ctx); }
}

File diff suppressed because one or more lines are too long

View File

@ -1,263 +0,0 @@
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
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, 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;
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", "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"
};
}
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'", "'''"
};
}
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"
};
}
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] = "<INVALID>";
}
}
}
@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\u0000&\u00df\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%\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"+
"\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"+
"\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\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";
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);
}
}
}

View File

@ -1,73 +0,0 @@
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

View File

@ -1,230 +0,0 @@
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/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#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#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
*/
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#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#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);
/**
* 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#variableDeclarationStatement}.
* @param ctx the parse tree
*/
void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
* @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);
/**
* 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#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#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#literal}.
* @param ctx the parse tree
*/
void enterLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#literal}.
* @param ctx the parse tree
*/
void exitLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
*/
void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
*/
void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
*/
void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
*/
void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +0,0 @@
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
/**
* 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#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#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
* @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#type}.
* @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);
/**
* 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#variableDeclarationStatement}.
* @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);
/**
* 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#block}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBlock(SimpleJavaParser.BlockContext 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#literal}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
}

View File

@ -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 block;
ifElseStatement: ifStatement elseStatement*;
ifStatement: If OpenRoundBracket expression ClosedRoundBracket block;
elseStatement: Else block;
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;

View File

@ -1,6 +1,6 @@
package semantic;
import ast.type.TypeNode;
import oldAst.type.TypeNode;
import java.util.HashMap;
import java.util.Stack;

View File

@ -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;

View File

@ -7,11 +7,12 @@ 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.*;
import ast.expression.This;
import ast.statement.ifstatement.IfStatementNode;
import typechecker.TypeCheckResult;
public interface SemanticVisitor {

View File

@ -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 {

View File

@ -1,7 +1,6 @@
package semantic.context;
import ast.ClassNode;
import ast.ProgramNode;
import oldAst.ProgramNode;
import java.util.HashMap;
public class Context {

View File

@ -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 {

View File

@ -1,7 +1,7 @@
package typechecker;
import ast.type.TypeNode;
import oldAst.type.TypeNode;
public class TypeCheckResult {

View File

@ -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;

View File

@ -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;

View File

@ -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;