Maven structure

This commit is contained in:
Jay 2024-05-09 15:25:46 +02:00
parent 85282ff90c
commit 334f470488
48 changed files with 6360 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="asm-9.7">
<CLASSES>
<root url="jar://$PROJECT_DIR$/Lib/asm-9.7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

9
.idea/modules.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/NichtHaskell.iml" filepath="$PROJECT_DIR$/NichtHaskell.iml" />
<module fileurl="file://$PROJECT_DIR$/src/NichtHaskell1.iml" filepath="$PROJECT_DIR$/src/NichtHaskell1.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

12
NichtHaskell.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Source" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="asm-9.7" level="project" />
</component>
</module>

12
src/NichtHaskell1.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/test/resources" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -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<Token> 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<FieldDecl> emptyFieldDecl = new ArrayList<>();
List<MethodDecl> emptyMethodDecl = new ArrayList<>();
abstractSyntaxTree.classes.add(new RefType(emptyFieldDecl, emptyMethodDecl, null, null, "MyClass"));
abstractSyntaxTree.typeCheck();
abstractSyntaxTree.codeGen();
}
}

128
src/main/java/Decaf.g4 Normal file
View File

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

View File

@ -0,0 +1,2 @@
class EmptyClass {
}

View File

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

View File

@ -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<String> typeslist) {
if(type.equals("int") || type.equals("bool") || type.equals("char")){
return true;
}
return typeslist.contains(type);
}
}

View File

@ -0,0 +1,5 @@
package TypeCheck;
public class TypeCheckResult {
public String type;
}

View File

@ -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<String, HashMap<String, String>> typeContext; // form class from program
public String type; // from parser
public String identifier; // from parser
public FieldDecl(HashMap<String, HashMap<String, String>> typeContext){
this.typeContext = typeContext;
}
public TypeCheckResult typeCheck(List<FieldDecl> 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<String, HashMap<String, HashMap<String, List<String>>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
return null;
}
@Override
public void codeGen(ClassWriter cw) {
}
}

View File

@ -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<String, HashMap<String, HashMap<String, List<String>>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception;
void codeGen(ClassWriter cw) throws Exception;
}

View File

@ -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<String> parameters;
public String returnType;
//TODO: Move this into the typeCheck
private HashMap<String, String> localVars; // (type, identifier) // add content here
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
// write localvars
// jede methode als block statement aufrufen
return null;
}
@Override
public void codeGen(ClassWriter cw) throws Exception {
}
}

View File

@ -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<FieldDecl> fieldDecls;
public List<MethodDecl> methodDecls;
private HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
public HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext; // (class, (returntype, (identifier, parameter)))
private boolean hasMain;
public RefType(List<FieldDecl> fieldDecls,
List<MethodDecl> methodDecls,
HashMap<String, HashMap<String, String>> typeContext,
HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext, String name){
this.name = name;
this.fieldDecls = fieldDecls;
this.methodDecls = methodDecls;
this.typeContext = typeContext;
this.methodContext = methodContext;
}
@Override
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext,
HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> 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();
}
}

View File

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

View File

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

View File

@ -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 "=="

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<String, Integer> 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");
}
}

View File

@ -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<RefType> classes;
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
public HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext; // (class, (returntype, (identifier, parameter)))
public Program(List<RefType> classes){
this.classes = classes;
this.typeContext = new HashMap<>();
this.methodContext = new HashMap<>();
}
public TypeCheckResult typeCheck() throws Exception{
for(RefType oneClass : classes){
HashMap<String, String> classVars = new HashMap<>();
for (FieldDecl fieldDecl: oneClass.fieldDecls){
classVars.put(fieldDecl.type, fieldDecl.identifier);
}
typeContext.put(oneClass.name, classVars);
HashMap<String, List<String>> methodIdentifierAndParameter = new HashMap<>();
HashMap<String, HashMap<String, List<String >>> 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();
}
*/
}
}

View File

@ -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<String, String > localVars;
HashMap<String, String > typeIndentifierTable; // from program
List<IStatement> statements;
// do we need expression, statementexpression
public BlockStatement(List<IStatement> statements, HashMap<String, String> localVars, HashMap<String, String> 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
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<IExpression> arguments;
RefType classThatHasTheMethodIfNotThis;
RefType thisClass;
public MethodCallStatementExpression(String methodName, List<IExpression> 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<MethodDecl> 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);
}
}

View File

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

View File

@ -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<IExpression> arguments) {
super(methodName, arguments);
}
}

File diff suppressed because one or more lines are too long

View File

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

View File

