Compare commits
9 Commits
09e36a84dc
...
57c2023215
Author | SHA1 | Date | |
---|---|---|---|
57c2023215 | |||
bf7a642233 | |||
3639b2a4f8 | |||
330b92a79f | |||
8094a93582 | |||
0271313a05 | |||
|
e552bd5ada | ||
|
56d316a6d0 | ||
|
22a30d5956 |
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>
|
||||
|
14
pom.xml
14
pom.xml
@ -27,18 +27,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>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>9.2</version>
|
||||
<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,21 +1,18 @@
|
||||
import ast.ASTNode;
|
||||
import oldAst.ASTNode;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import ast.ProgramNode;
|
||||
import oldAst.ProgramNode;
|
||||
import bytecode.ByteCodeGenerator;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import parser.ASTBuilder;
|
||||
import parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
import semantic.SemanticAnalyzer;
|
||||
import bytecode.ByteCodeGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1,12 +1,5 @@
|
||||
package ast;
|
||||
|
||||
//import java.util.List;
|
||||
|
||||
public interface ASTNode {
|
||||
/**
|
||||
* Please implement this method to return a list of children of each node.
|
||||
*/
|
||||
// public List<ASTNode> getChildren();
|
||||
}
|
||||
public interface ASTNode { }
|
||||
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
package ast;
|
||||
|
||||
public class BlockNode {
|
||||
}
|
@ -1,28 +1,30 @@
|
||||
package ast;
|
||||
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.EnumAccessModifierNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import ast.member.ConstructorNode;
|
||||
import ast.member.MemberNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.EnumAccessTypeNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
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 +36,8 @@ public class ClassNode implements ASTNode, Visitable {
|
||||
|
||||
public void ensureConstructor(){
|
||||
if(!hasConstructor) {
|
||||
ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), identifier);
|
||||
members.add(0,constructor);
|
||||
ConstructorNode constructor = new ConstructorNode("public", identifier, );
|
||||
members.addFirst(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
|
4
src/main/java/ast/IdentifierNode.java
Normal file
4
src/main/java/ast/IdentifierNode.java
Normal file
@ -0,0 +1,4 @@
|
||||
package ast;
|
||||
|
||||
public class IdentifierNode {
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package ast;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class LiteralNode implements ExpressionNode, Visitable {
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
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) {
|
||||
|
17
src/main/java/ast/block/BlockNode.java
Normal file
17
src/main/java/ast/block/BlockNode.java
Normal file
@ -0,0 +1,17 @@
|
||||
package ast.block;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.StatementNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockNode implements ASTNode {
|
||||
public List<StatementNode> statements = new ArrayList<>();
|
||||
|
||||
public BlockNode() {}
|
||||
|
||||
public void addStatement(StatementNode statement) {
|
||||
statements.add(statement);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -1,8 +1,4 @@
|
||||
package ast.expression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import visitor.Visitable;
|
||||
|
||||
public interface ExpressionNode extends ASTNode, Visitable {
|
||||
|
||||
public class ExpressionNode {
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
public enum ExpresssionOperator {
|
||||
DOT, // .
|
||||
PLUS, // +
|
||||
MINUS, // -
|
||||
MULTIPLY, // *
|
||||
DIVIDE, // /
|
||||
NOT, // !
|
||||
ASSIGNMENT, // =
|
||||
EQUALS, // ==
|
||||
UNEQUALS, // !=
|
||||
ERROR //TODO: Remove This
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
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, TypeNode type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ast.expression;
|
||||
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
public class BinaryExpression {
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class CalculationExpressionNode implements ASTNode {
|
||||
CalculationExpressionNode calculationExpression;
|
||||
String operator;
|
||||
DotExpressionNode dotExpression;
|
||||
|
||||
public CalculationExpressionNode(CalculationExpressionNode calculationExpression, String operator, DotExpressionNode dotExpression) {
|
||||
this.calculationExpression = calculationExpression;
|
||||
this.operator = operator;
|
||||
this.dotExpression = dotExpression;
|
||||
}
|
||||
|
||||
public CalculationExpressionNode(DotExpressionNode dotExpression) {
|
||||
this.dotExpression = dotExpression;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
public class DotExpressionNode implements ASTNode {
|
||||
DotExpressionNode dotExpression;
|
||||
String operator;
|
||||
DotSubstractionExpressionNode dotSubstractionExpression;
|
||||
|
||||
public DotExpressionNode(DotExpressionNode dotExpression, String operator, DotSubstractionExpressionNode dotSubstractionExpression) {
|
||||
this.dotExpression = dotExpression;
|
||||
this.operator = operator;
|
||||
this.dotSubstractionExpression = dotSubstractionExpression;
|
||||
}
|
||||
|
||||
public DotExpressionNode(DotSubstractionExpressionNode dotSubstractionExpression) {
|
||||
this.dotSubstractionExpression = dotSubstractionExpression;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode;
|
||||
import ast.type.ValueNode;
|
||||
|
||||
public class DotSubstractionExpressionNode implements ASTNode {
|
||||
ValueNode value;
|
||||
String identifier;
|
||||
MemberAccessNode memberAccess;
|
||||
MethodCallStatementExpressionNode methodCall;
|
||||
CalculationExpressionNode calculationExpression;
|
||||
|
||||
public DotSubstractionExpressionNode(ValueNode value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public DotSubstractionExpressionNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public DotSubstractionExpressionNode(MemberAccessNode memberAccess) {
|
||||
this.memberAccess = memberAccess;
|
||||
}
|
||||
|
||||
public DotSubstractionExpressionNode(MethodCallStatementExpressionNode methodCall, CalculationExpressionNode calculationExpression) {
|
||||
this.methodCall = methodCall;
|
||||
this.calculationExpression = calculationExpression;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ast.expression.binaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
|
||||
public class NonCalculationExpressionNode implements ASTNode {
|
||||
UnaryExpressionNode unaryExpression;
|
||||
String operator;
|
||||
ExpressionNode expression;
|
||||
|
||||
public NonCalculationExpressionNode(UnaryExpressionNode unaryExpression, String operator, ExpressionNode expression) {
|
||||
this.unaryExpression = unaryExpression;
|
||||
this.operator = operator;
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MemberAccessNode implements ASTNode {
|
||||
Boolean thisExpr;
|
||||
List<String> identifiers = new ArrayList<>();
|
||||
|
||||
public MemberAccessNode(Boolean thisExpr) {
|
||||
this.thisExpr = thisExpr;
|
||||
}
|
||||
|
||||
public void addIdentifier(String identifier) {
|
||||
identifiers.add(identifier);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
public class NotExpressionNode implements ASTNode {
|
||||
ExpressionNode expression;
|
||||
|
||||
public NotExpressionNode(ExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package ast.expression.unaryexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.statement.StatementNode;
|
||||
import ast.type.ValueNode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UnaryExpressionNode implements ASTNode {
|
||||
String thisExp;
|
||||
String identifier;
|
||||
MemberAccessNode memberAccess;
|
||||
ValueNode value;
|
||||
NotExpressionNode notExpression;
|
||||
StatementNode statement;
|
||||
ExpressionNode expression;
|
||||
|
||||
public UnaryExpressionNode(String value) {
|
||||
if(Objects.equals(value, "this")) {
|
||||
this.thisExp = "this";
|
||||
} else {
|
||||
this.identifier = value;
|
||||
}
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(MemberAccessNode memberAccess) {
|
||||
this.memberAccess = memberAccess;
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(ValueNode value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(NotExpressionNode notExpression) {
|
||||
this.notExpression = notExpression;
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(StatementNode statement) {
|
||||
this.statement = statement;
|
||||
}
|
||||
|
||||
public UnaryExpressionNode(ExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
@ -1,12 +1,28 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructorNode extends MethodNode implements Visitable {
|
||||
public ConstructorNode(AccessTypeNode visibility, String name) {
|
||||
super(visibility, name);
|
||||
public AccessModifierNode accessType;
|
||||
public String identifier;
|
||||
public List<ParameterNode> parameters = new ArrayList<>();
|
||||
public BlockNode body;
|
||||
|
||||
public ConstructorNode(String accessType, String identifier, BlockNode body) {
|
||||
this.accessType = new AccessModifierNode(accessType);
|
||||
this.identifier = identifier;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public void addParameter(ParameterNode parameterNode) {
|
||||
parameters.add(parameterNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.TypeNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
@ -8,11 +8,13 @@ import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class FieldNode implements MemberNode, Visitable {
|
||||
public AccessTypeNode accessTypeNode;
|
||||
public AccessModifierNode accessTypeNode;
|
||||
public TypeNode type;
|
||||
public String identifier;
|
||||
|
||||
public FieldNode(AccessTypeNode accessTypeNode, TypeNode type, String name){
|
||||
public FieldNode(){}
|
||||
|
||||
public FieldNode(AccessModifierNode accessTypeNode, TypeNode type, String name){
|
||||
this.accessTypeNode = accessTypeNode;
|
||||
this.type = type;
|
||||
this.identifier = name;
|
||||
|
@ -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,20 +1,15 @@
|
||||
package ast.member;
|
||||
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.statement.StatementNode;
|
||||
import ast.type.AccessTypeNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodNode implements MemberNode, Visitable {
|
||||
public AccessTypeNode visibility;
|
||||
public AccessModifierNode accessModifier;
|
||||
public TypeNode type;
|
||||
public String identifier;
|
||||
|
||||
@ -22,6 +17,8 @@ public class MethodNode implements MemberNode, Visitable {
|
||||
|
||||
public List<StatementNode> statements = new ArrayList<>();
|
||||
|
||||
public MethodNode(){}
|
||||
|
||||
public MethodNode(AccessTypeNode visibility, TypeNode type, String identifier, ParameterListNode parameters,
|
||||
List<StatementNode> statements){
|
||||
this.visibility = visibility;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@ import ast.ASTNode;
|
||||
import ast.type.TypeNode;
|
||||
|
||||
public class ParameterNode implements ASTNode {
|
||||
public TypeNode type;
|
||||
public String identifier;
|
||||
TypeNode type;
|
||||
String identifier;
|
||||
|
||||
public ParameterNode(TypeNode type, String identifier) {
|
||||
this.type = type;
|
||||
|
@ -1,29 +0,0 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.beans.Expression;
|
||||
|
||||
public class AssignmentStatementNode extends StatementNode implements Visitable {
|
||||
public String identifier;
|
||||
public ExpressionNode expression;
|
||||
|
||||
public AssignmentStatementNode(String identifier, ExpressionNode expression) {
|
||||
this.identifier = identifier;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
23
src/main/java/ast/statement/ForStatementNode.java
Normal file
23
src/main/java/ast/statement/ForStatementNode.java
Normal file
@ -0,0 +1,23 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
public class ForStatementNode implements ASTNode {
|
||||
ExpressionNode statementExpressionInit;
|
||||
StatementNode localVariableDeclarationInit;
|
||||
ExpressionNode expression;
|
||||
ExpressionNode statementExpression;
|
||||
|
||||
public ForStatementNode(ExpressionNode statementExpressionInit, ExpressionNode expression, ExpressionNode statementExpression) {
|
||||
this.statementExpressionInit = statementExpressionInit;
|
||||
this.expression = expression;
|
||||
this.statementExpression = statementExpression;
|
||||
}
|
||||
|
||||
public ForStatementNode(StatementNode localVariableDeclarationInit, ExpressionNode expression, ExpressionNode statementExpression) {
|
||||
this.localVariableDeclarationInit = localVariableDeclarationInit;
|
||||
this.expression = expression;
|
||||
this.statementExpression = statementExpression;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class IfStatementNode extends StatementNode implements Visitable {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.type.TypeNode;
|
||||
|
||||
public class LocalVariableDeclarationNode implements ASTNode {
|
||||
TypeNode type;
|
||||
String identifier;
|
||||
String assign;
|
||||
ExpressionNode expression;
|
||||
|
||||
public LocalVariableDeclarationNode(TypeNode type, String identifier, String assign, ExpressionNode expression) {
|
||||
this.type = type;
|
||||
this.identifier = identifier;
|
||||
this.assign = assign;
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
@ -1,25 +1,16 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
import ast.type.TypeNode;
|
||||
|
||||
public class ReturnStatementNode extends StatementNode implements Visitable {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReturnStatementNode implements ASTNode {
|
||||
public ExpressionNode expression;
|
||||
|
||||
public ReturnStatementNode(ExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -1,9 +1,2 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
public abstract class StatementNode implements ASTNode, Visitable {
|
||||
package ast.statement;public class StatementNode {
|
||||
}
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.type.TypeNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class VariableDeclarationStatementNode extends StatementNode implements Visitable {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
@ -1,27 +1,15 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class WhileStatementNode extends StatementNode implements Visitable {
|
||||
public ExpressionNode condition;
|
||||
public StatementNode body;
|
||||
public class WhileStatementNode implements ASTNode {
|
||||
ExpressionNode expression;
|
||||
BlockNode block;
|
||||
|
||||
public WhileStatementNode(ExpressionNode condition, StatementNode body) {
|
||||
this.condition = condition;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
public WhileStatementNode(ExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
this.block = block;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
|
||||
public class ElseStatementNode implements ASTNode {
|
||||
BlockNode block;
|
||||
|
||||
public ElseStatementNode(BlockNode block) {
|
||||
this.block = block;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IfElseStatementNode implements ASTNode {
|
||||
IfStatementNode ifStatement;
|
||||
List<ElseStatementNode> elseStatements = new ArrayList<>();
|
||||
|
||||
public IfElseStatementNode(IfStatementNode ifStatement) {
|
||||
this.ifStatement = ifStatement;
|
||||
}
|
||||
|
||||
public void addElseStatement(ElseStatementNode elseStatement) {
|
||||
elseStatements.add(elseStatement);
|
||||
}
|
||||
|
||||
}
|
15
src/main/java/ast/statement/ifstatement/IfStatementNode.java
Normal file
15
src/main/java/ast/statement/ifstatement/IfStatementNode.java
Normal file
@ -0,0 +1,15 @@
|
||||
package ast.statement.ifstatement;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
public class IfStatementNode implements ASTNode {
|
||||
ExpressionNode expression;
|
||||
BlockNode block;
|
||||
|
||||
public IfStatementNode(ExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
this.block = block;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
public class AssignStatementExpressionNode implements ASTNode {
|
||||
AssignableExpressionNode assignable;
|
||||
ExpressionNode expression;
|
||||
|
||||
public AssignStatementExpressionNode(AssignableExpressionNode assignable, ExpressionNode expression) {
|
||||
this.assignable = assignable;
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
|
||||
public class AssignableExpressionNode implements ASTNode {
|
||||
String identifier;
|
||||
MemberAccessNode memberAccess;
|
||||
|
||||
public AssignableExpressionNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public AssignableExpressionNode(MemberAccessNode memberAccess) {
|
||||
this.memberAccess = memberAccess;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
public class IncrementExpression {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ast.statement.statementexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewDeclarationStatementExpressionNode implements ASTNode {
|
||||
String identifier;
|
||||
List<ExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
public NewDeclarationStatementExpressionNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public void addExpression(ExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
public enum CrementType {
|
||||
PREFIX, SUFFIX
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
|
||||
public class DecrementExpressionNode implements ASTNode {
|
||||
CrementType crementType;
|
||||
AssignableExpressionNode assignableExpression;
|
||||
|
||||
public DecrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) {
|
||||
this.assignableExpression = assignableExpression;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ast.statement.statementexpression.crementExpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
|
||||
public class IncrementExpressionNode implements ASTNode {
|
||||
CrementType crementType;
|
||||
AssignableExpressionNode assignableExpression;
|
||||
|
||||
public IncrementExpressionNode(CrementType crementType, AssignableExpressionNode assignableExpression) {
|
||||
this.assignableExpression = assignableExpression;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ast.statement.statementexpression.methodcallstatementnexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChainedMethodNode implements ASTNode {
|
||||
String identifier;
|
||||
List<ExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
public ChainedMethodNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public void addExpression(ExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package ast.statement.statementexpression.methodcallstatementnexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodCallStatementExpressionNode implements ASTNode {
|
||||
TargetNode target;
|
||||
List<ChainedMethodNode> chainedMethods = new ArrayList<>();
|
||||
String identifier;
|
||||
List<ExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
public MethodCallStatementExpressionNode(TargetNode target, String identifier) {
|
||||
this.target = target;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public void addChainedMethod(ChainedMethodNode chainedMethode) {
|
||||
chainedMethods.add(chainedMethode);
|
||||
}
|
||||
|
||||
public void addExpression(ExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ast.statement.statementexpression.methodcallstatementnexpression;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
import ast.statement.statementexpression.NewDeclarationStatementExpressionNode;
|
||||
|
||||
public class TargetNode implements ASTNode {
|
||||
Boolean thisTar;
|
||||
MemberAccessNode memberAccess;
|
||||
NewDeclarationStatementExpressionNode newDeclaration;
|
||||
String identifier;
|
||||
|
||||
public TargetNode(Boolean thisTar) {
|
||||
this.thisTar = thisTar;
|
||||
}
|
||||
|
||||
public TargetNode(MemberAccessNode memberAccess) {
|
||||
this.memberAccess = memberAccess;
|
||||
}
|
||||
|
||||
public TargetNode(NewDeclarationStatementExpressionNode newDeclaration) {
|
||||
this.newDeclaration = newDeclaration;
|
||||
}
|
||||
|
||||
public TargetNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
}
|
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 {
|
||||
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 +1,5 @@
|
||||
package ast.type;
|
||||
|
||||
public enum EnumTypeNode {
|
||||
INT, BOOLEAN, CHAR
|
||||
INT, BOOLEAN, CHAR, IDENTIFIER
|
||||
}
|
||||
|
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 +1,25 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
public class TypeNode {
|
||||
EnumTypeNode type;
|
||||
|
||||
public interface TypeNode extends ASTNode {
|
||||
public TypeNode(String type) {
|
||||
setType(type);
|
||||
}
|
||||
|
||||
private void setType(String type) {
|
||||
switch(type) {
|
||||
case "int":
|
||||
this.type = EnumTypeNode.INT;
|
||||
break;
|
||||
case "boolean":
|
||||
this.type = EnumTypeNode.BOOLEAN;
|
||||
break;
|
||||
case "char":
|
||||
this.type = EnumTypeNode.CHAR;
|
||||
break;
|
||||
default:
|
||||
this.type = EnumTypeNode.IDENTIFIER;
|
||||
}
|
||||
}
|
||||
}
|
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 {
|
||||
EnumValueNode valueType;
|
||||
String value;
|
||||
|
||||
public ValueNode(EnumValueNode valueType, String value) {
|
||||
this.valueType = valueType;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package bytecode;
|
||||
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.type.*;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
@ -9,8 +9,6 @@ import ast.member.MethodNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.*;
|
||||
import ast.type.BaseTypeNode;
|
||||
import ast.type.ReferenceTypeNode;
|
||||
import ast.type.TypeNode;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
|
@ -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);
|
||||
|
Binary file not shown.
@ -1,262 +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.literal.BooleanLiteralNode;
|
||||
import ast.literal.CharLiteralNode;
|
||||
import ast.literal.LiteralNode;
|
||||
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;
|
||||
}
|
||||
|
||||
public ASTNode visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) {
|
||||
if(ctx.fieldDeclaration() != null) {
|
||||
return visitFieldDeclaration(ctx.fieldDeclaration());
|
||||
} else if(ctx.methodDeclaration() != null) {
|
||||
return visitMethodDeclaration(ctx.methodDeclaration());
|
||||
} else if(ctx.constructorDeclaration() != null) {
|
||||
return visitConstructorDeclaration(ctx.constructorDeclaration());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@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());
|
||||
} else if(ctx.ifStatement() != null) {
|
||||
return visitIfStatement(ctx.ifStatement());
|
||||
} else if(ctx.whileStatement() != null) {
|
||||
return visitWhileStatement(ctx.whileStatement());
|
||||
} else if(ctx.returnStatement() != null) {
|
||||
return visitReturnStatement(ctx.returnStatement());
|
||||
} else if(ctx.block() != null) {
|
||||
return visitBlock(ctx.block());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) {
|
||||
TypeNode type = (TypeNode) visit(ctx.type());
|
||||
String identifier = ctx.IDENTIFIER().getText();
|
||||
ExpressionNode expression = null;
|
||||
if(ctx.expression() != null) {
|
||||
expression = (ExpressionNode) visit(ctx.expression());
|
||||
}
|
||||
return new VariableDeclarationStatementNode(type, identifier, expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) {
|
||||
ExpressionNode expression = (ExpressionNode) visit(ctx.expression());
|
||||
return new AssignmentStatementNode(ctx.IDENTIFIER().getText(), expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitIfStatement(SimpleJavaParser.IfStatementContext ctx) {
|
||||
ExpressionNode condition = (ExpressionNode) visit(ctx.expression());
|
||||
StatementNode thenStatement = (StatementNode) visit(ctx.statement(0)); // The 'then' branch
|
||||
StatementNode elseStatement = null;
|
||||
if (ctx.statement().size() > 1) {
|
||||
elseStatement = (StatementNode) visit(ctx.statement(1)); // The 'else' branch, if present
|
||||
}
|
||||
return new IfStatementNode(condition, thenStatement, elseStatement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) {
|
||||
ExpressionNode condition = (ExpressionNode) visit(ctx.expression()); // Visit the condition part of the while statement
|
||||
StatementNode body = (StatementNode) visit(ctx.statement()); // Visit the body part of the while statement
|
||||
return new WhileStatementNode(condition, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) {
|
||||
ExpressionNode expression = null;
|
||||
if (ctx.expression() != null) {
|
||||
expression = (ExpressionNode) visit(ctx.expression()); // Visit the expression part of the return statement, if it exists
|
||||
}
|
||||
return new ReturnStatementNode(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitBlock(SimpleJavaParser.BlockContext ctx) {
|
||||
List<StatementNode> statements = new ArrayList<>();
|
||||
for(SimpleJavaParser.StatementContext stmtCtx : ctx.statement()) {
|
||||
statements.add((StatementNode) visit(stmtCtx));
|
||||
}
|
||||
return (ASTNode) new BlockStatementNode(statements);
|
||||
}
|
||||
|
||||
@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(), null);
|
||||
}
|
||||
|
||||
return null; // Return null or throw an exception if no valid expression found
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitLiteral(SimpleJavaParser.LiteralContext ctx) {
|
||||
TypeNode type;
|
||||
String value;
|
||||
if(ctx.INTEGERLITERAL() != null) {
|
||||
type = new BaseTypeNode(EnumTypeNode.INT);
|
||||
value = ctx.INTEGERLITERAL().getText();
|
||||
return new LiteralNode(value, type);
|
||||
} else if(ctx.booleanLiteral() != null) {
|
||||
type= new BaseTypeNode(EnumTypeNode.BOOLEAN);
|
||||
BooleanLiteralNode booleanNode = (BooleanLiteralNode) visitBooleanLiteral(ctx.booleanLiteral());
|
||||
value = booleanNode.getValue();
|
||||
return new LiteralNode(value, type);
|
||||
} else if(ctx.charLiteral() != null) {
|
||||
type= new BaseTypeNode(EnumTypeNode.CHAR);
|
||||
CharLiteralNode charNode = (CharLiteralNode) visitCharLiteral(ctx.charLiteral());
|
||||
value = charNode.getValue();
|
||||
return new LiteralNode(value, type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) {
|
||||
return (ASTNode) new BooleanLiteralNode(ctx.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) {
|
||||
return (ASTNode) new CharLiteralNode(ctx.getText());
|
||||
}
|
||||
}
|
@ -1,60 +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 : IDENTIFIER '=' expression ';' ;
|
||||
|
||||
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;
|
375
src/main/java/parser/astBuilder/ASTBuilder.java
Normal file
375
src/main/java/parser/astBuilder/ASTBuilder.java
Normal file
@ -0,0 +1,375 @@
|
||||
package parser.astBuilder;
|
||||
|
||||
import ast.*;
|
||||
import ast.block.BlockNode;
|
||||
import ast.expression.*;
|
||||
import ast.expression.binaryexpression.CalculationExpressionNode;
|
||||
import ast.expression.binaryexpression.DotExpressionNode;
|
||||
import ast.expression.binaryexpression.DotSubstractionExpressionNode;
|
||||
import ast.expression.binaryexpression.NonCalculationExpressionNode;
|
||||
import ast.expression.unaryexpression.MemberAccessNode;
|
||||
import ast.expression.unaryexpression.NotExpressionNode;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
import ast.statement.ifstatement.ElseStatementNode;
|
||||
import ast.statement.ifstatement.IfElseStatementNode;
|
||||
import ast.member.ConstructorNode;
|
||||
import ast.member.MemberNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.*;
|
||||
import ast.statement.ifstatement.IfStatementNode;
|
||||
import ast.statement.statementexpression.AssignStatementExpressionNode;
|
||||
import ast.statement.statementexpression.AssignableExpressionNode;
|
||||
import ast.statement.statementexpression.NewDeclarationStatementExpressionNode;
|
||||
import ast.statement.statementexpression.crementExpression.CrementType;
|
||||
import ast.statement.statementexpression.crementExpression.DecrementExpressionNode;
|
||||
import ast.statement.statementexpression.crementExpression.IncrementExpressionNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.ChainedMethodNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.MethodCallStatementExpressionNode;
|
||||
import ast.statement.statementexpression.methodcallstatementnexpression.TargetNode;
|
||||
import ast.type.*;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import parser.generated.*;
|
||||
|
||||
public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
@Override
|
||||
public ASTNode visitProgram(SimpleJavaParser.ProgramContext ctx) {
|
||||
ProgramNode program = new ProgramNode();
|
||||
for (SimpleJavaParser.ClassDeclarationContext classDeclCtx : ctx.classDeclaration()) {
|
||||
program.addClass((ClassNode) visit(classDeclCtx));
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) {
|
||||
ClassNode classNode = new ClassNode(ctx.AccessModifier().getText(), ctx.Identifier().getText());
|
||||
for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) {
|
||||
classNode.addMember((MemberNode) visit(member));
|
||||
}
|
||||
classNode.ensureConstructor();
|
||||
return classNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) {
|
||||
ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.block()));
|
||||
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
||||
constructorNode.addParameter((ParameterNode) visit(parameter));
|
||||
}
|
||||
return constructorNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitParameter(SimpleJavaParser.ParameterContext ctx) {
|
||||
return new ParameterNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitStatement(SimpleJavaParser.StatementContext ctx) {
|
||||
if(ctx.returnStatement() != null) {
|
||||
return visitReturnStatement(ctx.returnStatement());
|
||||
} else if(ctx.localVariableDeclaration() != null) {
|
||||
return visitLocalVariableDeclaration(ctx.localVariableDeclaration());
|
||||
} else if(ctx.block() != null) {
|
||||
return visitBlock(ctx.block());
|
||||
} else if(ctx.whileStatement() != null) {
|
||||
return visitWhileStatement(ctx.whileStatement());
|
||||
} else if(ctx.forStatement() != null) {
|
||||
return visitForStatement(ctx.forStatement());
|
||||
} else if(ctx.ifElseStatement() != null) {
|
||||
return visitIfElseStatement(ctx.ifElseStatement());
|
||||
} else if(ctx.statementExpression() != null) {
|
||||
return visitStatementExpression(ctx.statementExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) {
|
||||
return new ReturnStatementNode((ExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) {
|
||||
return new LocalVariableDeclarationNode(new TypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (ExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitBlock(SimpleJavaParser.BlockContext ctx) {
|
||||
BlockNode blockNode = new BlockNode();
|
||||
for(SimpleJavaParser.StatementContext statement : ctx.statement()) {
|
||||
blockNode.addStatement((StatementNode) visit(statement));
|
||||
}
|
||||
return blockNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) {
|
||||
return new WhileStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitForStatement(SimpleJavaParser.ForStatementContext ctx) {
|
||||
if(ctx.statementExpression(0) != null) {
|
||||
return new ForStatementNode((ExpressionNode) visit(ctx.statementExpression(0)), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1)));
|
||||
} else if(ctx.localVariableDeclaration() != null) {
|
||||
return new ForStatementNode((StatementNode) visit(ctx.localVariableDeclaration()), (ExpressionNode) visit(ctx.expression()), (ExpressionNode) visit(ctx.statementExpression(1)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) {
|
||||
IfElseStatementNode ifElseStatementNode = new IfElseStatementNode((IfStatementNode) visit(ctx.ifStatement()));
|
||||
for(SimpleJavaParser.ElseStatementContext elseStatement : ctx.elseStatement()) {
|
||||
ifElseStatementNode.addElseStatement((ElseStatementNode) visit(elseStatement));
|
||||
}
|
||||
return ifElseStatementNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitIfStatement(SimpleJavaParser.IfStatementContext ctx) {
|
||||
return new IfStatementNode((ExpressionNode) visit(ctx.expression()), (BlockNode) visit(ctx.block()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) {
|
||||
return new ElseStatementNode((BlockNode) visit(ctx.block()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitStatementExpression(SimpleJavaParser.StatementExpressionContext ctx) {
|
||||
if(ctx.assign() != null) {
|
||||
return visitAssign(ctx.assign());
|
||||
} else if(ctx.newDeclaration() != null) {
|
||||
return visitNewDeclaration(ctx.newDeclaration());
|
||||
} else if(ctx.methodCall() != null) {
|
||||
return visitMethodCall(ctx.methodCall());
|
||||
} else if(ctx.crementExpression() != null) {
|
||||
return visitCrementExpression(ctx.crementExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitAssign(SimpleJavaParser.AssignContext ctx) {
|
||||
return new AssignStatementExpressionNode((AssignableExpressionNode) visit(ctx.assignableExpression()), (ExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitNewDeclaration(SimpleJavaParser.NewDeclarationContext ctx) {
|
||||
NewDeclarationStatementExpressionNode newDeclarationStatementExpressionNode = new NewDeclarationStatementExpressionNode(ctx.Identifier().getText());
|
||||
for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) {
|
||||
newDeclarationStatementExpressionNode.addExpression((ExpressionNode) visit(expression));
|
||||
}
|
||||
return newDeclarationStatementExpressionNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitMethodCall(SimpleJavaParser.MethodCallContext ctx) {
|
||||
MethodCallStatementExpressionNode methodCallStatementExpressionNode = new MethodCallStatementExpressionNode((TargetNode) visit(ctx.target()), ctx.Identifier().getText());
|
||||
for(SimpleJavaParser.ChainedMethodContext chainedMethod : ctx.chainedMethod()) {
|
||||
methodCallStatementExpressionNode.addChainedMethod((ChainedMethodNode) visit(chainedMethod));
|
||||
}
|
||||
for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) {
|
||||
methodCallStatementExpressionNode.addExpression((ExpressionNode) visit(expression));
|
||||
}
|
||||
return methodCallStatementExpressionNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitTarget(SimpleJavaParser.TargetContext ctx) {
|
||||
if(ctx.This() != null) {
|
||||
return new TargetNode(true);
|
||||
} else if(ctx.memberAccess() != null) {
|
||||
return new TargetNode((MemberAccessNode) visit(ctx.memberAccess()));
|
||||
} else if(ctx.newDeclaration() != null) {
|
||||
return new TargetNode((NewDeclarationStatementExpressionNode) visit(ctx.newDeclaration()));
|
||||
} else if(ctx.Identifier() != null) {
|
||||
return new TargetNode(ctx.Identifier().getText());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitChainedMethod(SimpleJavaParser.ChainedMethodContext ctx) {
|
||||
ChainedMethodNode chainedMethodNode = new ChainedMethodNode(ctx.Identifier().getText());
|
||||
for(SimpleJavaParser.ExpressionContext expression : ctx.argumentList().expression()) {
|
||||
chainedMethodNode.addExpression((ExpressionNode) visit(expression));
|
||||
}
|
||||
return chainedMethodNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitCrementExpression(SimpleJavaParser.CrementExpressionContext ctx) {
|
||||
if(ctx.incrementExpression() != null) {
|
||||
return visitIncrementExpression(ctx.incrementExpression());
|
||||
} else if(ctx.decrementExpression() != null) {
|
||||
return visitDecrementExpression(ctx.decrementExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitIncrementExpression(SimpleJavaParser.IncrementExpressionContext ctx) {
|
||||
if(ctx.prefixIncrementExpression() != null) {
|
||||
return visitPrefixIncrementExpression(ctx.prefixIncrementExpression());
|
||||
} else if(ctx.suffixIncrementExpression() != null) {
|
||||
return visitSuffixIncrementExpression(ctx.suffixIncrementExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitPrefixIncrementExpression(SimpleJavaParser.PrefixIncrementExpressionContext ctx) {
|
||||
return new IncrementExpressionNode(CrementType.PREFIX, (AssignableExpressionNode) visit(ctx.assignableExpression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitSuffixIncrementExpression(SimpleJavaParser.SuffixIncrementExpressionContext ctx) {
|
||||
return new IncrementExpressionNode(CrementType.SUFFIX, (AssignableExpressionNode) visit(ctx.assignableExpression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitDecrementExpression(SimpleJavaParser.DecrementExpressionContext ctx) {
|
||||
if(ctx.prefixDecrementExpression() != null) {
|
||||
return visitPrefixDecrementExpression(ctx.prefixDecrementExpression());
|
||||
} else if(ctx.suffixDecrementExpression() != null) {
|
||||
return visitSuffixDecrementExpression(ctx.suffixDecrementExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitPrefixDecrementExpression(SimpleJavaParser.PrefixDecrementExpressionContext ctx) {
|
||||
return new DecrementExpressionNode(CrementType.PREFIX, (AssignableExpressionNode) visit(ctx.assignableExpression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitSuffixDecrementExpression(SimpleJavaParser.SuffixDecrementExpressionContext ctx) {
|
||||
return new DecrementExpressionNode(CrementType.SUFFIX, (AssignableExpressionNode) visit(ctx.assignableExpression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitExpression(SimpleJavaParser.ExpressionContext ctx) {
|
||||
if(ctx.unaryExpression() != null) {
|
||||
return visit(ctx.unaryExpression());
|
||||
} else if(ctx.binaryExpression() != null) {
|
||||
return visit(ctx.binaryExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitUnaryExpression(SimpleJavaParser.UnaryExpressionContext ctx) {
|
||||
if(ctx.This() != null) {
|
||||
return new UnaryExpressionNode(ctx.This().getText());
|
||||
} else if(ctx.Identifier() != null) {
|
||||
return new UnaryExpressionNode(ctx.Identifier().getText());
|
||||
} else if(ctx.memberAccess() != null) {
|
||||
return new UnaryExpressionNode((MemberAccessNode) visitMemberAccess(ctx.memberAccess()));
|
||||
} else if(ctx.value() != null) {
|
||||
return new UnaryExpressionNode((ValueNode) visitValue(ctx.value()));
|
||||
} else if(ctx.notExpression() != null) {
|
||||
return new UnaryExpressionNode((NotExpressionNode) visitNotExpression(ctx.notExpression()));
|
||||
} else if(ctx.statementExpression() != null) {
|
||||
return new UnaryExpressionNode((StatementNode) visitStatementExpression(ctx.statementExpression()));
|
||||
} else if(ctx.expression() != null) {
|
||||
return new UnaryExpressionNode((ExpressionNode) visitExpression(ctx.expression()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitMemberAccess(SimpleJavaParser.MemberAccessContext ctx) {
|
||||
MemberAccessNode memberAccessNode;
|
||||
if(ctx.This() != null) {
|
||||
memberAccessNode = new MemberAccessNode(true);
|
||||
} else {
|
||||
memberAccessNode = new MemberAccessNode(false);
|
||||
}
|
||||
for (TerminalNode identifierNode : ctx.Identifier()) {
|
||||
memberAccessNode.addIdentifier(identifierNode.getText());
|
||||
}
|
||||
return memberAccessNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitValue(SimpleJavaParser.ValueContext ctx) {
|
||||
if(ctx.IntValue() != null) {
|
||||
return new ValueNode(EnumValueNode.INT_VALUE, ctx.IntValue().getText());
|
||||
} else if(ctx.BooleanValue() != null) {
|
||||
return new ValueNode(EnumValueNode.BOOLEAN_VALUE, ctx.BooleanValue().getText());
|
||||
} else if(ctx.CharValue() != null) {
|
||||
return new ValueNode(EnumValueNode.CHAR_VALUE, ctx.CharValue().getText());
|
||||
} else if(ctx.NullValue() != null) {
|
||||
return new ValueNode(EnumValueNode.NULL_VALUE, ctx.NullValue().getText());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitNotExpression(SimpleJavaParser.NotExpressionContext ctx) {
|
||||
return new NotExpressionNode((ExpressionNode) visitExpression(ctx.expression()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ASTNode visitBinaryExpression(SimpleJavaParser.BinaryExpressionContext ctx) {
|
||||
if(ctx.calculationExpression() != null) {
|
||||
return visit(ctx.calculationExpression());
|
||||
} else if(ctx.nonCalculationExpression() != null) {
|
||||
return visit(ctx.nonCalculationExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitCalculationExpression(SimpleJavaParser.CalculationExpressionContext ctx) {
|
||||
if(ctx.calculationExpression() != null) {
|
||||
return new CalculationExpressionNode((CalculationExpressionNode) visit(ctx.calculationExpression()), ctx.LineOperator().getText(), (DotExpressionNode) visit(ctx.dotExpression()));
|
||||
} else if(ctx.dotExpression() != null) {
|
||||
return new CalculationExpressionNode((DotExpressionNode) visit(ctx.dotExpression()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitDotExpression(SimpleJavaParser.DotExpressionContext ctx) {
|
||||
if(ctx.dotExpression() != null) {
|
||||
return new DotExpressionNode((DotExpressionNode) visit(ctx.dotExpression()), ctx.DotOperator().getText(), (DotSubstractionExpressionNode) visit(ctx.dotSubtractionExpression()));
|
||||
} else if(ctx.dotSubtractionExpression() != null) {
|
||||
return new DotExpressionNode((DotSubstractionExpressionNode) visit(ctx.dotSubtractionExpression()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitDotSubtractionExpression(SimpleJavaParser.DotSubtractionExpressionContext ctx) {
|
||||
if(ctx.IntValue() != null) {
|
||||
return new DotSubstractionExpressionNode(new ValueNode(EnumValueNode.INT_VALUE, ctx.IntValue().getText()));
|
||||
} else if(ctx.Identifier() != null) {
|
||||
return new DotSubstractionExpressionNode(ctx.Identifier().getText());
|
||||
} else if(ctx.memberAccess() != null) {
|
||||
return new DotSubstractionExpressionNode((MemberAccessNode) visit(ctx.memberAccess()));
|
||||
} else if(ctx.methodCall() != null && ctx.calculationExpression() != null) {
|
||||
return new DotSubstractionExpressionNode((MethodCallStatementExpressionNode) visit(ctx.methodCall()), (CalculationExpressionNode) visit(ctx.calculationExpression()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitNonCalculationExpression(SimpleJavaParser.NonCalculationExpressionContext ctx) {
|
||||
return new NonCalculationExpressionNode((UnaryExpressionNode) visit(ctx.unaryExpression()), ctx.nonCalculationOperator().getText(), (ExpressionNode) visit(ctx.expression()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitAssignableExpression(SimpleJavaParser.AssignableExpressionContext ctx) {
|
||||
if(ctx.Identifier() != null) {
|
||||
return new AssignableExpressionNode(ctx.Identifier().getText());
|
||||
} else if(ctx.memberAccess() != null) {
|
||||
return new AssignableExpressionNode((MemberAccessNode) visit(ctx.memberAccess()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,73 +0,0 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
INTEGERLITERAL=36
|
||||
IDENTIFIER=37
|
||||
WS=38
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
||||
';'=4
|
||||
'static'=5
|
||||
'('=6
|
||||
')'=7
|
||||
','=8
|
||||
'int'=9
|
||||
'boolean'=10
|
||||
'char'=11
|
||||
'public'=12
|
||||
'private'=13
|
||||
'='=14
|
||||
'if'=15
|
||||
'else'=16
|
||||
'while'=17
|
||||
'return'=18
|
||||
'&&'=19
|
||||
'||'=20
|
||||
'=='=21
|
||||
'!='=22
|
||||
'<'=23
|
||||
'<='=24
|
||||
'>'=25
|
||||
'>='=26
|
||||
'+'=27
|
||||
'-'=28
|
||||
'*'=29
|
||||
'/'=30
|
||||
'%'=31
|
||||
'!'=32
|
||||
'true'=33
|
||||
'false'=34
|
||||
'\''=35
|
@ -1,292 +0,0 @@
|
||||
// Generated from C:/Users/ARB00075/Documents/DH/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link SimpleJavaListener},
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterProgram(SimpleJavaParser.ProgramContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitProgram(SimpleJavaParser.ProgramContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterParameterList(SimpleJavaParser.ParameterListContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitParameterList(SimpleJavaParser.ParameterListContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterParameter(SimpleJavaParser.ParameterContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitParameter(SimpleJavaParser.ParameterContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterType(SimpleJavaParser.TypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitType(SimpleJavaParser.TypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAccessType(SimpleJavaParser.AccessTypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAccessType(SimpleJavaParser.AccessTypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterStatement(SimpleJavaParser.StatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitStatement(SimpleJavaParser.StatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExpression(SimpleJavaParser.ExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExpression(SimpleJavaParser.ExpressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLiteral(SimpleJavaParser.LiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLiteral(SimpleJavaParser.LiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitTerminal(TerminalNode node) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitErrorNode(ErrorNode node) { }
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
// Generated from C:/Users/ARB00075/Documents/DH/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link SimpleJavaVisitor},
|
||||
* which can be extended to create a visitor which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SimpleJavaVisitor<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitProgram(SimpleJavaParser.ProgramContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitParameterList(SimpleJavaParser.ParameterListContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitParameter(SimpleJavaParser.ParameterContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitAccessType(SimpleJavaParser.AccessTypeContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitStatement(SimpleJavaParser.StatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExpression(SimpleJavaParser.ExpressionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitLiteral(SimpleJavaParser.LiteralContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { return visitChildren(ctx); }
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,263 +0,0 @@
|
||||
// Generated from C:/Users/ARB00075/Documents/DH/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"})
|
||||
public class SimpleJavaLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
|
||||
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
|
||||
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
|
||||
T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
|
||||
T__31=32, T__32=33, T__33=34, T__34=35, INTEGERLITERAL=36, IDENTIFIER=37,
|
||||
WS=38;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
|
||||
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
|
||||
"T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
|
||||
"T__33", "T__34", "INTEGERLITERAL", "IDENTIFIER", "WS"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'class'", "'{'", "'}'", "';'", "'static'", "'('", "')'", "','",
|
||||
"'int'", "'boolean'", "'char'", "'public'", "'private'", "'='", "'if'",
|
||||
"'else'", "'while'", "'return'", "'&&'", "'||'", "'=='", "'!='", "'<'",
|
||||
"'<='", "'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'true'",
|
||||
"'false'", "'''"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
"INTEGERLITERAL", "IDENTIFIER", "WS"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #VOCABULARY} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String[] tokenNames;
|
||||
static {
|
||||
tokenNames = new String[_SYMBOLIC_NAMES.length];
|
||||
for (int i = 0; i < tokenNames.length; i++) {
|
||||
tokenNames[i] = VOCABULARY.getLiteralName(i);
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = VOCABULARY.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = "<INVALID>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getTokenNames() {
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Vocabulary getVocabulary() {
|
||||
return VOCABULARY;
|
||||
}
|
||||
|
||||
|
||||
public SimpleJavaLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "SimpleJava.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public String[] getChannelNames() { return channelNames; }
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() { return modeNames; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u0000&\u00df\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
|
||||
"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+
|
||||
"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+
|
||||
"\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002"+
|
||||
"\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+
|
||||
"\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+
|
||||
"\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+
|
||||
"\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+
|
||||
"\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+
|
||||
"\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+
|
||||
"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0001\u0000"+
|
||||
"\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+
|
||||
"\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004"+
|
||||
"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+
|
||||
"\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+
|
||||
"\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+
|
||||
"\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+
|
||||
"\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f"+
|
||||
"\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+
|
||||
"\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001"+
|
||||
"\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001"+
|
||||
"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001"+
|
||||
"\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001"+
|
||||
"\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+
|
||||
"\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001"+
|
||||
"\u0019\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001"+
|
||||
"\u001b\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+
|
||||
"\u001e\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001"+
|
||||
"!\u0001!\u0001!\u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001#\u0004#\u00ce"+
|
||||
"\b#\u000b#\f#\u00cf\u0001$\u0001$\u0005$\u00d4\b$\n$\f$\u00d7\t$\u0001"+
|
||||
"%\u0004%\u00da\b%\u000b%\f%\u00db\u0001%\u0001%\u0000\u0000&\u0001\u0001"+
|
||||
"\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+
|
||||
"\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f"+
|
||||
"\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u0018"+
|
||||
"1\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&\u0001"+
|
||||
"\u0000\u0004\u0001\u000009\u0002\u0000AZaz\u0004\u000009AZ__az\u0003\u0000"+
|
||||
"\t\n\r\r \u00e1\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000"+
|
||||
"\u0000\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000"+
|
||||
"%\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001"+
|
||||
"\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000"+
|
||||
"\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u0000"+
|
||||
"3\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001"+
|
||||
"\u0000\u0000\u0000\u00009\u0001\u0000\u0000\u0000\u0000;\u0001\u0000\u0000"+
|
||||
"\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001\u0000\u0000\u0000\u0000"+
|
||||
"A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+
|
||||
"\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+
|
||||
"\u0000\u0000K\u0001\u0000\u0000\u0000\u0001M\u0001\u0000\u0000\u0000\u0003"+
|
||||
"S\u0001\u0000\u0000\u0000\u0005U\u0001\u0000\u0000\u0000\u0007W\u0001"+
|
||||
"\u0000\u0000\u0000\tY\u0001\u0000\u0000\u0000\u000b`\u0001\u0000\u0000"+
|
||||
"\u0000\rb\u0001\u0000\u0000\u0000\u000fd\u0001\u0000\u0000\u0000\u0011"+
|
||||
"f\u0001\u0000\u0000\u0000\u0013j\u0001\u0000\u0000\u0000\u0015r\u0001"+
|
||||
"\u0000\u0000\u0000\u0017w\u0001\u0000\u0000\u0000\u0019~\u0001\u0000\u0000"+
|
||||
"\u0000\u001b\u0086\u0001\u0000\u0000\u0000\u001d\u0088\u0001\u0000\u0000"+
|
||||
"\u0000\u001f\u008b\u0001\u0000\u0000\u0000!\u0090\u0001\u0000\u0000\u0000"+
|
||||
"#\u0096\u0001\u0000\u0000\u0000%\u009d\u0001\u0000\u0000\u0000\'\u00a0"+
|
||||
"\u0001\u0000\u0000\u0000)\u00a3\u0001\u0000\u0000\u0000+\u00a6\u0001\u0000"+
|
||||
"\u0000\u0000-\u00a9\u0001\u0000\u0000\u0000/\u00ab\u0001\u0000\u0000\u0000"+
|
||||
"1\u00ae\u0001\u0000\u0000\u00003\u00b0\u0001\u0000\u0000\u00005\u00b3"+
|
||||
"\u0001\u0000\u0000\u00007\u00b5\u0001\u0000\u0000\u00009\u00b7\u0001\u0000"+
|
||||
"\u0000\u0000;\u00b9\u0001\u0000\u0000\u0000=\u00bb\u0001\u0000\u0000\u0000"+
|
||||
"?\u00bd\u0001\u0000\u0000\u0000A\u00bf\u0001\u0000\u0000\u0000C\u00c4"+
|
||||
"\u0001\u0000\u0000\u0000E\u00ca\u0001\u0000\u0000\u0000G\u00cd\u0001\u0000"+
|
||||
"\u0000\u0000I\u00d1\u0001\u0000\u0000\u0000K\u00d9\u0001\u0000\u0000\u0000"+
|
||||
"MN\u0005c\u0000\u0000NO\u0005l\u0000\u0000OP\u0005a\u0000\u0000PQ\u0005"+
|
||||
"s\u0000\u0000QR\u0005s\u0000\u0000R\u0002\u0001\u0000\u0000\u0000ST\u0005"+
|
||||
"{\u0000\u0000T\u0004\u0001\u0000\u0000\u0000UV\u0005}\u0000\u0000V\u0006"+
|
||||
"\u0001\u0000\u0000\u0000WX\u0005;\u0000\u0000X\b\u0001\u0000\u0000\u0000"+
|
||||
"YZ\u0005s\u0000\u0000Z[\u0005t\u0000\u0000[\\\u0005a\u0000\u0000\\]\u0005"+
|
||||
"t\u0000\u0000]^\u0005i\u0000\u0000^_\u0005c\u0000\u0000_\n\u0001\u0000"+
|
||||
"\u0000\u0000`a\u0005(\u0000\u0000a\f\u0001\u0000\u0000\u0000bc\u0005)"+
|
||||
"\u0000\u0000c\u000e\u0001\u0000\u0000\u0000de\u0005,\u0000\u0000e\u0010"+
|
||||
"\u0001\u0000\u0000\u0000fg\u0005i\u0000\u0000gh\u0005n\u0000\u0000hi\u0005"+
|
||||
"t\u0000\u0000i\u0012\u0001\u0000\u0000\u0000jk\u0005b\u0000\u0000kl\u0005"+
|
||||
"o\u0000\u0000lm\u0005o\u0000\u0000mn\u0005l\u0000\u0000no\u0005e\u0000"+
|
||||
"\u0000op\u0005a\u0000\u0000pq\u0005n\u0000\u0000q\u0014\u0001\u0000\u0000"+
|
||||
"\u0000rs\u0005c\u0000\u0000st\u0005h\u0000\u0000tu\u0005a\u0000\u0000"+
|
||||
"uv\u0005r\u0000\u0000v\u0016\u0001\u0000\u0000\u0000wx\u0005p\u0000\u0000"+
|
||||
"xy\u0005u\u0000\u0000yz\u0005b\u0000\u0000z{\u0005l\u0000\u0000{|\u0005"+
|
||||
"i\u0000\u0000|}\u0005c\u0000\u0000}\u0018\u0001\u0000\u0000\u0000~\u007f"+
|
||||
"\u0005p\u0000\u0000\u007f\u0080\u0005r\u0000\u0000\u0080\u0081\u0005i"+
|
||||
"\u0000\u0000\u0081\u0082\u0005v\u0000\u0000\u0082\u0083\u0005a\u0000\u0000"+
|
||||
"\u0083\u0084\u0005t\u0000\u0000\u0084\u0085\u0005e\u0000\u0000\u0085\u001a"+
|
||||
"\u0001\u0000\u0000\u0000\u0086\u0087\u0005=\u0000\u0000\u0087\u001c\u0001"+
|
||||
"\u0000\u0000\u0000\u0088\u0089\u0005i\u0000\u0000\u0089\u008a\u0005f\u0000"+
|
||||
"\u0000\u008a\u001e\u0001\u0000\u0000\u0000\u008b\u008c\u0005e\u0000\u0000"+
|
||||
"\u008c\u008d\u0005l\u0000\u0000\u008d\u008e\u0005s\u0000\u0000\u008e\u008f"+
|
||||
"\u0005e\u0000\u0000\u008f \u0001\u0000\u0000\u0000\u0090\u0091\u0005w"+
|
||||
"\u0000\u0000\u0091\u0092\u0005h\u0000\u0000\u0092\u0093\u0005i\u0000\u0000"+
|
||||
"\u0093\u0094\u0005l\u0000\u0000\u0094\u0095\u0005e\u0000\u0000\u0095\""+
|
||||
"\u0001\u0000\u0000\u0000\u0096\u0097\u0005r\u0000\u0000\u0097\u0098\u0005"+
|
||||
"e\u0000\u0000\u0098\u0099\u0005t\u0000\u0000\u0099\u009a\u0005u\u0000"+
|
||||
"\u0000\u009a\u009b\u0005r\u0000\u0000\u009b\u009c\u0005n\u0000\u0000\u009c"+
|
||||
"$\u0001\u0000\u0000\u0000\u009d\u009e\u0005&\u0000\u0000\u009e\u009f\u0005"+
|
||||
"&\u0000\u0000\u009f&\u0001\u0000\u0000\u0000\u00a0\u00a1\u0005|\u0000"+
|
||||
"\u0000\u00a1\u00a2\u0005|\u0000\u0000\u00a2(\u0001\u0000\u0000\u0000\u00a3"+
|
||||
"\u00a4\u0005=\u0000\u0000\u00a4\u00a5\u0005=\u0000\u0000\u00a5*\u0001"+
|
||||
"\u0000\u0000\u0000\u00a6\u00a7\u0005!\u0000\u0000\u00a7\u00a8\u0005=\u0000"+
|
||||
"\u0000\u00a8,\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005<\u0000\u0000\u00aa"+
|
||||
".\u0001\u0000\u0000\u0000\u00ab\u00ac\u0005<\u0000\u0000\u00ac\u00ad\u0005"+
|
||||
"=\u0000\u0000\u00ad0\u0001\u0000\u0000\u0000\u00ae\u00af\u0005>\u0000"+
|
||||
"\u0000\u00af2\u0001\u0000\u0000\u0000\u00b0\u00b1\u0005>\u0000\u0000\u00b1"+
|
||||
"\u00b2\u0005=\u0000\u0000\u00b24\u0001\u0000\u0000\u0000\u00b3\u00b4\u0005"+
|
||||
"+\u0000\u0000\u00b46\u0001\u0000\u0000\u0000\u00b5\u00b6\u0005-\u0000"+
|
||||
"\u0000\u00b68\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005*\u0000\u0000\u00b8"+
|
||||
":\u0001\u0000\u0000\u0000\u00b9\u00ba\u0005/\u0000\u0000\u00ba<\u0001"+
|
||||
"\u0000\u0000\u0000\u00bb\u00bc\u0005%\u0000\u0000\u00bc>\u0001\u0000\u0000"+
|
||||
"\u0000\u00bd\u00be\u0005!\u0000\u0000\u00be@\u0001\u0000\u0000\u0000\u00bf"+
|
||||
"\u00c0\u0005t\u0000\u0000\u00c0\u00c1\u0005r\u0000\u0000\u00c1\u00c2\u0005"+
|
||||
"u\u0000\u0000\u00c2\u00c3\u0005e\u0000\u0000\u00c3B\u0001\u0000\u0000"+
|
||||
"\u0000\u00c4\u00c5\u0005f\u0000\u0000\u00c5\u00c6\u0005a\u0000\u0000\u00c6"+
|
||||
"\u00c7\u0005l\u0000\u0000\u00c7\u00c8\u0005s\u0000\u0000\u00c8\u00c9\u0005"+
|
||||
"e\u0000\u0000\u00c9D\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005\'\u0000"+
|
||||
"\u0000\u00cbF\u0001\u0000\u0000\u0000\u00cc\u00ce\u0007\u0000\u0000\u0000"+
|
||||
"\u00cd\u00cc\u0001\u0000\u0000\u0000\u00ce\u00cf\u0001\u0000\u0000\u0000"+
|
||||
"\u00cf\u00cd\u0001\u0000\u0000\u0000\u00cf\u00d0\u0001\u0000\u0000\u0000"+
|
||||
"\u00d0H\u0001\u0000\u0000\u0000\u00d1\u00d5\u0007\u0001\u0000\u0000\u00d2"+
|
||||
"\u00d4\u0007\u0002\u0000\u0000\u00d3\u00d2\u0001\u0000\u0000\u0000\u00d4"+
|
||||
"\u00d7\u0001\u0000\u0000\u0000\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d5"+
|
||||
"\u00d6\u0001\u0000\u0000\u0000\u00d6J\u0001\u0000\u0000\u0000\u00d7\u00d5"+
|
||||
"\u0001\u0000\u0000\u0000\u00d8\u00da\u0007\u0003\u0000\u0000\u00d9\u00d8"+
|
||||
"\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00d9"+
|
||||
"\u0001\u0000\u0000\u0000\u00db\u00dc\u0001\u0000\u0000\u0000\u00dc\u00dd"+
|
||||
"\u0001\u0000\u0000\u0000\u00dd\u00de\u0006%\u0000\u0000\u00deL\u0001\u0000"+
|
||||
"\u0000\u0000\u0004\u0000\u00cf\u00d5\u00db\u0001\u0006\u0000\u0000";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
|
||||
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
|
||||
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
INTEGERLITERAL=36
|
||||
IDENTIFIER=37
|
||||
WS=38
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
||||
';'=4
|
||||
'static'=5
|
||||
'('=6
|
||||
')'=7
|
||||
','=8
|
||||
'int'=9
|
||||
'boolean'=10
|
||||
'char'=11
|
||||
'public'=12
|
||||
'private'=13
|
||||
'='=14
|
||||
'if'=15
|
||||
'else'=16
|
||||
'while'=17
|
||||
'return'=18
|
||||
'&&'=19
|
||||
'||'=20
|
||||
'=='=21
|
||||
'!='=22
|
||||
'<'=23
|
||||
'<='=24
|
||||
'>'=25
|
||||
'>='=26
|
||||
'+'=27
|
||||
'-'=28
|
||||
'*'=29
|
||||
'/'=30
|
||||
'%'=31
|
||||
'!'=32
|
||||
'true'=33
|
||||
'false'=34
|
||||
'\''=35
|
@ -1,220 +0,0 @@
|
||||
// Generated from C:/Users/ARB00075/Documents/DH/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
* This interface defines a complete listener for a parse tree produced by
|
||||
* {@link SimpleJavaParser}.
|
||||
*/
|
||||
public interface SimpleJavaListener extends ParseTreeListener {
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterParameterList(SimpleJavaParser.ParameterListContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitParameterList(SimpleJavaParser.ParameterListContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#parameter}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterParameter(SimpleJavaParser.ParameterContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#parameter}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitParameter(SimpleJavaParser.ParameterContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterStatement(SimpleJavaParser.StatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitStatement(SimpleJavaParser.StatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#returnStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExpression(SimpleJavaParser.ExpressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExpression(SimpleJavaParser.ExpressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,139 +0,0 @@
|
||||
// Generated from C:/Users/ARB00075/Documents/DH/Compilerbau/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This interface defines a complete generic visitor for a parse tree produced
|
||||
* by {@link SimpleJavaParser}.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#constructorDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitParameterList(SimpleJavaParser.ParameterListContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#parameter}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitParameter(SimpleJavaParser.ParameterContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#type}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitType(SimpleJavaParser.TypeContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#accessType}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAccessType(SimpleJavaParser.AccessTypeContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitStatement(SimpleJavaParser.StatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIfStatement(SimpleJavaParser.IfStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#block}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBlock(SimpleJavaParser.BlockContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#expression}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExpression(SimpleJavaParser.ExpressionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitLiteral(SimpleJavaParser.LiteralContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
|
||||
}
|
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,6 +1,6 @@
|
||||
package semantic;
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import oldAst.type.TypeNode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
|
@ -1,31 +1,38 @@
|
||||
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 oldAst.*;
|
||||
import oldAst.expression.*;
|
||||
import oldAst.member.FieldNode;
|
||||
import oldAst.member.MemberNode;
|
||||
|
||||
import ast.member.MethodNode;
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.*;
|
||||
import oldAst.member.MethodNode;
|
||||
import oldAst.parameter.ParameterListNode;
|
||||
import oldAst.parameter.ParameterNode;
|
||||
import oldAst.statement.*;
|
||||
import oldAst.type.ReferenceTypeNode;
|
||||
import oldAst.expression.This;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import oldAst.type.BaseTypeNode;
|
||||
import oldAst.type.TypeNode;
|
||||
import semantic.context.Context;
|
||||
import semantic.exeptions.AlreadyDeclearedException;
|
||||
import semantic.exeptions.NotDeclearedException;
|
||||
import semantic.exeptions.TypeMismatchException;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
private static ArrayList<String> currentFields = new ArrayList<>();
|
||||
private static HashMap<String, TypeNode> currentFields = new HashMap<>();
|
||||
|
||||
public static ArrayList<Exception> errors = new ArrayList<>();
|
||||
|
||||
private Context context;
|
||||
private static Scope currentScope;
|
||||
private static ClassNode currentClass;
|
||||
|
||||
@ -56,6 +63,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 +78,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) {
|
||||
@ -134,11 +142,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(FieldNode toCheck) {
|
||||
if (currentFields.contains(toCheck.identifier)) {
|
||||
if (currentFields.get(toCheck.identifier) != null) {
|
||||
errors.add(new AlreadyDeclearedException("Already declared " + toCheck.identifier));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
currentFields.add(toCheck.identifier);
|
||||
currentFields.put(toCheck.identifier, toCheck.type);
|
||||
}
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
@ -146,18 +154,59 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignmentStatementNode assignmentStatementNode) {
|
||||
boolean valid = true;
|
||||
ExpressionNode expressionNodeLeft = assignmentStatementNode.expressionLeft;
|
||||
var resultLeft = expressionNodeLeft.accept(this);
|
||||
valid = valid && resultLeft.isValid();
|
||||
ExpressionNode expressionNodeRight = assignmentStatementNode.expressionRight;
|
||||
var resultRight = expressionNodeRight.accept(this);
|
||||
valid = valid && resultRight.isValid();
|
||||
|
||||
if(Objects.equals(resultLeft.getType(), resultRight.getType())){
|
||||
System.out.println("SAME TYPE");
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Type mismatch"));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(BinaryExpressionNode toCheck) {
|
||||
boolean valid = true;
|
||||
ExpressionNode left = toCheck.left;
|
||||
var resultLeft = left.accept(this);
|
||||
ExpressionNode right = toCheck.right;
|
||||
var resultRight = right.accept(this);
|
||||
|
||||
switch (toCheck.operator) {
|
||||
case ASSIGNMENT:
|
||||
if(Objects.equals(resultRight.getType(), resultLeft.getType())){
|
||||
System.out.println("Correct Type");
|
||||
} else {
|
||||
valid = false;
|
||||
errors.add(new TypeMismatchException("Type Mismatch " + resultLeft.getType() + " and " + resultRight.getType()));
|
||||
}
|
||||
break;
|
||||
case DOT:
|
||||
return new TypeCheckResult(true, resultRight.getType());
|
||||
default:
|
||||
throw new RuntimeException("Unexpected operator: " + toCheck.operator);
|
||||
}
|
||||
|
||||
return new TypeCheckResult(valid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IdentifierExpressionNode toCheck) {
|
||||
return null;
|
||||
if(toCheck.name == "this"){
|
||||
return new TypeCheckResult(true, null);
|
||||
} else if (currentFields.get(toCheck.name) == null) {
|
||||
errors.add(new AlreadyDeclearedException("Not declared " + toCheck.name + " in this scope"));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
return new TypeCheckResult(false, currentFields.get(toCheck.name));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,4 +240,40 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(LiteralNode toCheck) {
|
||||
return new TypeCheckResult(true, toCheck.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(InstVar toCheck) {
|
||||
boolean valid = true;
|
||||
|
||||
var result = toCheck.expression.accept(this);
|
||||
|
||||
if(result.getType() instanceof BaseTypeNode){
|
||||
throw new RuntimeException("BaseType has no Methods or Fields");
|
||||
} else {
|
||||
//Get typ of Field
|
||||
|
||||
var type = (ReferenceTypeNode)result.getType();
|
||||
var classContext = context.getClass(type.getIdentifier());
|
||||
|
||||
if(classContext == null){
|
||||
errors.add(new NotDeclearedException("Not declared " + type.getIdentifier() + " in this scope"));
|
||||
return new TypeCheckResult(false, null);
|
||||
} else {
|
||||
var field = classContext.getField(toCheck.identifier);
|
||||
|
||||
return new TypeCheckResult(valid, field.getType());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(This toCheck) {
|
||||
return new TypeCheckResult(true, toCheck.getType());
|
||||
}
|
||||
|
||||
}
|
@ -2,13 +2,17 @@ package semantic;
|
||||
|
||||
|
||||
import ast.ClassNode;
|
||||
import ast.expression.LiteralNode;
|
||||
import ast.ProgramNode;
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.IdentifierExpressionNode;
|
||||
import ast.expression.UnaryExpressionNode;
|
||||
import ast.expression.InstVar;
|
||||
import ast.expression.unaryexpression.UnaryExpressionNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.statement.*;
|
||||
import ast.expression.This;
|
||||
import ast.statement.ifstatement.IfStatementNode;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public interface SemanticVisitor {
|
||||
@ -36,4 +40,10 @@ public interface SemanticVisitor {
|
||||
TypeCheckResult analyze(ReturnStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(WhileStatementNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(LiteralNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(InstVar toCheck);
|
||||
|
||||
TypeCheckResult analyze(This 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 oldAst.ClassNode;
|
||||
import oldAst.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 oldAst.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 oldAst.member.FieldNode;
|
||||
import oldAst.type.AccessTypeNode;
|
||||
import oldAst.type.TypeNode;
|
||||
|
||||
public class FieldContext {
|
||||
|
||||
private AccessTypeNode accessModifier;
|
||||
private TypeNode type;
|
||||
|
||||
public FieldContext(FieldNode field) {
|
||||
accessModifier = field.accessTypeNode;
|
||||
type = field.type;
|
||||
}
|
||||
|
||||
public TypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
@ -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,7 +1,7 @@
|
||||
package typechecker;
|
||||
|
||||
|
||||
import ast.type.TypeNode;
|
||||
import oldAst.type.TypeNode;
|
||||
|
||||
public class TypeCheckResult {
|
||||
|
||||
|
@ -4,8 +4,8 @@ import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import parser.ASTBuilder;
|
||||
import ast.ClassNode;
|
||||
import ast.ProgramNode;
|
||||
import oldAst.ClassNode;
|
||||
import oldAst.ProgramNode;
|
||||
import bytecode.ByteCodeGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
76
src/test/java/semantic/Mocker.java
Normal file
76
src/test/java/semantic/Mocker.java
Normal file
@ -0,0 +1,76 @@
|
||||
package semantic;
|
||||
|
||||
import oldAst.ClassNode;
|
||||
import oldAst.expression.LiteralNode;
|
||||
import oldAst.ProgramNode;
|
||||
import oldAst.expression.*;
|
||||
import oldAst.member.FieldNode;
|
||||
import oldAst.member.MemberNode;
|
||||
import oldAst.member.MethodNode;
|
||||
import oldAst.parameter.ParameterListNode;
|
||||
import oldAst.parameter.ParameterNode;
|
||||
import oldAst.statement.AssignmentStatementNode;
|
||||
import oldAst.statement.StatementNode;
|
||||
import oldAst.type.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Mocker {
|
||||
|
||||
public static ProgramNode mockCorrectProgrammNode(){
|
||||
|
||||
ProgramNode programNode = new ProgramNode();
|
||||
List<ClassNode> classList = new ArrayList<ClassNode>();
|
||||
AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC);
|
||||
ClassNode classNode = new ClassNode(accessTypeNode, "testClass");
|
||||
|
||||
MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar1");
|
||||
classNode.members.add(memberNode1);
|
||||
|
||||
MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "objectVar");
|
||||
classNode.members.add(memberNode2);
|
||||
|
||||
List<ParameterNode> parameterNodeList = new ArrayList<ParameterNode>();
|
||||
ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1");
|
||||
parameterNodeList.add(parameterNode1);
|
||||
ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList);
|
||||
|
||||
List<StatementNode> statementNodeList = new ArrayList<StatementNode>();
|
||||
|
||||
ExpressionNode expressionNodeLeft = new InstVar(new This("testClass"), "objectVar");
|
||||
|
||||
LiteralNode expressionNodeRight = new LiteralNode();
|
||||
expressionNodeRight.setType(new BaseTypeNode(EnumTypeNode.INT));
|
||||
|
||||
StatementNode statementNode1 = new AssignmentStatementNode(expressionNodeLeft, expressionNodeRight);
|
||||
statementNodeList.add(statementNode1);
|
||||
|
||||
MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList );
|
||||
classNode.members.add(memberNode3);
|
||||
|
||||
classList.add(classNode);
|
||||
programNode.classes = classList;
|
||||
|
||||
return programNode;
|
||||
|
||||
}
|
||||
|
||||
public static ProgramNode mockFieldNodeAlreadyDeclaredProgrammNode(){
|
||||
ProgramNode programNode = new ProgramNode();
|
||||
List<ClassNode> classList = new ArrayList<ClassNode>();
|
||||
AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC);
|
||||
ClassNode classNode = new ClassNode(accessTypeNode, "testClass");
|
||||
|
||||
MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar");
|
||||
classNode.members.add(memberNode1);
|
||||
|
||||
MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar");
|
||||
classNode.members.add(memberNode2);
|
||||
|
||||
classList.add(classNode);
|
||||
programNode.classes = classList;
|
||||
|
||||
return programNode;
|
||||
}
|
||||
}
|
@ -1,31 +1,19 @@
|
||||
package semantic;
|
||||
|
||||
|
||||
import ast.*;
|
||||
import ast.expression.BinaryExpressionNode;
|
||||
import ast.expression.ExpressionNode;
|
||||
import ast.expression.ExpresssionOperator;
|
||||
import ast.expression.IdentifierExpressionNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MemberNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.parameter.ParameterListNode;
|
||||
import ast.parameter.ParameterNode;
|
||||
import ast.statement.AssignmentStatementNode;
|
||||
import ast.statement.StatementNode;
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.BaseTypeNode;
|
||||
import ast.type.EnumAccessTypeNode;
|
||||
import ast.type.EnumTypeNode;
|
||||
import bytecode.ByteCodeGenerator;
|
||||
import oldAst.*;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import semantic.exeptions.AlreadyDeclearedException;
|
||||
import semantic.exeptions.TypeMismatchException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SemanticTest {
|
||||
|
||||
@ -35,24 +23,18 @@ public class SemanticTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alreadyDeclaredLocalFieldVar(){
|
||||
public void alreadyDeclaredLocalFieldVar() {
|
||||
|
||||
ProgramNode programNode = new ProgramNode();
|
||||
List<ClassNode> classList = new ArrayList<ClassNode>();
|
||||
AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC);
|
||||
ClassNode classNode = new ClassNode(accessTypeNode, "testClass");
|
||||
//Arrange
|
||||
|
||||
MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar");
|
||||
classNode.members.add(memberNode1);
|
||||
ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode();
|
||||
|
||||
MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar");
|
||||
classNode.members.add(memberNode2);
|
||||
|
||||
classList.add(classNode);
|
||||
programNode.classes = classList;
|
||||
//Act
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(programNode);
|
||||
|
||||
//Assert
|
||||
|
||||
assertEquals(1, SemanticAnalyzer.errors.size());
|
||||
assertEquals(true, SemanticAnalyzer.errors.get(0) instanceof AlreadyDeclearedException);
|
||||
assertEquals(null, typedAst);
|
||||
@ -60,53 +42,120 @@ public class SemanticTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWorkWithNoError(){
|
||||
public void alreadyDecleared() {
|
||||
|
||||
ProgramNode programNode = new ProgramNode();
|
||||
List<ClassNode> classList = new ArrayList<ClassNode>();
|
||||
AccessTypeNode accessTypeNode = new AccessTypeNode(EnumAccessTypeNode.PUBLIC);
|
||||
ClassNode classNode = new ClassNode(accessTypeNode, "testClass");
|
||||
//Arrange
|
||||
|
||||
MemberNode memberNode1 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar1");
|
||||
classNode.members.add(memberNode1);
|
||||
ProgramNode programNode = Mocker.mockFieldNodeAlreadyDeclaredProgrammNode();
|
||||
|
||||
MemberNode memberNode2 = new FieldNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2");
|
||||
classNode.members.add(memberNode2);
|
||||
|
||||
List<ParameterNode> parameterNodeList = new ArrayList<ParameterNode>();
|
||||
ParameterNode parameterNode1 = new ParameterNode(new BaseTypeNode(EnumTypeNode.INT), "param1");
|
||||
parameterNodeList.add(parameterNode1);
|
||||
ParameterListNode parameterListNode = new ParameterListNode(parameterNodeList);
|
||||
|
||||
List<StatementNode> statementNodeList = new ArrayList<StatementNode>();
|
||||
|
||||
ExpressionNode expressionNodeObjectVariableLeft = new IdentifierExpressionNode("Example", null);
|
||||
ExpressionNode expressionNodeObjectVariableRight = new IdentifierExpressionNode("objectVar", new BaseTypeNode(EnumTypeNode.INT));
|
||||
|
||||
ExpressionNode expressionNodeLeft = new BinaryExpressionNode(expressionNodeObjectVariableLeft, expressionNodeObjectVariableRight, ExpresssionOperator.DOT);
|
||||
|
||||
ExpressionNode expressionNodeRight = new LiteralNode(1);
|
||||
|
||||
BinaryExpressionNode expressionNode = new BinaryExpressionNode(expressionNodeLeft, expressionNodeRight, ExpresssionOperator.ASSIGNMENT);
|
||||
|
||||
StatementNode statementNode1 = new AssignmentStatementNode(expressionNode);
|
||||
statementNodeList.add(statementNode1);
|
||||
|
||||
MemberNode memberNode3 = new MethodNode(accessTypeNode, new BaseTypeNode(EnumTypeNode.INT), "testVar2",parameterListNode, statementNodeList );
|
||||
classNode.members.add(memberNode3);
|
||||
|
||||
|
||||
|
||||
classList.add(classNode);
|
||||
programNode.classes = classList;
|
||||
//Act
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(programNode);
|
||||
|
||||
//Assert
|
||||
|
||||
assertEquals(1, SemanticAnalyzer.errors.size());
|
||||
assertInstanceOf(AlreadyDeclearedException.class, SemanticAnalyzer.errors.getFirst());
|
||||
assertNull(typedAst);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWorkWithNoError() {
|
||||
|
||||
//Arrange
|
||||
|
||||
ProgramNode programNode = Mocker.mockCorrectProgrammNode();
|
||||
|
||||
//Act
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(programNode);
|
||||
|
||||
//Assert
|
||||
|
||||
assertEquals(0, SemanticAnalyzer.errors.size());
|
||||
assertEquals(programNode, typedAst);
|
||||
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator();
|
||||
byteCodeGenerator.visit((ProgramNode) typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refTypeCorrect() {
|
||||
|
||||
//Arrange
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ProgramNode programNode = null;
|
||||
try{
|
||||
programNode = objectMapper.readValue(new File("src/test/resources/semantic/correctRefType.json"), ProgramNode.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Act
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(programNode);
|
||||
|
||||
//Assert
|
||||
|
||||
assertEquals(0, SemanticAnalyzer.errors.size());
|
||||
assertEquals(programNode, typedAst);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonWriteTest() {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
//Arrange
|
||||
|
||||
ProgramNode programNode = Mocker.mockCorrectProgrammNode();
|
||||
try{
|
||||
objectMapper.writeValue(new File("src/test/resources/semantic/test.json"), programNode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonReadTest() {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
ProgramNode programNode1 = null;
|
||||
try{
|
||||
programNode1 = objectMapper.readValue(new File("src/test/resources/semantic/test.json"), ProgramNode.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ProgramNode programNode2 = Mocker.mockCorrectProgrammNode();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeMismatch() {
|
||||
|
||||
//Arrange
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ProgramNode programNode = null;
|
||||
try{
|
||||
programNode = objectMapper.readValue(new File("src/test/resources/semantic/refTypeMismatch.json"), ProgramNode.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Act
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(programNode);
|
||||
|
||||
//Assert
|
||||
|
||||
assertEquals(1, SemanticAnalyzer.errors.size());
|
||||
assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst());
|
||||
assertNull(typedAst);
|
||||
|
||||
}
|
||||
|
||||
|
70
src/test/resources/semantic/correctRefType.json
Normal file
70
src/test/resources/semantic/correctRefType.json
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"classes": [
|
||||
{
|
||||
"identifier": "testClass1",
|
||||
"accessType": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
"@type": "Field",
|
||||
"accessTypeNode": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "testVar1"
|
||||
},
|
||||
{
|
||||
"@type": "Method",
|
||||
"visibility": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "testMethod",
|
||||
"parameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "param1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"statements": [
|
||||
{
|
||||
"@type": "Assignment",
|
||||
"expressionLeft": {
|
||||
"@type": "InstVar",
|
||||
"identifier": "testVar1",
|
||||
"expression": {
|
||||
"@type": "This",
|
||||
"type": {
|
||||
"@type": "Reference",
|
||||
"identifier": "testClass1"
|
||||
}
|
||||
},
|
||||
"type": null
|
||||
},
|
||||
"expressionRight": {
|
||||
"@type": "Literal",
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"hasConstructor": false
|
||||
}
|
||||
]
|
||||
}
|
133
src/test/resources/semantic/refTypeMismatch.json
Normal file
133
src/test/resources/semantic/refTypeMismatch.json
Normal file
@ -0,0 +1,133 @@
|
||||
{
|
||||
"classes": [
|
||||
{
|
||||
"identifier": "testClass1",
|
||||
"accessType": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
"@type": "Field",
|
||||
"accessTypeNode": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "testVar1"
|
||||
},
|
||||
{
|
||||
"@type": "Method",
|
||||
"visibility": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "testMethod",
|
||||
"parameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "param1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"statements": [
|
||||
{
|
||||
"@type": "Assignment",
|
||||
"expressionLeft": {
|
||||
"@type": "InstVar",
|
||||
"identifier": "testVar1",
|
||||
"expression": {
|
||||
"@type": "This",
|
||||
"type": {
|
||||
"@type": "Reference",
|
||||
"identifier": "testClass1"
|
||||
}
|
||||
},
|
||||
"type": null
|
||||
},
|
||||
"expressionRight": {
|
||||
"@type": "Literal",
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "BOOLEAN"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"hasConstructor": false,
|
||||
"methods": [
|
||||
{
|
||||
"@type": "Method",
|
||||
"visibility": {
|
||||
"enumAccessTypeNode": "PUBLIC"
|
||||
},
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "testMethod",
|
||||
"parameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "INT"
|
||||
},
|
||||
"identifier": "param1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"statements": [
|
||||
{
|
||||
"@type": "Assignment",
|
||||
"expressionLeft": {
|
||||
"@type": "InstVar",
|
||||
"identifier": "testVar",
|
||||
"expression": {
|
||||
"@type": "InstVar",
|
||||
"identifier": "testVar",
|
||||
"expression": {
|
||||
"@type": "This",
|
||||
"type": {
|
||||
"@type": "Reference",
|
||||
"identifier": "testClass2"
|
||||
}
|
||||
},
|
||||
"type": null
|
||||
},
|
||||
"type": null
|
||||
},
|
||||
"expressionRight": {
|
||||
"@type": "Literal",
|
||||
"type": null
|
||||
},
|
||||
"type": null
|
||||
},
|
||||
{
|
||||
"@type": "VariableDeclaration",
|
||||
"type": {
|
||||
"@type": "Base",
|
||||
"enumType": "CHAR"
|
||||
},
|
||||
"identifier": "objectVar",
|
||||
"expression": {
|
||||
"@type": "Literal",
|
||||
"type": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
1
src/test/resources/semantic/test.json
Normal file
1
src/test/resources/semantic/test.json
Normal file
@ -0,0 +1 @@
|
||||
{"classes":[{"identifier":"testClass","accessType":{"enumAccessTypeNode":"PUBLIC"},"members":[{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar1"},{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"objectVar"},{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}],"hasConstructor":false,"methods":[{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}]}]}
|
Loading…
Reference in New Issue
Block a user