Merge branch 'main' into Tests
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
commit
f9743efddc
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
@ -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>
|
||||
|
13
pom.xml
13
pom.xml
@ -28,13 +28,22 @@
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>9.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.16.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.26.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,9 +1,5 @@
|
||||
package ast;
|
||||
|
||||
//import java.util.List;
|
||||
|
||||
public interface ASTNode {
|
||||
// public List<ASTNode> getChildren();
|
||||
}
|
||||
public interface ASTNode { }
|
||||
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
package ast;
|
||||
|
||||
public class BlockNode {
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
package ast;
|
||||
|
||||
import ast.type.AccessModifierNode;
|
||||
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;
|
||||
|
||||
public class ClassNode implements ASTNode, Visitable {
|
||||
public String identifier;
|
||||
public AccessTypeNode accessType;
|
||||
public List<MemberNode> members = new ArrayList<>();
|
||||
public boolean hasConstructor = false;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public ClassNode(AccessTypeNode accessType, String identifier){
|
||||
this.accessType = accessType;
|
||||
public class ClassNode implements ASTNode, Visitable {
|
||||
public AccessModifierNode accessType;
|
||||
public String identifier;
|
||||
public List<MemberNode> members = new ArrayList<>();
|
||||
public boolean hasConstructor;
|
||||
|
||||
public ClassNode() {}
|
||||
|
||||
public ClassNode(String accessType, String identifier){
|
||||
this.accessType = new AccessModifierNode(accessType);
|
||||
this.identifier = identifier;
|
||||
hasConstructor = false;
|
||||
}
|
||||
|
||||
public void addMember(MemberNode member) {
|
||||
@ -34,8 +34,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(new AccessModifierNode("public"), identifier);
|
||||
members.addFirst(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +54,4 @@ public class ClassNode implements ASTNode, Visitable {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ClassVisitor classVisitor) {
|
||||
classVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package ast;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class LiteralNode implements ExpressionNode {
|
||||
|
||||
int value;
|
||||
private String type;
|
||||
|
||||
public LiteralNode(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,14 +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;
|
||||
|
||||
public class ProgramNode implements ASTNode, Visitable{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProgramNode implements ASTNode, Visitable {
|
||||
public List<ClassNode> classes = new ArrayList<>();
|
||||
|
||||
public void addClass(ClassNode classNode) {
|
||||
@ -19,9 +18,4 @@ public class ProgramNode implements ASTNode, Visitable{
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ProgramVisitor programVisitor) {
|
||||
programVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
src/main/java/ast/block/BlockNode.java
Normal file
29
src/main/java/ast/block/BlockNode.java
Normal file
@ -0,0 +1,29 @@
|
||||
package ast.block;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.IStatementNode;
|
||||
import ast.statement.ReturnStatementNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.beans.Visibility;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockNode implements ASTNode, Visitable {
|
||||
public List<IStatementNode> statements = new ArrayList<>();
|
||||
public Boolean hasReturnStatement = false;
|
||||
|
||||
public BlockNode() {}
|
||||
|
||||
public void addStatement(IStatementNode statement) {
|
||||
statements.add(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import visitor.Visitable;
|
||||
|
||||
public interface ExpressionNode extends ASTNode, Visitable {
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
public enum ExpresssionOperator {
|
||||
DOT, // .
|
||||
PLUS, // +
|
||||
MINUS, // -
|
||||
MULTIPLY, // *
|
||||
DIVIDE, // /
|
||||
NOT, // !
|
||||
ASSIGNMENT, // =
|
||||
EQUALS, // ==
|
||||
UNEQUALS, // !=
|
||||
ERROR //TODO: Remove This
|
||||
}
|
11
src/main/java/ast/expression/IExpressionNode.java
Normal file
11
src/main/java/ast/expression/IExpressionNode.java
Normal file
@ -0,0 +1,11 @@
|
||||
package ast.expression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import visitor.Visitable;
|
||||
|
||||
public interface IExpressionNode extends ASTNode, Visitable {
|
||||
|
||||
ITypeNode getType();
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class BinaryExpressionNode implements IExpressionNode {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class CalculationExpressionNode extends BinaryExpressionNode {
|
||||
public CalculationExpressionNode calculationExpression;
|
||||
public EnumLineOperator operator;
|
||||
public DotExpressionNode dotExpression;
|
||||
|
||||
public CalculationExpressionNode(CalculationExpressionNode calculationExpression, String operator, DotExpressionNode dotExpression) {
|
||||
this.calculationExpression = calculationExpression;
|
||||
setOperator(operator);
|
||||
this.dotExpression = dotExpression;
|
||||
}
|
||||
|
||||
public CalculationExpressionNode(DotExpressionNode dotExpression) {
|
||||
this.dotExpression = dotExpression;
|
||||
}
|
||||
|
||||
private void setOperator(String operator) {
|
||||
if(operator.equals("+")) {
|
||||
this.operator = EnumLineOperator.PLUS;
|
||||
} else if(operator.equals("-")) {
|
||||
this.operator = EnumLineOperator.MINUS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class DotExpressionNode extends BinaryExpressionNode {
|
||||
public DotExpressionNode dotExpression;
|
||||
public EnumDotOperator operator;
|
||||
public DotSubstractionExpressionNode dotSubstractionExpression;
|
||||
|
||||
public DotExpressionNode(DotExpressionNode dotExpression, String operator, DotSubstractionExpressionNode dotSubstractionExpression) {
|
||||
this.dotExpression = dotExpression;
|
||||
setOperator(operator);
|
||||
this.dotSubstractionExpression = dotSubstractionExpression;
|
||||
}
|
||||
|
||||
public DotExpressionNode(DotSubstractionExpressionNode dotSubstractionExpression) {
|
||||
this.dotSubstractionExpression = dotSubstractionExpression;
|
||||
}
|
||||
|
||||
private void setOperator(String operator) {
|
||||
if(operator.equals("*")) {
|
||||
this.operator = EnumDotOperator.MULT;
|
||||
} else if(operator.equals("/")) {
|
||||
this.operator = EnumDotOperator.DIV;
|
||||
} else if(operator.equals("%")) {
|
||||
this.operator = EnumDotOperator.MOD;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import ast.type.ValueNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class DotSubstractionExpressionNode extends BinaryExpressionNode {
|
||||
public ValueNode value;
|
||||
public String identifier;
|
||||
public MemberAccessNode memberAccess;
|
||||
public MethodCallStatementExpressionNode methodCall;
|
||||
public 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
public enum EnumDotOperator {
|
||||
MULT, DIV, MOD
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
public enum EnumLineOperator {
|
||||
PLUS, MINUS
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
public enum EnumNonCalculationOperator {
|
||||
AND, OR, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL, EQUAL, NOT_EQUAL
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class NonCalculationExpressionNode extends BinaryExpressionNode {
|
||||
public UnaryExpressionNode unaryExpression;
|
||||
public EnumNonCalculationOperator operator;
|
||||
public IExpressionNode expression;
|
||||
|
||||
public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, IExpressionNode expression) {
|
||||
this.unaryExpression = unaryExpression;
|
||||
setOperator(operator);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
private void setOperator(String operator) {
|
||||
if(operator.equals("&&")) {
|
||||
this.operator = EnumNonCalculationOperator.AND;
|
||||
} else if(operator.equals("||")) {
|
||||
this.operator = EnumNonCalculationOperator.OR;
|
||||
} else if(operator.equals(">")) {
|
||||
this.operator = EnumNonCalculationOperator.GREATER;
|
||||
} else if(operator.equals("<")) {
|
||||
this.operator = EnumNonCalculationOperator.LESS;
|
||||
} else if(operator.equals(">=")) {
|
||||
this.operator = EnumNonCalculationOperator.GREATER_EQUAL;
|
||||
} else if(operator.equals("<=")) {
|
||||
this.operator = EnumNonCalculationOperator.LESS_EQUAL;
|
||||
} else if(operator.equals("==")) {
|
||||
this.operator = EnumNonCalculationOperator.EQUAL;
|
||||
} else if(operator.equals("!=")) {
|
||||
this.operator = EnumNonCalculationOperator.NOT_EQUAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MemberAccessNode implements ASTNode {
|
||||
public Boolean thisExpr;
|
||||
public List<String> identifiers = new ArrayList<>();
|
||||
|
||||
public MemberAccessNode(Boolean thisExpr) {
|
||||
this.thisExpr = thisExpr;
|
||||
}
|
||||
|
||||
public void addIdentifier(String identifier) {
|
||||
identifiers.add(identifier);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
|
||||
public class NotExpressionNode implements ASTNode {
|
||||
public IExpressionNode expression;
|
||||
|
||||
public NotExpressionNode(IExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.statement.IStatementNode;
|
||||
import ast.type.type.*;
|
||||
import ast.type.ValueNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UnaryExpressionNode implements IExpressionNode {
|
||||
public String thisExp;
|
||||
public String identifier;
|
||||
public MemberAccessNode memberAccess;
|
||||
public ValueNode value;
|
||||
public NotExpressionNode notExpression;
|
||||
public IStatementNode statement;
|
||||
public IExpressionNode expression;
|
||||
private ITypeNode type;
|
||||
|
||||
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(IStatementNode statement) {
|
||||
this.statement = statement;
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(IExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ITypeNode type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,34 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.type.AccessTypeNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import ast.block.BlockNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class ConstructorNode extends MethodNode implements Visitable {
|
||||
public ConstructorNode(AccessTypeNode visibility, String name) {
|
||||
super(visibility, name);
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructorNode extends MethodNode {
|
||||
public AccessModifierNode accessType;
|
||||
public String identifier;
|
||||
public List<ParameterNode> parameters = new ArrayList<>();
|
||||
public BlockNode body;
|
||||
|
||||
public ConstructorNode(AccessModifierNode accessType, String identifier) {
|
||||
this.accessType = accessType;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.TypeNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class FieldNode implements MemberNode, Visitable {
|
||||
public AccessTypeNode accessTypeNode;
|
||||
public TypeNode type;
|
||||
public AccessModifierNode accessTypeNode;
|
||||
public ITypeNode type;
|
||||
public String identifier;
|
||||
|
||||
public FieldNode(AccessTypeNode accessTypeNode, TypeNode type, String name){
|
||||
public FieldNode(AccessModifierNode accessTypeNode, ITypeNode type, String name){
|
||||
this.accessTypeNode = accessTypeNode;
|
||||
this.type = type;
|
||||
this.identifier = name;
|
||||
@ -23,8 +22,4 @@ public class FieldNode implements MemberNode, Visitable {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ClassVisitor classVisitor) {
|
||||
classVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
11
src/main/java/ast/member/MainMethodNode.java
Normal file
11
src/main/java/ast/member/MainMethodNode.java
Normal file
@ -0,0 +1,11 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.block.BlockNode;
|
||||
|
||||
public class MainMethodNode extends MethodNode {
|
||||
public BlockNode block;
|
||||
|
||||
public MainMethodNode(BlockNode block) {
|
||||
this.block = block;
|
||||
}
|
||||
}
|
@ -1,6 +1,16 @@
|
||||
package ast.member;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import ast.ASTNode;
|
||||
|
||||
public interface MemberNode extends ASTNode {
|
||||
}
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = MethodNode.class, name = "Method"),
|
||||
|
||||
@JsonSubTypes.Type(value = FieldNode.class, name = "Field") }
|
||||
)
|
||||
|
||||
public interface MemberNode extends ASTNode {}
|
||||
|
@ -1,54 +1,56 @@
|
||||
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 ast.block.BlockNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MethodNode implements MemberNode, Visitable {
|
||||
public AccessTypeNode visibility;
|
||||
public TypeNode type;
|
||||
public String identifier;
|
||||
public AccessModifierNode accesModifier;
|
||||
private ITypeNode type;
|
||||
public Boolean voidType;
|
||||
private String identifier;
|
||||
public List<ParameterNode> parameters = new ArrayList<>();
|
||||
public BlockNode block;
|
||||
|
||||
public ParameterListNode parameters;
|
||||
public MethodNode() {}
|
||||
|
||||
public List<StatementNode> statements = new ArrayList<>();
|
||||
|
||||
public MethodNode(AccessTypeNode visibility, TypeNode type, String identifier, ParameterListNode parameters, List<StatementNode> statements) {
|
||||
this.visibility = visibility;
|
||||
public MethodNode(String accessModifier, ITypeNode type, Boolean voidType, String identifier, BlockNode block){
|
||||
this.accesModifier = new AccessModifierNode(accessModifier);
|
||||
this.type = type;
|
||||
this.voidType = voidType;
|
||||
this.identifier = identifier;
|
||||
this.parameters = parameters;
|
||||
this.statements = statements;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public MethodNode(AccessTypeNode visibility, String identifier) {
|
||||
this.visibility = visibility;
|
||||
this.identifier = identifier;
|
||||
public void addParameter(ParameterNode parameter) {
|
||||
this.parameters.add(parameter);
|
||||
}
|
||||
|
||||
public boolean isSame(MethodNode methodNode) {
|
||||
boolean isSame = false;
|
||||
if (methodNode.identifier.equals(identifier)) {
|
||||
if (parameters != null && methodNode.parameters != null) {
|
||||
if (parameters.parameters.size() == methodNode.parameters.parameters.size()) {
|
||||
for (int i = 0; i < parameters.parameters.size(); i++) {
|
||||
if (parameters.parameters.get(i).identifier.equals(methodNode.parameters.parameters.get(i).identifier)) {
|
||||
isSame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<ParameterNode> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public boolean isSame(MethodNode methodNode){
|
||||
if (!(Objects.equals(this.identifier, methodNode.getIdentifier())) || type.equals(methodNode.type)
|
||||
|| getParameters().size() != methodNode.getParameters().size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.getParameters().size(); i++) {
|
||||
if (this.getParameters().get(i).type.equals(methodNode.getParameters().get(i).type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return isSame;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,4 +62,21 @@ public class MethodNode implements MemberNode, Visitable {
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public ITypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ITypeNode type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +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(List<ParameterNode> parameters){
|
||||
this.parameters = parameters;
|
||||
}
|
||||
}
|
@ -1,14 +1,23 @@
|
||||
package ast.parameter;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.type.TypeNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class ParameterNode implements ASTNode {
|
||||
public TypeNode type;
|
||||
public class ParameterNode implements ASTNode, Visitable {
|
||||
public ITypeNode type;
|
||||
public String identifier;
|
||||
|
||||
public ParameterNode(TypeNode type, String identifier) {
|
||||
public ParameterNode(ITypeNode type, String identifier) {
|
||||
this.type = type;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class AssignmentStatementNode extends StatementNode implements Visitable {
|
||||
public BinaryExpressionNode expression;
|
||||
|
||||
public AssignmentStatementNode(BinaryExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
31
src/main/java/ast/statement/ForStatementNode.java
Normal file
31
src/main/java/ast/statement/ForStatementNode.java
Normal file
@ -0,0 +1,31 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class ForStatementNode implements IStatementNode {
|
||||
public IExpressionNode statementExpressionInit;
|
||||
public IStatementNode localVariableDeclarationInit;
|
||||
public IExpressionNode expression;
|
||||
public IExpressionNode statementExpression;
|
||||
|
||||
public ForStatementNode(IExpressionNode statementExpressionInit, IExpressionNode expression, IExpressionNode statementExpression) {
|
||||
this.statementExpressionInit = statementExpressionInit;
|
||||
this.expression = expression;
|
||||
this.statementExpression = statementExpression;
|
||||
}
|
||||
|
||||
public ForStatementNode(IStatementNode localVariableDeclarationInit, IExpressionNode expression, IExpressionNode statementExpression) {
|
||||
this.localVariableDeclarationInit = localVariableDeclarationInit;
|
||||
this.expression = expression;
|
||||
this.statementExpression = statementExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,5 @@ package ast.statement;
|
||||
import ast.ASTNode;
|
||||
import visitor.Visitable;
|
||||
|
||||
public abstract class StatementNode implements ASTNode, Visitable {
|
||||
public interface IStatementNode extends ASTNode, Visitable {
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class LocalVariableDeclarationNode implements IStatementNode {
|
||||
public ITypeNode type;
|
||||
public String identifier;
|
||||
public String assign;
|
||||
public IExpressionNode expression;
|
||||
|
||||
public LocalVariableDeclarationNode(ITypeNode type, String identifier, String assign, IExpressionNode expression) {
|
||||
this.type = type;
|
||||
this.identifier = identifier;
|
||||
this.assign = assign;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,24 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class ReturnStatementNode extends StatementNode {
|
||||
public ExpressionNode expression;
|
||||
public class ReturnStatementNode implements IStatementNode {
|
||||
public IExpressionNode expression;
|
||||
public Boolean voidReturn = false;
|
||||
|
||||
public ReturnStatementNode(ExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
public ReturnStatementNode(IExpressionNode expression) {
|
||||
if(expression != null) {
|
||||
this.expression = expression;
|
||||
} else {
|
||||
voidReturn = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,22 +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(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);
|
||||
}
|
||||
}
|
@ -1,20 +1,23 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class WhileStatementNode extends StatementNode {
|
||||
public ExpressionNode condition;
|
||||
public StatementNode body;
|
||||
public class WhileStatementNode implements IStatementNode {
|
||||
public IExpressionNode expression;
|
||||
public BlockNode block;
|
||||
|
||||
public WhileStatementNode(ExpressionNode condition, StatementNode body) {
|
||||
this.condition = condition;
|
||||
this.body = body;
|
||||
public WhileStatementNode(IExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.statement.IStatementNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class ElseStatementNode implements IStatementNode {
|
||||
public BlockNode block;
|
||||
|
||||
public ElseStatementNode(BlockNode block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.IStatementNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IfElseStatementNode implements IStatementNode {
|
||||
public IfStatementNode ifStatement;
|
||||
public List<ElseStatementNode> elseStatements = new ArrayList<>();
|
||||
|
||||
public IfElseStatementNode(IfStatementNode ifStatement) {
|
||||
this.ifStatement = ifStatement;
|
||||
}
|
||||
|
||||
public void addElseStatement(ElseStatementNode elseStatement) {
|
||||
elseStatements.add(elseStatement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
24
src/main/java/ast/statement/ifstatement/IfStatementNode.java
Normal file
24
src/main/java/ast/statement/ifstatement/IfStatementNode.java
Normal file
@ -0,0 +1,24 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.statement.IStatementNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class IfStatementNode implements IStatementNode {
|
||||
public IExpressionNode expression;
|
||||
public BlockNode block;
|
||||
|
||||
public IfStatementNode(IExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.expression.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class AssignStatementExpressionNode implements IStatementExpressionNode {
|
||||
public AssignableExpressionNode assignable;
|
||||
public IExpressionNode expression;
|
||||
|
||||
public AssignStatementExpressionNode(AssignableExpressionNode assignable, IExpressionNode expression) {
|
||||
this.assignable = assignable;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class AssignableExpressionNode implements IStatementExpressionNode {
|
||||
public String identifier;
|
||||
|
||||
public MemberAccessNode memberAccess;
|
||||
|
||||
public AssignableExpressionNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public AssignableExpressionNode(MemberAccessNode memberAccess) {
|
||||
this.memberAccess = memberAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.statement.IStatementNode;
|
||||
|
||||
public interface IStatementExpressionNode extends IStatementNode {}
|
@ -0,0 +1,28 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewDeclarationStatementExpressionNode implements IStatementExpressionNode {
|
||||
public String identifier;
|
||||
public List<IExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
public NewDeclarationStatementExpressionNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public void addExpression(IExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
public enum CrementType {
|
||||
PREFIX, SUFFIX
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
import ast.statement.statementexpression.IStatementExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class DecrementExpressionNode implements IStatementExpressionNode {
|
||||
public CrementType crementType;
|
||||
public AssignableExpressionNode assignableExpression;
|
||||
|
||||
public DecrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) {
|
||||
this.assignableExpression = assignableExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
import ast.statement.statementexpression.IStatementExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class IncrementExpressionNode implements IStatementExpressionNode {
|
||||
public CrementType crementType;
|
||||
public AssignableExpressionNode assignableExpression;
|
||||
|
||||
public IncrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) {
|
||||
this.assignableExpression = assignableExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ast.statement.statementexpression.methodcallstatementnexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChainedMethodNode implements ASTNode {
|
||||
public String identifier;
|
||||
public List<IExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
public ChainedMethodNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public void addExpression(IExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package ast.statement.statementexpression.methodcallstatementnexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.statement.statementexpression.IStatementExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodCallStatementExpressionNode implements IStatementExpressionNode {
|
||||
public TargetNode target;
|
||||
public List<ChainedMethodNode> chainedMethods = new ArrayList<>();
|
||||
public String identifier;
|
||||
public List<IExpressionNode> 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(IExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
||||
public Boolean thisTar;
|
||||
public MemberAccessNode memberAccess;
|
||||
public NewDeclarationStatementExpressionNode newDeclaration;
|
||||
public 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;
|
||||
}
|
||||
}
|
28
src/main/java/ast/type/AccessModifierNode.java
Normal file
28
src/main/java/ast/type/AccessModifierNode.java
Normal file
@ -0,0 +1,28 @@
|
||||
package ast.type;
|
||||
|
||||
public class AccessModifierNode {
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class AccessTypeNode implements ASTNode {
|
||||
public EnumAccessTypeNode enumAccessTypeNode;
|
||||
|
||||
public AccessTypeNode(EnumAccessTypeNode enumAccessTypeNode) {
|
||||
this.enumAccessTypeNode = enumAccessTypeNode;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class BaseTypeNode implements ASTNode, TypeNode {
|
||||
|
||||
public EnumTypeNode enumType;
|
||||
|
||||
public BaseTypeNode(EnumTypeNode enumType) {
|
||||
this.enumType = enumType;
|
||||
}
|
||||
|
||||
}
|
6
src/main/java/ast/type/EnumAccessModifierNode.java
Normal file
6
src/main/java/ast/type/EnumAccessModifierNode.java
Normal file
@ -0,0 +1,6 @@
|
||||
package ast.type;
|
||||
|
||||
public enum EnumAccessModifierNode {
|
||||
PUBLIC, PRIVATE, PUBLIC_STATIC, PRIVATE_STATIC
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
public enum EnumAccessTypeNode {
|
||||
PUBLIC, PRIVATE
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
public enum EnumTypeNode {
|
||||
INT, BOOLEAN, CHAR
|
||||
}
|
5
src/main/java/ast/type/EnumValueNode.java
Normal file
5
src/main/java/ast/type/EnumValueNode.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ast.type;
|
||||
|
||||
public enum EnumValueNode {
|
||||
INT_VALUE, BOOLEAN_VALUE, CHAR_VALUE, NULL_VALUE
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class ReferenceTypeNode implements ASTNode, TypeNode {
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public interface TypeNode extends ASTNode {
|
||||
}
|
13
src/main/java/ast/type/ValueNode.java
Normal file
13
src/main/java/ast/type/ValueNode.java
Normal file
@ -0,0 +1,13 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class ValueNode implements ASTNode {
|
||||
public EnumValueNode valueType;
|
||||
public String value;
|
||||
|
||||
public ValueNode(EnumValueNode valueType, String value) {
|
||||
this.valueType = valueType;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
30
src/main/java/ast/type/type/BaseType.java
Normal file
30
src/main/java/ast/type/type/BaseType.java
Normal file
@ -0,0 +1,30 @@
|
||||
package ast.type.type;
|
||||
|
||||
public class BaseType implements ITypeNode {
|
||||
|
||||
private TypeEnum typeEnum;
|
||||
|
||||
public BaseType(TypeEnum typeEnum) {
|
||||
this.typeEnum = typeEnum;
|
||||
}
|
||||
|
||||
public TypeEnum getTypeEnum() {
|
||||
return typeEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BaseType other = (BaseType) obj;
|
||||
if (typeEnum != other.typeEnum)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
5
src/main/java/ast/type/type/ITypeNode.java
Normal file
5
src/main/java/ast/type/type/ITypeNode.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ast.type.type;
|
||||
|
||||
public interface ITypeNode {
|
||||
|
||||
}
|
33
src/main/java/ast/type/type/ReferenceType.java
Normal file
33
src/main/java/ast/type/type/ReferenceType.java
Normal file
@ -0,0 +1,33 @@
|
||||
package ast.type.type;
|
||||
|
||||
public class ReferenceType implements ITypeNode{
|
||||
|
||||
private String identifier;
|
||||
|
||||
public ReferenceType(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ReferenceType other = (ReferenceType) obj;
|
||||
if (identifier == null) {
|
||||
if (other.identifier != null)
|
||||
return false;
|
||||
} else if (!identifier.equals(other.identifier))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
9
src/main/java/ast/type/type/TypeEnum.java
Normal file
9
src/main/java/ast/type/type/TypeEnum.java
Normal file
@ -0,0 +1,9 @@
|
||||
package ast.type.type;
|
||||
|
||||
public enum TypeEnum {
|
||||
VOID,
|
||||
INT,
|
||||
CHAR,
|
||||
BOOL;
|
||||
|
||||
}
|
@ -15,8 +15,8 @@ public class ByteCodeGenerator implements ProgramVisitor {
|
||||
@Override
|
||||
public void visit(ProgramNode programNode) {
|
||||
for (ClassNode classDeclarationNode : programNode.classes) {
|
||||
ClassCodeGen classCodeGen = new ClassCodeGen(outputDirectoryPath);
|
||||
classDeclarationNode.accept(classCodeGen);
|
||||
// ClassCodeGen classCodeGen = new ClassCodeGen();
|
||||
// classDeclarationNode.accept(classCodeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ import ast.ClassNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MemberNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.type.BaseTypeNode;
|
||||
import ast.type.type.BaseType;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -29,8 +28,8 @@ public class ClassCodeGen implements ClassVisitor {
|
||||
@Override
|
||||
public void visit(ClassNode classNode) {
|
||||
classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null,
|
||||
"java/lang/Object", null);
|
||||
// classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null,
|
||||
// "java/lang/Object", null);
|
||||
|
||||
for (MemberNode memberNode : classNode.members) {
|
||||
if (memberNode instanceof FieldNode) {
|
||||
@ -49,8 +48,8 @@ public class ClassCodeGen implements ClassVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(FieldNode fieldNode) {
|
||||
if (fieldNode.type instanceof BaseTypeNode baseTypeNode) {
|
||||
classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null);
|
||||
if(fieldNode.type instanceof BaseType baseTypeNode){
|
||||
// classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null );
|
||||
}
|
||||
classWriter.visitEnd();
|
||||
}
|
||||
|
@ -1,45 +1,41 @@
|
||||
package bytecode;
|
||||
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.type.*;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import ast.type.BaseTypeNode;
|
||||
|
||||
public class Mapper {
|
||||
public int mapAccessTypeToOpcode(AccessTypeNode type) {
|
||||
switch (type.enumAccessTypeNode) {
|
||||
case EnumAccessTypeNode.PUBLIC:
|
||||
return Opcodes.ACC_PUBLIC;
|
||||
case EnumAccessTypeNode.PRIVATE:
|
||||
return Opcodes.ACC_PRIVATE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// public int mapAccessTypeToOpcode(AccessModifierNode type) {
|
||||
// switch (type.enumAccessTypeNode) {
|
||||
// case EnumAccessTypeNode.PUBLIC:
|
||||
// return Opcodes.ACC_PUBLIC;
|
||||
// case EnumAccessTypeNode.PRIVATE:
|
||||
// return Opcodes.ACC_PRIVATE;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) {
|
||||
String descriptor = "(";
|
||||
for(ParameterNode parameterNode : parameterListNode.parameters) {
|
||||
descriptor += getTypeChar(EnumTypeNode.INT);
|
||||
}
|
||||
descriptor += ")";
|
||||
descriptor += getTypeChar(baseTypeNode.enumType);
|
||||
return descriptor;
|
||||
}
|
||||
// public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) {
|
||||
// String descriptor = "(";
|
||||
// for(ParameterNode parameterNode : parameterListNode.parameters) {
|
||||
// descriptor += getTypeChar(EnumTypeNode.INT);
|
||||
// }
|
||||
// descriptor += ")";
|
||||
// descriptor += getTypeChar(baseTypeNode.enumType);
|
||||
// return descriptor;
|
||||
// }
|
||||
|
||||
public String getTypeChar(EnumTypeNode enumTypeNode) {
|
||||
String typeChar = "";
|
||||
switch (enumTypeNode) {
|
||||
case EnumTypeNode.INT:
|
||||
typeChar = "I";
|
||||
break;
|
||||
case EnumTypeNode.CHAR:
|
||||
typeChar = "C";
|
||||
break;
|
||||
case EnumTypeNode.BOOLEAN:
|
||||
typeChar = "Z";
|
||||
break;
|
||||
}
|
||||
return typeChar;
|
||||
}
|
||||
// public String getTypeChar(TypeEnum enumTypeNode) {
|
||||
// String typeChar = "";
|
||||
// switch (enumTypeNode) {
|
||||
// case TypeEnum.INT:
|
||||
// typeChar = "I";
|
||||
// break;
|
||||
// case TypeEnum.CHAR:
|
||||
// typeChar = "C";
|
||||
// break;
|
||||
// case TypeEnum.BOOLEAN:
|
||||
// typeChar = "Z";
|
||||
// break;
|
||||
// }
|
||||
// return typeChar;
|
||||
// }
|
||||
}
|
||||
|
@ -2,14 +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;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -33,12 +27,12 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(ConstructorNode constructorNode) {
|
||||
methodVisitor =
|
||||
classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.visibility),
|
||||
"<init>",
|
||||
"()V",
|
||||
null,
|
||||
null);
|
||||
// methodVisitor =
|
||||
// classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.visibility),
|
||||
// "<init>",
|
||||
// "()V",
|
||||
// null,
|
||||
// null);
|
||||
methodVisitor.visitCode();
|
||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||
methodVisitor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
@ -49,52 +43,52 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode methodNode) {
|
||||
if (methodNode.type instanceof BaseTypeNode baseTypeNode) {
|
||||
methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.visibility),
|
||||
methodNode.identifier,
|
||||
mapper.generateMethodDescriptor(baseTypeNode, methodNode.parameters),
|
||||
null,
|
||||
null);
|
||||
// if (methodNode.type instanceof BaseTypeNode baseTypeNode) {
|
||||
// methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.visibility),
|
||||
// methodNode.identifier,
|
||||
// mapper.generateMethodDescriptor(baseTypeNode, methodNode.parameters),
|
||||
// null,
|
||||
// null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVaribales.add("this");
|
||||
for (ParameterNode parameterNode : methodNode.parameters.parameters) {
|
||||
localVaribales.add(parameterNode.identifier);
|
||||
}
|
||||
// for (ParameterNode parameterNode : methodNode.parameters.parameters) {
|
||||
// localVaribales.add(parameterNode.identifier);
|
||||
// }
|
||||
|
||||
//test();
|
||||
methodVisitor.visitMaxs(1, localVaribales.size());
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public void test() {
|
||||
Label start = new Label();
|
||||
Label loop = new Label();
|
||||
Label end = new Label();
|
||||
methodVisitor.visitLabel(start);
|
||||
//methodVisitor.visitVarInsn(Opcodes.ICONST_M1, 99);
|
||||
//methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
methodVisitor.visitLdcInsn(99);
|
||||
// methodVisitor.visitInsn(Opcodes.ICONST_0);
|
||||
//methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
|
||||
methodVisitor.visitVarInsn(Opcodes.ISTORE, 1);
|
||||
methodVisitor.visitLabel(loop);
|
||||
methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
methodVisitor.visitJumpInsn(Opcodes.IF_ICMPGE, end);
|
||||
methodVisitor.visitFieldInsn(Opcodes.GETSTATIC,
|
||||
"java/lang/System", "out",
|
||||
"Ljava/io/PrintStream;");
|
||||
methodVisitor.visitLdcInsn("Bytecode");
|
||||
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
|
||||
"java/io/PrintStream", "println",
|
||||
"(Ljava/lang/String;)V", false);
|
||||
methodVisitor.visitIincInsn(1, 1);
|
||||
methodVisitor.visitJumpInsn(Opcodes.GOTO, loop);
|
||||
methodVisitor.visitLabel(end);
|
||||
methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
methodVisitor.visitInsn(Opcodes.IRETURN);
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
// public void test() {
|
||||
// Label start = new Label();
|
||||
// Label loop = new Label();
|
||||
// Label end = new Label();
|
||||
// methodVisitor.visitLabel(start);
|
||||
// //methodVisitor.visitVarInsn(Opcodes.ICONST_M1, 99);
|
||||
// //methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
// methodVisitor.visitLdcInsn(99);
|
||||
// // methodVisitor.visitInsn(Opcodes.ICONST_0);
|
||||
// //methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ISTORE, 1);
|
||||
// methodVisitor.visitLabel(loop);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
// methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
// methodVisitor.visitJumpInsn(Opcodes.IF_ICMPGE, end);
|
||||
// methodVisitor.visitFieldInsn(Opcodes.GETSTATIC,
|
||||
// "java/lang/System", "out",
|
||||
// "Ljava/io/PrintStream;");
|
||||
// methodVisitor.visitLdcInsn("Bytecode");
|
||||
// methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
|
||||
// "java/io/PrintStream", "println",
|
||||
// "(Ljava/lang/String;)V", false);
|
||||
// methodVisitor.visitIincInsn(1, 1);
|
||||
// methodVisitor.visitJumpInsn(Opcodes.GOTO, loop);
|
||||
// methodVisitor.visitLabel(end);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
// methodVisitor.visitInsn(Opcodes.IRETURN);
|
||||
// methodVisitor.visitEnd();
|
||||
// }
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -1,11 +1,8 @@
|
||||
package main;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.ClassNode;
|
||||
import ast.ProgramNode;
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.EnumAccessTypeNode;
|
||||
import parser.ASTBuilder;
|
||||
import parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
import semantic.SemanticAnalyzer;
|
||||
@ -28,6 +25,8 @@ import java.nio.file.Paths;
|
||||
* <code> java.exe -jar .\target\JavaCompiler-1.0-SNAPSHOT-jar-with-dependencies.jar 'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' </code>
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 2) {
|
||||
// args[0] is the input file path
|
||||
|
@ -1,221 +0,0 @@
|
||||
package parser;
|
||||
|
||||
import ast.*;
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.expression.ExpresssionOperator;
|
||||
import ast.expression.IdentifierExpressionNode;
|
||||
import ast.expression.UnaryExpressionNode;
|
||||
import ast.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) {
|
||||
|
||||
BinaryExpressionNode expression = (BinaryExpressionNode) visit(ctx.expression());
|
||||
return new AssignmentStatementNode(expression);
|
||||
}
|
||||
|
||||
@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("int");
|
||||
return literalNode;
|
||||
} catch (NumberFormatException ignored) {}
|
||||
|
||||
return null; // Return null or throw an exception if no valid expression found
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
415
src/main/java/parser/astBuilder/ASTBuilder.java
Normal file
415
src/main/java/parser/astBuilder/ASTBuilder.java
Normal file
@ -0,0 +1,415 @@
|
||||
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.member.*;
|
||||
import ast.statement.ifstatement.ElseStatementNode;
|
||||
import ast.statement.ifstatement.IfElseStatementNode;
|
||||
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 ast.type.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 visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) {
|
||||
if(ctx.MainMethodDeclaration() != null) {
|
||||
return new MainMethodNode((BlockNode) visit(ctx.block()));
|
||||
} else {
|
||||
if(ctx.type() != null) {
|
||||
MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), createTypeNode(ctx.type().getText()), false, ctx.Identifier().getText(), (BlockNode) visit(ctx.block()));
|
||||
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
||||
methodNode.addParameter((ParameterNode) visit(parameter));
|
||||
}
|
||||
return methodNode;
|
||||
} else {
|
||||
MethodNode methodNode = new MethodNode(ctx.AccessModifier().getText(), null, true, ctx.Identifier().getText(), (BlockNode) visit(ctx.block()));
|
||||
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
||||
methodNode.addParameter((ParameterNode) visit(parameter));
|
||||
}
|
||||
return methodNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) {
|
||||
return new FieldNode(new AccessModifierNode(ctx.AccessModifier().getText()), createTypeNode(ctx.type().getText()), ctx.Identifier().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) {
|
||||
return new ParameterNode(createTypeNode(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((IExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) {
|
||||
return new LocalVariableDeclarationNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitBlock(SimpleJavaParser.BlockContext ctx) {
|
||||
BlockNode blockNode = new BlockNode();
|
||||
for(SimpleJavaParser.StatementContext statement : ctx.statement()) {
|
||||
blockNode.addStatement((IStatementNode) visit(statement));
|
||||
}
|
||||
if(!blockNode.hasReturnStatement) {
|
||||
blockNode.addStatement(new ReturnStatementNode(null));
|
||||
}
|
||||
return blockNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) {
|
||||
return new WhileStatementNode((IExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitForStatement(SimpleJavaParser.ForStatementContext ctx) {
|
||||
if(ctx.statementExpression(0) != null) {
|
||||
return new ForStatementNode((IExpressionNode) visit(ctx.statementExpression(0)), (IExpressionNode) visit(ctx.expression()), (IExpressionNode) visit(ctx.statementExpression(1)));
|
||||
} else if(ctx.localVariableDeclaration() != null) {
|
||||
return new ForStatementNode((IStatementNode) visit(ctx.localVariableDeclaration()), (IExpressionNode) visit(ctx.expression()), (IExpressionNode) 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((IExpressionNode) 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()), (IExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) {
|
||||
NewDeclarationStatementExpressionNode newDeclarationStatementExpressionNode = new NewDeclarationStatementExpressionNode(ctx.Identifier().getText());
|
||||
for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) {
|
||||
newDeclarationStatementExpressionNode.addExpression((IExpressionNode) 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((IExpressionNode) 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((IExpressionNode) 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((IStatementNode) visitStatementExpression(ctx.statementExpression()));
|
||||
} else if(ctx.expression() != null) {
|
||||
return new UnaryExpressionNode((IExpressionNode) 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((IExpressionNode) 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(), (IExpressionNode) 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;
|
||||
}
|
||||
|
||||
public ITypeNode createTypeNode(String identifier){
|
||||
return switch (identifier) {
|
||||
case "int" -> new BaseType(TypeEnum.INT);
|
||||
case "boolean" -> new BaseType(TypeEnum.BOOL);
|
||||
case "char" -> new BaseType(TypeEnum.CHAR);
|
||||
case "void" -> new BaseType(TypeEnum.VOID);
|
||||
default -> new ReferenceType(identifier);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,73 +1,88 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
INTEGERLITERAL=36
|
||||
IDENTIFIER=37
|
||||
WS=38
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
||||
';'=4
|
||||
'static'=5
|
||||
'('=6
|
||||
')'=7
|
||||
','=8
|
||||
'int'=9
|
||||
'boolean'=10
|
||||
'char'=11
|
||||
'public'=12
|
||||
'private'=13
|
||||
'='=14
|
||||
'if'=15
|
||||
'else'=16
|
||||
'while'=17
|
||||
'return'=18
|
||||
'&&'=19
|
||||
'||'=20
|
||||
'=='=21
|
||||
'!='=22
|
||||
'<'=23
|
||||
'<='=24
|
||||
'>'=25
|
||||
'>='=26
|
||||
'+'=27
|
||||
'-'=28
|
||||
'*'=29
|
||||
'/'=30
|
||||
'%'=31
|
||||
'!'=32
|
||||
'true'=33
|
||||
'false'=34
|
||||
'\''=35
|
||||
Void=3
|
||||
Boolean=4
|
||||
Char=5
|
||||
Int=6
|
||||
AccessModifier=7
|
||||
MainMethodDeclaration=8
|
||||
DotOperator=9
|
||||
LineOperator=10
|
||||
ComparisonOperator=11
|
||||
LogicalOperator=12
|
||||
Assign=13
|
||||
Plus=14
|
||||
Minus=15
|
||||
Mult=16
|
||||
Modulo=17
|
||||
Div=18
|
||||
Greater=19
|
||||
Less=20
|
||||
GreaterEqual=21
|
||||
LessEqual=22
|
||||
Equal=23
|
||||
NotEqual=24
|
||||
Not=25
|
||||
And=26
|
||||
Or=27
|
||||
Dot=28
|
||||
OpenRoundBracket=29
|
||||
ClosedRoundBracket=30
|
||||
OpenCurlyBracket=31
|
||||
ClosedCurlyBracket=32
|
||||
Semicolon=33
|
||||
Comma=34
|
||||
Class=35
|
||||
This=36
|
||||
While=37
|
||||
If=38
|
||||
Else=39
|
||||
For=40
|
||||
Return=41
|
||||
New=42
|
||||
CharValue=43
|
||||
IntValue=44
|
||||
BooleanValue=45
|
||||
NullValue=46
|
||||
Identifier=47
|
||||
WS=48
|
||||
InlineComment=49
|
||||
MultilineComment=50
|
||||
'++'=1
|
||||
'--'=2
|
||||
'void'=3
|
||||
'boolean'=4
|
||||
'char'=5
|
||||
'int'=6
|
||||
'public static void main(String[] args)'=8
|
||||
'='=13
|
||||
'+'=14
|
||||
'-'=15
|
||||
'*'=16
|
||||
'%'=17
|
||||
'/'=18
|
||||
'>'=19
|
||||
'<'=20
|
||||
'>='=21
|
||||
'<='=22
|
||||
'=='=23
|
||||
'!='=24
|
||||
'!'=25
|
||||
'&&'=26
|
||||
'||'=27
|
||||
'.'=28
|
||||
'('=29
|
||||
')'=30
|
||||
'{'=31
|
||||
'}'=32
|
||||
';'=33
|
||||
','=34
|
||||
'class'=35
|
||||
'this'=36
|
||||
'while'=37
|
||||
'if'=38
|
||||
'else'=39
|
||||
'for'=40
|
||||
'return'=41
|
||||
'new'=42
|
||||
'null'=46
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
@ -48,6 +48,18 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
* <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 enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -72,18 +84,6 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
* <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}
|
||||
*
|
||||
@ -113,25 +113,13 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterType(SimpleJavaParser.TypeContext ctx) { }
|
||||
@Override public void enterArgumentList(SimpleJavaParser.ArgumentListContext 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) { }
|
||||
@Override public void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -149,61 +137,13 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
|
||||
@Override public void enterBlock(SimpleJavaParser.BlockContext 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) { }
|
||||
@Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -221,13 +161,109 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { }
|
||||
@Override public void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { }
|
||||
@Override public void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext 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 enterForStatement(SimpleJavaParser.ForStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitForStatement(SimpleJavaParser.ForStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext 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 enterElseStatement(SimpleJavaParser.ElseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAssign(SimpleJavaParser.AssignContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAssign(SimpleJavaParser.AssignContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -245,37 +281,265 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLiteral(SimpleJavaParser.LiteralContext ctx) { }
|
||||
@Override public void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLiteral(SimpleJavaParser.LiteralContext ctx) { }
|
||||
@Override public void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
|
||||
@Override public void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
|
||||
@Override public void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
|
||||
@Override public void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
|
||||
@Override public void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMethodCall(SimpleJavaParser.MethodCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMethodCall(SimpleJavaParser.MethodCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterTarget(SimpleJavaParser.TargetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitTarget(SimpleJavaParser.TargetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitChainedMethod(SimpleJavaParser.ChainedMethodContext 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 enterValue(SimpleJavaParser.ValueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitValue(SimpleJavaParser.ValueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
@ -33,6 +33,13 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* {@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 visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -47,13 +54,6 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* {@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}
|
||||
*
|
||||
@ -74,14 +74,7 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* <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); }
|
||||
@Override public T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -95,35 +88,7 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* <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); }
|
||||
@Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -137,7 +102,63 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* <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); }
|
||||
@Override public T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext 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 visitForStatement(SimpleJavaParser.ForStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext 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 visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitAssign(SimpleJavaParser.AssignContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -151,19 +172,152 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* <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); }
|
||||
@Override public T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext 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); }
|
||||
@Override public T visitNotExpression(SimpleJavaParser.NotExpressionContext 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); }
|
||||
@Override public T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMethodCall(SimpleJavaParser.MethodCallContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitTarget(SimpleJavaParser.TargetContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitChainedMethod(SimpleJavaParser.ChainedMethodContext 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 visitValue(SimpleJavaParser.ValueContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx) { return visitChildren(ctx); }
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
@ -17,12 +17,15 @@ public class SimpleJavaLexer extends Lexer {
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
|
||||
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
|
||||
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
|
||||
T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
|
||||
T__31=32, T__32=33, T__33=34, T__34=35, INTEGERLITERAL=36, IDENTIFIER=37,
|
||||
WS=38;
|
||||
T__0=1, T__1=2, Void=3, Boolean=4, Char=5, Int=6, AccessModifier=7, MainMethodDeclaration=8,
|
||||
DotOperator=9, LineOperator=10, ComparisonOperator=11, LogicalOperator=12,
|
||||
Assign=13, Plus=14, Minus=15, Mult=16, Modulo=17, Div=18, Greater=19,
|
||||
Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25,
|
||||
And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31,
|
||||
ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37,
|
||||
If=38, Else=39, For=40, Return=41, New=42, CharValue=43, IntValue=44,
|
||||
BooleanValue=45, NullValue=46, Identifier=47, WS=48, InlineComment=49,
|
||||
MultilineComment=50;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
@ -33,31 +36,40 @@ public class SimpleJavaLexer extends Lexer {
|
||||
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
|
||||
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
|
||||
"T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
|
||||
"T__33", "T__34", "INTEGERLITERAL", "IDENTIFIER", "WS"
|
||||
"T__0", "T__1", "Void", "Boolean", "Char", "Int", "AccessModifier", "MainMethodDeclaration",
|
||||
"DotOperator", "LineOperator", "ComparisonOperator", "LogicalOperator",
|
||||
"Assign", "Plus", "Minus", "Mult", "Modulo", "Div", "Greater", "Less",
|
||||
"GreaterEqual", "LessEqual", "Equal", "NotEqual", "Not", "And", "Or",
|
||||
"Dot", "OpenRoundBracket", "ClosedRoundBracket", "OpenCurlyBracket",
|
||||
"ClosedCurlyBracket", "Semicolon", "Comma", "Class", "This", "While",
|
||||
"If", "Else", "For", "Return", "New", "CharValue", "IntValue", "BooleanValue",
|
||||
"NullValue", "Alphabetic", "Numeric", "ValidIdentSymbols", "Identifier",
|
||||
"WS", "InlineComment", "MultilineComment"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'class'", "'{'", "'}'", "';'", "'static'", "'('", "')'", "','",
|
||||
"'int'", "'boolean'", "'char'", "'public'", "'private'", "'='", "'if'",
|
||||
"'else'", "'while'", "'return'", "'&&'", "'||'", "'=='", "'!='", "'<'",
|
||||
"'<='", "'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'true'",
|
||||
"'false'", "'''"
|
||||
null, "'++'", "'--'", "'void'", "'boolean'", "'char'", "'int'", null,
|
||||
"'public static void main(String[] args)'", null, null, null, null, "'='",
|
||||
"'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='",
|
||||
"'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'",
|
||||
"','", "'class'", "'this'", "'while'", "'if'", "'else'", "'for'", "'return'",
|
||||
"'new'", null, null, null, "'null'"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
"INTEGERLITERAL", "IDENTIFIER", "WS"
|
||||
null, null, null, "Void", "Boolean", "Char", "Int", "AccessModifier",
|
||||
"MainMethodDeclaration", "DotOperator", "LineOperator", "ComparisonOperator",
|
||||
"LogicalOperator", "Assign", "Plus", "Minus", "Mult", "Modulo", "Div",
|
||||
"Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual",
|
||||
"Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket",
|
||||
"OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class",
|
||||
"This", "While", "If", "Else", "For", "Return", "New", "CharValue", "IntValue",
|
||||
"BooleanValue", "NullValue", "Identifier", "WS", "InlineComment", "MultilineComment"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
@ -119,7 +131,7 @@ public class SimpleJavaLexer extends Lexer {
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u0000&\u00df\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0004\u00002\u0198\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
|
||||
"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+
|
||||
"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+
|
||||
@ -130,43 +142,67 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+
|
||||
"\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+
|
||||
"\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+
|
||||
"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0001\u0000"+
|
||||
"\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+
|
||||
"\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004"+
|
||||
"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+
|
||||
"\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+
|
||||
"\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+
|
||||
"\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+
|
||||
"\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f"+
|
||||
"\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+
|
||||
"\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001"+
|
||||
"\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001"+
|
||||
"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001"+
|
||||
"\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001"+
|
||||
"\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+
|
||||
"\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001"+
|
||||
"\u0019\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001"+
|
||||
"\u001b\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+
|
||||
"\u001e\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001"+
|
||||
"!\u0001!\u0001!\u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001#\u0004#\u00ce"+
|
||||
"\b#\u000b#\f#\u00cf\u0001$\u0001$\u0005$\u00d4\b$\n$\f$\u00d7\t$\u0001"+
|
||||
"%\u0004%\u00da\b%\u000b%\f%\u00db\u0001%\u0001%\u0000\u0000&\u0001\u0001"+
|
||||
"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+
|
||||
"&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+
|
||||
"+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+
|
||||
"0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u0001\u0000"+
|
||||
"\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+
|
||||
"\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+
|
||||
"\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+
|
||||
"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+
|
||||
"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0003\u0006\u00b0\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\b\u0001\b\u0001\b\u0003\b\u00dc\b\b\u0001\t\u0001\t\u0003\t\u00e0"+
|
||||
"\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003\n\u00e8\b\n"+
|
||||
"\u0001\u000b\u0001\u000b\u0003\u000b\u00ec\b\u000b\u0001\f\u0001\f\u0001"+
|
||||
"\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+
|
||||
"\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+
|
||||
"\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+
|
||||
"\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017"+
|
||||
"\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+
|
||||
"\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001c"+
|
||||
"\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f"+
|
||||
"\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001"+
|
||||
"\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001$\u0001"+
|
||||
"$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001"+
|
||||
"&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001"+
|
||||
"(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0005*\u014a"+
|
||||
"\b*\n*\f*\u014d\t*\u0001*\u0001*\u0001+\u0003+\u0152\b+\u0001+\u0004+"+
|
||||
"\u0155\b+\u000b+\f+\u0156\u0001,\u0001,\u0001,\u0001,\u0001,\u0001,\u0001"+
|
||||
",\u0001,\u0001,\u0003,\u0162\b,\u0001-\u0001-\u0001-\u0001-\u0001-\u0001"+
|
||||
".\u0001.\u0001/\u0001/\u00010\u00010\u00010\u00030\u0170\b0\u00011\u0001"+
|
||||
"1\u00051\u0174\b1\n1\f1\u0177\t1\u00012\u00042\u017a\b2\u000b2\f2\u017b"+
|
||||
"\u00012\u00012\u00013\u00013\u00013\u00013\u00053\u0184\b3\n3\f3\u0187"+
|
||||
"\t3\u00013\u00013\u00014\u00014\u00014\u00014\u00054\u018f\b4\n4\f4\u0192"+
|
||||
"\t4\u00014\u00014\u00014\u00014\u00014\u0001\u0190\u00005\u0001\u0001"+
|
||||
"\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+
|
||||
"\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f"+
|
||||
"\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u0018"+
|
||||
"1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&\u0001"+
|
||||
"\u0000\u0004\u0001\u000009\u0002\u0000AZaz\u0004\u000009AZ__az\u0003\u0000"+
|
||||
"\t\n\r\r \u00e1\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000"+
|
||||
"\u0000\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000"+
|
||||
"%\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+
|
||||
"1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\'O("+
|
||||
"Q)S*U+W,Y-[.]\u0000_\u0000a\u0000c/e0g1i2\u0001\u0000\u0005\u0002\u0000"+
|
||||
"\n\n\r\r\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0003\u0000\t\n"+
|
||||
"\r\r \u01aa\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000"+
|
||||
"\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000"+
|
||||
"\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000"+
|
||||
"\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000"+
|
||||
"\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000"+
|
||||
"\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%"+
|
||||
"\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+
|
||||
"\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000"+
|
||||
"\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u0000"+
|
||||
"3\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001"+
|
||||
@ -174,84 +210,179 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001\u0000\u0000\u0000\u0000"+
|
||||
"A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+
|
||||
"\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+
|
||||
"\u0000\u0000K\u0001\u0000\u0000\u0000\u0001M\u0001\u0000\u0000\u0000\u0003"+
|
||||
"S\u0001\u0000\u0000\u0000\u0005U\u0001\u0000\u0000\u0000\u0007W\u0001"+
|
||||
"\u0000\u0000\u0000\tY\u0001\u0000\u0000\u0000\u000b`\u0001\u0000\u0000"+
|
||||
"\u0000\rb\u0001\u0000\u0000\u0000\u000fd\u0001\u0000\u0000\u0000\u0011"+
|
||||
"f\u0001\u0000\u0000\u0000\u0013j\u0001\u0000\u0000\u0000\u0015r\u0001"+
|
||||
"\u0000\u0000\u0000\u0017w\u0001\u0000\u0000\u0000\u0019~\u0001\u0000\u0000"+
|
||||
"\u0000\u001b\u0086\u0001\u0000\u0000\u0000\u001d\u0088\u0001\u0000\u0000"+
|
||||
"\u0000\u001f\u008b\u0001\u0000\u0000\u0000!\u0090\u0001\u0000\u0000\u0000"+
|
||||
"#\u0096\u0001\u0000\u0000\u0000%\u009d\u0001\u0000\u0000\u0000\'\u00a0"+
|
||||
"\u0001\u0000\u0000\u0000)\u00a3\u0001\u0000\u0000\u0000+\u00a6\u0001\u0000"+
|
||||
"\u0000\u0000-\u00a9\u0001\u0000\u0000\u0000/\u00ab\u0001\u0000\u0000\u0000"+
|
||||
"1\u00ae\u0001\u0000\u0000\u00003\u00b0\u0001\u0000\u0000\u00005\u00b3"+
|
||||
"\u0001\u0000\u0000\u00007\u00b5\u0001\u0000\u0000\u00009\u00b7\u0001\u0000"+
|
||||
"\u0000\u0000;\u00b9\u0001\u0000\u0000\u0000=\u00bb\u0001\u0000\u0000\u0000"+
|
||||
"?\u00bd\u0001\u0000\u0000\u0000A\u00bf\u0001\u0000\u0000\u0000C\u00c4"+
|
||||
"\u0001\u0000\u0000\u0000E\u00ca\u0001\u0000\u0000\u0000G\u00cd\u0001\u0000"+
|
||||
"\u0000\u0000I\u00d1\u0001\u0000\u0000\u0000K\u00d9\u0001\u0000\u0000\u0000"+
|
||||
"MN\u0005c\u0000\u0000NO\u0005l\u0000\u0000OP\u0005a\u0000\u0000PQ\u0005"+
|
||||
"s\u0000\u0000QR\u0005s\u0000\u0000R\u0002\u0001\u0000\u0000\u0000ST\u0005"+
|
||||
"{\u0000\u0000T\u0004\u0001\u0000\u0000\u0000UV\u0005}\u0000\u0000V\u0006"+
|
||||
"\u0001\u0000\u0000\u0000WX\u0005;\u0000\u0000X\b\u0001\u0000\u0000\u0000"+
|
||||
"YZ\u0005s\u0000\u0000Z[\u0005t\u0000\u0000[\\\u0005a\u0000\u0000\\]\u0005"+
|
||||
"t\u0000\u0000]^\u0005i\u0000\u0000^_\u0005c\u0000\u0000_\n\u0001\u0000"+
|
||||
"\u0000\u0000`a\u0005(\u0000\u0000a\f\u0001\u0000\u0000\u0000bc\u0005)"+
|
||||
"\u0000\u0000c\u000e\u0001\u0000\u0000\u0000de\u0005,\u0000\u0000e\u0010"+
|
||||
"\u0001\u0000\u0000\u0000fg\u0005i\u0000\u0000gh\u0005n\u0000\u0000hi\u0005"+
|
||||
"t\u0000\u0000i\u0012\u0001\u0000\u0000\u0000jk\u0005b\u0000\u0000kl\u0005"+
|
||||
"o\u0000\u0000lm\u0005o\u0000\u0000mn\u0005l\u0000\u0000no\u0005e\u0000"+
|
||||
"\u0000op\u0005a\u0000\u0000pq\u0005n\u0000\u0000q\u0014\u0001\u0000\u0000"+
|
||||
"\u0000rs\u0005c\u0000\u0000st\u0005h\u0000\u0000tu\u0005a\u0000\u0000"+
|
||||
"uv\u0005r\u0000\u0000v\u0016\u0001\u0000\u0000\u0000wx\u0005p\u0000\u0000"+
|
||||
"xy\u0005u\u0000\u0000yz\u0005b\u0000\u0000z{\u0005l\u0000\u0000{|\u0005"+
|
||||
"i\u0000\u0000|}\u0005c\u0000\u0000}\u0018\u0001\u0000\u0000\u0000~\u007f"+
|
||||
"\u0005p\u0000\u0000\u007f\u0080\u0005r\u0000\u0000\u0080\u0081\u0005i"+
|
||||
"\u0000\u0000\u0081\u0082\u0005v\u0000\u0000\u0082\u0083\u0005a\u0000\u0000"+
|
||||
"\u0083\u0084\u0005t\u0000\u0000\u0084\u0085\u0005e\u0000\u0000\u0085\u001a"+
|
||||
"\u0001\u0000\u0000\u0000\u0086\u0087\u0005=\u0000\u0000\u0087\u001c\u0001"+
|
||||
"\u0000\u0000\u0000\u0088\u0089\u0005i\u0000\u0000\u0089\u008a\u0005f\u0000"+
|
||||
"\u0000\u008a\u001e\u0001\u0000\u0000\u0000\u008b\u008c\u0005e\u0000\u0000"+
|
||||
"\u008c\u008d\u0005l\u0000\u0000\u008d\u008e\u0005s\u0000\u0000\u008e\u008f"+
|
||||
"\u0005e\u0000\u0000\u008f \u0001\u0000\u0000\u0000\u0090\u0091\u0005w"+
|
||||
"\u0000\u0000\u0091\u0092\u0005h\u0000\u0000\u0092\u0093\u0005i\u0000\u0000"+
|
||||
"\u0093\u0094\u0005l\u0000\u0000\u0094\u0095\u0005e\u0000\u0000\u0095\""+
|
||||
"\u0001\u0000\u0000\u0000\u0096\u0097\u0005r\u0000\u0000\u0097\u0098\u0005"+
|
||||
"e\u0000\u0000\u0098\u0099\u0005t\u0000\u0000\u0099\u009a\u0005u\u0000"+
|
||||
"\u0000\u009a\u009b\u0005r\u0000\u0000\u009b\u009c\u0005n\u0000\u0000\u009c"+
|
||||
"$\u0001\u0000\u0000\u0000\u009d\u009e\u0005&\u0000\u0000\u009e\u009f\u0005"+
|
||||
"&\u0000\u0000\u009f&\u0001\u0000\u0000\u0000\u00a0\u00a1\u0005|\u0000"+
|
||||
"\u0000\u00a1\u00a2\u0005|\u0000\u0000\u00a2(\u0001\u0000\u0000\u0000\u00a3"+
|
||||
"\u00a4\u0005=\u0000\u0000\u00a4\u00a5\u0005=\u0000\u0000\u00a5*\u0001"+
|
||||
"\u0000\u0000\u0000\u00a6\u00a7\u0005!\u0000\u0000\u00a7\u00a8\u0005=\u0000"+
|
||||
"\u0000\u00a8,\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005<\u0000\u0000\u00aa"+
|
||||
".\u0001\u0000\u0000\u0000\u00ab\u00ac\u0005<\u0000\u0000\u00ac\u00ad\u0005"+
|
||||
"=\u0000\u0000\u00ad0\u0001\u0000\u0000\u0000\u00ae\u00af\u0005>\u0000"+
|
||||
"\u0000\u00af2\u0001\u0000\u0000\u0000\u00b0\u00b1\u0005>\u0000\u0000\u00b1"+
|
||||
"\u00b2\u0005=\u0000\u0000\u00b24\u0001\u0000\u0000\u0000\u00b3\u00b4\u0005"+
|
||||
"+\u0000\u0000\u00b46\u0001\u0000\u0000\u0000\u00b5\u00b6\u0005-\u0000"+
|
||||
"\u0000\u00b68\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005*\u0000\u0000\u00b8"+
|
||||
":\u0001\u0000\u0000\u0000\u00b9\u00ba\u0005/\u0000\u0000\u00ba<\u0001"+
|
||||
"\u0000\u0000\u0000\u00bb\u00bc\u0005%\u0000\u0000\u00bc>\u0001\u0000\u0000"+
|
||||
"\u0000\u00bd\u00be\u0005!\u0000\u0000\u00be@\u0001\u0000\u0000\u0000\u00bf"+
|
||||
"\u00c0\u0005t\u0000\u0000\u00c0\u00c1\u0005r\u0000\u0000\u00c1\u00c2\u0005"+
|
||||
"u\u0000\u0000\u00c2\u00c3\u0005e\u0000\u0000\u00c3B\u0001\u0000\u0000"+
|
||||
"\u0000\u00c4\u00c5\u0005f\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6"+
|
||||
"\u00c7\u0005l\u0000\u0000\u00c7\u00c8\u0005s\u0000\u0000\u00c8\u00c9\u0005"+
|
||||
"e\u0000\u0000\u00c9D\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005\'\u0000"+
|
||||
"\u0000\u00cbF\u0001\u0000\u0000\u0000\u00cc\u00ce\u0007\u0000\u0000\u0000"+
|
||||
"\u00cd\u00cc\u0001\u0000\u0000\u0000\u00ce\u00cf\u0001\u0000\u0000\u0000"+
|
||||
"\u00cf\u00cd\u0001\u0000\u0000\u0000\u00cf\u00d0\u0001\u0000\u0000\u0000"+
|
||||
"\u00d0H\u0001\u0000\u0000\u0000\u00d1\u00d5\u0007\u0001\u0000\u0000\u00d2"+
|
||||
"\u00d4\u0007\u0002\u0000\u0000\u00d3\u00d2\u0001\u0000\u0000\u0000\u00d4"+
|
||||
"\u00d7\u0001\u0000\u0000\u0000\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d5"+
|
||||
"\u00d6\u0001\u0000\u0000\u0000\u00d6J\u0001\u0000\u0000\u0000\u00d7\u00d5"+
|
||||
"\u0001\u0000\u0000\u0000\u00d8\u00da\u0007\u0003\u0000\u0000\u00d9\u00d8"+
|
||||
"\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00d9"+
|
||||
"\u0001\u0000\u0000\u0000\u00db\u00dc\u0001\u0000\u0000\u0000\u00dc\u00dd"+
|
||||
"\u0001\u0000\u0000\u0000\u00dd\u00de\u0006%\u0000\u0000\u00deL\u0001\u0000"+
|
||||
"\u0000\u0000\u0004\u0000\u00cf\u00d5\u00db\u0001\u0006\u0000\u0000";
|
||||
"\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+
|
||||
"O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+
|
||||
"\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+
|
||||
"\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+
|
||||
"c\u0001\u0000\u0000\u0000\u0000e\u0001\u0000\u0000\u0000\u0000g\u0001"+
|
||||
"\u0000\u0000\u0000\u0000i\u0001\u0000\u0000\u0000\u0001k\u0001\u0000\u0000"+
|
||||
"\u0000\u0003n\u0001\u0000\u0000\u0000\u0005q\u0001\u0000\u0000\u0000\u0007"+
|
||||
"v\u0001\u0000\u0000\u0000\t~\u0001\u0000\u0000\u0000\u000b\u0083\u0001"+
|
||||
"\u0000\u0000\u0000\r\u00af\u0001\u0000\u0000\u0000\u000f\u00b1\u0001\u0000"+
|
||||
"\u0000\u0000\u0011\u00db\u0001\u0000\u0000\u0000\u0013\u00df\u0001\u0000"+
|
||||
"\u0000\u0000\u0015\u00e7\u0001\u0000\u0000\u0000\u0017\u00eb\u0001\u0000"+
|
||||
"\u0000\u0000\u0019\u00ed\u0001\u0000\u0000\u0000\u001b\u00ef\u0001\u0000"+
|
||||
"\u0000\u0000\u001d\u00f1\u0001\u0000\u0000\u0000\u001f\u00f3\u0001\u0000"+
|
||||
"\u0000\u0000!\u00f5\u0001\u0000\u0000\u0000#\u00f7\u0001\u0000\u0000\u0000"+
|
||||
"%\u00f9\u0001\u0000\u0000\u0000\'\u00fb\u0001\u0000\u0000\u0000)\u00fd"+
|
||||
"\u0001\u0000\u0000\u0000+\u0100\u0001\u0000\u0000\u0000-\u0103\u0001\u0000"+
|
||||
"\u0000\u0000/\u0106\u0001\u0000\u0000\u00001\u0109\u0001\u0000\u0000\u0000"+
|
||||
"3\u010b\u0001\u0000\u0000\u00005\u010e\u0001\u0000\u0000\u00007\u0111"+
|
||||
"\u0001\u0000\u0000\u00009\u0113\u0001\u0000\u0000\u0000;\u0115\u0001\u0000"+
|
||||
"\u0000\u0000=\u0117\u0001\u0000\u0000\u0000?\u0119\u0001\u0000\u0000\u0000"+
|
||||
"A\u011b\u0001\u0000\u0000\u0000C\u011d\u0001\u0000\u0000\u0000E\u011f"+
|
||||
"\u0001\u0000\u0000\u0000G\u0125\u0001\u0000\u0000\u0000I\u012a\u0001\u0000"+
|
||||
"\u0000\u0000K\u0130\u0001\u0000\u0000\u0000M\u0133\u0001\u0000\u0000\u0000"+
|
||||
"O\u0138\u0001\u0000\u0000\u0000Q\u013c\u0001\u0000\u0000\u0000S\u0143"+
|
||||
"\u0001\u0000\u0000\u0000U\u0147\u0001\u0000\u0000\u0000W\u0151\u0001\u0000"+
|
||||
"\u0000\u0000Y\u0161\u0001\u0000\u0000\u0000[\u0163\u0001\u0000\u0000\u0000"+
|
||||
"]\u0168\u0001\u0000\u0000\u0000_\u016a\u0001\u0000\u0000\u0000a\u016f"+
|
||||
"\u0001\u0000\u0000\u0000c\u0171\u0001\u0000\u0000\u0000e\u0179\u0001\u0000"+
|
||||
"\u0000\u0000g\u017f\u0001\u0000\u0000\u0000i\u018a\u0001\u0000\u0000\u0000"+
|
||||
"kl\u0005+\u0000\u0000lm\u0005+\u0000\u0000m\u0002\u0001\u0000\u0000\u0000"+
|
||||
"no\u0005-\u0000\u0000op\u0005-\u0000\u0000p\u0004\u0001\u0000\u0000\u0000"+
|
||||
"qr\u0005v\u0000\u0000rs\u0005o\u0000\u0000st\u0005i\u0000\u0000tu\u0005"+
|
||||
"d\u0000\u0000u\u0006\u0001\u0000\u0000\u0000vw\u0005b\u0000\u0000wx\u0005"+
|
||||
"o\u0000\u0000xy\u0005o\u0000\u0000yz\u0005l\u0000\u0000z{\u0005e\u0000"+
|
||||
"\u0000{|\u0005a\u0000\u0000|}\u0005n\u0000\u0000}\b\u0001\u0000\u0000"+
|
||||
"\u0000~\u007f\u0005c\u0000\u0000\u007f\u0080\u0005h\u0000\u0000\u0080"+
|
||||
"\u0081\u0005a\u0000\u0000\u0081\u0082\u0005r\u0000\u0000\u0082\n\u0001"+
|
||||
"\u0000\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+
|
||||
"\u0000\u0085\u0086\u0005t\u0000\u0000\u0086\f\u0001\u0000\u0000\u0000"+
|
||||
"\u0087\u0088\u0005p\u0000\u0000\u0088\u0089\u0005u\u0000\u0000\u0089\u008a"+
|
||||
"\u0005b\u0000\u0000\u008a\u008b\u0005l\u0000\u0000\u008b\u008c\u0005i"+
|
||||
"\u0000\u0000\u008c\u00b0\u0005c\u0000\u0000\u008d\u008e\u0005p\u0000\u0000"+
|
||||
"\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005i\u0000\u0000\u0090\u0091"+
|
||||
"\u0005v\u0000\u0000\u0091\u0092\u0005a\u0000\u0000\u0092\u0093\u0005t"+
|
||||
"\u0000\u0000\u0093\u00b0\u0005e\u0000\u0000\u0094\u0095\u0005p\u0000\u0000"+
|
||||
"\u0095\u0096\u0005u\u0000\u0000\u0096\u0097\u0005b\u0000\u0000\u0097\u0098"+
|
||||
"\u0005l\u0000\u0000\u0098\u0099\u0005i\u0000\u0000\u0099\u009a\u0005c"+
|
||||
"\u0000\u0000\u009a\u009b\u0005 \u0000\u0000\u009b\u009c\u0005s\u0000\u0000"+
|
||||
"\u009c\u009d\u0005t\u0000\u0000\u009d\u009e\u0005a\u0000\u0000\u009e\u009f"+
|
||||
"\u0005t\u0000\u0000\u009f\u00a0\u0005i\u0000\u0000\u00a0\u00b0\u0005c"+
|
||||
"\u0000\u0000\u00a1\u00a2\u0005p\u0000\u0000\u00a2\u00a3\u0005r\u0000\u0000"+
|
||||
"\u00a3\u00a4\u0005i\u0000\u0000\u00a4\u00a5\u0005v\u0000\u0000\u00a5\u00a6"+
|
||||
"\u0005a\u0000\u0000\u00a6\u00a7\u0005t\u0000\u0000\u00a7\u00a8\u0005e"+
|
||||
"\u0000\u0000\u00a8\u00a9\u0005 \u0000\u0000\u00a9\u00aa\u0005s\u0000\u0000"+
|
||||
"\u00aa\u00ab\u0005t\u0000\u0000\u00ab\u00ac\u0005a\u0000\u0000\u00ac\u00ad"+
|
||||
"\u0005t\u0000\u0000\u00ad\u00ae\u0005i\u0000\u0000\u00ae\u00b0\u0005c"+
|
||||
"\u0000\u0000\u00af\u0087\u0001\u0000\u0000\u0000\u00af\u008d\u0001\u0000"+
|
||||
"\u0000\u0000\u00af\u0094\u0001\u0000\u0000\u0000\u00af\u00a1\u0001\u0000"+
|
||||
"\u0000\u0000\u00b0\u000e\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005p\u0000"+
|
||||
"\u0000\u00b2\u00b3\u0005u\u0000\u0000\u00b3\u00b4\u0005b\u0000\u0000\u00b4"+
|
||||
"\u00b5\u0005l\u0000\u0000\u00b5\u00b6\u0005i\u0000\u0000\u00b6\u00b7\u0005"+
|
||||
"c\u0000\u0000\u00b7\u00b8\u0005 \u0000\u0000\u00b8\u00b9\u0005s\u0000"+
|
||||
"\u0000\u00b9\u00ba\u0005t\u0000\u0000\u00ba\u00bb\u0005a\u0000\u0000\u00bb"+
|
||||
"\u00bc\u0005t\u0000\u0000\u00bc\u00bd\u0005i\u0000\u0000\u00bd\u00be\u0005"+
|
||||
"c\u0000\u0000\u00be\u00bf\u0005 \u0000\u0000\u00bf\u00c0\u0005v\u0000"+
|
||||
"\u0000\u00c0\u00c1\u0005o\u0000\u0000\u00c1\u00c2\u0005i\u0000\u0000\u00c2"+
|
||||
"\u00c3\u0005d\u0000\u0000\u00c3\u00c4\u0005 \u0000\u0000\u00c4\u00c5\u0005"+
|
||||
"m\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6\u00c7\u0005i\u0000"+
|
||||
"\u0000\u00c7\u00c8\u0005n\u0000\u0000\u00c8\u00c9\u0005(\u0000\u0000\u00c9"+
|
||||
"\u00ca\u0005S\u0000\u0000\u00ca\u00cb\u0005t\u0000\u0000\u00cb\u00cc\u0005"+
|
||||
"r\u0000\u0000\u00cc\u00cd\u0005i\u0000\u0000\u00cd\u00ce\u0005n\u0000"+
|
||||
"\u0000\u00ce\u00cf\u0005g\u0000\u0000\u00cf\u00d0\u0005[\u0000\u0000\u00d0"+
|
||||
"\u00d1\u0005]\u0000\u0000\u00d1\u00d2\u0005 \u0000\u0000\u00d2\u00d3\u0005"+
|
||||
"a\u0000\u0000\u00d3\u00d4\u0005r\u0000\u0000\u00d4\u00d5\u0005g\u0000"+
|
||||
"\u0000\u00d5\u00d6\u0005s\u0000\u0000\u00d6\u00d7\u0005)\u0000\u0000\u00d7"+
|
||||
"\u0010\u0001\u0000\u0000\u0000\u00d8\u00dc\u0003\u001f\u000f\u0000\u00d9"+
|
||||
"\u00dc\u0003#\u0011\u0000\u00da\u00dc\u0003!\u0010\u0000\u00db\u00d8\u0001"+
|
||||
"\u0000\u0000\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00db\u00da\u0001"+
|
||||
"\u0000\u0000\u0000\u00dc\u0012\u0001\u0000\u0000\u0000\u00dd\u00e0\u0003"+
|
||||
"\u001b\r\u0000\u00de\u00e0\u0003\u001d\u000e\u0000\u00df\u00dd\u0001\u0000"+
|
||||
"\u0000\u0000\u00df\u00de\u0001\u0000\u0000\u0000\u00e0\u0014\u0001\u0000"+
|
||||
"\u0000\u0000\u00e1\u00e8\u0003%\u0012\u0000\u00e2\u00e8\u0003\'\u0013"+
|
||||
"\u0000\u00e3\u00e8\u0003)\u0014\u0000\u00e4\u00e8\u0003+\u0015\u0000\u00e5"+
|
||||
"\u00e8\u0003-\u0016\u0000\u00e6\u00e8\u0003/\u0017\u0000\u00e7\u00e1\u0001"+
|
||||
"\u0000\u0000\u0000\u00e7\u00e2\u0001\u0000\u0000\u0000\u00e7\u00e3\u0001"+
|
||||
"\u0000\u0000\u0000\u00e7\u00e4\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001"+
|
||||
"\u0000\u0000\u0000\u00e7\u00e6\u0001\u0000\u0000\u0000\u00e8\u0016\u0001"+
|
||||
"\u0000\u0000\u0000\u00e9\u00ec\u00033\u0019\u0000\u00ea\u00ec\u00035\u001a"+
|
||||
"\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb\u00ea\u0001\u0000\u0000"+
|
||||
"\u0000\u00ec\u0018\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005=\u0000\u0000"+
|
||||
"\u00ee\u001a\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005+\u0000\u0000\u00f0"+
|
||||
"\u001c\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005-\u0000\u0000\u00f2\u001e"+
|
||||
"\u0001\u0000\u0000\u0000\u00f3\u00f4\u0005*\u0000\u0000\u00f4 \u0001\u0000"+
|
||||
"\u0000\u0000\u00f5\u00f6\u0005%\u0000\u0000\u00f6\"\u0001\u0000\u0000"+
|
||||
"\u0000\u00f7\u00f8\u0005/\u0000\u0000\u00f8$\u0001\u0000\u0000\u0000\u00f9"+
|
||||
"\u00fa\u0005>\u0000\u0000\u00fa&\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005"+
|
||||
"<\u0000\u0000\u00fc(\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005>\u0000"+
|
||||
"\u0000\u00fe\u00ff\u0005=\u0000\u0000\u00ff*\u0001\u0000\u0000\u0000\u0100"+
|
||||
"\u0101\u0005<\u0000\u0000\u0101\u0102\u0005=\u0000\u0000\u0102,\u0001"+
|
||||
"\u0000\u0000\u0000\u0103\u0104\u0005=\u0000\u0000\u0104\u0105\u0005=\u0000"+
|
||||
"\u0000\u0105.\u0001\u0000\u0000\u0000\u0106\u0107\u0005!\u0000\u0000\u0107"+
|
||||
"\u0108\u0005=\u0000\u0000\u01080\u0001\u0000\u0000\u0000\u0109\u010a\u0005"+
|
||||
"!\u0000\u0000\u010a2\u0001\u0000\u0000\u0000\u010b\u010c\u0005&\u0000"+
|
||||
"\u0000\u010c\u010d\u0005&\u0000\u0000\u010d4\u0001\u0000\u0000\u0000\u010e"+
|
||||
"\u010f\u0005|\u0000\u0000\u010f\u0110\u0005|\u0000\u0000\u01106\u0001"+
|
||||
"\u0000\u0000\u0000\u0111\u0112\u0005.\u0000\u0000\u01128\u0001\u0000\u0000"+
|
||||
"\u0000\u0113\u0114\u0005(\u0000\u0000\u0114:\u0001\u0000\u0000\u0000\u0115"+
|
||||
"\u0116\u0005)\u0000\u0000\u0116<\u0001\u0000\u0000\u0000\u0117\u0118\u0005"+
|
||||
"{\u0000\u0000\u0118>\u0001\u0000\u0000\u0000\u0119\u011a\u0005}\u0000"+
|
||||
"\u0000\u011a@\u0001\u0000\u0000\u0000\u011b\u011c\u0005;\u0000\u0000\u011c"+
|
||||
"B\u0001\u0000\u0000\u0000\u011d\u011e\u0005,\u0000\u0000\u011eD\u0001"+
|
||||
"\u0000\u0000\u0000\u011f\u0120\u0005c\u0000\u0000\u0120\u0121\u0005l\u0000"+
|
||||
"\u0000\u0121\u0122\u0005a\u0000\u0000\u0122\u0123\u0005s\u0000\u0000\u0123"+
|
||||
"\u0124\u0005s\u0000\u0000\u0124F\u0001\u0000\u0000\u0000\u0125\u0126\u0005"+
|
||||
"t\u0000\u0000\u0126\u0127\u0005h\u0000\u0000\u0127\u0128\u0005i\u0000"+
|
||||
"\u0000\u0128\u0129\u0005s\u0000\u0000\u0129H\u0001\u0000\u0000\u0000\u012a"+
|
||||
"\u012b\u0005w\u0000\u0000\u012b\u012c\u0005h\u0000\u0000\u012c\u012d\u0005"+
|
||||
"i\u0000\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005e\u0000"+
|
||||
"\u0000\u012fJ\u0001\u0000\u0000\u0000\u0130\u0131\u0005i\u0000\u0000\u0131"+
|
||||
"\u0132\u0005f\u0000\u0000\u0132L\u0001\u0000\u0000\u0000\u0133\u0134\u0005"+
|
||||
"e\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136\u0005s\u0000"+
|
||||
"\u0000\u0136\u0137\u0005e\u0000\u0000\u0137N\u0001\u0000\u0000\u0000\u0138"+
|
||||
"\u0139\u0005f\u0000\u0000\u0139\u013a\u0005o\u0000\u0000\u013a\u013b\u0005"+
|
||||
"r\u0000\u0000\u013bP\u0001\u0000\u0000\u0000\u013c\u013d\u0005r\u0000"+
|
||||
"\u0000\u013d\u013e\u0005e\u0000\u0000\u013e\u013f\u0005t\u0000\u0000\u013f"+
|
||||
"\u0140\u0005u\u0000\u0000\u0140\u0141\u0005r\u0000\u0000\u0141\u0142\u0005"+
|
||||
"n\u0000\u0000\u0142R\u0001\u0000\u0000\u0000\u0143\u0144\u0005n\u0000"+
|
||||
"\u0000\u0144\u0145\u0005e\u0000\u0000\u0145\u0146\u0005w\u0000\u0000\u0146"+
|
||||
"T\u0001\u0000\u0000\u0000\u0147\u014b\u0005\'\u0000\u0000\u0148\u014a"+
|
||||
"\b\u0000\u0000\u0000\u0149\u0148\u0001\u0000\u0000\u0000\u014a\u014d\u0001"+
|
||||
"\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000\u014b\u014c\u0001"+
|
||||
"\u0000\u0000\u0000\u014c\u014e\u0001\u0000\u0000\u0000\u014d\u014b\u0001"+
|
||||
"\u0000\u0000\u0000\u014e\u014f\u0005\'\u0000\u0000\u014fV\u0001\u0000"+
|
||||
"\u0000\u0000\u0150\u0152\u0003\u001d\u000e\u0000\u0151\u0150\u0001\u0000"+
|
||||
"\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u0154\u0001\u0000"+
|
||||
"\u0000\u0000\u0153\u0155\u0003_/\u0000\u0154\u0153\u0001\u0000\u0000\u0000"+
|
||||
"\u0155\u0156\u0001\u0000\u0000\u0000\u0156\u0154\u0001\u0000\u0000\u0000"+
|
||||
"\u0156\u0157\u0001\u0000\u0000\u0000\u0157X\u0001\u0000\u0000\u0000\u0158"+
|
||||
"\u0159\u0005t\u0000\u0000\u0159\u015a\u0005r\u0000\u0000\u015a\u015b\u0005"+
|
||||
"u\u0000\u0000\u015b\u0162\u0005e\u0000\u0000\u015c\u015d\u0005f\u0000"+
|
||||
"\u0000\u015d\u015e\u0005a\u0000\u0000\u015e\u015f\u0005l\u0000\u0000\u015f"+
|
||||
"\u0160\u0005s\u0000\u0000\u0160\u0162\u0005e\u0000\u0000\u0161\u0158\u0001"+
|
||||
"\u0000\u0000\u0000\u0161\u015c\u0001\u0000\u0000\u0000\u0162Z\u0001\u0000"+
|
||||
"\u0000\u0000\u0163\u0164\u0005n\u0000\u0000\u0164\u0165\u0005u\u0000\u0000"+
|
||||
"\u0165\u0166\u0005l\u0000\u0000\u0166\u0167\u0005l\u0000\u0000\u0167\\"+
|
||||
"\u0001\u0000\u0000\u0000\u0168\u0169\u0007\u0001\u0000\u0000\u0169^\u0001"+
|
||||
"\u0000\u0000\u0000\u016a\u016b\u0007\u0002\u0000\u0000\u016b`\u0001\u0000"+
|
||||
"\u0000\u0000\u016c\u0170\u0003].\u0000\u016d\u0170\u0003_/\u0000\u016e"+
|
||||
"\u0170\u0007\u0003\u0000\u0000\u016f\u016c\u0001\u0000\u0000\u0000\u016f"+
|
||||
"\u016d\u0001\u0000\u0000\u0000\u016f\u016e\u0001\u0000\u0000\u0000\u0170"+
|
||||
"b\u0001\u0000\u0000\u0000\u0171\u0175\u0003].\u0000\u0172\u0174\u0003"+
|
||||
"a0\u0000\u0173\u0172\u0001\u0000\u0000\u0000\u0174\u0177\u0001\u0000\u0000"+
|
||||
"\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0176\u0001\u0000\u0000"+
|
||||
"\u0000\u0176d\u0001\u0000\u0000\u0000\u0177\u0175\u0001\u0000\u0000\u0000"+
|
||||
"\u0178\u017a\u0007\u0004\u0000\u0000\u0179\u0178\u0001\u0000\u0000\u0000"+
|
||||
"\u017a\u017b\u0001\u0000\u0000\u0000\u017b\u0179\u0001\u0000\u0000\u0000"+
|
||||
"\u017b\u017c\u0001\u0000\u0000\u0000\u017c\u017d\u0001\u0000\u0000\u0000"+
|
||||
"\u017d\u017e\u00062\u0000\u0000\u017ef\u0001\u0000\u0000\u0000\u017f\u0180"+
|
||||
"\u0005/\u0000\u0000\u0180\u0181\u0005/\u0000\u0000\u0181\u0185\u0001\u0000"+
|
||||
"\u0000\u0000\u0182\u0184\b\u0000\u0000\u0000\u0183\u0182\u0001\u0000\u0000"+
|
||||
"\u0000\u0184\u0187\u0001\u0000\u0000\u0000\u0185\u0183\u0001\u0000\u0000"+
|
||||
"\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0188\u0001\u0000\u0000"+
|
||||
"\u0000\u0187\u0185\u0001\u0000\u0000\u0000\u0188\u0189\u00063\u0000\u0000"+
|
||||
"\u0189h\u0001\u0000\u0000\u0000\u018a\u018b\u0005/\u0000\u0000\u018b\u018c"+
|
||||
"\u0005*\u0000\u0000\u018c\u0190\u0001\u0000\u0000\u0000\u018d\u018f\t"+
|
||||
"\u0000\u0000\u0000\u018e\u018d\u0001\u0000\u0000\u0000\u018f\u0192\u0001"+
|
||||
"\u0000\u0000\u0000\u0190\u0191\u0001\u0000\u0000\u0000\u0190\u018e\u0001"+
|
||||
"\u0000\u0000\u0000\u0191\u0193\u0001\u0000\u0000\u0000\u0192\u0190\u0001"+
|
||||
"\u0000\u0000\u0000\u0193\u0194\u0005*\u0000\u0000\u0194\u0195\u0005/\u0000"+
|
||||
"\u0000\u0195\u0196\u0001\u0000\u0000\u0000\u0196\u0197\u00064\u0000\u0000"+
|
||||
"\u0197j\u0001\u0000\u0000\u0000\u000f\u0000\u00af\u00db\u00df\u00e7\u00eb"+
|
||||
"\u014b\u0151\u0156\u0161\u016f\u0175\u017b\u0185\u0190\u0001\u0006\u0000"+
|
||||
"\u0000";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@ -1,73 +1,88 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
INTEGERLITERAL=36
|
||||
IDENTIFIER=37
|
||||
WS=38
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
||||
';'=4
|
||||
'static'=5
|
||||
'('=6
|
||||
')'=7
|
||||
','=8
|
||||
'int'=9
|
||||
'boolean'=10
|
||||
'char'=11
|
||||
'public'=12
|
||||
'private'=13
|
||||
'='=14
|
||||
'if'=15
|
||||
'else'=16
|
||||
'while'=17
|
||||
'return'=18
|
||||
'&&'=19
|
||||
'||'=20
|
||||
'=='=21
|
||||
'!='=22
|
||||
'<'=23
|
||||
'<='=24
|
||||
'>'=25
|
||||
'>='=26
|
||||
'+'=27
|
||||
'-'=28
|
||||
'*'=29
|
||||
'/'=30
|
||||
'%'=31
|
||||
'!'=32
|
||||
'true'=33
|
||||
'false'=34
|
||||
'\''=35
|
||||
Void=3
|
||||
Boolean=4
|
||||
Char=5
|
||||
Int=6
|
||||
AccessModifier=7
|
||||
MainMethodDeclaration=8
|
||||
DotOperator=9
|
||||
LineOperator=10
|
||||
ComparisonOperator=11
|
||||
LogicalOperator=12
|
||||
Assign=13
|
||||
Plus=14
|
||||
Minus=15
|
||||
Mult=16
|
||||
Modulo=17
|
||||
Div=18
|
||||
Greater=19
|
||||
Less=20
|
||||
GreaterEqual=21
|
||||
LessEqual=22
|
||||
Equal=23
|
||||
NotEqual=24
|
||||
Not=25
|
||||
And=26
|
||||
Or=27
|
||||
Dot=28
|
||||
OpenRoundBracket=29
|
||||
ClosedRoundBracket=30
|
||||
OpenCurlyBracket=31
|
||||
ClosedCurlyBracket=32
|
||||
Semicolon=33
|
||||
Comma=34
|
||||
Class=35
|
||||
This=36
|
||||
While=37
|
||||
If=38
|
||||
Else=39
|
||||
For=40
|
||||
Return=41
|
||||
New=42
|
||||
CharValue=43
|
||||
IntValue=44
|
||||
BooleanValue=45
|
||||
NullValue=46
|
||||
Identifier=47
|
||||
WS=48
|
||||
InlineComment=49
|
||||
MultilineComment=50
|
||||
'++'=1
|
||||
'--'=2
|
||||
'void'=3
|
||||
'boolean'=4
|
||||
'char'=5
|
||||
'int'=6
|
||||
'public static void main(String[] args)'=8
|
||||
'='=13
|
||||
'+'=14
|
||||
'-'=15
|
||||
'*'=16
|
||||
'%'=17
|
||||
'/'=18
|
||||
'>'=19
|
||||
'<'=20
|
||||
'>='=21
|
||||
'<='=22
|
||||
'=='=23
|
||||
'!='=24
|
||||
'!'=25
|
||||
'&&'=26
|
||||
'||'=27
|
||||
'.'=28
|
||||
'('=29
|
||||
')'=30
|
||||
'{'=31
|
||||
'}'=32
|
||||
';'=33
|
||||
','=34
|
||||
'class'=35
|
||||
'this'=36
|
||||
'while'=37
|
||||
'if'=38
|
||||
'else'=39
|
||||
'for'=40
|
||||
'return'=41
|
||||
'new'=42
|
||||
'null'=46
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
@ -37,6 +37,16 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
@ -57,16 +67,6 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
@ -88,25 +88,15 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
*/
|
||||
void exitParameter(SimpleJavaParser.ParameterContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#argumentList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterType(SimpleJavaParser.TypeContext ctx);
|
||||
void enterArgumentList(SimpleJavaParser.ArgumentListContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#argumentList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
void exitArgumentList(SimpleJavaParser.ArgumentListContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
@ -118,55 +108,15 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
*/
|
||||
void exitStatement(SimpleJavaParser.StatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
void enterBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#var}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterVar(SimpleJavaParser.VarContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#var}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitVar(SimpleJavaParser.VarContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
void exitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}.
|
||||
* @param ctx the parse tree
|
||||
@ -178,15 +128,95 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
*/
|
||||
void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBlock(SimpleJavaParser.BlockContext ctx);
|
||||
void enterLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
void exitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#forStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterForStatement(SimpleJavaParser.ForStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#forStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitForStatement(SimpleJavaParser.ForStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#ifElseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#elseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterElseStatement(SimpleJavaParser.ElseStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#elseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#statementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterStatementExpression(SimpleJavaParser.StatementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#statementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#assign}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAssign(SimpleJavaParser.AssignContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#assign}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAssign(SimpleJavaParser.AssignContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#newDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#newDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#expression}.
|
||||
* @param ctx the parse tree
|
||||
@ -198,33 +228,223 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
*/
|
||||
void exitExpression(SimpleJavaParser.ExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#unaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
void enterUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#unaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
void exitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#notExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
void enterNotExpression(SimpleJavaParser.NotExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#notExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
void exitNotExpression(SimpleJavaParser.NotExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#crementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
void enterCrementExpression(SimpleJavaParser.CrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#crementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
void exitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#incrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#incrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#decrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#decrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#assignableExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#assignableExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#memberAccess}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMemberAccess(SimpleJavaParser.MemberAccessContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#memberAccess}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMemberAccess(SimpleJavaParser.MemberAccessContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#binaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#binaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#calculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#calculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#dotExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDotExpression(SimpleJavaParser.DotExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#dotExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDotExpression(SimpleJavaParser.DotExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#methodCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMethodCall(SimpleJavaParser.MethodCallContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#methodCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMethodCall(SimpleJavaParser.MethodCallContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#target}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterTarget(SimpleJavaParser.TargetContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#target}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitTarget(SimpleJavaParser.TargetContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#chainedMethod}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterChainedMethod(SimpleJavaParser.ChainedMethodContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#chainedMethod}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterValue(SimpleJavaParser.ValueContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitValue(SimpleJavaParser.ValueContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/Johannes/Documents/Github/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
@ -28,6 +28,12 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
@ -40,12 +46,6 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
@ -59,17 +59,11 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
*/
|
||||
T visitParameter(SimpleJavaParser.ParameterContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#argumentList}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
T visitArgumentList(SimpleJavaParser.ArgumentListContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
@ -77,35 +71,11 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
*/
|
||||
T visitStatement(SimpleJavaParser.StatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#var}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitVar(SimpleJavaParser.VarContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
T visitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}.
|
||||
* @param ctx the parse tree
|
||||
@ -113,11 +83,59 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
*/
|
||||
T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#localVariableDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
T visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#forStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitForStatement(SimpleJavaParser.ForStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#ifElseStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#elseStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#statementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#assign}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAssign(SimpleJavaParser.AssignContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#newDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#expression}.
|
||||
* @param ctx the parse tree
|
||||
@ -125,21 +143,135 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
*/
|
||||
T visitExpression(SimpleJavaParser.ExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#unaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
T visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#notExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
T visitNotExpression(SimpleJavaParser.NotExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#crementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
T visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#incrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#prefixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#suffixIncrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#decrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#prefixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#suffixDecrementExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#assignableExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#memberAccess}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#binaryExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#calculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#dotExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitDotExpression(SimpleJavaParser.DotExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#dotSubtractionExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationExpression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#methodCall}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMethodCall(SimpleJavaParser.MethodCallContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#target}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitTarget(SimpleJavaParser.TargetContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#chainedMethod}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#value}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitValue(SimpleJavaParser.ValueContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#nonCalculationOperator}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitNonCalculationOperator(SimpleJavaParser.NonCalculationOperatorContext ctx);
|
||||
}
|
168
src/main/java/parser/grammar/SimpleJava.g4
Normal file
168
src/main/java/parser/grammar/SimpleJava.g4
Normal 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;
|
@ -1,27 +1,35 @@
|
||||
package semantic;
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.exeptions.AlreadyDeclearedException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
|
||||
public class Scope {
|
||||
|
||||
private Stack<HashMap<String, TypeNode>> localVars;
|
||||
private Stack<HashMap<String, ITypeNode>> localVars;
|
||||
|
||||
public Scope() {
|
||||
localVars = new Stack<HashMap<String, TypeNode>>();
|
||||
localVars = new Stack<HashMap<String, ITypeNode>>();
|
||||
}
|
||||
|
||||
public void addLocalVar(String name, TypeNode type) {
|
||||
public void addLocalVar(String name, ITypeNode type) {
|
||||
if (this.contains(name)) {
|
||||
throw new RuntimeException("Variable " + name + " already exists in this scope");
|
||||
throw new AlreadyDeclearedException("Variable " + name + " already exists in this scope");
|
||||
}
|
||||
localVars.peek().put(name, type);
|
||||
}
|
||||
|
||||
public ITypeNode getLocalVar(String name) {
|
||||
for (HashMap<String, ITypeNode> map : localVars) {
|
||||
return map.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean contains(String name) {
|
||||
for (HashMap<String, TypeNode> map : localVars) {
|
||||
for (HashMap<String, ITypeNode> map : localVars) {
|
||||
if (map.containsKey(name)) {
|
||||
return true;
|
||||
}
|
||||
@ -30,7 +38,7 @@ public class Scope {
|
||||
}
|
||||
|
||||
public void pushScope() {
|
||||
localVars.push(new HashMap<String, TypeNode>());
|
||||
localVars.push(new HashMap<String, ITypeNode>());
|
||||
}
|
||||
|
||||
public void popScope() {
|
||||
|
@ -1,33 +1,44 @@
|
||||
package semantic;
|
||||
|
||||
|
||||
import ast.*;
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.IdentifierExpressionNode;
|
||||
import ast.expression.UnaryExpressionNode;
|
||||
import ast.member.ConstructorNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MemberNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import ast.member.MethodNode;
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.*;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.IExpressionNode;
|
||||
import ast.expression.binaryexpression.*;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
import ast.member.*;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import semantic.exeptions.AlreadyDeclearedException;
|
||||
import ast.statement.ifstatement.ElseStatementNode;
|
||||
import ast.statement.ifstatement.IfElseStatementNode;
|
||||
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.DecrementExpressionNode;
|
||||
import ast.statement.statementexpression.crementExpression.IncrementExpressionNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import semantic.context.Context;
|
||||
import semantic.exeptions.*;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
private static ArrayList<String> currentFields = new ArrayList<>();
|
||||
private static HashMap<String, ITypeNode> currentFields = new HashMap<>();
|
||||
|
||||
public static ArrayList<Exception> errors = new ArrayList<>();
|
||||
|
||||
private static Context context;
|
||||
private static Scope currentScope;
|
||||
private static ClassNode currentClass;
|
||||
private static ITypeNode currentNullType;
|
||||
private ITypeNode currentMethodReturnType;
|
||||
|
||||
public static ASTNode generateTast(ASTNode node) {
|
||||
SemanticAnalyzer semanticCheck = new SemanticAnalyzer();
|
||||
@ -43,7 +54,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void clearAnalyzier(){
|
||||
public static void clearAnalyzer() {
|
||||
currentFields.clear();
|
||||
errors.clear();
|
||||
currentScope = null;
|
||||
@ -56,6 +67,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
var valid = true;
|
||||
|
||||
currentScope = new Scope();
|
||||
context = new Context(node);
|
||||
|
||||
List<ClassNode> classes = node.classes;
|
||||
for (ClassNode classNode : classes) {
|
||||
@ -70,7 +82,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
var valid = true;
|
||||
|
||||
currentClass = classNode;
|
||||
|
||||
currentFields.clear();
|
||||
List<MemberNode> members = classNode.members;
|
||||
for (MemberNode memberNode : members) {
|
||||
if (memberNode instanceof FieldNode fieldNode) {
|
||||
@ -79,13 +91,10 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
valid = valid && result.isValid();
|
||||
} else if (memberNode instanceof MethodNode methodNode) {
|
||||
//Methods
|
||||
for(MethodNode methode : currentClass.getMethods()){
|
||||
if(methode.equals(methodNode))
|
||||
for (MethodNode methode : currentClass.getMethods()) {
|
||||
if (methode.equals(methodNode))
|
||||
break;
|
||||
if(methode.isSame(methodNode)){
|
||||
errors.add(new AlreadyDeclearedException("This method has already been declared"));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
var result = methodNode.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
@ -98,95 +107,87 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(MethodNode methodNode) {
|
||||
var valid = true;
|
||||
if (methodNode instanceof ConstructorNode) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.VOID));
|
||||
} else {
|
||||
|
||||
currentScope.pushScope();
|
||||
var valid = true;
|
||||
|
||||
//Parameter
|
||||
ParameterListNode parameterListNode = methodNode.parameters;
|
||||
if (parameterListNode != null) {
|
||||
List<ParameterNode> parameters = parameterListNode.parameters;
|
||||
for (ParameterNode parameter : parameters) {
|
||||
if (currentScope.contains(parameter.identifier)) {
|
||||
errors.add(new AlreadyDeclearedException("Duplicated Parameter " + parameter.identifier));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
currentScope.addLocalVar(parameter.identifier, parameter.type);
|
||||
for (var otherMethod : currentClass.getMethods()) {
|
||||
if (Objects.equals(otherMethod, methodNode))
|
||||
break;
|
||||
if (otherMethod.isSame(methodNode)) {
|
||||
errors.add(new AlreadyDeclearedException(
|
||||
"Method " + methodNode.getIdentifier() + " is already defined in class "
|
||||
+ currentClass.identifier));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Statements
|
||||
List<StatementNode> statements = methodNode.statements;
|
||||
for (StatementNode statement : statements) {
|
||||
if (statement instanceof AssignmentStatementNode assignmentStatementNode) {
|
||||
var result = assignmentStatementNode.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
} else if (statement instanceof VariableDeclarationStatementNode variableDeclarationStatementNode) {
|
||||
var result = variableDeclarationStatementNode.accept(this);
|
||||
currentScope.pushScope();
|
||||
for (var parameter : methodNode.getParameters()) {
|
||||
var result = parameter.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
try {
|
||||
currentScope.addLocalVar(parameter.identifier, parameter.type);
|
||||
} catch (AlreadyDeclearedException e) {
|
||||
errors.add(new AlreadyDeclearedException(parameter.identifier));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Check if this method is already declared
|
||||
|
||||
currentScope.popScope();
|
||||
return new TypeCheckResult(valid, null);
|
||||
currentMethodReturnType = methodNode.getType();
|
||||
currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ
|
||||
|
||||
ITypeNode resultType = new BaseType(TypeEnum.VOID);
|
||||
|
||||
// gesetzt ist, ist dieser der Rückgabewert der Methode
|
||||
var result = methodNode.block.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
currentScope.popScope();
|
||||
resultType = result.getType();
|
||||
|
||||
if (resultType == null) {
|
||||
resultType = new BaseType(TypeEnum.VOID);
|
||||
}
|
||||
if (!resultType.equals(methodNode.getType())) {
|
||||
errors.add(new TypeMismatchException("Method-Declaration " + methodNode.getIdentifier() + " with type "
|
||||
+ methodNode.getType() + " has at least one Mismatching return Type:"));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return new TypeCheckResult(valid, resultType);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(FieldNode toCheck) {
|
||||
if (currentFields.contains(toCheck.identifier)) {
|
||||
if (currentFields.get(toCheck.identifier) != null) {
|
||||
errors.add(new AlreadyDeclearedException("Already declared " + toCheck.identifier));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
currentFields.add(toCheck.identifier);
|
||||
}
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignmentStatementNode assignmentStatementNode) {
|
||||
boolean valid = true;
|
||||
BinaryExpressionNode binaryExpressionNode = assignmentStatementNode.expression;
|
||||
var result = binaryExpressionNode.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(BinaryExpressionNode toCheck) {
|
||||
boolean valid = true;
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IdentifierExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(UnaryExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(VariableDeclarationStatementNode toCheck) {
|
||||
if (currentScope.contains(toCheck.identifier)) {
|
||||
errors.add(new AlreadyDeclearedException("Already declared " + toCheck.identifier + " in this scope"));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
currentScope.addLocalVar(toCheck.identifier, toCheck.type);
|
||||
currentFields.put(toCheck.identifier, toCheck.type);
|
||||
}
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfStatementNode toCheck) {
|
||||
return null;
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ReturnStatementNode toCheck) {
|
||||
return null;
|
||||
|
||||
if(toCheck.expression != null){
|
||||
var result = toCheck.expression.accept(this);
|
||||
return new TypeCheckResult(true, result.getType());
|
||||
} else {
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,4 +195,176 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ParameterNode toCheck) {
|
||||
|
||||
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(BlockNode blockNode) {
|
||||
ITypeNode blockReturnType = null;
|
||||
for (IStatementNode statementNode : blockNode.statements) {
|
||||
var result = statementNode.accept(this);
|
||||
if(result.getType() != null){
|
||||
if(blockReturnType == null){
|
||||
blockReturnType = result.getType();
|
||||
} else {
|
||||
errors.add(new MultipleReturnTypes("There are multiple Return types"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TypeCheckResult(true, blockReturnType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignableExpressionNode toCheck) {
|
||||
return new TypeCheckResult(true, currentFields.get(toCheck.identifier));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ElseStatementNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ForStatementNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignStatementExpressionNode toCheck) {
|
||||
AssignableExpressionNode assignable = toCheck.assignable;
|
||||
var oldNullType = currentNullType;
|
||||
currentNullType = currentFields.get(toCheck.assignable.identifier);
|
||||
IExpressionNode rExpression = toCheck.expression;
|
||||
currentNullType = oldNullType;
|
||||
var valid = true;
|
||||
|
||||
// This check currently handles things like :
|
||||
/**
|
||||
* private int i;
|
||||
* void foo(int i){
|
||||
* i = i;
|
||||
* }
|
||||
*/
|
||||
if (assignable.equals(rExpression)) {
|
||||
errors.add(new TypeMismatchException("Cannot assign to self"));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
var lResult = assignable.accept(this);
|
||||
currentNullType = lResult.getType();
|
||||
var rResult = rExpression.accept(this);
|
||||
|
||||
if (!Objects.equals(currentScope.getLocalVar(toCheck.assignable.identifier), rExpression.getType())) {
|
||||
errors.add(new TypeMismatchException(
|
||||
"Mismatch types in Assign-Statement: cannot convert from \"" + lResult.getType() + "\" to \""
|
||||
+ rResult.getType() + "\""));
|
||||
valid = false;
|
||||
}
|
||||
// else {
|
||||
// toCheck.setType(assignable.getType());
|
||||
// }
|
||||
valid = valid && lResult.isValid() && rResult.isValid();
|
||||
currentNullType = null;
|
||||
return new TypeCheckResult(valid, null); // return type is null to get the return type sufficently
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DecrementExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfElseStatementNode toCheck) {
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(MethodCallStatementExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(LocalVariableDeclarationNode localVarDecl) {
|
||||
var valid = true;
|
||||
|
||||
if (localVarDecl.expression != null) {
|
||||
TypeCheckResult result = localVarDecl.expression.accept(this);
|
||||
|
||||
var resultType = localVarDecl.expression.getType();
|
||||
valid = result.isValid() && valid;
|
||||
|
||||
if (!Objects.equals(resultType, localVarDecl.type)) {
|
||||
errors.add(new TypeMismatchException(
|
||||
"Type mismatch: cannot convert from " + resultType + " to " + localVarDecl.type));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
currentScope.addLocalVar(localVarDecl.identifier, localVarDecl.type);
|
||||
} catch (AlreadyDefinedException e) {
|
||||
errors.add(new AlreadyDefinedException(e.getMessage()));
|
||||
valid = false;
|
||||
}
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(NewDeclarationStatementExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IncrementExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(BinaryExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(CalculationExpressionNode calcNode) {
|
||||
if (calcNode.calculationExpression != null) {
|
||||
calcNode.calculationExpression.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotSubstractionExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(NonCalculationExpressionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(UnaryExpressionNode unary) {
|
||||
var valid = true;
|
||||
|
||||
if (currentScope.contains(unary.identifier)) {
|
||||
return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier));
|
||||
} else if(currentFields.get(unary.identifier) != null) {
|
||||
return new TypeCheckResult(valid, currentFields.get(unary.identifier));
|
||||
} else {
|
||||
errors.add(new NotDeclearedException("Var is not Decleared"));
|
||||
}
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,20 @@
|
||||
package semantic;
|
||||
|
||||
|
||||
import ast.ClassNode;
|
||||
import ast.ProgramNode;
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.IdentifierExpressionNode;
|
||||
import ast.expression.UnaryExpressionNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.*;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.binaryexpression.*;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
import ast.member.*;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.*;
|
||||
import ast.statement.ifstatement.*;
|
||||
import ast.statement.statementexpression.AssignStatementExpressionNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
import ast.statement.statementexpression.NewDeclarationStatementExpressionNode;
|
||||
import ast.statement.statementexpression.crementExpression.DecrementExpressionNode;
|
||||
import ast.statement.statementexpression.crementExpression.IncrementExpressionNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public interface SemanticVisitor {
|
||||
@ -21,19 +27,46 @@ public interface SemanticVisitor {
|
||||
|
||||
TypeCheckResult analyze(FieldNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(AssignmentStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(BinaryExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(IdentifierExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(UnaryExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(VariableDeclarationStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(IfStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(ReturnStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(WhileStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(ParameterNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(BlockNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(AssignableExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(ElseStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(ForStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(AssignStatementExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(DecrementExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(IfElseStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(MethodCallStatementExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(LocalVariableDeclarationNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(NewDeclarationStatementExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(IncrementExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(BinaryExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(CalculationExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(DotExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(DotSubstractionExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(NonCalculationExpressionNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(UnaryExpressionNode toCheck);
|
||||
|
||||
}
|
27
src/main/java/semantic/context/ClassContext.java
Normal file
27
src/main/java/semantic/context/ClassContext.java
Normal file
@ -0,0 +1,27 @@
|
||||
package semantic.context;
|
||||
|
||||
import ast.ClassNode;
|
||||
import ast.member.FieldNode;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ClassContext {
|
||||
|
||||
private HashMap<String, FieldContext> fields;
|
||||
|
||||
public ClassContext(ClassNode classNode) {
|
||||
|
||||
fields = new HashMap<>();
|
||||
|
||||
classNode.members.forEach(member -> {
|
||||
if(member instanceof FieldNode fieldNode) {
|
||||
fields.put(fieldNode.identifier, new FieldContext(fieldNode));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public FieldContext getField(String name) {
|
||||
return fields.get(name);
|
||||
}
|
||||
|
||||
}
|
24
src/main/java/semantic/context/Context.java
Normal file
24
src/main/java/semantic/context/Context.java
Normal file
@ -0,0 +1,24 @@
|
||||
package semantic.context;
|
||||
|
||||
import ast.ProgramNode;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Context {
|
||||
|
||||
private HashMap<String, ClassContext> classes;
|
||||
|
||||
public Context(ProgramNode programNode) {
|
||||
classes = new HashMap<>();
|
||||
|
||||
programNode.classes.forEach(classNode -> {
|
||||
ClassContext classContext = new ClassContext(classNode);
|
||||
classes.put(classNode.identifier, classContext);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public ClassContext getClass(String identifier) {
|
||||
return classes.get(identifier);
|
||||
}
|
||||
|
||||
}
|
21
src/main/java/semantic/context/FieldContext.java
Normal file
21
src/main/java/semantic/context/FieldContext.java
Normal file
@ -0,0 +1,21 @@
|
||||
package semantic.context;
|
||||
|
||||
import ast.member.FieldNode;
|
||||
import ast.type.*;
|
||||
import ast.type.type.*;
|
||||
|
||||
public class FieldContext {
|
||||
|
||||
private AccessModifierNode accessModifier;
|
||||
private ITypeNode type;
|
||||
|
||||
public FieldContext(FieldNode field) {
|
||||
accessModifier = field.accessTypeNode;
|
||||
type = field.type;
|
||||
}
|
||||
|
||||
public ITypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package semantic.exeptions;
|
||||
|
||||
public class AlreadyDefinedException extends RuntimeException {
|
||||
|
||||
public AlreadyDefinedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package semantic.exeptions;
|
||||
|
||||
public class MultipleReturnTypes extends RuntimeException {
|
||||
|
||||
public MultipleReturnTypes(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package semantic.exeptions;
|
||||
|
||||
public class NotDeclearedException extends RuntimeException {
|
||||
|
||||
public NotDeclearedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package semantic.exeptions;
|
||||
|
||||
public class TypeMismatchException extends RuntimeException {
|
||||
|
||||
public TypeMismatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package typechecker;
|
||||
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
|
||||
public class TypeCheckResult {
|
||||
|
||||
private boolean valid;
|
||||
private TypeNode type;
|
||||
private ITypeNode type;
|
||||
|
||||
public TypeCheckResult(boolean valid, TypeNode type) {
|
||||
public TypeCheckResult(boolean valid, ITypeNode type) {
|
||||
this.valid = valid;
|
||||
this.type = type;
|
||||
}
|
||||
@ -17,7 +17,7 @@ public class TypeCheckResult {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public TypeNode getType() {
|
||||
public ITypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user