From 334f4704887d3d0c5f2d6bc2c7eefabc1258050e Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 9 May 2024 15:25:46 +0200 Subject: [PATCH 1/5] Maven structure --- .idea/.gitignore | 3 + .idea/libraries/asm_9_7.xml | 9 + .idea/misc.xml | 6 + .idea/modules.xml | 9 + .idea/vcs.xml | 6 + NichtHaskell.iml | 12 + src/NichtHaskell1.iml | 12 + src/main/java/Compiler.java | 64 + src/main/java/Decaf.g4 | 128 + src/main/java/EmptyClass.java | 2 + src/main/java/TypeCheck/AbstractType.java | 15 + src/main/java/TypeCheck/TypeCheckHelper.java | 32 + src/main/java/TypeCheck/TypeCheckResult.java | 5 + .../abstractSyntaxTree/Class/FieldDecl.java | 46 + .../java/abstractSyntaxTree/Class/IClass.java | 16 + .../abstractSyntaxTree/Class/MethodDecl.java | 33 + .../abstractSyntaxTree/Class/RefType.java | 76 + .../Datatype/BoolDatatype.java | 27 + .../Datatype/CharDatatype.java | 27 + .../Datatype/IDatatype.java | 15 + .../Datatype/IntDatatype.java | 34 + .../Expression/BinaryExpression.java | 170 + .../Expression/IExpression.java | 12 + .../Expression/InstVarExpression.java | 32 + .../Expression/UnaryExpression.java | 65 + .../Expression/VarRefExpression.java | 23 + src/main/java/abstractSyntaxTree/Program.java | 95 + .../Statement/BlockStatement.java | 49 + .../Statement/EmptyStatement.java | 19 + .../Statement/IStatement.java | 13 + .../Statement/IfElseStatement.java | 58 + .../Statement/IfStatement.java | 49 + .../Statement/ReturnStatement.java | 51 + .../Statement/WhileStatement.java | 50 + .../AssignStatementExpression.java | 50 + .../MethodCallStatementExpression.java | 64 + .../NewStatementExpression.java | 19 + .../SuperStatementExpression.java | 10 + src/main/java/gen/Decaf.interp | 136 + src/main/java/gen/Decaf.tokens | 81 + src/main/java/gen/DecafBaseListener.java | 459 +++ src/main/java/gen/DecafBaseVisitor.java | 259 ++ src/main/java/gen/DecafLexer.interp | 155 + src/main/java/gen/DecafLexer.java | 338 ++ src/main/java/gen/DecafLexer.tokens | 81 + src/main/java/gen/DecafListener.java | 359 +++ src/main/java/gen/DecafParser.java | 2864 +++++++++++++++++ src/main/java/gen/DecafVisitor.java | 222 ++ 48 files changed, 6360 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/libraries/asm_9_7.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 NichtHaskell.iml create mode 100644 src/NichtHaskell1.iml create mode 100644 src/main/java/Compiler.java create mode 100644 src/main/java/Decaf.g4 create mode 100644 src/main/java/EmptyClass.java create mode 100644 src/main/java/TypeCheck/AbstractType.java create mode 100644 src/main/java/TypeCheck/TypeCheckHelper.java create mode 100644 src/main/java/TypeCheck/TypeCheckResult.java create mode 100644 src/main/java/abstractSyntaxTree/Class/FieldDecl.java create mode 100644 src/main/java/abstractSyntaxTree/Class/IClass.java create mode 100644 src/main/java/abstractSyntaxTree/Class/MethodDecl.java create mode 100644 src/main/java/abstractSyntaxTree/Class/RefType.java create mode 100644 src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java create mode 100644 src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java create mode 100644 src/main/java/abstractSyntaxTree/Datatype/IDatatype.java create mode 100644 src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java create mode 100644 src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java create mode 100644 src/main/java/abstractSyntaxTree/Expression/IExpression.java create mode 100644 src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java create mode 100644 src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java create mode 100644 src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java create mode 100644 src/main/java/abstractSyntaxTree/Program.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/BlockStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/IStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/IfStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java create mode 100644 src/main/java/abstractSyntaxTree/Statement/WhileStatement.java create mode 100644 src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java create mode 100644 src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java create mode 100644 src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java create mode 100644 src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java create mode 100644 src/main/java/gen/Decaf.interp create mode 100644 src/main/java/gen/Decaf.tokens create mode 100644 src/main/java/gen/DecafBaseListener.java create mode 100644 src/main/java/gen/DecafBaseVisitor.java create mode 100644 src/main/java/gen/DecafLexer.interp create mode 100644 src/main/java/gen/DecafLexer.java create mode 100644 src/main/java/gen/DecafLexer.tokens create mode 100644 src/main/java/gen/DecafListener.java create mode 100644 src/main/java/gen/DecafParser.java create mode 100644 src/main/java/gen/DecafVisitor.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/libraries/asm_9_7.xml b/.idea/libraries/asm_9_7.xml new file mode 100644 index 0000000..d5564c6 --- /dev/null +++ b/.idea/libraries/asm_9_7.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0b5faa7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/NichtHaskell.iml b/NichtHaskell.iml new file mode 100644 index 0000000..d55d4c8 --- /dev/null +++ b/NichtHaskell.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NichtHaskell1.iml b/src/NichtHaskell1.iml new file mode 100644 index 0000000..2336fe3 --- /dev/null +++ b/src/NichtHaskell1.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/Compiler.java b/src/main/java/Compiler.java new file mode 100644 index 0000000..d993d97 --- /dev/null +++ b/src/main/java/Compiler.java @@ -0,0 +1,64 @@ +import abstractSyntaxTree.Class.FieldDecl; +import abstractSyntaxTree.Class.MethodDecl; +import abstractSyntaxTree.Class.RefType; +import abstractSyntaxTree.Program; +import gen.DecafLexer; +import gen.DecafParser; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; + +import java.io.CharArrayReader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +public class Compiler { + + public static void main(String[] args) throws Exception{ + + // get file +// String filePath = "EmptyClass.java"; +// String content = new String(Files.readAllBytes(Paths.get(filePath))); +// CharArrayReader charStream = new CharArrayReader(content.toCharArray()); + + CharStream codeCharStream = CharStreams.fromString("class Example { }"); + DecafLexer lexer = new DecafLexer(codeCharStream); + CommonTokenStream tokens = new CommonTokenStream(lexer); + + System.out.println("--- print tokens ---"); + tokens.fill(); + + List tokenList = tokens.getTokens(); + + StringBuilder stringBuilder = new StringBuilder(); + for (Token token : tokenList) { + stringBuilder.append(token.toString()).append(" "); + } + String readableTokens = stringBuilder.toString().trim(); + + System.out.println(readableTokens); + + + DecafParser parser = new DecafParser(tokens); + + ParseTree tree = parser.program(); + + System.out.println("--- print tree ---"); + System.out.println(tree); + + + + Program abstractSyntaxTree = new Program(new ArrayList<>()); + List emptyFieldDecl = new ArrayList<>(); + List emptyMethodDecl = new ArrayList<>(); + abstractSyntaxTree.classes.add(new RefType(emptyFieldDecl, emptyMethodDecl, null, null, "MyClass")); + + abstractSyntaxTree.typeCheck(); + + abstractSyntaxTree.codeGen(); + } +} diff --git a/src/main/java/Decaf.g4 b/src/main/java/Decaf.g4 new file mode 100644 index 0000000..2af8297 --- /dev/null +++ b/src/main/java/Decaf.g4 @@ -0,0 +1,128 @@ +grammar Decaf; + +program: classdecl+; + +//class identifier{...} +classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; +constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method without + +//Method and FieldVar +methodDecl: AccessModifierPublic? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; +fieldDecl: AccessModifierPublic? type Identifier Semicolon; + +//Parameters +parameterList: parameter(Comma parameter)*; +parameter: type Identifier; + +//property, object.a, 3+1, a = 3 +expression: subExpression | binaryExpr; +//subExpression to dissolve left-recusion +subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression ClosedRoundBracket; +assignableExpr: Identifier | instVar; +instVar: subReceiver? receivingMethod* Identifier; + +//.trim().toLength().toLowerCase().count ... +methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; +argumentList: expression? | expression (Comma expression)+; + +subReceiver: ((This | newDecl | Identifier) Dot); +receiver: ((This | instVar | newDecl | Identifier) Dot); +receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; + + +binaryExpr: calcExpr | nonCalcExpr| value | Not binaryExpr; + +calcExpr: calcExpr LineOperator dotExpr | dotExpr; +dotExpr: dotExpr DotOperator dotSubExpr | dotSubExpr; +dotSubExpr: IntValue | Identifier | instVar | methodCall | OpenRoundBracket calcExpr ClosedRoundBracket; +nonCalcExpr: subExpression nonCalcOperator expression; +nonCalcOperator: LogicalOpertor | ComparisonOperator; + +//Statement but also expression +//a = expr, new Object(), method(param1) +stmtExpr: assign | newDecl | methodCall; + +//Statements +//int a, {...}, while(a > 10){...}, if(...){...} else if{...} else{...} +statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; +returnStmt: Return (expression)?; +localVarDecl: type Identifier (Assign expression)?; +block: OpenCurlyBracket statement* ClosedCurlyBracket; +whileStmt: While OpenRoundBracket expression ClosedRoundBracket statement; +ifElseStmt: ifStmt elseStmt?; +ifStmt: If OpenRoundBracket expression ClosedRoundBracket statement; +elseStmt: Else statement; +assign: assignableExpr Assign expression; +newDecl: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; + + +type: Int | Boolean | Char | Identifier; +value: IntValue | BooleanValue | CharValue | NullValue; + +//Access modifier +AccessModifierPublic : 'public' ; +MainMethodDecl : 'public static void main(String[] args)'; + + + +//Operators +DotOperator : Multipilkation | Division | Modulo; +LineOperator : Plus | Minus; +ComparisonOperator : Greater | Less | GreaterEqual | LessEqual | Equal | NotEqual; +LogicalOpertor : And | Or; + +Assign : '='; +Minus : '-'; +Plus : '+'; +Multipilkation : '*'; +Division : '/'; +Modulo : '%'; +Greater : '>'; +Less : '<'; +GreaterEqual : '>='; +LessEqual : '<='; +Equal : '=='; +NotEqual : '!='; +Not : '!'; +And : '&&'; +Or : '||'; + +//Symbols +Dot : '.'; +OpenRoundBracket : '('; +ClosedRoundBracket : ')'; +OpenCurlyBracket : '{'; +ClosedCurlyBracket : '}'; +Semicolon : ';'; +Comma : ','; + +//Keywords +Class : 'class'; +This : 'this'; +While : 'while'; +If : 'if'; +Else : 'else'; +Return : 'return'; +New : 'new'; + +//Identifier +fragment Alpabetic : [a-zA-Z]; +fragment Numeric: [0-9]; +fragment ValidIdentSymbols : Alpabetic|Numeric|'$'|'_'; +Identifier: Alpabetic ValidIdentSymbols*; + +//Types +Void : 'void'; +Int : 'int'; +Boolean : 'bool'; +Char : 'char'; + +//Values +IntValue : ('+'|'-')*[0-9]+; +CharValue: '\''~[\r\n]?'\''; +BooleanValue: 'true'|'false'; +NullValue: 'null'; + +//Whitespace? Right into the trash it gooeesss +WS : [ \t\r\n] -> skip; + diff --git a/src/main/java/EmptyClass.java b/src/main/java/EmptyClass.java new file mode 100644 index 0000000..a3496cf --- /dev/null +++ b/src/main/java/EmptyClass.java @@ -0,0 +1,2 @@ +class EmptyClass { +} diff --git a/src/main/java/TypeCheck/AbstractType.java b/src/main/java/TypeCheck/AbstractType.java new file mode 100644 index 0000000..ea2fd30 --- /dev/null +++ b/src/main/java/TypeCheck/AbstractType.java @@ -0,0 +1,15 @@ +package TypeCheck; + +import TypeCheck.TypeCheckResult; + +public abstract class AbstractType { + TypeCheckResult typeCheckResult; + + public void setTypeCheckResult(TypeCheckResult typeCheckResult) { + this.typeCheckResult = typeCheckResult; + } + + public TypeCheckResult getTypeCheckResult() { + return typeCheckResult; + } +} \ No newline at end of file diff --git a/src/main/java/TypeCheck/TypeCheckHelper.java b/src/main/java/TypeCheck/TypeCheckHelper.java new file mode 100644 index 0000000..bd4aa58 --- /dev/null +++ b/src/main/java/TypeCheck/TypeCheckHelper.java @@ -0,0 +1,32 @@ +package TypeCheck; + +import java.util.List; +import java.util.Objects; + +public class TypeCheckHelper { + public String upperBound(String type1, String type2) throws Exception{ + boolean type1Primitiv = Objects.equals(type1, "bool") || Objects.equals(type1, "int") || Objects.equals(type1, "char"); + boolean type2Primitiv = Objects.equals(type2, "bool") || Objects.equals(type2, "int") || Objects.equals(type2, "char"); + + String result; + if(type1Primitiv && type2Primitiv){ + if(Objects.equals(type1, type2)){ + result = type1; + } + throw new Exception("no upper bound"); + }else if(type1Primitiv || type2Primitiv){ + throw new Exception("no upper bound"); + }else{ + result = "class"; + } + return result; + } + public static boolean typeExists(String type, List typeslist) { + + if(type.equals("int") || type.equals("bool") || type.equals("char")){ + return true; + } + return typeslist.contains(type); + } + +} diff --git a/src/main/java/TypeCheck/TypeCheckResult.java b/src/main/java/TypeCheck/TypeCheckResult.java new file mode 100644 index 0000000..6382b99 --- /dev/null +++ b/src/main/java/TypeCheck/TypeCheckResult.java @@ -0,0 +1,5 @@ +package TypeCheck; + +public class TypeCheckResult { + public String type; +} diff --git a/src/main/java/abstractSyntaxTree/Class/FieldDecl.java b/src/main/java/abstractSyntaxTree/Class/FieldDecl.java new file mode 100644 index 0000000..a02fb36 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Class/FieldDecl.java @@ -0,0 +1,46 @@ +package abstractSyntaxTree.Class; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckHelper; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Program; +import org.objectweb.asm.ClassWriter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class FieldDecl extends AbstractType implements IClass{ + + private HashMap> typeContext; // form class from program + public String type; // from parser + public String identifier; // from parser + + public FieldDecl(HashMap> typeContext){ + this.typeContext = typeContext; + } + public TypeCheckResult typeCheck(List classFieldsIdentifier) throws Exception { + TypeCheckResult result = new TypeCheckResult(); + if (classFieldsIdentifier.contains(this.identifier)){ + throw new Exception("field already defined"); + } else { + classFieldsIdentifier.add(this); + } + //TypeCheckHelper.typeExists(type, ) // need all types of classes + setTypeCheckResult(result); + + return result; + + //write field table + } + + @Override + public TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception { + return null; + } + + @Override + public void codeGen(ClassWriter cw) { + + } +} diff --git a/src/main/java/abstractSyntaxTree/Class/IClass.java b/src/main/java/abstractSyntaxTree/Class/IClass.java new file mode 100644 index 0000000..cfd14e3 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Class/IClass.java @@ -0,0 +1,16 @@ +package abstractSyntaxTree.Class; + +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.TypeReference; + +import java.util.HashMap; +import java.util.List; + +public interface IClass { + // visit method for code generation + + TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception; + void codeGen(ClassWriter cw) throws Exception; + +} diff --git a/src/main/java/abstractSyntaxTree/Class/MethodDecl.java b/src/main/java/abstractSyntaxTree/Class/MethodDecl.java new file mode 100644 index 0000000..6e12a51 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Class/MethodDecl.java @@ -0,0 +1,33 @@ +package abstractSyntaxTree.Class; + +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Program; +import org.objectweb.asm.ClassWriter; + +import java.util.HashMap; +import java.util.List; + +public class MethodDecl implements IClass { + + public String classThatContainsMethod; + public String name; + public List parameters; + public String returnType; + + + //TODO: Move this into the typeCheck + private HashMap localVars; // (type, identifier) // add content here + + public TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception { + // write localvars + + + // jede methode als block statement aufrufen + return null; + } + + @Override + public void codeGen(ClassWriter cw) throws Exception { + + } +} diff --git a/src/main/java/abstractSyntaxTree/Class/RefType.java b/src/main/java/abstractSyntaxTree/Class/RefType.java new file mode 100644 index 0000000..3018ec7 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Class/RefType.java @@ -0,0 +1,76 @@ +package abstractSyntaxTree.Class; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Class.FieldDecl; +import abstractSyntaxTree.Class.MethodDecl; +import abstractSyntaxTree.Datatype.IDatatype; +import abstractSyntaxTree.Program; +import jdk.jshell.spi.ExecutionControl; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +import java.util.HashMap; +import java.util.List; + +public class RefType extends AbstractType implements IClass { + + public String name; + public List fieldDecls; + public List methodDecls; + private HashMap> typeContext; // (class, (type, identifier)) + public HashMap>>> methodContext; // (class, (returntype, (identifier, parameter))) + private boolean hasMain; + + public RefType(List fieldDecls, + List methodDecls, + HashMap> typeContext, + HashMap>>> methodContext, String name){ + this.name = name; + this.fieldDecls = fieldDecls; + this.methodDecls = methodDecls; + this.typeContext = typeContext; + this.methodContext = methodContext; + } + + + + @Override + public TypeCheckResult typeCheck(HashMap>>> methodContext, + HashMap> typeContext, List fieldsOrMethods) throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + for (FieldDecl fieldDecl : fieldDecls) { + fieldDecl.typeCheck(fieldDecls); + } + + for (MethodDecl methodDecl : methodDecls) { + methodDecl.typeCheck(methodContext, typeContext, methodDecls); + } + + result.type = "class"; + setTypeCheckResult(result); + return result; + } + + // Method for code generation which iterates over all the field declarations + // and method declarations and calls their CodeGen methods + @Override + public void codeGen(ClassWriter cw) throws Exception { + + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, + "java/lang/Object", null); + + for (FieldDecl field : fieldDecls) { + field.codeGen(cw); + } + + for (MethodDecl method : methodDecls) { + method.codeGen(cw); + } + cw.visitEnd(); + } + + +} diff --git a/src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java new file mode 100644 index 0000000..6b8ccf0 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java @@ -0,0 +1,27 @@ +package abstractSyntaxTree.Datatype; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.*; + +public class BoolDatatype extends AbstractType implements IDatatype{ + boolean value; + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + result.type = "bool"; + + setTypeCheckResult(result); + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + if(value) { + mv.visitInsn(Opcodes.ICONST_1); // Pushes the int 1 on the stack (true) + } else { + mv.visitInsn(Opcodes.ICONST_0); // 0 for false + } + } +} diff --git a/src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java new file mode 100644 index 0000000..1346f0d --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java @@ -0,0 +1,27 @@ +package abstractSyntaxTree.Datatype; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; + +public class CharDatatype extends AbstractType implements IDatatype{ + char value; + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + result.type = "char"; + + setTypeCheckResult(result); + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + // Possible use of BIPUSH and SIPUSH if the value is small enough + //This saves space in the bytecode which is not very relevant at this point, but could be implemented anyway + + mv.visitLdcInsn((int)value); + } +} diff --git a/src/main/java/abstractSyntaxTree/Datatype/IDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/IDatatype.java new file mode 100644 index 0000000..d729f96 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Datatype/IDatatype.java @@ -0,0 +1,15 @@ +package abstractSyntaxTree.Datatype; + +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; + +public interface IDatatype { + // typeCheck method + TypeCheckResult typeCheck() throws Exception; + + // visit method for code generation + + void codeGen(MethodVisitor mv) throws Exception; +} + +//TODO: Check if we need to differentiate between primitive types and reference types --> for example in "==" \ No newline at end of file diff --git a/src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java new file mode 100644 index 0000000..4733931 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java @@ -0,0 +1,34 @@ +package abstractSyntaxTree.Datatype; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class IntDatatype extends AbstractType implements IDatatype{ + int value; + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + result.type = "int"; + + setTypeCheckResult(result); + return result; + } + + // visit method for code generation + + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + //Example of using BIPUSH and SIPUSH for optimizing bytecode size + if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) + mv.visitIntInsn(Opcodes.BIPUSH, value); + else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) + mv.visitIntInsn(Opcodes.SIPUSH, value); + else + mv.visitLdcInsn(value); + } +} diff --git a/src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java b/src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java new file mode 100644 index 0000000..72af1be --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java @@ -0,0 +1,170 @@ +package abstractSyntaxTree.Expression; + +import TypeCheck.TypeCheckResult; +import TypeCheck.TypeCheckHelper; +import TypeCheck.AbstractType; +import org.objectweb.asm.*; + +import java.beans.Expression; +import java.util.Objects; + +public class BinaryExpression extends AbstractType implements IExpression{ + + public String operator; + public IExpression left; + public IExpression right; + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckHelper helper = new TypeCheckHelper(); + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult leftType = left.typeCheck(); + TypeCheckResult rightType = right.typeCheck(); + + switch (operator) { + + case "&&": + case "||" :{ + if (Objects.equals(helper.upperBound(leftType.type, rightType.type), "bool")){ + result.type = "bool"; + } + break; + } + case "==": + case "<": + case ">": + case "<=": + case ">=": + case "!=": + result.type = helper.upperBound(leftType.type, rightType.type); + break; + + case "-": + case "+": + case "*": + case "/": + if (Objects.equals(helper.upperBound(leftType.type, rightType.type), "int")){ + result.type = "int"; + } + break; + + //case "&" ist für logisches und auf bit level + //case "|" ist für logisches oder auf bit level + } + + setTypeCheckResult(result); + return result; + } + + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + // Label for the jump instruction + Label operationFalse = new Label(); //Operation is false + Label operationTrue = new Label(); //Operation is true + // Labels are placed at the end of this method + Label expressionEnd = new Label(); //End of the whole expression + + // Bytecode for the binary operation + switch (operator) { + case "&&": + left.codeGen(mv); + mv.visitJumpInsn(Opcodes.IFEQ, operationFalse); // IFEQ --> "if equals to zero" (false) --> if left exp is false + + right.codeGen(mv); + mv.visitJumpInsn(Opcodes.IFEQ, operationFalse); // If right exp is false, jump to the end of the whole expression + + mv.visitJumpInsn(Opcodes.GOTO, operationTrue); // If it reaches this point, the right exp is true + break; + + case "||": + left.codeGen(mv); + mv.visitJumpInsn(Opcodes.IFNE, operationTrue); // IFNE --> "if not equals to zero" (true) --> if left exp is true + + right.codeGen(mv); + mv.visitJumpInsn(Opcodes.IFNE, operationTrue); + break; + + case "==": + // Keep in mind that only primitive types are allowed in this case (at this time) + + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPEQ, operationTrue); // If the two values are equal, jump to the end of the expression + break; + + case "<": + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPLT, operationTrue); // Checks only on less than, not equal + break; + + case ">": + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPGT, operationTrue); // Checks only on greater than, not equal + break; + + case "<=": + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPLE, operationTrue); // Checks on less than OR equal + break; + + case ">=": + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPGE, operationTrue); // Checks on greater than OR equal + break; + + case "!=": + left.codeGen(mv); + right.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IF_ICMPNE, operationTrue); // Checks on not equal + break; + + case "+": + left.codeGen(mv); + right.codeGen(mv); + mv.visitInsn(Opcodes.IADD); + break; + + case "-": + left.codeGen(mv); + right.codeGen(mv); + mv.visitInsn(Opcodes.ISUB); + break; + + case "*": + left.codeGen(mv); + right.codeGen(mv); + mv.visitInsn(Opcodes.IMUL); + break; + + case "/": + left.codeGen(mv); + right.codeGen(mv); + mv.visitInsn(Opcodes.IDIV); + break; + + default: + throw new Exception("Unknown operator: " + operator); + } + + mv.visitLabel(operationFalse); + mv.visitInsn(Opcodes.ICONST_0); // Push false on the stack + mv.visitJumpInsn(Opcodes.GOTO, expressionEnd); // Jump to the end of the expression (skip the true push) + + mv.visitLabel(operationTrue); + mv.visitInsn(Opcodes.ICONST_1); // Push true on the stack + + mv.visitLabel(expressionEnd); + } +} diff --git a/src/main/java/abstractSyntaxTree/Expression/IExpression.java b/src/main/java/abstractSyntaxTree/Expression/IExpression.java new file mode 100644 index 0000000..a679711 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Expression/IExpression.java @@ -0,0 +1,12 @@ +package abstractSyntaxTree.Expression; + +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; + +public interface IExpression { + // typeCheck method + TypeCheckResult typeCheck() throws Exception; + + // visit method for code generation + void codeGen(MethodVisitor mv) throws Exception; +} diff --git a/src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java b/src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java new file mode 100644 index 0000000..f7d58e3 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java @@ -0,0 +1,32 @@ +package abstractSyntaxTree.Expression; + +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Class.RefType; +import jdk.jshell.spi.ExecutionControl; +import org.objectweb.asm.MethodVisitor; + +public class InstVarExpression implements IExpression{ + + //TODO: We have to decide upon more parameters and where they come from, for + // example here we need the index of the field, the class reference and the field name + private RefType classRef; + private String fieldName; + +/* public InstVarExpression(RefType classRef, String fieldName){ + this.classRef = classRef; + this.fieldName = fieldName; + }*/ + @Override + public TypeCheckResult typeCheck() throws Exception { + return null; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + throw new ExecutionControl.NotImplementedException("CodeGen not implemented for InstVarExpression"); + + //ALOAD the index of the var + //GETFIELD the field + //visitFieldInsn(Opcodes.GETFIELD, "class reference", "field name", type); + } +} diff --git a/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java b/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java new file mode 100644 index 0000000..4acdc53 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java @@ -0,0 +1,65 @@ +package abstractSyntaxTree.Expression; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckHelper; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Datatype.IDatatype; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +import java.util.Objects; + +public class UnaryExpression extends AbstractType implements IExpression{ + public String operator; + public IDatatype operand; + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult operandTypeCheckResult = operand.typeCheck(); + String operandType = operandTypeCheckResult.type; + + switch (operator) { + + case "!" :{ + if (Objects.equals(operandType, "bool")){ + result.type = "bool"; + } + break; + } + + case "-": + case "+": + if (Objects.equals(operandType, "int")){ + result.type = "int"; + } + break; + + } + + setTypeCheckResult(result); + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + operand.codeGen(mv); + + switch (operator) { + case "!": + //XOR with 1 to get the negation + mv.visitInsn(Opcodes.ICONST_1); + mv.visitInsn(Opcodes.IXOR); + break; + case "-": + mv.visitInsn(Opcodes.INEG); + break; + case "+": + break; + + default: throw new Exception("Unknown operator :" + operator); + } + + } +} diff --git a/src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java b/src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java new file mode 100644 index 0000000..9276930 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java @@ -0,0 +1,23 @@ +package abstractSyntaxTree.Expression; + +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; + +import java.util.Map; + +public class VarRefExpression implements IExpression{ + + //Parameters that are needed here + private String varName; + private Map localVars; + + @Override + public TypeCheckResult typeCheck() throws Exception { + return null; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + throw new Exception("CodeGen not implemented for VarRefExpression"); + } +} diff --git a/src/main/java/abstractSyntaxTree/Program.java b/src/main/java/abstractSyntaxTree/Program.java new file mode 100644 index 0000000..659ad47 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Program.java @@ -0,0 +1,95 @@ +package abstractSyntaxTree; + +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Class.FieldDecl; +import abstractSyntaxTree.Class.MethodDecl; +import org.objectweb.asm.MethodVisitor; +import abstractSyntaxTree.Class.RefType; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; + +import java.util.*; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; + +public class Program { + public List classes; + public HashMap> typeContext; // (class, (type, identifier)) + public HashMap>>> methodContext; // (class, (returntype, (identifier, parameter))) + + public Program(List classes){ + this.classes = classes; + this.typeContext = new HashMap<>(); + this.methodContext = new HashMap<>(); + } + + + public TypeCheckResult typeCheck() throws Exception{ + for(RefType oneClass : classes){ + HashMap classVars = new HashMap<>(); + for (FieldDecl fieldDecl: oneClass.fieldDecls){ + classVars.put(fieldDecl.type, fieldDecl.identifier); + } + typeContext.put(oneClass.name, classVars); + + HashMap> methodIdentifierAndParameter = new HashMap<>(); + HashMap>> returnTypeAndMethod = new HashMap<>(); + for (MethodDecl methodDecl : oneClass.methodDecls){ + methodIdentifierAndParameter.put(methodDecl.name, methodDecl.parameters); + returnTypeAndMethod.put(methodDecl.returnType, methodIdentifierAndParameter); + } + + methodContext.put(oneClass.name, returnTypeAndMethod); + + oneClass.typeCheck(methodContext, typeContext, oneClass.methodDecls); + } + return null; + } + + public void codeGen() throws Exception{ + try (JarOutputStream jos = new JarOutputStream(new FileOutputStream("output.jar"))) { + for (RefType oneClass : classes) { + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, oneClass.name, null, "java/lang/Object", null); + + oneClass.codeGen(cw); + + cw.visitEnd(); + byte[] bytecode = cw.toByteArray(); + + try (FileOutputStream fos = new FileOutputStream(oneClass.name + ".class")) { + fos.write(bytecode); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + + /*// Write the bytecode to a .class file in the .jar file + JarEntry entry = new JarEntry(oneClass.name + ".class"); + jos.putNextEntry(entry); + jos.write(bytecode); + jos.closeEntry(); + } + } catch (IOException e) { + e.printStackTrace(); + }*/ + + /* + for(RefType oneClass : classes){ + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC,oneClass.name, null, + "java/lang/Object", null); + oneClass.codeGen(cw); + + cw.visitEnd(); + byte[] bytecode = cw.toByteArray(); + } + */ + } +} diff --git a/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java b/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java new file mode 100644 index 0000000..da8e26d --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java @@ -0,0 +1,49 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import org.objectweb.asm.*; + +import java.util.HashMap; +import java.util.List; + +public class BlockStatement extends AbstractType implements IStatement{ + + //We will need a parameter which holds the symbol table + HashMap localVars; + HashMap typeIndentifierTable; // from program + List statements; + // do we need expression, statementexpression + + public BlockStatement(List statements, HashMap localVars, HashMap typeIndentifierTable){ + + this.statements = statements; + } + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + if(statements.size() == 0){ + result.type = "void"; + } + + TypeCheckResult blockType = null; + for (IStatement statement : statements) { + TypeCheckResult typeOfCurrentStatement = statement.typeCheck(); + + if (blockType == null) { + blockType = typeOfCurrentStatement; + } else if (!typeOfCurrentStatement.equals(blockType) && !blockType.equals("void")) { + throw new IllegalArgumentException("different statement types"); + } + } + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + for (IStatement statement : statements) { + statement.codeGen(mv); //TODO: I think we need to pass the symbol table here + } + } +} diff --git a/src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java b/src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java new file mode 100644 index 0000000..01818d7 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java @@ -0,0 +1,19 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import org.objectweb.asm.MethodVisitor; + +public class EmptyStatement extends AbstractType implements IStatement{ + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + result.type = "void"; + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + //An empty statement does not generate any code + } +} diff --git a/src/main/java/abstractSyntaxTree/Statement/IStatement.java b/src/main/java/abstractSyntaxTree/Statement/IStatement.java new file mode 100644 index 0000000..d15e56b --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/IStatement.java @@ -0,0 +1,13 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import org.objectweb.asm.MethodVisitor; + +public interface IStatement { + + + + TypeCheckResult typeCheck() throws Exception; + + void codeGen(MethodVisitor mv) throws Exception; +} diff --git a/src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java b/src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java new file mode 100644 index 0000000..d8ac01e --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java @@ -0,0 +1,58 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import abstractSyntaxTree.Expression.IExpression; +import org.objectweb.asm.*; + +public class IfElseStatement extends AbstractType implements IStatement{ + IExpression condition; + IStatement ifStatement; + IStatement elseStatement; + + public IfElseStatement(IExpression condition, IStatement ifStatement, IStatement elseStatement) { + this.condition = condition; + this.ifStatement = ifStatement; + this.elseStatement = elseStatement; + } + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult conditionType = condition.typeCheck(); + + if (!conditionType.equals("bool")) { + throw new IllegalArgumentException("should be boolean"); + } + + TypeCheckResult ifStatementType = ifStatement.typeCheck(); + TypeCheckResult elseStatementType = elseStatement.typeCheck(); + + if (!ifStatementType.equals(elseStatementType)) { + throw new IllegalArgumentException("if and else have different types"); + } + + result.type = elseStatementType.type; + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + Label conditionFalse = new Label(); + Label statementEnd = new Label(); + + condition.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); //Checks if the condition is false (0) + ifStatement.codeGen(mv); //If the condition is true, execute the ifBlock + mv.visitJumpInsn(Opcodes.GOTO, statementEnd); //Jump to the end of the if-else statement + + mv.visitLabel(conditionFalse); + elseStatement.codeGen(mv); //If the condition is false, execute the elseBlock + + mv.visitLabel(statementEnd); //End of the if-else statement + + } +} diff --git a/src/main/java/abstractSyntaxTree/Statement/IfStatement.java b/src/main/java/abstractSyntaxTree/Statement/IfStatement.java new file mode 100644 index 0000000..1c8461c --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/IfStatement.java @@ -0,0 +1,49 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import abstractSyntaxTree.Expression.IExpression; +import org.objectweb.asm.*; + +public class IfStatement extends AbstractType implements IStatement{ + IExpression condition; + + //Do we need a block statement here? + IStatement ifStatement; + + public IfStatement(IExpression condition, IStatement ifStatement) { + this.condition = condition; + this.ifStatement = ifStatement; + } + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult conditionType = condition.typeCheck(); + + if (!conditionType.equals("boolean")) { + throw new IllegalArgumentException("should be boolean"); + } + + TypeCheckResult ifStatementType = ifStatement.typeCheck(); + result.type = ifStatementType.type; + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + Label conditionFalse = new Label(); + + condition.codeGen(mv); + + mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); //Checks if the condition is false (0) + ifStatement.codeGen(mv); + + mv.visitLabel(conditionFalse); // If the condition is false, the Statements in the ifBlock will not be executed + } +} + + + + diff --git a/src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java b/src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java new file mode 100644 index 0000000..976de6e --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java @@ -0,0 +1,51 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import abstractSyntaxTree.Expression.IExpression; +import org.objectweb.asm.*; + +public class ReturnStatement extends AbstractType implements IStatement{ + IExpression expression; + + public ReturnStatement(IExpression expression) { + this.expression = expression; + } + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + if (expression == null) { + result.type = "void"; + } else { + TypeCheckResult typedExpression = expression.typeCheck(); + result.type = typedExpression.type; + } + + return result; + } + + + //TODO: We do not differentiate between primitive types and reference types + // This is a problem at "BinaryExpression" and here because we need to know the type to return + // At this point in time we can either return reference types or have an error message + @Override + public void codeGen(MethodVisitor mv) throws Exception { + + if (expression != null) { + expression.codeGen(mv); + //Get the Type of the expression + String type = expression.typeCheck().type; + + if (type.equals("int") || type.equals("bool") || type.equals("char")) { + mv.visitInsn(Opcodes.IRETURN); + } else { + mv.visitInsn(Opcodes.ARETURN); + + } + } else { + mv.visitInsn(Opcodes.RETURN); + } + } +} diff --git a/src/main/java/abstractSyntaxTree/Statement/WhileStatement.java b/src/main/java/abstractSyntaxTree/Statement/WhileStatement.java new file mode 100644 index 0000000..e923fa1 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/Statement/WhileStatement.java @@ -0,0 +1,50 @@ +package abstractSyntaxTree.Statement; + +import TypeCheck.TypeCheckResult; +import TypeCheck.AbstractType; +import abstractSyntaxTree.Expression.IExpression; +import org.objectweb.asm.*; + +public class WhileStatement extends AbstractType implements IStatement { + IExpression condition; + IStatement statement; + + public WhileStatement(IExpression condition, IStatement statement) { + this.condition = condition; + this.statement = statement; + } + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult conditionType = condition.typeCheck(); + + if (!conditionType.equals("bool")) { + throw new IllegalArgumentException("Expected boolean"); + } + + TypeCheckResult statementType = statement.typeCheck(); + + result.type = statementType.type; + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + Label conditionFalse = new Label(); + Label LoopStart = new Label(); + + mv.visitLabel(LoopStart); + + condition.codeGen(mv); + mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); // Checks if the condition is false (0) + + statement.codeGen(mv); + //TODO: If the block ends with a return statement, we might have to pop it from the stack + // So the next iteration starts with a clean stack + mv.visitJumpInsn(Opcodes.GOTO, LoopStart); // Jump to the start of the while loop + + mv.visitLabel(conditionFalse); + } +} \ No newline at end of file diff --git a/src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java new file mode 100644 index 0000000..4085494 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java @@ -0,0 +1,50 @@ +package abstractSyntaxTree.StatementExpression; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckHelper; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Expression.IExpression; +import abstractSyntaxTree.Expression.InstVarExpression; +import abstractSyntaxTree.Expression.VarRefExpression; +import abstractSyntaxTree.Statement.IStatement; +import org.objectweb.asm.*; + +import java.util.Objects; + +public class AssignStatementExpression extends AbstractType implements IExpression, IStatement { + public String operator; + public IExpression left; + public IExpression right; + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckHelper helper = new TypeCheckHelper(); + TypeCheckResult result = new TypeCheckResult(); + + TypeCheckResult leftType = left.typeCheck(); + TypeCheckResult rightType = right.typeCheck(); + + String upperbound = helper.upperBound(leftType.type, rightType.type); + if (Objects.equals(upperbound, leftType.type)) { + result.type = leftType.type; + } + setTypeCheckResult(result); + return result; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + left.codeGen(mv); + right.codeGen(mv); + + if (left instanceof VarRefExpression varRef) { + //TODO: Implement the handling of a variable reference --> I need a list of local variables + // for that to determine if the variable is a local or field variable + } else if (left instanceof InstVarExpression instVar) { + mv.visitInsn(Opcodes.DUP_X1); + + // We now again need the owner (class reference), name (of the Field in the owner) and type of the field + //mv.visitFieldInsn(Opcodes.PUTFIELD, instVar.className, instVar.varName, instVar.type); + } + } +} diff --git a/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java new file mode 100644 index 0000000..2907a43 --- /dev/null +++ b/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java @@ -0,0 +1,64 @@ +package abstractSyntaxTree.StatementExpression; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Class.MethodDecl; +import abstractSyntaxTree.Class.RefType; +import abstractSyntaxTree.Expression.IExpression; +import abstractSyntaxTree.Statement.IStatement; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +import java.util.List; + +public class MethodCallStatementExpression extends AbstractType implements IExpression, IStatement { + String methodName; + List arguments; + RefType classThatHasTheMethodIfNotThis; + RefType thisClass; + + public MethodCallStatementExpression(String methodName, List arguments) { + this.methodName = methodName; + this.arguments = arguments; + } + + @Override + public TypeCheckResult typeCheck() throws Exception { + TypeCheckResult result = new TypeCheckResult(); + + RefType searchMethodHere; + if(classThatHasTheMethodIfNotThis == null){ + searchMethodHere = thisClass; + } else { + searchMethodHere = classThatHasTheMethodIfNotThis; + } + + List methods = searchMethodHere.methodDecls; + + if(!methods.contains(methodName)){ + throw new Exception("method not found"); + } + + return result; + } + + //Errors occur due to the change in parameter in the RefType class + @Override + public void codeGen(MethodVisitor mv) throws Exception { + //Generate Bytecode for the receiver + if(classThatHasTheMethodIfNotThis != null){ + classThatHasTheMethodIfNotThis.codeGen(new ClassWriter(ClassWriter.COMPUTE_FRAMES)); + } else { + mv.visitVarInsn(Opcodes.ALOAD, 0); + } + + for (IExpression argument : arguments) { + argument.codeGen(mv); + } + + //We need the class reference and the return type of the method + //mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, thisClass.name, methodName, return type); + + } +} diff --git a/src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java new file mode 100644 index 0000000..f54986c --- /dev/null +++ b/src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java @@ -0,0 +1,19 @@ +package abstractSyntaxTree.StatementExpression; + +import TypeCheck.AbstractType; +import TypeCheck.TypeCheckResult; +import abstractSyntaxTree.Expression.IExpression; +import abstractSyntaxTree.Statement.IStatement; +import org.objectweb.asm.MethodVisitor; + +public class NewStatementExpression extends AbstractType implements IExpression, IStatement { + @Override + public TypeCheckResult typeCheck() throws Exception { + return null; + } + + @Override + public void codeGen(MethodVisitor mv) throws Exception { + throw new Exception("CodeGen not implemented for NewStatementExpression"); + } +} diff --git a/src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java new file mode 100644 index 0000000..61fa3cc --- /dev/null +++ b/src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java @@ -0,0 +1,10 @@ +package abstractSyntaxTree.StatementExpression; + +import abstractSyntaxTree.Expression.IExpression; +import java.util.List; + +public class SuperStatementExpression extends MethodCallStatementExpression{ + public SuperStatementExpression(String methodName, List arguments) { + super(methodName, arguments); + } +} diff --git a/src/main/java/gen/Decaf.interp b/src/main/java/gen/Decaf.interp new file mode 100644 index 0000000..3b8abd6 --- /dev/null +++ b/src/main/java/gen/Decaf.interp @@ -0,0 +1,136 @@ +token literal names: +null +'public' +'public static void main(String[] args)' +null +null +null +null +'=' +'-' +'+' +'*' +'/' +'%' +'>' +'<' +'>=' +'<=' +'==' +'!=' +'!' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'return' +'new' +null +'void' +'int' +'bool' +'char' +null +null +null +'null' +null + +token symbolic names: +null +AccessModifierPublic +MainMethodDecl +DotOperator +LineOperator +ComparisonOperator +LogicalOpertor +Assign +Minus +Plus +Multipilkation +Division +Modulo +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +Return +New +Identifier +Void +Int +Boolean +Char +IntValue +CharValue +BooleanValue +NullValue +WS + +rule names: +program +classdecl +constuctorDecl +methodDecl +fieldDecl +parameterList +parameter +expression +subExpression +assignableExpr +instVar +methodCall +argumentList +subReceiver +receiver +receivingMethod +binaryExpr +calcExpr +dotExpr +dotSubExpr +nonCalcExpr +nonCalcOperator +stmtExpr +statement +returnStmt +localVarDecl +block +whileStmt +ifElseStmt +ifStmt +elseStmt +assign +newDecl +type +value + + +atn: +[4, 1, 45, 331, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 1, 0, 4, 0, 72, 8, 0, 11, 0, 12, 0, 73, 1, 1, 3, 1, 77, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 85, 8, 1, 10, 1, 12, 1, 88, 9, 1, 1, 1, 1, 1, 3, 1, 92, 8, 1, 1, 1, 1, 1, 1, 2, 3, 2, 97, 8, 2, 1, 2, 1, 2, 1, 2, 3, 2, 102, 8, 2, 1, 2, 1, 2, 1, 2, 1, 3, 3, 3, 108, 8, 3, 1, 3, 1, 3, 3, 3, 112, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 117, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 123, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 132, 8, 5, 10, 5, 12, 5, 135, 9, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 142, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 151, 8, 8, 1, 9, 1, 9, 3, 9, 155, 8, 9, 1, 10, 3, 10, 158, 8, 10, 1, 10, 5, 10, 161, 8, 10, 10, 10, 12, 10, 164, 9, 10, 1, 10, 1, 10, 1, 11, 3, 11, 169, 8, 11, 1, 11, 5, 11, 172, 8, 11, 10, 11, 12, 11, 175, 9, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 3, 12, 183, 8, 12, 1, 12, 1, 12, 1, 12, 4, 12, 188, 8, 12, 11, 12, 12, 12, 189, 3, 12, 192, 8, 12, 1, 13, 1, 13, 1, 13, 3, 13, 197, 8, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 205, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 220, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 5, 17, 228, 8, 17, 10, 17, 12, 17, 231, 9, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 239, 8, 18, 10, 18, 12, 18, 242, 9, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 252, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 3, 22, 263, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 277, 8, 23, 1, 24, 1, 24, 3, 24, 281, 8, 24, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 287, 8, 25, 1, 26, 1, 26, 5, 26, 291, 8, 26, 10, 26, 12, 26, 294, 9, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 3, 28, 306, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 0, 2, 34, 36, 35, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 0, 3, 1, 0, 5, 6, 2, 0, 36, 36, 38, 40, 1, 0, 41, 44, 345, 0, 71, 1, 0, 0, 0, 2, 76, 1, 0, 0, 0, 4, 96, 1, 0, 0, 0, 6, 107, 1, 0, 0, 0, 8, 122, 1, 0, 0, 0, 10, 128, 1, 0, 0, 0, 12, 136, 1, 0, 0, 0, 14, 141, 1, 0, 0, 0, 16, 150, 1, 0, 0, 0, 18, 154, 1, 0, 0, 0, 20, 157, 1, 0, 0, 0, 22, 168, 1, 0, 0, 0, 24, 191, 1, 0, 0, 0, 26, 196, 1, 0, 0, 0, 28, 204, 1, 0, 0, 0, 30, 208, 1, 0, 0, 0, 32, 219, 1, 0, 0, 0, 34, 221, 1, 0, 0, 0, 36, 232, 1, 0, 0, 0, 38, 251, 1, 0, 0, 0, 40, 253, 1, 0, 0, 0, 42, 257, 1, 0, 0, 0, 44, 262, 1, 0, 0, 0, 46, 276, 1, 0, 0, 0, 48, 278, 1, 0, 0, 0, 50, 282, 1, 0, 0, 0, 52, 288, 1, 0, 0, 0, 54, 297, 1, 0, 0, 0, 56, 303, 1, 0, 0, 0, 58, 307, 1, 0, 0, 0, 60, 313, 1, 0, 0, 0, 62, 316, 1, 0, 0, 0, 64, 320, 1, 0, 0, 0, 66, 326, 1, 0, 0, 0, 68, 328, 1, 0, 0, 0, 70, 72, 3, 2, 1, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 1, 1, 0, 0, 0, 75, 77, 5, 1, 0, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 79, 5, 29, 0, 0, 79, 80, 5, 36, 0, 0, 80, 86, 5, 25, 0, 0, 81, 85, 3, 4, 2, 0, 82, 85, 3, 8, 4, 0, 83, 85, 3, 6, 3, 0, 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 88, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 91, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 89, 90, 5, 2, 0, 0, 90, 92, 3, 52, 26, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 94, 5, 26, 0, 0, 94, 3, 1, 0, 0, 0, 95, 97, 5, 1, 0, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 99, 5, 36, 0, 0, 99, 101, 5, 23, 0, 0, 100, 102, 3, 10, 5, 0, 101, 100, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 104, 5, 24, 0, 0, 104, 105, 3, 52, 26, 0, 105, 5, 1, 0, 0, 0, 106, 108, 5, 1, 0, 0, 107, 106, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 111, 1, 0, 0, 0, 109, 112, 3, 66, 33, 0, 110, 112, 5, 37, 0, 0, 111, 109, 1, 0, 0, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 5, 36, 0, 0, 114, 116, 5, 23, 0, 0, 115, 117, 3, 10, 5, 0, 116, 115, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 119, 5, 24, 0, 0, 119, 120, 3, 52, 26, 0, 120, 7, 1, 0, 0, 0, 121, 123, 5, 1, 0, 0, 122, 121, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 125, 3, 66, 33, 0, 125, 126, 5, 36, 0, 0, 126, 127, 5, 27, 0, 0, 127, 9, 1, 0, 0, 0, 128, 133, 3, 12, 6, 0, 129, 130, 5, 28, 0, 0, 130, 132, 3, 12, 6, 0, 131, 129, 1, 0, 0, 0, 132, 135, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 11, 1, 0, 0, 0, 135, 133, 1, 0, 0, 0, 136, 137, 3, 66, 33, 0, 137, 138, 5, 36, 0, 0, 138, 13, 1, 0, 0, 0, 139, 142, 3, 16, 8, 0, 140, 142, 3, 32, 16, 0, 141, 139, 1, 0, 0, 0, 141, 140, 1, 0, 0, 0, 142, 15, 1, 0, 0, 0, 143, 151, 5, 30, 0, 0, 144, 151, 3, 18, 9, 0, 145, 151, 3, 44, 22, 0, 146, 147, 5, 23, 0, 0, 147, 148, 3, 16, 8, 0, 148, 149, 5, 24, 0, 0, 149, 151, 1, 0, 0, 0, 150, 143, 1, 0, 0, 0, 150, 144, 1, 0, 0, 0, 150, 145, 1, 0, 0, 0, 150, 146, 1, 0, 0, 0, 151, 17, 1, 0, 0, 0, 152, 155, 5, 36, 0, 0, 153, 155, 3, 20, 10, 0, 154, 152, 1, 0, 0, 0, 154, 153, 1, 0, 0, 0, 155, 19, 1, 0, 0, 0, 156, 158, 3, 26, 13, 0, 157, 156, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 162, 1, 0, 0, 0, 159, 161, 3, 30, 15, 0, 160, 159, 1, 0, 0, 0, 161, 164, 1, 0, 0, 0, 162, 160, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 165, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 165, 166, 5, 36, 0, 0, 166, 21, 1, 0, 0, 0, 167, 169, 3, 28, 14, 0, 168, 167, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 173, 1, 0, 0, 0, 170, 172, 3, 30, 15, 0, 171, 170, 1, 0, 0, 0, 172, 175, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 176, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 176, 177, 5, 36, 0, 0, 177, 178, 5, 23, 0, 0, 178, 179, 3, 24, 12, 0, 179, 180, 5, 24, 0, 0, 180, 23, 1, 0, 0, 0, 181, 183, 3, 14, 7, 0, 182, 181, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 192, 1, 0, 0, 0, 184, 187, 3, 14, 7, 0, 185, 186, 5, 28, 0, 0, 186, 188, 3, 14, 7, 0, 187, 185, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 189, 190, 1, 0, 0, 0, 190, 192, 1, 0, 0, 0, 191, 182, 1, 0, 0, 0, 191, 184, 1, 0, 0, 0, 192, 25, 1, 0, 0, 0, 193, 197, 5, 30, 0, 0, 194, 197, 3, 64, 32, 0, 195, 197, 5, 36, 0, 0, 196, 193, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 195, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 199, 5, 22, 0, 0, 199, 27, 1, 0, 0, 0, 200, 205, 5, 30, 0, 0, 201, 205, 3, 20, 10, 0, 202, 205, 3, 64, 32, 0, 203, 205, 5, 36, 0, 0, 204, 200, 1, 0, 0, 0, 204, 201, 1, 0, 0, 0, 204, 202, 1, 0, 0, 0, 204, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 207, 5, 22, 0, 0, 207, 29, 1, 0, 0, 0, 208, 209, 5, 36, 0, 0, 209, 210, 5, 23, 0, 0, 210, 211, 3, 24, 12, 0, 211, 212, 5, 24, 0, 0, 212, 213, 5, 22, 0, 0, 213, 31, 1, 0, 0, 0, 214, 220, 3, 34, 17, 0, 215, 220, 3, 40, 20, 0, 216, 220, 3, 68, 34, 0, 217, 218, 5, 19, 0, 0, 218, 220, 3, 32, 16, 0, 219, 214, 1, 0, 0, 0, 219, 215, 1, 0, 0, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 220, 33, 1, 0, 0, 0, 221, 222, 6, 17, -1, 0, 222, 223, 3, 36, 18, 0, 223, 229, 1, 0, 0, 0, 224, 225, 10, 2, 0, 0, 225, 226, 5, 4, 0, 0, 226, 228, 3, 36, 18, 0, 227, 224, 1, 0, 0, 0, 228, 231, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 35, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 232, 233, 6, 18, -1, 0, 233, 234, 3, 38, 19, 0, 234, 240, 1, 0, 0, 0, 235, 236, 10, 2, 0, 0, 236, 237, 5, 3, 0, 0, 237, 239, 3, 38, 19, 0, 238, 235, 1, 0, 0, 0, 239, 242, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 37, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 243, 252, 5, 41, 0, 0, 244, 252, 5, 36, 0, 0, 245, 252, 3, 20, 10, 0, 246, 252, 3, 22, 11, 0, 247, 248, 5, 23, 0, 0, 248, 249, 3, 34, 17, 0, 249, 250, 5, 24, 0, 0, 250, 252, 1, 0, 0, 0, 251, 243, 1, 0, 0, 0, 251, 244, 1, 0, 0, 0, 251, 245, 1, 0, 0, 0, 251, 246, 1, 0, 0, 0, 251, 247, 1, 0, 0, 0, 252, 39, 1, 0, 0, 0, 253, 254, 3, 16, 8, 0, 254, 255, 3, 42, 21, 0, 255, 256, 3, 14, 7, 0, 256, 41, 1, 0, 0, 0, 257, 258, 7, 0, 0, 0, 258, 43, 1, 0, 0, 0, 259, 263, 3, 62, 31, 0, 260, 263, 3, 64, 32, 0, 261, 263, 3, 22, 11, 0, 262, 259, 1, 0, 0, 0, 262, 260, 1, 0, 0, 0, 262, 261, 1, 0, 0, 0, 263, 45, 1, 0, 0, 0, 264, 265, 3, 48, 24, 0, 265, 266, 5, 27, 0, 0, 266, 277, 1, 0, 0, 0, 267, 268, 3, 50, 25, 0, 268, 269, 5, 27, 0, 0, 269, 277, 1, 0, 0, 0, 270, 277, 3, 52, 26, 0, 271, 277, 3, 54, 27, 0, 272, 277, 3, 56, 28, 0, 273, 274, 3, 44, 22, 0, 274, 275, 5, 27, 0, 0, 275, 277, 1, 0, 0, 0, 276, 264, 1, 0, 0, 0, 276, 267, 1, 0, 0, 0, 276, 270, 1, 0, 0, 0, 276, 271, 1, 0, 0, 0, 276, 272, 1, 0, 0, 0, 276, 273, 1, 0, 0, 0, 277, 47, 1, 0, 0, 0, 278, 280, 5, 34, 0, 0, 279, 281, 3, 14, 7, 0, 280, 279, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 49, 1, 0, 0, 0, 282, 283, 3, 66, 33, 0, 283, 286, 5, 36, 0, 0, 284, 285, 5, 7, 0, 0, 285, 287, 3, 14, 7, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 51, 1, 0, 0, 0, 288, 292, 5, 25, 0, 0, 289, 291, 3, 46, 23, 0, 290, 289, 1, 0, 0, 0, 291, 294, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 292, 293, 1, 0, 0, 0, 293, 295, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 295, 296, 5, 26, 0, 0, 296, 53, 1, 0, 0, 0, 297, 298, 5, 31, 0, 0, 298, 299, 5, 23, 0, 0, 299, 300, 3, 14, 7, 0, 300, 301, 5, 24, 0, 0, 301, 302, 3, 46, 23, 0, 302, 55, 1, 0, 0, 0, 303, 305, 3, 58, 29, 0, 304, 306, 3, 60, 30, 0, 305, 304, 1, 0, 0, 0, 305, 306, 1, 0, 0, 0, 306, 57, 1, 0, 0, 0, 307, 308, 5, 32, 0, 0, 308, 309, 5, 23, 0, 0, 309, 310, 3, 14, 7, 0, 310, 311, 5, 24, 0, 0, 311, 312, 3, 46, 23, 0, 312, 59, 1, 0, 0, 0, 313, 314, 5, 33, 0, 0, 314, 315, 3, 46, 23, 0, 315, 61, 1, 0, 0, 0, 316, 317, 3, 18, 9, 0, 317, 318, 5, 7, 0, 0, 318, 319, 3, 14, 7, 0, 319, 63, 1, 0, 0, 0, 320, 321, 5, 35, 0, 0, 321, 322, 5, 36, 0, 0, 322, 323, 5, 23, 0, 0, 323, 324, 3, 24, 12, 0, 324, 325, 5, 24, 0, 0, 325, 65, 1, 0, 0, 0, 326, 327, 7, 1, 0, 0, 327, 67, 1, 0, 0, 0, 328, 329, 7, 2, 0, 0, 329, 69, 1, 0, 0, 0, 34, 73, 76, 84, 86, 91, 96, 101, 107, 111, 116, 122, 133, 141, 150, 154, 157, 162, 168, 173, 182, 189, 191, 196, 204, 219, 229, 240, 251, 262, 276, 280, 286, 292, 305] \ No newline at end of file diff --git a/src/main/java/gen/Decaf.tokens b/src/main/java/gen/Decaf.tokens new file mode 100644 index 0000000..6873c36 --- /dev/null +++ b/src/main/java/gen/Decaf.tokens @@ -0,0 +1,81 @@ +AccessModifierPublic=1 +MainMethodDecl=2 +DotOperator=3 +LineOperator=4 +ComparisonOperator=5 +LogicalOpertor=6 +Assign=7 +Minus=8 +Plus=9 +Multipilkation=10 +Division=11 +Modulo=12 +Greater=13 +Less=14 +GreaterEqual=15 +LessEqual=16 +Equal=17 +NotEqual=18 +Not=19 +And=20 +Or=21 +Dot=22 +OpenRoundBracket=23 +ClosedRoundBracket=24 +OpenCurlyBracket=25 +ClosedCurlyBracket=26 +Semicolon=27 +Comma=28 +Class=29 +This=30 +While=31 +If=32 +Else=33 +Return=34 +New=35 +Identifier=36 +Void=37 +Int=38 +Boolean=39 +Char=40 +IntValue=41 +CharValue=42 +BooleanValue=43 +NullValue=44 +WS=45 +'public'=1 +'public static void main(String[] args)'=2 +'='=7 +'-'=8 +'+'=9 +'*'=10 +'/'=11 +'%'=12 +'>'=13 +'<'=14 +'>='=15 +'<='=16 +'=='=17 +'!='=18 +'!'=19 +'&&'=20 +'||'=21 +'.'=22 +'('=23 +')'=24 +'{'=25 +'}'=26 +';'=27 +','=28 +'class'=29 +'this'=30 +'while'=31 +'if'=32 +'else'=33 +'return'=34 +'new'=35 +'void'=37 +'int'=38 +'bool'=39 +'char'=40 +'null'=44 diff --git a/src/main/java/gen/DecafBaseListener.java b/src/main/java/gen/DecafBaseListener.java new file mode 100644 index 0000000..59f157f --- /dev/null +++ b/src/main/java/gen/DecafBaseListener.java @@ -0,0 +1,459 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 + +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 DecafListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class DecafBaseListener implements DecafListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterClassdecl(DecafParser.ClassdeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitClassdecl(DecafParser.ClassdeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMethodDecl(DecafParser.MethodDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMethodDecl(DecafParser.MethodDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFieldDecl(DecafParser.FieldDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFieldDecl(DecafParser.FieldDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterSubExpression(DecafParser.SubExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSubExpression(DecafParser.SubExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssignableExpr(DecafParser.AssignableExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssignableExpr(DecafParser.AssignableExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInstVar(DecafParser.InstVarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInstVar(DecafParser.InstVarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterSubReceiver(DecafParser.SubReceiverContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSubReceiver(DecafParser.SubReceiverContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReceiver(DecafParser.ReceiverContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReceiver(DecafParser.ReceiverContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReceivingMethod(DecafParser.ReceivingMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryExpr(DecafParser.BinaryExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryExpr(DecafParser.BinaryExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCalcExpr(DecafParser.CalcExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCalcExpr(DecafParser.CalcExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotExpr(DecafParser.DotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotExpr(DecafParser.DotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotSubExpr(DecafParser.DotSubExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotSubExpr(DecafParser.DotSubExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalcExpr(DecafParser.NonCalcExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStmtExpr(DecafParser.StmtExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStmtExpr(DecafParser.StmtExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterReturnStmt(DecafParser.ReturnStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReturnStmt(DecafParser.ReturnStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterWhileStmt(DecafParser.WhileStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhileStmt(DecafParser.WhileStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfElseStmt(DecafParser.IfElseStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfElseStmt(DecafParser.IfElseStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfStmt(DecafParser.IfStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfStmt(DecafParser.IfStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterElseStmt(DecafParser.ElseStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitElseStmt(DecafParser.ElseStmtContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterNewDecl(DecafParser.NewDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNewDecl(DecafParser.NewDeclContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/java/gen/DecafBaseVisitor.java b/src/main/java/gen/DecafBaseVisitor.java new file mode 100644 index 0000000..9bd240e --- /dev/null +++ b/src/main/java/gen/DecafBaseVisitor.java @@ -0,0 +1,259 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link DecafVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class DecafBaseVisitor extends AbstractParseTreeVisitor implements DecafVisitor { + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitClassdecl(DecafParser.ClassdeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitMethodDecl(DecafParser.MethodDeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFieldDecl(DecafParser.FieldDeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitParameterList(DecafParser.ParameterListContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

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

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

+ */ + @Override public T visitSubExpression(DecafParser.SubExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAssignableExpr(DecafParser.AssignableExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInstVar(DecafParser.InstVarContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

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

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

+ */ + @Override public T visitSubReceiver(DecafParser.SubReceiverContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitReceiver(DecafParser.ReceiverContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBinaryExpr(DecafParser.BinaryExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCalcExpr(DecafParser.CalcExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDotExpr(DecafParser.DotExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDotSubExpr(DecafParser.DotSubExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitStmtExpr(DecafParser.StmtExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitReturnStmt(DecafParser.ReturnStmtContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitWhileStmt(DecafParser.WhileStmtContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIfElseStmt(DecafParser.IfElseStmtContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIfStmt(DecafParser.IfStmtContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitElseStmt(DecafParser.ElseStmtContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitNewDecl(DecafParser.NewDeclContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitValue(DecafParser.ValueContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/gen/DecafLexer.interp b/src/main/java/gen/DecafLexer.interp new file mode 100644 index 0000000..cf85022 --- /dev/null +++ b/src/main/java/gen/DecafLexer.interp @@ -0,0 +1,155 @@ +token literal names: +null +'public' +'public static void main(String[] args)' +null +null +null +null +'=' +'-' +'+' +'*' +'/' +'%' +'>' +'<' +'>=' +'<=' +'==' +'!=' +'!' +'&&' +'||' +'.' +'(' +')' +'{' +'}' +';' +',' +'class' +'this' +'while' +'if' +'else' +'return' +'new' +null +'void' +'int' +'bool' +'char' +null +null +null +'null' +null + +token symbolic names: +null +AccessModifierPublic +MainMethodDecl +DotOperator +LineOperator +ComparisonOperator +LogicalOpertor +Assign +Minus +Plus +Multipilkation +Division +Modulo +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +Return +New +Identifier +Void +Int +Boolean +Char +IntValue +CharValue +BooleanValue +NullValue +WS + +rule names: +AccessModifierPublic +MainMethodDecl +DotOperator +LineOperator +ComparisonOperator +LogicalOpertor +Assign +Minus +Plus +Multipilkation +Division +Modulo +Greater +Less +GreaterEqual +LessEqual +Equal +NotEqual +Not +And +Or +Dot +OpenRoundBracket +ClosedRoundBracket +OpenCurlyBracket +ClosedCurlyBracket +Semicolon +Comma +Class +This +While +If +Else +Return +New +Alpabetic +Numeric +ValidIdentSymbols +Identifier +Void +Int +Boolean +Char +IntValue +CharValue +BooleanValue +NullValue +WS + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 45, 322, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 147, 8, 2, 1, 3, 1, 3, 3, 3, 151, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 159, 8, 4, 1, 5, 1, 5, 3, 5, 163, 8, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 3, 37, 258, 8, 37, 1, 38, 1, 38, 5, 38, 262, 8, 38, 10, 38, 12, 38, 265, 9, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 5, 43, 287, 8, 43, 10, 43, 12, 43, 290, 9, 43, 1, 43, 4, 43, 293, 8, 43, 11, 43, 12, 43, 294, 1, 44, 1, 44, 3, 44, 299, 8, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 312, 8, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 0, 0, 48, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 0, 73, 0, 75, 0, 77, 36, 79, 37, 81, 38, 83, 39, 85, 40, 87, 41, 89, 42, 91, 43, 93, 44, 95, 45, 1, 0, 6, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 2, 0, 36, 36, 95, 95, 2, 0, 43, 43, 45, 45, 2, 0, 10, 10, 13, 13, 3, 0, 9, 10, 13, 13, 32, 32, 334, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 1, 97, 1, 0, 0, 0, 3, 104, 1, 0, 0, 0, 5, 146, 1, 0, 0, 0, 7, 150, 1, 0, 0, 0, 9, 158, 1, 0, 0, 0, 11, 162, 1, 0, 0, 0, 13, 164, 1, 0, 0, 0, 15, 166, 1, 0, 0, 0, 17, 168, 1, 0, 0, 0, 19, 170, 1, 0, 0, 0, 21, 172, 1, 0, 0, 0, 23, 174, 1, 0, 0, 0, 25, 176, 1, 0, 0, 0, 27, 178, 1, 0, 0, 0, 29, 180, 1, 0, 0, 0, 31, 183, 1, 0, 0, 0, 33, 186, 1, 0, 0, 0, 35, 189, 1, 0, 0, 0, 37, 192, 1, 0, 0, 0, 39, 194, 1, 0, 0, 0, 41, 197, 1, 0, 0, 0, 43, 200, 1, 0, 0, 0, 45, 202, 1, 0, 0, 0, 47, 204, 1, 0, 0, 0, 49, 206, 1, 0, 0, 0, 51, 208, 1, 0, 0, 0, 53, 210, 1, 0, 0, 0, 55, 212, 1, 0, 0, 0, 57, 214, 1, 0, 0, 0, 59, 220, 1, 0, 0, 0, 61, 225, 1, 0, 0, 0, 63, 231, 1, 0, 0, 0, 65, 234, 1, 0, 0, 0, 67, 239, 1, 0, 0, 0, 69, 246, 1, 0, 0, 0, 71, 250, 1, 0, 0, 0, 73, 252, 1, 0, 0, 0, 75, 257, 1, 0, 0, 0, 77, 259, 1, 0, 0, 0, 79, 266, 1, 0, 0, 0, 81, 271, 1, 0, 0, 0, 83, 275, 1, 0, 0, 0, 85, 280, 1, 0, 0, 0, 87, 288, 1, 0, 0, 0, 89, 296, 1, 0, 0, 0, 91, 311, 1, 0, 0, 0, 93, 313, 1, 0, 0, 0, 95, 318, 1, 0, 0, 0, 97, 98, 5, 112, 0, 0, 98, 99, 5, 117, 0, 0, 99, 100, 5, 98, 0, 0, 100, 101, 5, 108, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, 5, 99, 0, 0, 103, 2, 1, 0, 0, 0, 104, 105, 5, 112, 0, 0, 105, 106, 5, 117, 0, 0, 106, 107, 5, 98, 0, 0, 107, 108, 5, 108, 0, 0, 108, 109, 5, 105, 0, 0, 109, 110, 5, 99, 0, 0, 110, 111, 5, 32, 0, 0, 111, 112, 5, 115, 0, 0, 112, 113, 5, 116, 0, 0, 113, 114, 5, 97, 0, 0, 114, 115, 5, 116, 0, 0, 115, 116, 5, 105, 0, 0, 116, 117, 5, 99, 0, 0, 117, 118, 5, 32, 0, 0, 118, 119, 5, 118, 0, 0, 119, 120, 5, 111, 0, 0, 120, 121, 5, 105, 0, 0, 121, 122, 5, 100, 0, 0, 122, 123, 5, 32, 0, 0, 123, 124, 5, 109, 0, 0, 124, 125, 5, 97, 0, 0, 125, 126, 5, 105, 0, 0, 126, 127, 5, 110, 0, 0, 127, 128, 5, 40, 0, 0, 128, 129, 5, 83, 0, 0, 129, 130, 5, 116, 0, 0, 130, 131, 5, 114, 0, 0, 131, 132, 5, 105, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 103, 0, 0, 134, 135, 5, 91, 0, 0, 135, 136, 5, 93, 0, 0, 136, 137, 5, 32, 0, 0, 137, 138, 5, 97, 0, 0, 138, 139, 5, 114, 0, 0, 139, 140, 5, 103, 0, 0, 140, 141, 5, 115, 0, 0, 141, 142, 5, 41, 0, 0, 142, 4, 1, 0, 0, 0, 143, 147, 3, 19, 9, 0, 144, 147, 3, 21, 10, 0, 145, 147, 3, 23, 11, 0, 146, 143, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 146, 145, 1, 0, 0, 0, 147, 6, 1, 0, 0, 0, 148, 151, 3, 17, 8, 0, 149, 151, 3, 15, 7, 0, 150, 148, 1, 0, 0, 0, 150, 149, 1, 0, 0, 0, 151, 8, 1, 0, 0, 0, 152, 159, 3, 25, 12, 0, 153, 159, 3, 27, 13, 0, 154, 159, 3, 29, 14, 0, 155, 159, 3, 31, 15, 0, 156, 159, 3, 33, 16, 0, 157, 159, 3, 35, 17, 0, 158, 152, 1, 0, 0, 0, 158, 153, 1, 0, 0, 0, 158, 154, 1, 0, 0, 0, 158, 155, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 158, 157, 1, 0, 0, 0, 159, 10, 1, 0, 0, 0, 160, 163, 3, 39, 19, 0, 161, 163, 3, 41, 20, 0, 162, 160, 1, 0, 0, 0, 162, 161, 1, 0, 0, 0, 163, 12, 1, 0, 0, 0, 164, 165, 5, 61, 0, 0, 165, 14, 1, 0, 0, 0, 166, 167, 5, 45, 0, 0, 167, 16, 1, 0, 0, 0, 168, 169, 5, 43, 0, 0, 169, 18, 1, 0, 0, 0, 170, 171, 5, 42, 0, 0, 171, 20, 1, 0, 0, 0, 172, 173, 5, 47, 0, 0, 173, 22, 1, 0, 0, 0, 174, 175, 5, 37, 0, 0, 175, 24, 1, 0, 0, 0, 176, 177, 5, 62, 0, 0, 177, 26, 1, 0, 0, 0, 178, 179, 5, 60, 0, 0, 179, 28, 1, 0, 0, 0, 180, 181, 5, 62, 0, 0, 181, 182, 5, 61, 0, 0, 182, 30, 1, 0, 0, 0, 183, 184, 5, 60, 0, 0, 184, 185, 5, 61, 0, 0, 185, 32, 1, 0, 0, 0, 186, 187, 5, 61, 0, 0, 187, 188, 5, 61, 0, 0, 188, 34, 1, 0, 0, 0, 189, 190, 5, 33, 0, 0, 190, 191, 5, 61, 0, 0, 191, 36, 1, 0, 0, 0, 192, 193, 5, 33, 0, 0, 193, 38, 1, 0, 0, 0, 194, 195, 5, 38, 0, 0, 195, 196, 5, 38, 0, 0, 196, 40, 1, 0, 0, 0, 197, 198, 5, 124, 0, 0, 198, 199, 5, 124, 0, 0, 199, 42, 1, 0, 0, 0, 200, 201, 5, 46, 0, 0, 201, 44, 1, 0, 0, 0, 202, 203, 5, 40, 0, 0, 203, 46, 1, 0, 0, 0, 204, 205, 5, 41, 0, 0, 205, 48, 1, 0, 0, 0, 206, 207, 5, 123, 0, 0, 207, 50, 1, 0, 0, 0, 208, 209, 5, 125, 0, 0, 209, 52, 1, 0, 0, 0, 210, 211, 5, 59, 0, 0, 211, 54, 1, 0, 0, 0, 212, 213, 5, 44, 0, 0, 213, 56, 1, 0, 0, 0, 214, 215, 5, 99, 0, 0, 215, 216, 5, 108, 0, 0, 216, 217, 5, 97, 0, 0, 217, 218, 5, 115, 0, 0, 218, 219, 5, 115, 0, 0, 219, 58, 1, 0, 0, 0, 220, 221, 5, 116, 0, 0, 221, 222, 5, 104, 0, 0, 222, 223, 5, 105, 0, 0, 223, 224, 5, 115, 0, 0, 224, 60, 1, 0, 0, 0, 225, 226, 5, 119, 0, 0, 226, 227, 5, 104, 0, 0, 227, 228, 5, 105, 0, 0, 228, 229, 5, 108, 0, 0, 229, 230, 5, 101, 0, 0, 230, 62, 1, 0, 0, 0, 231, 232, 5, 105, 0, 0, 232, 233, 5, 102, 0, 0, 233, 64, 1, 0, 0, 0, 234, 235, 5, 101, 0, 0, 235, 236, 5, 108, 0, 0, 236, 237, 5, 115, 0, 0, 237, 238, 5, 101, 0, 0, 238, 66, 1, 0, 0, 0, 239, 240, 5, 114, 0, 0, 240, 241, 5, 101, 0, 0, 241, 242, 5, 116, 0, 0, 242, 243, 5, 117, 0, 0, 243, 244, 5, 114, 0, 0, 244, 245, 5, 110, 0, 0, 245, 68, 1, 0, 0, 0, 246, 247, 5, 110, 0, 0, 247, 248, 5, 101, 0, 0, 248, 249, 5, 119, 0, 0, 249, 70, 1, 0, 0, 0, 250, 251, 7, 0, 0, 0, 251, 72, 1, 0, 0, 0, 252, 253, 7, 1, 0, 0, 253, 74, 1, 0, 0, 0, 254, 258, 3, 71, 35, 0, 255, 258, 3, 73, 36, 0, 256, 258, 7, 2, 0, 0, 257, 254, 1, 0, 0, 0, 257, 255, 1, 0, 0, 0, 257, 256, 1, 0, 0, 0, 258, 76, 1, 0, 0, 0, 259, 263, 3, 71, 35, 0, 260, 262, 3, 75, 37, 0, 261, 260, 1, 0, 0, 0, 262, 265, 1, 0, 0, 0, 263, 261, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 78, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 266, 267, 5, 118, 0, 0, 267, 268, 5, 111, 0, 0, 268, 269, 5, 105, 0, 0, 269, 270, 5, 100, 0, 0, 270, 80, 1, 0, 0, 0, 271, 272, 5, 105, 0, 0, 272, 273, 5, 110, 0, 0, 273, 274, 5, 116, 0, 0, 274, 82, 1, 0, 0, 0, 275, 276, 5, 98, 0, 0, 276, 277, 5, 111, 0, 0, 277, 278, 5, 111, 0, 0, 278, 279, 5, 108, 0, 0, 279, 84, 1, 0, 0, 0, 280, 281, 5, 99, 0, 0, 281, 282, 5, 104, 0, 0, 282, 283, 5, 97, 0, 0, 283, 284, 5, 114, 0, 0, 284, 86, 1, 0, 0, 0, 285, 287, 7, 3, 0, 0, 286, 285, 1, 0, 0, 0, 287, 290, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 291, 293, 7, 1, 0, 0, 292, 291, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 88, 1, 0, 0, 0, 296, 298, 5, 39, 0, 0, 297, 299, 8, 4, 0, 0, 298, 297, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 301, 5, 39, 0, 0, 301, 90, 1, 0, 0, 0, 302, 303, 5, 116, 0, 0, 303, 304, 5, 114, 0, 0, 304, 305, 5, 117, 0, 0, 305, 312, 5, 101, 0, 0, 306, 307, 5, 102, 0, 0, 307, 308, 5, 97, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 115, 0, 0, 310, 312, 5, 101, 0, 0, 311, 302, 1, 0, 0, 0, 311, 306, 1, 0, 0, 0, 312, 92, 1, 0, 0, 0, 313, 314, 5, 110, 0, 0, 314, 315, 5, 117, 0, 0, 315, 316, 5, 108, 0, 0, 316, 317, 5, 108, 0, 0, 317, 94, 1, 0, 0, 0, 318, 319, 7, 5, 0, 0, 319, 320, 1, 0, 0, 0, 320, 321, 6, 47, 0, 0, 321, 96, 1, 0, 0, 0, 11, 0, 146, 150, 158, 162, 257, 263, 288, 294, 298, 311, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/gen/DecafLexer.java b/src/main/java/gen/DecafLexer.java new file mode 100644 index 0000000..1448a7c --- /dev/null +++ b/src/main/java/gen/DecafLexer.java @@ -0,0 +1,338 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 +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 DecafLexer 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 + AccessModifierPublic=1, MainMethodDecl=2, DotOperator=3, LineOperator=4, + ComparisonOperator=5, LogicalOpertor=6, Assign=7, Minus=8, Plus=9, Multipilkation=10, + Division=11, Modulo=12, Greater=13, Less=14, GreaterEqual=15, LessEqual=16, + Equal=17, NotEqual=18, Not=19, And=20, Or=21, Dot=22, OpenRoundBracket=23, + ClosedRoundBracket=24, OpenCurlyBracket=25, ClosedCurlyBracket=26, Semicolon=27, + Comma=28, Class=29, This=30, While=31, If=32, Else=33, Return=34, New=35, + Identifier=36, Void=37, Int=38, Boolean=39, Char=40, IntValue=41, CharValue=42, + BooleanValue=43, NullValue=44, WS=45; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", + "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", + "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", + "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "Return", "New", "Alpabetic", "Numeric", + "ValidIdentSymbols", "Identifier", "Void", "Int", "Boolean", "Char", + "IntValue", "CharValue", "BooleanValue", "NullValue", "WS" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'public'", "'public static void main(String[] args)'", null, null, + null, null, "'='", "'-'", "'+'", "'*'", "'/'", "'%'", "'>'", "'<'", "'>='", + "'<='", "'=='", "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", + "'}'", "';'", "','", "'class'", "'this'", "'while'", "'if'", "'else'", + "'return'", "'new'", null, "'void'", "'int'", "'bool'", "'char'", null, + null, null, "'null'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", + "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", + "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", + "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "Return", "New", "Identifier", "Void", + "Int", "Boolean", "Char", "IntValue", "CharValue", "BooleanValue", "NullValue", + "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] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public DecafLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Decaf.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-\u0142\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ + "\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ + "\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ + "\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+ + "\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002"+ + "\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+ + "\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+ + "\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ + "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ + "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ + "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ + "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ + "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ + "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u0001\u0000"+ + "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ + "\u0003\u0002\u0093\b\u0002\u0001\u0003\u0001\u0003\u0003\u0003\u0097\b"+ + "\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+ + "\u0004\u0003\u0004\u009f\b\u0004\u0001\u0005\u0001\u0005\u0003\u0005\u00a3"+ + "\b\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001"+ + "\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001"+ + "\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ + "\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001"+ + "\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001"+ + "\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001"+ + "\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001"+ + "\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001"+ + "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001"+ + "\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001"+ + "\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0001"+ + "!\u0001!\u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0001#\u0001"+ + "#\u0001$\u0001$\u0001%\u0001%\u0001%\u0003%\u0102\b%\u0001&\u0001&\u0005"+ + "&\u0106\b&\n&\f&\u0109\t&\u0001\'\u0001\'\u0001\'\u0001\'\u0001\'\u0001"+ + "(\u0001(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001)\u0001*\u0001"+ + "*\u0001*\u0001*\u0001*\u0001+\u0005+\u011f\b+\n+\f+\u0122\t+\u0001+\u0004"+ + "+\u0125\b+\u000b+\f+\u0126\u0001,\u0001,\u0003,\u012b\b,\u0001,\u0001"+ + ",\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0003"+ + "-\u0138\b-\u0001.\u0001.\u0001.\u0001.\u0001.\u0001/\u0001/\u0001/\u0001"+ + "/\u0000\u00000\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/\u00181\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f"+ + "? A!C\"E#G\u0000I\u0000K\u0000M$O%Q&S\'U(W)Y*[+],_-\u0001\u0000\u0006"+ + "\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0002\u0000++--\u0002\u0000"+ + "\n\n\r\r\u0003\u0000\t\n\r\r \u014e\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\u00003\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\u0000A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000"+ + "\u0000\u0000E\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+ + "O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+ + "\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+ + "\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+ + "]\u0001\u0000\u0000\u0000\u0000_\u0001\u0000\u0000\u0000\u0001a\u0001"+ + "\u0000\u0000\u0000\u0003h\u0001\u0000\u0000\u0000\u0005\u0092\u0001\u0000"+ + "\u0000\u0000\u0007\u0096\u0001\u0000\u0000\u0000\t\u009e\u0001\u0000\u0000"+ + "\u0000\u000b\u00a2\u0001\u0000\u0000\u0000\r\u00a4\u0001\u0000\u0000\u0000"+ + "\u000f\u00a6\u0001\u0000\u0000\u0000\u0011\u00a8\u0001\u0000\u0000\u0000"+ + "\u0013\u00aa\u0001\u0000\u0000\u0000\u0015\u00ac\u0001\u0000\u0000\u0000"+ + "\u0017\u00ae\u0001\u0000\u0000\u0000\u0019\u00b0\u0001\u0000\u0000\u0000"+ + "\u001b\u00b2\u0001\u0000\u0000\u0000\u001d\u00b4\u0001\u0000\u0000\u0000"+ + "\u001f\u00b7\u0001\u0000\u0000\u0000!\u00ba\u0001\u0000\u0000\u0000#\u00bd"+ + "\u0001\u0000\u0000\u0000%\u00c0\u0001\u0000\u0000\u0000\'\u00c2\u0001"+ + "\u0000\u0000\u0000)\u00c5\u0001\u0000\u0000\u0000+\u00c8\u0001\u0000\u0000"+ + "\u0000-\u00ca\u0001\u0000\u0000\u0000/\u00cc\u0001\u0000\u0000\u00001"+ + "\u00ce\u0001\u0000\u0000\u00003\u00d0\u0001\u0000\u0000\u00005\u00d2\u0001"+ + "\u0000\u0000\u00007\u00d4\u0001\u0000\u0000\u00009\u00d6\u0001\u0000\u0000"+ + "\u0000;\u00dc\u0001\u0000\u0000\u0000=\u00e1\u0001\u0000\u0000\u0000?"+ + "\u00e7\u0001\u0000\u0000\u0000A\u00ea\u0001\u0000\u0000\u0000C\u00ef\u0001"+ + "\u0000\u0000\u0000E\u00f6\u0001\u0000\u0000\u0000G\u00fa\u0001\u0000\u0000"+ + "\u0000I\u00fc\u0001\u0000\u0000\u0000K\u0101\u0001\u0000\u0000\u0000M"+ + "\u0103\u0001\u0000\u0000\u0000O\u010a\u0001\u0000\u0000\u0000Q\u010f\u0001"+ + "\u0000\u0000\u0000S\u0113\u0001\u0000\u0000\u0000U\u0118\u0001\u0000\u0000"+ + "\u0000W\u0120\u0001\u0000\u0000\u0000Y\u0128\u0001\u0000\u0000\u0000["+ + "\u0137\u0001\u0000\u0000\u0000]\u0139\u0001\u0000\u0000\u0000_\u013e\u0001"+ + "\u0000\u0000\u0000ab\u0005p\u0000\u0000bc\u0005u\u0000\u0000cd\u0005b"+ + "\u0000\u0000de\u0005l\u0000\u0000ef\u0005i\u0000\u0000fg\u0005c\u0000"+ + "\u0000g\u0002\u0001\u0000\u0000\u0000hi\u0005p\u0000\u0000ij\u0005u\u0000"+ + "\u0000jk\u0005b\u0000\u0000kl\u0005l\u0000\u0000lm\u0005i\u0000\u0000"+ + "mn\u0005c\u0000\u0000no\u0005 \u0000\u0000op\u0005s\u0000\u0000pq\u0005"+ + "t\u0000\u0000qr\u0005a\u0000\u0000rs\u0005t\u0000\u0000st\u0005i\u0000"+ + "\u0000tu\u0005c\u0000\u0000uv\u0005 \u0000\u0000vw\u0005v\u0000\u0000"+ + "wx\u0005o\u0000\u0000xy\u0005i\u0000\u0000yz\u0005d\u0000\u0000z{\u0005"+ + " \u0000\u0000{|\u0005m\u0000\u0000|}\u0005a\u0000\u0000}~\u0005i\u0000"+ + "\u0000~\u007f\u0005n\u0000\u0000\u007f\u0080\u0005(\u0000\u0000\u0080"+ + "\u0081\u0005S\u0000\u0000\u0081\u0082\u0005t\u0000\u0000\u0082\u0083\u0005"+ + "r\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+ + "\u0000\u0085\u0086\u0005g\u0000\u0000\u0086\u0087\u0005[\u0000\u0000\u0087"+ + "\u0088\u0005]\u0000\u0000\u0088\u0089\u0005 \u0000\u0000\u0089\u008a\u0005"+ + "a\u0000\u0000\u008a\u008b\u0005r\u0000\u0000\u008b\u008c\u0005g\u0000"+ + "\u0000\u008c\u008d\u0005s\u0000\u0000\u008d\u008e\u0005)\u0000\u0000\u008e"+ + "\u0004\u0001\u0000\u0000\u0000\u008f\u0093\u0003\u0013\t\u0000\u0090\u0093"+ + "\u0003\u0015\n\u0000\u0091\u0093\u0003\u0017\u000b\u0000\u0092\u008f\u0001"+ + "\u0000\u0000\u0000\u0092\u0090\u0001\u0000\u0000\u0000\u0092\u0091\u0001"+ + "\u0000\u0000\u0000\u0093\u0006\u0001\u0000\u0000\u0000\u0094\u0097\u0003"+ + "\u0011\b\u0000\u0095\u0097\u0003\u000f\u0007\u0000\u0096\u0094\u0001\u0000"+ + "\u0000\u0000\u0096\u0095\u0001\u0000\u0000\u0000\u0097\b\u0001\u0000\u0000"+ + "\u0000\u0098\u009f\u0003\u0019\f\u0000\u0099\u009f\u0003\u001b\r\u0000"+ + "\u009a\u009f\u0003\u001d\u000e\u0000\u009b\u009f\u0003\u001f\u000f\u0000"+ + "\u009c\u009f\u0003!\u0010\u0000\u009d\u009f\u0003#\u0011\u0000\u009e\u0098"+ + "\u0001\u0000\u0000\u0000\u009e\u0099\u0001\u0000\u0000\u0000\u009e\u009a"+ + "\u0001\u0000\u0000\u0000\u009e\u009b\u0001\u0000\u0000\u0000\u009e\u009c"+ + "\u0001\u0000\u0000\u0000\u009e\u009d\u0001\u0000\u0000\u0000\u009f\n\u0001"+ + "\u0000\u0000\u0000\u00a0\u00a3\u0003\'\u0013\u0000\u00a1\u00a3\u0003)"+ + "\u0014\u0000\u00a2\u00a0\u0001\u0000\u0000\u0000\u00a2\u00a1\u0001\u0000"+ + "\u0000\u0000\u00a3\f\u0001\u0000\u0000\u0000\u00a4\u00a5\u0005=\u0000"+ + "\u0000\u00a5\u000e\u0001\u0000\u0000\u0000\u00a6\u00a7\u0005-\u0000\u0000"+ + "\u00a7\u0010\u0001\u0000\u0000\u0000\u00a8\u00a9\u0005+\u0000\u0000\u00a9"+ + "\u0012\u0001\u0000\u0000\u0000\u00aa\u00ab\u0005*\u0000\u0000\u00ab\u0014"+ + "\u0001\u0000\u0000\u0000\u00ac\u00ad\u0005/\u0000\u0000\u00ad\u0016\u0001"+ + "\u0000\u0000\u0000\u00ae\u00af\u0005%\u0000\u0000\u00af\u0018\u0001\u0000"+ + "\u0000\u0000\u00b0\u00b1\u0005>\u0000\u0000\u00b1\u001a\u0001\u0000\u0000"+ + "\u0000\u00b2\u00b3\u0005<\u0000\u0000\u00b3\u001c\u0001\u0000\u0000\u0000"+ + "\u00b4\u00b5\u0005>\u0000\u0000\u00b5\u00b6\u0005=\u0000\u0000\u00b6\u001e"+ + "\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005<\u0000\u0000\u00b8\u00b9\u0005"+ + "=\u0000\u0000\u00b9 \u0001\u0000\u0000\u0000\u00ba\u00bb\u0005=\u0000"+ + "\u0000\u00bb\u00bc\u0005=\u0000\u0000\u00bc\"\u0001\u0000\u0000\u0000"+ + "\u00bd\u00be\u0005!\u0000\u0000\u00be\u00bf\u0005=\u0000\u0000\u00bf$"+ + "\u0001\u0000\u0000\u0000\u00c0\u00c1\u0005!\u0000\u0000\u00c1&\u0001\u0000"+ + "\u0000\u0000\u00c2\u00c3\u0005&\u0000\u0000\u00c3\u00c4\u0005&\u0000\u0000"+ + "\u00c4(\u0001\u0000\u0000\u0000\u00c5\u00c6\u0005|\u0000\u0000\u00c6\u00c7"+ + "\u0005|\u0000\u0000\u00c7*\u0001\u0000\u0000\u0000\u00c8\u00c9\u0005."+ + "\u0000\u0000\u00c9,\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005(\u0000\u0000"+ + "\u00cb.\u0001\u0000\u0000\u0000\u00cc\u00cd\u0005)\u0000\u0000\u00cd0"+ + "\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005{\u0000\u0000\u00cf2\u0001\u0000"+ + "\u0000\u0000\u00d0\u00d1\u0005}\u0000\u0000\u00d14\u0001\u0000\u0000\u0000"+ + "\u00d2\u00d3\u0005;\u0000\u0000\u00d36\u0001\u0000\u0000\u0000\u00d4\u00d5"+ + "\u0005,\u0000\u0000\u00d58\u0001\u0000\u0000\u0000\u00d6\u00d7\u0005c"+ + "\u0000\u0000\u00d7\u00d8\u0005l\u0000\u0000\u00d8\u00d9\u0005a\u0000\u0000"+ + "\u00d9\u00da\u0005s\u0000\u0000\u00da\u00db\u0005s\u0000\u0000\u00db:"+ + "\u0001\u0000\u0000\u0000\u00dc\u00dd\u0005t\u0000\u0000\u00dd\u00de\u0005"+ + "h\u0000\u0000\u00de\u00df\u0005i\u0000\u0000\u00df\u00e0\u0005s\u0000"+ + "\u0000\u00e0<\u0001\u0000\u0000\u0000\u00e1\u00e2\u0005w\u0000\u0000\u00e2"+ + "\u00e3\u0005h\u0000\u0000\u00e3\u00e4\u0005i\u0000\u0000\u00e4\u00e5\u0005"+ + "l\u0000\u0000\u00e5\u00e6\u0005e\u0000\u0000\u00e6>\u0001\u0000\u0000"+ + "\u0000\u00e7\u00e8\u0005i\u0000\u0000\u00e8\u00e9\u0005f\u0000\u0000\u00e9"+ + "@\u0001\u0000\u0000\u0000\u00ea\u00eb\u0005e\u0000\u0000\u00eb\u00ec\u0005"+ + "l\u0000\u0000\u00ec\u00ed\u0005s\u0000\u0000\u00ed\u00ee\u0005e\u0000"+ + "\u0000\u00eeB\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005r\u0000\u0000\u00f0"+ + "\u00f1\u0005e\u0000\u0000\u00f1\u00f2\u0005t\u0000\u0000\u00f2\u00f3\u0005"+ + "u\u0000\u0000\u00f3\u00f4\u0005r\u0000\u0000\u00f4\u00f5\u0005n\u0000"+ + "\u0000\u00f5D\u0001\u0000\u0000\u0000\u00f6\u00f7\u0005n\u0000\u0000\u00f7"+ + "\u00f8\u0005e\u0000\u0000\u00f8\u00f9\u0005w\u0000\u0000\u00f9F\u0001"+ + "\u0000\u0000\u0000\u00fa\u00fb\u0007\u0000\u0000\u0000\u00fbH\u0001\u0000"+ + "\u0000\u0000\u00fc\u00fd\u0007\u0001\u0000\u0000\u00fdJ\u0001\u0000\u0000"+ + "\u0000\u00fe\u0102\u0003G#\u0000\u00ff\u0102\u0003I$\u0000\u0100\u0102"+ + "\u0007\u0002\u0000\u0000\u0101\u00fe\u0001\u0000\u0000\u0000\u0101\u00ff"+ + "\u0001\u0000\u0000\u0000\u0101\u0100\u0001\u0000\u0000\u0000\u0102L\u0001"+ + "\u0000\u0000\u0000\u0103\u0107\u0003G#\u0000\u0104\u0106\u0003K%\u0000"+ + "\u0105\u0104\u0001\u0000\u0000\u0000\u0106\u0109\u0001\u0000\u0000\u0000"+ + "\u0107\u0105\u0001\u0000\u0000\u0000\u0107\u0108\u0001\u0000\u0000\u0000"+ + "\u0108N\u0001\u0000\u0000\u0000\u0109\u0107\u0001\u0000\u0000\u0000\u010a"+ + "\u010b\u0005v\u0000\u0000\u010b\u010c\u0005o\u0000\u0000\u010c\u010d\u0005"+ + "i\u0000\u0000\u010d\u010e\u0005d\u0000\u0000\u010eP\u0001\u0000\u0000"+ + "\u0000\u010f\u0110\u0005i\u0000\u0000\u0110\u0111\u0005n\u0000\u0000\u0111"+ + "\u0112\u0005t\u0000\u0000\u0112R\u0001\u0000\u0000\u0000\u0113\u0114\u0005"+ + "b\u0000\u0000\u0114\u0115\u0005o\u0000\u0000\u0115\u0116\u0005o\u0000"+ + "\u0000\u0116\u0117\u0005l\u0000\u0000\u0117T\u0001\u0000\u0000\u0000\u0118"+ + "\u0119\u0005c\u0000\u0000\u0119\u011a\u0005h\u0000\u0000\u011a\u011b\u0005"+ + "a\u0000\u0000\u011b\u011c\u0005r\u0000\u0000\u011cV\u0001\u0000\u0000"+ + "\u0000\u011d\u011f\u0007\u0003\u0000\u0000\u011e\u011d\u0001\u0000\u0000"+ + "\u0000\u011f\u0122\u0001\u0000\u0000\u0000\u0120\u011e\u0001\u0000\u0000"+ + "\u0000\u0120\u0121\u0001\u0000\u0000\u0000\u0121\u0124\u0001\u0000\u0000"+ + "\u0000\u0122\u0120\u0001\u0000\u0000\u0000\u0123\u0125\u0007\u0001\u0000"+ + "\u0000\u0124\u0123\u0001\u0000\u0000\u0000\u0125\u0126\u0001\u0000\u0000"+ + "\u0000\u0126\u0124\u0001\u0000\u0000\u0000\u0126\u0127\u0001\u0000\u0000"+ + "\u0000\u0127X\u0001\u0000\u0000\u0000\u0128\u012a\u0005\'\u0000\u0000"+ + "\u0129\u012b\b\u0004\u0000\u0000\u012a\u0129\u0001\u0000\u0000\u0000\u012a"+ + "\u012b\u0001\u0000\u0000\u0000\u012b\u012c\u0001\u0000\u0000\u0000\u012c"+ + "\u012d\u0005\'\u0000\u0000\u012dZ\u0001\u0000\u0000\u0000\u012e\u012f"+ + "\u0005t\u0000\u0000\u012f\u0130\u0005r\u0000\u0000\u0130\u0131\u0005u"+ + "\u0000\u0000\u0131\u0138\u0005e\u0000\u0000\u0132\u0133\u0005f\u0000\u0000"+ + "\u0133\u0134\u0005a\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136"+ + "\u0005s\u0000\u0000\u0136\u0138\u0005e\u0000\u0000\u0137\u012e\u0001\u0000"+ + "\u0000\u0000\u0137\u0132\u0001\u0000\u0000\u0000\u0138\\\u0001\u0000\u0000"+ + "\u0000\u0139\u013a\u0005n\u0000\u0000\u013a\u013b\u0005u\u0000\u0000\u013b"+ + "\u013c\u0005l\u0000\u0000\u013c\u013d\u0005l\u0000\u0000\u013d^\u0001"+ + "\u0000\u0000\u0000\u013e\u013f\u0007\u0005\u0000\u0000\u013f\u0140\u0001"+ + "\u0000\u0000\u0000\u0140\u0141\u0006/\u0000\u0000\u0141`\u0001\u0000\u0000"+ + "\u0000\u000b\u0000\u0092\u0096\u009e\u00a2\u0101\u0107\u0120\u0126\u012a"+ + "\u0137\u0001\u0006\u0000\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/gen/DecafLexer.tokens b/src/main/java/gen/DecafLexer.tokens new file mode 100644 index 0000000..6873c36 --- /dev/null +++ b/src/main/java/gen/DecafLexer.tokens @@ -0,0 +1,81 @@ +AccessModifierPublic=1 +MainMethodDecl=2 +DotOperator=3 +LineOperator=4 +ComparisonOperator=5 +LogicalOpertor=6 +Assign=7 +Minus=8 +Plus=9 +Multipilkation=10 +Division=11 +Modulo=12 +Greater=13 +Less=14 +GreaterEqual=15 +LessEqual=16 +Equal=17 +NotEqual=18 +Not=19 +And=20 +Or=21 +Dot=22 +OpenRoundBracket=23 +ClosedRoundBracket=24 +OpenCurlyBracket=25 +ClosedCurlyBracket=26 +Semicolon=27 +Comma=28 +Class=29 +This=30 +While=31 +If=32 +Else=33 +Return=34 +New=35 +Identifier=36 +Void=37 +Int=38 +Boolean=39 +Char=40 +IntValue=41 +CharValue=42 +BooleanValue=43 +NullValue=44 +WS=45 +'public'=1 +'public static void main(String[] args)'=2 +'='=7 +'-'=8 +'+'=9 +'*'=10 +'/'=11 +'%'=12 +'>'=13 +'<'=14 +'>='=15 +'<='=16 +'=='=17 +'!='=18 +'!'=19 +'&&'=20 +'||'=21 +'.'=22 +'('=23 +')'=24 +'{'=25 +'}'=26 +';'=27 +','=28 +'class'=29 +'this'=30 +'while'=31 +'if'=32 +'else'=33 +'return'=34 +'new'=35 +'void'=37 +'int'=38 +'bool'=39 +'char'=40 +'null'=44 diff --git a/src/main/java/gen/DecafListener.java b/src/main/java/gen/DecafListener.java new file mode 100644 index 0000000..4e2702f --- /dev/null +++ b/src/main/java/gen/DecafListener.java @@ -0,0 +1,359 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link DecafParser}. + */ +public interface DecafListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + */ + void enterProgram(DecafParser.ProgramContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + */ + void exitProgram(DecafParser.ProgramContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#classdecl}. + * @param ctx the parse tree + */ + void enterClassdecl(DecafParser.ClassdeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#classdecl}. + * @param ctx the parse tree + */ + void exitClassdecl(DecafParser.ClassdeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#constuctorDecl}. + * @param ctx the parse tree + */ + void enterConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#constuctorDecl}. + * @param ctx the parse tree + */ + void exitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#methodDecl}. + * @param ctx the parse tree + */ + void enterMethodDecl(DecafParser.MethodDeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#methodDecl}. + * @param ctx the parse tree + */ + void exitMethodDecl(DecafParser.MethodDeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#fieldDecl}. + * @param ctx the parse tree + */ + void enterFieldDecl(DecafParser.FieldDeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#fieldDecl}. + * @param ctx the parse tree + */ + void exitFieldDecl(DecafParser.FieldDeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#parameterList}. + * @param ctx the parse tree + */ + void enterParameterList(DecafParser.ParameterListContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#parameterList}. + * @param ctx the parse tree + */ + void exitParameterList(DecafParser.ParameterListContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#parameter}. + * @param ctx the parse tree + */ + void enterParameter(DecafParser.ParameterContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#parameter}. + * @param ctx the parse tree + */ + void exitParameter(DecafParser.ParameterContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(DecafParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(DecafParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#subExpression}. + * @param ctx the parse tree + */ + void enterSubExpression(DecafParser.SubExpressionContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#subExpression}. + * @param ctx the parse tree + */ + void exitSubExpression(DecafParser.SubExpressionContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#assignableExpr}. + * @param ctx the parse tree + */ + void enterAssignableExpr(DecafParser.AssignableExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#assignableExpr}. + * @param ctx the parse tree + */ + void exitAssignableExpr(DecafParser.AssignableExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#instVar}. + * @param ctx the parse tree + */ + void enterInstVar(DecafParser.InstVarContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#instVar}. + * @param ctx the parse tree + */ + void exitInstVar(DecafParser.InstVarContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#methodCall}. + * @param ctx the parse tree + */ + void enterMethodCall(DecafParser.MethodCallContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#methodCall}. + * @param ctx the parse tree + */ + void exitMethodCall(DecafParser.MethodCallContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#argumentList}. + * @param ctx the parse tree + */ + void enterArgumentList(DecafParser.ArgumentListContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#argumentList}. + * @param ctx the parse tree + */ + void exitArgumentList(DecafParser.ArgumentListContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#subReceiver}. + * @param ctx the parse tree + */ + void enterSubReceiver(DecafParser.SubReceiverContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#subReceiver}. + * @param ctx the parse tree + */ + void exitSubReceiver(DecafParser.SubReceiverContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#receiver}. + * @param ctx the parse tree + */ + void enterReceiver(DecafParser.ReceiverContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#receiver}. + * @param ctx the parse tree + */ + void exitReceiver(DecafParser.ReceiverContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#receivingMethod}. + * @param ctx the parse tree + */ + void enterReceivingMethod(DecafParser.ReceivingMethodContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#receivingMethod}. + * @param ctx the parse tree + */ + void exitReceivingMethod(DecafParser.ReceivingMethodContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#binaryExpr}. + * @param ctx the parse tree + */ + void enterBinaryExpr(DecafParser.BinaryExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#binaryExpr}. + * @param ctx the parse tree + */ + void exitBinaryExpr(DecafParser.BinaryExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#calcExpr}. + * @param ctx the parse tree + */ + void enterCalcExpr(DecafParser.CalcExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#calcExpr}. + * @param ctx the parse tree + */ + void exitCalcExpr(DecafParser.CalcExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#dotExpr}. + * @param ctx the parse tree + */ + void enterDotExpr(DecafParser.DotExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#dotExpr}. + * @param ctx the parse tree + */ + void exitDotExpr(DecafParser.DotExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#dotSubExpr}. + * @param ctx the parse tree + */ + void enterDotSubExpr(DecafParser.DotSubExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#dotSubExpr}. + * @param ctx the parse tree + */ + void exitDotSubExpr(DecafParser.DotSubExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#nonCalcExpr}. + * @param ctx the parse tree + */ + void enterNonCalcExpr(DecafParser.NonCalcExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#nonCalcExpr}. + * @param ctx the parse tree + */ + void exitNonCalcExpr(DecafParser.NonCalcExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#nonCalcOperator}. + * @param ctx the parse tree + */ + void enterNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#nonCalcOperator}. + * @param ctx the parse tree + */ + void exitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#stmtExpr}. + * @param ctx the parse tree + */ + void enterStmtExpr(DecafParser.StmtExprContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#stmtExpr}. + * @param ctx the parse tree + */ + void exitStmtExpr(DecafParser.StmtExprContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#statement}. + * @param ctx the parse tree + */ + void enterStatement(DecafParser.StatementContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#statement}. + * @param ctx the parse tree + */ + void exitStatement(DecafParser.StatementContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#returnStmt}. + * @param ctx the parse tree + */ + void enterReturnStmt(DecafParser.ReturnStmtContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#returnStmt}. + * @param ctx the parse tree + */ + void exitReturnStmt(DecafParser.ReturnStmtContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#localVarDecl}. + * @param ctx the parse tree + */ + void enterLocalVarDecl(DecafParser.LocalVarDeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#localVarDecl}. + * @param ctx the parse tree + */ + void exitLocalVarDecl(DecafParser.LocalVarDeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + */ + void enterBlock(DecafParser.BlockContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + */ + void exitBlock(DecafParser.BlockContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#whileStmt}. + * @param ctx the parse tree + */ + void enterWhileStmt(DecafParser.WhileStmtContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#whileStmt}. + * @param ctx the parse tree + */ + void exitWhileStmt(DecafParser.WhileStmtContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#ifElseStmt}. + * @param ctx the parse tree + */ + void enterIfElseStmt(DecafParser.IfElseStmtContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#ifElseStmt}. + * @param ctx the parse tree + */ + void exitIfElseStmt(DecafParser.IfElseStmtContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#ifStmt}. + * @param ctx the parse tree + */ + void enterIfStmt(DecafParser.IfStmtContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#ifStmt}. + * @param ctx the parse tree + */ + void exitIfStmt(DecafParser.IfStmtContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#elseStmt}. + * @param ctx the parse tree + */ + void enterElseStmt(DecafParser.ElseStmtContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#elseStmt}. + * @param ctx the parse tree + */ + void exitElseStmt(DecafParser.ElseStmtContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#assign}. + * @param ctx the parse tree + */ + void enterAssign(DecafParser.AssignContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#assign}. + * @param ctx the parse tree + */ + void exitAssign(DecafParser.AssignContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#newDecl}. + * @param ctx the parse tree + */ + void enterNewDecl(DecafParser.NewDeclContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#newDecl}. + * @param ctx the parse tree + */ + void exitNewDecl(DecafParser.NewDeclContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + */ + void enterType(DecafParser.TypeContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + */ + void exitType(DecafParser.TypeContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#value}. + * @param ctx the parse tree + */ + void enterValue(DecafParser.ValueContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#value}. + * @param ctx the parse tree + */ + void exitValue(DecafParser.ValueContext ctx); +} \ No newline at end of file diff --git a/src/main/java/gen/DecafParser.java b/src/main/java/gen/DecafParser.java new file mode 100644 index 0000000..f46dc11 --- /dev/null +++ b/src/main/java/gen/DecafParser.java @@ -0,0 +1,2864 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class DecafParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + AccessModifierPublic=1, MainMethodDecl=2, DotOperator=3, LineOperator=4, + ComparisonOperator=5, LogicalOpertor=6, Assign=7, Minus=8, Plus=9, Multipilkation=10, + Division=11, Modulo=12, Greater=13, Less=14, GreaterEqual=15, LessEqual=16, + Equal=17, NotEqual=18, Not=19, And=20, Or=21, Dot=22, OpenRoundBracket=23, + ClosedRoundBracket=24, OpenCurlyBracket=25, ClosedCurlyBracket=26, Semicolon=27, + Comma=28, Class=29, This=30, While=31, If=32, Else=33, Return=34, New=35, + Identifier=36, Void=37, Int=38, Boolean=39, Char=40, IntValue=41, CharValue=42, + BooleanValue=43, NullValue=44, WS=45; + public static final int + RULE_program = 0, RULE_classdecl = 1, RULE_constuctorDecl = 2, RULE_methodDecl = 3, + RULE_fieldDecl = 4, RULE_parameterList = 5, RULE_parameter = 6, RULE_expression = 7, + RULE_subExpression = 8, RULE_assignableExpr = 9, RULE_instVar = 10, RULE_methodCall = 11, + RULE_argumentList = 12, RULE_subReceiver = 13, RULE_receiver = 14, RULE_receivingMethod = 15, + RULE_binaryExpr = 16, RULE_calcExpr = 17, RULE_dotExpr = 18, RULE_dotSubExpr = 19, + RULE_nonCalcExpr = 20, RULE_nonCalcOperator = 21, RULE_stmtExpr = 22, + RULE_statement = 23, RULE_returnStmt = 24, RULE_localVarDecl = 25, RULE_block = 26, + RULE_whileStmt = 27, RULE_ifElseStmt = 28, RULE_ifStmt = 29, RULE_elseStmt = 30, + RULE_assign = 31, RULE_newDecl = 32, RULE_type = 33, RULE_value = 34; + private static String[] makeRuleNames() { + return new String[] { + "program", "classdecl", "constuctorDecl", "methodDecl", "fieldDecl", + "parameterList", "parameter", "expression", "subExpression", "assignableExpr", + "instVar", "methodCall", "argumentList", "subReceiver", "receiver", "receivingMethod", + "binaryExpr", "calcExpr", "dotExpr", "dotSubExpr", "nonCalcExpr", "nonCalcOperator", + "stmtExpr", "statement", "returnStmt", "localVarDecl", "block", "whileStmt", + "ifElseStmt", "ifStmt", "elseStmt", "assign", "newDecl", "type", "value" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'public'", "'public static void main(String[] args)'", null, null, + null, null, "'='", "'-'", "'+'", "'*'", "'/'", "'%'", "'>'", "'<'", "'>='", + "'<='", "'=='", "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", + "'}'", "';'", "','", "'class'", "'this'", "'while'", "'if'", "'else'", + "'return'", "'new'", null, "'void'", "'int'", "'bool'", "'char'", null, + null, null, "'null'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", + "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", + "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", + "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", + "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", + "This", "While", "If", "Else", "Return", "New", "Identifier", "Void", + "Int", "Boolean", "Char", "IntValue", "CharValue", "BooleanValue", "NullValue", + "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] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "Decaf.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public DecafParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class ProgramContext extends ParserRuleContext { + public List classdecl() { + return getRuleContexts(ClassdeclContext.class); + } + public ClassdeclContext classdecl(int i) { + return getRuleContext(ClassdeclContext.class,i); + } + public ProgramContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_program; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterProgram(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitProgram(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitProgram(this); + else return visitor.visitChildren(this); + } + } + + public final ProgramContext program() throws RecognitionException { + ProgramContext _localctx = new ProgramContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_program); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(71); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(70); + classdecl(); + } + } + setState(73); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==AccessModifierPublic || _la==Class ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ClassdeclContext extends ParserRuleContext { + public TerminalNode Class() { return getToken(DecafParser.Class, 0); } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenCurlyBracket() { return getToken(DecafParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(DecafParser.ClosedCurlyBracket, 0); } + public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } + public List constuctorDecl() { + return getRuleContexts(ConstuctorDeclContext.class); + } + public ConstuctorDeclContext constuctorDecl(int i) { + return getRuleContext(ConstuctorDeclContext.class,i); + } + public List fieldDecl() { + return getRuleContexts(FieldDeclContext.class); + } + public FieldDeclContext fieldDecl(int i) { + return getRuleContext(FieldDeclContext.class,i); + } + public List methodDecl() { + return getRuleContexts(MethodDeclContext.class); + } + public MethodDeclContext methodDecl(int i) { + return getRuleContext(MethodDeclContext.class,i); + } + public TerminalNode MainMethodDecl() { return getToken(DecafParser.MainMethodDecl, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public ClassdeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_classdecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterClassdecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitClassdecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitClassdecl(this); + else return visitor.visitChildren(this); + } + } + + public final ClassdeclContext classdecl() throws RecognitionException { + ClassdeclContext _localctx = new ClassdeclContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_classdecl); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(76); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifierPublic) { + { + setState(75); + match(AccessModifierPublic); + } + } + + setState(78); + match(Class); + setState(79); + match(Identifier); + setState(80); + match(OpenCurlyBracket); + setState(86); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2130303778818L) != 0)) { + { + setState(84); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { + case 1: + { + setState(81); + constuctorDecl(); + } + break; + case 2: + { + setState(82); + fieldDecl(); + } + break; + case 3: + { + setState(83); + methodDecl(); + } + break; + } + } + setState(88); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(91); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==MainMethodDecl) { + { + setState(89); + match(MainMethodDecl); + setState(90); + block(); + } + } + + setState(93); + match(ClosedCurlyBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ConstuctorDeclContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } + public ParameterListContext parameterList() { + return getRuleContext(ParameterListContext.class,0); + } + public ConstuctorDeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_constuctorDecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterConstuctorDecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitConstuctorDecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitConstuctorDecl(this); + else return visitor.visitChildren(this); + } + } + + public final ConstuctorDeclContext constuctorDecl() throws RecognitionException { + ConstuctorDeclContext _localctx = new ConstuctorDeclContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_constuctorDecl); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(96); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifierPublic) { + { + setState(95); + match(AccessModifierPublic); + } + } + + setState(98); + match(Identifier); + setState(99); + match(OpenRoundBracket); + setState(101); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) { + { + setState(100); + parameterList(); + } + } + + setState(103); + match(ClosedRoundBracket); + setState(104); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodDeclContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Void() { return getToken(DecafParser.Void, 0); } + public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } + public ParameterListContext parameterList() { + return getRuleContext(ParameterListContext.class,0); + } + public MethodDeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodDecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterMethodDecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitMethodDecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitMethodDecl(this); + else return visitor.visitChildren(this); + } + } + + public final MethodDeclContext methodDecl() throws RecognitionException { + MethodDeclContext _localctx = new MethodDeclContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_methodDecl); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(107); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifierPublic) { + { + setState(106); + match(AccessModifierPublic); + } + } + + setState(111); + _errHandler.sync(this); + switch (_input.LA(1)) { + case Identifier: + case Int: + case Boolean: + case Char: + { + setState(109); + type(); + } + break; + case Void: + { + setState(110); + match(Void); + } + break; + default: + throw new NoViableAltException(this); + } + setState(113); + match(Identifier); + setState(114); + match(OpenRoundBracket); + setState(116); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) { + { + setState(115); + parameterList(); + } + } + + setState(118); + match(ClosedRoundBracket); + setState(119); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FieldDeclContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode Semicolon() { return getToken(DecafParser.Semicolon, 0); } + public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } + public FieldDeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_fieldDecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFieldDecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFieldDecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFieldDecl(this); + else return visitor.visitChildren(this); + } + } + + public final FieldDeclContext fieldDecl() throws RecognitionException { + FieldDeclContext _localctx = new FieldDeclContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_fieldDecl); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(122); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==AccessModifierPublic) { + { + setState(121); + match(AccessModifierPublic); + } + } + + setState(124); + type(); + setState(125); + match(Identifier); + setState(126); + match(Semicolon); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParameterListContext extends ParserRuleContext { + public List parameter() { + return getRuleContexts(ParameterContext.class); + } + public ParameterContext parameter(int i) { + return getRuleContext(ParameterContext.class,i); + } + public List Comma() { return getTokens(DecafParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(DecafParser.Comma, i); + } + public ParameterListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameterList; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParameterList(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParameterList(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParameterList(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterListContext parameterList() throws RecognitionException { + ParameterListContext _localctx = new ParameterListContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_parameterList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(128); + parameter(); + setState(133); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Comma) { + { + { + setState(129); + match(Comma); + setState(130); + parameter(); + } + } + setState(135); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParameterContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public ParameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameter; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParameter(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParameter(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParameter(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterContext parameter() throws RecognitionException { + ParameterContext _localctx = new ParameterContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_parameter); + try { + enterOuterAlt(_localctx, 1); + { + setState(136); + type(); + setState(137); + match(Identifier); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public SubExpressionContext subExpression() { + return getRuleContext(SubExpressionContext.class,0); + } + public BinaryExprContext binaryExpr() { + return getRuleContext(BinaryExprContext.class,0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_expression); + try { + setState(141); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,12,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(139); + subExpression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(140); + binaryExpr(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SubExpressionContext extends ParserRuleContext { + public TerminalNode This() { return getToken(DecafParser.This, 0); } + public AssignableExprContext assignableExpr() { + return getRuleContext(AssignableExprContext.class,0); + } + public StmtExprContext stmtExpr() { + return getRuleContext(StmtExprContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public SubExpressionContext subExpression() { + return getRuleContext(SubExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public SubExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_subExpression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterSubExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitSubExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitSubExpression(this); + else return visitor.visitChildren(this); + } + } + + public final SubExpressionContext subExpression() throws RecognitionException { + SubExpressionContext _localctx = new SubExpressionContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_subExpression); + try { + setState(150); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,13,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(143); + match(This); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(144); + assignableExpr(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(145); + stmtExpr(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(146); + match(OpenRoundBracket); + setState(147); + subExpression(); + setState(148); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignableExprContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public InstVarContext instVar() { + return getRuleContext(InstVarContext.class,0); + } + public AssignableExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assignableExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterAssignableExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitAssignableExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitAssignableExpr(this); + else return visitor.visitChildren(this); + } + } + + public final AssignableExprContext assignableExpr() throws RecognitionException { + AssignableExprContext _localctx = new AssignableExprContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_assignableExpr); + try { + setState(154); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(152); + match(Identifier); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(153); + instVar(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class InstVarContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public SubReceiverContext subReceiver() { + return getRuleContext(SubReceiverContext.class,0); + } + public List receivingMethod() { + return getRuleContexts(ReceivingMethodContext.class); + } + public ReceivingMethodContext receivingMethod(int i) { + return getRuleContext(ReceivingMethodContext.class,i); + } + public InstVarContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_instVar; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterInstVar(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitInstVar(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitInstVar(this); + else return visitor.visitChildren(this); + } + } + + public final InstVarContext instVar() throws RecognitionException { + InstVarContext _localctx = new InstVarContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_instVar); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(157); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,15,_ctx) ) { + case 1: + { + setState(156); + subReceiver(); + } + break; + } + setState(162); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,16,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(159); + receivingMethod(); + } + } + } + setState(164); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,16,_ctx); + } + setState(165); + match(Identifier); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class MethodCallContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public ReceiverContext receiver() { + return getRuleContext(ReceiverContext.class,0); + } + public List receivingMethod() { + return getRuleContexts(ReceivingMethodContext.class); + } + public ReceivingMethodContext receivingMethod(int i) { + return getRuleContext(ReceivingMethodContext.class,i); + } + public MethodCallContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_methodCall; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterMethodCall(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitMethodCall(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitMethodCall(this); + else return visitor.visitChildren(this); + } + } + + public final MethodCallContext methodCall() throws RecognitionException { + MethodCallContext _localctx = new MethodCallContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_methodCall); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(168); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) { + case 1: + { + setState(167); + receiver(); + } + break; + } + setState(173); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,18,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(170); + receivingMethod(); + } + } + } + setState(175); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,18,_ctx); + } + setState(176); + match(Identifier); + setState(177); + match(OpenRoundBracket); + setState(178); + argumentList(); + setState(179); + match(ClosedRoundBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArgumentListContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List Comma() { return getTokens(DecafParser.Comma); } + public TerminalNode Comma(int i) { + return getToken(DecafParser.Comma, i); + } + public ArgumentListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_argumentList; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterArgumentList(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitArgumentList(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitArgumentList(this); + else return visitor.visitChildren(this); + } + } + + public final ArgumentListContext argumentList() throws RecognitionException { + ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_argumentList); + int _la; + try { + setState(191); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(182); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 33089510703104L) != 0)) { + { + setState(181); + expression(); + } + } + + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(184); + expression(); + setState(187); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(185); + match(Comma); + setState(186); + expression(); + } + } + setState(189); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==Comma ); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SubReceiverContext extends ParserRuleContext { + public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } + public TerminalNode This() { return getToken(DecafParser.This, 0); } + public NewDeclContext newDecl() { + return getRuleContext(NewDeclContext.class,0); + } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public SubReceiverContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_subReceiver; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterSubReceiver(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitSubReceiver(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitSubReceiver(this); + else return visitor.visitChildren(this); + } + } + + public final SubReceiverContext subReceiver() throws RecognitionException { + SubReceiverContext _localctx = new SubReceiverContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_subReceiver); + try { + enterOuterAlt(_localctx, 1); + { + { + setState(196); + _errHandler.sync(this); + switch (_input.LA(1)) { + case This: + { + setState(193); + match(This); + } + break; + case New: + { + setState(194); + newDecl(); + } + break; + case Identifier: + { + setState(195); + match(Identifier); + } + break; + default: + throw new NoViableAltException(this); + } + setState(198); + match(Dot); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReceiverContext extends ParserRuleContext { + public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } + public TerminalNode This() { return getToken(DecafParser.This, 0); } + public InstVarContext instVar() { + return getRuleContext(InstVarContext.class,0); + } + public NewDeclContext newDecl() { + return getRuleContext(NewDeclContext.class,0); + } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public ReceiverContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_receiver; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReceiver(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReceiver(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReceiver(this); + else return visitor.visitChildren(this); + } + } + + public final ReceiverContext receiver() throws RecognitionException { + ReceiverContext _localctx = new ReceiverContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_receiver); + try { + enterOuterAlt(_localctx, 1); + { + { + setState(204); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { + case 1: + { + setState(200); + match(This); + } + break; + case 2: + { + setState(201); + instVar(); + } + break; + case 3: + { + setState(202); + newDecl(); + } + break; + case 4: + { + setState(203); + match(Identifier); + } + break; + } + setState(206); + match(Dot); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReceivingMethodContext extends ParserRuleContext { + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } + public ReceivingMethodContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_receivingMethod; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReceivingMethod(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReceivingMethod(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReceivingMethod(this); + else return visitor.visitChildren(this); + } + } + + public final ReceivingMethodContext receivingMethod() throws RecognitionException { + ReceivingMethodContext _localctx = new ReceivingMethodContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_receivingMethod); + try { + enterOuterAlt(_localctx, 1); + { + setState(208); + match(Identifier); + setState(209); + match(OpenRoundBracket); + setState(210); + argumentList(); + setState(211); + match(ClosedRoundBracket); + setState(212); + match(Dot); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BinaryExprContext extends ParserRuleContext { + public CalcExprContext calcExpr() { + return getRuleContext(CalcExprContext.class,0); + } + public NonCalcExprContext nonCalcExpr() { + return getRuleContext(NonCalcExprContext.class,0); + } + public ValueContext value() { + return getRuleContext(ValueContext.class,0); + } + public TerminalNode Not() { return getToken(DecafParser.Not, 0); } + public BinaryExprContext binaryExpr() { + return getRuleContext(BinaryExprContext.class,0); + } + public BinaryExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_binaryExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBinaryExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBinaryExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBinaryExpr(this); + else return visitor.visitChildren(this); + } + } + + public final BinaryExprContext binaryExpr() throws RecognitionException { + BinaryExprContext _localctx = new BinaryExprContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_binaryExpr); + try { + setState(219); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(214); + calcExpr(0); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(215); + nonCalcExpr(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(216); + value(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(217); + match(Not); + setState(218); + binaryExpr(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CalcExprContext extends ParserRuleContext { + public DotExprContext dotExpr() { + return getRuleContext(DotExprContext.class,0); + } + public CalcExprContext calcExpr() { + return getRuleContext(CalcExprContext.class,0); + } + public TerminalNode LineOperator() { return getToken(DecafParser.LineOperator, 0); } + public CalcExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_calcExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterCalcExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitCalcExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitCalcExpr(this); + else return visitor.visitChildren(this); + } + } + + public final CalcExprContext calcExpr() throws RecognitionException { + return calcExpr(0); + } + + private CalcExprContext calcExpr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + CalcExprContext _localctx = new CalcExprContext(_ctx, _parentState); + CalcExprContext _prevctx = _localctx; + int _startState = 34; + enterRecursionRule(_localctx, 34, RULE_calcExpr, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(222); + dotExpr(0); + } + _ctx.stop = _input.LT(-1); + setState(229); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,25,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new CalcExprContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_calcExpr); + setState(224); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(225); + match(LineOperator); + setState(226); + dotExpr(0); + } + } + } + setState(231); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,25,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotExprContext extends ParserRuleContext { + public DotSubExprContext dotSubExpr() { + return getRuleContext(DotSubExprContext.class,0); + } + public DotExprContext dotExpr() { + return getRuleContext(DotExprContext.class,0); + } + public TerminalNode DotOperator() { return getToken(DecafParser.DotOperator, 0); } + public DotExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterDotExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitDotExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitDotExpr(this); + else return visitor.visitChildren(this); + } + } + + public final DotExprContext dotExpr() throws RecognitionException { + return dotExpr(0); + } + + private DotExprContext dotExpr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + DotExprContext _localctx = new DotExprContext(_ctx, _parentState); + DotExprContext _prevctx = _localctx; + int _startState = 36; + enterRecursionRule(_localctx, 36, RULE_dotExpr, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + { + setState(233); + dotSubExpr(); + } + _ctx.stop = _input.LT(-1); + setState(240); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,26,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new DotExprContext(_parentctx, _parentState); + pushNewRecursionContext(_localctx, _startState, RULE_dotExpr); + setState(235); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(236); + match(DotOperator); + setState(237); + dotSubExpr(); + } + } + } + setState(242); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,26,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DotSubExprContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(DecafParser.IntValue, 0); } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public InstVarContext instVar() { + return getRuleContext(InstVarContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public CalcExprContext calcExpr() { + return getRuleContext(CalcExprContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public DotSubExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dotSubExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterDotSubExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitDotSubExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitDotSubExpr(this); + else return visitor.visitChildren(this); + } + } + + public final DotSubExprContext dotSubExpr() throws RecognitionException { + DotSubExprContext _localctx = new DotSubExprContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_dotSubExpr); + try { + setState(251); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(243); + match(IntValue); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(244); + match(Identifier); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(245); + instVar(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(246); + methodCall(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(247); + match(OpenRoundBracket); + setState(248); + calcExpr(0); + setState(249); + match(ClosedRoundBracket); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalcExprContext extends ParserRuleContext { + public SubExpressionContext subExpression() { + return getRuleContext(SubExpressionContext.class,0); + } + public NonCalcOperatorContext nonCalcOperator() { + return getRuleContext(NonCalcOperatorContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public NonCalcExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalcExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNonCalcExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNonCalcExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNonCalcExpr(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalcExprContext nonCalcExpr() throws RecognitionException { + NonCalcExprContext _localctx = new NonCalcExprContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_nonCalcExpr); + try { + enterOuterAlt(_localctx, 1); + { + setState(253); + subExpression(); + setState(254); + nonCalcOperator(); + setState(255); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NonCalcOperatorContext extends ParserRuleContext { + public TerminalNode LogicalOpertor() { return getToken(DecafParser.LogicalOpertor, 0); } + public TerminalNode ComparisonOperator() { return getToken(DecafParser.ComparisonOperator, 0); } + public NonCalcOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_nonCalcOperator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNonCalcOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNonCalcOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNonCalcOperator(this); + else return visitor.visitChildren(this); + } + } + + public final NonCalcOperatorContext nonCalcOperator() throws RecognitionException { + NonCalcOperatorContext _localctx = new NonCalcOperatorContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_nonCalcOperator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(257); + _la = _input.LA(1); + if ( !(_la==ComparisonOperator || _la==LogicalOpertor) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StmtExprContext extends ParserRuleContext { + public AssignContext assign() { + return getRuleContext(AssignContext.class,0); + } + public NewDeclContext newDecl() { + return getRuleContext(NewDeclContext.class,0); + } + public MethodCallContext methodCall() { + return getRuleContext(MethodCallContext.class,0); + } + public StmtExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stmtExpr; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterStmtExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitStmtExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitStmtExpr(this); + else return visitor.visitChildren(this); + } + } + + public final StmtExprContext stmtExpr() throws RecognitionException { + StmtExprContext _localctx = new StmtExprContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_stmtExpr); + try { + setState(262); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(259); + assign(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(260); + newDecl(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(261); + methodCall(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StatementContext extends ParserRuleContext { + public ReturnStmtContext returnStmt() { + return getRuleContext(ReturnStmtContext.class,0); + } + public TerminalNode Semicolon() { return getToken(DecafParser.Semicolon, 0); } + public LocalVarDeclContext localVarDecl() { + return getRuleContext(LocalVarDeclContext.class,0); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public WhileStmtContext whileStmt() { + return getRuleContext(WhileStmtContext.class,0); + } + public IfElseStmtContext ifElseStmt() { + return getRuleContext(IfElseStmtContext.class,0); + } + public StmtExprContext stmtExpr() { + return getRuleContext(StmtExprContext.class,0); + } + public StatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterStatement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitStatement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitStatement(this); + else return visitor.visitChildren(this); + } + } + + public final StatementContext statement() throws RecognitionException { + StatementContext _localctx = new StatementContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_statement); + try { + setState(276); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,29,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(264); + returnStmt(); + setState(265); + match(Semicolon); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(267); + localVarDecl(); + setState(268); + match(Semicolon); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(270); + block(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(271); + whileStmt(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(272); + ifElseStmt(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(273); + stmtExpr(); + setState(274); + match(Semicolon); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReturnStmtContext extends ParserRuleContext { + public TerminalNode Return() { return getToken(DecafParser.Return, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ReturnStmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_returnStmt; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReturnStmt(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReturnStmt(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReturnStmt(this); + else return visitor.visitChildren(this); + } + } + + public final ReturnStmtContext returnStmt() throws RecognitionException { + ReturnStmtContext _localctx = new ReturnStmtContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_returnStmt); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(278); + match(Return); + setState(280); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 33089510703104L) != 0)) { + { + setState(279); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class LocalVarDeclContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode Assign() { return getToken(DecafParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public LocalVarDeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_localVarDecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterLocalVarDecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitLocalVarDecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitLocalVarDecl(this); + else return visitor.visitChildren(this); + } + } + + public final LocalVarDeclContext localVarDecl() throws RecognitionException { + LocalVarDeclContext _localctx = new LocalVarDeclContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_localVarDecl); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(282); + type(); + setState(283); + match(Identifier); + setState(286); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==Assign) { + { + setState(284); + match(Assign); + setState(285); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BlockContext extends ParserRuleContext { + public TerminalNode OpenCurlyBracket() { return getToken(DecafParser.OpenCurlyBracket, 0); } + public TerminalNode ClosedCurlyBracket() { return getToken(DecafParser.ClosedCurlyBracket, 0); } + public List statement() { + return getRuleContexts(StatementContext.class); + } + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class,i); + } + public BlockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_block; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBlock(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBlock(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBlock(this); + else return visitor.visitChildren(this); + } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(288); + match(OpenCurlyBracket); + setState(292); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2051954180096L) != 0)) { + { + { + setState(289); + statement(); + } + } + setState(294); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(295); + match(ClosedCurlyBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class WhileStmtContext extends ParserRuleContext { + public TerminalNode While() { return getToken(DecafParser.While, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public WhileStmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_whileStmt; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterWhileStmt(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitWhileStmt(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitWhileStmt(this); + else return visitor.visitChildren(this); + } + } + + public final WhileStmtContext whileStmt() throws RecognitionException { + WhileStmtContext _localctx = new WhileStmtContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_whileStmt); + try { + enterOuterAlt(_localctx, 1); + { + setState(297); + match(While); + setState(298); + match(OpenRoundBracket); + setState(299); + expression(); + setState(300); + match(ClosedRoundBracket); + setState(301); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfElseStmtContext extends ParserRuleContext { + public IfStmtContext ifStmt() { + return getRuleContext(IfStmtContext.class,0); + } + public ElseStmtContext elseStmt() { + return getRuleContext(ElseStmtContext.class,0); + } + public IfElseStmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifElseStmt; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterIfElseStmt(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitIfElseStmt(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitIfElseStmt(this); + else return visitor.visitChildren(this); + } + } + + public final IfElseStmtContext ifElseStmt() throws RecognitionException { + IfElseStmtContext _localctx = new IfElseStmtContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_ifElseStmt); + try { + enterOuterAlt(_localctx, 1); + { + setState(303); + ifStmt(); + setState(305); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,33,_ctx) ) { + case 1: + { + setState(304); + elseStmt(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfStmtContext extends ParserRuleContext { + public TerminalNode If() { return getToken(DecafParser.If, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public IfStmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifStmt; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterIfStmt(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitIfStmt(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitIfStmt(this); + else return visitor.visitChildren(this); + } + } + + public final IfStmtContext ifStmt() throws RecognitionException { + IfStmtContext _localctx = new IfStmtContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_ifStmt); + try { + enterOuterAlt(_localctx, 1); + { + setState(307); + match(If); + setState(308); + match(OpenRoundBracket); + setState(309); + expression(); + setState(310); + match(ClosedRoundBracket); + setState(311); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ElseStmtContext extends ParserRuleContext { + public TerminalNode Else() { return getToken(DecafParser.Else, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public ElseStmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_elseStmt; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterElseStmt(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitElseStmt(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitElseStmt(this); + else return visitor.visitChildren(this); + } + } + + public final ElseStmtContext elseStmt() throws RecognitionException { + ElseStmtContext _localctx = new ElseStmtContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_elseStmt); + try { + enterOuterAlt(_localctx, 1); + { + setState(313); + match(Else); + setState(314); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AssignContext extends ParserRuleContext { + public AssignableExprContext assignableExpr() { + return getRuleContext(AssignableExprContext.class,0); + } + public TerminalNode Assign() { return getToken(DecafParser.Assign, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public AssignContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assign; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterAssign(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitAssign(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + + public final AssignContext assign() throws RecognitionException { + AssignContext _localctx = new AssignContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_assign); + try { + enterOuterAlt(_localctx, 1); + { + setState(316); + assignableExpr(); + setState(317); + match(Assign); + setState(318); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NewDeclContext extends ParserRuleContext { + public TerminalNode New() { return getToken(DecafParser.New, 0); } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } + public ArgumentListContext argumentList() { + return getRuleContext(ArgumentListContext.class,0); + } + public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } + public NewDeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_newDecl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNewDecl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNewDecl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNewDecl(this); + else return visitor.visitChildren(this); + } + } + + public final NewDeclContext newDecl() throws RecognitionException { + NewDeclContext _localctx = new NewDeclContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_newDecl); + try { + enterOuterAlt(_localctx, 1); + { + setState(320); + match(New); + setState(321); + match(Identifier); + setState(322); + match(OpenRoundBracket); + setState(323); + argumentList(); + setState(324); + match(ClosedRoundBracket); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TypeContext extends ParserRuleContext { + public TerminalNode Int() { return getToken(DecafParser.Int, 0); } + public TerminalNode Boolean() { return getToken(DecafParser.Boolean, 0); } + public TerminalNode Char() { return getToken(DecafParser.Char, 0); } + public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_type; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterType(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitType(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + TypeContext _localctx = new TypeContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_type); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(326); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueContext extends ParserRuleContext { + public TerminalNode IntValue() { return getToken(DecafParser.IntValue, 0); } + public TerminalNode BooleanValue() { return getToken(DecafParser.BooleanValue, 0); } + public TerminalNode CharValue() { return getToken(DecafParser.CharValue, 0); } + public TerminalNode NullValue() { return getToken(DecafParser.NullValue, 0); } + public ValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_value; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterValue(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitValue(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitValue(this); + else return visitor.visitChildren(this); + } + } + + public final ValueContext value() throws RecognitionException { + ValueContext _localctx = new ValueContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_value); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(328); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 32985348833280L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 17: + return calcExpr_sempred((CalcExprContext)_localctx, predIndex); + case 18: + return dotExpr_sempred((DotExprContext)_localctx, predIndex); + } + return true; + } + private boolean calcExpr_sempred(CalcExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 2); + } + return true; + } + private boolean dotExpr_sempred(DotExprContext _localctx, int predIndex) { + switch (predIndex) { + case 1: + return precpred(_ctx, 2); + } + return true; + } + + public static final String _serializedATN = + "\u0004\u0001-\u014b\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\"\u0001"+ + "\u0000\u0004\u0000H\b\u0000\u000b\u0000\f\u0000I\u0001\u0001\u0003\u0001"+ + "M\b\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0005\u0001U\b\u0001\n\u0001\f\u0001X\t\u0001\u0001\u0001"+ + "\u0001\u0001\u0003\u0001\\\b\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ + "\u0003\u0002a\b\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002"+ + "f\b\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0003\u0003"+ + "l\b\u0003\u0001\u0003\u0001\u0003\u0003\u0003p\b\u0003\u0001\u0003\u0001"+ + "\u0003\u0001\u0003\u0003\u0003u\b\u0003\u0001\u0003\u0001\u0003\u0001"+ + "\u0003\u0001\u0004\u0003\u0004{\b\u0004\u0001\u0004\u0001\u0004\u0001"+ + "\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0005\u0005\u0084"+ + "\b\u0005\n\u0005\f\u0005\u0087\t\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0007\u0001\u0007\u0003\u0007\u008e\b\u0007\u0001\b\u0001\b\u0001"+ + "\b\u0001\b\u0001\b\u0001\b\u0001\b\u0003\b\u0097\b\b\u0001\t\u0001\t\u0003"+ + "\t\u009b\b\t\u0001\n\u0003\n\u009e\b\n\u0001\n\u0005\n\u00a1\b\n\n\n\f"+ + "\n\u00a4\t\n\u0001\n\u0001\n\u0001\u000b\u0003\u000b\u00a9\b\u000b\u0001"+ + "\u000b\u0005\u000b\u00ac\b\u000b\n\u000b\f\u000b\u00af\t\u000b\u0001\u000b"+ + "\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\f\u0003\f\u00b7"+ + "\b\f\u0001\f\u0001\f\u0001\f\u0004\f\u00bc\b\f\u000b\f\f\f\u00bd\u0003"+ + "\f\u00c0\b\f\u0001\r\u0001\r\u0001\r\u0003\r\u00c5\b\r\u0001\r\u0001\r"+ + "\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e\u00cd\b\u000e"+ + "\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f"+ + "\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010"+ + "\u0001\u0010\u0003\u0010\u00dc\b\u0010\u0001\u0011\u0001\u0011\u0001\u0011"+ + "\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011\u00e4\b\u0011\n\u0011"+ + "\f\u0011\u00e7\t\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ + "\u0001\u0012\u0001\u0012\u0005\u0012\u00ef\b\u0012\n\u0012\f\u0012\u00f2"+ + "\t\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001"+ + "\u0013\u0001\u0013\u0001\u0013\u0003\u0013\u00fc\b\u0013\u0001\u0014\u0001"+ + "\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+ + "\u0016\u0001\u0016\u0003\u0016\u0107\b\u0016\u0001\u0017\u0001\u0017\u0001"+ + "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001"+ + "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0003\u0017\u0115\b\u0017\u0001"+ + "\u0018\u0001\u0018\u0003\u0018\u0119\b\u0018\u0001\u0019\u0001\u0019\u0001"+ + "\u0019\u0001\u0019\u0003\u0019\u011f\b\u0019\u0001\u001a\u0001\u001a\u0005"+ + "\u001a\u0123\b\u001a\n\u001a\f\u001a\u0126\t\u001a\u0001\u001a\u0001\u001a"+ + "\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b"+ + "\u0001\u001c\u0001\u001c\u0003\u001c\u0132\b\u001c\u0001\u001d\u0001\u001d"+ + "\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e"+ + "\u0001\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001 \u0001"+ + " \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0000"+ + "\u0002\"$#\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016"+ + "\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BD\u0000\u0003\u0001\u0000\u0005"+ + "\u0006\u0002\u0000$$&(\u0001\u0000),\u0159\u0000G\u0001\u0000\u0000\u0000"+ + "\u0002L\u0001\u0000\u0000\u0000\u0004`\u0001\u0000\u0000\u0000\u0006k"+ + "\u0001\u0000\u0000\u0000\bz\u0001\u0000\u0000\u0000\n\u0080\u0001\u0000"+ + "\u0000\u0000\f\u0088\u0001\u0000\u0000\u0000\u000e\u008d\u0001\u0000\u0000"+ + "\u0000\u0010\u0096\u0001\u0000\u0000\u0000\u0012\u009a\u0001\u0000\u0000"+ + "\u0000\u0014\u009d\u0001\u0000\u0000\u0000\u0016\u00a8\u0001\u0000\u0000"+ + "\u0000\u0018\u00bf\u0001\u0000\u0000\u0000\u001a\u00c4\u0001\u0000\u0000"+ + "\u0000\u001c\u00cc\u0001\u0000\u0000\u0000\u001e\u00d0\u0001\u0000\u0000"+ + "\u0000 \u00db\u0001\u0000\u0000\u0000\"\u00dd\u0001\u0000\u0000\u0000"+ + "$\u00e8\u0001\u0000\u0000\u0000&\u00fb\u0001\u0000\u0000\u0000(\u00fd"+ + "\u0001\u0000\u0000\u0000*\u0101\u0001\u0000\u0000\u0000,\u0106\u0001\u0000"+ + "\u0000\u0000.\u0114\u0001\u0000\u0000\u00000\u0116\u0001\u0000\u0000\u0000"+ + "2\u011a\u0001\u0000\u0000\u00004\u0120\u0001\u0000\u0000\u00006\u0129"+ + "\u0001\u0000\u0000\u00008\u012f\u0001\u0000\u0000\u0000:\u0133\u0001\u0000"+ + "\u0000\u0000<\u0139\u0001\u0000\u0000\u0000>\u013c\u0001\u0000\u0000\u0000"+ + "@\u0140\u0001\u0000\u0000\u0000B\u0146\u0001\u0000\u0000\u0000D\u0148"+ + "\u0001\u0000\u0000\u0000FH\u0003\u0002\u0001\u0000GF\u0001\u0000\u0000"+ + "\u0000HI\u0001\u0000\u0000\u0000IG\u0001\u0000\u0000\u0000IJ\u0001\u0000"+ + "\u0000\u0000J\u0001\u0001\u0000\u0000\u0000KM\u0005\u0001\u0000\u0000"+ + "LK\u0001\u0000\u0000\u0000LM\u0001\u0000\u0000\u0000MN\u0001\u0000\u0000"+ + "\u0000NO\u0005\u001d\u0000\u0000OP\u0005$\u0000\u0000PV\u0005\u0019\u0000"+ + "\u0000QU\u0003\u0004\u0002\u0000RU\u0003\b\u0004\u0000SU\u0003\u0006\u0003"+ + "\u0000TQ\u0001\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TS\u0001\u0000"+ + "\u0000\u0000UX\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000VW\u0001"+ + "\u0000\u0000\u0000W[\u0001\u0000\u0000\u0000XV\u0001\u0000\u0000\u0000"+ + "YZ\u0005\u0002\u0000\u0000Z\\\u00034\u001a\u0000[Y\u0001\u0000\u0000\u0000"+ + "[\\\u0001\u0000\u0000\u0000\\]\u0001\u0000\u0000\u0000]^\u0005\u001a\u0000"+ + "\u0000^\u0003\u0001\u0000\u0000\u0000_a\u0005\u0001\u0000\u0000`_\u0001"+ + "\u0000\u0000\u0000`a\u0001\u0000\u0000\u0000ab\u0001\u0000\u0000\u0000"+ + "bc\u0005$\u0000\u0000ce\u0005\u0017\u0000\u0000df\u0003\n\u0005\u0000"+ + "ed\u0001\u0000\u0000\u0000ef\u0001\u0000\u0000\u0000fg\u0001\u0000\u0000"+ + "\u0000gh\u0005\u0018\u0000\u0000hi\u00034\u001a\u0000i\u0005\u0001\u0000"+ + "\u0000\u0000jl\u0005\u0001\u0000\u0000kj\u0001\u0000\u0000\u0000kl\u0001"+ + "\u0000\u0000\u0000lo\u0001\u0000\u0000\u0000mp\u0003B!\u0000np\u0005%"+ + "\u0000\u0000om\u0001\u0000\u0000\u0000on\u0001\u0000\u0000\u0000pq\u0001"+ + "\u0000\u0000\u0000qr\u0005$\u0000\u0000rt\u0005\u0017\u0000\u0000su\u0003"+ + "\n\u0005\u0000ts\u0001\u0000\u0000\u0000tu\u0001\u0000\u0000\u0000uv\u0001"+ + "\u0000\u0000\u0000vw\u0005\u0018\u0000\u0000wx\u00034\u001a\u0000x\u0007"+ + "\u0001\u0000\u0000\u0000y{\u0005\u0001\u0000\u0000zy\u0001\u0000\u0000"+ + "\u0000z{\u0001\u0000\u0000\u0000{|\u0001\u0000\u0000\u0000|}\u0003B!\u0000"+ + "}~\u0005$\u0000\u0000~\u007f\u0005\u001b\u0000\u0000\u007f\t\u0001\u0000"+ + "\u0000\u0000\u0080\u0085\u0003\f\u0006\u0000\u0081\u0082\u0005\u001c\u0000"+ + "\u0000\u0082\u0084\u0003\f\u0006\u0000\u0083\u0081\u0001\u0000\u0000\u0000"+ + "\u0084\u0087\u0001\u0000\u0000\u0000\u0085\u0083\u0001\u0000\u0000\u0000"+ + "\u0085\u0086\u0001\u0000\u0000\u0000\u0086\u000b\u0001\u0000\u0000\u0000"+ + "\u0087\u0085\u0001\u0000\u0000\u0000\u0088\u0089\u0003B!\u0000\u0089\u008a"+ + "\u0005$\u0000\u0000\u008a\r\u0001\u0000\u0000\u0000\u008b\u008e\u0003"+ + "\u0010\b\u0000\u008c\u008e\u0003 \u0010\u0000\u008d\u008b\u0001\u0000"+ + "\u0000\u0000\u008d\u008c\u0001\u0000\u0000\u0000\u008e\u000f\u0001\u0000"+ + "\u0000\u0000\u008f\u0097\u0005\u001e\u0000\u0000\u0090\u0097\u0003\u0012"+ + "\t\u0000\u0091\u0097\u0003,\u0016\u0000\u0092\u0093\u0005\u0017\u0000"+ + "\u0000\u0093\u0094\u0003\u0010\b\u0000\u0094\u0095\u0005\u0018\u0000\u0000"+ + "\u0095\u0097\u0001\u0000\u0000\u0000\u0096\u008f\u0001\u0000\u0000\u0000"+ + "\u0096\u0090\u0001\u0000\u0000\u0000\u0096\u0091\u0001\u0000\u0000\u0000"+ + "\u0096\u0092\u0001\u0000\u0000\u0000\u0097\u0011\u0001\u0000\u0000\u0000"+ + "\u0098\u009b\u0005$\u0000\u0000\u0099\u009b\u0003\u0014\n\u0000\u009a"+ + "\u0098\u0001\u0000\u0000\u0000\u009a\u0099\u0001\u0000\u0000\u0000\u009b"+ + "\u0013\u0001\u0000\u0000\u0000\u009c\u009e\u0003\u001a\r\u0000\u009d\u009c"+ + "\u0001\u0000\u0000\u0000\u009d\u009e\u0001\u0000\u0000\u0000\u009e\u00a2"+ + "\u0001\u0000\u0000\u0000\u009f\u00a1\u0003\u001e\u000f\u0000\u00a0\u009f"+ + "\u0001\u0000\u0000\u0000\u00a1\u00a4\u0001\u0000\u0000\u0000\u00a2\u00a0"+ + "\u0001\u0000\u0000\u0000\u00a2\u00a3\u0001\u0000\u0000\u0000\u00a3\u00a5"+ + "\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000\u0000\u00a5\u00a6"+ + "\u0005$\u0000\u0000\u00a6\u0015\u0001\u0000\u0000\u0000\u00a7\u00a9\u0003"+ + "\u001c\u000e\u0000\u00a8\u00a7\u0001\u0000\u0000\u0000\u00a8\u00a9\u0001"+ + "\u0000\u0000\u0000\u00a9\u00ad\u0001\u0000\u0000\u0000\u00aa\u00ac\u0003"+ + "\u001e\u000f\u0000\u00ab\u00aa\u0001\u0000\u0000\u0000\u00ac\u00af\u0001"+ + "\u0000\u0000\u0000\u00ad\u00ab\u0001\u0000\u0000\u0000\u00ad\u00ae\u0001"+ + "\u0000\u0000\u0000\u00ae\u00b0\u0001\u0000\u0000\u0000\u00af\u00ad\u0001"+ + "\u0000\u0000\u0000\u00b0\u00b1\u0005$\u0000\u0000\u00b1\u00b2\u0005\u0017"+ + "\u0000\u0000\u00b2\u00b3\u0003\u0018\f\u0000\u00b3\u00b4\u0005\u0018\u0000"+ + "\u0000\u00b4\u0017\u0001\u0000\u0000\u0000\u00b5\u00b7\u0003\u000e\u0007"+ + "\u0000\u00b6\u00b5\u0001\u0000\u0000\u0000\u00b6\u00b7\u0001\u0000\u0000"+ + "\u0000\u00b7\u00c0\u0001\u0000\u0000\u0000\u00b8\u00bb\u0003\u000e\u0007"+ + "\u0000\u00b9\u00ba\u0005\u001c\u0000\u0000\u00ba\u00bc\u0003\u000e\u0007"+ + "\u0000\u00bb\u00b9\u0001\u0000\u0000\u0000\u00bc\u00bd\u0001\u0000\u0000"+ + "\u0000\u00bd\u00bb\u0001\u0000\u0000\u0000\u00bd\u00be\u0001\u0000\u0000"+ + "\u0000\u00be\u00c0\u0001\u0000\u0000\u0000\u00bf\u00b6\u0001\u0000\u0000"+ + "\u0000\u00bf\u00b8\u0001\u0000\u0000\u0000\u00c0\u0019\u0001\u0000\u0000"+ + "\u0000\u00c1\u00c5\u0005\u001e\u0000\u0000\u00c2\u00c5\u0003@ \u0000\u00c3"+ + "\u00c5\u0005$\u0000\u0000\u00c4\u00c1\u0001\u0000\u0000\u0000\u00c4\u00c2"+ + "\u0001\u0000\u0000\u0000\u00c4\u00c3\u0001\u0000\u0000\u0000\u00c5\u00c6"+ + "\u0001\u0000\u0000\u0000\u00c6\u00c7\u0005\u0016\u0000\u0000\u00c7\u001b"+ + "\u0001\u0000\u0000\u0000\u00c8\u00cd\u0005\u001e\u0000\u0000\u00c9\u00cd"+ + "\u0003\u0014\n\u0000\u00ca\u00cd\u0003@ \u0000\u00cb\u00cd\u0005$\u0000"+ + "\u0000\u00cc\u00c8\u0001\u0000\u0000\u0000\u00cc\u00c9\u0001\u0000\u0000"+ + "\u0000\u00cc\u00ca\u0001\u0000\u0000\u0000\u00cc\u00cb\u0001\u0000\u0000"+ + "\u0000\u00cd\u00ce\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005\u0016\u0000"+ + "\u0000\u00cf\u001d\u0001\u0000\u0000\u0000\u00d0\u00d1\u0005$\u0000\u0000"+ + "\u00d1\u00d2\u0005\u0017\u0000\u0000\u00d2\u00d3\u0003\u0018\f\u0000\u00d3"+ + "\u00d4\u0005\u0018\u0000\u0000\u00d4\u00d5\u0005\u0016\u0000\u0000\u00d5"+ + "\u001f\u0001\u0000\u0000\u0000\u00d6\u00dc\u0003\"\u0011\u0000\u00d7\u00dc"+ + "\u0003(\u0014\u0000\u00d8\u00dc\u0003D\"\u0000\u00d9\u00da\u0005\u0013"+ + "\u0000\u0000\u00da\u00dc\u0003 \u0010\u0000\u00db\u00d6\u0001\u0000\u0000"+ + "\u0000\u00db\u00d7\u0001\u0000\u0000\u0000\u00db\u00d8\u0001\u0000\u0000"+ + "\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00dc!\u0001\u0000\u0000\u0000"+ + "\u00dd\u00de\u0006\u0011\uffff\uffff\u0000\u00de\u00df\u0003$\u0012\u0000"+ + "\u00df\u00e5\u0001\u0000\u0000\u0000\u00e0\u00e1\n\u0002\u0000\u0000\u00e1"+ + "\u00e2\u0005\u0004\u0000\u0000\u00e2\u00e4\u0003$\u0012\u0000\u00e3\u00e0"+ + "\u0001\u0000\u0000\u0000\u00e4\u00e7\u0001\u0000\u0000\u0000\u00e5\u00e3"+ + "\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000\u0000\u00e6#\u0001"+ + "\u0000\u0000\u0000\u00e7\u00e5\u0001\u0000\u0000\u0000\u00e8\u00e9\u0006"+ + "\u0012\uffff\uffff\u0000\u00e9\u00ea\u0003&\u0013\u0000\u00ea\u00f0\u0001"+ + "\u0000\u0000\u0000\u00eb\u00ec\n\u0002\u0000\u0000\u00ec\u00ed\u0005\u0003"+ + "\u0000\u0000\u00ed\u00ef\u0003&\u0013\u0000\u00ee\u00eb\u0001\u0000\u0000"+ + "\u0000\u00ef\u00f2\u0001\u0000\u0000\u0000\u00f0\u00ee\u0001\u0000\u0000"+ + "\u0000\u00f0\u00f1\u0001\u0000\u0000\u0000\u00f1%\u0001\u0000\u0000\u0000"+ + "\u00f2\u00f0\u0001\u0000\u0000\u0000\u00f3\u00fc\u0005)\u0000\u0000\u00f4"+ + "\u00fc\u0005$\u0000\u0000\u00f5\u00fc\u0003\u0014\n\u0000\u00f6\u00fc"+ + "\u0003\u0016\u000b\u0000\u00f7\u00f8\u0005\u0017\u0000\u0000\u00f8\u00f9"+ + "\u0003\"\u0011\u0000\u00f9\u00fa\u0005\u0018\u0000\u0000\u00fa\u00fc\u0001"+ + "\u0000\u0000\u0000\u00fb\u00f3\u0001\u0000\u0000\u0000\u00fb\u00f4\u0001"+ + "\u0000\u0000\u0000\u00fb\u00f5\u0001\u0000\u0000\u0000\u00fb\u00f6\u0001"+ + "\u0000\u0000\u0000\u00fb\u00f7\u0001\u0000\u0000\u0000\u00fc\'\u0001\u0000"+ + "\u0000\u0000\u00fd\u00fe\u0003\u0010\b\u0000\u00fe\u00ff\u0003*\u0015"+ + "\u0000\u00ff\u0100\u0003\u000e\u0007\u0000\u0100)\u0001\u0000\u0000\u0000"+ + "\u0101\u0102\u0007\u0000\u0000\u0000\u0102+\u0001\u0000\u0000\u0000\u0103"+ + "\u0107\u0003>\u001f\u0000\u0104\u0107\u0003@ \u0000\u0105\u0107\u0003"+ + "\u0016\u000b\u0000\u0106\u0103\u0001\u0000\u0000\u0000\u0106\u0104\u0001"+ + "\u0000\u0000\u0000\u0106\u0105\u0001\u0000\u0000\u0000\u0107-\u0001\u0000"+ + "\u0000\u0000\u0108\u0109\u00030\u0018\u0000\u0109\u010a\u0005\u001b\u0000"+ + "\u0000\u010a\u0115\u0001\u0000\u0000\u0000\u010b\u010c\u00032\u0019\u0000"+ + "\u010c\u010d\u0005\u001b\u0000\u0000\u010d\u0115\u0001\u0000\u0000\u0000"+ + "\u010e\u0115\u00034\u001a\u0000\u010f\u0115\u00036\u001b\u0000\u0110\u0115"+ + "\u00038\u001c\u0000\u0111\u0112\u0003,\u0016\u0000\u0112\u0113\u0005\u001b"+ + "\u0000\u0000\u0113\u0115\u0001\u0000\u0000\u0000\u0114\u0108\u0001\u0000"+ + "\u0000\u0000\u0114\u010b\u0001\u0000\u0000\u0000\u0114\u010e\u0001\u0000"+ + "\u0000\u0000\u0114\u010f\u0001\u0000\u0000\u0000\u0114\u0110\u0001\u0000"+ + "\u0000\u0000\u0114\u0111\u0001\u0000\u0000\u0000\u0115/\u0001\u0000\u0000"+ + "\u0000\u0116\u0118\u0005\"\u0000\u0000\u0117\u0119\u0003\u000e\u0007\u0000"+ + "\u0118\u0117\u0001\u0000\u0000\u0000\u0118\u0119\u0001\u0000\u0000\u0000"+ + "\u01191\u0001\u0000\u0000\u0000\u011a\u011b\u0003B!\u0000\u011b\u011e"+ + "\u0005$\u0000\u0000\u011c\u011d\u0005\u0007\u0000\u0000\u011d\u011f\u0003"+ + "\u000e\u0007\u0000\u011e\u011c\u0001\u0000\u0000\u0000\u011e\u011f\u0001"+ + "\u0000\u0000\u0000\u011f3\u0001\u0000\u0000\u0000\u0120\u0124\u0005\u0019"+ + "\u0000\u0000\u0121\u0123\u0003.\u0017\u0000\u0122\u0121\u0001\u0000\u0000"+ + "\u0000\u0123\u0126\u0001\u0000\u0000\u0000\u0124\u0122\u0001\u0000\u0000"+ + "\u0000\u0124\u0125\u0001\u0000\u0000\u0000\u0125\u0127\u0001\u0000\u0000"+ + "\u0000\u0126\u0124\u0001\u0000\u0000\u0000\u0127\u0128\u0005\u001a\u0000"+ + "\u0000\u01285\u0001\u0000\u0000\u0000\u0129\u012a\u0005\u001f\u0000\u0000"+ + "\u012a\u012b\u0005\u0017\u0000\u0000\u012b\u012c\u0003\u000e\u0007\u0000"+ + "\u012c\u012d\u0005\u0018\u0000\u0000\u012d\u012e\u0003.\u0017\u0000\u012e"+ + "7\u0001\u0000\u0000\u0000\u012f\u0131\u0003:\u001d\u0000\u0130\u0132\u0003"+ + "<\u001e\u0000\u0131\u0130\u0001\u0000\u0000\u0000\u0131\u0132\u0001\u0000"+ + "\u0000\u0000\u01329\u0001\u0000\u0000\u0000\u0133\u0134\u0005 \u0000\u0000"+ + "\u0134\u0135\u0005\u0017\u0000\u0000\u0135\u0136\u0003\u000e\u0007\u0000"+ + "\u0136\u0137\u0005\u0018\u0000\u0000\u0137\u0138\u0003.\u0017\u0000\u0138"+ + ";\u0001\u0000\u0000\u0000\u0139\u013a\u0005!\u0000\u0000\u013a\u013b\u0003"+ + ".\u0017\u0000\u013b=\u0001\u0000\u0000\u0000\u013c\u013d\u0003\u0012\t"+ + "\u0000\u013d\u013e\u0005\u0007\u0000\u0000\u013e\u013f\u0003\u000e\u0007"+ + "\u0000\u013f?\u0001\u0000\u0000\u0000\u0140\u0141\u0005#\u0000\u0000\u0141"+ + "\u0142\u0005$\u0000\u0000\u0142\u0143\u0005\u0017\u0000\u0000\u0143\u0144"+ + "\u0003\u0018\f\u0000\u0144\u0145\u0005\u0018\u0000\u0000\u0145A\u0001"+ + "\u0000\u0000\u0000\u0146\u0147\u0007\u0001\u0000\u0000\u0147C\u0001\u0000"+ + "\u0000\u0000\u0148\u0149\u0007\u0002\u0000\u0000\u0149E\u0001\u0000\u0000"+ + "\u0000\"ILTV[`ekotz\u0085\u008d\u0096\u009a\u009d\u00a2\u00a8\u00ad\u00b6"+ + "\u00bd\u00bf\u00c4\u00cc\u00db\u00e5\u00f0\u00fb\u0106\u0114\u0118\u011e"+ + "\u0124\u0131"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/gen/DecafVisitor.java b/src/main/java/gen/DecafVisitor.java new file mode 100644 index 0000000..e9a524c --- /dev/null +++ b/src/main/java/gen/DecafVisitor.java @@ -0,0 +1,222 @@ +package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link DecafParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface DecafVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitProgram(DecafParser.ProgramContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#classdecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitClassdecl(DecafParser.ClassdeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#constuctorDecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#methodDecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMethodDecl(DecafParser.MethodDeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#fieldDecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFieldDecl(DecafParser.FieldDeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#parameterList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameterList(DecafParser.ParameterListContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#parameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameter(DecafParser.ParameterContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(DecafParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#subExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSubExpression(DecafParser.SubExpressionContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#assignableExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssignableExpr(DecafParser.AssignableExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#instVar}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInstVar(DecafParser.InstVarContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#methodCall}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMethodCall(DecafParser.MethodCallContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#argumentList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArgumentList(DecafParser.ArgumentListContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#subReceiver}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSubReceiver(DecafParser.SubReceiverContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#receiver}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReceiver(DecafParser.ReceiverContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#receivingMethod}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReceivingMethod(DecafParser.ReceivingMethodContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#binaryExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryExpr(DecafParser.BinaryExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#calcExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCalcExpr(DecafParser.CalcExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#dotExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotExpr(DecafParser.DotExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#dotSubExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotSubExpr(DecafParser.DotSubExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#nonCalcExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalcExpr(DecafParser.NonCalcExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#nonCalcOperator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#stmtExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStmtExpr(DecafParser.StmtExprContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(DecafParser.StatementContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#returnStmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturnStmt(DecafParser.ReturnStmtContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#localVarDecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(DecafParser.BlockContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#whileStmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhileStmt(DecafParser.WhileStmtContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#ifElseStmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfElseStmt(DecafParser.IfElseStmtContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#ifStmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfStmt(DecafParser.IfStmtContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#elseStmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitElseStmt(DecafParser.ElseStmtContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#assign}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(DecafParser.AssignContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#newDecl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNewDecl(DecafParser.NewDeclContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitType(DecafParser.TypeContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#value}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValue(DecafParser.ValueContext ctx); +} \ No newline at end of file From 0576bd303d9a0a065d22ab99b1f23ae2b78f8b79 Mon Sep 17 00:00:00 2001 From: Jochen Seyfried Date: Thu, 9 May 2024 15:41:52 +0200 Subject: [PATCH 2/5] Pom and gitignore --- .idea/.gitignore | 2 ++ pom.xml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 pom.xml diff --git a/.idea/.gitignore b/.idea/.gitignore index 26d3352..ebde8d0 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,5 @@ # Default ignored files /shelf/ /workspace.xml + +.idea/ \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5aea1ca --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + Clippit.org + NichtHaskell + 1 + + + 20 + 20 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.0 + test + + + junit + junit + 4.13.1 + compile + + + + + \ No newline at end of file From cf590b22485021295c3ea5e0ae1a8a5ec6aaf337 Mon Sep 17 00:00:00 2001 From: Jochen Seyfried Date: Thu, 9 May 2024 15:56:23 +0200 Subject: [PATCH 3/5] Added dependencies to pom --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 5aea1ca..bdd7dcd 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,16 @@ 4.13.1 compile + + org.ow2.asm + asm + 9.7 + + + org.antlr + antlr4-runtime + 4.13.1 + From 1cd4d87a94964152fcd45c60b80fcd3b45374e98 Mon Sep 17 00:00:00 2001 From: Jochen Seyfried Date: Thu, 9 May 2024 15:58:48 +0200 Subject: [PATCH 4/5] Deleted old Source --- .idea/compiler.xml | 13 + .idea/jarRepositories.xml | 20 + .idea/libraries/asm_9_7.xml | 9 - .idea/misc.xml | 10 +- NichtHaskell.iml | 8 +- Source/.idea/.gitignore | 8 - Source/.idea/Source.iml | 12 - Source/.idea/libraries/asm_9_7.xml | 10 - Source/.idea/misc.xml | 6 - Source/.idea/modules.xml | 8 - Source/.idea/uiDesigner.xml | 124 - Source/.idea/vcs.xml | 6 - Source/Compiler.java | 64 - Source/Decaf.g4 | 128 - Source/EmptyClass.java | 2 - Source/TypeCheck/AbstractType.java | 15 - Source/TypeCheck/TypeCheckHelper.java | 32 - Source/TypeCheck/TypeCheckResult.java | 5 - .../abstractSyntaxTree/Class/FieldDecl.java | 46 - Source/abstractSyntaxTree/Class/IClass.java | 16 - .../abstractSyntaxTree/Class/MethodDecl.java | 33 - Source/abstractSyntaxTree/Class/RefType.java | 76 - .../Datatype/BoolDatatype.java | 27 - .../Datatype/CharDatatype.java | 27 - .../Datatype/IDatatype.java | 15 - .../Datatype/IntDatatype.java | 34 - .../Expression/BinaryExpression.java | 170 - .../Expression/IExpression.java | 12 - .../Expression/InstVarExpression.java | 32 - .../Expression/UnaryExpression.java | 65 - .../Expression/VarRefExpression.java | 23 - Source/abstractSyntaxTree/Program.java | 95 - .../Statement/BlockStatement.java | 49 - .../Statement/EmptyStatement.java | 19 - .../Statement/IStatement.java | 13 - .../Statement/IfElseStatement.java | 58 - .../Statement/IfStatement.java | 49 - .../Statement/ReturnStatement.java | 51 - .../Statement/WhileStatement.java | 50 - .../AssignStatementExpression.java | 50 - .../MethodCallStatementExpression.java | 64 - .../NewStatementExpression.java | 19 - .../SuperStatementExpression.java | 10 - Source/gen/Decaf.interp | 136 - Source/gen/Decaf.tokens | 81 - Source/gen/DecafBaseListener.java | 459 --- Source/gen/DecafBaseVisitor.java | 259 -- Source/gen/DecafLexer.interp | 155 - Source/gen/DecafLexer.java | 338 -- Source/gen/DecafLexer.tokens | 81 - Source/gen/DecafListener.java | 359 --- Source/gen/DecafParser.java | 2864 ----------------- Source/gen/DecafVisitor.java | 222 -- 53 files changed, 44 insertions(+), 6493 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/libraries/asm_9_7.xml delete mode 100644 Source/.idea/.gitignore delete mode 100644 Source/.idea/Source.iml delete mode 100644 Source/.idea/libraries/asm_9_7.xml delete mode 100644 Source/.idea/misc.xml delete mode 100644 Source/.idea/modules.xml delete mode 100644 Source/.idea/uiDesigner.xml delete mode 100644 Source/.idea/vcs.xml delete mode 100644 Source/Compiler.java delete mode 100644 Source/Decaf.g4 delete mode 100644 Source/EmptyClass.java delete mode 100644 Source/TypeCheck/AbstractType.java delete mode 100644 Source/TypeCheck/TypeCheckHelper.java delete mode 100644 Source/TypeCheck/TypeCheckResult.java delete mode 100644 Source/abstractSyntaxTree/Class/FieldDecl.java delete mode 100644 Source/abstractSyntaxTree/Class/IClass.java delete mode 100644 Source/abstractSyntaxTree/Class/MethodDecl.java delete mode 100644 Source/abstractSyntaxTree/Class/RefType.java delete mode 100644 Source/abstractSyntaxTree/Datatype/BoolDatatype.java delete mode 100644 Source/abstractSyntaxTree/Datatype/CharDatatype.java delete mode 100644 Source/abstractSyntaxTree/Datatype/IDatatype.java delete mode 100644 Source/abstractSyntaxTree/Datatype/IntDatatype.java delete mode 100644 Source/abstractSyntaxTree/Expression/BinaryExpression.java delete mode 100644 Source/abstractSyntaxTree/Expression/IExpression.java delete mode 100644 Source/abstractSyntaxTree/Expression/InstVarExpression.java delete mode 100644 Source/abstractSyntaxTree/Expression/UnaryExpression.java delete mode 100644 Source/abstractSyntaxTree/Expression/VarRefExpression.java delete mode 100644 Source/abstractSyntaxTree/Program.java delete mode 100644 Source/abstractSyntaxTree/Statement/BlockStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/EmptyStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/IStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/IfElseStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/IfStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/ReturnStatement.java delete mode 100644 Source/abstractSyntaxTree/Statement/WhileStatement.java delete mode 100644 Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java delete mode 100644 Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java delete mode 100644 Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java delete mode 100644 Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java delete mode 100644 Source/gen/Decaf.interp delete mode 100644 Source/gen/Decaf.tokens delete mode 100644 Source/gen/DecafBaseListener.java delete mode 100644 Source/gen/DecafBaseVisitor.java delete mode 100644 Source/gen/DecafLexer.interp delete mode 100644 Source/gen/DecafLexer.java delete mode 100644 Source/gen/DecafLexer.tokens delete mode 100644 Source/gen/DecafListener.java delete mode 100644 Source/gen/DecafParser.java delete mode 100644 Source/gen/DecafVisitor.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..8643296 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/asm_9_7.xml b/.idea/libraries/asm_9_7.xml deleted file mode 100644 index d5564c6..0000000 --- a/.idea/libraries/asm_9_7.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..0e338d8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,14 @@ - + + + + + \ No newline at end of file diff --git a/NichtHaskell.iml b/NichtHaskell.iml index d55d4c8..b18ce81 100644 --- a/NichtHaskell.iml +++ b/NichtHaskell.iml @@ -1,12 +1,8 @@ - - - + + - - - \ No newline at end of file diff --git a/Source/.idea/.gitignore b/Source/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/Source/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/Source/.idea/Source.iml b/Source/.idea/Source.iml deleted file mode 100644 index f9bd605..0000000 --- a/Source/.idea/Source.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/libraries/asm_9_7.xml b/Source/.idea/libraries/asm_9_7.xml deleted file mode 100644 index 2233f59..0000000 --- a/Source/.idea/libraries/asm_9_7.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/misc.xml b/Source/.idea/misc.xml deleted file mode 100644 index ceb7609..0000000 --- a/Source/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Source/.idea/modules.xml b/Source/.idea/modules.xml deleted file mode 100644 index 6044bc3..0000000 --- a/Source/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/uiDesigner.xml b/Source/.idea/uiDesigner.xml deleted file mode 100644 index 2b63946..0000000 --- a/Source/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/vcs.xml b/Source/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/Source/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Source/Compiler.java b/Source/Compiler.java deleted file mode 100644 index d993d97..0000000 --- a/Source/Compiler.java +++ /dev/null @@ -1,64 +0,0 @@ -import abstractSyntaxTree.Class.FieldDecl; -import abstractSyntaxTree.Class.MethodDecl; -import abstractSyntaxTree.Class.RefType; -import abstractSyntaxTree.Program; -import gen.DecafLexer; -import gen.DecafParser; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.tree.ParseTree; - -import java.io.CharArrayReader; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -public class Compiler { - - public static void main(String[] args) throws Exception{ - - // get file -// String filePath = "EmptyClass.java"; -// String content = new String(Files.readAllBytes(Paths.get(filePath))); -// CharArrayReader charStream = new CharArrayReader(content.toCharArray()); - - CharStream codeCharStream = CharStreams.fromString("class Example { }"); - DecafLexer lexer = new DecafLexer(codeCharStream); - CommonTokenStream tokens = new CommonTokenStream(lexer); - - System.out.println("--- print tokens ---"); - tokens.fill(); - - List tokenList = tokens.getTokens(); - - StringBuilder stringBuilder = new StringBuilder(); - for (Token token : tokenList) { - stringBuilder.append(token.toString()).append(" "); - } - String readableTokens = stringBuilder.toString().trim(); - - System.out.println(readableTokens); - - - DecafParser parser = new DecafParser(tokens); - - ParseTree tree = parser.program(); - - System.out.println("--- print tree ---"); - System.out.println(tree); - - - - Program abstractSyntaxTree = new Program(new ArrayList<>()); - List emptyFieldDecl = new ArrayList<>(); - List emptyMethodDecl = new ArrayList<>(); - abstractSyntaxTree.classes.add(new RefType(emptyFieldDecl, emptyMethodDecl, null, null, "MyClass")); - - abstractSyntaxTree.typeCheck(); - - abstractSyntaxTree.codeGen(); - } -} diff --git a/Source/Decaf.g4 b/Source/Decaf.g4 deleted file mode 100644 index 2af8297..0000000 --- a/Source/Decaf.g4 +++ /dev/null @@ -1,128 +0,0 @@ -grammar Decaf; - -program: classdecl+; - -//class identifier{...} -classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; -constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method without - -//Method and FieldVar -methodDecl: AccessModifierPublic? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; -fieldDecl: AccessModifierPublic? type Identifier Semicolon; - -//Parameters -parameterList: parameter(Comma parameter)*; -parameter: type Identifier; - -//property, object.a, 3+1, a = 3 -expression: subExpression | binaryExpr; -//subExpression to dissolve left-recusion -subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression ClosedRoundBracket; -assignableExpr: Identifier | instVar; -instVar: subReceiver? receivingMethod* Identifier; - -//.trim().toLength().toLowerCase().count ... -methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; -argumentList: expression? | expression (Comma expression)+; - -subReceiver: ((This | newDecl | Identifier) Dot); -receiver: ((This | instVar | newDecl | Identifier) Dot); -receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; - - -binaryExpr: calcExpr | nonCalcExpr| value | Not binaryExpr; - -calcExpr: calcExpr LineOperator dotExpr | dotExpr; -dotExpr: dotExpr DotOperator dotSubExpr | dotSubExpr; -dotSubExpr: IntValue | Identifier | instVar | methodCall | OpenRoundBracket calcExpr ClosedRoundBracket; -nonCalcExpr: subExpression nonCalcOperator expression; -nonCalcOperator: LogicalOpertor | ComparisonOperator; - -//Statement but also expression -//a = expr, new Object(), method(param1) -stmtExpr: assign | newDecl | methodCall; - -//Statements -//int a, {...}, while(a > 10){...}, if(...){...} else if{...} else{...} -statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; -returnStmt: Return (expression)?; -localVarDecl: type Identifier (Assign expression)?; -block: OpenCurlyBracket statement* ClosedCurlyBracket; -whileStmt: While OpenRoundBracket expression ClosedRoundBracket statement; -ifElseStmt: ifStmt elseStmt?; -ifStmt: If OpenRoundBracket expression ClosedRoundBracket statement; -elseStmt: Else statement; -assign: assignableExpr Assign expression; -newDecl: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; - - -type: Int | Boolean | Char | Identifier; -value: IntValue | BooleanValue | CharValue | NullValue; - -//Access modifier -AccessModifierPublic : 'public' ; -MainMethodDecl : 'public static void main(String[] args)'; - - - -//Operators -DotOperator : Multipilkation | Division | Modulo; -LineOperator : Plus | Minus; -ComparisonOperator : Greater | Less | GreaterEqual | LessEqual | Equal | NotEqual; -LogicalOpertor : And | Or; - -Assign : '='; -Minus : '-'; -Plus : '+'; -Multipilkation : '*'; -Division : '/'; -Modulo : '%'; -Greater : '>'; -Less : '<'; -GreaterEqual : '>='; -LessEqual : '<='; -Equal : '=='; -NotEqual : '!='; -Not : '!'; -And : '&&'; -Or : '||'; - -//Symbols -Dot : '.'; -OpenRoundBracket : '('; -ClosedRoundBracket : ')'; -OpenCurlyBracket : '{'; -ClosedCurlyBracket : '}'; -Semicolon : ';'; -Comma : ','; - -//Keywords -Class : 'class'; -This : 'this'; -While : 'while'; -If : 'if'; -Else : 'else'; -Return : 'return'; -New : 'new'; - -//Identifier -fragment Alpabetic : [a-zA-Z]; -fragment Numeric: [0-9]; -fragment ValidIdentSymbols : Alpabetic|Numeric|'$'|'_'; -Identifier: Alpabetic ValidIdentSymbols*; - -//Types -Void : 'void'; -Int : 'int'; -Boolean : 'bool'; -Char : 'char'; - -//Values -IntValue : ('+'|'-')*[0-9]+; -CharValue: '\''~[\r\n]?'\''; -BooleanValue: 'true'|'false'; -NullValue: 'null'; - -//Whitespace? Right into the trash it gooeesss -WS : [ \t\r\n] -> skip; - diff --git a/Source/EmptyClass.java b/Source/EmptyClass.java deleted file mode 100644 index a3496cf..0000000 --- a/Source/EmptyClass.java +++ /dev/null @@ -1,2 +0,0 @@ -class EmptyClass { -} diff --git a/Source/TypeCheck/AbstractType.java b/Source/TypeCheck/AbstractType.java deleted file mode 100644 index ea2fd30..0000000 --- a/Source/TypeCheck/AbstractType.java +++ /dev/null @@ -1,15 +0,0 @@ -package TypeCheck; - -import TypeCheck.TypeCheckResult; - -public abstract class AbstractType { - TypeCheckResult typeCheckResult; - - public void setTypeCheckResult(TypeCheckResult typeCheckResult) { - this.typeCheckResult = typeCheckResult; - } - - public TypeCheckResult getTypeCheckResult() { - return typeCheckResult; - } -} \ No newline at end of file diff --git a/Source/TypeCheck/TypeCheckHelper.java b/Source/TypeCheck/TypeCheckHelper.java deleted file mode 100644 index bd4aa58..0000000 --- a/Source/TypeCheck/TypeCheckHelper.java +++ /dev/null @@ -1,32 +0,0 @@ -package TypeCheck; - -import java.util.List; -import java.util.Objects; - -public class TypeCheckHelper { - public String upperBound(String type1, String type2) throws Exception{ - boolean type1Primitiv = Objects.equals(type1, "bool") || Objects.equals(type1, "int") || Objects.equals(type1, "char"); - boolean type2Primitiv = Objects.equals(type2, "bool") || Objects.equals(type2, "int") || Objects.equals(type2, "char"); - - String result; - if(type1Primitiv && type2Primitiv){ - if(Objects.equals(type1, type2)){ - result = type1; - } - throw new Exception("no upper bound"); - }else if(type1Primitiv || type2Primitiv){ - throw new Exception("no upper bound"); - }else{ - result = "class"; - } - return result; - } - public static boolean typeExists(String type, List typeslist) { - - if(type.equals("int") || type.equals("bool") || type.equals("char")){ - return true; - } - return typeslist.contains(type); - } - -} diff --git a/Source/TypeCheck/TypeCheckResult.java b/Source/TypeCheck/TypeCheckResult.java deleted file mode 100644 index 6382b99..0000000 --- a/Source/TypeCheck/TypeCheckResult.java +++ /dev/null @@ -1,5 +0,0 @@ -package TypeCheck; - -public class TypeCheckResult { - public String type; -} diff --git a/Source/abstractSyntaxTree/Class/FieldDecl.java b/Source/abstractSyntaxTree/Class/FieldDecl.java deleted file mode 100644 index a02fb36..0000000 --- a/Source/abstractSyntaxTree/Class/FieldDecl.java +++ /dev/null @@ -1,46 +0,0 @@ -package abstractSyntaxTree.Class; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckHelper; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Program; -import org.objectweb.asm.ClassWriter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class FieldDecl extends AbstractType implements IClass{ - - private HashMap> typeContext; // form class from program - public String type; // from parser - public String identifier; // from parser - - public FieldDecl(HashMap> typeContext){ - this.typeContext = typeContext; - } - public TypeCheckResult typeCheck(List classFieldsIdentifier) throws Exception { - TypeCheckResult result = new TypeCheckResult(); - if (classFieldsIdentifier.contains(this.identifier)){ - throw new Exception("field already defined"); - } else { - classFieldsIdentifier.add(this); - } - //TypeCheckHelper.typeExists(type, ) // need all types of classes - setTypeCheckResult(result); - - return result; - - //write field table - } - - @Override - public TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception { - return null; - } - - @Override - public void codeGen(ClassWriter cw) { - - } -} diff --git a/Source/abstractSyntaxTree/Class/IClass.java b/Source/abstractSyntaxTree/Class/IClass.java deleted file mode 100644 index cfd14e3..0000000 --- a/Source/abstractSyntaxTree/Class/IClass.java +++ /dev/null @@ -1,16 +0,0 @@ -package abstractSyntaxTree.Class; - -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.TypeReference; - -import java.util.HashMap; -import java.util.List; - -public interface IClass { - // visit method for code generation - - TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception; - void codeGen(ClassWriter cw) throws Exception; - -} diff --git a/Source/abstractSyntaxTree/Class/MethodDecl.java b/Source/abstractSyntaxTree/Class/MethodDecl.java deleted file mode 100644 index 6e12a51..0000000 --- a/Source/abstractSyntaxTree/Class/MethodDecl.java +++ /dev/null @@ -1,33 +0,0 @@ -package abstractSyntaxTree.Class; - -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Program; -import org.objectweb.asm.ClassWriter; - -import java.util.HashMap; -import java.util.List; - -public class MethodDecl implements IClass { - - public String classThatContainsMethod; - public String name; - public List parameters; - public String returnType; - - - //TODO: Move this into the typeCheck - private HashMap localVars; // (type, identifier) // add content here - - public TypeCheckResult typeCheck(HashMap>>> methodContext, HashMap> typeContext, List fieldsOrMethods) throws Exception { - // write localvars - - - // jede methode als block statement aufrufen - return null; - } - - @Override - public void codeGen(ClassWriter cw) throws Exception { - - } -} diff --git a/Source/abstractSyntaxTree/Class/RefType.java b/Source/abstractSyntaxTree/Class/RefType.java deleted file mode 100644 index 3018ec7..0000000 --- a/Source/abstractSyntaxTree/Class/RefType.java +++ /dev/null @@ -1,76 +0,0 @@ -package abstractSyntaxTree.Class; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Class.FieldDecl; -import abstractSyntaxTree.Class.MethodDecl; -import abstractSyntaxTree.Datatype.IDatatype; -import abstractSyntaxTree.Program; -import jdk.jshell.spi.ExecutionControl; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -import java.util.HashMap; -import java.util.List; - -public class RefType extends AbstractType implements IClass { - - public String name; - public List fieldDecls; - public List methodDecls; - private HashMap> typeContext; // (class, (type, identifier)) - public HashMap>>> methodContext; // (class, (returntype, (identifier, parameter))) - private boolean hasMain; - - public RefType(List fieldDecls, - List methodDecls, - HashMap> typeContext, - HashMap>>> methodContext, String name){ - this.name = name; - this.fieldDecls = fieldDecls; - this.methodDecls = methodDecls; - this.typeContext = typeContext; - this.methodContext = methodContext; - } - - - - @Override - public TypeCheckResult typeCheck(HashMap>>> methodContext, - HashMap> typeContext, List fieldsOrMethods) throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - for (FieldDecl fieldDecl : fieldDecls) { - fieldDecl.typeCheck(fieldDecls); - } - - for (MethodDecl methodDecl : methodDecls) { - methodDecl.typeCheck(methodContext, typeContext, methodDecls); - } - - result.type = "class"; - setTypeCheckResult(result); - return result; - } - - // Method for code generation which iterates over all the field declarations - // and method declarations and calls their CodeGen methods - @Override - public void codeGen(ClassWriter cw) throws Exception { - - cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, - "java/lang/Object", null); - - for (FieldDecl field : fieldDecls) { - field.codeGen(cw); - } - - for (MethodDecl method : methodDecls) { - method.codeGen(cw); - } - cw.visitEnd(); - } - - -} diff --git a/Source/abstractSyntaxTree/Datatype/BoolDatatype.java b/Source/abstractSyntaxTree/Datatype/BoolDatatype.java deleted file mode 100644 index 6b8ccf0..0000000 --- a/Source/abstractSyntaxTree/Datatype/BoolDatatype.java +++ /dev/null @@ -1,27 +0,0 @@ -package abstractSyntaxTree.Datatype; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.*; - -public class BoolDatatype extends AbstractType implements IDatatype{ - boolean value; - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - result.type = "bool"; - - setTypeCheckResult(result); - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - if(value) { - mv.visitInsn(Opcodes.ICONST_1); // Pushes the int 1 on the stack (true) - } else { - mv.visitInsn(Opcodes.ICONST_0); // 0 for false - } - } -} diff --git a/Source/abstractSyntaxTree/Datatype/CharDatatype.java b/Source/abstractSyntaxTree/Datatype/CharDatatype.java deleted file mode 100644 index 1346f0d..0000000 --- a/Source/abstractSyntaxTree/Datatype/CharDatatype.java +++ /dev/null @@ -1,27 +0,0 @@ -package abstractSyntaxTree.Datatype; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; - -public class CharDatatype extends AbstractType implements IDatatype{ - char value; - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - result.type = "char"; - - setTypeCheckResult(result); - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - // Possible use of BIPUSH and SIPUSH if the value is small enough - //This saves space in the bytecode which is not very relevant at this point, but could be implemented anyway - - mv.visitLdcInsn((int)value); - } -} diff --git a/Source/abstractSyntaxTree/Datatype/IDatatype.java b/Source/abstractSyntaxTree/Datatype/IDatatype.java deleted file mode 100644 index d729f96..0000000 --- a/Source/abstractSyntaxTree/Datatype/IDatatype.java +++ /dev/null @@ -1,15 +0,0 @@ -package abstractSyntaxTree.Datatype; - -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; - -public interface IDatatype { - // typeCheck method - TypeCheckResult typeCheck() throws Exception; - - // visit method for code generation - - void codeGen(MethodVisitor mv) throws Exception; -} - -//TODO: Check if we need to differentiate between primitive types and reference types --> for example in "==" \ No newline at end of file diff --git a/Source/abstractSyntaxTree/Datatype/IntDatatype.java b/Source/abstractSyntaxTree/Datatype/IntDatatype.java deleted file mode 100644 index 4733931..0000000 --- a/Source/abstractSyntaxTree/Datatype/IntDatatype.java +++ /dev/null @@ -1,34 +0,0 @@ -package abstractSyntaxTree.Datatype; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -public class IntDatatype extends AbstractType implements IDatatype{ - int value; - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - result.type = "int"; - - setTypeCheckResult(result); - return result; - } - - // visit method for code generation - - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - //Example of using BIPUSH and SIPUSH for optimizing bytecode size - if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) - mv.visitIntInsn(Opcodes.BIPUSH, value); - else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) - mv.visitIntInsn(Opcodes.SIPUSH, value); - else - mv.visitLdcInsn(value); - } -} diff --git a/Source/abstractSyntaxTree/Expression/BinaryExpression.java b/Source/abstractSyntaxTree/Expression/BinaryExpression.java deleted file mode 100644 index 72af1be..0000000 --- a/Source/abstractSyntaxTree/Expression/BinaryExpression.java +++ /dev/null @@ -1,170 +0,0 @@ -package abstractSyntaxTree.Expression; - -import TypeCheck.TypeCheckResult; -import TypeCheck.TypeCheckHelper; -import TypeCheck.AbstractType; -import org.objectweb.asm.*; - -import java.beans.Expression; -import java.util.Objects; - -public class BinaryExpression extends AbstractType implements IExpression{ - - public String operator; - public IExpression left; - public IExpression right; - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckHelper helper = new TypeCheckHelper(); - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult leftType = left.typeCheck(); - TypeCheckResult rightType = right.typeCheck(); - - switch (operator) { - - case "&&": - case "||" :{ - if (Objects.equals(helper.upperBound(leftType.type, rightType.type), "bool")){ - result.type = "bool"; - } - break; - } - case "==": - case "<": - case ">": - case "<=": - case ">=": - case "!=": - result.type = helper.upperBound(leftType.type, rightType.type); - break; - - case "-": - case "+": - case "*": - case "/": - if (Objects.equals(helper.upperBound(leftType.type, rightType.type), "int")){ - result.type = "int"; - } - break; - - //case "&" ist für logisches und auf bit level - //case "|" ist für logisches oder auf bit level - } - - setTypeCheckResult(result); - return result; - } - - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - // Label for the jump instruction - Label operationFalse = new Label(); //Operation is false - Label operationTrue = new Label(); //Operation is true - // Labels are placed at the end of this method - Label expressionEnd = new Label(); //End of the whole expression - - // Bytecode for the binary operation - switch (operator) { - case "&&": - left.codeGen(mv); - mv.visitJumpInsn(Opcodes.IFEQ, operationFalse); // IFEQ --> "if equals to zero" (false) --> if left exp is false - - right.codeGen(mv); - mv.visitJumpInsn(Opcodes.IFEQ, operationFalse); // If right exp is false, jump to the end of the whole expression - - mv.visitJumpInsn(Opcodes.GOTO, operationTrue); // If it reaches this point, the right exp is true - break; - - case "||": - left.codeGen(mv); - mv.visitJumpInsn(Opcodes.IFNE, operationTrue); // IFNE --> "if not equals to zero" (true) --> if left exp is true - - right.codeGen(mv); - mv.visitJumpInsn(Opcodes.IFNE, operationTrue); - break; - - case "==": - // Keep in mind that only primitive types are allowed in this case (at this time) - - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPEQ, operationTrue); // If the two values are equal, jump to the end of the expression - break; - - case "<": - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPLT, operationTrue); // Checks only on less than, not equal - break; - - case ">": - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPGT, operationTrue); // Checks only on greater than, not equal - break; - - case "<=": - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPLE, operationTrue); // Checks on less than OR equal - break; - - case ">=": - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPGE, operationTrue); // Checks on greater than OR equal - break; - - case "!=": - left.codeGen(mv); - right.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IF_ICMPNE, operationTrue); // Checks on not equal - break; - - case "+": - left.codeGen(mv); - right.codeGen(mv); - mv.visitInsn(Opcodes.IADD); - break; - - case "-": - left.codeGen(mv); - right.codeGen(mv); - mv.visitInsn(Opcodes.ISUB); - break; - - case "*": - left.codeGen(mv); - right.codeGen(mv); - mv.visitInsn(Opcodes.IMUL); - break; - - case "/": - left.codeGen(mv); - right.codeGen(mv); - mv.visitInsn(Opcodes.IDIV); - break; - - default: - throw new Exception("Unknown operator: " + operator); - } - - mv.visitLabel(operationFalse); - mv.visitInsn(Opcodes.ICONST_0); // Push false on the stack - mv.visitJumpInsn(Opcodes.GOTO, expressionEnd); // Jump to the end of the expression (skip the true push) - - mv.visitLabel(operationTrue); - mv.visitInsn(Opcodes.ICONST_1); // Push true on the stack - - mv.visitLabel(expressionEnd); - } -} diff --git a/Source/abstractSyntaxTree/Expression/IExpression.java b/Source/abstractSyntaxTree/Expression/IExpression.java deleted file mode 100644 index a679711..0000000 --- a/Source/abstractSyntaxTree/Expression/IExpression.java +++ /dev/null @@ -1,12 +0,0 @@ -package abstractSyntaxTree.Expression; - -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; - -public interface IExpression { - // typeCheck method - TypeCheckResult typeCheck() throws Exception; - - // visit method for code generation - void codeGen(MethodVisitor mv) throws Exception; -} diff --git a/Source/abstractSyntaxTree/Expression/InstVarExpression.java b/Source/abstractSyntaxTree/Expression/InstVarExpression.java deleted file mode 100644 index f7d58e3..0000000 --- a/Source/abstractSyntaxTree/Expression/InstVarExpression.java +++ /dev/null @@ -1,32 +0,0 @@ -package abstractSyntaxTree.Expression; - -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Class.RefType; -import jdk.jshell.spi.ExecutionControl; -import org.objectweb.asm.MethodVisitor; - -public class InstVarExpression implements IExpression{ - - //TODO: We have to decide upon more parameters and where they come from, for - // example here we need the index of the field, the class reference and the field name - private RefType classRef; - private String fieldName; - -/* public InstVarExpression(RefType classRef, String fieldName){ - this.classRef = classRef; - this.fieldName = fieldName; - }*/ - @Override - public TypeCheckResult typeCheck() throws Exception { - return null; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - throw new ExecutionControl.NotImplementedException("CodeGen not implemented for InstVarExpression"); - - //ALOAD the index of the var - //GETFIELD the field - //visitFieldInsn(Opcodes.GETFIELD, "class reference", "field name", type); - } -} diff --git a/Source/abstractSyntaxTree/Expression/UnaryExpression.java b/Source/abstractSyntaxTree/Expression/UnaryExpression.java deleted file mode 100644 index 4acdc53..0000000 --- a/Source/abstractSyntaxTree/Expression/UnaryExpression.java +++ /dev/null @@ -1,65 +0,0 @@ -package abstractSyntaxTree.Expression; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckHelper; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Datatype.IDatatype; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -import java.util.Objects; - -public class UnaryExpression extends AbstractType implements IExpression{ - public String operator; - public IDatatype operand; - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult operandTypeCheckResult = operand.typeCheck(); - String operandType = operandTypeCheckResult.type; - - switch (operator) { - - case "!" :{ - if (Objects.equals(operandType, "bool")){ - result.type = "bool"; - } - break; - } - - case "-": - case "+": - if (Objects.equals(operandType, "int")){ - result.type = "int"; - } - break; - - } - - setTypeCheckResult(result); - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - operand.codeGen(mv); - - switch (operator) { - case "!": - //XOR with 1 to get the negation - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IXOR); - break; - case "-": - mv.visitInsn(Opcodes.INEG); - break; - case "+": - break; - - default: throw new Exception("Unknown operator :" + operator); - } - - } -} diff --git a/Source/abstractSyntaxTree/Expression/VarRefExpression.java b/Source/abstractSyntaxTree/Expression/VarRefExpression.java deleted file mode 100644 index 9276930..0000000 --- a/Source/abstractSyntaxTree/Expression/VarRefExpression.java +++ /dev/null @@ -1,23 +0,0 @@ -package abstractSyntaxTree.Expression; - -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; - -import java.util.Map; - -public class VarRefExpression implements IExpression{ - - //Parameters that are needed here - private String varName; - private Map localVars; - - @Override - public TypeCheckResult typeCheck() throws Exception { - return null; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - throw new Exception("CodeGen not implemented for VarRefExpression"); - } -} diff --git a/Source/abstractSyntaxTree/Program.java b/Source/abstractSyntaxTree/Program.java deleted file mode 100644 index 659ad47..0000000 --- a/Source/abstractSyntaxTree/Program.java +++ /dev/null @@ -1,95 +0,0 @@ -package abstractSyntaxTree; - -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Class.FieldDecl; -import abstractSyntaxTree.Class.MethodDecl; -import org.objectweb.asm.MethodVisitor; -import abstractSyntaxTree.Class.RefType; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; - -import java.util.*; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; - -public class Program { - public List classes; - public HashMap> typeContext; // (class, (type, identifier)) - public HashMap>>> methodContext; // (class, (returntype, (identifier, parameter))) - - public Program(List classes){ - this.classes = classes; - this.typeContext = new HashMap<>(); - this.methodContext = new HashMap<>(); - } - - - public TypeCheckResult typeCheck() throws Exception{ - for(RefType oneClass : classes){ - HashMap classVars = new HashMap<>(); - for (FieldDecl fieldDecl: oneClass.fieldDecls){ - classVars.put(fieldDecl.type, fieldDecl.identifier); - } - typeContext.put(oneClass.name, classVars); - - HashMap> methodIdentifierAndParameter = new HashMap<>(); - HashMap>> returnTypeAndMethod = new HashMap<>(); - for (MethodDecl methodDecl : oneClass.methodDecls){ - methodIdentifierAndParameter.put(methodDecl.name, methodDecl.parameters); - returnTypeAndMethod.put(methodDecl.returnType, methodIdentifierAndParameter); - } - - methodContext.put(oneClass.name, returnTypeAndMethod); - - oneClass.typeCheck(methodContext, typeContext, oneClass.methodDecls); - } - return null; - } - - public void codeGen() throws Exception{ - try (JarOutputStream jos = new JarOutputStream(new FileOutputStream("output.jar"))) { - for (RefType oneClass : classes) { - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, oneClass.name, null, "java/lang/Object", null); - - oneClass.codeGen(cw); - - cw.visitEnd(); - byte[] bytecode = cw.toByteArray(); - - try (FileOutputStream fos = new FileOutputStream(oneClass.name + ".class")) { - fos.write(bytecode); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - - /*// Write the bytecode to a .class file in the .jar file - JarEntry entry = new JarEntry(oneClass.name + ".class"); - jos.putNextEntry(entry); - jos.write(bytecode); - jos.closeEntry(); - } - } catch (IOException e) { - e.printStackTrace(); - }*/ - - /* - for(RefType oneClass : classes){ - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC,oneClass.name, null, - "java/lang/Object", null); - oneClass.codeGen(cw); - - cw.visitEnd(); - byte[] bytecode = cw.toByteArray(); - } - */ - } -} diff --git a/Source/abstractSyntaxTree/Statement/BlockStatement.java b/Source/abstractSyntaxTree/Statement/BlockStatement.java deleted file mode 100644 index da8e26d..0000000 --- a/Source/abstractSyntaxTree/Statement/BlockStatement.java +++ /dev/null @@ -1,49 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import org.objectweb.asm.*; - -import java.util.HashMap; -import java.util.List; - -public class BlockStatement extends AbstractType implements IStatement{ - - //We will need a parameter which holds the symbol table - HashMap localVars; - HashMap typeIndentifierTable; // from program - List statements; - // do we need expression, statementexpression - - public BlockStatement(List statements, HashMap localVars, HashMap typeIndentifierTable){ - - this.statements = statements; - } - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - if(statements.size() == 0){ - result.type = "void"; - } - - TypeCheckResult blockType = null; - for (IStatement statement : statements) { - TypeCheckResult typeOfCurrentStatement = statement.typeCheck(); - - if (blockType == null) { - blockType = typeOfCurrentStatement; - } else if (!typeOfCurrentStatement.equals(blockType) && !blockType.equals("void")) { - throw new IllegalArgumentException("different statement types"); - } - } - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - for (IStatement statement : statements) { - statement.codeGen(mv); //TODO: I think we need to pass the symbol table here - } - } -} diff --git a/Source/abstractSyntaxTree/Statement/EmptyStatement.java b/Source/abstractSyntaxTree/Statement/EmptyStatement.java deleted file mode 100644 index 01818d7..0000000 --- a/Source/abstractSyntaxTree/Statement/EmptyStatement.java +++ /dev/null @@ -1,19 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import org.objectweb.asm.MethodVisitor; - -public class EmptyStatement extends AbstractType implements IStatement{ - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - result.type = "void"; - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - //An empty statement does not generate any code - } -} diff --git a/Source/abstractSyntaxTree/Statement/IStatement.java b/Source/abstractSyntaxTree/Statement/IStatement.java deleted file mode 100644 index d15e56b..0000000 --- a/Source/abstractSyntaxTree/Statement/IStatement.java +++ /dev/null @@ -1,13 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import org.objectweb.asm.MethodVisitor; - -public interface IStatement { - - - - TypeCheckResult typeCheck() throws Exception; - - void codeGen(MethodVisitor mv) throws Exception; -} diff --git a/Source/abstractSyntaxTree/Statement/IfElseStatement.java b/Source/abstractSyntaxTree/Statement/IfElseStatement.java deleted file mode 100644 index d8ac01e..0000000 --- a/Source/abstractSyntaxTree/Statement/IfElseStatement.java +++ /dev/null @@ -1,58 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import abstractSyntaxTree.Expression.IExpression; -import org.objectweb.asm.*; - -public class IfElseStatement extends AbstractType implements IStatement{ - IExpression condition; - IStatement ifStatement; - IStatement elseStatement; - - public IfElseStatement(IExpression condition, IStatement ifStatement, IStatement elseStatement) { - this.condition = condition; - this.ifStatement = ifStatement; - this.elseStatement = elseStatement; - } - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult conditionType = condition.typeCheck(); - - if (!conditionType.equals("bool")) { - throw new IllegalArgumentException("should be boolean"); - } - - TypeCheckResult ifStatementType = ifStatement.typeCheck(); - TypeCheckResult elseStatementType = elseStatement.typeCheck(); - - if (!ifStatementType.equals(elseStatementType)) { - throw new IllegalArgumentException("if and else have different types"); - } - - result.type = elseStatementType.type; - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - Label conditionFalse = new Label(); - Label statementEnd = new Label(); - - condition.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); //Checks if the condition is false (0) - ifStatement.codeGen(mv); //If the condition is true, execute the ifBlock - mv.visitJumpInsn(Opcodes.GOTO, statementEnd); //Jump to the end of the if-else statement - - mv.visitLabel(conditionFalse); - elseStatement.codeGen(mv); //If the condition is false, execute the elseBlock - - mv.visitLabel(statementEnd); //End of the if-else statement - - } -} diff --git a/Source/abstractSyntaxTree/Statement/IfStatement.java b/Source/abstractSyntaxTree/Statement/IfStatement.java deleted file mode 100644 index 1c8461c..0000000 --- a/Source/abstractSyntaxTree/Statement/IfStatement.java +++ /dev/null @@ -1,49 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import abstractSyntaxTree.Expression.IExpression; -import org.objectweb.asm.*; - -public class IfStatement extends AbstractType implements IStatement{ - IExpression condition; - - //Do we need a block statement here? - IStatement ifStatement; - - public IfStatement(IExpression condition, IStatement ifStatement) { - this.condition = condition; - this.ifStatement = ifStatement; - } - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult conditionType = condition.typeCheck(); - - if (!conditionType.equals("boolean")) { - throw new IllegalArgumentException("should be boolean"); - } - - TypeCheckResult ifStatementType = ifStatement.typeCheck(); - result.type = ifStatementType.type; - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - Label conditionFalse = new Label(); - - condition.codeGen(mv); - - mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); //Checks if the condition is false (0) - ifStatement.codeGen(mv); - - mv.visitLabel(conditionFalse); // If the condition is false, the Statements in the ifBlock will not be executed - } -} - - - - diff --git a/Source/abstractSyntaxTree/Statement/ReturnStatement.java b/Source/abstractSyntaxTree/Statement/ReturnStatement.java deleted file mode 100644 index 976de6e..0000000 --- a/Source/abstractSyntaxTree/Statement/ReturnStatement.java +++ /dev/null @@ -1,51 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import abstractSyntaxTree.Expression.IExpression; -import org.objectweb.asm.*; - -public class ReturnStatement extends AbstractType implements IStatement{ - IExpression expression; - - public ReturnStatement(IExpression expression) { - this.expression = expression; - } - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - if (expression == null) { - result.type = "void"; - } else { - TypeCheckResult typedExpression = expression.typeCheck(); - result.type = typedExpression.type; - } - - return result; - } - - - //TODO: We do not differentiate between primitive types and reference types - // This is a problem at "BinaryExpression" and here because we need to know the type to return - // At this point in time we can either return reference types or have an error message - @Override - public void codeGen(MethodVisitor mv) throws Exception { - - if (expression != null) { - expression.codeGen(mv); - //Get the Type of the expression - String type = expression.typeCheck().type; - - if (type.equals("int") || type.equals("bool") || type.equals("char")) { - mv.visitInsn(Opcodes.IRETURN); - } else { - mv.visitInsn(Opcodes.ARETURN); - - } - } else { - mv.visitInsn(Opcodes.RETURN); - } - } -} diff --git a/Source/abstractSyntaxTree/Statement/WhileStatement.java b/Source/abstractSyntaxTree/Statement/WhileStatement.java deleted file mode 100644 index e923fa1..0000000 --- a/Source/abstractSyntaxTree/Statement/WhileStatement.java +++ /dev/null @@ -1,50 +0,0 @@ -package abstractSyntaxTree.Statement; - -import TypeCheck.TypeCheckResult; -import TypeCheck.AbstractType; -import abstractSyntaxTree.Expression.IExpression; -import org.objectweb.asm.*; - -public class WhileStatement extends AbstractType implements IStatement { - IExpression condition; - IStatement statement; - - public WhileStatement(IExpression condition, IStatement statement) { - this.condition = condition; - this.statement = statement; - } - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult conditionType = condition.typeCheck(); - - if (!conditionType.equals("bool")) { - throw new IllegalArgumentException("Expected boolean"); - } - - TypeCheckResult statementType = statement.typeCheck(); - - result.type = statementType.type; - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - Label conditionFalse = new Label(); - Label LoopStart = new Label(); - - mv.visitLabel(LoopStart); - - condition.codeGen(mv); - mv.visitJumpInsn(Opcodes.IFEQ, conditionFalse); // Checks if the condition is false (0) - - statement.codeGen(mv); - //TODO: If the block ends with a return statement, we might have to pop it from the stack - // So the next iteration starts with a clean stack - mv.visitJumpInsn(Opcodes.GOTO, LoopStart); // Jump to the start of the while loop - - mv.visitLabel(conditionFalse); - } -} \ No newline at end of file diff --git a/Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java b/Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java deleted file mode 100644 index 4085494..0000000 --- a/Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java +++ /dev/null @@ -1,50 +0,0 @@ -package abstractSyntaxTree.StatementExpression; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckHelper; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Expression.IExpression; -import abstractSyntaxTree.Expression.InstVarExpression; -import abstractSyntaxTree.Expression.VarRefExpression; -import abstractSyntaxTree.Statement.IStatement; -import org.objectweb.asm.*; - -import java.util.Objects; - -public class AssignStatementExpression extends AbstractType implements IExpression, IStatement { - public String operator; - public IExpression left; - public IExpression right; - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckHelper helper = new TypeCheckHelper(); - TypeCheckResult result = new TypeCheckResult(); - - TypeCheckResult leftType = left.typeCheck(); - TypeCheckResult rightType = right.typeCheck(); - - String upperbound = helper.upperBound(leftType.type, rightType.type); - if (Objects.equals(upperbound, leftType.type)) { - result.type = leftType.type; - } - setTypeCheckResult(result); - return result; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - left.codeGen(mv); - right.codeGen(mv); - - if (left instanceof VarRefExpression varRef) { - //TODO: Implement the handling of a variable reference --> I need a list of local variables - // for that to determine if the variable is a local or field variable - } else if (left instanceof InstVarExpression instVar) { - mv.visitInsn(Opcodes.DUP_X1); - - // We now again need the owner (class reference), name (of the Field in the owner) and type of the field - //mv.visitFieldInsn(Opcodes.PUTFIELD, instVar.className, instVar.varName, instVar.type); - } - } -} diff --git a/Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java b/Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java deleted file mode 100644 index 2907a43..0000000 --- a/Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java +++ /dev/null @@ -1,64 +0,0 @@ -package abstractSyntaxTree.StatementExpression; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Class.MethodDecl; -import abstractSyntaxTree.Class.RefType; -import abstractSyntaxTree.Expression.IExpression; -import abstractSyntaxTree.Statement.IStatement; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -import java.util.List; - -public class MethodCallStatementExpression extends AbstractType implements IExpression, IStatement { - String methodName; - List arguments; - RefType classThatHasTheMethodIfNotThis; - RefType thisClass; - - public MethodCallStatementExpression(String methodName, List arguments) { - this.methodName = methodName; - this.arguments = arguments; - } - - @Override - public TypeCheckResult typeCheck() throws Exception { - TypeCheckResult result = new TypeCheckResult(); - - RefType searchMethodHere; - if(classThatHasTheMethodIfNotThis == null){ - searchMethodHere = thisClass; - } else { - searchMethodHere = classThatHasTheMethodIfNotThis; - } - - List methods = searchMethodHere.methodDecls; - - if(!methods.contains(methodName)){ - throw new Exception("method not found"); - } - - return result; - } - - //Errors occur due to the change in parameter in the RefType class - @Override - public void codeGen(MethodVisitor mv) throws Exception { - //Generate Bytecode for the receiver - if(classThatHasTheMethodIfNotThis != null){ - classThatHasTheMethodIfNotThis.codeGen(new ClassWriter(ClassWriter.COMPUTE_FRAMES)); - } else { - mv.visitVarInsn(Opcodes.ALOAD, 0); - } - - for (IExpression argument : arguments) { - argument.codeGen(mv); - } - - //We need the class reference and the return type of the method - //mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, thisClass.name, methodName, return type); - - } -} diff --git a/Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java b/Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java deleted file mode 100644 index f54986c..0000000 --- a/Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java +++ /dev/null @@ -1,19 +0,0 @@ -package abstractSyntaxTree.StatementExpression; - -import TypeCheck.AbstractType; -import TypeCheck.TypeCheckResult; -import abstractSyntaxTree.Expression.IExpression; -import abstractSyntaxTree.Statement.IStatement; -import org.objectweb.asm.MethodVisitor; - -public class NewStatementExpression extends AbstractType implements IExpression, IStatement { - @Override - public TypeCheckResult typeCheck() throws Exception { - return null; - } - - @Override - public void codeGen(MethodVisitor mv) throws Exception { - throw new Exception("CodeGen not implemented for NewStatementExpression"); - } -} diff --git a/Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java b/Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java deleted file mode 100644 index 61fa3cc..0000000 --- a/Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java +++ /dev/null @@ -1,10 +0,0 @@ -package abstractSyntaxTree.StatementExpression; - -import abstractSyntaxTree.Expression.IExpression; -import java.util.List; - -public class SuperStatementExpression extends MethodCallStatementExpression{ - public SuperStatementExpression(String methodName, List arguments) { - super(methodName, arguments); - } -} diff --git a/Source/gen/Decaf.interp b/Source/gen/Decaf.interp deleted file mode 100644 index 3b8abd6..0000000 --- a/Source/gen/Decaf.interp +++ /dev/null @@ -1,136 +0,0 @@ -token literal names: -null -'public' -'public static void main(String[] args)' -null -null -null -null -'=' -'-' -'+' -'*' -'/' -'%' -'>' -'<' -'>=' -'<=' -'==' -'!=' -'!' -'&&' -'||' -'.' -'(' -')' -'{' -'}' -';' -',' -'class' -'this' -'while' -'if' -'else' -'return' -'new' -null -'void' -'int' -'bool' -'char' -null -null -null -'null' -null - -token symbolic names: -null -AccessModifierPublic -MainMethodDecl -DotOperator -LineOperator -ComparisonOperator -LogicalOpertor -Assign -Minus -Plus -Multipilkation -Division -Modulo -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -Return -New -Identifier -Void -Int -Boolean -Char -IntValue -CharValue -BooleanValue -NullValue -WS - -rule names: -program -classdecl -constuctorDecl -methodDecl -fieldDecl -parameterList -parameter -expression -subExpression -assignableExpr -instVar -methodCall -argumentList -subReceiver -receiver -receivingMethod -binaryExpr -calcExpr -dotExpr -dotSubExpr -nonCalcExpr -nonCalcOperator -stmtExpr -statement -returnStmt -localVarDecl -block -whileStmt -ifElseStmt -ifStmt -elseStmt -assign -newDecl -type -value - - -atn: -[4, 1, 45, 331, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 1, 0, 4, 0, 72, 8, 0, 11, 0, 12, 0, 73, 1, 1, 3, 1, 77, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 85, 8, 1, 10, 1, 12, 1, 88, 9, 1, 1, 1, 1, 1, 3, 1, 92, 8, 1, 1, 1, 1, 1, 1, 2, 3, 2, 97, 8, 2, 1, 2, 1, 2, 1, 2, 3, 2, 102, 8, 2, 1, 2, 1, 2, 1, 2, 1, 3, 3, 3, 108, 8, 3, 1, 3, 1, 3, 3, 3, 112, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 117, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 123, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 132, 8, 5, 10, 5, 12, 5, 135, 9, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 142, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 151, 8, 8, 1, 9, 1, 9, 3, 9, 155, 8, 9, 1, 10, 3, 10, 158, 8, 10, 1, 10, 5, 10, 161, 8, 10, 10, 10, 12, 10, 164, 9, 10, 1, 10, 1, 10, 1, 11, 3, 11, 169, 8, 11, 1, 11, 5, 11, 172, 8, 11, 10, 11, 12, 11, 175, 9, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 3, 12, 183, 8, 12, 1, 12, 1, 12, 1, 12, 4, 12, 188, 8, 12, 11, 12, 12, 12, 189, 3, 12, 192, 8, 12, 1, 13, 1, 13, 1, 13, 3, 13, 197, 8, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 205, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 220, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 5, 17, 228, 8, 17, 10, 17, 12, 17, 231, 9, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 239, 8, 18, 10, 18, 12, 18, 242, 9, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 252, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 3, 22, 263, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 277, 8, 23, 1, 24, 1, 24, 3, 24, 281, 8, 24, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 287, 8, 25, 1, 26, 1, 26, 5, 26, 291, 8, 26, 10, 26, 12, 26, 294, 9, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 3, 28, 306, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 0, 2, 34, 36, 35, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 0, 3, 1, 0, 5, 6, 2, 0, 36, 36, 38, 40, 1, 0, 41, 44, 345, 0, 71, 1, 0, 0, 0, 2, 76, 1, 0, 0, 0, 4, 96, 1, 0, 0, 0, 6, 107, 1, 0, 0, 0, 8, 122, 1, 0, 0, 0, 10, 128, 1, 0, 0, 0, 12, 136, 1, 0, 0, 0, 14, 141, 1, 0, 0, 0, 16, 150, 1, 0, 0, 0, 18, 154, 1, 0, 0, 0, 20, 157, 1, 0, 0, 0, 22, 168, 1, 0, 0, 0, 24, 191, 1, 0, 0, 0, 26, 196, 1, 0, 0, 0, 28, 204, 1, 0, 0, 0, 30, 208, 1, 0, 0, 0, 32, 219, 1, 0, 0, 0, 34, 221, 1, 0, 0, 0, 36, 232, 1, 0, 0, 0, 38, 251, 1, 0, 0, 0, 40, 253, 1, 0, 0, 0, 42, 257, 1, 0, 0, 0, 44, 262, 1, 0, 0, 0, 46, 276, 1, 0, 0, 0, 48, 278, 1, 0, 0, 0, 50, 282, 1, 0, 0, 0, 52, 288, 1, 0, 0, 0, 54, 297, 1, 0, 0, 0, 56, 303, 1, 0, 0, 0, 58, 307, 1, 0, 0, 0, 60, 313, 1, 0, 0, 0, 62, 316, 1, 0, 0, 0, 64, 320, 1, 0, 0, 0, 66, 326, 1, 0, 0, 0, 68, 328, 1, 0, 0, 0, 70, 72, 3, 2, 1, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 1, 1, 0, 0, 0, 75, 77, 5, 1, 0, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 79, 5, 29, 0, 0, 79, 80, 5, 36, 0, 0, 80, 86, 5, 25, 0, 0, 81, 85, 3, 4, 2, 0, 82, 85, 3, 8, 4, 0, 83, 85, 3, 6, 3, 0, 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 88, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 91, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 89, 90, 5, 2, 0, 0, 90, 92, 3, 52, 26, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 94, 5, 26, 0, 0, 94, 3, 1, 0, 0, 0, 95, 97, 5, 1, 0, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 99, 5, 36, 0, 0, 99, 101, 5, 23, 0, 0, 100, 102, 3, 10, 5, 0, 101, 100, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 104, 5, 24, 0, 0, 104, 105, 3, 52, 26, 0, 105, 5, 1, 0, 0, 0, 106, 108, 5, 1, 0, 0, 107, 106, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 111, 1, 0, 0, 0, 109, 112, 3, 66, 33, 0, 110, 112, 5, 37, 0, 0, 111, 109, 1, 0, 0, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 5, 36, 0, 0, 114, 116, 5, 23, 0, 0, 115, 117, 3, 10, 5, 0, 116, 115, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 119, 5, 24, 0, 0, 119, 120, 3, 52, 26, 0, 120, 7, 1, 0, 0, 0, 121, 123, 5, 1, 0, 0, 122, 121, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 125, 3, 66, 33, 0, 125, 126, 5, 36, 0, 0, 126, 127, 5, 27, 0, 0, 127, 9, 1, 0, 0, 0, 128, 133, 3, 12, 6, 0, 129, 130, 5, 28, 0, 0, 130, 132, 3, 12, 6, 0, 131, 129, 1, 0, 0, 0, 132, 135, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 11, 1, 0, 0, 0, 135, 133, 1, 0, 0, 0, 136, 137, 3, 66, 33, 0, 137, 138, 5, 36, 0, 0, 138, 13, 1, 0, 0, 0, 139, 142, 3, 16, 8, 0, 140, 142, 3, 32, 16, 0, 141, 139, 1, 0, 0, 0, 141, 140, 1, 0, 0, 0, 142, 15, 1, 0, 0, 0, 143, 151, 5, 30, 0, 0, 144, 151, 3, 18, 9, 0, 145, 151, 3, 44, 22, 0, 146, 147, 5, 23, 0, 0, 147, 148, 3, 16, 8, 0, 148, 149, 5, 24, 0, 0, 149, 151, 1, 0, 0, 0, 150, 143, 1, 0, 0, 0, 150, 144, 1, 0, 0, 0, 150, 145, 1, 0, 0, 0, 150, 146, 1, 0, 0, 0, 151, 17, 1, 0, 0, 0, 152, 155, 5, 36, 0, 0, 153, 155, 3, 20, 10, 0, 154, 152, 1, 0, 0, 0, 154, 153, 1, 0, 0, 0, 155, 19, 1, 0, 0, 0, 156, 158, 3, 26, 13, 0, 157, 156, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 162, 1, 0, 0, 0, 159, 161, 3, 30, 15, 0, 160, 159, 1, 0, 0, 0, 161, 164, 1, 0, 0, 0, 162, 160, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 165, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 165, 166, 5, 36, 0, 0, 166, 21, 1, 0, 0, 0, 167, 169, 3, 28, 14, 0, 168, 167, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 173, 1, 0, 0, 0, 170, 172, 3, 30, 15, 0, 171, 170, 1, 0, 0, 0, 172, 175, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 176, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 176, 177, 5, 36, 0, 0, 177, 178, 5, 23, 0, 0, 178, 179, 3, 24, 12, 0, 179, 180, 5, 24, 0, 0, 180, 23, 1, 0, 0, 0, 181, 183, 3, 14, 7, 0, 182, 181, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 192, 1, 0, 0, 0, 184, 187, 3, 14, 7, 0, 185, 186, 5, 28, 0, 0, 186, 188, 3, 14, 7, 0, 187, 185, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 189, 190, 1, 0, 0, 0, 190, 192, 1, 0, 0, 0, 191, 182, 1, 0, 0, 0, 191, 184, 1, 0, 0, 0, 192, 25, 1, 0, 0, 0, 193, 197, 5, 30, 0, 0, 194, 197, 3, 64, 32, 0, 195, 197, 5, 36, 0, 0, 196, 193, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 195, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 199, 5, 22, 0, 0, 199, 27, 1, 0, 0, 0, 200, 205, 5, 30, 0, 0, 201, 205, 3, 20, 10, 0, 202, 205, 3, 64, 32, 0, 203, 205, 5, 36, 0, 0, 204, 200, 1, 0, 0, 0, 204, 201, 1, 0, 0, 0, 204, 202, 1, 0, 0, 0, 204, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 207, 5, 22, 0, 0, 207, 29, 1, 0, 0, 0, 208, 209, 5, 36, 0, 0, 209, 210, 5, 23, 0, 0, 210, 211, 3, 24, 12, 0, 211, 212, 5, 24, 0, 0, 212, 213, 5, 22, 0, 0, 213, 31, 1, 0, 0, 0, 214, 220, 3, 34, 17, 0, 215, 220, 3, 40, 20, 0, 216, 220, 3, 68, 34, 0, 217, 218, 5, 19, 0, 0, 218, 220, 3, 32, 16, 0, 219, 214, 1, 0, 0, 0, 219, 215, 1, 0, 0, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 220, 33, 1, 0, 0, 0, 221, 222, 6, 17, -1, 0, 222, 223, 3, 36, 18, 0, 223, 229, 1, 0, 0, 0, 224, 225, 10, 2, 0, 0, 225, 226, 5, 4, 0, 0, 226, 228, 3, 36, 18, 0, 227, 224, 1, 0, 0, 0, 228, 231, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 35, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 232, 233, 6, 18, -1, 0, 233, 234, 3, 38, 19, 0, 234, 240, 1, 0, 0, 0, 235, 236, 10, 2, 0, 0, 236, 237, 5, 3, 0, 0, 237, 239, 3, 38, 19, 0, 238, 235, 1, 0, 0, 0, 239, 242, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 37, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 243, 252, 5, 41, 0, 0, 244, 252, 5, 36, 0, 0, 245, 252, 3, 20, 10, 0, 246, 252, 3, 22, 11, 0, 247, 248, 5, 23, 0, 0, 248, 249, 3, 34, 17, 0, 249, 250, 5, 24, 0, 0, 250, 252, 1, 0, 0, 0, 251, 243, 1, 0, 0, 0, 251, 244, 1, 0, 0, 0, 251, 245, 1, 0, 0, 0, 251, 246, 1, 0, 0, 0, 251, 247, 1, 0, 0, 0, 252, 39, 1, 0, 0, 0, 253, 254, 3, 16, 8, 0, 254, 255, 3, 42, 21, 0, 255, 256, 3, 14, 7, 0, 256, 41, 1, 0, 0, 0, 257, 258, 7, 0, 0, 0, 258, 43, 1, 0, 0, 0, 259, 263, 3, 62, 31, 0, 260, 263, 3, 64, 32, 0, 261, 263, 3, 22, 11, 0, 262, 259, 1, 0, 0, 0, 262, 260, 1, 0, 0, 0, 262, 261, 1, 0, 0, 0, 263, 45, 1, 0, 0, 0, 264, 265, 3, 48, 24, 0, 265, 266, 5, 27, 0, 0, 266, 277, 1, 0, 0, 0, 267, 268, 3, 50, 25, 0, 268, 269, 5, 27, 0, 0, 269, 277, 1, 0, 0, 0, 270, 277, 3, 52, 26, 0, 271, 277, 3, 54, 27, 0, 272, 277, 3, 56, 28, 0, 273, 274, 3, 44, 22, 0, 274, 275, 5, 27, 0, 0, 275, 277, 1, 0, 0, 0, 276, 264, 1, 0, 0, 0, 276, 267, 1, 0, 0, 0, 276, 270, 1, 0, 0, 0, 276, 271, 1, 0, 0, 0, 276, 272, 1, 0, 0, 0, 276, 273, 1, 0, 0, 0, 277, 47, 1, 0, 0, 0, 278, 280, 5, 34, 0, 0, 279, 281, 3, 14, 7, 0, 280, 279, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 49, 1, 0, 0, 0, 282, 283, 3, 66, 33, 0, 283, 286, 5, 36, 0, 0, 284, 285, 5, 7, 0, 0, 285, 287, 3, 14, 7, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 51, 1, 0, 0, 0, 288, 292, 5, 25, 0, 0, 289, 291, 3, 46, 23, 0, 290, 289, 1, 0, 0, 0, 291, 294, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 292, 293, 1, 0, 0, 0, 293, 295, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 295, 296, 5, 26, 0, 0, 296, 53, 1, 0, 0, 0, 297, 298, 5, 31, 0, 0, 298, 299, 5, 23, 0, 0, 299, 300, 3, 14, 7, 0, 300, 301, 5, 24, 0, 0, 301, 302, 3, 46, 23, 0, 302, 55, 1, 0, 0, 0, 303, 305, 3, 58, 29, 0, 304, 306, 3, 60, 30, 0, 305, 304, 1, 0, 0, 0, 305, 306, 1, 0, 0, 0, 306, 57, 1, 0, 0, 0, 307, 308, 5, 32, 0, 0, 308, 309, 5, 23, 0, 0, 309, 310, 3, 14, 7, 0, 310, 311, 5, 24, 0, 0, 311, 312, 3, 46, 23, 0, 312, 59, 1, 0, 0, 0, 313, 314, 5, 33, 0, 0, 314, 315, 3, 46, 23, 0, 315, 61, 1, 0, 0, 0, 316, 317, 3, 18, 9, 0, 317, 318, 5, 7, 0, 0, 318, 319, 3, 14, 7, 0, 319, 63, 1, 0, 0, 0, 320, 321, 5, 35, 0, 0, 321, 322, 5, 36, 0, 0, 322, 323, 5, 23, 0, 0, 323, 324, 3, 24, 12, 0, 324, 325, 5, 24, 0, 0, 325, 65, 1, 0, 0, 0, 326, 327, 7, 1, 0, 0, 327, 67, 1, 0, 0, 0, 328, 329, 7, 2, 0, 0, 329, 69, 1, 0, 0, 0, 34, 73, 76, 84, 86, 91, 96, 101, 107, 111, 116, 122, 133, 141, 150, 154, 157, 162, 168, 173, 182, 189, 191, 196, 204, 219, 229, 240, 251, 262, 276, 280, 286, 292, 305] \ No newline at end of file diff --git a/Source/gen/Decaf.tokens b/Source/gen/Decaf.tokens deleted file mode 100644 index 6873c36..0000000 --- a/Source/gen/Decaf.tokens +++ /dev/null @@ -1,81 +0,0 @@ -AccessModifierPublic=1 -MainMethodDecl=2 -DotOperator=3 -LineOperator=4 -ComparisonOperator=5 -LogicalOpertor=6 -Assign=7 -Minus=8 -Plus=9 -Multipilkation=10 -Division=11 -Modulo=12 -Greater=13 -Less=14 -GreaterEqual=15 -LessEqual=16 -Equal=17 -NotEqual=18 -Not=19 -And=20 -Or=21 -Dot=22 -OpenRoundBracket=23 -ClosedRoundBracket=24 -OpenCurlyBracket=25 -ClosedCurlyBracket=26 -Semicolon=27 -Comma=28 -Class=29 -This=30 -While=31 -If=32 -Else=33 -Return=34 -New=35 -Identifier=36 -Void=37 -Int=38 -Boolean=39 -Char=40 -IntValue=41 -CharValue=42 -BooleanValue=43 -NullValue=44 -WS=45 -'public'=1 -'public static void main(String[] args)'=2 -'='=7 -'-'=8 -'+'=9 -'*'=10 -'/'=11 -'%'=12 -'>'=13 -'<'=14 -'>='=15 -'<='=16 -'=='=17 -'!='=18 -'!'=19 -'&&'=20 -'||'=21 -'.'=22 -'('=23 -')'=24 -'{'=25 -'}'=26 -';'=27 -','=28 -'class'=29 -'this'=30 -'while'=31 -'if'=32 -'else'=33 -'return'=34 -'new'=35 -'void'=37 -'int'=38 -'bool'=39 -'char'=40 -'null'=44 diff --git a/Source/gen/DecafBaseListener.java b/Source/gen/DecafBaseListener.java deleted file mode 100644 index 59f157f..0000000 --- a/Source/gen/DecafBaseListener.java +++ /dev/null @@ -1,459 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 - -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 DecafListener}, - * which can be extended to create a listener which only needs to handle a subset - * of the available methods. - */ -@SuppressWarnings("CheckReturnValue") -public class DecafBaseListener implements DecafListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterClassdecl(DecafParser.ClassdeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitClassdecl(DecafParser.ClassdeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMethodDecl(DecafParser.MethodDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMethodDecl(DecafParser.MethodDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFieldDecl(DecafParser.FieldDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFieldDecl(DecafParser.FieldDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterSubExpression(DecafParser.SubExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSubExpression(DecafParser.SubExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssignableExpr(DecafParser.AssignableExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssignableExpr(DecafParser.AssignableExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterInstVar(DecafParser.InstVarContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitInstVar(DecafParser.InstVarContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterSubReceiver(DecafParser.SubReceiverContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSubReceiver(DecafParser.SubReceiverContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterReceiver(DecafParser.ReceiverContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReceiver(DecafParser.ReceiverContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterReceivingMethod(DecafParser.ReceivingMethodContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBinaryExpr(DecafParser.BinaryExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBinaryExpr(DecafParser.BinaryExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCalcExpr(DecafParser.CalcExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCalcExpr(DecafParser.CalcExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDotExpr(DecafParser.DotExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDotExpr(DecafParser.DotExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDotSubExpr(DecafParser.DotSubExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDotSubExpr(DecafParser.DotSubExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNonCalcExpr(DecafParser.NonCalcExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStmtExpr(DecafParser.StmtExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStmtExpr(DecafParser.StmtExprContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterReturnStmt(DecafParser.ReturnStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReturnStmt(DecafParser.ReturnStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterWhileStmt(DecafParser.WhileStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhileStmt(DecafParser.WhileStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfElseStmt(DecafParser.IfElseStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfElseStmt(DecafParser.IfElseStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfStmt(DecafParser.IfStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfStmt(DecafParser.IfStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterElseStmt(DecafParser.ElseStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitElseStmt(DecafParser.ElseStmtContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void enterNewDecl(DecafParser.NewDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNewDecl(DecafParser.NewDeclContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file diff --git a/Source/gen/DecafBaseVisitor.java b/Source/gen/DecafBaseVisitor.java deleted file mode 100644 index 9bd240e..0000000 --- a/Source/gen/DecafBaseVisitor.java +++ /dev/null @@ -1,259 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link DecafVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -@SuppressWarnings("CheckReturnValue") -public class DecafBaseVisitor extends AbstractParseTreeVisitor implements DecafVisitor { - /** - * {@inheritDoc} - * - *

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

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

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

- */ - @Override public T visitClassdecl(DecafParser.ClassdeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitMethodDecl(DecafParser.MethodDeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitFieldDecl(DecafParser.FieldDeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitParameterList(DecafParser.ParameterListContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

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

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

- */ - @Override public T visitSubExpression(DecafParser.SubExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitAssignableExpr(DecafParser.AssignableExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitInstVar(DecafParser.InstVarContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

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

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

- */ - @Override public T visitSubReceiver(DecafParser.SubReceiverContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitReceiver(DecafParser.ReceiverContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitBinaryExpr(DecafParser.BinaryExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitCalcExpr(DecafParser.CalcExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitDotExpr(DecafParser.DotExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitDotSubExpr(DecafParser.DotSubExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitStmtExpr(DecafParser.StmtExprContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

- */ - @Override public T visitReturnStmt(DecafParser.ReturnStmtContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

- */ - @Override public T visitWhileStmt(DecafParser.WhileStmtContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitIfElseStmt(DecafParser.IfElseStmtContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitIfStmt(DecafParser.IfStmtContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitElseStmt(DecafParser.ElseStmtContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

- */ - @Override public T visitNewDecl(DecafParser.NewDeclContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

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

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

- */ - @Override public T visitValue(DecafParser.ValueContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file diff --git a/Source/gen/DecafLexer.interp b/Source/gen/DecafLexer.interp deleted file mode 100644 index cf85022..0000000 --- a/Source/gen/DecafLexer.interp +++ /dev/null @@ -1,155 +0,0 @@ -token literal names: -null -'public' -'public static void main(String[] args)' -null -null -null -null -'=' -'-' -'+' -'*' -'/' -'%' -'>' -'<' -'>=' -'<=' -'==' -'!=' -'!' -'&&' -'||' -'.' -'(' -')' -'{' -'}' -';' -',' -'class' -'this' -'while' -'if' -'else' -'return' -'new' -null -'void' -'int' -'bool' -'char' -null -null -null -'null' -null - -token symbolic names: -null -AccessModifierPublic -MainMethodDecl -DotOperator -LineOperator -ComparisonOperator -LogicalOpertor -Assign -Minus -Plus -Multipilkation -Division -Modulo -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -Return -New -Identifier -Void -Int -Boolean -Char -IntValue -CharValue -BooleanValue -NullValue -WS - -rule names: -AccessModifierPublic -MainMethodDecl -DotOperator -LineOperator -ComparisonOperator -LogicalOpertor -Assign -Minus -Plus -Multipilkation -Division -Modulo -Greater -Less -GreaterEqual -LessEqual -Equal -NotEqual -Not -And -Or -Dot -OpenRoundBracket -ClosedRoundBracket -OpenCurlyBracket -ClosedCurlyBracket -Semicolon -Comma -Class -This -While -If -Else -Return -New -Alpabetic -Numeric -ValidIdentSymbols -Identifier -Void -Int -Boolean -Char -IntValue -CharValue -BooleanValue -NullValue -WS - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 45, 322, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 147, 8, 2, 1, 3, 1, 3, 3, 3, 151, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 159, 8, 4, 1, 5, 1, 5, 3, 5, 163, 8, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 3, 37, 258, 8, 37, 1, 38, 1, 38, 5, 38, 262, 8, 38, 10, 38, 12, 38, 265, 9, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 5, 43, 287, 8, 43, 10, 43, 12, 43, 290, 9, 43, 1, 43, 4, 43, 293, 8, 43, 11, 43, 12, 43, 294, 1, 44, 1, 44, 3, 44, 299, 8, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 312, 8, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 0, 0, 48, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 0, 73, 0, 75, 0, 77, 36, 79, 37, 81, 38, 83, 39, 85, 40, 87, 41, 89, 42, 91, 43, 93, 44, 95, 45, 1, 0, 6, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 2, 0, 36, 36, 95, 95, 2, 0, 43, 43, 45, 45, 2, 0, 10, 10, 13, 13, 3, 0, 9, 10, 13, 13, 32, 32, 334, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 1, 97, 1, 0, 0, 0, 3, 104, 1, 0, 0, 0, 5, 146, 1, 0, 0, 0, 7, 150, 1, 0, 0, 0, 9, 158, 1, 0, 0, 0, 11, 162, 1, 0, 0, 0, 13, 164, 1, 0, 0, 0, 15, 166, 1, 0, 0, 0, 17, 168, 1, 0, 0, 0, 19, 170, 1, 0, 0, 0, 21, 172, 1, 0, 0, 0, 23, 174, 1, 0, 0, 0, 25, 176, 1, 0, 0, 0, 27, 178, 1, 0, 0, 0, 29, 180, 1, 0, 0, 0, 31, 183, 1, 0, 0, 0, 33, 186, 1, 0, 0, 0, 35, 189, 1, 0, 0, 0, 37, 192, 1, 0, 0, 0, 39, 194, 1, 0, 0, 0, 41, 197, 1, 0, 0, 0, 43, 200, 1, 0, 0, 0, 45, 202, 1, 0, 0, 0, 47, 204, 1, 0, 0, 0, 49, 206, 1, 0, 0, 0, 51, 208, 1, 0, 0, 0, 53, 210, 1, 0, 0, 0, 55, 212, 1, 0, 0, 0, 57, 214, 1, 0, 0, 0, 59, 220, 1, 0, 0, 0, 61, 225, 1, 0, 0, 0, 63, 231, 1, 0, 0, 0, 65, 234, 1, 0, 0, 0, 67, 239, 1, 0, 0, 0, 69, 246, 1, 0, 0, 0, 71, 250, 1, 0, 0, 0, 73, 252, 1, 0, 0, 0, 75, 257, 1, 0, 0, 0, 77, 259, 1, 0, 0, 0, 79, 266, 1, 0, 0, 0, 81, 271, 1, 0, 0, 0, 83, 275, 1, 0, 0, 0, 85, 280, 1, 0, 0, 0, 87, 288, 1, 0, 0, 0, 89, 296, 1, 0, 0, 0, 91, 311, 1, 0, 0, 0, 93, 313, 1, 0, 0, 0, 95, 318, 1, 0, 0, 0, 97, 98, 5, 112, 0, 0, 98, 99, 5, 117, 0, 0, 99, 100, 5, 98, 0, 0, 100, 101, 5, 108, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, 5, 99, 0, 0, 103, 2, 1, 0, 0, 0, 104, 105, 5, 112, 0, 0, 105, 106, 5, 117, 0, 0, 106, 107, 5, 98, 0, 0, 107, 108, 5, 108, 0, 0, 108, 109, 5, 105, 0, 0, 109, 110, 5, 99, 0, 0, 110, 111, 5, 32, 0, 0, 111, 112, 5, 115, 0, 0, 112, 113, 5, 116, 0, 0, 113, 114, 5, 97, 0, 0, 114, 115, 5, 116, 0, 0, 115, 116, 5, 105, 0, 0, 116, 117, 5, 99, 0, 0, 117, 118, 5, 32, 0, 0, 118, 119, 5, 118, 0, 0, 119, 120, 5, 111, 0, 0, 120, 121, 5, 105, 0, 0, 121, 122, 5, 100, 0, 0, 122, 123, 5, 32, 0, 0, 123, 124, 5, 109, 0, 0, 124, 125, 5, 97, 0, 0, 125, 126, 5, 105, 0, 0, 126, 127, 5, 110, 0, 0, 127, 128, 5, 40, 0, 0, 128, 129, 5, 83, 0, 0, 129, 130, 5, 116, 0, 0, 130, 131, 5, 114, 0, 0, 131, 132, 5, 105, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 103, 0, 0, 134, 135, 5, 91, 0, 0, 135, 136, 5, 93, 0, 0, 136, 137, 5, 32, 0, 0, 137, 138, 5, 97, 0, 0, 138, 139, 5, 114, 0, 0, 139, 140, 5, 103, 0, 0, 140, 141, 5, 115, 0, 0, 141, 142, 5, 41, 0, 0, 142, 4, 1, 0, 0, 0, 143, 147, 3, 19, 9, 0, 144, 147, 3, 21, 10, 0, 145, 147, 3, 23, 11, 0, 146, 143, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 146, 145, 1, 0, 0, 0, 147, 6, 1, 0, 0, 0, 148, 151, 3, 17, 8, 0, 149, 151, 3, 15, 7, 0, 150, 148, 1, 0, 0, 0, 150, 149, 1, 0, 0, 0, 151, 8, 1, 0, 0, 0, 152, 159, 3, 25, 12, 0, 153, 159, 3, 27, 13, 0, 154, 159, 3, 29, 14, 0, 155, 159, 3, 31, 15, 0, 156, 159, 3, 33, 16, 0, 157, 159, 3, 35, 17, 0, 158, 152, 1, 0, 0, 0, 158, 153, 1, 0, 0, 0, 158, 154, 1, 0, 0, 0, 158, 155, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 158, 157, 1, 0, 0, 0, 159, 10, 1, 0, 0, 0, 160, 163, 3, 39, 19, 0, 161, 163, 3, 41, 20, 0, 162, 160, 1, 0, 0, 0, 162, 161, 1, 0, 0, 0, 163, 12, 1, 0, 0, 0, 164, 165, 5, 61, 0, 0, 165, 14, 1, 0, 0, 0, 166, 167, 5, 45, 0, 0, 167, 16, 1, 0, 0, 0, 168, 169, 5, 43, 0, 0, 169, 18, 1, 0, 0, 0, 170, 171, 5, 42, 0, 0, 171, 20, 1, 0, 0, 0, 172, 173, 5, 47, 0, 0, 173, 22, 1, 0, 0, 0, 174, 175, 5, 37, 0, 0, 175, 24, 1, 0, 0, 0, 176, 177, 5, 62, 0, 0, 177, 26, 1, 0, 0, 0, 178, 179, 5, 60, 0, 0, 179, 28, 1, 0, 0, 0, 180, 181, 5, 62, 0, 0, 181, 182, 5, 61, 0, 0, 182, 30, 1, 0, 0, 0, 183, 184, 5, 60, 0, 0, 184, 185, 5, 61, 0, 0, 185, 32, 1, 0, 0, 0, 186, 187, 5, 61, 0, 0, 187, 188, 5, 61, 0, 0, 188, 34, 1, 0, 0, 0, 189, 190, 5, 33, 0, 0, 190, 191, 5, 61, 0, 0, 191, 36, 1, 0, 0, 0, 192, 193, 5, 33, 0, 0, 193, 38, 1, 0, 0, 0, 194, 195, 5, 38, 0, 0, 195, 196, 5, 38, 0, 0, 196, 40, 1, 0, 0, 0, 197, 198, 5, 124, 0, 0, 198, 199, 5, 124, 0, 0, 199, 42, 1, 0, 0, 0, 200, 201, 5, 46, 0, 0, 201, 44, 1, 0, 0, 0, 202, 203, 5, 40, 0, 0, 203, 46, 1, 0, 0, 0, 204, 205, 5, 41, 0, 0, 205, 48, 1, 0, 0, 0, 206, 207, 5, 123, 0, 0, 207, 50, 1, 0, 0, 0, 208, 209, 5, 125, 0, 0, 209, 52, 1, 0, 0, 0, 210, 211, 5, 59, 0, 0, 211, 54, 1, 0, 0, 0, 212, 213, 5, 44, 0, 0, 213, 56, 1, 0, 0, 0, 214, 215, 5, 99, 0, 0, 215, 216, 5, 108, 0, 0, 216, 217, 5, 97, 0, 0, 217, 218, 5, 115, 0, 0, 218, 219, 5, 115, 0, 0, 219, 58, 1, 0, 0, 0, 220, 221, 5, 116, 0, 0, 221, 222, 5, 104, 0, 0, 222, 223, 5, 105, 0, 0, 223, 224, 5, 115, 0, 0, 224, 60, 1, 0, 0, 0, 225, 226, 5, 119, 0, 0, 226, 227, 5, 104, 0, 0, 227, 228, 5, 105, 0, 0, 228, 229, 5, 108, 0, 0, 229, 230, 5, 101, 0, 0, 230, 62, 1, 0, 0, 0, 231, 232, 5, 105, 0, 0, 232, 233, 5, 102, 0, 0, 233, 64, 1, 0, 0, 0, 234, 235, 5, 101, 0, 0, 235, 236, 5, 108, 0, 0, 236, 237, 5, 115, 0, 0, 237, 238, 5, 101, 0, 0, 238, 66, 1, 0, 0, 0, 239, 240, 5, 114, 0, 0, 240, 241, 5, 101, 0, 0, 241, 242, 5, 116, 0, 0, 242, 243, 5, 117, 0, 0, 243, 244, 5, 114, 0, 0, 244, 245, 5, 110, 0, 0, 245, 68, 1, 0, 0, 0, 246, 247, 5, 110, 0, 0, 247, 248, 5, 101, 0, 0, 248, 249, 5, 119, 0, 0, 249, 70, 1, 0, 0, 0, 250, 251, 7, 0, 0, 0, 251, 72, 1, 0, 0, 0, 252, 253, 7, 1, 0, 0, 253, 74, 1, 0, 0, 0, 254, 258, 3, 71, 35, 0, 255, 258, 3, 73, 36, 0, 256, 258, 7, 2, 0, 0, 257, 254, 1, 0, 0, 0, 257, 255, 1, 0, 0, 0, 257, 256, 1, 0, 0, 0, 258, 76, 1, 0, 0, 0, 259, 263, 3, 71, 35, 0, 260, 262, 3, 75, 37, 0, 261, 260, 1, 0, 0, 0, 262, 265, 1, 0, 0, 0, 263, 261, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 78, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 266, 267, 5, 118, 0, 0, 267, 268, 5, 111, 0, 0, 268, 269, 5, 105, 0, 0, 269, 270, 5, 100, 0, 0, 270, 80, 1, 0, 0, 0, 271, 272, 5, 105, 0, 0, 272, 273, 5, 110, 0, 0, 273, 274, 5, 116, 0, 0, 274, 82, 1, 0, 0, 0, 275, 276, 5, 98, 0, 0, 276, 277, 5, 111, 0, 0, 277, 278, 5, 111, 0, 0, 278, 279, 5, 108, 0, 0, 279, 84, 1, 0, 0, 0, 280, 281, 5, 99, 0, 0, 281, 282, 5, 104, 0, 0, 282, 283, 5, 97, 0, 0, 283, 284, 5, 114, 0, 0, 284, 86, 1, 0, 0, 0, 285, 287, 7, 3, 0, 0, 286, 285, 1, 0, 0, 0, 287, 290, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 291, 293, 7, 1, 0, 0, 292, 291, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 88, 1, 0, 0, 0, 296, 298, 5, 39, 0, 0, 297, 299, 8, 4, 0, 0, 298, 297, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 301, 5, 39, 0, 0, 301, 90, 1, 0, 0, 0, 302, 303, 5, 116, 0, 0, 303, 304, 5, 114, 0, 0, 304, 305, 5, 117, 0, 0, 305, 312, 5, 101, 0, 0, 306, 307, 5, 102, 0, 0, 307, 308, 5, 97, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 115, 0, 0, 310, 312, 5, 101, 0, 0, 311, 302, 1, 0, 0, 0, 311, 306, 1, 0, 0, 0, 312, 92, 1, 0, 0, 0, 313, 314, 5, 110, 0, 0, 314, 315, 5, 117, 0, 0, 315, 316, 5, 108, 0, 0, 316, 317, 5, 108, 0, 0, 317, 94, 1, 0, 0, 0, 318, 319, 7, 5, 0, 0, 319, 320, 1, 0, 0, 0, 320, 321, 6, 47, 0, 0, 321, 96, 1, 0, 0, 0, 11, 0, 146, 150, 158, 162, 257, 263, 288, 294, 298, 311, 1, 6, 0, 0] \ No newline at end of file diff --git a/Source/gen/DecafLexer.java b/Source/gen/DecafLexer.java deleted file mode 100644 index 1448a7c..0000000 --- a/Source/gen/DecafLexer.java +++ /dev/null @@ -1,338 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 -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 DecafLexer 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 - AccessModifierPublic=1, MainMethodDecl=2, DotOperator=3, LineOperator=4, - ComparisonOperator=5, LogicalOpertor=6, Assign=7, Minus=8, Plus=9, Multipilkation=10, - Division=11, Modulo=12, Greater=13, Less=14, GreaterEqual=15, LessEqual=16, - Equal=17, NotEqual=18, Not=19, And=20, Or=21, Dot=22, OpenRoundBracket=23, - ClosedRoundBracket=24, OpenCurlyBracket=25, ClosedCurlyBracket=26, Semicolon=27, - Comma=28, Class=29, This=30, While=31, If=32, Else=33, Return=34, New=35, - Identifier=36, Void=37, Int=38, Boolean=39, Char=40, IntValue=41, CharValue=42, - BooleanValue=43, NullValue=44, WS=45; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[] { - "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", - "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", - "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", - "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", - "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", - "This", "While", "If", "Else", "Return", "New", "Alpabetic", "Numeric", - "ValidIdentSymbols", "Identifier", "Void", "Int", "Boolean", "Char", - "IntValue", "CharValue", "BooleanValue", "NullValue", "WS" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'public'", "'public static void main(String[] args)'", null, null, - null, null, "'='", "'-'", "'+'", "'*'", "'/'", "'%'", "'>'", "'<'", "'>='", - "'<='", "'=='", "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", - "'}'", "';'", "','", "'class'", "'this'", "'while'", "'if'", "'else'", - "'return'", "'new'", null, "'void'", "'int'", "'bool'", "'char'", null, - null, null, "'null'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", - "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", - "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", - "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", - "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", - "This", "While", "If", "Else", "Return", "New", "Identifier", "Void", - "Int", "Boolean", "Char", "IntValue", "CharValue", "BooleanValue", "NullValue", - "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] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public DecafLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "Decaf.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-\u0142\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ - "\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ - "\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ - "\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+ - "\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002"+ - "\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+ - "\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+ - "\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ - "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ - "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ - "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ - "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ - "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ - "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u0001\u0000"+ - "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ - "\u0003\u0002\u0093\b\u0002\u0001\u0003\u0001\u0003\u0003\u0003\u0097\b"+ - "\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+ - "\u0004\u0003\u0004\u009f\b\u0004\u0001\u0005\u0001\u0005\u0003\u0005\u00a3"+ - "\b\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001"+ - "\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001"+ - "\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ - "\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001"+ - "\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001"+ - "\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001"+ - "\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001"+ - "\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001"+ - "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001"+ - "\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+ - "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001"+ - "\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0001"+ - "!\u0001!\u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0001#\u0001"+ - "#\u0001$\u0001$\u0001%\u0001%\u0001%\u0003%\u0102\b%\u0001&\u0001&\u0005"+ - "&\u0106\b&\n&\f&\u0109\t&\u0001\'\u0001\'\u0001\'\u0001\'\u0001\'\u0001"+ - "(\u0001(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001)\u0001*\u0001"+ - "*\u0001*\u0001*\u0001*\u0001+\u0005+\u011f\b+\n+\f+\u0122\t+\u0001+\u0004"+ - "+\u0125\b+\u000b+\f+\u0126\u0001,\u0001,\u0003,\u012b\b,\u0001,\u0001"+ - ",\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0003"+ - "-\u0138\b-\u0001.\u0001.\u0001.\u0001.\u0001.\u0001/\u0001/\u0001/\u0001"+ - "/\u0000\u00000\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/\u00181\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f"+ - "? A!C\"E#G\u0000I\u0000K\u0000M$O%Q&S\'U(W)Y*[+],_-\u0001\u0000\u0006"+ - "\u0002\u0000AZaz\u0001\u000009\u0002\u0000$$__\u0002\u0000++--\u0002\u0000"+ - "\n\n\r\r\u0003\u0000\t\n\r\r \u014e\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\u00003\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\u0000A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000"+ - "\u0000\u0000E\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+ - "O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+ - "\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+ - "\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+ - "]\u0001\u0000\u0000\u0000\u0000_\u0001\u0000\u0000\u0000\u0001a\u0001"+ - "\u0000\u0000\u0000\u0003h\u0001\u0000\u0000\u0000\u0005\u0092\u0001\u0000"+ - "\u0000\u0000\u0007\u0096\u0001\u0000\u0000\u0000\t\u009e\u0001\u0000\u0000"+ - "\u0000\u000b\u00a2\u0001\u0000\u0000\u0000\r\u00a4\u0001\u0000\u0000\u0000"+ - "\u000f\u00a6\u0001\u0000\u0000\u0000\u0011\u00a8\u0001\u0000\u0000\u0000"+ - "\u0013\u00aa\u0001\u0000\u0000\u0000\u0015\u00ac\u0001\u0000\u0000\u0000"+ - "\u0017\u00ae\u0001\u0000\u0000\u0000\u0019\u00b0\u0001\u0000\u0000\u0000"+ - "\u001b\u00b2\u0001\u0000\u0000\u0000\u001d\u00b4\u0001\u0000\u0000\u0000"+ - "\u001f\u00b7\u0001\u0000\u0000\u0000!\u00ba\u0001\u0000\u0000\u0000#\u00bd"+ - "\u0001\u0000\u0000\u0000%\u00c0\u0001\u0000\u0000\u0000\'\u00c2\u0001"+ - "\u0000\u0000\u0000)\u00c5\u0001\u0000\u0000\u0000+\u00c8\u0001\u0000\u0000"+ - "\u0000-\u00ca\u0001\u0000\u0000\u0000/\u00cc\u0001\u0000\u0000\u00001"+ - "\u00ce\u0001\u0000\u0000\u00003\u00d0\u0001\u0000\u0000\u00005\u00d2\u0001"+ - "\u0000\u0000\u00007\u00d4\u0001\u0000\u0000\u00009\u00d6\u0001\u0000\u0000"+ - "\u0000;\u00dc\u0001\u0000\u0000\u0000=\u00e1\u0001\u0000\u0000\u0000?"+ - "\u00e7\u0001\u0000\u0000\u0000A\u00ea\u0001\u0000\u0000\u0000C\u00ef\u0001"+ - "\u0000\u0000\u0000E\u00f6\u0001\u0000\u0000\u0000G\u00fa\u0001\u0000\u0000"+ - "\u0000I\u00fc\u0001\u0000\u0000\u0000K\u0101\u0001\u0000\u0000\u0000M"+ - "\u0103\u0001\u0000\u0000\u0000O\u010a\u0001\u0000\u0000\u0000Q\u010f\u0001"+ - "\u0000\u0000\u0000S\u0113\u0001\u0000\u0000\u0000U\u0118\u0001\u0000\u0000"+ - "\u0000W\u0120\u0001\u0000\u0000\u0000Y\u0128\u0001\u0000\u0000\u0000["+ - "\u0137\u0001\u0000\u0000\u0000]\u0139\u0001\u0000\u0000\u0000_\u013e\u0001"+ - "\u0000\u0000\u0000ab\u0005p\u0000\u0000bc\u0005u\u0000\u0000cd\u0005b"+ - "\u0000\u0000de\u0005l\u0000\u0000ef\u0005i\u0000\u0000fg\u0005c\u0000"+ - "\u0000g\u0002\u0001\u0000\u0000\u0000hi\u0005p\u0000\u0000ij\u0005u\u0000"+ - "\u0000jk\u0005b\u0000\u0000kl\u0005l\u0000\u0000lm\u0005i\u0000\u0000"+ - "mn\u0005c\u0000\u0000no\u0005 \u0000\u0000op\u0005s\u0000\u0000pq\u0005"+ - "t\u0000\u0000qr\u0005a\u0000\u0000rs\u0005t\u0000\u0000st\u0005i\u0000"+ - "\u0000tu\u0005c\u0000\u0000uv\u0005 \u0000\u0000vw\u0005v\u0000\u0000"+ - "wx\u0005o\u0000\u0000xy\u0005i\u0000\u0000yz\u0005d\u0000\u0000z{\u0005"+ - " \u0000\u0000{|\u0005m\u0000\u0000|}\u0005a\u0000\u0000}~\u0005i\u0000"+ - "\u0000~\u007f\u0005n\u0000\u0000\u007f\u0080\u0005(\u0000\u0000\u0080"+ - "\u0081\u0005S\u0000\u0000\u0081\u0082\u0005t\u0000\u0000\u0082\u0083\u0005"+ - "r\u0000\u0000\u0083\u0084\u0005i\u0000\u0000\u0084\u0085\u0005n\u0000"+ - "\u0000\u0085\u0086\u0005g\u0000\u0000\u0086\u0087\u0005[\u0000\u0000\u0087"+ - "\u0088\u0005]\u0000\u0000\u0088\u0089\u0005 \u0000\u0000\u0089\u008a\u0005"+ - "a\u0000\u0000\u008a\u008b\u0005r\u0000\u0000\u008b\u008c\u0005g\u0000"+ - "\u0000\u008c\u008d\u0005s\u0000\u0000\u008d\u008e\u0005)\u0000\u0000\u008e"+ - "\u0004\u0001\u0000\u0000\u0000\u008f\u0093\u0003\u0013\t\u0000\u0090\u0093"+ - "\u0003\u0015\n\u0000\u0091\u0093\u0003\u0017\u000b\u0000\u0092\u008f\u0001"+ - "\u0000\u0000\u0000\u0092\u0090\u0001\u0000\u0000\u0000\u0092\u0091\u0001"+ - "\u0000\u0000\u0000\u0093\u0006\u0001\u0000\u0000\u0000\u0094\u0097\u0003"+ - "\u0011\b\u0000\u0095\u0097\u0003\u000f\u0007\u0000\u0096\u0094\u0001\u0000"+ - "\u0000\u0000\u0096\u0095\u0001\u0000\u0000\u0000\u0097\b\u0001\u0000\u0000"+ - "\u0000\u0098\u009f\u0003\u0019\f\u0000\u0099\u009f\u0003\u001b\r\u0000"+ - "\u009a\u009f\u0003\u001d\u000e\u0000\u009b\u009f\u0003\u001f\u000f\u0000"+ - "\u009c\u009f\u0003!\u0010\u0000\u009d\u009f\u0003#\u0011\u0000\u009e\u0098"+ - "\u0001\u0000\u0000\u0000\u009e\u0099\u0001\u0000\u0000\u0000\u009e\u009a"+ - "\u0001\u0000\u0000\u0000\u009e\u009b\u0001\u0000\u0000\u0000\u009e\u009c"+ - "\u0001\u0000\u0000\u0000\u009e\u009d\u0001\u0000\u0000\u0000\u009f\n\u0001"+ - "\u0000\u0000\u0000\u00a0\u00a3\u0003\'\u0013\u0000\u00a1\u00a3\u0003)"+ - "\u0014\u0000\u00a2\u00a0\u0001\u0000\u0000\u0000\u00a2\u00a1\u0001\u0000"+ - "\u0000\u0000\u00a3\f\u0001\u0000\u0000\u0000\u00a4\u00a5\u0005=\u0000"+ - "\u0000\u00a5\u000e\u0001\u0000\u0000\u0000\u00a6\u00a7\u0005-\u0000\u0000"+ - "\u00a7\u0010\u0001\u0000\u0000\u0000\u00a8\u00a9\u0005+\u0000\u0000\u00a9"+ - "\u0012\u0001\u0000\u0000\u0000\u00aa\u00ab\u0005*\u0000\u0000\u00ab\u0014"+ - "\u0001\u0000\u0000\u0000\u00ac\u00ad\u0005/\u0000\u0000\u00ad\u0016\u0001"+ - "\u0000\u0000\u0000\u00ae\u00af\u0005%\u0000\u0000\u00af\u0018\u0001\u0000"+ - "\u0000\u0000\u00b0\u00b1\u0005>\u0000\u0000\u00b1\u001a\u0001\u0000\u0000"+ - "\u0000\u00b2\u00b3\u0005<\u0000\u0000\u00b3\u001c\u0001\u0000\u0000\u0000"+ - "\u00b4\u00b5\u0005>\u0000\u0000\u00b5\u00b6\u0005=\u0000\u0000\u00b6\u001e"+ - "\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005<\u0000\u0000\u00b8\u00b9\u0005"+ - "=\u0000\u0000\u00b9 \u0001\u0000\u0000\u0000\u00ba\u00bb\u0005=\u0000"+ - "\u0000\u00bb\u00bc\u0005=\u0000\u0000\u00bc\"\u0001\u0000\u0000\u0000"+ - "\u00bd\u00be\u0005!\u0000\u0000\u00be\u00bf\u0005=\u0000\u0000\u00bf$"+ - "\u0001\u0000\u0000\u0000\u00c0\u00c1\u0005!\u0000\u0000\u00c1&\u0001\u0000"+ - "\u0000\u0000\u00c2\u00c3\u0005&\u0000\u0000\u00c3\u00c4\u0005&\u0000\u0000"+ - "\u00c4(\u0001\u0000\u0000\u0000\u00c5\u00c6\u0005|\u0000\u0000\u00c6\u00c7"+ - "\u0005|\u0000\u0000\u00c7*\u0001\u0000\u0000\u0000\u00c8\u00c9\u0005."+ - "\u0000\u0000\u00c9,\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005(\u0000\u0000"+ - "\u00cb.\u0001\u0000\u0000\u0000\u00cc\u00cd\u0005)\u0000\u0000\u00cd0"+ - "\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005{\u0000\u0000\u00cf2\u0001\u0000"+ - "\u0000\u0000\u00d0\u00d1\u0005}\u0000\u0000\u00d14\u0001\u0000\u0000\u0000"+ - "\u00d2\u00d3\u0005;\u0000\u0000\u00d36\u0001\u0000\u0000\u0000\u00d4\u00d5"+ - "\u0005,\u0000\u0000\u00d58\u0001\u0000\u0000\u0000\u00d6\u00d7\u0005c"+ - "\u0000\u0000\u00d7\u00d8\u0005l\u0000\u0000\u00d8\u00d9\u0005a\u0000\u0000"+ - "\u00d9\u00da\u0005s\u0000\u0000\u00da\u00db\u0005s\u0000\u0000\u00db:"+ - "\u0001\u0000\u0000\u0000\u00dc\u00dd\u0005t\u0000\u0000\u00dd\u00de\u0005"+ - "h\u0000\u0000\u00de\u00df\u0005i\u0000\u0000\u00df\u00e0\u0005s\u0000"+ - "\u0000\u00e0<\u0001\u0000\u0000\u0000\u00e1\u00e2\u0005w\u0000\u0000\u00e2"+ - "\u00e3\u0005h\u0000\u0000\u00e3\u00e4\u0005i\u0000\u0000\u00e4\u00e5\u0005"+ - "l\u0000\u0000\u00e5\u00e6\u0005e\u0000\u0000\u00e6>\u0001\u0000\u0000"+ - "\u0000\u00e7\u00e8\u0005i\u0000\u0000\u00e8\u00e9\u0005f\u0000\u0000\u00e9"+ - "@\u0001\u0000\u0000\u0000\u00ea\u00eb\u0005e\u0000\u0000\u00eb\u00ec\u0005"+ - "l\u0000\u0000\u00ec\u00ed\u0005s\u0000\u0000\u00ed\u00ee\u0005e\u0000"+ - "\u0000\u00eeB\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005r\u0000\u0000\u00f0"+ - "\u00f1\u0005e\u0000\u0000\u00f1\u00f2\u0005t\u0000\u0000\u00f2\u00f3\u0005"+ - "u\u0000\u0000\u00f3\u00f4\u0005r\u0000\u0000\u00f4\u00f5\u0005n\u0000"+ - "\u0000\u00f5D\u0001\u0000\u0000\u0000\u00f6\u00f7\u0005n\u0000\u0000\u00f7"+ - "\u00f8\u0005e\u0000\u0000\u00f8\u00f9\u0005w\u0000\u0000\u00f9F\u0001"+ - "\u0000\u0000\u0000\u00fa\u00fb\u0007\u0000\u0000\u0000\u00fbH\u0001\u0000"+ - "\u0000\u0000\u00fc\u00fd\u0007\u0001\u0000\u0000\u00fdJ\u0001\u0000\u0000"+ - "\u0000\u00fe\u0102\u0003G#\u0000\u00ff\u0102\u0003I$\u0000\u0100\u0102"+ - "\u0007\u0002\u0000\u0000\u0101\u00fe\u0001\u0000\u0000\u0000\u0101\u00ff"+ - "\u0001\u0000\u0000\u0000\u0101\u0100\u0001\u0000\u0000\u0000\u0102L\u0001"+ - "\u0000\u0000\u0000\u0103\u0107\u0003G#\u0000\u0104\u0106\u0003K%\u0000"+ - "\u0105\u0104\u0001\u0000\u0000\u0000\u0106\u0109\u0001\u0000\u0000\u0000"+ - "\u0107\u0105\u0001\u0000\u0000\u0000\u0107\u0108\u0001\u0000\u0000\u0000"+ - "\u0108N\u0001\u0000\u0000\u0000\u0109\u0107\u0001\u0000\u0000\u0000\u010a"+ - "\u010b\u0005v\u0000\u0000\u010b\u010c\u0005o\u0000\u0000\u010c\u010d\u0005"+ - "i\u0000\u0000\u010d\u010e\u0005d\u0000\u0000\u010eP\u0001\u0000\u0000"+ - "\u0000\u010f\u0110\u0005i\u0000\u0000\u0110\u0111\u0005n\u0000\u0000\u0111"+ - "\u0112\u0005t\u0000\u0000\u0112R\u0001\u0000\u0000\u0000\u0113\u0114\u0005"+ - "b\u0000\u0000\u0114\u0115\u0005o\u0000\u0000\u0115\u0116\u0005o\u0000"+ - "\u0000\u0116\u0117\u0005l\u0000\u0000\u0117T\u0001\u0000\u0000\u0000\u0118"+ - "\u0119\u0005c\u0000\u0000\u0119\u011a\u0005h\u0000\u0000\u011a\u011b\u0005"+ - "a\u0000\u0000\u011b\u011c\u0005r\u0000\u0000\u011cV\u0001\u0000\u0000"+ - "\u0000\u011d\u011f\u0007\u0003\u0000\u0000\u011e\u011d\u0001\u0000\u0000"+ - "\u0000\u011f\u0122\u0001\u0000\u0000\u0000\u0120\u011e\u0001\u0000\u0000"+ - "\u0000\u0120\u0121\u0001\u0000\u0000\u0000\u0121\u0124\u0001\u0000\u0000"+ - "\u0000\u0122\u0120\u0001\u0000\u0000\u0000\u0123\u0125\u0007\u0001\u0000"+ - "\u0000\u0124\u0123\u0001\u0000\u0000\u0000\u0125\u0126\u0001\u0000\u0000"+ - "\u0000\u0126\u0124\u0001\u0000\u0000\u0000\u0126\u0127\u0001\u0000\u0000"+ - "\u0000\u0127X\u0001\u0000\u0000\u0000\u0128\u012a\u0005\'\u0000\u0000"+ - "\u0129\u012b\b\u0004\u0000\u0000\u012a\u0129\u0001\u0000\u0000\u0000\u012a"+ - "\u012b\u0001\u0000\u0000\u0000\u012b\u012c\u0001\u0000\u0000\u0000\u012c"+ - "\u012d\u0005\'\u0000\u0000\u012dZ\u0001\u0000\u0000\u0000\u012e\u012f"+ - "\u0005t\u0000\u0000\u012f\u0130\u0005r\u0000\u0000\u0130\u0131\u0005u"+ - "\u0000\u0000\u0131\u0138\u0005e\u0000\u0000\u0132\u0133\u0005f\u0000\u0000"+ - "\u0133\u0134\u0005a\u0000\u0000\u0134\u0135\u0005l\u0000\u0000\u0135\u0136"+ - "\u0005s\u0000\u0000\u0136\u0138\u0005e\u0000\u0000\u0137\u012e\u0001\u0000"+ - "\u0000\u0000\u0137\u0132\u0001\u0000\u0000\u0000\u0138\\\u0001\u0000\u0000"+ - "\u0000\u0139\u013a\u0005n\u0000\u0000\u013a\u013b\u0005u\u0000\u0000\u013b"+ - "\u013c\u0005l\u0000\u0000\u013c\u013d\u0005l\u0000\u0000\u013d^\u0001"+ - "\u0000\u0000\u0000\u013e\u013f\u0007\u0005\u0000\u0000\u013f\u0140\u0001"+ - "\u0000\u0000\u0000\u0140\u0141\u0006/\u0000\u0000\u0141`\u0001\u0000\u0000"+ - "\u0000\u000b\u0000\u0092\u0096\u009e\u00a2\u0101\u0107\u0120\u0126\u012a"+ - "\u0137\u0001\u0006\u0000\u0000"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/Source/gen/DecafLexer.tokens b/Source/gen/DecafLexer.tokens deleted file mode 100644 index 6873c36..0000000 --- a/Source/gen/DecafLexer.tokens +++ /dev/null @@ -1,81 +0,0 @@ -AccessModifierPublic=1 -MainMethodDecl=2 -DotOperator=3 -LineOperator=4 -ComparisonOperator=5 -LogicalOpertor=6 -Assign=7 -Minus=8 -Plus=9 -Multipilkation=10 -Division=11 -Modulo=12 -Greater=13 -Less=14 -GreaterEqual=15 -LessEqual=16 -Equal=17 -NotEqual=18 -Not=19 -And=20 -Or=21 -Dot=22 -OpenRoundBracket=23 -ClosedRoundBracket=24 -OpenCurlyBracket=25 -ClosedCurlyBracket=26 -Semicolon=27 -Comma=28 -Class=29 -This=30 -While=31 -If=32 -Else=33 -Return=34 -New=35 -Identifier=36 -Void=37 -Int=38 -Boolean=39 -Char=40 -IntValue=41 -CharValue=42 -BooleanValue=43 -NullValue=44 -WS=45 -'public'=1 -'public static void main(String[] args)'=2 -'='=7 -'-'=8 -'+'=9 -'*'=10 -'/'=11 -'%'=12 -'>'=13 -'<'=14 -'>='=15 -'<='=16 -'=='=17 -'!='=18 -'!'=19 -'&&'=20 -'||'=21 -'.'=22 -'('=23 -')'=24 -'{'=25 -'}'=26 -';'=27 -','=28 -'class'=29 -'this'=30 -'while'=31 -'if'=32 -'else'=33 -'return'=34 -'new'=35 -'void'=37 -'int'=38 -'bool'=39 -'char'=40 -'null'=44 diff --git a/Source/gen/DecafListener.java b/Source/gen/DecafListener.java deleted file mode 100644 index 4e2702f..0000000 --- a/Source/gen/DecafListener.java +++ /dev/null @@ -1,359 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 -import org.antlr.v4.runtime.tree.ParseTreeListener; - -/** - * This interface defines a complete listener for a parse tree produced by - * {@link DecafParser}. - */ -public interface DecafListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link DecafParser#program}. - * @param ctx the parse tree - */ - void enterProgram(DecafParser.ProgramContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#program}. - * @param ctx the parse tree - */ - void exitProgram(DecafParser.ProgramContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#classdecl}. - * @param ctx the parse tree - */ - void enterClassdecl(DecafParser.ClassdeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#classdecl}. - * @param ctx the parse tree - */ - void exitClassdecl(DecafParser.ClassdeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#constuctorDecl}. - * @param ctx the parse tree - */ - void enterConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#constuctorDecl}. - * @param ctx the parse tree - */ - void exitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#methodDecl}. - * @param ctx the parse tree - */ - void enterMethodDecl(DecafParser.MethodDeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#methodDecl}. - * @param ctx the parse tree - */ - void exitMethodDecl(DecafParser.MethodDeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#fieldDecl}. - * @param ctx the parse tree - */ - void enterFieldDecl(DecafParser.FieldDeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#fieldDecl}. - * @param ctx the parse tree - */ - void exitFieldDecl(DecafParser.FieldDeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#parameterList}. - * @param ctx the parse tree - */ - void enterParameterList(DecafParser.ParameterListContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#parameterList}. - * @param ctx the parse tree - */ - void exitParameterList(DecafParser.ParameterListContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#parameter}. - * @param ctx the parse tree - */ - void enterParameter(DecafParser.ParameterContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#parameter}. - * @param ctx the parse tree - */ - void exitParameter(DecafParser.ParameterContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#expression}. - * @param ctx the parse tree - */ - void enterExpression(DecafParser.ExpressionContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#expression}. - * @param ctx the parse tree - */ - void exitExpression(DecafParser.ExpressionContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#subExpression}. - * @param ctx the parse tree - */ - void enterSubExpression(DecafParser.SubExpressionContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#subExpression}. - * @param ctx the parse tree - */ - void exitSubExpression(DecafParser.SubExpressionContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#assignableExpr}. - * @param ctx the parse tree - */ - void enterAssignableExpr(DecafParser.AssignableExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#assignableExpr}. - * @param ctx the parse tree - */ - void exitAssignableExpr(DecafParser.AssignableExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#instVar}. - * @param ctx the parse tree - */ - void enterInstVar(DecafParser.InstVarContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#instVar}. - * @param ctx the parse tree - */ - void exitInstVar(DecafParser.InstVarContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#methodCall}. - * @param ctx the parse tree - */ - void enterMethodCall(DecafParser.MethodCallContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#methodCall}. - * @param ctx the parse tree - */ - void exitMethodCall(DecafParser.MethodCallContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#argumentList}. - * @param ctx the parse tree - */ - void enterArgumentList(DecafParser.ArgumentListContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#argumentList}. - * @param ctx the parse tree - */ - void exitArgumentList(DecafParser.ArgumentListContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#subReceiver}. - * @param ctx the parse tree - */ - void enterSubReceiver(DecafParser.SubReceiverContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#subReceiver}. - * @param ctx the parse tree - */ - void exitSubReceiver(DecafParser.SubReceiverContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#receiver}. - * @param ctx the parse tree - */ - void enterReceiver(DecafParser.ReceiverContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#receiver}. - * @param ctx the parse tree - */ - void exitReceiver(DecafParser.ReceiverContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#receivingMethod}. - * @param ctx the parse tree - */ - void enterReceivingMethod(DecafParser.ReceivingMethodContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#receivingMethod}. - * @param ctx the parse tree - */ - void exitReceivingMethod(DecafParser.ReceivingMethodContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#binaryExpr}. - * @param ctx the parse tree - */ - void enterBinaryExpr(DecafParser.BinaryExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#binaryExpr}. - * @param ctx the parse tree - */ - void exitBinaryExpr(DecafParser.BinaryExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#calcExpr}. - * @param ctx the parse tree - */ - void enterCalcExpr(DecafParser.CalcExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#calcExpr}. - * @param ctx the parse tree - */ - void exitCalcExpr(DecafParser.CalcExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#dotExpr}. - * @param ctx the parse tree - */ - void enterDotExpr(DecafParser.DotExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#dotExpr}. - * @param ctx the parse tree - */ - void exitDotExpr(DecafParser.DotExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#dotSubExpr}. - * @param ctx the parse tree - */ - void enterDotSubExpr(DecafParser.DotSubExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#dotSubExpr}. - * @param ctx the parse tree - */ - void exitDotSubExpr(DecafParser.DotSubExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#nonCalcExpr}. - * @param ctx the parse tree - */ - void enterNonCalcExpr(DecafParser.NonCalcExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#nonCalcExpr}. - * @param ctx the parse tree - */ - void exitNonCalcExpr(DecafParser.NonCalcExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#nonCalcOperator}. - * @param ctx the parse tree - */ - void enterNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#nonCalcOperator}. - * @param ctx the parse tree - */ - void exitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#stmtExpr}. - * @param ctx the parse tree - */ - void enterStmtExpr(DecafParser.StmtExprContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#stmtExpr}. - * @param ctx the parse tree - */ - void exitStmtExpr(DecafParser.StmtExprContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#statement}. - * @param ctx the parse tree - */ - void enterStatement(DecafParser.StatementContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#statement}. - * @param ctx the parse tree - */ - void exitStatement(DecafParser.StatementContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#returnStmt}. - * @param ctx the parse tree - */ - void enterReturnStmt(DecafParser.ReturnStmtContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#returnStmt}. - * @param ctx the parse tree - */ - void exitReturnStmt(DecafParser.ReturnStmtContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#localVarDecl}. - * @param ctx the parse tree - */ - void enterLocalVarDecl(DecafParser.LocalVarDeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#localVarDecl}. - * @param ctx the parse tree - */ - void exitLocalVarDecl(DecafParser.LocalVarDeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#block}. - * @param ctx the parse tree - */ - void enterBlock(DecafParser.BlockContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#block}. - * @param ctx the parse tree - */ - void exitBlock(DecafParser.BlockContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#whileStmt}. - * @param ctx the parse tree - */ - void enterWhileStmt(DecafParser.WhileStmtContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#whileStmt}. - * @param ctx the parse tree - */ - void exitWhileStmt(DecafParser.WhileStmtContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#ifElseStmt}. - * @param ctx the parse tree - */ - void enterIfElseStmt(DecafParser.IfElseStmtContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#ifElseStmt}. - * @param ctx the parse tree - */ - void exitIfElseStmt(DecafParser.IfElseStmtContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#ifStmt}. - * @param ctx the parse tree - */ - void enterIfStmt(DecafParser.IfStmtContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#ifStmt}. - * @param ctx the parse tree - */ - void exitIfStmt(DecafParser.IfStmtContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#elseStmt}. - * @param ctx the parse tree - */ - void enterElseStmt(DecafParser.ElseStmtContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#elseStmt}. - * @param ctx the parse tree - */ - void exitElseStmt(DecafParser.ElseStmtContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#assign}. - * @param ctx the parse tree - */ - void enterAssign(DecafParser.AssignContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#assign}. - * @param ctx the parse tree - */ - void exitAssign(DecafParser.AssignContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#newDecl}. - * @param ctx the parse tree - */ - void enterNewDecl(DecafParser.NewDeclContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#newDecl}. - * @param ctx the parse tree - */ - void exitNewDecl(DecafParser.NewDeclContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#type}. - * @param ctx the parse tree - */ - void enterType(DecafParser.TypeContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#type}. - * @param ctx the parse tree - */ - void exitType(DecafParser.TypeContext ctx); - /** - * Enter a parse tree produced by {@link DecafParser#value}. - * @param ctx the parse tree - */ - void enterValue(DecafParser.ValueContext ctx); - /** - * Exit a parse tree produced by {@link DecafParser#value}. - * @param ctx the parse tree - */ - void exitValue(DecafParser.ValueContext ctx); -} \ No newline at end of file diff --git a/Source/gen/DecafParser.java b/Source/gen/DecafParser.java deleted file mode 100644 index f46dc11..0000000 --- a/Source/gen/DecafParser.java +++ /dev/null @@ -1,2864 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.misc.*; -import org.antlr.v4.runtime.tree.*; -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) -public class DecafParser extends Parser { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - AccessModifierPublic=1, MainMethodDecl=2, DotOperator=3, LineOperator=4, - ComparisonOperator=5, LogicalOpertor=6, Assign=7, Minus=8, Plus=9, Multipilkation=10, - Division=11, Modulo=12, Greater=13, Less=14, GreaterEqual=15, LessEqual=16, - Equal=17, NotEqual=18, Not=19, And=20, Or=21, Dot=22, OpenRoundBracket=23, - ClosedRoundBracket=24, OpenCurlyBracket=25, ClosedCurlyBracket=26, Semicolon=27, - Comma=28, Class=29, This=30, While=31, If=32, Else=33, Return=34, New=35, - Identifier=36, Void=37, Int=38, Boolean=39, Char=40, IntValue=41, CharValue=42, - BooleanValue=43, NullValue=44, WS=45; - public static final int - RULE_program = 0, RULE_classdecl = 1, RULE_constuctorDecl = 2, RULE_methodDecl = 3, - RULE_fieldDecl = 4, RULE_parameterList = 5, RULE_parameter = 6, RULE_expression = 7, - RULE_subExpression = 8, RULE_assignableExpr = 9, RULE_instVar = 10, RULE_methodCall = 11, - RULE_argumentList = 12, RULE_subReceiver = 13, RULE_receiver = 14, RULE_receivingMethod = 15, - RULE_binaryExpr = 16, RULE_calcExpr = 17, RULE_dotExpr = 18, RULE_dotSubExpr = 19, - RULE_nonCalcExpr = 20, RULE_nonCalcOperator = 21, RULE_stmtExpr = 22, - RULE_statement = 23, RULE_returnStmt = 24, RULE_localVarDecl = 25, RULE_block = 26, - RULE_whileStmt = 27, RULE_ifElseStmt = 28, RULE_ifStmt = 29, RULE_elseStmt = 30, - RULE_assign = 31, RULE_newDecl = 32, RULE_type = 33, RULE_value = 34; - private static String[] makeRuleNames() { - return new String[] { - "program", "classdecl", "constuctorDecl", "methodDecl", "fieldDecl", - "parameterList", "parameter", "expression", "subExpression", "assignableExpr", - "instVar", "methodCall", "argumentList", "subReceiver", "receiver", "receivingMethod", - "binaryExpr", "calcExpr", "dotExpr", "dotSubExpr", "nonCalcExpr", "nonCalcOperator", - "stmtExpr", "statement", "returnStmt", "localVarDecl", "block", "whileStmt", - "ifElseStmt", "ifStmt", "elseStmt", "assign", "newDecl", "type", "value" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'public'", "'public static void main(String[] args)'", null, null, - null, null, "'='", "'-'", "'+'", "'*'", "'/'", "'%'", "'>'", "'<'", "'>='", - "'<='", "'=='", "'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", - "'}'", "';'", "','", "'class'", "'this'", "'while'", "'if'", "'else'", - "'return'", "'new'", null, "'void'", "'int'", "'bool'", "'char'", null, - null, null, "'null'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "AccessModifierPublic", "MainMethodDecl", "DotOperator", "LineOperator", - "ComparisonOperator", "LogicalOpertor", "Assign", "Minus", "Plus", "Multipilkation", - "Division", "Modulo", "Greater", "Less", "GreaterEqual", "LessEqual", - "Equal", "NotEqual", "Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket", - "OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class", - "This", "While", "If", "Else", "Return", "New", "Identifier", "Void", - "Int", "Boolean", "Char", "IntValue", "CharValue", "BooleanValue", "NullValue", - "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] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "Decaf.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public DecafParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @SuppressWarnings("CheckReturnValue") - public static class ProgramContext extends ParserRuleContext { - public List classdecl() { - return getRuleContexts(ClassdeclContext.class); - } - public ClassdeclContext classdecl(int i) { - return getRuleContext(ClassdeclContext.class,i); - } - public ProgramContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_program; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterProgram(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitProgram(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitProgram(this); - else return visitor.visitChildren(this); - } - } - - public final ProgramContext program() throws RecognitionException { - ProgramContext _localctx = new ProgramContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_program); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(71); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(70); - classdecl(); - } - } - setState(73); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==AccessModifierPublic || _la==Class ); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ClassdeclContext extends ParserRuleContext { - public TerminalNode Class() { return getToken(DecafParser.Class, 0); } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenCurlyBracket() { return getToken(DecafParser.OpenCurlyBracket, 0); } - public TerminalNode ClosedCurlyBracket() { return getToken(DecafParser.ClosedCurlyBracket, 0); } - public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } - public List constuctorDecl() { - return getRuleContexts(ConstuctorDeclContext.class); - } - public ConstuctorDeclContext constuctorDecl(int i) { - return getRuleContext(ConstuctorDeclContext.class,i); - } - public List fieldDecl() { - return getRuleContexts(FieldDeclContext.class); - } - public FieldDeclContext fieldDecl(int i) { - return getRuleContext(FieldDeclContext.class,i); - } - public List methodDecl() { - return getRuleContexts(MethodDeclContext.class); - } - public MethodDeclContext methodDecl(int i) { - return getRuleContext(MethodDeclContext.class,i); - } - public TerminalNode MainMethodDecl() { return getToken(DecafParser.MainMethodDecl, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public ClassdeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_classdecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterClassdecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitClassdecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitClassdecl(this); - else return visitor.visitChildren(this); - } - } - - public final ClassdeclContext classdecl() throws RecognitionException { - ClassdeclContext _localctx = new ClassdeclContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_classdecl); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(76); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifierPublic) { - { - setState(75); - match(AccessModifierPublic); - } - } - - setState(78); - match(Class); - setState(79); - match(Identifier); - setState(80); - match(OpenCurlyBracket); - setState(86); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2130303778818L) != 0)) { - { - setState(84); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { - case 1: - { - setState(81); - constuctorDecl(); - } - break; - case 2: - { - setState(82); - fieldDecl(); - } - break; - case 3: - { - setState(83); - methodDecl(); - } - break; - } - } - setState(88); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(91); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==MainMethodDecl) { - { - setState(89); - match(MainMethodDecl); - setState(90); - block(); - } - } - - setState(93); - match(ClosedCurlyBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ConstuctorDeclContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } - public ParameterListContext parameterList() { - return getRuleContext(ParameterListContext.class,0); - } - public ConstuctorDeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_constuctorDecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterConstuctorDecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitConstuctorDecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitConstuctorDecl(this); - else return visitor.visitChildren(this); - } - } - - public final ConstuctorDeclContext constuctorDecl() throws RecognitionException { - ConstuctorDeclContext _localctx = new ConstuctorDeclContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_constuctorDecl); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(96); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifierPublic) { - { - setState(95); - match(AccessModifierPublic); - } - } - - setState(98); - match(Identifier); - setState(99); - match(OpenRoundBracket); - setState(101); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) { - { - setState(100); - parameterList(); - } - } - - setState(103); - match(ClosedRoundBracket); - setState(104); - block(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MethodDeclContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Void() { return getToken(DecafParser.Void, 0); } - public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } - public ParameterListContext parameterList() { - return getRuleContext(ParameterListContext.class,0); - } - public MethodDeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_methodDecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterMethodDecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitMethodDecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitMethodDecl(this); - else return visitor.visitChildren(this); - } - } - - public final MethodDeclContext methodDecl() throws RecognitionException { - MethodDeclContext _localctx = new MethodDeclContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_methodDecl); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(107); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifierPublic) { - { - setState(106); - match(AccessModifierPublic); - } - } - - setState(111); - _errHandler.sync(this); - switch (_input.LA(1)) { - case Identifier: - case Int: - case Boolean: - case Char: - { - setState(109); - type(); - } - break; - case Void: - { - setState(110); - match(Void); - } - break; - default: - throw new NoViableAltException(this); - } - setState(113); - match(Identifier); - setState(114); - match(OpenRoundBracket); - setState(116); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) { - { - setState(115); - parameterList(); - } - } - - setState(118); - match(ClosedRoundBracket); - setState(119); - block(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class FieldDeclContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode Semicolon() { return getToken(DecafParser.Semicolon, 0); } - public TerminalNode AccessModifierPublic() { return getToken(DecafParser.AccessModifierPublic, 0); } - public FieldDeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldDecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFieldDecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFieldDecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFieldDecl(this); - else return visitor.visitChildren(this); - } - } - - public final FieldDeclContext fieldDecl() throws RecognitionException { - FieldDeclContext _localctx = new FieldDeclContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_fieldDecl); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(122); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AccessModifierPublic) { - { - setState(121); - match(AccessModifierPublic); - } - } - - setState(124); - type(); - setState(125); - match(Identifier); - setState(126); - match(Semicolon); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ParameterListContext extends ParserRuleContext { - public List parameter() { - return getRuleContexts(ParameterContext.class); - } - public ParameterContext parameter(int i) { - return getRuleContext(ParameterContext.class,i); - } - public List Comma() { return getTokens(DecafParser.Comma); } - public TerminalNode Comma(int i) { - return getToken(DecafParser.Comma, i); - } - public ParameterListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameterList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParameterList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParameterList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParameterList(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterListContext parameterList() throws RecognitionException { - ParameterListContext _localctx = new ParameterListContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_parameterList); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(128); - parameter(); - setState(133); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==Comma) { - { - { - setState(129); - match(Comma); - setState(130); - parameter(); - } - } - setState(135); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ParameterContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public ParameterContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameter; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParameter(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParameter(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParameter(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterContext parameter() throws RecognitionException { - ParameterContext _localctx = new ParameterContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_parameter); - try { - enterOuterAlt(_localctx, 1); - { - setState(136); - type(); - setState(137); - match(Identifier); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ExpressionContext extends ParserRuleContext { - public SubExpressionContext subExpression() { - return getRuleContext(SubExpressionContext.class,0); - } - public BinaryExprContext binaryExpr() { - return getRuleContext(BinaryExprContext.class,0); - } - public ExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitExpression(this); - else return visitor.visitChildren(this); - } - } - - public final ExpressionContext expression() throws RecognitionException { - ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_expression); - try { - setState(141); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,12,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(139); - subExpression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(140); - binaryExpr(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class SubExpressionContext extends ParserRuleContext { - public TerminalNode This() { return getToken(DecafParser.This, 0); } - public AssignableExprContext assignableExpr() { - return getRuleContext(AssignableExprContext.class,0); - } - public StmtExprContext stmtExpr() { - return getRuleContext(StmtExprContext.class,0); - } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public SubExpressionContext subExpression() { - return getRuleContext(SubExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public SubExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_subExpression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterSubExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitSubExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitSubExpression(this); - else return visitor.visitChildren(this); - } - } - - public final SubExpressionContext subExpression() throws RecognitionException { - SubExpressionContext _localctx = new SubExpressionContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_subExpression); - try { - setState(150); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,13,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(143); - match(This); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(144); - assignableExpr(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(145); - stmtExpr(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(146); - match(OpenRoundBracket); - setState(147); - subExpression(); - setState(148); - match(ClosedRoundBracket); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AssignableExprContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public InstVarContext instVar() { - return getRuleContext(InstVarContext.class,0); - } - public AssignableExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assignableExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterAssignableExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitAssignableExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitAssignableExpr(this); - else return visitor.visitChildren(this); - } - } - - public final AssignableExprContext assignableExpr() throws RecognitionException { - AssignableExprContext _localctx = new AssignableExprContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_assignableExpr); - try { - setState(154); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(152); - match(Identifier); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(153); - instVar(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class InstVarContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public SubReceiverContext subReceiver() { - return getRuleContext(SubReceiverContext.class,0); - } - public List receivingMethod() { - return getRuleContexts(ReceivingMethodContext.class); - } - public ReceivingMethodContext receivingMethod(int i) { - return getRuleContext(ReceivingMethodContext.class,i); - } - public InstVarContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_instVar; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterInstVar(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitInstVar(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitInstVar(this); - else return visitor.visitChildren(this); - } - } - - public final InstVarContext instVar() throws RecognitionException { - InstVarContext _localctx = new InstVarContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_instVar); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(157); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,15,_ctx) ) { - case 1: - { - setState(156); - subReceiver(); - } - break; - } - setState(162); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,16,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(159); - receivingMethod(); - } - } - } - setState(164); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,16,_ctx); - } - setState(165); - match(Identifier); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class MethodCallContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public ReceiverContext receiver() { - return getRuleContext(ReceiverContext.class,0); - } - public List receivingMethod() { - return getRuleContexts(ReceivingMethodContext.class); - } - public ReceivingMethodContext receivingMethod(int i) { - return getRuleContext(ReceivingMethodContext.class,i); - } - public MethodCallContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_methodCall; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterMethodCall(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitMethodCall(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitMethodCall(this); - else return visitor.visitChildren(this); - } - } - - public final MethodCallContext methodCall() throws RecognitionException { - MethodCallContext _localctx = new MethodCallContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_methodCall); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(168); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) { - case 1: - { - setState(167); - receiver(); - } - break; - } - setState(173); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,18,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(170); - receivingMethod(); - } - } - } - setState(175); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,18,_ctx); - } - setState(176); - match(Identifier); - setState(177); - match(OpenRoundBracket); - setState(178); - argumentList(); - setState(179); - match(ClosedRoundBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ArgumentListContext extends ParserRuleContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public List Comma() { return getTokens(DecafParser.Comma); } - public TerminalNode Comma(int i) { - return getToken(DecafParser.Comma, i); - } - public ArgumentListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_argumentList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterArgumentList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitArgumentList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitArgumentList(this); - else return visitor.visitChildren(this); - } - } - - public final ArgumentListContext argumentList() throws RecognitionException { - ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_argumentList); - int _la; - try { - setState(191); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(182); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 33089510703104L) != 0)) { - { - setState(181); - expression(); - } - } - - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(184); - expression(); - setState(187); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(185); - match(Comma); - setState(186); - expression(); - } - } - setState(189); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==Comma ); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class SubReceiverContext extends ParserRuleContext { - public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } - public TerminalNode This() { return getToken(DecafParser.This, 0); } - public NewDeclContext newDecl() { - return getRuleContext(NewDeclContext.class,0); - } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public SubReceiverContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_subReceiver; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterSubReceiver(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitSubReceiver(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitSubReceiver(this); - else return visitor.visitChildren(this); - } - } - - public final SubReceiverContext subReceiver() throws RecognitionException { - SubReceiverContext _localctx = new SubReceiverContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_subReceiver); - try { - enterOuterAlt(_localctx, 1); - { - { - setState(196); - _errHandler.sync(this); - switch (_input.LA(1)) { - case This: - { - setState(193); - match(This); - } - break; - case New: - { - setState(194); - newDecl(); - } - break; - case Identifier: - { - setState(195); - match(Identifier); - } - break; - default: - throw new NoViableAltException(this); - } - setState(198); - match(Dot); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReceiverContext extends ParserRuleContext { - public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } - public TerminalNode This() { return getToken(DecafParser.This, 0); } - public InstVarContext instVar() { - return getRuleContext(InstVarContext.class,0); - } - public NewDeclContext newDecl() { - return getRuleContext(NewDeclContext.class,0); - } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public ReceiverContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_receiver; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReceiver(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReceiver(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReceiver(this); - else return visitor.visitChildren(this); - } - } - - public final ReceiverContext receiver() throws RecognitionException { - ReceiverContext _localctx = new ReceiverContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_receiver); - try { - enterOuterAlt(_localctx, 1); - { - { - setState(204); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { - case 1: - { - setState(200); - match(This); - } - break; - case 2: - { - setState(201); - instVar(); - } - break; - case 3: - { - setState(202); - newDecl(); - } - break; - case 4: - { - setState(203); - match(Identifier); - } - break; - } - setState(206); - match(Dot); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReceivingMethodContext extends ParserRuleContext { - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public TerminalNode Dot() { return getToken(DecafParser.Dot, 0); } - public ReceivingMethodContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_receivingMethod; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReceivingMethod(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReceivingMethod(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReceivingMethod(this); - else return visitor.visitChildren(this); - } - } - - public final ReceivingMethodContext receivingMethod() throws RecognitionException { - ReceivingMethodContext _localctx = new ReceivingMethodContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_receivingMethod); - try { - enterOuterAlt(_localctx, 1); - { - setState(208); - match(Identifier); - setState(209); - match(OpenRoundBracket); - setState(210); - argumentList(); - setState(211); - match(ClosedRoundBracket); - setState(212); - match(Dot); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class BinaryExprContext extends ParserRuleContext { - public CalcExprContext calcExpr() { - return getRuleContext(CalcExprContext.class,0); - } - public NonCalcExprContext nonCalcExpr() { - return getRuleContext(NonCalcExprContext.class,0); - } - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public TerminalNode Not() { return getToken(DecafParser.Not, 0); } - public BinaryExprContext binaryExpr() { - return getRuleContext(BinaryExprContext.class,0); - } - public BinaryExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_binaryExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBinaryExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBinaryExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBinaryExpr(this); - else return visitor.visitChildren(this); - } - } - - public final BinaryExprContext binaryExpr() throws RecognitionException { - BinaryExprContext _localctx = new BinaryExprContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_binaryExpr); - try { - setState(219); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(214); - calcExpr(0); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(215); - nonCalcExpr(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(216); - value(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(217); - match(Not); - setState(218); - binaryExpr(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class CalcExprContext extends ParserRuleContext { - public DotExprContext dotExpr() { - return getRuleContext(DotExprContext.class,0); - } - public CalcExprContext calcExpr() { - return getRuleContext(CalcExprContext.class,0); - } - public TerminalNode LineOperator() { return getToken(DecafParser.LineOperator, 0); } - public CalcExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_calcExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterCalcExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitCalcExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitCalcExpr(this); - else return visitor.visitChildren(this); - } - } - - public final CalcExprContext calcExpr() throws RecognitionException { - return calcExpr(0); - } - - private CalcExprContext calcExpr(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - CalcExprContext _localctx = new CalcExprContext(_ctx, _parentState); - CalcExprContext _prevctx = _localctx; - int _startState = 34; - enterRecursionRule(_localctx, 34, RULE_calcExpr, _p); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - { - setState(222); - dotExpr(0); - } - _ctx.stop = _input.LT(-1); - setState(229); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,25,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new CalcExprContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_calcExpr); - setState(224); - if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(225); - match(LineOperator); - setState(226); - dotExpr(0); - } - } - } - setState(231); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,25,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DotExprContext extends ParserRuleContext { - public DotSubExprContext dotSubExpr() { - return getRuleContext(DotSubExprContext.class,0); - } - public DotExprContext dotExpr() { - return getRuleContext(DotExprContext.class,0); - } - public TerminalNode DotOperator() { return getToken(DecafParser.DotOperator, 0); } - public DotExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_dotExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterDotExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitDotExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitDotExpr(this); - else return visitor.visitChildren(this); - } - } - - public final DotExprContext dotExpr() throws RecognitionException { - return dotExpr(0); - } - - private DotExprContext dotExpr(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - DotExprContext _localctx = new DotExprContext(_ctx, _parentState); - DotExprContext _prevctx = _localctx; - int _startState = 36; - enterRecursionRule(_localctx, 36, RULE_dotExpr, _p); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - { - setState(233); - dotSubExpr(); - } - _ctx.stop = _input.LT(-1); - setState(240); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,26,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new DotExprContext(_parentctx, _parentState); - pushNewRecursionContext(_localctx, _startState, RULE_dotExpr); - setState(235); - if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(236); - match(DotOperator); - setState(237); - dotSubExpr(); - } - } - } - setState(242); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,26,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DotSubExprContext extends ParserRuleContext { - public TerminalNode IntValue() { return getToken(DecafParser.IntValue, 0); } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public InstVarContext instVar() { - return getRuleContext(InstVarContext.class,0); - } - public MethodCallContext methodCall() { - return getRuleContext(MethodCallContext.class,0); - } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public CalcExprContext calcExpr() { - return getRuleContext(CalcExprContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public DotSubExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_dotSubExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterDotSubExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitDotSubExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitDotSubExpr(this); - else return visitor.visitChildren(this); - } - } - - public final DotSubExprContext dotSubExpr() throws RecognitionException { - DotSubExprContext _localctx = new DotSubExprContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_dotSubExpr); - try { - setState(251); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(243); - match(IntValue); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(244); - match(Identifier); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(245); - instVar(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(246); - methodCall(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(247); - match(OpenRoundBracket); - setState(248); - calcExpr(0); - setState(249); - match(ClosedRoundBracket); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NonCalcExprContext extends ParserRuleContext { - public SubExpressionContext subExpression() { - return getRuleContext(SubExpressionContext.class,0); - } - public NonCalcOperatorContext nonCalcOperator() { - return getRuleContext(NonCalcOperatorContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public NonCalcExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nonCalcExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNonCalcExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNonCalcExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNonCalcExpr(this); - else return visitor.visitChildren(this); - } - } - - public final NonCalcExprContext nonCalcExpr() throws RecognitionException { - NonCalcExprContext _localctx = new NonCalcExprContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_nonCalcExpr); - try { - enterOuterAlt(_localctx, 1); - { - setState(253); - subExpression(); - setState(254); - nonCalcOperator(); - setState(255); - expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NonCalcOperatorContext extends ParserRuleContext { - public TerminalNode LogicalOpertor() { return getToken(DecafParser.LogicalOpertor, 0); } - public TerminalNode ComparisonOperator() { return getToken(DecafParser.ComparisonOperator, 0); } - public NonCalcOperatorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nonCalcOperator; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNonCalcOperator(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNonCalcOperator(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNonCalcOperator(this); - else return visitor.visitChildren(this); - } - } - - public final NonCalcOperatorContext nonCalcOperator() throws RecognitionException { - NonCalcOperatorContext _localctx = new NonCalcOperatorContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_nonCalcOperator); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(257); - _la = _input.LA(1); - if ( !(_la==ComparisonOperator || _la==LogicalOpertor) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class StmtExprContext extends ParserRuleContext { - public AssignContext assign() { - return getRuleContext(AssignContext.class,0); - } - public NewDeclContext newDecl() { - return getRuleContext(NewDeclContext.class,0); - } - public MethodCallContext methodCall() { - return getRuleContext(MethodCallContext.class,0); - } - public StmtExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_stmtExpr; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterStmtExpr(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitStmtExpr(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitStmtExpr(this); - else return visitor.visitChildren(this); - } - } - - public final StmtExprContext stmtExpr() throws RecognitionException { - StmtExprContext _localctx = new StmtExprContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_stmtExpr); - try { - setState(262); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(259); - assign(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(260); - newDecl(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(261); - methodCall(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class StatementContext extends ParserRuleContext { - public ReturnStmtContext returnStmt() { - return getRuleContext(ReturnStmtContext.class,0); - } - public TerminalNode Semicolon() { return getToken(DecafParser.Semicolon, 0); } - public LocalVarDeclContext localVarDecl() { - return getRuleContext(LocalVarDeclContext.class,0); - } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public WhileStmtContext whileStmt() { - return getRuleContext(WhileStmtContext.class,0); - } - public IfElseStmtContext ifElseStmt() { - return getRuleContext(IfElseStmtContext.class,0); - } - public StmtExprContext stmtExpr() { - return getRuleContext(StmtExprContext.class,0); - } - public StatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_statement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitStatement(this); - else return visitor.visitChildren(this); - } - } - - public final StatementContext statement() throws RecognitionException { - StatementContext _localctx = new StatementContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_statement); - try { - setState(276); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,29,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(264); - returnStmt(); - setState(265); - match(Semicolon); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(267); - localVarDecl(); - setState(268); - match(Semicolon); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(270); - block(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(271); - whileStmt(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(272); - ifElseStmt(); - } - break; - case 6: - enterOuterAlt(_localctx, 6); - { - setState(273); - stmtExpr(); - setState(274); - match(Semicolon); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReturnStmtContext extends ParserRuleContext { - public TerminalNode Return() { return getToken(DecafParser.Return, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ReturnStmtContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_returnStmt; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReturnStmt(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReturnStmt(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReturnStmt(this); - else return visitor.visitChildren(this); - } - } - - public final ReturnStmtContext returnStmt() throws RecognitionException { - ReturnStmtContext _localctx = new ReturnStmtContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_returnStmt); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(278); - match(Return); - setState(280); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 33089510703104L) != 0)) { - { - setState(279); - expression(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class LocalVarDeclContext extends ParserRuleContext { - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode Assign() { return getToken(DecafParser.Assign, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public LocalVarDeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_localVarDecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterLocalVarDecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitLocalVarDecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitLocalVarDecl(this); - else return visitor.visitChildren(this); - } - } - - public final LocalVarDeclContext localVarDecl() throws RecognitionException { - LocalVarDeclContext _localctx = new LocalVarDeclContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_localVarDecl); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(282); - type(); - setState(283); - match(Identifier); - setState(286); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==Assign) { - { - setState(284); - match(Assign); - setState(285); - expression(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class BlockContext extends ParserRuleContext { - public TerminalNode OpenCurlyBracket() { return getToken(DecafParser.OpenCurlyBracket, 0); } - public TerminalNode ClosedCurlyBracket() { return getToken(DecafParser.ClosedCurlyBracket, 0); } - public List statement() { - return getRuleContexts(StatementContext.class); - } - public StatementContext statement(int i) { - return getRuleContext(StatementContext.class,i); - } - public BlockContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_block; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBlock(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBlock(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBlock(this); - else return visitor.visitChildren(this); - } - } - - public final BlockContext block() throws RecognitionException { - BlockContext _localctx = new BlockContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_block); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(288); - match(OpenCurlyBracket); - setState(292); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2051954180096L) != 0)) { - { - { - setState(289); - statement(); - } - } - setState(294); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(295); - match(ClosedCurlyBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class WhileStmtContext extends ParserRuleContext { - public TerminalNode While() { return getToken(DecafParser.While, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public WhileStmtContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_whileStmt; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterWhileStmt(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitWhileStmt(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitWhileStmt(this); - else return visitor.visitChildren(this); - } - } - - public final WhileStmtContext whileStmt() throws RecognitionException { - WhileStmtContext _localctx = new WhileStmtContext(_ctx, getState()); - enterRule(_localctx, 54, RULE_whileStmt); - try { - enterOuterAlt(_localctx, 1); - { - setState(297); - match(While); - setState(298); - match(OpenRoundBracket); - setState(299); - expression(); - setState(300); - match(ClosedRoundBracket); - setState(301); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IfElseStmtContext extends ParserRuleContext { - public IfStmtContext ifStmt() { - return getRuleContext(IfStmtContext.class,0); - } - public ElseStmtContext elseStmt() { - return getRuleContext(ElseStmtContext.class,0); - } - public IfElseStmtContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifElseStmt; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterIfElseStmt(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitIfElseStmt(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitIfElseStmt(this); - else return visitor.visitChildren(this); - } - } - - public final IfElseStmtContext ifElseStmt() throws RecognitionException { - IfElseStmtContext _localctx = new IfElseStmtContext(_ctx, getState()); - enterRule(_localctx, 56, RULE_ifElseStmt); - try { - enterOuterAlt(_localctx, 1); - { - setState(303); - ifStmt(); - setState(305); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,33,_ctx) ) { - case 1: - { - setState(304); - elseStmt(); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IfStmtContext extends ParserRuleContext { - public TerminalNode If() { return getToken(DecafParser.If, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public IfStmtContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifStmt; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterIfStmt(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitIfStmt(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitIfStmt(this); - else return visitor.visitChildren(this); - } - } - - public final IfStmtContext ifStmt() throws RecognitionException { - IfStmtContext _localctx = new IfStmtContext(_ctx, getState()); - enterRule(_localctx, 58, RULE_ifStmt); - try { - enterOuterAlt(_localctx, 1); - { - setState(307); - match(If); - setState(308); - match(OpenRoundBracket); - setState(309); - expression(); - setState(310); - match(ClosedRoundBracket); - setState(311); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ElseStmtContext extends ParserRuleContext { - public TerminalNode Else() { return getToken(DecafParser.Else, 0); } - public StatementContext statement() { - return getRuleContext(StatementContext.class,0); - } - public ElseStmtContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_elseStmt; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterElseStmt(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitElseStmt(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitElseStmt(this); - else return visitor.visitChildren(this); - } - } - - public final ElseStmtContext elseStmt() throws RecognitionException { - ElseStmtContext _localctx = new ElseStmtContext(_ctx, getState()); - enterRule(_localctx, 60, RULE_elseStmt); - try { - enterOuterAlt(_localctx, 1); - { - setState(313); - match(Else); - setState(314); - statement(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AssignContext extends ParserRuleContext { - public AssignableExprContext assignableExpr() { - return getRuleContext(AssignableExprContext.class,0); - } - public TerminalNode Assign() { return getToken(DecafParser.Assign, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public AssignContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assign; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterAssign(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitAssign(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitAssign(this); - else return visitor.visitChildren(this); - } - } - - public final AssignContext assign() throws RecognitionException { - AssignContext _localctx = new AssignContext(_ctx, getState()); - enterRule(_localctx, 62, RULE_assign); - try { - enterOuterAlt(_localctx, 1); - { - setState(316); - assignableExpr(); - setState(317); - match(Assign); - setState(318); - expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class NewDeclContext extends ParserRuleContext { - public TerminalNode New() { return getToken(DecafParser.New, 0); } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TerminalNode OpenRoundBracket() { return getToken(DecafParser.OpenRoundBracket, 0); } - public ArgumentListContext argumentList() { - return getRuleContext(ArgumentListContext.class,0); - } - public TerminalNode ClosedRoundBracket() { return getToken(DecafParser.ClosedRoundBracket, 0); } - public NewDeclContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_newDecl; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNewDecl(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNewDecl(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNewDecl(this); - else return visitor.visitChildren(this); - } - } - - public final NewDeclContext newDecl() throws RecognitionException { - NewDeclContext _localctx = new NewDeclContext(_ctx, getState()); - enterRule(_localctx, 64, RULE_newDecl); - try { - enterOuterAlt(_localctx, 1); - { - setState(320); - match(New); - setState(321); - match(Identifier); - setState(322); - match(OpenRoundBracket); - setState(323); - argumentList(); - setState(324); - match(ClosedRoundBracket); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class TypeContext extends ParserRuleContext { - public TerminalNode Int() { return getToken(DecafParser.Int, 0); } - public TerminalNode Boolean() { return getToken(DecafParser.Boolean, 0); } - public TerminalNode Char() { return getToken(DecafParser.Char, 0); } - public TerminalNode Identifier() { return getToken(DecafParser.Identifier, 0); } - public TypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_type; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitType(this); - else return visitor.visitChildren(this); - } - } - - public final TypeContext type() throws RecognitionException { - TypeContext _localctx = new TypeContext(_ctx, getState()); - enterRule(_localctx, 66, RULE_type); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(326); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 1992864825344L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValueContext extends ParserRuleContext { - public TerminalNode IntValue() { return getToken(DecafParser.IntValue, 0); } - public TerminalNode BooleanValue() { return getToken(DecafParser.BooleanValue, 0); } - public TerminalNode CharValue() { return getToken(DecafParser.CharValue, 0); } - public TerminalNode NullValue() { return getToken(DecafParser.NullValue, 0); } - public ValueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).enterValue(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof DecafListener ) ((DecafListener)listener).exitValue(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitValue(this); - else return visitor.visitChildren(this); - } - } - - public final ValueContext value() throws RecognitionException { - ValueContext _localctx = new ValueContext(_ctx, getState()); - enterRule(_localctx, 68, RULE_value); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(328); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 32985348833280L) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 17: - return calcExpr_sempred((CalcExprContext)_localctx, predIndex); - case 18: - return dotExpr_sempred((DotExprContext)_localctx, predIndex); - } - return true; - } - private boolean calcExpr_sempred(CalcExprContext _localctx, int predIndex) { - switch (predIndex) { - case 0: - return precpred(_ctx, 2); - } - return true; - } - private boolean dotExpr_sempred(DotExprContext _localctx, int predIndex) { - switch (predIndex) { - case 1: - return precpred(_ctx, 2); - } - return true; - } - - public static final String _serializedATN = - "\u0004\u0001-\u014b\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\"\u0001"+ - "\u0000\u0004\u0000H\b\u0000\u000b\u0000\f\u0000I\u0001\u0001\u0003\u0001"+ - "M\b\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0005\u0001U\b\u0001\n\u0001\f\u0001X\t\u0001\u0001\u0001"+ - "\u0001\u0001\u0003\u0001\\\b\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ - "\u0003\u0002a\b\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002"+ - "f\b\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0003\u0003"+ - "l\b\u0003\u0001\u0003\u0001\u0003\u0003\u0003p\b\u0003\u0001\u0003\u0001"+ - "\u0003\u0001\u0003\u0003\u0003u\b\u0003\u0001\u0003\u0001\u0003\u0001"+ - "\u0003\u0001\u0004\u0003\u0004{\b\u0004\u0001\u0004\u0001\u0004\u0001"+ - "\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0005\u0005\u0084"+ - "\b\u0005\n\u0005\f\u0005\u0087\t\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0007\u0001\u0007\u0003\u0007\u008e\b\u0007\u0001\b\u0001\b\u0001"+ - "\b\u0001\b\u0001\b\u0001\b\u0001\b\u0003\b\u0097\b\b\u0001\t\u0001\t\u0003"+ - "\t\u009b\b\t\u0001\n\u0003\n\u009e\b\n\u0001\n\u0005\n\u00a1\b\n\n\n\f"+ - "\n\u00a4\t\n\u0001\n\u0001\n\u0001\u000b\u0003\u000b\u00a9\b\u000b\u0001"+ - "\u000b\u0005\u000b\u00ac\b\u000b\n\u000b\f\u000b\u00af\t\u000b\u0001\u000b"+ - "\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\f\u0003\f\u00b7"+ - "\b\f\u0001\f\u0001\f\u0001\f\u0004\f\u00bc\b\f\u000b\f\f\f\u00bd\u0003"+ - "\f\u00c0\b\f\u0001\r\u0001\r\u0001\r\u0003\r\u00c5\b\r\u0001\r\u0001\r"+ - "\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0003\u000e\u00cd\b\u000e"+ - "\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f"+ - "\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010"+ - "\u0001\u0010\u0003\u0010\u00dc\b\u0010\u0001\u0011\u0001\u0011\u0001\u0011"+ - "\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011\u00e4\b\u0011\n\u0011"+ - "\f\u0011\u00e7\t\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0005\u0012\u00ef\b\u0012\n\u0012\f\u0012\u00f2"+ - "\t\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001"+ - "\u0013\u0001\u0013\u0001\u0013\u0003\u0013\u00fc\b\u0013\u0001\u0014\u0001"+ - "\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+ - "\u0016\u0001\u0016\u0003\u0016\u0107\b\u0016\u0001\u0017\u0001\u0017\u0001"+ - "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001"+ - "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0003\u0017\u0115\b\u0017\u0001"+ - "\u0018\u0001\u0018\u0003\u0018\u0119\b\u0018\u0001\u0019\u0001\u0019\u0001"+ - "\u0019\u0001\u0019\u0003\u0019\u011f\b\u0019\u0001\u001a\u0001\u001a\u0005"+ - "\u001a\u0123\b\u001a\n\u001a\f\u001a\u0126\t\u001a\u0001\u001a\u0001\u001a"+ - "\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b"+ - "\u0001\u001c\u0001\u001c\u0003\u001c\u0132\b\u001c\u0001\u001d\u0001\u001d"+ - "\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e"+ - "\u0001\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001 \u0001"+ - " \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0000"+ - "\u0002\"$#\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016"+ - "\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BD\u0000\u0003\u0001\u0000\u0005"+ - "\u0006\u0002\u0000$$&(\u0001\u0000),\u0159\u0000G\u0001\u0000\u0000\u0000"+ - "\u0002L\u0001\u0000\u0000\u0000\u0004`\u0001\u0000\u0000\u0000\u0006k"+ - "\u0001\u0000\u0000\u0000\bz\u0001\u0000\u0000\u0000\n\u0080\u0001\u0000"+ - "\u0000\u0000\f\u0088\u0001\u0000\u0000\u0000\u000e\u008d\u0001\u0000\u0000"+ - "\u0000\u0010\u0096\u0001\u0000\u0000\u0000\u0012\u009a\u0001\u0000\u0000"+ - "\u0000\u0014\u009d\u0001\u0000\u0000\u0000\u0016\u00a8\u0001\u0000\u0000"+ - "\u0000\u0018\u00bf\u0001\u0000\u0000\u0000\u001a\u00c4\u0001\u0000\u0000"+ - "\u0000\u001c\u00cc\u0001\u0000\u0000\u0000\u001e\u00d0\u0001\u0000\u0000"+ - "\u0000 \u00db\u0001\u0000\u0000\u0000\"\u00dd\u0001\u0000\u0000\u0000"+ - "$\u00e8\u0001\u0000\u0000\u0000&\u00fb\u0001\u0000\u0000\u0000(\u00fd"+ - "\u0001\u0000\u0000\u0000*\u0101\u0001\u0000\u0000\u0000,\u0106\u0001\u0000"+ - "\u0000\u0000.\u0114\u0001\u0000\u0000\u00000\u0116\u0001\u0000\u0000\u0000"+ - "2\u011a\u0001\u0000\u0000\u00004\u0120\u0001\u0000\u0000\u00006\u0129"+ - "\u0001\u0000\u0000\u00008\u012f\u0001\u0000\u0000\u0000:\u0133\u0001\u0000"+ - "\u0000\u0000<\u0139\u0001\u0000\u0000\u0000>\u013c\u0001\u0000\u0000\u0000"+ - "@\u0140\u0001\u0000\u0000\u0000B\u0146\u0001\u0000\u0000\u0000D\u0148"+ - "\u0001\u0000\u0000\u0000FH\u0003\u0002\u0001\u0000GF\u0001\u0000\u0000"+ - "\u0000HI\u0001\u0000\u0000\u0000IG\u0001\u0000\u0000\u0000IJ\u0001\u0000"+ - "\u0000\u0000J\u0001\u0001\u0000\u0000\u0000KM\u0005\u0001\u0000\u0000"+ - "LK\u0001\u0000\u0000\u0000LM\u0001\u0000\u0000\u0000MN\u0001\u0000\u0000"+ - "\u0000NO\u0005\u001d\u0000\u0000OP\u0005$\u0000\u0000PV\u0005\u0019\u0000"+ - "\u0000QU\u0003\u0004\u0002\u0000RU\u0003\b\u0004\u0000SU\u0003\u0006\u0003"+ - "\u0000TQ\u0001\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TS\u0001\u0000"+ - "\u0000\u0000UX\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000VW\u0001"+ - "\u0000\u0000\u0000W[\u0001\u0000\u0000\u0000XV\u0001\u0000\u0000\u0000"+ - "YZ\u0005\u0002\u0000\u0000Z\\\u00034\u001a\u0000[Y\u0001\u0000\u0000\u0000"+ - "[\\\u0001\u0000\u0000\u0000\\]\u0001\u0000\u0000\u0000]^\u0005\u001a\u0000"+ - "\u0000^\u0003\u0001\u0000\u0000\u0000_a\u0005\u0001\u0000\u0000`_\u0001"+ - "\u0000\u0000\u0000`a\u0001\u0000\u0000\u0000ab\u0001\u0000\u0000\u0000"+ - "bc\u0005$\u0000\u0000ce\u0005\u0017\u0000\u0000df\u0003\n\u0005\u0000"+ - "ed\u0001\u0000\u0000\u0000ef\u0001\u0000\u0000\u0000fg\u0001\u0000\u0000"+ - "\u0000gh\u0005\u0018\u0000\u0000hi\u00034\u001a\u0000i\u0005\u0001\u0000"+ - "\u0000\u0000jl\u0005\u0001\u0000\u0000kj\u0001\u0000\u0000\u0000kl\u0001"+ - "\u0000\u0000\u0000lo\u0001\u0000\u0000\u0000mp\u0003B!\u0000np\u0005%"+ - "\u0000\u0000om\u0001\u0000\u0000\u0000on\u0001\u0000\u0000\u0000pq\u0001"+ - "\u0000\u0000\u0000qr\u0005$\u0000\u0000rt\u0005\u0017\u0000\u0000su\u0003"+ - "\n\u0005\u0000ts\u0001\u0000\u0000\u0000tu\u0001\u0000\u0000\u0000uv\u0001"+ - "\u0000\u0000\u0000vw\u0005\u0018\u0000\u0000wx\u00034\u001a\u0000x\u0007"+ - "\u0001\u0000\u0000\u0000y{\u0005\u0001\u0000\u0000zy\u0001\u0000\u0000"+ - "\u0000z{\u0001\u0000\u0000\u0000{|\u0001\u0000\u0000\u0000|}\u0003B!\u0000"+ - "}~\u0005$\u0000\u0000~\u007f\u0005\u001b\u0000\u0000\u007f\t\u0001\u0000"+ - "\u0000\u0000\u0080\u0085\u0003\f\u0006\u0000\u0081\u0082\u0005\u001c\u0000"+ - "\u0000\u0082\u0084\u0003\f\u0006\u0000\u0083\u0081\u0001\u0000\u0000\u0000"+ - "\u0084\u0087\u0001\u0000\u0000\u0000\u0085\u0083\u0001\u0000\u0000\u0000"+ - "\u0085\u0086\u0001\u0000\u0000\u0000\u0086\u000b\u0001\u0000\u0000\u0000"+ - "\u0087\u0085\u0001\u0000\u0000\u0000\u0088\u0089\u0003B!\u0000\u0089\u008a"+ - "\u0005$\u0000\u0000\u008a\r\u0001\u0000\u0000\u0000\u008b\u008e\u0003"+ - "\u0010\b\u0000\u008c\u008e\u0003 \u0010\u0000\u008d\u008b\u0001\u0000"+ - "\u0000\u0000\u008d\u008c\u0001\u0000\u0000\u0000\u008e\u000f\u0001\u0000"+ - "\u0000\u0000\u008f\u0097\u0005\u001e\u0000\u0000\u0090\u0097\u0003\u0012"+ - "\t\u0000\u0091\u0097\u0003,\u0016\u0000\u0092\u0093\u0005\u0017\u0000"+ - "\u0000\u0093\u0094\u0003\u0010\b\u0000\u0094\u0095\u0005\u0018\u0000\u0000"+ - "\u0095\u0097\u0001\u0000\u0000\u0000\u0096\u008f\u0001\u0000\u0000\u0000"+ - "\u0096\u0090\u0001\u0000\u0000\u0000\u0096\u0091\u0001\u0000\u0000\u0000"+ - "\u0096\u0092\u0001\u0000\u0000\u0000\u0097\u0011\u0001\u0000\u0000\u0000"+ - "\u0098\u009b\u0005$\u0000\u0000\u0099\u009b\u0003\u0014\n\u0000\u009a"+ - "\u0098\u0001\u0000\u0000\u0000\u009a\u0099\u0001\u0000\u0000\u0000\u009b"+ - "\u0013\u0001\u0000\u0000\u0000\u009c\u009e\u0003\u001a\r\u0000\u009d\u009c"+ - "\u0001\u0000\u0000\u0000\u009d\u009e\u0001\u0000\u0000\u0000\u009e\u00a2"+ - "\u0001\u0000\u0000\u0000\u009f\u00a1\u0003\u001e\u000f\u0000\u00a0\u009f"+ - "\u0001\u0000\u0000\u0000\u00a1\u00a4\u0001\u0000\u0000\u0000\u00a2\u00a0"+ - "\u0001\u0000\u0000\u0000\u00a2\u00a3\u0001\u0000\u0000\u0000\u00a3\u00a5"+ - "\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000\u0000\u00a5\u00a6"+ - "\u0005$\u0000\u0000\u00a6\u0015\u0001\u0000\u0000\u0000\u00a7\u00a9\u0003"+ - "\u001c\u000e\u0000\u00a8\u00a7\u0001\u0000\u0000\u0000\u00a8\u00a9\u0001"+ - "\u0000\u0000\u0000\u00a9\u00ad\u0001\u0000\u0000\u0000\u00aa\u00ac\u0003"+ - "\u001e\u000f\u0000\u00ab\u00aa\u0001\u0000\u0000\u0000\u00ac\u00af\u0001"+ - "\u0000\u0000\u0000\u00ad\u00ab\u0001\u0000\u0000\u0000\u00ad\u00ae\u0001"+ - "\u0000\u0000\u0000\u00ae\u00b0\u0001\u0000\u0000\u0000\u00af\u00ad\u0001"+ - "\u0000\u0000\u0000\u00b0\u00b1\u0005$\u0000\u0000\u00b1\u00b2\u0005\u0017"+ - "\u0000\u0000\u00b2\u00b3\u0003\u0018\f\u0000\u00b3\u00b4\u0005\u0018\u0000"+ - "\u0000\u00b4\u0017\u0001\u0000\u0000\u0000\u00b5\u00b7\u0003\u000e\u0007"+ - "\u0000\u00b6\u00b5\u0001\u0000\u0000\u0000\u00b6\u00b7\u0001\u0000\u0000"+ - "\u0000\u00b7\u00c0\u0001\u0000\u0000\u0000\u00b8\u00bb\u0003\u000e\u0007"+ - "\u0000\u00b9\u00ba\u0005\u001c\u0000\u0000\u00ba\u00bc\u0003\u000e\u0007"+ - "\u0000\u00bb\u00b9\u0001\u0000\u0000\u0000\u00bc\u00bd\u0001\u0000\u0000"+ - "\u0000\u00bd\u00bb\u0001\u0000\u0000\u0000\u00bd\u00be\u0001\u0000\u0000"+ - "\u0000\u00be\u00c0\u0001\u0000\u0000\u0000\u00bf\u00b6\u0001\u0000\u0000"+ - "\u0000\u00bf\u00b8\u0001\u0000\u0000\u0000\u00c0\u0019\u0001\u0000\u0000"+ - "\u0000\u00c1\u00c5\u0005\u001e\u0000\u0000\u00c2\u00c5\u0003@ \u0000\u00c3"+ - "\u00c5\u0005$\u0000\u0000\u00c4\u00c1\u0001\u0000\u0000\u0000\u00c4\u00c2"+ - "\u0001\u0000\u0000\u0000\u00c4\u00c3\u0001\u0000\u0000\u0000\u00c5\u00c6"+ - "\u0001\u0000\u0000\u0000\u00c6\u00c7\u0005\u0016\u0000\u0000\u00c7\u001b"+ - "\u0001\u0000\u0000\u0000\u00c8\u00cd\u0005\u001e\u0000\u0000\u00c9\u00cd"+ - "\u0003\u0014\n\u0000\u00ca\u00cd\u0003@ \u0000\u00cb\u00cd\u0005$\u0000"+ - "\u0000\u00cc\u00c8\u0001\u0000\u0000\u0000\u00cc\u00c9\u0001\u0000\u0000"+ - "\u0000\u00cc\u00ca\u0001\u0000\u0000\u0000\u00cc\u00cb\u0001\u0000\u0000"+ - "\u0000\u00cd\u00ce\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005\u0016\u0000"+ - "\u0000\u00cf\u001d\u0001\u0000\u0000\u0000\u00d0\u00d1\u0005$\u0000\u0000"+ - "\u00d1\u00d2\u0005\u0017\u0000\u0000\u00d2\u00d3\u0003\u0018\f\u0000\u00d3"+ - "\u00d4\u0005\u0018\u0000\u0000\u00d4\u00d5\u0005\u0016\u0000\u0000\u00d5"+ - "\u001f\u0001\u0000\u0000\u0000\u00d6\u00dc\u0003\"\u0011\u0000\u00d7\u00dc"+ - "\u0003(\u0014\u0000\u00d8\u00dc\u0003D\"\u0000\u00d9\u00da\u0005\u0013"+ - "\u0000\u0000\u00da\u00dc\u0003 \u0010\u0000\u00db\u00d6\u0001\u0000\u0000"+ - "\u0000\u00db\u00d7\u0001\u0000\u0000\u0000\u00db\u00d8\u0001\u0000\u0000"+ - "\u0000\u00db\u00d9\u0001\u0000\u0000\u0000\u00dc!\u0001\u0000\u0000\u0000"+ - "\u00dd\u00de\u0006\u0011\uffff\uffff\u0000\u00de\u00df\u0003$\u0012\u0000"+ - "\u00df\u00e5\u0001\u0000\u0000\u0000\u00e0\u00e1\n\u0002\u0000\u0000\u00e1"+ - "\u00e2\u0005\u0004\u0000\u0000\u00e2\u00e4\u0003$\u0012\u0000\u00e3\u00e0"+ - "\u0001\u0000\u0000\u0000\u00e4\u00e7\u0001\u0000\u0000\u0000\u00e5\u00e3"+ - "\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000\u0000\u00e6#\u0001"+ - "\u0000\u0000\u0000\u00e7\u00e5\u0001\u0000\u0000\u0000\u00e8\u00e9\u0006"+ - "\u0012\uffff\uffff\u0000\u00e9\u00ea\u0003&\u0013\u0000\u00ea\u00f0\u0001"+ - "\u0000\u0000\u0000\u00eb\u00ec\n\u0002\u0000\u0000\u00ec\u00ed\u0005\u0003"+ - "\u0000\u0000\u00ed\u00ef\u0003&\u0013\u0000\u00ee\u00eb\u0001\u0000\u0000"+ - "\u0000\u00ef\u00f2\u0001\u0000\u0000\u0000\u00f0\u00ee\u0001\u0000\u0000"+ - "\u0000\u00f0\u00f1\u0001\u0000\u0000\u0000\u00f1%\u0001\u0000\u0000\u0000"+ - "\u00f2\u00f0\u0001\u0000\u0000\u0000\u00f3\u00fc\u0005)\u0000\u0000\u00f4"+ - "\u00fc\u0005$\u0000\u0000\u00f5\u00fc\u0003\u0014\n\u0000\u00f6\u00fc"+ - "\u0003\u0016\u000b\u0000\u00f7\u00f8\u0005\u0017\u0000\u0000\u00f8\u00f9"+ - "\u0003\"\u0011\u0000\u00f9\u00fa\u0005\u0018\u0000\u0000\u00fa\u00fc\u0001"+ - "\u0000\u0000\u0000\u00fb\u00f3\u0001\u0000\u0000\u0000\u00fb\u00f4\u0001"+ - "\u0000\u0000\u0000\u00fb\u00f5\u0001\u0000\u0000\u0000\u00fb\u00f6\u0001"+ - "\u0000\u0000\u0000\u00fb\u00f7\u0001\u0000\u0000\u0000\u00fc\'\u0001\u0000"+ - "\u0000\u0000\u00fd\u00fe\u0003\u0010\b\u0000\u00fe\u00ff\u0003*\u0015"+ - "\u0000\u00ff\u0100\u0003\u000e\u0007\u0000\u0100)\u0001\u0000\u0000\u0000"+ - "\u0101\u0102\u0007\u0000\u0000\u0000\u0102+\u0001\u0000\u0000\u0000\u0103"+ - "\u0107\u0003>\u001f\u0000\u0104\u0107\u0003@ \u0000\u0105\u0107\u0003"+ - "\u0016\u000b\u0000\u0106\u0103\u0001\u0000\u0000\u0000\u0106\u0104\u0001"+ - "\u0000\u0000\u0000\u0106\u0105\u0001\u0000\u0000\u0000\u0107-\u0001\u0000"+ - "\u0000\u0000\u0108\u0109\u00030\u0018\u0000\u0109\u010a\u0005\u001b\u0000"+ - "\u0000\u010a\u0115\u0001\u0000\u0000\u0000\u010b\u010c\u00032\u0019\u0000"+ - "\u010c\u010d\u0005\u001b\u0000\u0000\u010d\u0115\u0001\u0000\u0000\u0000"+ - "\u010e\u0115\u00034\u001a\u0000\u010f\u0115\u00036\u001b\u0000\u0110\u0115"+ - "\u00038\u001c\u0000\u0111\u0112\u0003,\u0016\u0000\u0112\u0113\u0005\u001b"+ - "\u0000\u0000\u0113\u0115\u0001\u0000\u0000\u0000\u0114\u0108\u0001\u0000"+ - "\u0000\u0000\u0114\u010b\u0001\u0000\u0000\u0000\u0114\u010e\u0001\u0000"+ - "\u0000\u0000\u0114\u010f\u0001\u0000\u0000\u0000\u0114\u0110\u0001\u0000"+ - "\u0000\u0000\u0114\u0111\u0001\u0000\u0000\u0000\u0115/\u0001\u0000\u0000"+ - "\u0000\u0116\u0118\u0005\"\u0000\u0000\u0117\u0119\u0003\u000e\u0007\u0000"+ - "\u0118\u0117\u0001\u0000\u0000\u0000\u0118\u0119\u0001\u0000\u0000\u0000"+ - "\u01191\u0001\u0000\u0000\u0000\u011a\u011b\u0003B!\u0000\u011b\u011e"+ - "\u0005$\u0000\u0000\u011c\u011d\u0005\u0007\u0000\u0000\u011d\u011f\u0003"+ - "\u000e\u0007\u0000\u011e\u011c\u0001\u0000\u0000\u0000\u011e\u011f\u0001"+ - "\u0000\u0000\u0000\u011f3\u0001\u0000\u0000\u0000\u0120\u0124\u0005\u0019"+ - "\u0000\u0000\u0121\u0123\u0003.\u0017\u0000\u0122\u0121\u0001\u0000\u0000"+ - "\u0000\u0123\u0126\u0001\u0000\u0000\u0000\u0124\u0122\u0001\u0000\u0000"+ - "\u0000\u0124\u0125\u0001\u0000\u0000\u0000\u0125\u0127\u0001\u0000\u0000"+ - "\u0000\u0126\u0124\u0001\u0000\u0000\u0000\u0127\u0128\u0005\u001a\u0000"+ - "\u0000\u01285\u0001\u0000\u0000\u0000\u0129\u012a\u0005\u001f\u0000\u0000"+ - "\u012a\u012b\u0005\u0017\u0000\u0000\u012b\u012c\u0003\u000e\u0007\u0000"+ - "\u012c\u012d\u0005\u0018\u0000\u0000\u012d\u012e\u0003.\u0017\u0000\u012e"+ - "7\u0001\u0000\u0000\u0000\u012f\u0131\u0003:\u001d\u0000\u0130\u0132\u0003"+ - "<\u001e\u0000\u0131\u0130\u0001\u0000\u0000\u0000\u0131\u0132\u0001\u0000"+ - "\u0000\u0000\u01329\u0001\u0000\u0000\u0000\u0133\u0134\u0005 \u0000\u0000"+ - "\u0134\u0135\u0005\u0017\u0000\u0000\u0135\u0136\u0003\u000e\u0007\u0000"+ - "\u0136\u0137\u0005\u0018\u0000\u0000\u0137\u0138\u0003.\u0017\u0000\u0138"+ - ";\u0001\u0000\u0000\u0000\u0139\u013a\u0005!\u0000\u0000\u013a\u013b\u0003"+ - ".\u0017\u0000\u013b=\u0001\u0000\u0000\u0000\u013c\u013d\u0003\u0012\t"+ - "\u0000\u013d\u013e\u0005\u0007\u0000\u0000\u013e\u013f\u0003\u000e\u0007"+ - "\u0000\u013f?\u0001\u0000\u0000\u0000\u0140\u0141\u0005#\u0000\u0000\u0141"+ - "\u0142\u0005$\u0000\u0000\u0142\u0143\u0005\u0017\u0000\u0000\u0143\u0144"+ - "\u0003\u0018\f\u0000\u0144\u0145\u0005\u0018\u0000\u0000\u0145A\u0001"+ - "\u0000\u0000\u0000\u0146\u0147\u0007\u0001\u0000\u0000\u0147C\u0001\u0000"+ - "\u0000\u0000\u0148\u0149\u0007\u0002\u0000\u0000\u0149E\u0001\u0000\u0000"+ - "\u0000\"ILTV[`ekotz\u0085\u008d\u0096\u009a\u009d\u00a2\u00a8\u00ad\u00b6"+ - "\u00bd\u00bf\u00c4\u00cc\u00db\u00e5\u00f0\u00fb\u0106\u0114\u0118\u011e"+ - "\u0124\u0131"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/Source/gen/DecafVisitor.java b/Source/gen/DecafVisitor.java deleted file mode 100644 index e9a524c..0000000 --- a/Source/gen/DecafVisitor.java +++ /dev/null @@ -1,222 +0,0 @@ -package gen;// Generated from C:/Users/dh10krj/OneDrive - Durr Group/Dokumente/S4/Compilerbau/projekt/NichtHaskell/Source/Decaf.g4 by ANTLR 4.13.1 -import org.antlr.v4.runtime.tree.ParseTreeVisitor; - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link DecafParser}. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface DecafVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link DecafParser#program}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitProgram(DecafParser.ProgramContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#classdecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitClassdecl(DecafParser.ClassdeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#constuctorDecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#methodDecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMethodDecl(DecafParser.MethodDeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#fieldDecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFieldDecl(DecafParser.FieldDeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#parameterList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameterList(DecafParser.ParameterListContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#parameter}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameter(DecafParser.ParameterContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpression(DecafParser.ExpressionContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#subExpression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSubExpression(DecafParser.SubExpressionContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#assignableExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssignableExpr(DecafParser.AssignableExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#instVar}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitInstVar(DecafParser.InstVarContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#methodCall}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMethodCall(DecafParser.MethodCallContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#argumentList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArgumentList(DecafParser.ArgumentListContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#subReceiver}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSubReceiver(DecafParser.SubReceiverContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#receiver}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReceiver(DecafParser.ReceiverContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#receivingMethod}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReceivingMethod(DecafParser.ReceivingMethodContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#binaryExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBinaryExpr(DecafParser.BinaryExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#calcExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCalcExpr(DecafParser.CalcExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#dotExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDotExpr(DecafParser.DotExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#dotSubExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDotSubExpr(DecafParser.DotSubExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#nonCalcExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNonCalcExpr(DecafParser.NonCalcExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#nonCalcOperator}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#stmtExpr}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStmtExpr(DecafParser.StmtExprContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStatement(DecafParser.StatementContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#returnStmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReturnStmt(DecafParser.ReturnStmtContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#localVarDecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#block}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBlock(DecafParser.BlockContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#whileStmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitWhileStmt(DecafParser.WhileStmtContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#ifElseStmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfElseStmt(DecafParser.IfElseStmtContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#ifStmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfStmt(DecafParser.IfStmtContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#elseStmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitElseStmt(DecafParser.ElseStmtContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#assign}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssign(DecafParser.AssignContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#newDecl}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNewDecl(DecafParser.NewDeclContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitType(DecafParser.TypeContext ctx); - /** - * Visit a parse tree produced by {@link DecafParser#value}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValue(DecafParser.ValueContext ctx); -} \ No newline at end of file From 9166d87afdde15bf099d6d258fb09bbd8c3af9e4 Mon Sep 17 00:00:00 2001 From: David Mueller Date: Thu, 9 May 2024 16:08:07 +0200 Subject: [PATCH 5/5] Changes to the Grammar --- .idea/compiler.xml | 4 ++- .idea/misc.xml | 1 - src/main/java/Decaf.g4 | 60 ++++++++++++++++++++++-------------------- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 8643296..1181d5e 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,8 +6,10 @@ - + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0e338d8..6ddae43 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/Decaf.g4 b/src/main/java/Decaf.g4 index 2af8297..28887f3 100644 --- a/src/main/java/Decaf.g4 +++ b/src/main/java/Decaf.g4 @@ -3,32 +3,33 @@ grammar Decaf; program: classdecl+; //class identifier{...} -classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; -constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method without +classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|localVarDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; +constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method and FieldVar methodDecl: AccessModifierPublic? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; -fieldDecl: AccessModifierPublic? type Identifier Semicolon; //Parameters parameterList: parameter(Comma parameter)*; parameter: type Identifier; +argumentList: expression? | expression (Comma expression)+; //property, object.a, 3+1, a = 3 expression: subExpression | binaryExpr; //subExpression to dissolve left-recusion subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression ClosedRoundBracket; -assignableExpr: Identifier | instVar; -instVar: subReceiver? receivingMethod* Identifier; - //.trim().toLength().toLowerCase().count ... methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; -argumentList: expression? | expression (Comma expression)+; + +statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; + +stmtExpr: assign | newDecl | methodCall; + +assignableExpr: Identifier | instVar; subReceiver: ((This | newDecl | Identifier) Dot); -receiver: ((This | instVar | newDecl | Identifier) Dot); -receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; +instVar: subReceiver? receivingMethod* Identifier; binaryExpr: calcExpr | nonCalcExpr| value | Not binaryExpr; @@ -38,15 +39,11 @@ dotSubExpr: IntValue | Identifier | instVar | methodCall | OpenRoundBracket calc nonCalcExpr: subExpression nonCalcOperator expression; nonCalcOperator: LogicalOpertor | ComparisonOperator; -//Statement but also expression -//a = expr, new Object(), method(param1) -stmtExpr: assign | newDecl | methodCall; +BooleanValue: 'true'|'false'; +NullValue: 'null'; -//Statements -//int a, {...}, while(a > 10){...}, if(...){...} else if{...} else{...} -statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; returnStmt: Return (expression)?; -localVarDecl: type Identifier (Assign expression)?; +localVarDecl: AccessModifierPublic? type Identifier (Assign expression)? Semicolon; block: OpenCurlyBracket statement* ClosedCurlyBracket; whileStmt: While OpenRoundBracket expression ClosedRoundBracket statement; ifElseStmt: ifStmt elseStmt?; @@ -54,6 +51,8 @@ ifStmt: If OpenRoundBracket expression ClosedRoundBracket statement; elseStmt: Else statement; assign: assignableExpr Assign expression; newDecl: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; +receiver: ((This | instVar | newDecl | Identifier) Dot); +receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; type: Int | Boolean | Char | Identifier; @@ -63,7 +62,11 @@ value: IntValue | BooleanValue | CharValue | NullValue; AccessModifierPublic : 'public' ; MainMethodDecl : 'public static void main(String[] args)'; - +//Types +Void : 'void'; +Int : 'int'; +Boolean : 'bool'; +Char : 'char'; //Operators DotOperator : Multipilkation | Division | Modulo; @@ -105,24 +108,23 @@ Else : 'else'; Return : 'return'; New : 'new'; + + +//Values +IntValue : ('+'|'-')*[0-9]+; +CharValue: '\''~[\r\n]?'\''; + + //Identifier fragment Alpabetic : [a-zA-Z]; fragment Numeric: [0-9]; fragment ValidIdentSymbols : Alpabetic|Numeric|'$'|'_'; Identifier: Alpabetic ValidIdentSymbols*; -//Types -Void : 'void'; -Int : 'int'; -Boolean : 'bool'; -Char : 'char'; - -//Values -IntValue : ('+'|'-')*[0-9]+; -CharValue: '\''~[\r\n]?'\''; -BooleanValue: 'true'|'false'; -NullValue: 'null'; - //Whitespace? Right into the trash it gooeesss WS : [ \t\r\n] -> skip; + + + +