diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ebde8d0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml + +.idea/ \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..1181d5e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6ddae43 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0b5faa7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Source/.idea/vcs.xml b/.idea/vcs.xml similarity index 64% rename from Source/.idea/vcs.xml rename to .idea/vcs.xml index 6c0b863..35eb1dd 100644 --- a/Source/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/NichtHaskell.iml b/NichtHaskell.iml new file mode 100644 index 0000000..b18ce81 --- /dev/null +++ b/NichtHaskell.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Source/.idea/.gitignore b/Source/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/Source/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/Source/.idea/libraries/asm_9_7.xml b/Source/.idea/libraries/asm_9_7.xml deleted file mode 100644 index 2233f59..0000000 --- a/Source/.idea/libraries/asm_9_7.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/misc.xml b/Source/.idea/misc.xml deleted file mode 100644 index ceb7609..0000000 --- a/Source/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Source/.idea/modules.xml b/Source/.idea/modules.xml deleted file mode 100644 index 6044bc3..0000000 --- a/Source/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Source/.idea/uiDesigner.xml b/Source/.idea/uiDesigner.xml deleted file mode 100644 index 2b63946..0000000 --- a/Source/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..bdd7dcd --- /dev/null +++ b/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + Clippit.org + NichtHaskell + 1 + + + 20 + 20 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.0 + test + + + junit + junit + 4.13.1 + compile + + + org.ow2.asm + asm + 9.7 + + + org.antlr + antlr4-runtime + 4.13.1 + + + + + \ No newline at end of file diff --git a/Source/.idea/Source.iml b/src/NichtHaskell1.iml similarity index 66% rename from Source/.idea/Source.iml rename to src/NichtHaskell1.iml index f9bd605..2336fe3 100644 --- a/Source/.idea/Source.iml +++ b/src/NichtHaskell1.iml @@ -3,10 +3,10 @@ - + + - \ No newline at end of file diff --git a/Source/Compiler.java b/src/main/java/Compiler.java similarity index 100% rename from Source/Compiler.java rename to src/main/java/Compiler.java diff --git a/Source/Decaf.g4 b/src/main/java/Decaf.g4 similarity index 89% rename from Source/Decaf.g4 rename to src/main/java/Decaf.g4 index 2af8297..28887f3 100644 --- a/Source/Decaf.g4 +++ b/src/main/java/Decaf.g4 @@ -3,32 +3,33 @@ grammar Decaf; program: classdecl+; //class identifier{...} -classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|fieldDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; -constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method without +classdecl: AccessModifierPublic? 'class' Identifier OpenCurlyBracket (constuctorDecl|localVarDecl|methodDecl)*(MainMethodDecl block)? ClosedCurlyBracket; +constuctorDecl: AccessModifierPublic? Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; //Method and FieldVar methodDecl: AccessModifierPublic? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket block; -fieldDecl: AccessModifierPublic? type Identifier Semicolon; //Parameters parameterList: parameter(Comma parameter)*; parameter: type Identifier; +argumentList: expression? | expression (Comma expression)+; //property, object.a, 3+1, a = 3 expression: subExpression | binaryExpr; //subExpression to dissolve left-recusion subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression ClosedRoundBracket; -assignableExpr: Identifier | instVar; -instVar: subReceiver? receivingMethod* Identifier; - //.trim().toLength().toLowerCase().count ... methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; -argumentList: expression? | expression (Comma expression)+; + +statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; + +stmtExpr: assign | newDecl | methodCall; + +assignableExpr: Identifier | instVar; subReceiver: ((This | newDecl | Identifier) Dot); -receiver: ((This | instVar | newDecl | Identifier) Dot); -receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; +instVar: subReceiver? receivingMethod* Identifier; binaryExpr: calcExpr | nonCalcExpr| value | Not binaryExpr; @@ -38,15 +39,11 @@ dotSubExpr: IntValue | Identifier | instVar | methodCall | OpenRoundBracket calc nonCalcExpr: subExpression nonCalcOperator expression; nonCalcOperator: LogicalOpertor | ComparisonOperator; -//Statement but also expression -//a = expr, new Object(), method(param1) -stmtExpr: assign | newDecl | methodCall; +BooleanValue: 'true'|'false'; +NullValue: 'null'; -//Statements -//int a, {...}, while(a > 10){...}, if(...){...} else if{...} else{...} -statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; returnStmt: Return (expression)?; -localVarDecl: type Identifier (Assign expression)?; +localVarDecl: AccessModifierPublic? type Identifier (Assign expression)? Semicolon; block: OpenCurlyBracket statement* ClosedCurlyBracket; whileStmt: While OpenRoundBracket expression ClosedRoundBracket statement; ifElseStmt: ifStmt elseStmt?; @@ -54,6 +51,8 @@ ifStmt: If OpenRoundBracket expression ClosedRoundBracket statement; elseStmt: Else statement; assign: assignableExpr Assign expression; newDecl: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; +receiver: ((This | instVar | newDecl | Identifier) Dot); +receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; type: Int | Boolean | Char | Identifier; @@ -63,7 +62,11 @@ value: IntValue | BooleanValue | CharValue | NullValue; AccessModifierPublic : 'public' ; MainMethodDecl : 'public static void main(String[] args)'; - +//Types +Void : 'void'; +Int : 'int'; +Boolean : 'bool'; +Char : 'char'; //Operators DotOperator : Multipilkation | Division | Modulo; @@ -105,24 +108,23 @@ Else : 'else'; Return : 'return'; New : 'new'; + + +//Values +IntValue : ('+'|'-')*[0-9]+; +CharValue: '\''~[\r\n]?'\''; + + //Identifier fragment Alpabetic : [a-zA-Z]; fragment Numeric: [0-9]; fragment ValidIdentSymbols : Alpabetic|Numeric|'$'|'_'; Identifier: Alpabetic ValidIdentSymbols*; -//Types -Void : 'void'; -Int : 'int'; -Boolean : 'bool'; -Char : 'char'; - -//Values -IntValue : ('+'|'-')*[0-9]+; -CharValue: '\''~[\r\n]?'\''; -BooleanValue: 'true'|'false'; -NullValue: 'null'; - //Whitespace? Right into the trash it gooeesss WS : [ \t\r\n] -> skip; + + + + diff --git a/Source/EmptyClass.java b/src/main/java/EmptyClass.java similarity index 100% rename from Source/EmptyClass.java rename to src/main/java/EmptyClass.java diff --git a/Source/TypeCheck/AbstractType.java b/src/main/java/TypeCheck/AbstractType.java similarity index 100% rename from Source/TypeCheck/AbstractType.java rename to src/main/java/TypeCheck/AbstractType.java diff --git a/Source/TypeCheck/TypeCheckHelper.java b/src/main/java/TypeCheck/TypeCheckHelper.java similarity index 100% rename from Source/TypeCheck/TypeCheckHelper.java rename to src/main/java/TypeCheck/TypeCheckHelper.java diff --git a/Source/TypeCheck/TypeCheckResult.java b/src/main/java/TypeCheck/TypeCheckResult.java similarity index 100% rename from Source/TypeCheck/TypeCheckResult.java rename to src/main/java/TypeCheck/TypeCheckResult.java diff --git a/Source/abstractSyntaxTree/Class/FieldDecl.java b/src/main/java/abstractSyntaxTree/Class/FieldDecl.java similarity index 100% rename from Source/abstractSyntaxTree/Class/FieldDecl.java rename to src/main/java/abstractSyntaxTree/Class/FieldDecl.java diff --git a/Source/abstractSyntaxTree/Class/IClass.java b/src/main/java/abstractSyntaxTree/Class/IClass.java similarity index 100% rename from Source/abstractSyntaxTree/Class/IClass.java rename to src/main/java/abstractSyntaxTree/Class/IClass.java diff --git a/Source/abstractSyntaxTree/Class/MethodDecl.java b/src/main/java/abstractSyntaxTree/Class/MethodDecl.java similarity index 100% rename from Source/abstractSyntaxTree/Class/MethodDecl.java rename to src/main/java/abstractSyntaxTree/Class/MethodDecl.java diff --git a/Source/abstractSyntaxTree/Class/RefType.java b/src/main/java/abstractSyntaxTree/Class/RefType.java similarity index 100% rename from Source/abstractSyntaxTree/Class/RefType.java rename to src/main/java/abstractSyntaxTree/Class/RefType.java diff --git a/Source/abstractSyntaxTree/Datatype/BoolDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java similarity index 100% rename from Source/abstractSyntaxTree/Datatype/BoolDatatype.java rename to src/main/java/abstractSyntaxTree/Datatype/BoolDatatype.java diff --git a/Source/abstractSyntaxTree/Datatype/CharDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java similarity index 100% rename from Source/abstractSyntaxTree/Datatype/CharDatatype.java rename to src/main/java/abstractSyntaxTree/Datatype/CharDatatype.java diff --git a/Source/abstractSyntaxTree/Datatype/IDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/IDatatype.java similarity index 100% rename from Source/abstractSyntaxTree/Datatype/IDatatype.java rename to src/main/java/abstractSyntaxTree/Datatype/IDatatype.java diff --git a/Source/abstractSyntaxTree/Datatype/IntDatatype.java b/src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java similarity index 100% rename from Source/abstractSyntaxTree/Datatype/IntDatatype.java rename to src/main/java/abstractSyntaxTree/Datatype/IntDatatype.java diff --git a/Source/abstractSyntaxTree/Expression/BinaryExpression.java b/src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java similarity index 100% rename from Source/abstractSyntaxTree/Expression/BinaryExpression.java rename to src/main/java/abstractSyntaxTree/Expression/BinaryExpression.java diff --git a/Source/abstractSyntaxTree/Expression/IExpression.java b/src/main/java/abstractSyntaxTree/Expression/IExpression.java similarity index 100% rename from Source/abstractSyntaxTree/Expression/IExpression.java rename to src/main/java/abstractSyntaxTree/Expression/IExpression.java diff --git a/Source/abstractSyntaxTree/Expression/InstVarExpression.java b/src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java similarity index 100% rename from Source/abstractSyntaxTree/Expression/InstVarExpression.java rename to src/main/java/abstractSyntaxTree/Expression/InstVarExpression.java diff --git a/Source/abstractSyntaxTree/Expression/UnaryExpression.java b/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java similarity index 100% rename from Source/abstractSyntaxTree/Expression/UnaryExpression.java rename to src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java diff --git a/Source/abstractSyntaxTree/Expression/VarRefExpression.java b/src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java similarity index 100% rename from Source/abstractSyntaxTree/Expression/VarRefExpression.java rename to src/main/java/abstractSyntaxTree/Expression/VarRefExpression.java diff --git a/Source/abstractSyntaxTree/Program.java b/src/main/java/abstractSyntaxTree/Program.java similarity index 100% rename from Source/abstractSyntaxTree/Program.java rename to src/main/java/abstractSyntaxTree/Program.java diff --git a/Source/abstractSyntaxTree/Statement/BlockStatement.java b/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/BlockStatement.java rename to src/main/java/abstractSyntaxTree/Statement/BlockStatement.java diff --git a/Source/abstractSyntaxTree/Statement/EmptyStatement.java b/src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/EmptyStatement.java rename to src/main/java/abstractSyntaxTree/Statement/EmptyStatement.java diff --git a/Source/abstractSyntaxTree/Statement/IStatement.java b/src/main/java/abstractSyntaxTree/Statement/IStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/IStatement.java rename to src/main/java/abstractSyntaxTree/Statement/IStatement.java diff --git a/Source/abstractSyntaxTree/Statement/IfElseStatement.java b/src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/IfElseStatement.java rename to src/main/java/abstractSyntaxTree/Statement/IfElseStatement.java diff --git a/Source/abstractSyntaxTree/Statement/IfStatement.java b/src/main/java/abstractSyntaxTree/Statement/IfStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/IfStatement.java rename to src/main/java/abstractSyntaxTree/Statement/IfStatement.java diff --git a/Source/abstractSyntaxTree/Statement/ReturnStatement.java b/src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/ReturnStatement.java rename to src/main/java/abstractSyntaxTree/Statement/ReturnStatement.java diff --git a/Source/abstractSyntaxTree/Statement/WhileStatement.java b/src/main/java/abstractSyntaxTree/Statement/WhileStatement.java similarity index 100% rename from Source/abstractSyntaxTree/Statement/WhileStatement.java rename to src/main/java/abstractSyntaxTree/Statement/WhileStatement.java diff --git a/Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java similarity index 100% rename from Source/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java rename to src/main/java/abstractSyntaxTree/StatementExpression/AssignStatementExpression.java diff --git a/Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java similarity index 100% rename from Source/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java rename to src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java diff --git a/Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java similarity index 100% rename from Source/abstractSyntaxTree/StatementExpression/NewStatementExpression.java rename to src/main/java/abstractSyntaxTree/StatementExpression/NewStatementExpression.java diff --git a/Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java similarity index 100% rename from Source/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java rename to src/main/java/abstractSyntaxTree/StatementExpression/SuperStatementExpression.java diff --git a/Source/gen/Decaf.interp b/src/main/java/gen/Decaf.interp similarity index 100% rename from Source/gen/Decaf.interp rename to src/main/java/gen/Decaf.interp diff --git a/Source/gen/Decaf.tokens b/src/main/java/gen/Decaf.tokens similarity index 100% rename from Source/gen/Decaf.tokens rename to src/main/java/gen/Decaf.tokens diff --git a/Source/gen/DecafBaseListener.java b/src/main/java/gen/DecafBaseListener.java similarity index 100% rename from Source/gen/DecafBaseListener.java rename to src/main/java/gen/DecafBaseListener.java diff --git a/Source/gen/DecafBaseVisitor.java b/src/main/java/gen/DecafBaseVisitor.java similarity index 100% rename from Source/gen/DecafBaseVisitor.java rename to src/main/java/gen/DecafBaseVisitor.java diff --git a/Source/gen/DecafLexer.interp b/src/main/java/gen/DecafLexer.interp similarity index 100% rename from Source/gen/DecafLexer.interp rename to src/main/java/gen/DecafLexer.interp diff --git a/Source/gen/DecafLexer.java b/src/main/java/gen/DecafLexer.java similarity index 100% rename from Source/gen/DecafLexer.java rename to src/main/java/gen/DecafLexer.java diff --git a/Source/gen/DecafLexer.tokens b/src/main/java/gen/DecafLexer.tokens similarity index 100% rename from Source/gen/DecafLexer.tokens rename to src/main/java/gen/DecafLexer.tokens diff --git a/Source/gen/DecafListener.java b/src/main/java/gen/DecafListener.java similarity index 100% rename from Source/gen/DecafListener.java rename to src/main/java/gen/DecafListener.java diff --git a/Source/gen/DecafParser.java b/src/main/java/gen/DecafParser.java similarity index 100% rename from Source/gen/DecafParser.java rename to src/main/java/gen/DecafParser.java diff --git a/Source/gen/DecafVisitor.java b/src/main/java/gen/DecafVisitor.java similarity index 100% rename from Source/gen/DecafVisitor.java rename to src/main/java/gen/DecafVisitor.java