@ -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}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterProgram(DecafParser.ProgramContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitProgram(DecafParser.ProgramContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterClassdecl(DecafParser.ClassdeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitClassdecl(DecafParser.ClassdeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethodDecl(DecafParser.MethodDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethodDecl(DecafParser.MethodDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFieldDecl(DecafParser.FieldDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFieldDecl(DecafParser.FieldDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameterList(DecafParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameterList(DecafParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameter(DecafParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameter(DecafParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterExpression(DecafParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitExpression(DecafParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterSubExpression(DecafParser.SubExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSubExpression(DecafParser.SubExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignableExpr(DecafParser.AssignableExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignableExpr(DecafParser.AssignableExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInstVar(DecafParser.InstVarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInstVar(DecafParser.InstVarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethodCall(DecafParser.MethodCallContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethodCall(DecafParser.MethodCallContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterArgumentList(DecafParser.ArgumentListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitArgumentList(DecafParser.ArgumentListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterSubReceiver(DecafParser.SubReceiverContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSubReceiver(DecafParser.SubReceiverContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterReceiver(DecafParser.ReceiverContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitReceiver(DecafParser.ReceiverContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterReceivingMethod(DecafParser.ReceivingMethodContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBinaryExpr(DecafParser.BinaryExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBinaryExpr(DecafParser.BinaryExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCalcExpr(DecafParser.CalcExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCalcExpr(DecafParser.CalcExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDotExpr(DecafParser.DotExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDotExpr(DecafParser.DotExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDotSubExpr(DecafParser.DotSubExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDotSubExpr(DecafParser.DotSubExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterNonCalcExpr(DecafParser.NonCalcExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStmtExpr(DecafParser.StmtExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStmtExpr(DecafParser.StmtExprContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStatement(DecafParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStatement(DecafParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterReturnStmt(DecafParser.ReturnStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitReturnStmt(DecafParser.ReturnStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBlock(DecafParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBlock(DecafParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterWhileStmt(DecafParser.WhileStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitWhileStmt(DecafParser.WhileStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIfElseStmt(DecafParser.IfElseStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIfElseStmt(DecafParser.IfElseStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIfStmt(DecafParser.IfStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIfStmt(DecafParser.IfStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterElseStmt(DecafParser.ElseStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitElseStmt(DecafParser.ElseStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssign(DecafParser.AssignContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssign(DecafParser.AssignContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterNewDecl(DecafParser.NewDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitNewDecl(DecafParser.NewDeclContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterType(DecafParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitType(DecafParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterValue(DecafParser.ValueContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitValue(DecafParser.ValueContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}

View File

@ -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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
@SuppressWarnings("CheckReturnValue")
public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements DecafVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitProgram(DecafParser.ProgramContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitClassdecl(DecafParser.ClassdeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethodDecl(DecafParser.MethodDeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFieldDecl(DecafParser.FieldDeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameterList(DecafParser.ParameterListContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameter(DecafParser.ParameterContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitExpression(DecafParser.ExpressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSubExpression(DecafParser.SubExpressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssignableExpr(DecafParser.AssignableExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInstVar(DecafParser.InstVarContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethodCall(DecafParser.MethodCallContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitArgumentList(DecafParser.ArgumentListContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSubReceiver(DecafParser.SubReceiverContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitReceiver(DecafParser.ReceiverContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitReceivingMethod(DecafParser.ReceivingMethodContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBinaryExpr(DecafParser.BinaryExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCalcExpr(DecafParser.CalcExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDotExpr(DecafParser.DotExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDotSubExpr(DecafParser.DotSubExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitNonCalcExpr(DecafParser.NonCalcExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitNonCalcOperator(DecafParser.NonCalcOperatorContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStmtExpr(DecafParser.StmtExprContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStatement(DecafParser.StatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitReturnStmt(DecafParser.ReturnStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBlock(DecafParser.BlockContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWhileStmt(DecafParser.WhileStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIfElseStmt(DecafParser.IfElseStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIfStmt(DecafParser.IfStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitElseStmt(DecafParser.ElseStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssign(DecafParser.AssignContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitNewDecl(DecafParser.NewDeclContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitType(DecafParser.TypeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitValue(DecafParser.ValueContext ctx) { return visitChildren(ctx); }
}

File diff suppressed because one or more lines are too long

View File

@ -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] = "<INVALID>";
}
}
}
@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);
}
}
}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
/**
* 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);
}