Compare commits
70 Commits
88ce9e52f0
...
7d441116bd
Author | SHA1 | Date | |
---|---|---|---|
|
7d441116bd | ||
|
8afa3b8461 | ||
|
ba73e1bd45 | ||
|
b7affd75ae | ||
bd76135895 | |||
3227d69fc1 | |||
4ca6972ccd | |||
0047f6c08e | |||
|
437de74cc6 | ||
|
ca77307f0c | ||
|
5f46130439 | ||
903e87901e | |||
775beb60fe | |||
b58fa00c9a | |||
|
92990e4042 | ||
|
3500ffd377 | ||
|
771b92bfd7 | ||
c7ad574474 | |||
22c3850062 | |||
|
21da31dee3 | ||
|
294df16e89 | ||
3112660880 | |||
c135819ba0 | |||
e94cd9cc2a | |||
|
71ffb8bb83 | ||
|
2d455ba197 | ||
|
77fecfa476 | ||
|
36e56fa66e | ||
|
f3e3158460 | ||
|
7b1e6fced4 | ||
|
4d5c0017b4 | ||
093beb9ef1 | |||
|
18fc17b707 | ||
|
bea71838ac | ||
0298e2cb76 | |||
90f91d58d1 | |||
612c967023 | |||
f12e553ffc | |||
f24e279596 | |||
c5fc378eed | |||
3e901ea254 | |||
|
4d21d8e94e | ||
|
a34c7ded50 | ||
|
10eb17497e | ||
|
576146c4fc | ||
|
bf365194be | ||
|
35b3e9ee46 | ||
|
8163d0b61e | ||
|
92e1daab5b | ||
70a3788030 | |||
4c5473827e | |||
d631b01c82 | |||
|
8cd22c6e4c | ||
ef0bc99bbf | |||
99948fef07 | |||
66c9481b3e | |||
fd8d451ba7 | |||
f27a7471bc | |||
a15f684c04 | |||
fb3f822160 | |||
b9f6014f59 | |||
af64f88198 | |||
837e751094 | |||
57c2023215 | |||
09e36a84dc | |||
|
e395c4d96b | ||
|
8a5f307947 | ||
514f7d724a | |||
|
de5c2a5002 | ||
407b03620e |
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -6,6 +6,11 @@
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven_central" />
|
||||
<option name="name" value="Maven Central" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -6,7 +6,7 @@
|
||||
<PerGrammarGenerationSettings>
|
||||
<option name="fileName" value="$PROJECT_DIR$/src/main/java/parser/SimpleJava.g4" />
|
||||
<option name="autoGen" value="true" />
|
||||
<option name="outputDir" value="C:\Users\Johannes\Documents\Github\JavaCompiler\src\main\java" />
|
||||
<option name="outputDir" value="C:\Users\ARB00075\Documents\DH\Compilerbau\NichtHaskell2.0\src\main\java" />
|
||||
<option name="libDir" value="" />
|
||||
<option name="encoding" value="" />
|
||||
<option name="pkg" value="parser.generated" />
|
||||
|
13
pom.xml
13
pom.xml
@@ -44,6 +44,12 @@
|
||||
<version>3.26.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -78,4 +84,11 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven_central</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo.maven.apache.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
@@ -4,6 +4,7 @@ import ast.type.AccessModifierNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.MemberNode;
|
||||
import ast.members.MethodNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
@@ -44,4 +45,9 @@ public class ClassNode implements ASTNode, Visitable {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ClassVisitor classVisitor) {
|
||||
classVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package ast;
|
||||
|
||||
import bytecode.visitor.ProgramVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
@@ -18,4 +19,9 @@ public class ProgramNode implements ASTNode, Visitable {
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ProgramVisitor programVisitor) {
|
||||
programVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@@ -8,4 +8,6 @@ public interface IExpressionNode extends ASTNode, Visitable {
|
||||
|
||||
ITypeNode getType();
|
||||
|
||||
void setType(ITypeNode type);
|
||||
|
||||
}
|
||||
|
@@ -2,10 +2,14 @@ package ast.expressions.binaryexpressions;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class BinaryNode implements IExpressionNode {
|
||||
public class BinaryNode implements IExpressionNode, Visitable {
|
||||
|
||||
private ITypeNode typeNode;
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
@@ -14,6 +18,16 @@ public class BinaryNode implements IExpressionNode {
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
return typeNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(ITypeNode type) {
|
||||
this.typeNode = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package ast.expressions.binaryexpressions;
|
||||
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -8,6 +9,7 @@ public class CalculationNode extends BinaryNode {
|
||||
public CalculationNode calculationExpression;
|
||||
public EnumLineOperator operator;
|
||||
public DotNode dotExpression;
|
||||
private ITypeNode typeNode;
|
||||
|
||||
public CalculationNode(CalculationNode calculationExpression, String operator, DotNode dotExpression) {
|
||||
this.calculationExpression = calculationExpression;
|
||||
@@ -34,9 +36,10 @@ public class CalculationNode extends BinaryNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package ast.expressions.binaryexpressions;
|
||||
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class DotNode extends BinaryNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.type.type.*;
|
||||
import ast.type.ValueNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -37,8 +38,8 @@ public class DotSubstractionNode extends BinaryNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package ast.expressions.binaryexpressions;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -43,8 +44,8 @@ public class NonCalculationNode extends BinaryNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITypeNode getType() {
|
||||
return null;
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,13 +1,19 @@
|
||||
package ast.expressions.unaryexpressions;
|
||||
|
||||
import ast.ASTNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import ast.type.type.ITypeNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MemberAccessNode implements ASTNode {
|
||||
public class MemberAccessNode implements ASTNode, Visitable {
|
||||
public Boolean thisExpr;
|
||||
public List<String> identifiers = new ArrayList<>();
|
||||
private ITypeNode typeNode;
|
||||
|
||||
public MemberAccessNode(Boolean thisExpr) {
|
||||
this.thisExpr = thisExpr;
|
||||
@@ -17,4 +23,21 @@ public class MemberAccessNode implements ASTNode {
|
||||
identifiers.add(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
public ITypeNode getTypeNode() {
|
||||
return typeNode;
|
||||
}
|
||||
|
||||
public void setTypeNode(ITypeNode typeNode) {
|
||||
this.typeNode = typeNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,12 +2,26 @@ package ast.expressions.unaryexpressions;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class NotNode implements ASTNode {
|
||||
public class NotNode implements ASTNode, Visitable {
|
||||
public IExpressionNode expression;
|
||||
|
||||
public NotNode(IExpressionNode expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import ast.expressions.IExpressionNode;
|
||||
import ast.statements.IStatementNode;
|
||||
import ast.type.type.*;
|
||||
import ast.type.ValueNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -61,4 +62,9 @@ public class UnaryNode implements IExpressionNode {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
11
src/main/java/ast/literal/BooleanLiteralNode.java
Normal file
11
src/main/java/ast/literal/BooleanLiteralNode.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package ast.literal;
|
||||
|
||||
public class BooleanLiteralNode {
|
||||
private String value;
|
||||
|
||||
public BooleanLiteralNode(String value) {this.value = value;}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
11
src/main/java/ast/literal/CharLiteralNode.java
Normal file
11
src/main/java/ast/literal/CharLiteralNode.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package ast.literal;
|
||||
|
||||
public class CharLiteralNode {
|
||||
public String value;
|
||||
|
||||
public CharLiteralNode(String value) {this.value = value;}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
31
src/main/java/ast/literal/LiteralNode.java
Normal file
31
src/main/java/ast/literal/LiteralNode.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package ast.literal;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class LiteralNode implements IExpressionNode {
|
||||
|
||||
public String value;
|
||||
private ITypeNode type;
|
||||
|
||||
public LiteralNode(String value, ITypeNode type) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ITypeNode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ITypeNode type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -3,11 +3,14 @@ package ast.members;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.statements.BlockNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConstructorNode extends MethodNode {
|
||||
public class ConstructorNode extends MethodNode implements Visitable {
|
||||
public AccessModifierNode accessType;
|
||||
public String identifier;
|
||||
public List<ParameterNode> parameters = new ArrayList<>();
|
||||
@@ -23,4 +26,22 @@ public class ConstructorNode extends MethodNode {
|
||||
parameters.add(parameterNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
public boolean isSame(MethodNode methodNode) {
|
||||
if (!(Objects.equals(this.identifier, methodNode.getIdentifier()))
|
||||
|| getParameters().size() != methodNode.getParameters().size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.getParameters().size(); i++) {
|
||||
if (!this.getParameters().get(i).type.equals(methodNode.getParameters().get(i).type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package ast.members;
|
||||
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
@@ -22,4 +24,9 @@ public class FieldNode implements MemberNode, Visitable {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ClassVisitor classVisitor) {
|
||||
classVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,18 @@
|
||||
package ast.members;
|
||||
|
||||
import ast.statements.BlockNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class MainMethodNode extends MethodNode {
|
||||
public class MainMethodNode extends MethodNode implements Visitable {
|
||||
public BlockNode block;
|
||||
|
||||
public MainMethodNode(BlockNode block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,8 @@ public class MethodNode implements MemberNode, Visitable {
|
||||
public List<ParameterNode> parameters = new ArrayList<>();
|
||||
public BlockNode block;
|
||||
|
||||
public MethodNode() {}
|
||||
public MethodNode() {
|
||||
}
|
||||
|
||||
public MethodNode(String accessModifier, ITypeNode type, Boolean voidType, String identifier, BlockNode block){
|
||||
this.accesModifier = new AccessModifierNode(accessModifier);
|
||||
@@ -46,7 +47,7 @@ public class MethodNode implements MemberNode, Visitable {
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.getParameters().size(); i++) {
|
||||
if (this.getParameters().get(i).type.equals(methodNode.getParameters().get(i).type)) {
|
||||
if (!this.getParameters().get(i).type.equals(methodNode.getParameters().get(i).type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
11
src/main/java/ast/statement/BlockStatementNode.java
Normal file
11
src/main/java/ast/statement/BlockStatementNode.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package ast.statement;
|
||||
|
||||
import ast.statements.IStatementNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockStatementNode {
|
||||
List<IStatementNode> statements;
|
||||
|
||||
public BlockStatementNode(List<IStatementNode> statements) {this.statements = statements;}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package ast.statementexpressions;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -18,4 +19,9 @@ public class AssignNode implements IStatementExpressionNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
package ast.statementexpressions;
|
||||
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class AssignableNode implements IStatementExpressionNode {
|
||||
public String identifier;
|
||||
private ITypeNode typeNode;
|
||||
|
||||
public MemberAccessNode memberAccess;
|
||||
|
||||
@@ -22,4 +24,12 @@ public class AssignableNode implements IStatementExpressionNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
public ITypeNode getTypeNode() {
|
||||
return typeNode;
|
||||
}
|
||||
|
||||
public void setTypeNode(ITypeNode typeNode) {
|
||||
this.typeNode = typeNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package ast.statementexpressions;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -24,4 +25,9 @@ public class NewDeclarationNode implements IStatementExpressionNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,8 +2,10 @@ package ast.statementexpressions.crementexpressions;
|
||||
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.IStatementExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class DecrementNode implements IStatementExpressionNode {
|
||||
public CrementType crementType;
|
||||
@@ -18,5 +20,4 @@ public class DecrementNode implements IStatementExpressionNode {
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package ast.statementexpressions.crementexpressions;
|
||||
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.IStatementExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -18,5 +19,4 @@ public class IncrementNode implements IStatementExpressionNode {
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,11 +2,15 @@ package ast.statementexpressions.methodcallstatementnexpressions;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChainedMethodNode implements ASTNode {
|
||||
public class ChainedMethodNode implements ASTNode, Visitable {
|
||||
public String identifier;
|
||||
public List<IExpressionNode> expressions = new ArrayList<>();
|
||||
|
||||
@@ -17,4 +21,14 @@ public class ChainedMethodNode implements ASTNode {
|
||||
public void addExpression(IExpressionNode expression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package ast.statementexpressions.methodcallstatementnexpressions;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.statements.IStatementNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -32,4 +33,9 @@ public class MethodCallNode implements IStatementNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,8 +3,12 @@ package ast.statementexpressions.methodcallstatementnexpressions;
|
||||
import ast.ASTNode;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.statementexpressions.NewDeclarationNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class TargetNode implements ASTNode {
|
||||
public class TargetNode implements ASTNode, Visitable {
|
||||
public Boolean thisTar;
|
||||
public MemberAccessNode memberAccess;
|
||||
public NewDeclarationNode newDeclaration;
|
||||
@@ -25,4 +29,10 @@ public class TargetNode implements ASTNode {
|
||||
public TargetNode(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
10
src/main/java/ast/statements/BlockStatementNode.java
Normal file
10
src/main/java/ast/statements/BlockStatementNode.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package ast.statements;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockStatementNode {
|
||||
List<IStatementNode> statements;
|
||||
|
||||
public BlockStatementNode(List<IStatementNode> statements) {this.statements = statements;}
|
||||
}
|
@@ -1,11 +1,10 @@
|
||||
package ast.statements;
|
||||
|
||||
import ast.ASTNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class ElseNode implements IStatementNode {
|
||||
BlockNode block;
|
||||
public BlockNode block;
|
||||
|
||||
public ElseNode(BlockNode block) {
|
||||
this.block = block;
|
||||
@@ -14,6 +13,6 @@ public class ElseNode implements IStatementNode {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package ast.statements;
|
||||
|
||||
import ast.ASTNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -8,9 +7,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IfElseNode implements IStatementNode {
|
||||
IfNode ifStatement;
|
||||
List<IfNode> elseIfStatements = new ArrayList<>();
|
||||
ElseNode elseStatement;
|
||||
public IfNode ifStatement;
|
||||
public List<IfNode> elseIfStatements = new ArrayList<>();
|
||||
public ElseNode elseStatement;
|
||||
|
||||
public IfElseNode(IfNode ifStatement, ElseNode elseNode) {
|
||||
this.ifStatement = ifStatement;
|
||||
@@ -23,6 +22,6 @@ public class IfElseNode implements IStatementNode {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,12 @@
|
||||
package ast.statements;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class IfNode implements IStatementNode {
|
||||
IExpressionNode expression;
|
||||
BlockNode block;
|
||||
public IExpressionNode expression;
|
||||
public BlockNode block;
|
||||
|
||||
public IfNode(IExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
@@ -16,6 +15,6 @@ public class IfNode implements IStatementNode {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package ast.statements;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.type.type.*;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -23,4 +24,9 @@ public class LocalVariableDeclarationNode implements IStatementNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package ast.statements;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
@@ -21,4 +22,9 @@ public class ReturnNode implements IStatementNode {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public class WhileNode implements IStatementNode {
|
||||
IExpressionNode expression;
|
||||
BlockNode block;
|
||||
public IExpressionNode expression;
|
||||
public BlockNode block;
|
||||
|
||||
public WhileNode(IExpressionNode expression, BlockNode block) {
|
||||
this.expression = expression;
|
||||
@@ -15,6 +15,6 @@ public class WhileNode implements IStatementNode {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return null;
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,12 @@
|
||||
package ast.type;
|
||||
|
||||
import ast.ASTNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class ValueNode implements ASTNode {
|
||||
public class ValueNode implements ASTNode, Visitable {
|
||||
public EnumValueNode valueType;
|
||||
public String value;
|
||||
|
||||
@@ -10,4 +14,14 @@ public class ValueNode implements ASTNode {
|
||||
this.valueType = valueType;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
}
|
||||
|
@@ -2,21 +2,89 @@ package bytecode;
|
||||
|
||||
import ast.ProgramNode;
|
||||
import ast.ClassNode;
|
||||
import ast.members.MainMethodNode;
|
||||
import ast.members.MemberNode;
|
||||
import bytecode.visitor.ProgramVisitor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class ByteCodeGenerator implements ProgramVisitor {
|
||||
|
||||
private final String outputDirectoryPath;
|
||||
private JarOutputStream jarOutputStream;
|
||||
private ByteArrayOutputStream byteArrayOutputStream;
|
||||
private String outputDirectory;
|
||||
private boolean generateJar;
|
||||
private boolean generateClassFiles;
|
||||
|
||||
public ByteCodeGenerator(String outputDirectoryPath) {
|
||||
this.outputDirectoryPath = outputDirectoryPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ProgramNode programNode) {
|
||||
for (ClassNode classDeclarationNode : programNode.classes) {
|
||||
// ClassCodeGen classCodeGen = new ClassCodeGen();
|
||||
// classDeclarationNode.accept(classCodeGen);
|
||||
public ByteCodeGenerator(String outputDirectory, boolean generateJar, boolean generateClassFiles) {
|
||||
this.outputDirectory = outputDirectory;
|
||||
this.generateJar = generateJar;
|
||||
this.generateClassFiles = generateClassFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ProgramNode programNode) {
|
||||
if(generateJar) {
|
||||
byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
Manifest manifest = new Manifest();
|
||||
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
|
||||
boolean foundMainClass = false;
|
||||
for (ClassNode classNode : programNode.classes) {
|
||||
if (foundMainClass) {
|
||||
break;
|
||||
}
|
||||
for (MemberNode memberNode : classNode.members) {
|
||||
if (memberNode instanceof MainMethodNode) {
|
||||
manifest.getMainAttributes().putValue("Main-Class", classNode.identifier);
|
||||
foundMainClass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jarOutputStream = new JarOutputStream(byteArrayOutputStream, manifest);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (ClassNode classDeclarationNode : programNode.classes) {
|
||||
ClassCodeGen classCodeGen = new ClassCodeGen(jarOutputStream, outputDirectory, generateJar, generateClassFiles);
|
||||
classDeclarationNode.accept(classCodeGen);
|
||||
}
|
||||
|
||||
try {
|
||||
jarOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
saveJarFile(byteArrayOutputStream.toByteArray(), "output.jar");
|
||||
} else {
|
||||
for (ClassNode classDeclarationNode : programNode.classes) {
|
||||
ClassCodeGen classCodeGen = new ClassCodeGen(jarOutputStream, outputDirectory, generateJar, generateClassFiles);
|
||||
classDeclarationNode.accept(classCodeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveJarFile(byte[] jarBytes, String jarFileName) {
|
||||
File directory = new File(outputDirectory);
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
File jarFile = new File(directory, jarFileName);
|
||||
try (FileOutputStream fos = new FileOutputStream(jarFile)) {
|
||||
fos.write(jarBytes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,26 +10,35 @@ import bytecode.visitor.ClassVisitor;
|
||||
import java.io.File;
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
|
||||
public class ClassCodeGen implements ClassVisitor {
|
||||
private Mapper mapper;
|
||||
private ClassWriter classWriter;
|
||||
private final String outputDirectoryPath;
|
||||
private JarOutputStream jarOutputStream;
|
||||
private String outputDirectory;
|
||||
private boolean generateJar;
|
||||
private boolean generateClassFiles;
|
||||
|
||||
public ClassCodeGen(String outputDirectoryPath) {
|
||||
this.outputDirectoryPath = outputDirectoryPath;
|
||||
public ClassCodeGen(JarOutputStream jarOutputStream, String outputDirectory, boolean generateJar, boolean generateClassFiles) {
|
||||
mapper = new Mapper();
|
||||
this.jarOutputStream = jarOutputStream;
|
||||
this.outputDirectory = outputDirectory;
|
||||
this.generateJar = generateJar;
|
||||
this.generateClassFiles = generateClassFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassNode classNode) {
|
||||
classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
// classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null,
|
||||
// "java/lang/Object", null);
|
||||
classWriter.visit(Opcodes.V1_5, mapper.mapAccessTypeToOpcode(classNode.accessType), classNode.identifier, null,
|
||||
"java/lang/Object", null);
|
||||
|
||||
for (MemberNode memberNode : classNode.members) {
|
||||
if (memberNode instanceof FieldNode) {
|
||||
@@ -40,29 +49,31 @@ public class ClassCodeGen implements ClassVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
classWriter.visitEnd();
|
||||
printIntoClassFile(classWriter.toByteArray(), classNode.identifier);
|
||||
if (generateJar) {
|
||||
writeToJar(classWriter.toByteArray(), classNode.identifier);
|
||||
}
|
||||
if (generateClassFiles) {
|
||||
printIntoClassFile(classWriter.toByteArray(), classNode.identifier, outputDirectory);
|
||||
}
|
||||
|
||||
classWriter.visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldNode fieldNode) {
|
||||
if(fieldNode.type instanceof BaseType baseTypeNode){
|
||||
// classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null );
|
||||
if (fieldNode.type instanceof BaseType) {
|
||||
classWriter.visitField(mapper.mapAccessTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar((BaseType) fieldNode.type), null, null);
|
||||
}
|
||||
classWriter.visitEnd();
|
||||
}
|
||||
|
||||
private void printIntoClassFile(byte[] byteCode, String name) {
|
||||
// String outputDirectoryPath = "src/main/resources/output";
|
||||
// System.out.println("Output directory path: " + outputDirectoryPath);
|
||||
File directory = new File(outputDirectoryPath);
|
||||
private void printIntoClassFile(byte[] byteCode, String name, String outputDirectory) {
|
||||
File directory = new File(outputDirectory);
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
String filePath = outputDirectoryPath + "/" + name + ".class";
|
||||
String filePath = outputDirectory + "/" + name + ".class";
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
|
||||
fileOutputStream.write(byteCode);
|
||||
@@ -71,4 +82,15 @@ public class ClassCodeGen implements ClassVisitor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeToJar(byte[] byteCode, String className) {
|
||||
try {
|
||||
JarEntry jarEntry = new JarEntry(className + ".class");
|
||||
jarOutputStream.putNextEntry(jarEntry);
|
||||
jarOutputStream.write(byteCode);
|
||||
jarOutputStream.closeEntry();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,41 +1,60 @@
|
||||
package bytecode;
|
||||
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.type.*;
|
||||
import ast.type.type.BaseType;
|
||||
import ast.type.type.ReferenceType;
|
||||
import ast.type.type.TypeEnum;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Mapper {
|
||||
// public int mapAccessTypeToOpcode(AccessModifierNode type) {
|
||||
// switch (type.enumAccessTypeNode) {
|
||||
// case EnumAccessTypeNode.PUBLIC:
|
||||
// return Opcodes.ACC_PUBLIC;
|
||||
// case EnumAccessTypeNode.PRIVATE:
|
||||
// return Opcodes.ACC_PRIVATE;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
public int mapAccessTypeToOpcode(AccessModifierNode accessModifierNode) {
|
||||
switch (accessModifierNode.accessType) {
|
||||
case EnumAccessModifierNode.PUBLIC:
|
||||
return Opcodes.ACC_PUBLIC;
|
||||
case EnumAccessModifierNode.PRIVATE:
|
||||
return Opcodes.ACC_PRIVATE;
|
||||
case EnumAccessModifierNode.PUBLIC_STATIC:
|
||||
return Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC;
|
||||
case EnumAccessModifierNode.PRIVATE_STATIC:
|
||||
return Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// public String generateMethodDescriptor(BaseTypeNode baseTypeNode, ParameterListNode parameterListNode) {
|
||||
// String descriptor = "(";
|
||||
// for(ParameterNode parameterNode : parameterListNode.parameters) {
|
||||
// descriptor += getTypeChar(EnumTypeNode.INT);
|
||||
// }
|
||||
// descriptor += ")";
|
||||
// descriptor += getTypeChar(baseTypeNode.enumType);
|
||||
// return descriptor;
|
||||
// }
|
||||
public String generateMethodDescriptor(BaseType type, List<ParameterNode> parameters) {
|
||||
String descriptor = "(";
|
||||
for (ParameterNode parameterNode : parameters) {
|
||||
if(parameterNode.type instanceof BaseType) {
|
||||
descriptor += getTypeChar((BaseType) parameterNode.type);
|
||||
} else {
|
||||
ReferenceType referenceType = (ReferenceType) parameterNode.type;
|
||||
descriptor += "L" + referenceType.getIdentifier() + ";";
|
||||
}
|
||||
}
|
||||
descriptor += ")";
|
||||
descriptor += getTypeChar(type);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
// public String getTypeChar(TypeEnum enumTypeNode) {
|
||||
// String typeChar = "";
|
||||
// switch (enumTypeNode) {
|
||||
// case TypeEnum.INT:
|
||||
// typeChar = "I";
|
||||
// break;
|
||||
// case TypeEnum.CHAR:
|
||||
// typeChar = "C";
|
||||
// break;
|
||||
// case TypeEnum.BOOLEAN:
|
||||
// typeChar = "Z";
|
||||
// break;
|
||||
// }
|
||||
// return typeChar;
|
||||
// }
|
||||
public String getTypeChar(BaseType type) {
|
||||
String typeChar = "";
|
||||
switch (type.getTypeEnum()) {
|
||||
case TypeEnum.INT:
|
||||
typeChar = "I";
|
||||
break;
|
||||
case TypeEnum.CHAR:
|
||||
typeChar = "C";
|
||||
break;
|
||||
case TypeEnum.BOOL:
|
||||
typeChar = "Z";
|
||||
break;
|
||||
case TypeEnum.VOID:
|
||||
typeChar = "V";
|
||||
break;
|
||||
}
|
||||
return typeChar;
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,31 @@
|
||||
package bytecode;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.expressions.binaryexpressions.*;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.NotNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.MainMethodNode;
|
||||
import ast.members.MethodNode;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.statementexpressions.AssignNode;
|
||||
import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.CrementType;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.ChainedMethodNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||
import ast.statements.*;
|
||||
import ast.type.ValueNode;
|
||||
import ast.type.type.BaseType;
|
||||
import ast.type.type.ReferenceType;
|
||||
import ast.type.type.TypeEnum;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -17,78 +39,498 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
private Mapper mapper;
|
||||
private MethodVisitor methodVisitor;
|
||||
|
||||
private List<String> localVaribales;
|
||||
private List<String> localVariables;
|
||||
|
||||
public MethodCodeGen(ClassWriter classWriter) {
|
||||
this.classWriter = classWriter;
|
||||
mapper = new Mapper();
|
||||
localVaribales = new ArrayList<>();
|
||||
localVariables = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
// Method nodes
|
||||
|
||||
@Override
|
||||
public void visit(ConstructorNode constructorNode) {
|
||||
// methodVisitor =
|
||||
// classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.visibility),
|
||||
// "<init>",
|
||||
// "()V",
|
||||
// null,
|
||||
// null);
|
||||
methodVisitor =
|
||||
classWriter.visitMethod(mapper.mapAccessTypeToOpcode(constructorNode.accessType),
|
||||
"<init>",
|
||||
mapper.generateMethodDescriptor(new BaseType(TypeEnum.VOID), constructorNode.parameters),
|
||||
null,
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVariables.add("this");
|
||||
// Add all method parameters to localVariables
|
||||
for (ParameterNode parameterNode : constructorNode.parameters) {
|
||||
localVariables.add(parameterNode.identifier);
|
||||
}
|
||||
|
||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||
methodVisitor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
methodVisitor.visitInsn(RETURN);
|
||||
methodVisitor.visitMaxs(1, 1);
|
||||
|
||||
// Visit all statements
|
||||
for (IStatementNode statementNode : constructorNode.block.statements) {
|
||||
if (statementNode != null) {
|
||||
statementNode.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
methodVisitor.visitMaxs(0, 0);
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MainMethodNode mainMethodNode) {
|
||||
methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(mainMethodNode.accesModifier),
|
||||
mainMethodNode.getIdentifier(),
|
||||
"([Ljava/lang/String;)V",
|
||||
null,
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVariables.add("this");
|
||||
localVariables.add("args");
|
||||
|
||||
// Visit all statements
|
||||
for (IStatementNode statementNode : mainMethodNode.block.statements) {
|
||||
statementNode.accept(this);
|
||||
}
|
||||
|
||||
methodVisitor.visitMaxs(0, 0);
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode methodNode) {
|
||||
// if (methodNode.type instanceof BaseTypeNode baseTypeNode) {
|
||||
// methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.visibility),
|
||||
// methodNode.identifier,
|
||||
// mapper.generateMethodDescriptor(baseTypeNode, methodNode.parameters),
|
||||
// null,
|
||||
// null);
|
||||
methodVisitor = classWriter.visitMethod(mapper.mapAccessTypeToOpcode(methodNode.accesModifier),
|
||||
methodNode.getIdentifier(),
|
||||
mapper.generateMethodDescriptor((BaseType) methodNode.getType(), methodNode.parameters),
|
||||
null,
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVaribales.add("this");
|
||||
// for (ParameterNode parameterNode : methodNode.parameters.parameters) {
|
||||
// localVaribales.add(parameterNode.identifier);
|
||||
// }
|
||||
methodVisitor.visitCode();
|
||||
localVariables.add("this");
|
||||
// Add all method parameters to localVariables
|
||||
for (ParameterNode parameterNode : methodNode.parameters) {
|
||||
localVariables.add(parameterNode.identifier);
|
||||
}
|
||||
|
||||
//test();
|
||||
methodVisitor.visitMaxs(1, localVaribales.size());
|
||||
methodVisitor.visitEnd();
|
||||
// }
|
||||
// Visit all statements
|
||||
for (IStatementNode statementNode : methodNode.block.statements) {
|
||||
statementNode.accept(this);
|
||||
}
|
||||
|
||||
methodVisitor.visitMaxs(0, 0);
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
|
||||
// public void test() {
|
||||
// Label start = new Label();
|
||||
// Label loop = new Label();
|
||||
// Label end = new Label();
|
||||
// methodVisitor.visitLabel(start);
|
||||
// //methodVisitor.visitVarInsn(Opcodes.ICONST_M1, 99);
|
||||
// //methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
// methodVisitor.visitLdcInsn(99);
|
||||
// // methodVisitor.visitInsn(Opcodes.ICONST_0);
|
||||
// //methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ISTORE, 1);
|
||||
// methodVisitor.visitLabel(loop);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
// methodVisitor.visitInsn(Opcodes.ICONST_5);
|
||||
// methodVisitor.visitJumpInsn(Opcodes.IF_ICMPGE, end);
|
||||
// methodVisitor.visitFieldInsn(Opcodes.GETSTATIC,
|
||||
// "java/lang/System", "out",
|
||||
// "Ljava/io/PrintStream;");
|
||||
// methodVisitor.visitLdcInsn("Bytecode");
|
||||
// methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
|
||||
// "java/io/PrintStream", "println",
|
||||
// "(Ljava/lang/String;)V", false);
|
||||
// methodVisitor.visitIincInsn(1, 1);
|
||||
// methodVisitor.visitJumpInsn(Opcodes.GOTO, loop);
|
||||
// methodVisitor.visitLabel(end);
|
||||
// methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
|
||||
// methodVisitor.visitInsn(Opcodes.IRETURN);
|
||||
// methodVisitor.visitEnd();
|
||||
// }
|
||||
|
||||
// Binary expressions
|
||||
|
||||
@Override
|
||||
public void visit(BinaryNode binaryNode) {
|
||||
binaryNode.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CalculationNode calculationNode) {
|
||||
if (calculationNode.dotExpression != null) {
|
||||
calculationNode.dotExpression.accept(this);
|
||||
}
|
||||
if (calculationNode.calculationExpression != null) {
|
||||
calculationNode.calculationExpression.accept(this);
|
||||
}
|
||||
if (calculationNode.operator != null) {
|
||||
switch (calculationNode.operator) {
|
||||
case PLUS:
|
||||
methodVisitor.visitInsn(IADD);
|
||||
break;
|
||||
case MINUS:
|
||||
methodVisitor.visitInsn(ISUB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DotNode dotNode) {
|
||||
if (dotNode.dotExpression != null) {
|
||||
dotNode.dotExpression.accept(this);
|
||||
}
|
||||
if (dotNode.dotSubstractionExpression != null) {
|
||||
dotNode.dotSubstractionExpression.accept(this);
|
||||
}
|
||||
if (dotNode.operator != null) {
|
||||
switch (dotNode.operator) {
|
||||
case DIV:
|
||||
methodVisitor.visitInsn(IDIV);
|
||||
break;
|
||||
case MULT:
|
||||
methodVisitor.visitInsn(IMUL);
|
||||
break;
|
||||
case MOD:
|
||||
methodVisitor.visitInsn(IREM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DotSubstractionNode dotSubstractionNode) {
|
||||
if (dotSubstractionNode.value != null) {
|
||||
dotSubstractionNode.value.accept(this);
|
||||
} else if (dotSubstractionNode.identifier != null) {
|
||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(dotSubstractionNode.identifier));
|
||||
} else if (dotSubstractionNode.memberAccess != null) {
|
||||
dotSubstractionNode.memberAccess.accept(this);
|
||||
} else if (dotSubstractionNode.methodCall != null) {
|
||||
dotSubstractionNode.methodCall.accept(this);
|
||||
} else if (dotSubstractionNode.calculationExpression != null) {
|
||||
dotSubstractionNode.calculationExpression.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NonCalculationNode nonCalculationNode) {
|
||||
Label labelFalse = new Label();
|
||||
Label labelTrue = new Label();
|
||||
switch (nonCalculationNode.operator) {
|
||||
case AND:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFEQ, labelFalse); // Value compared to 0 (false)
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFEQ, labelFalse);
|
||||
break;
|
||||
case OR:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFNE, labelTrue);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFEQ, labelFalse);
|
||||
break;
|
||||
case GREATER:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IF_ICMPLE, labelFalse);
|
||||
break;
|
||||
case LESS:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IF_ICMPGE, labelFalse);
|
||||
break;
|
||||
case GREATER_EQUAL:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IF_ICMPLT, labelFalse);
|
||||
break;
|
||||
case LESS_EQUAL:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IF_ICMPGT, labelFalse);
|
||||
break;
|
||||
case EQUAL:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
if (nonCalculationNode.unaryExpression.getType() instanceof BaseType && nonCalculationNode.expression.getType() instanceof BaseType) {
|
||||
methodVisitor.visitJumpInsn(IF_ICMPNE, labelFalse);
|
||||
} else {
|
||||
methodVisitor.visitJumpInsn(IF_ACMPNE, labelFalse);
|
||||
}
|
||||
break;
|
||||
case NOT_EQUAL:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
nonCalculationNode.expression.accept(this);
|
||||
if (nonCalculationNode.unaryExpression.getType() instanceof BaseType && nonCalculationNode.expression.getType() instanceof BaseType) {
|
||||
methodVisitor.visitJumpInsn(IF_ACMPEQ, labelFalse);
|
||||
} else {
|
||||
methodVisitor.visitJumpInsn(IF_ACMPEQ, labelFalse);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Label labelEndLogicalExpression = new Label();
|
||||
|
||||
methodVisitor.visitLabel(labelTrue);
|
||||
methodVisitor.visitInsn(ICONST_1); // true
|
||||
methodVisitor.visitJumpInsn(GOTO, labelEndLogicalExpression);
|
||||
|
||||
methodVisitor.visitLabel(labelFalse);
|
||||
methodVisitor.visitInsn(ICONST_0); // false
|
||||
|
||||
methodVisitor.visitLabel(labelEndLogicalExpression);
|
||||
}
|
||||
|
||||
|
||||
// Unary expressions
|
||||
|
||||
@Override
|
||||
public void visit(MemberAccessNode memberAccessNode) {
|
||||
// Only used to get, not to put
|
||||
if (memberAccessNode.thisExpr) { // Field
|
||||
// methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), );
|
||||
} else { // Object Attribut
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NotNode notNode) {
|
||||
Label labelFalse = new Label();
|
||||
Label labelTrue = new Label();
|
||||
|
||||
notNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(Opcodes.IFNE, labelFalse); // false if value is true (value != 0)
|
||||
|
||||
Label labelEndLogicalExpression = new Label();
|
||||
|
||||
methodVisitor.visitLabel(labelTrue);
|
||||
methodVisitor.visitInsn(ICONST_1); // true
|
||||
methodVisitor.visitJumpInsn(GOTO, labelEndLogicalExpression);
|
||||
|
||||
methodVisitor.visitLabel(labelFalse);
|
||||
methodVisitor.visitInsn(ICONST_0); // false
|
||||
|
||||
methodVisitor.visitLabel(labelEndLogicalExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryNode unaryNode) {
|
||||
if (unaryNode.thisExp != null) {
|
||||
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
||||
} else if (unaryNode.identifier != null) {
|
||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(unaryNode.identifier));
|
||||
} else if (unaryNode.memberAccess != null) {
|
||||
unaryNode.memberAccess.accept(this);
|
||||
} else if (unaryNode.value != null) {
|
||||
unaryNode.value.accept(this);
|
||||
} else if (unaryNode.notExpression != null) {
|
||||
unaryNode.notExpression.accept(this);
|
||||
} else if (unaryNode.statement != null) {
|
||||
unaryNode.statement.accept(this);
|
||||
} else if (unaryNode.expression != null) {
|
||||
unaryNode.expression.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Statements
|
||||
|
||||
@Override
|
||||
public void visit(IfElseNode ifElseNode) {
|
||||
Label elseLabel = new Label();
|
||||
|
||||
Label[] elseIfLabels = new Label[ifElseNode.elseIfStatements.size()];
|
||||
for (int i = 0; i < ifElseNode.elseIfStatements.size(); i++) {
|
||||
elseIfLabels[i] = new Label();
|
||||
}
|
||||
|
||||
ifElseNode.ifStatement.expression.accept(this);
|
||||
if (ifElseNode.elseIfStatements.isEmpty()) {
|
||||
// No else if
|
||||
methodVisitor.visitJumpInsn(IFEQ, elseLabel);
|
||||
} else {
|
||||
// else if statements
|
||||
methodVisitor.visitJumpInsn(IFEQ, elseIfLabels[0]);
|
||||
}
|
||||
ifElseNode.ifStatement.block.accept(this); // accept if block
|
||||
|
||||
Label endLabel = new Label();
|
||||
methodVisitor.visitJumpInsn(GOTO, endLabel);
|
||||
|
||||
for (int i = 0; i < ifElseNode.elseIfStatements.size(); i++) {
|
||||
methodVisitor.visitLabel(elseIfLabels[i]);
|
||||
ifElseNode.elseIfStatements.get(i).expression.accept(this);
|
||||
if (i + 1 < elseIfLabels.length) {
|
||||
// at least one more else if
|
||||
methodVisitor.visitJumpInsn(IFEQ, elseIfLabels[i + 1]);
|
||||
} else {
|
||||
methodVisitor.visitJumpInsn(IFEQ, elseLabel);
|
||||
}
|
||||
ifElseNode.elseIfStatements.get(i).block.accept(this);
|
||||
methodVisitor.visitJumpInsn(GOTO, endLabel);
|
||||
}
|
||||
|
||||
if (ifElseNode.elseStatement != null) {
|
||||
methodVisitor.visitLabel(elseLabel);
|
||||
ifElseNode.elseStatement.block.accept(this);
|
||||
}
|
||||
|
||||
methodVisitor.visitLabel(endLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVariableDeclarationNode localVariableDeclarationNode) {
|
||||
if (localVariableDeclarationNode.expression != null) {
|
||||
// Process expression
|
||||
localVariableDeclarationNode.expression.accept(this);
|
||||
// Store result of expression in variable
|
||||
if (localVariables.contains(localVariableDeclarationNode.identifier)) {
|
||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
}
|
||||
} else {
|
||||
localVariables.add(localVariableDeclarationNode.identifier);
|
||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!localVariables.contains(localVariableDeclarationNode.identifier)) {
|
||||
localVariables.add(localVariableDeclarationNode.identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignNode assignNode) {
|
||||
// Process expression
|
||||
if (assignNode.expression instanceof IncrementNode) {
|
||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
||||
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||
assign(assignNode);
|
||||
} else if (incrementNode.crementType.equals(CrementType.SUFFIX)) { // Suffix: i++
|
||||
assign(assignNode);
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||
}
|
||||
} else if (assignNode.expression instanceof DecrementNode) {
|
||||
DecrementNode decrementNode = (DecrementNode) assignNode.expression;
|
||||
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), -1);
|
||||
assign(assignNode);
|
||||
} else if (decrementNode.crementType.equals(CrementType.SUFFIX)) {
|
||||
assign(assignNode);
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), 1);
|
||||
}
|
||||
} else {
|
||||
assignNode.expression.accept(this);
|
||||
assign(assignNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void assign(AssignNode assignNode) {
|
||||
if (assignNode.assignable.memberAccess.thisExpr) {
|
||||
assignField(assignNode);
|
||||
} else {
|
||||
assignLocalVar(assignNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void assignLocalVar(AssignNode assignNode) {
|
||||
if (assignNode.expression instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
||||
} else if (assignNode.expression instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
||||
}
|
||||
}
|
||||
|
||||
private void assignField(AssignNode assignNode) {
|
||||
if (assignNode.expression instanceof BaseType) {
|
||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
||||
} else if (assignNode.expression instanceof ReferenceType) {
|
||||
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L"+referenceType.getIdentifier()+";");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewDeclarationNode newDeclarationNode) {
|
||||
methodVisitor.visitTypeInsn(NEW, newDeclarationNode.identifier);
|
||||
methodVisitor.visitInsn(DUP);
|
||||
List<ParameterNode> parameterNodes = new ArrayList<>();
|
||||
for (IExpressionNode expressionNode : newDeclarationNode.expressions) {
|
||||
expressionNode.accept(this);
|
||||
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
|
||||
}
|
||||
methodVisitor.visitMethodInsn(INVOKESPECIAL, newDeclarationNode.identifier, "<init>", mapper.generateMethodDescriptor(new BaseType(TypeEnum.VOID),parameterNodes), false);
|
||||
localVariables.add(newDeclarationNode.identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ValueNode valueNode) {
|
||||
switch (valueNode.valueType) {
|
||||
case INT_VALUE:
|
||||
int intValue = Integer.parseInt(valueNode.value);
|
||||
if (intValue >= Byte.MIN_VALUE && intValue <= Byte.MAX_VALUE) { // load int as byte
|
||||
methodVisitor.visitIntInsn(BIPUSH, intValue);
|
||||
} else if (intValue >= Short.MIN_VALUE && intValue <= Short.MAX_VALUE) { // load int as short
|
||||
methodVisitor.visitIntInsn(SIPUSH, intValue);
|
||||
} else { // load int as const
|
||||
methodVisitor.visitLdcInsn(intValue);
|
||||
}
|
||||
break;
|
||||
case BOOLEAN_VALUE:
|
||||
if (valueNode.value.equals("true")) {
|
||||
methodVisitor.visitInsn(ICONST_1);
|
||||
} else {
|
||||
methodVisitor.visitInsn(ICONST_0);
|
||||
}
|
||||
break;
|
||||
case CHAR_VALUE:
|
||||
char charValue = valueNode.value.charAt(0);
|
||||
if (charValue <= Byte.MAX_VALUE) { // load char as byte
|
||||
methodVisitor.visitIntInsn(BIPUSH, charValue);
|
||||
} else if (charValue <= Short.MAX_VALUE) { // load char as short
|
||||
methodVisitor.visitIntInsn(SIPUSH, charValue);
|
||||
} else { // load char as const
|
||||
methodVisitor.visitLdcInsn(charValue);
|
||||
}
|
||||
break;
|
||||
case NULL_VALUE:
|
||||
methodVisitor.visitInsn(ACONST_NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnNode returnNode) {
|
||||
if (returnNode.voidReturn) { // Return nothing
|
||||
methodVisitor.visitInsn(RETURN);
|
||||
} else { // Return something
|
||||
// Process expression
|
||||
returnNode.expression.accept(this);
|
||||
// Return result of expression
|
||||
if (returnNode.expression.getType() instanceof BaseType) {
|
||||
methodVisitor.visitInsn(IRETURN);
|
||||
} else if (returnNode.expression.getType() instanceof ReferenceType) {
|
||||
methodVisitor.visitInsn(ARETURN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void visit(WhileNode whileNode) {
|
||||
Label loopLabel = new Label();
|
||||
Label endOfLoopLabel = new Label();
|
||||
|
||||
methodVisitor.visitLabel(loopLabel);
|
||||
// while loop
|
||||
whileNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFEQ, endOfLoopLabel); // if condition is false, jump out of loop
|
||||
|
||||
whileNode.block.accept(this);
|
||||
methodVisitor.visitJumpInsn(GOTO, loopLabel);
|
||||
|
||||
methodVisitor.visitLabel(endOfLoopLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ChainedMethodNode chainedMethodNode) {
|
||||
// TODO: Erstmal abwarten
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCallNode methodCallNode) {
|
||||
List<ParameterNode> parameterNodes = new ArrayList<>();
|
||||
for(IExpressionNode expressionNode : methodCallNode.parameters) {
|
||||
expressionNode.accept(this);
|
||||
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
|
||||
}
|
||||
// TODO: Klassenname und Returntype
|
||||
//methodVisitor.visitMethodInsn(INVOKEVIRTUAL, classname, methodCallNode.identifier, mapper.generateMethodDescriptor(returntype, parameterNodes), false);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,56 @@
|
||||
package bytecode.visitor;
|
||||
|
||||
import ast.expressions.binaryexpressions.*;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.NotNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.MainMethodNode;
|
||||
import ast.members.MethodNode;
|
||||
import ast.statementexpressions.AssignNode;
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.ChainedMethodNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||
import ast.statements.*;
|
||||
import ast.type.ValueNode;
|
||||
|
||||
public interface MethodVisitor {
|
||||
// members
|
||||
void visit(ConstructorNode constructorNode);
|
||||
void visit(MethodNode methodNode);
|
||||
void visit(MainMethodNode mainMethodNode);
|
||||
|
||||
// Binary expressions
|
||||
void visit(BinaryNode binaryNode);
|
||||
void visit(CalculationNode calculationNode);
|
||||
void visit(DotNode dotNode);
|
||||
void visit(DotSubstractionNode dotSubstractionNode);
|
||||
void visit(NonCalculationNode nonCalculationNode);
|
||||
|
||||
// Unary expressions
|
||||
void visit(MemberAccessNode memberAccessNode);
|
||||
void visit(NotNode notExpressionNode);
|
||||
void visit(UnaryNode unaryExpressionNode);
|
||||
|
||||
// statements
|
||||
void visit(IfElseNode ifElseNode);
|
||||
|
||||
void visit(LocalVariableDeclarationNode localVariableDeclarationNode);
|
||||
void visit(ReturnNode returnNode);
|
||||
void visit(WhileNode whileNode);
|
||||
|
||||
// statement expression
|
||||
void visit(ChainedMethodNode chainedMethodNode);
|
||||
void visit(MethodCallNode methodCallNode);
|
||||
|
||||
void visit(AssignNode assignNode);
|
||||
void visit(NewDeclarationNode newDeclarationNode);
|
||||
|
||||
// type
|
||||
void visit(ValueNode valueNode);
|
||||
|
||||
}
|
||||
|
@@ -91,15 +91,15 @@ public class Main {
|
||||
|
||||
/*------------------------- Semantic Analyzer -> typed AST -------------------------*/
|
||||
// Use the SemanticAnalyzer to generate a typed AST
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
//ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
// Log the typed AST
|
||||
RaupenLogger.logSemanticAnalyzer(typedAst);
|
||||
RaupenLogger.logSemanticAnalyzer(abstractSyntaxTree);
|
||||
|
||||
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
||||
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath);
|
||||
assert typedAst != null;
|
||||
byteCodeGenerator.visit((ProgramNode) typedAst);
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, true, true);
|
||||
assert abstractSyntaxTree != null;
|
||||
byteCodeGenerator.visit((ProgramNode) abstractSyntaxTree);
|
||||
// Log the bytecode generation
|
||||
RaupenLogger.logBytecodeGenerator();
|
||||
}
|
||||
|
@@ -3,10 +3,7 @@ package parser.astBuilder;
|
||||
import ast.*;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.expressions.binaryexpressions.CalculationNode;
|
||||
import ast.expressions.binaryexpressions.DotNode;
|
||||
import ast.expressions.binaryexpressions.DotSubstractionNode;
|
||||
import ast.expressions.binaryexpressions.NonCalculationNode;
|
||||
import ast.expressions.binaryexpressions.*;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.NotNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
@@ -170,6 +167,8 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
return visitForStatement(ctx.forStatement());
|
||||
} else if(ctx.ifElseStatement() != null) {
|
||||
return visitIfElseStatement(ctx.ifElseStatement());
|
||||
} else if(ctx.switchStatement() != null) {
|
||||
return visitSwitchStatement(ctx.switchStatement());
|
||||
} else if(ctx.statementExpression() != null) {
|
||||
return visitStatementExpression(ctx.statementExpression());
|
||||
}
|
||||
@@ -321,6 +320,49 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx) {
|
||||
UnaryNode switchExpression = (UnaryNode) visit(ctx.expression());
|
||||
|
||||
List<IfNode> ifNodes = new ArrayList<>();
|
||||
|
||||
for (SimpleJavaParser.CaseStatementContext caseCtx : ctx.caseStatement()) {
|
||||
IExpressionNode caseExpression = (IExpressionNode) visit(caseCtx.value());
|
||||
|
||||
// Condition as NonCalculationNode -> Equals Expression
|
||||
NonCalculationNode condition = new NonCalculationNode(switchExpression, "==", caseExpression);
|
||||
|
||||
BlockNode caseBlock = new BlockNode();
|
||||
for (SimpleJavaParser.StatementContext stmtCtx : caseCtx.statement()) {
|
||||
caseBlock.addStatement((IStatementNode) visit(stmtCtx));
|
||||
}
|
||||
|
||||
// Each case as if
|
||||
IfNode ifNode = new IfNode(condition, caseBlock);
|
||||
ifNodes.add(ifNode);
|
||||
}
|
||||
|
||||
// Check if has Default
|
||||
ElseNode defaulElseNode = null;
|
||||
if (ctx.defaultStatement() != null) {
|
||||
BlockNode defaultBlock = new BlockNode();
|
||||
for (SimpleJavaParser.StatementContext stmtCtx : ctx.defaultStatement().statement()) {
|
||||
defaultBlock.addStatement((IStatementNode) visit(stmtCtx));
|
||||
}
|
||||
// Default als letztes Else Statement
|
||||
defaulElseNode = new ElseNode(defaultBlock);
|
||||
}
|
||||
|
||||
IfElseNode ifElseNode = new IfElseNode(ifNodes.getFirst(),defaulElseNode);
|
||||
ifNodes.removeFirst();
|
||||
|
||||
for (IfNode ifNode : ifNodes){
|
||||
ifElseNode.addElseIfStatement(ifNode);
|
||||
}
|
||||
|
||||
return ifElseNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode visitAssign(SimpleJavaParser.AssignContext ctx) {
|
||||
return new AssignNode((AssignableNode) visit(ctx.assignableExpression()), (IExpressionNode) visit(ctx.expression()));
|
||||
|
File diff suppressed because one or more lines are too long
@@ -41,14 +41,18 @@ Else=40
|
||||
For=41
|
||||
Return=42
|
||||
New=43
|
||||
CharValue=44
|
||||
IntValue=45
|
||||
BooleanValue=46
|
||||
NullValue=47
|
||||
Identifier=48
|
||||
WS=49
|
||||
InlineComment=50
|
||||
MultilineComment=51
|
||||
Switch=44
|
||||
Case=45
|
||||
Default=46
|
||||
Colon=47
|
||||
CharValue=48
|
||||
IntValue=49
|
||||
BooleanValue=50
|
||||
NullValue=51
|
||||
Identifier=52
|
||||
WS=53
|
||||
InlineComment=54
|
||||
MultilineComment=55
|
||||
'++'=1
|
||||
'--'=2
|
||||
'void'=3
|
||||
@@ -87,4 +91,8 @@ MultilineComment=51
|
||||
'for'=41
|
||||
'return'=42
|
||||
'new'=43
|
||||
'null'=47
|
||||
'switch'=44
|
||||
'case'=45
|
||||
'default'=46
|
||||
':'=47
|
||||
'null'=51
|
||||
|
@@ -252,6 +252,42 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterCaseStatement(SimpleJavaParser.CaseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitCaseStatement(SimpleJavaParser.CaseStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@@ -152,6 +152,27 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitCaseStatement(SimpleJavaParser.CaseStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
@@ -23,9 +23,9 @@ public class SimpleJavaLexer extends Lexer {
|
||||
Less=20, GreaterEqual=21, LessEqual=22, Equal=23, NotEqual=24, Not=25,
|
||||
And=26, Or=27, Dot=28, OpenRoundBracket=29, ClosedRoundBracket=30, OpenCurlyBracket=31,
|
||||
ClosedCurlyBracket=32, Semicolon=33, Comma=34, Class=35, This=36, While=37,
|
||||
Do=38, If=39, Else=40, For=41, Return=42, New=43, CharValue=44, IntValue=45,
|
||||
BooleanValue=46, NullValue=47, Identifier=48, WS=49, InlineComment=50,
|
||||
MultilineComment=51;
|
||||
Do=38, If=39, Else=40, For=41, Return=42, New=43, Switch=44, Case=45,
|
||||
Default=46, Colon=47, CharValue=48, IntValue=49, BooleanValue=50, NullValue=51,
|
||||
Identifier=52, WS=53, InlineComment=54, MultilineComment=55;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
@@ -42,9 +42,10 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"GreaterEqual", "LessEqual", "Equal", "NotEqual", "Not", "And", "Or",
|
||||
"Dot", "OpenRoundBracket", "ClosedRoundBracket", "OpenCurlyBracket",
|
||||
"ClosedCurlyBracket", "Semicolon", "Comma", "Class", "This", "While",
|
||||
"Do", "If", "Else", "For", "Return", "New", "CharValue", "IntValue",
|
||||
"BooleanValue", "NullValue", "Alphabetic", "Numeric", "ValidIdentSymbols",
|
||||
"Identifier", "WS", "InlineComment", "MultilineComment"
|
||||
"Do", "If", "Else", "For", "Return", "New", "Switch", "Case", "Default",
|
||||
"Colon", "CharValue", "IntValue", "BooleanValue", "NullValue", "Alphabetic",
|
||||
"Numeric", "ValidIdentSymbols", "Identifier", "WS", "InlineComment",
|
||||
"MultilineComment"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
@@ -56,7 +57,8 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"'+'", "'-'", "'*'", "'%'", "'/'", "'>'", "'<'", "'>='", "'<='", "'=='",
|
||||
"'!='", "'!'", "'&&'", "'||'", "'.'", "'('", "')'", "'{'", "'}'", "';'",
|
||||
"','", "'class'", "'this'", "'while'", "'do'", "'if'", "'else'", "'for'",
|
||||
"'return'", "'new'", null, null, null, "'null'"
|
||||
"'return'", "'new'", "'switch'", "'case'", "'default'", "':'", null,
|
||||
null, null, "'null'"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
@@ -68,9 +70,9 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"Greater", "Less", "GreaterEqual", "LessEqual", "Equal", "NotEqual",
|
||||
"Not", "And", "Or", "Dot", "OpenRoundBracket", "ClosedRoundBracket",
|
||||
"OpenCurlyBracket", "ClosedCurlyBracket", "Semicolon", "Comma", "Class",
|
||||
"This", "While", "Do", "If", "Else", "For", "Return", "New", "CharValue",
|
||||
"IntValue", "BooleanValue", "NullValue", "Identifier", "WS", "InlineComment",
|
||||
"MultilineComment"
|
||||
"This", "While", "Do", "If", "Else", "For", "Return", "New", "Switch",
|
||||
"Case", "Default", "Colon", "CharValue", "IntValue", "BooleanValue",
|
||||
"NullValue", "Identifier", "WS", "InlineComment", "MultilineComment"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
@@ -132,7 +134,7 @@ public class SimpleJavaLexer extends Lexer {
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u00003\u019d\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0004\u00007\u01bb\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"+
|
||||
@@ -147,245 +149,263 @@ public class SimpleJavaLexer extends Lexer {
|
||||
"&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+
|
||||
"+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+
|
||||
"0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u00025\u0007"+
|
||||
"5\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001"+
|
||||
"\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003"+
|
||||
"5\u00026\u00076\u00027\u00077\u00028\u00078\u00029\u00079\u0001\u0000"+
|
||||
"\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+
|
||||
"\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+
|
||||
"\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+
|
||||
"\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+
|
||||
"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+
|
||||
"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0003\u0006\u00b2\b\u0006\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0006\u0003\u0006\u00ba\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\u0007\u0001\b\u0001\b\u0001\b\u0003\b\u00de\b\b\u0001\t\u0001\t"+
|
||||
"\u0003\t\u00e2\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003"+
|
||||
"\n\u00ea\b\n\u0001\u000b\u0001\u000b\u0003\u000b\u00ee\b\u000b\u0001\f"+
|
||||
"\u0001\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f"+
|
||||
"\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012"+
|
||||
"\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015"+
|
||||
"\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017"+
|
||||
"\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019"+
|
||||
"\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b"+
|
||||
"\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e"+
|
||||
"\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001"+
|
||||
"\"\u0001\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001"+
|
||||
"$\u0001$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001"+
|
||||
"&\u0001\'\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001("+
|
||||
"\u0001)\u0001)\u0001)\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0001"+
|
||||
"*\u0001*\u0001+\u0001+\u0005+\u014f\b+\n+\f+\u0152\t+\u0001+\u0001+\u0001"+
|
||||
",\u0003,\u0157\b,\u0001,\u0004,\u015a\b,\u000b,\f,\u015b\u0001-\u0001"+
|
||||
"-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0003-\u0167\b-\u0001"+
|
||||
".\u0001.\u0001.\u0001.\u0001.\u0001/\u0001/\u00010\u00010\u00011\u0001"+
|
||||
"1\u00011\u00031\u0175\b1\u00012\u00012\u00052\u0179\b2\n2\f2\u017c\t2"+
|
||||
"\u00013\u00043\u017f\b3\u000b3\f3\u0180\u00013\u00013\u00014\u00014\u0001"+
|
||||
"4\u00014\u00054\u0189\b4\n4\f4\u018c\t4\u00014\u00014\u00015\u00015\u0001"+
|
||||
"5\u00015\u00055\u0194\b5\n5\f5\u0197\t5\u00015\u00015\u00015\u00015\u0001"+
|
||||
"5\u0001\u0195\u00006\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$I%K&M\'O(Q)S*U+W,Y-[.]/_\u0000a\u0000c\u0000e0g1i2k"+
|
||||
"3\u0001\u0000\u0005\u0002\u0000\n\n\r\r\u0002\u0000AZaz\u0001\u000009"+
|
||||
"\u0002\u0000$$__\u0003\u0000\t\n\r\r \u01af\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\u0000G\u0001\u0000\u0000\u0000"+
|
||||
"\u0000I\u0001\u0000\u0000\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M"+
|
||||
"\u0001\u0000\u0000\u0000\u0000O\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\u0000e\u0001\u0000"+
|
||||
"\u0000\u0000\u0000g\u0001\u0000\u0000\u0000\u0000i\u0001\u0000\u0000\u0000"+
|
||||
"\u0000k\u0001\u0000\u0000\u0000\u0001m\u0001\u0000\u0000\u0000\u0003p"+
|
||||
"\u0001\u0000\u0000\u0000\u0005s\u0001\u0000\u0000\u0000\u0007x\u0001\u0000"+
|
||||
"\u0000\u0000\t\u0080\u0001\u0000\u0000\u0000\u000b\u0085\u0001\u0000\u0000"+
|
||||
"\u0000\r\u00b1\u0001\u0000\u0000\u0000\u000f\u00b3\u0001\u0000\u0000\u0000"+
|
||||
"\u0011\u00dd\u0001\u0000\u0000\u0000\u0013\u00e1\u0001\u0000\u0000\u0000"+
|
||||
"\u0015\u00e9\u0001\u0000\u0000\u0000\u0017\u00ed\u0001\u0000\u0000\u0000"+
|
||||
"\u0019\u00ef\u0001\u0000\u0000\u0000\u001b\u00f1\u0001\u0000\u0000\u0000"+
|
||||
"\u001d\u00f3\u0001\u0000\u0000\u0000\u001f\u00f5\u0001\u0000\u0000\u0000"+
|
||||
"!\u00f7\u0001\u0000\u0000\u0000#\u00f9\u0001\u0000\u0000\u0000%\u00fb"+
|
||||
"\u0001\u0000\u0000\u0000\'\u00fd\u0001\u0000\u0000\u0000)\u00ff\u0001"+
|
||||
"\u0000\u0000\u0000+\u0102\u0001\u0000\u0000\u0000-\u0105\u0001\u0000\u0000"+
|
||||
"\u0000/\u0108\u0001\u0000\u0000\u00001\u010b\u0001\u0000\u0000\u00003"+
|
||||
"\u010d\u0001\u0000\u0000\u00005\u0110\u0001\u0000\u0000\u00007\u0113\u0001"+
|
||||
"\u0000\u0000\u00009\u0115\u0001\u0000\u0000\u0000;\u0117\u0001\u0000\u0000"+
|
||||
"\u0000=\u0119\u0001\u0000\u0000\u0000?\u011b\u0001\u0000\u0000\u0000A"+
|
||||
"\u011d\u0001\u0000\u0000\u0000C\u011f\u0001\u0000\u0000\u0000E\u0121\u0001"+
|
||||
"\u0000\u0000\u0000G\u0127\u0001\u0000\u0000\u0000I\u012c\u0001\u0000\u0000"+
|
||||
"\u0000K\u0132\u0001\u0000\u0000\u0000M\u0135\u0001\u0000\u0000\u0000O"+
|
||||
"\u0138\u0001\u0000\u0000\u0000Q\u013d\u0001\u0000\u0000\u0000S\u0141\u0001"+
|
||||
"\u0000\u0000\u0000U\u0148\u0001\u0000\u0000\u0000W\u014c\u0001\u0000\u0000"+
|
||||
"\u0000Y\u0156\u0001\u0000\u0000\u0000[\u0166\u0001\u0000\u0000\u0000]"+
|
||||
"\u0168\u0001\u0000\u0000\u0000_\u016d\u0001\u0000\u0000\u0000a\u016f\u0001"+
|
||||
"\u0000\u0000\u0000c\u0174\u0001\u0000\u0000\u0000e\u0176\u0001\u0000\u0000"+
|
||||
"\u0000g\u017e\u0001\u0000\u0000\u0000i\u0184\u0001\u0000\u0000\u0000k"+
|
||||
"\u018f\u0001\u0000\u0000\u0000mn\u0005+\u0000\u0000no\u0005+\u0000\u0000"+
|
||||
"o\u0002\u0001\u0000\u0000\u0000pq\u0005-\u0000\u0000qr\u0005-\u0000\u0000"+
|
||||
"r\u0004\u0001\u0000\u0000\u0000st\u0005v\u0000\u0000tu\u0005o\u0000\u0000"+
|
||||
"uv\u0005i\u0000\u0000vw\u0005d\u0000\u0000w\u0006\u0001\u0000\u0000\u0000"+
|
||||
"xy\u0005b\u0000\u0000yz\u0005o\u0000\u0000z{\u0005o\u0000\u0000{|\u0005"+
|
||||
"l\u0000\u0000|}\u0005e\u0000\u0000}~\u0005a\u0000\u0000~\u007f\u0005n"+
|
||||
"\u0000\u0000\u007f\b\u0001\u0000\u0000\u0000\u0080\u0081\u0005c\u0000"+
|
||||
"\u0000\u0081\u0082\u0005h\u0000\u0000\u0082\u0083\u0005a\u0000\u0000\u0083"+
|
||||
"\u0084\u0005r\u0000\u0000\u0084\n\u0001\u0000\u0000\u0000\u0085\u0086"+
|
||||
"\u0005i\u0000\u0000\u0086\u0087\u0005n\u0000\u0000\u0087\u0088\u0005t"+
|
||||
"\u0000\u0000\u0088\f\u0001\u0000\u0000\u0000\u0089\u008a\u0005p\u0000"+
|
||||
"\u0000\u008a\u008b\u0005u\u0000\u0000\u008b\u008c\u0005b\u0000\u0000\u008c"+
|
||||
"\u008d\u0005l\u0000\u0000\u008d\u008e\u0005i\u0000\u0000\u008e\u00b2\u0005"+
|
||||
"c\u0000\u0000\u008f\u0090\u0005p\u0000\u0000\u0090\u0091\u0005r\u0000"+
|
||||
"\u0000\u0091\u0092\u0005i\u0000\u0000\u0092\u0093\u0005v\u0000\u0000\u0093"+
|
||||
"\u0094\u0005a\u0000\u0000\u0094\u0095\u0005t\u0000\u0000\u0095\u00b2\u0005"+
|
||||
"e\u0000\u0000\u0096\u0097\u0005p\u0000\u0000\u0097\u0098\u0005u\u0000"+
|
||||
"\u0000\u0098\u0099\u0005b\u0000\u0000\u0099\u009a\u0005l\u0000\u0000\u009a"+
|
||||
"\u009b\u0005i\u0000\u0000\u009b\u009c\u0005c\u0000\u0000\u009c\u009d\u0005"+
|
||||
" \u0000\u0000\u009d\u009e\u0005s\u0000\u0000\u009e\u009f\u0005t\u0000"+
|
||||
"\u0000\u009f\u00a0\u0005a\u0000\u0000\u00a0\u00a1\u0005t\u0000\u0000\u00a1"+
|
||||
"\u00a2\u0005i\u0000\u0000\u00a2\u00b2\u0005c\u0000\u0000\u00a3\u00a4\u0005"+
|
||||
"p\u0000\u0000\u00a4\u00a5\u0005r\u0000\u0000\u00a5\u00a6\u0005i\u0000"+
|
||||
"\u0000\u00a6\u00a7\u0005v\u0000\u0000\u00a7\u00a8\u0005a\u0000\u0000\u00a8"+
|
||||
"\u00a9\u0005t\u0000\u0000\u00a9\u00aa\u0005e\u0000\u0000\u00aa\u00ab\u0005"+
|
||||
" \u0000\u0000\u00ab\u00ac\u0005s\u0000\u0000\u00ac\u00ad\u0005t\u0000"+
|
||||
"\u0000\u00ad\u00ae\u0005a\u0000\u0000\u00ae\u00af\u0005t\u0000\u0000\u00af"+
|
||||
"\u00b0\u0005i\u0000\u0000\u00b0\u00b2\u0005c\u0000\u0000\u00b1\u0089\u0001"+
|
||||
"\u0000\u0000\u0000\u00b1\u008f\u0001\u0000\u0000\u0000\u00b1\u0096\u0001"+
|
||||
"\u0000\u0000\u0000\u00b1\u00a3\u0001\u0000\u0000\u0000\u00b2\u000e\u0001"+
|
||||
"\u0000\u0000\u0000\u00b3\u00b4\u0005p\u0000\u0000\u00b4\u00b5\u0005u\u0000"+
|
||||
"\u0000\u00b5\u00b6\u0005b\u0000\u0000\u00b6\u00b7\u0005l\u0000\u0000\u00b7"+
|
||||
"\u00b8\u0005i\u0000\u0000\u00b8\u00b9\u0005c\u0000\u0000\u00b9\u00ba\u0005"+
|
||||
" \u0000\u0000\u00ba\u00bb\u0005s\u0000\u0000\u00bb\u00bc\u0005t\u0000"+
|
||||
"\u0000\u00bc\u00bd\u0005a\u0000\u0000\u00bd\u00be\u0005t\u0000\u0000\u00be"+
|
||||
"\u00bf\u0005i\u0000\u0000\u00bf\u00c0\u0005c\u0000\u0000\u00c0\u00c1\u0005"+
|
||||
" \u0000\u0000\u00c1\u00c2\u0005v\u0000\u0000\u00c2\u00c3\u0005o\u0000"+
|
||||
"\u0000\u00c3\u00c4\u0005i\u0000\u0000\u00c4\u00c5\u0005d\u0000\u0000\u00c5"+
|
||||
"\u00c6\u0005 \u0000\u0000\u00c6\u00c7\u0005m\u0000\u0000\u00c7\u00c8\u0005"+
|
||||
"a\u0000\u0000\u00c8\u00c9\u0005i\u0000\u0000\u00c9\u00ca\u0005n\u0000"+
|
||||
"\u0000\u00ca\u00cb\u0005(\u0000\u0000\u00cb\u00cc\u0005S\u0000\u0000\u00cc"+
|
||||
"\u00cd\u0005t\u0000\u0000\u00cd\u00ce\u0005r\u0000\u0000\u00ce\u00cf\u0005"+
|
||||
"i\u0000\u0000\u00cf\u00d0\u0005n\u0000\u0000\u00d0\u00d1\u0005g\u0000"+
|
||||
"\u0000\u00d1\u00d2\u0005[\u0000\u0000\u00d2\u00d3\u0005]\u0000\u0000\u00d3"+
|
||||
"\u00d4\u0005 \u0000\u0000\u00d4\u00d5\u0005a\u0000\u0000\u00d5\u00d6\u0005"+
|
||||
"r\u0000\u0000\u00d6\u00d7\u0005g\u0000\u0000\u00d7\u00d8\u0005s\u0000"+
|
||||
"\u0000\u00d8\u00d9\u0005)\u0000\u0000\u00d9\u0010\u0001\u0000\u0000\u0000"+
|
||||
"\u00da\u00de\u0003\u001f\u000f\u0000\u00db\u00de\u0003#\u0011\u0000\u00dc"+
|
||||
"\u00de\u0003!\u0010\u0000\u00dd\u00da\u0001\u0000\u0000\u0000\u00dd\u00db"+
|
||||
"\u0001\u0000\u0000\u0000\u00dd\u00dc\u0001\u0000\u0000\u0000\u00de\u0012"+
|
||||
"\u0001\u0000\u0000\u0000\u00df\u00e2\u0003\u001b\r\u0000\u00e0\u00e2\u0003"+
|
||||
"\u001d\u000e\u0000\u00e1\u00df\u0001\u0000\u0000\u0000\u00e1\u00e0\u0001"+
|
||||
"\u0000\u0000\u0000\u00e2\u0014\u0001\u0000\u0000\u0000\u00e3\u00ea\u0003"+
|
||||
"%\u0012\u0000\u00e4\u00ea\u0003\'\u0013\u0000\u00e5\u00ea\u0003)\u0014"+
|
||||
"\u0000\u00e6\u00ea\u0003+\u0015\u0000\u00e7\u00ea\u0003-\u0016\u0000\u00e8"+
|
||||
"\u00ea\u0003/\u0017\u0000\u00e9\u00e3\u0001\u0000\u0000\u0000\u00e9\u00e4"+
|
||||
"\u0001\u0000\u0000\u0000\u00e9\u00e5\u0001\u0000\u0000\u0000\u00e9\u00e6"+
|
||||
"\u0001\u0000\u0000\u0000\u00e9\u00e7\u0001\u0000\u0000\u0000\u00e9\u00e8"+
|
||||
"\u0001\u0000\u0000\u0000\u00ea\u0016\u0001\u0000\u0000\u0000\u00eb\u00ee"+
|
||||
"\u00033\u0019\u0000\u00ec\u00ee\u00035\u001a\u0000\u00ed\u00eb\u0001\u0000"+
|
||||
"\u0000\u0000\u00ed\u00ec\u0001\u0000\u0000\u0000\u00ee\u0018\u0001\u0000"+
|
||||
"\u0000\u0000\u00ef\u00f0\u0005=\u0000\u0000\u00f0\u001a\u0001\u0000\u0000"+
|
||||
"\u0000\u00f1\u00f2\u0005+\u0000\u0000\u00f2\u001c\u0001\u0000\u0000\u0000"+
|
||||
"\u00f3\u00f4\u0005-\u0000\u0000\u00f4\u001e\u0001\u0000\u0000\u0000\u00f5"+
|
||||
"\u00f6\u0005*\u0000\u0000\u00f6 \u0001\u0000\u0000\u0000\u00f7\u00f8\u0005"+
|
||||
"%\u0000\u0000\u00f8\"\u0001\u0000\u0000\u0000\u00f9\u00fa\u0005/\u0000"+
|
||||
"\u0000\u00fa$\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005>\u0000\u0000\u00fc"+
|
||||
"&\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005<\u0000\u0000\u00fe(\u0001"+
|
||||
"\u0000\u0000\u0000\u00ff\u0100\u0005>\u0000\u0000\u0100\u0101\u0005=\u0000"+
|
||||
"\u0000\u0101*\u0001\u0000\u0000\u0000\u0102\u0103\u0005<\u0000\u0000\u0103"+
|
||||
"\u0104\u0005=\u0000\u0000\u0104,\u0001\u0000\u0000\u0000\u0105\u0106\u0005"+
|
||||
"=\u0000\u0000\u0106\u0107\u0005=\u0000\u0000\u0107.\u0001\u0000\u0000"+
|
||||
"\u0000\u0108\u0109\u0005!\u0000\u0000\u0109\u010a\u0005=\u0000\u0000\u010a"+
|
||||
"0\u0001\u0000\u0000\u0000\u010b\u010c\u0005!\u0000\u0000\u010c2\u0001"+
|
||||
"\u0000\u0000\u0000\u010d\u010e\u0005&\u0000\u0000\u010e\u010f\u0005&\u0000"+
|
||||
"\u0000\u010f4\u0001\u0000\u0000\u0000\u0110\u0111\u0005|\u0000\u0000\u0111"+
|
||||
"\u0112\u0005|\u0000\u0000\u01126\u0001\u0000\u0000\u0000\u0113\u0114\u0005"+
|
||||
".\u0000\u0000\u01148\u0001\u0000\u0000\u0000\u0115\u0116\u0005(\u0000"+
|
||||
"\u0000\u0116:\u0001\u0000\u0000\u0000\u0117\u0118\u0005)\u0000\u0000\u0118"+
|
||||
"<\u0001\u0000\u0000\u0000\u0119\u011a\u0005{\u0000\u0000\u011a>\u0001"+
|
||||
"\u0000\u0000\u0000\u011b\u011c\u0005}\u0000\u0000\u011c@\u0001\u0000\u0000"+
|
||||
"\u0000\u011d\u011e\u0005;\u0000\u0000\u011eB\u0001\u0000\u0000\u0000\u011f"+
|
||||
"\u0120\u0005,\u0000\u0000\u0120D\u0001\u0000\u0000\u0000\u0121\u0122\u0005"+
|
||||
"c\u0000\u0000\u0122\u0123\u0005l\u0000\u0000\u0123\u0124\u0005a\u0000"+
|
||||
"\u0000\u0124\u0125\u0005s\u0000\u0000\u0125\u0126\u0005s\u0000\u0000\u0126"+
|
||||
"F\u0001\u0000\u0000\u0000\u0127\u0128\u0005t\u0000\u0000\u0128\u0129\u0005"+
|
||||
"h\u0000\u0000\u0129\u012a\u0005i\u0000\u0000\u012a\u012b\u0005s\u0000"+
|
||||
"\u0000\u012bH\u0001\u0000\u0000\u0000\u012c\u012d\u0005w\u0000\u0000\u012d"+
|
||||
"\u012e\u0005h\u0000\u0000\u012e\u012f\u0005i\u0000\u0000\u012f\u0130\u0005"+
|
||||
"l\u0000\u0000\u0130\u0131\u0005e\u0000\u0000\u0131J\u0001\u0000\u0000"+
|
||||
"\u0000\u0132\u0133\u0005d\u0000\u0000\u0133\u0134\u0005o\u0000\u0000\u0134"+
|
||||
"L\u0001\u0000\u0000\u0000\u0135\u0136\u0005i\u0000\u0000\u0136\u0137\u0005"+
|
||||
"f\u0000\u0000\u0137N\u0001\u0000\u0000\u0000\u0138\u0139\u0005e\u0000"+
|
||||
"\u0000\u0139\u013a\u0005l\u0000\u0000\u013a\u013b\u0005s\u0000\u0000\u013b"+
|
||||
"\u013c\u0005e\u0000\u0000\u013cP\u0001\u0000\u0000\u0000\u013d\u013e\u0005"+
|
||||
"f\u0000\u0000\u013e\u013f\u0005o\u0000\u0000\u013f\u0140\u0005r\u0000"+
|
||||
"\u0000\u0140R\u0001\u0000\u0000\u0000\u0141\u0142\u0005r\u0000\u0000\u0142"+
|
||||
"\u0143\u0005e\u0000\u0000\u0143\u0144\u0005t\u0000\u0000\u0144\u0145\u0005"+
|
||||
"u\u0000\u0000\u0145\u0146\u0005r\u0000\u0000\u0146\u0147\u0005n\u0000"+
|
||||
"\u0000\u0147T\u0001\u0000\u0000\u0000\u0148\u0149\u0005n\u0000\u0000\u0149"+
|
||||
"\u014a\u0005e\u0000\u0000\u014a\u014b\u0005w\u0000\u0000\u014bV\u0001"+
|
||||
"\u0000\u0000\u0000\u014c\u0150\u0005\'\u0000\u0000\u014d\u014f\b\u0000"+
|
||||
"\u0000\u0000\u014e\u014d\u0001\u0000\u0000\u0000\u014f\u0152\u0001\u0000"+
|
||||
"\u0000\u0000\u0150\u014e\u0001\u0000\u0000\u0000\u0150\u0151\u0001\u0000"+
|
||||
"\u0000\u0000\u0151\u0153\u0001\u0000\u0000\u0000\u0152\u0150\u0001\u0000"+
|
||||
"\u0000\u0000\u0153\u0154\u0005\'\u0000\u0000\u0154X\u0001\u0000\u0000"+
|
||||
"\u0000\u0155\u0157\u0003\u001d\u000e\u0000\u0156\u0155\u0001\u0000\u0000"+
|
||||
"\u0000\u0156\u0157\u0001\u0000\u0000\u0000\u0157\u0159\u0001\u0000\u0000"+
|
||||
"\u0000\u0158\u015a\u0003a0\u0000\u0159\u0158\u0001\u0000\u0000\u0000\u015a"+
|
||||
"\u015b\u0001\u0000\u0000\u0000\u015b\u0159\u0001\u0000\u0000\u0000\u015b"+
|
||||
"\u015c\u0001\u0000\u0000\u0000\u015cZ\u0001\u0000\u0000\u0000\u015d\u015e"+
|
||||
"\u0005t\u0000\u0000\u015e\u015f\u0005r\u0000\u0000\u015f\u0160\u0005u"+
|
||||
"\u0000\u0000\u0160\u0167\u0005e\u0000\u0000\u0161\u0162\u0005f\u0000\u0000"+
|
||||
"\u0162\u0163\u0005a\u0000\u0000\u0163\u0164\u0005l\u0000\u0000\u0164\u0165"+
|
||||
"\u0005s\u0000\u0000\u0165\u0167\u0005e\u0000\u0000\u0166\u015d\u0001\u0000"+
|
||||
"\u0000\u0000\u0166\u0161\u0001\u0000\u0000\u0000\u0167\\\u0001\u0000\u0000"+
|
||||
"\u0000\u0168\u0169\u0005n\u0000\u0000\u0169\u016a\u0005u\u0000\u0000\u016a"+
|
||||
"\u016b\u0005l\u0000\u0000\u016b\u016c\u0005l\u0000\u0000\u016c^\u0001"+
|
||||
"\u0000\u0000\u0000\u016d\u016e\u0007\u0001\u0000\u0000\u016e`\u0001\u0000"+
|
||||
"\u0000\u0000\u016f\u0170\u0007\u0002\u0000\u0000\u0170b\u0001\u0000\u0000"+
|
||||
"\u0000\u0171\u0175\u0003_/\u0000\u0172\u0175\u0003a0\u0000\u0173\u0175"+
|
||||
"\u0007\u0003\u0000\u0000\u0174\u0171\u0001\u0000\u0000\u0000\u0174\u0172"+
|
||||
"\u0001\u0000\u0000\u0000\u0174\u0173\u0001\u0000\u0000\u0000\u0175d\u0001"+
|
||||
"\u0000\u0000\u0000\u0176\u017a\u0003_/\u0000\u0177\u0179\u0003c1\u0000"+
|
||||
"\u0178\u0177\u0001\u0000\u0000\u0000\u0179\u017c\u0001\u0000\u0000\u0000"+
|
||||
"\u017a\u0178\u0001\u0000\u0000\u0000\u017a\u017b\u0001\u0000\u0000\u0000"+
|
||||
"\u017bf\u0001\u0000\u0000\u0000\u017c\u017a\u0001\u0000\u0000\u0000\u017d"+
|
||||
"\u017f\u0007\u0004\u0000\u0000\u017e\u017d\u0001\u0000\u0000\u0000\u017f"+
|
||||
"\u0180\u0001\u0000\u0000\u0000\u0180\u017e\u0001\u0000\u0000\u0000\u0180"+
|
||||
"\u0181\u0001\u0000\u0000\u0000\u0181\u0182\u0001\u0000\u0000\u0000\u0182"+
|
||||
"\u0183\u00063\u0000\u0000\u0183h\u0001\u0000\u0000\u0000\u0184\u0185\u0005"+
|
||||
"/\u0000\u0000\u0185\u0186\u0005/\u0000\u0000\u0186\u018a\u0001\u0000\u0000"+
|
||||
"\u0000\u0187\u0189\b\u0000\u0000\u0000\u0188\u0187\u0001\u0000\u0000\u0000"+
|
||||
"\u0189\u018c\u0001\u0000\u0000\u0000\u018a\u0188\u0001\u0000\u0000\u0000"+
|
||||
"\u018a\u018b\u0001\u0000\u0000\u0000\u018b\u018d\u0001\u0000\u0000\u0000"+
|
||||
"\u018c\u018a\u0001\u0000\u0000\u0000\u018d\u018e\u00064\u0000\u0000\u018e"+
|
||||
"j\u0001\u0000\u0000\u0000\u018f\u0190\u0005/\u0000\u0000\u0190\u0191\u0005"+
|
||||
"*\u0000\u0000\u0191\u0195\u0001\u0000\u0000\u0000\u0192\u0194\t\u0000"+
|
||||
"\u0000\u0000\u0193\u0192\u0001\u0000\u0000\u0000\u0194\u0197\u0001\u0000"+
|
||||
"\u0000\u0000\u0195\u0196\u0001\u0000\u0000\u0000\u0195\u0193\u0001\u0000"+
|
||||
"\u0000\u0000\u0196\u0198\u0001\u0000\u0000\u0000\u0197\u0195\u0001\u0000"+
|
||||
"\u0000\u0000\u0198\u0199\u0005*\u0000\u0000\u0199\u019a\u0005/\u0000\u0000"+
|
||||
"\u019a\u019b\u0001\u0000\u0000\u0000\u019b\u019c\u00065\u0000\u0000\u019c"+
|
||||
"l\u0001\u0000\u0000\u0000\u000f\u0000\u00b1\u00dd\u00e1\u00e9\u00ed\u0150"+
|
||||
"\u0156\u015b\u0166\u0174\u017a\u0180\u018a\u0195\u0001\u0006\u0000\u0000";
|
||||
"\u0001\b\u0001\b\u0001\b\u0003\b\u00e6\b\b\u0001\t\u0001\t\u0003\t\u00ea"+
|
||||
"\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003\n\u00f2\b\n"+
|
||||
"\u0001\u000b\u0001\u000b\u0003\u000b\u00f6\b\u000b\u0001\f\u0001\f\u0001"+
|
||||
"\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+
|
||||
"\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013"+
|
||||
"\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+
|
||||
"\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017"+
|
||||
"\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+
|
||||
"\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001c"+
|
||||
"\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f"+
|
||||
"\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001"+
|
||||
"\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001$\u0001$\u0001"+
|
||||
"$\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001"+
|
||||
"\'\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001)"+
|
||||
"\u0001)\u0001)\u0001)\u0001)\u0001)\u0001)\u0001*\u0001*\u0001*\u0001"+
|
||||
"*\u0001+\u0001+\u0001+\u0001+\u0001+\u0001+\u0001+\u0001,\u0001,\u0001"+
|
||||
",\u0001,\u0001,\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001-\u0001"+
|
||||
"-\u0001.\u0001.\u0001/\u0001/\u0005/\u016d\b/\n/\f/\u0170\t/\u0001/\u0001"+
|
||||
"/\u00010\u00030\u0175\b0\u00010\u00040\u0178\b0\u000b0\f0\u0179\u0001"+
|
||||
"1\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u00031\u0185"+
|
||||
"\b1\u00012\u00012\u00012\u00012\u00012\u00013\u00013\u00014\u00014\u0001"+
|
||||
"5\u00015\u00015\u00035\u0193\b5\u00016\u00016\u00056\u0197\b6\n6\f6\u019a"+
|
||||
"\t6\u00017\u00047\u019d\b7\u000b7\f7\u019e\u00017\u00017\u00018\u0001"+
|
||||
"8\u00018\u00018\u00058\u01a7\b8\n8\f8\u01aa\t8\u00018\u00018\u00019\u0001"+
|
||||
"9\u00019\u00019\u00059\u01b2\b9\n9\f9\u01b5\t9\u00019\u00019\u00019\u0001"+
|
||||
"9\u00019\u0001\u01b3\u0000:\u0001\u0001\u0003\u0002\u0005\u0003\u0007"+
|
||||
"\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u000b"+
|
||||
"\u0017\f\u0019\r\u001b\u000e\u001d\u000f\u001f\u0010!\u0011#\u0012%\u0013"+
|
||||
"\'\u0014)\u0015+\u0016-\u0017/\u00181\u00193\u001a5\u001b7\u001c9\u001d"+
|
||||
";\u001e=\u001f? A!C\"E#G$I%K&M\'O(Q)S*U+W,Y-[.]/_0a1c2e3g\u0000i\u0000"+
|
||||
"k\u0000m4o5q6s7\u0001\u0000\u0005\u0002\u0000\n\n\r\r\u0002\u0000AZaz"+
|
||||
"\u0001\u000009\u0002\u0000$$__\u0003\u0000\t\n\r\r \u01cd\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\u0000"+
|
||||
"5\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\u0000"+
|
||||
"C\u0001\u0000\u0000\u0000\u0000E\u0001\u0000\u0000\u0000\u0000G\u0001"+
|
||||
"\u0000\u0000\u0000\u0000I\u0001\u0000\u0000\u0000\u0000K\u0001\u0000\u0000"+
|
||||
"\u0000\u0000M\u0001\u0000\u0000\u0000\u0000O\u0001\u0000\u0000\u0000\u0000"+
|
||||
"Q\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\u0000a\u0001\u0000\u0000\u0000\u0000c\u0001"+
|
||||
"\u0000\u0000\u0000\u0000e\u0001\u0000\u0000\u0000\u0000m\u0001\u0000\u0000"+
|
||||
"\u0000\u0000o\u0001\u0000\u0000\u0000\u0000q\u0001\u0000\u0000\u0000\u0000"+
|
||||
"s\u0001\u0000\u0000\u0000\u0001u\u0001\u0000\u0000\u0000\u0003x\u0001"+
|
||||
"\u0000\u0000\u0000\u0005{\u0001\u0000\u0000\u0000\u0007\u0080\u0001\u0000"+
|
||||
"\u0000\u0000\t\u0088\u0001\u0000\u0000\u0000\u000b\u008d\u0001\u0000\u0000"+
|
||||
"\u0000\r\u00b9\u0001\u0000\u0000\u0000\u000f\u00bb\u0001\u0000\u0000\u0000"+
|
||||
"\u0011\u00e5\u0001\u0000\u0000\u0000\u0013\u00e9\u0001\u0000\u0000\u0000"+
|
||||
"\u0015\u00f1\u0001\u0000\u0000\u0000\u0017\u00f5\u0001\u0000\u0000\u0000"+
|
||||
"\u0019\u00f7\u0001\u0000\u0000\u0000\u001b\u00f9\u0001\u0000\u0000\u0000"+
|
||||
"\u001d\u00fb\u0001\u0000\u0000\u0000\u001f\u00fd\u0001\u0000\u0000\u0000"+
|
||||
"!\u00ff\u0001\u0000\u0000\u0000#\u0101\u0001\u0000\u0000\u0000%\u0103"+
|
||||
"\u0001\u0000\u0000\u0000\'\u0105\u0001\u0000\u0000\u0000)\u0107\u0001"+
|
||||
"\u0000\u0000\u0000+\u010a\u0001\u0000\u0000\u0000-\u010d\u0001\u0000\u0000"+
|
||||
"\u0000/\u0110\u0001\u0000\u0000\u00001\u0113\u0001\u0000\u0000\u00003"+
|
||||
"\u0115\u0001\u0000\u0000\u00005\u0118\u0001\u0000\u0000\u00007\u011b\u0001"+
|
||||
"\u0000\u0000\u00009\u011d\u0001\u0000\u0000\u0000;\u011f\u0001\u0000\u0000"+
|
||||
"\u0000=\u0121\u0001\u0000\u0000\u0000?\u0123\u0001\u0000\u0000\u0000A"+
|
||||
"\u0125\u0001\u0000\u0000\u0000C\u0127\u0001\u0000\u0000\u0000E\u0129\u0001"+
|
||||
"\u0000\u0000\u0000G\u012f\u0001\u0000\u0000\u0000I\u0134\u0001\u0000\u0000"+
|
||||
"\u0000K\u013a\u0001\u0000\u0000\u0000M\u013d\u0001\u0000\u0000\u0000O"+
|
||||
"\u0140\u0001\u0000\u0000\u0000Q\u0145\u0001\u0000\u0000\u0000S\u0149\u0001"+
|
||||
"\u0000\u0000\u0000U\u0150\u0001\u0000\u0000\u0000W\u0154\u0001\u0000\u0000"+
|
||||
"\u0000Y\u015b\u0001\u0000\u0000\u0000[\u0160\u0001\u0000\u0000\u0000]"+
|
||||
"\u0168\u0001\u0000\u0000\u0000_\u016a\u0001\u0000\u0000\u0000a\u0174\u0001"+
|
||||
"\u0000\u0000\u0000c\u0184\u0001\u0000\u0000\u0000e\u0186\u0001\u0000\u0000"+
|
||||
"\u0000g\u018b\u0001\u0000\u0000\u0000i\u018d\u0001\u0000\u0000\u0000k"+
|
||||
"\u0192\u0001\u0000\u0000\u0000m\u0194\u0001\u0000\u0000\u0000o\u019c\u0001"+
|
||||
"\u0000\u0000\u0000q\u01a2\u0001\u0000\u0000\u0000s\u01ad\u0001\u0000\u0000"+
|
||||
"\u0000uv\u0005+\u0000\u0000vw\u0005+\u0000\u0000w\u0002\u0001\u0000\u0000"+
|
||||
"\u0000xy\u0005-\u0000\u0000yz\u0005-\u0000\u0000z\u0004\u0001\u0000\u0000"+
|
||||
"\u0000{|\u0005v\u0000\u0000|}\u0005o\u0000\u0000}~\u0005i\u0000\u0000"+
|
||||
"~\u007f\u0005d\u0000\u0000\u007f\u0006\u0001\u0000\u0000\u0000\u0080\u0081"+
|
||||
"\u0005b\u0000\u0000\u0081\u0082\u0005o\u0000\u0000\u0082\u0083\u0005o"+
|
||||
"\u0000\u0000\u0083\u0084\u0005l\u0000\u0000\u0084\u0085\u0005e\u0000\u0000"+
|
||||
"\u0085\u0086\u0005a\u0000\u0000\u0086\u0087\u0005n\u0000\u0000\u0087\b"+
|
||||
"\u0001\u0000\u0000\u0000\u0088\u0089\u0005c\u0000\u0000\u0089\u008a\u0005"+
|
||||
"h\u0000\u0000\u008a\u008b\u0005a\u0000\u0000\u008b\u008c\u0005r\u0000"+
|
||||
"\u0000\u008c\n\u0001\u0000\u0000\u0000\u008d\u008e\u0005i\u0000\u0000"+
|
||||
"\u008e\u008f\u0005n\u0000\u0000\u008f\u0090\u0005t\u0000\u0000\u0090\f"+
|
||||
"\u0001\u0000\u0000\u0000\u0091\u0092\u0005p\u0000\u0000\u0092\u0093\u0005"+
|
||||
"u\u0000\u0000\u0093\u0094\u0005b\u0000\u0000\u0094\u0095\u0005l\u0000"+
|
||||
"\u0000\u0095\u0096\u0005i\u0000\u0000\u0096\u00ba\u0005c\u0000\u0000\u0097"+
|
||||
"\u0098\u0005p\u0000\u0000\u0098\u0099\u0005r\u0000\u0000\u0099\u009a\u0005"+
|
||||
"i\u0000\u0000\u009a\u009b\u0005v\u0000\u0000\u009b\u009c\u0005a\u0000"+
|
||||
"\u0000\u009c\u009d\u0005t\u0000\u0000\u009d\u00ba\u0005e\u0000\u0000\u009e"+
|
||||
"\u009f\u0005p\u0000\u0000\u009f\u00a0\u0005u\u0000\u0000\u00a0\u00a1\u0005"+
|
||||
"b\u0000\u0000\u00a1\u00a2\u0005l\u0000\u0000\u00a2\u00a3\u0005i\u0000"+
|
||||
"\u0000\u00a3\u00a4\u0005c\u0000\u0000\u00a4\u00a5\u0005 \u0000\u0000\u00a5"+
|
||||
"\u00a6\u0005s\u0000\u0000\u00a6\u00a7\u0005t\u0000\u0000\u00a7\u00a8\u0005"+
|
||||
"a\u0000\u0000\u00a8\u00a9\u0005t\u0000\u0000\u00a9\u00aa\u0005i\u0000"+
|
||||
"\u0000\u00aa\u00ba\u0005c\u0000\u0000\u00ab\u00ac\u0005p\u0000\u0000\u00ac"+
|
||||
"\u00ad\u0005r\u0000\u0000\u00ad\u00ae\u0005i\u0000\u0000\u00ae\u00af\u0005"+
|
||||
"v\u0000\u0000\u00af\u00b0\u0005a\u0000\u0000\u00b0\u00b1\u0005t\u0000"+
|
||||
"\u0000\u00b1\u00b2\u0005e\u0000\u0000\u00b2\u00b3\u0005 \u0000\u0000\u00b3"+
|
||||
"\u00b4\u0005s\u0000\u0000\u00b4\u00b5\u0005t\u0000\u0000\u00b5\u00b6\u0005"+
|
||||
"a\u0000\u0000\u00b6\u00b7\u0005t\u0000\u0000\u00b7\u00b8\u0005i\u0000"+
|
||||
"\u0000\u00b8\u00ba\u0005c\u0000\u0000\u00b9\u0091\u0001\u0000\u0000\u0000"+
|
||||
"\u00b9\u0097\u0001\u0000\u0000\u0000\u00b9\u009e\u0001\u0000\u0000\u0000"+
|
||||
"\u00b9\u00ab\u0001\u0000\u0000\u0000\u00ba\u000e\u0001\u0000\u0000\u0000"+
|
||||
"\u00bb\u00bc\u0005p\u0000\u0000\u00bc\u00bd\u0005u\u0000\u0000\u00bd\u00be"+
|
||||
"\u0005b\u0000\u0000\u00be\u00bf\u0005l\u0000\u0000\u00bf\u00c0\u0005i"+
|
||||
"\u0000\u0000\u00c0\u00c1\u0005c\u0000\u0000\u00c1\u00c2\u0005 \u0000\u0000"+
|
||||
"\u00c2\u00c3\u0005s\u0000\u0000\u00c3\u00c4\u0005t\u0000\u0000\u00c4\u00c5"+
|
||||
"\u0005a\u0000\u0000\u00c5\u00c6\u0005t\u0000\u0000\u00c6\u00c7\u0005i"+
|
||||
"\u0000\u0000\u00c7\u00c8\u0005c\u0000\u0000\u00c8\u00c9\u0005 \u0000\u0000"+
|
||||
"\u00c9\u00ca\u0005v\u0000\u0000\u00ca\u00cb\u0005o\u0000\u0000\u00cb\u00cc"+
|
||||
"\u0005i\u0000\u0000\u00cc\u00cd\u0005d\u0000\u0000\u00cd\u00ce\u0005 "+
|
||||
"\u0000\u0000\u00ce\u00cf\u0005m\u0000\u0000\u00cf\u00d0\u0005a\u0000\u0000"+
|
||||
"\u00d0\u00d1\u0005i\u0000\u0000\u00d1\u00d2\u0005n\u0000\u0000\u00d2\u00d3"+
|
||||
"\u0005(\u0000\u0000\u00d3\u00d4\u0005S\u0000\u0000\u00d4\u00d5\u0005t"+
|
||||
"\u0000\u0000\u00d5\u00d6\u0005r\u0000\u0000\u00d6\u00d7\u0005i\u0000\u0000"+
|
||||
"\u00d7\u00d8\u0005n\u0000\u0000\u00d8\u00d9\u0005g\u0000\u0000\u00d9\u00da"+
|
||||
"\u0005[\u0000\u0000\u00da\u00db\u0005]\u0000\u0000\u00db\u00dc\u0005 "+
|
||||
"\u0000\u0000\u00dc\u00dd\u0005a\u0000\u0000\u00dd\u00de\u0005r\u0000\u0000"+
|
||||
"\u00de\u00df\u0005g\u0000\u0000\u00df\u00e0\u0005s\u0000\u0000\u00e0\u00e1"+
|
||||
"\u0005)\u0000\u0000\u00e1\u0010\u0001\u0000\u0000\u0000\u00e2\u00e6\u0003"+
|
||||
"\u001f\u000f\u0000\u00e3\u00e6\u0003#\u0011\u0000\u00e4\u00e6\u0003!\u0010"+
|
||||
"\u0000\u00e5\u00e2\u0001\u0000\u0000\u0000\u00e5\u00e3\u0001\u0000\u0000"+
|
||||
"\u0000\u00e5\u00e4\u0001\u0000\u0000\u0000\u00e6\u0012\u0001\u0000\u0000"+
|
||||
"\u0000\u00e7\u00ea\u0003\u001b\r\u0000\u00e8\u00ea\u0003\u001d\u000e\u0000"+
|
||||
"\u00e9\u00e7\u0001\u0000\u0000\u0000\u00e9\u00e8\u0001\u0000\u0000\u0000"+
|
||||
"\u00ea\u0014\u0001\u0000\u0000\u0000\u00eb\u00f2\u0003%\u0012\u0000\u00ec"+
|
||||
"\u00f2\u0003\'\u0013\u0000\u00ed\u00f2\u0003)\u0014\u0000\u00ee\u00f2"+
|
||||
"\u0003+\u0015\u0000\u00ef\u00f2\u0003-\u0016\u0000\u00f0\u00f2\u0003/"+
|
||||
"\u0017\u0000\u00f1\u00eb\u0001\u0000\u0000\u0000\u00f1\u00ec\u0001\u0000"+
|
||||
"\u0000\u0000\u00f1\u00ed\u0001\u0000\u0000\u0000\u00f1\u00ee\u0001\u0000"+
|
||||
"\u0000\u0000\u00f1\u00ef\u0001\u0000\u0000\u0000\u00f1\u00f0\u0001\u0000"+
|
||||
"\u0000\u0000\u00f2\u0016\u0001\u0000\u0000\u0000\u00f3\u00f6\u00033\u0019"+
|
||||
"\u0000\u00f4\u00f6\u00035\u001a\u0000\u00f5\u00f3\u0001\u0000\u0000\u0000"+
|
||||
"\u00f5\u00f4\u0001\u0000\u0000\u0000\u00f6\u0018\u0001\u0000\u0000\u0000"+
|
||||
"\u00f7\u00f8\u0005=\u0000\u0000\u00f8\u001a\u0001\u0000\u0000\u0000\u00f9"+
|
||||
"\u00fa\u0005+\u0000\u0000\u00fa\u001c\u0001\u0000\u0000\u0000\u00fb\u00fc"+
|
||||
"\u0005-\u0000\u0000\u00fc\u001e\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005"+
|
||||
"*\u0000\u0000\u00fe \u0001\u0000\u0000\u0000\u00ff\u0100\u0005%\u0000"+
|
||||
"\u0000\u0100\"\u0001\u0000\u0000\u0000\u0101\u0102\u0005/\u0000\u0000"+
|
||||
"\u0102$\u0001\u0000\u0000\u0000\u0103\u0104\u0005>\u0000\u0000\u0104&"+
|
||||
"\u0001\u0000\u0000\u0000\u0105\u0106\u0005<\u0000\u0000\u0106(\u0001\u0000"+
|
||||
"\u0000\u0000\u0107\u0108\u0005>\u0000\u0000\u0108\u0109\u0005=\u0000\u0000"+
|
||||
"\u0109*\u0001\u0000\u0000\u0000\u010a\u010b\u0005<\u0000\u0000\u010b\u010c"+
|
||||
"\u0005=\u0000\u0000\u010c,\u0001\u0000\u0000\u0000\u010d\u010e\u0005="+
|
||||
"\u0000\u0000\u010e\u010f\u0005=\u0000\u0000\u010f.\u0001\u0000\u0000\u0000"+
|
||||
"\u0110\u0111\u0005!\u0000\u0000\u0111\u0112\u0005=\u0000\u0000\u01120"+
|
||||
"\u0001\u0000\u0000\u0000\u0113\u0114\u0005!\u0000\u0000\u01142\u0001\u0000"+
|
||||
"\u0000\u0000\u0115\u0116\u0005&\u0000\u0000\u0116\u0117\u0005&\u0000\u0000"+
|
||||
"\u01174\u0001\u0000\u0000\u0000\u0118\u0119\u0005|\u0000\u0000\u0119\u011a"+
|
||||
"\u0005|\u0000\u0000\u011a6\u0001\u0000\u0000\u0000\u011b\u011c\u0005."+
|
||||
"\u0000\u0000\u011c8\u0001\u0000\u0000\u0000\u011d\u011e\u0005(\u0000\u0000"+
|
||||
"\u011e:\u0001\u0000\u0000\u0000\u011f\u0120\u0005)\u0000\u0000\u0120<"+
|
||||
"\u0001\u0000\u0000\u0000\u0121\u0122\u0005{\u0000\u0000\u0122>\u0001\u0000"+
|
||||
"\u0000\u0000\u0123\u0124\u0005}\u0000\u0000\u0124@\u0001\u0000\u0000\u0000"+
|
||||
"\u0125\u0126\u0005;\u0000\u0000\u0126B\u0001\u0000\u0000\u0000\u0127\u0128"+
|
||||
"\u0005,\u0000\u0000\u0128D\u0001\u0000\u0000\u0000\u0129\u012a\u0005c"+
|
||||
"\u0000\u0000\u012a\u012b\u0005l\u0000\u0000\u012b\u012c\u0005a\u0000\u0000"+
|
||||
"\u012c\u012d\u0005s\u0000\u0000\u012d\u012e\u0005s\u0000\u0000\u012eF"+
|
||||
"\u0001\u0000\u0000\u0000\u012f\u0130\u0005t\u0000\u0000\u0130\u0131\u0005"+
|
||||
"h\u0000\u0000\u0131\u0132\u0005i\u0000\u0000\u0132\u0133\u0005s\u0000"+
|
||||
"\u0000\u0133H\u0001\u0000\u0000\u0000\u0134\u0135\u0005w\u0000\u0000\u0135"+
|
||||
"\u0136\u0005h\u0000\u0000\u0136\u0137\u0005i\u0000\u0000\u0137\u0138\u0005"+
|
||||
"l\u0000\u0000\u0138\u0139\u0005e\u0000\u0000\u0139J\u0001\u0000\u0000"+
|
||||
"\u0000\u013a\u013b\u0005d\u0000\u0000\u013b\u013c\u0005o\u0000\u0000\u013c"+
|
||||
"L\u0001\u0000\u0000\u0000\u013d\u013e\u0005i\u0000\u0000\u013e\u013f\u0005"+
|
||||
"f\u0000\u0000\u013fN\u0001\u0000\u0000\u0000\u0140\u0141\u0005e\u0000"+
|
||||
"\u0000\u0141\u0142\u0005l\u0000\u0000\u0142\u0143\u0005s\u0000\u0000\u0143"+
|
||||
"\u0144\u0005e\u0000\u0000\u0144P\u0001\u0000\u0000\u0000\u0145\u0146\u0005"+
|
||||
"f\u0000\u0000\u0146\u0147\u0005o\u0000\u0000\u0147\u0148\u0005r\u0000"+
|
||||
"\u0000\u0148R\u0001\u0000\u0000\u0000\u0149\u014a\u0005r\u0000\u0000\u014a"+
|
||||
"\u014b\u0005e\u0000\u0000\u014b\u014c\u0005t\u0000\u0000\u014c\u014d\u0005"+
|
||||
"u\u0000\u0000\u014d\u014e\u0005r\u0000\u0000\u014e\u014f\u0005n\u0000"+
|
||||
"\u0000\u014fT\u0001\u0000\u0000\u0000\u0150\u0151\u0005n\u0000\u0000\u0151"+
|
||||
"\u0152\u0005e\u0000\u0000\u0152\u0153\u0005w\u0000\u0000\u0153V\u0001"+
|
||||
"\u0000\u0000\u0000\u0154\u0155\u0005s\u0000\u0000\u0155\u0156\u0005w\u0000"+
|
||||
"\u0000\u0156\u0157\u0005i\u0000\u0000\u0157\u0158\u0005t\u0000\u0000\u0158"+
|
||||
"\u0159\u0005c\u0000\u0000\u0159\u015a\u0005h\u0000\u0000\u015aX\u0001"+
|
||||
"\u0000\u0000\u0000\u015b\u015c\u0005c\u0000\u0000\u015c\u015d\u0005a\u0000"+
|
||||
"\u0000\u015d\u015e\u0005s\u0000\u0000\u015e\u015f\u0005e\u0000\u0000\u015f"+
|
||||
"Z\u0001\u0000\u0000\u0000\u0160\u0161\u0005d\u0000\u0000\u0161\u0162\u0005"+
|
||||
"e\u0000\u0000\u0162\u0163\u0005f\u0000\u0000\u0163\u0164\u0005a\u0000"+
|
||||
"\u0000\u0164\u0165\u0005u\u0000\u0000\u0165\u0166\u0005l\u0000\u0000\u0166"+
|
||||
"\u0167\u0005t\u0000\u0000\u0167\\\u0001\u0000\u0000\u0000\u0168\u0169"+
|
||||
"\u0005:\u0000\u0000\u0169^\u0001\u0000\u0000\u0000\u016a\u016e\u0005\'"+
|
||||
"\u0000\u0000\u016b\u016d\b\u0000\u0000\u0000\u016c\u016b\u0001\u0000\u0000"+
|
||||
"\u0000\u016d\u0170\u0001\u0000\u0000\u0000\u016e\u016c\u0001\u0000\u0000"+
|
||||
"\u0000\u016e\u016f\u0001\u0000\u0000\u0000\u016f\u0171\u0001\u0000\u0000"+
|
||||
"\u0000\u0170\u016e\u0001\u0000\u0000\u0000\u0171\u0172\u0005\'\u0000\u0000"+
|
||||
"\u0172`\u0001\u0000\u0000\u0000\u0173\u0175\u0003\u001d\u000e\u0000\u0174"+
|
||||
"\u0173\u0001\u0000\u0000\u0000\u0174\u0175\u0001\u0000\u0000\u0000\u0175"+
|
||||
"\u0177\u0001\u0000\u0000\u0000\u0176\u0178\u0003i4\u0000\u0177\u0176\u0001"+
|
||||
"\u0000\u0000\u0000\u0178\u0179\u0001\u0000\u0000\u0000\u0179\u0177\u0001"+
|
||||
"\u0000\u0000\u0000\u0179\u017a\u0001\u0000\u0000\u0000\u017ab\u0001\u0000"+
|
||||
"\u0000\u0000\u017b\u017c\u0005t\u0000\u0000\u017c\u017d\u0005r\u0000\u0000"+
|
||||
"\u017d\u017e\u0005u\u0000\u0000\u017e\u0185\u0005e\u0000\u0000\u017f\u0180"+
|
||||
"\u0005f\u0000\u0000\u0180\u0181\u0005a\u0000\u0000\u0181\u0182\u0005l"+
|
||||
"\u0000\u0000\u0182\u0183\u0005s\u0000\u0000\u0183\u0185\u0005e\u0000\u0000"+
|
||||
"\u0184\u017b\u0001\u0000\u0000\u0000\u0184\u017f\u0001\u0000\u0000\u0000"+
|
||||
"\u0185d\u0001\u0000\u0000\u0000\u0186\u0187\u0005n\u0000\u0000\u0187\u0188"+
|
||||
"\u0005u\u0000\u0000\u0188\u0189\u0005l\u0000\u0000\u0189\u018a\u0005l"+
|
||||
"\u0000\u0000\u018af\u0001\u0000\u0000\u0000\u018b\u018c\u0007\u0001\u0000"+
|
||||
"\u0000\u018ch\u0001\u0000\u0000\u0000\u018d\u018e\u0007\u0002\u0000\u0000"+
|
||||
"\u018ej\u0001\u0000\u0000\u0000\u018f\u0193\u0003g3\u0000\u0190\u0193"+
|
||||
"\u0003i4\u0000\u0191\u0193\u0007\u0003\u0000\u0000\u0192\u018f\u0001\u0000"+
|
||||
"\u0000\u0000\u0192\u0190\u0001\u0000\u0000\u0000\u0192\u0191\u0001\u0000"+
|
||||
"\u0000\u0000\u0193l\u0001\u0000\u0000\u0000\u0194\u0198\u0003g3\u0000"+
|
||||
"\u0195\u0197\u0003k5\u0000\u0196\u0195\u0001\u0000\u0000\u0000\u0197\u019a"+
|
||||
"\u0001\u0000\u0000\u0000\u0198\u0196\u0001\u0000\u0000\u0000\u0198\u0199"+
|
||||
"\u0001\u0000\u0000\u0000\u0199n\u0001\u0000\u0000\u0000\u019a\u0198\u0001"+
|
||||
"\u0000\u0000\u0000\u019b\u019d\u0007\u0004\u0000\u0000\u019c\u019b\u0001"+
|
||||
"\u0000\u0000\u0000\u019d\u019e\u0001\u0000\u0000\u0000\u019e\u019c\u0001"+
|
||||
"\u0000\u0000\u0000\u019e\u019f\u0001\u0000\u0000\u0000\u019f\u01a0\u0001"+
|
||||
"\u0000\u0000\u0000\u01a0\u01a1\u00067\u0000\u0000\u01a1p\u0001\u0000\u0000"+
|
||||
"\u0000\u01a2\u01a3\u0005/\u0000\u0000\u01a3\u01a4\u0005/\u0000\u0000\u01a4"+
|
||||
"\u01a8\u0001\u0000\u0000\u0000\u01a5\u01a7\b\u0000\u0000\u0000\u01a6\u01a5"+
|
||||
"\u0001\u0000\u0000\u0000\u01a7\u01aa\u0001\u0000\u0000\u0000\u01a8\u01a6"+
|
||||
"\u0001\u0000\u0000\u0000\u01a8\u01a9\u0001\u0000\u0000\u0000\u01a9\u01ab"+
|
||||
"\u0001\u0000\u0000\u0000\u01aa\u01a8\u0001\u0000\u0000\u0000\u01ab\u01ac"+
|
||||
"\u00068\u0000\u0000\u01acr\u0001\u0000\u0000\u0000\u01ad\u01ae\u0005/"+
|
||||
"\u0000\u0000\u01ae\u01af\u0005*\u0000\u0000\u01af\u01b3\u0001\u0000\u0000"+
|
||||
"\u0000\u01b0\u01b2\t\u0000\u0000\u0000\u01b1\u01b0\u0001\u0000\u0000\u0000"+
|
||||
"\u01b2\u01b5\u0001\u0000\u0000\u0000\u01b3\u01b4\u0001\u0000\u0000\u0000"+
|
||||
"\u01b3\u01b1\u0001\u0000\u0000\u0000\u01b4\u01b6\u0001\u0000\u0000\u0000"+
|
||||
"\u01b5\u01b3\u0001\u0000\u0000\u0000\u01b6\u01b7\u0005*\u0000\u0000\u01b7"+
|
||||
"\u01b8\u0005/\u0000\u0000\u01b8\u01b9\u0001\u0000\u0000\u0000\u01b9\u01ba"+
|
||||
"\u00069\u0000\u0000\u01bat\u0001\u0000\u0000\u0000\u000f\u0000\u00b9\u00e5"+
|
||||
"\u00e9\u00f1\u00f5\u016e\u0174\u0179\u0184\u0192\u0198\u019e\u01a8\u01b3"+
|
||||
"\u0001\u0006\u0000\u0000";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@@ -41,14 +41,18 @@ Else=40
|
||||
For=41
|
||||
Return=42
|
||||
New=43
|
||||
CharValue=44
|
||||
IntValue=45
|
||||
BooleanValue=46
|
||||
NullValue=47
|
||||
Identifier=48
|
||||
WS=49
|
||||
InlineComment=50
|
||||
MultilineComment=51
|
||||
Switch=44
|
||||
Case=45
|
||||
Default=46
|
||||
Colon=47
|
||||
CharValue=48
|
||||
IntValue=49
|
||||
BooleanValue=50
|
||||
NullValue=51
|
||||
Identifier=52
|
||||
WS=53
|
||||
InlineComment=54
|
||||
MultilineComment=55
|
||||
'++'=1
|
||||
'--'=2
|
||||
'void'=3
|
||||
@@ -87,4 +91,8 @@ MultilineComment=51
|
||||
'for'=41
|
||||
'return'=42
|
||||
'new'=43
|
||||
'null'=47
|
||||
'switch'=44
|
||||
'case'=45
|
||||
'default'=46
|
||||
':'=47
|
||||
'null'=51
|
||||
|
@@ -207,6 +207,36 @@ public interface SimpleJavaListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitElseStatement(SimpleJavaParser.ElseStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#switchStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#switchStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#caseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterCaseStatement(SimpleJavaParser.CaseStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#caseStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitCaseStatement(SimpleJavaParser.CaseStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#defaultStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#defaultStatement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#statementExpression}.
|
||||
* @param ctx the parse tree
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -130,6 +130,24 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitElseStatement(SimpleJavaParser.ElseStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#switchStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSwitchStatement(SimpleJavaParser.SwitchStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#caseStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitCaseStatement(SimpleJavaParser.CaseStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#defaultStatement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitDefaultStatement(SimpleJavaParser.DefaultStatementContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#statementExpression}.
|
||||
* @param ctx the parse tree
|
||||
|
@@ -7,7 +7,7 @@ classDeclaration: AccessModifier? 'class' Identifier OpenCurlyBracket memberDecl
|
||||
memberDeclaration: constructorDeclaration | fieldDeclaration | methodDeclaration;
|
||||
|
||||
constructorDeclaration: AccessModifier? Identifier OpenRoundBracket parameterList? ClosedRoundBracket blockStatement;
|
||||
fieldDeclaration: AccessModifier? type Identifier Semicolon;
|
||||
fieldDeclaration: AccessModifier? type Identifier (Assign expression)? Semicolon;
|
||||
methodDeclaration: MainMethodDeclaration blockStatement | AccessModifier? (type | Void) Identifier OpenRoundBracket parameterList? ClosedRoundBracket blockStatement;
|
||||
|
||||
parameterList: parameter (Comma parameter)*;
|
||||
@@ -22,6 +22,7 @@ statement: returnStatement Semicolon
|
||||
| doWhileStatement
|
||||
| forStatement
|
||||
| ifElseStatement
|
||||
| switchStatement
|
||||
| statementExpression Semicolon;
|
||||
|
||||
blockStatement: OpenCurlyBracket statement* ClosedCurlyBracket;
|
||||
@@ -38,6 +39,10 @@ ifStatement: If OpenRoundBracket expression ClosedRoundBracket blockStatement;
|
||||
elseIfStatement: Else If OpenRoundBracket expression ClosedRoundBracket blockStatement;
|
||||
elseStatement: Else blockStatement;
|
||||
|
||||
switchStatement: Switch OpenRoundBracket expression ClosedRoundBracket OpenCurlyBracket caseStatement+ defaultStatement? ClosedCurlyBracket;
|
||||
caseStatement: Case value Colon statement*;
|
||||
defaultStatement: Default Colon statement*;
|
||||
|
||||
statementExpression: assign | newDeclaration | methodCall | crementExpression;
|
||||
assign: assignableExpression Assign expression;
|
||||
newDeclaration: New Identifier OpenRoundBracket argumentList ClosedRoundBracket;
|
||||
@@ -153,6 +158,10 @@ Else: 'else';
|
||||
For: 'for';
|
||||
Return: 'return';
|
||||
New: 'new';
|
||||
Switch: 'switch';
|
||||
Case: 'case';
|
||||
Default: 'default';
|
||||
Colon: ':';
|
||||
|
||||
// Werte
|
||||
CharValue: '\'' ~[\r\n]* '\'';
|
||||
|
@@ -9,6 +9,7 @@ import java.util.Objects;
|
||||
import ast.*;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.expressions.binaryexpressions.*;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.FieldNode;
|
||||
@@ -21,8 +22,13 @@ import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||
import ast.statements.*;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.EnumAccessModifierNode;
|
||||
import ast.type.ValueNode;
|
||||
import ast.type.type.*;
|
||||
import com.sun.jdi.IntegerType;
|
||||
import semantic.context.Context;
|
||||
import semantic.exceptions.*;
|
||||
import typechecker.TypeCheckResult;
|
||||
@@ -134,26 +140,20 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
}
|
||||
|
||||
}
|
||||
// Check if this method is already declared
|
||||
|
||||
currentMethodReturnType = methodNode.getType();
|
||||
currentNullType = currentMethodReturnType; // Solange nicht in einem Assign oder Methoden-Aufruf dieser Typ
|
||||
currentNullType = currentMethodReturnType;
|
||||
|
||||
ITypeNode resultType = new BaseType(TypeEnum.VOID);
|
||||
|
||||
// gesetzt ist, ist dieser der Rückgabewert der Methode
|
||||
var result = methodNode.block.accept(this);
|
||||
valid = valid && result.isValid();
|
||||
currentScope.popScope();
|
||||
resultType = result.getType();
|
||||
ITypeNode resultType = result.getType();
|
||||
|
||||
if (resultType == null) {
|
||||
resultType = new BaseType(TypeEnum.VOID);
|
||||
}
|
||||
if (!resultType.equals(methodNode.getType())) {
|
||||
errors.add(new TypeMismatchException("Method-Declaration " + methodNode.getIdentifier() + " with type "
|
||||
+ methodNode.getType() + " has at least one Mismatching return Type:"));
|
||||
valid = false;
|
||||
if (methodNode.getType() == null) {
|
||||
methodNode.setType(new BaseType(TypeEnum.VOID));
|
||||
}
|
||||
|
||||
return new TypeCheckResult(valid, resultType);
|
||||
@@ -174,43 +174,65 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfNode toCheck) {
|
||||
toCheck.block.accept(this);
|
||||
|
||||
var resultExpression = toCheck.expression.accept(this);
|
||||
if (resultExpression.isValid()) {
|
||||
if (!resultExpression.getType().equals(new BaseType(TypeEnum.BOOL))) {
|
||||
errors.add(new TypeMismatchException("Expression must be Boolean"));
|
||||
return new TypeCheckResult(false, new BaseType(TypeEnum.VOID));
|
||||
}
|
||||
}
|
||||
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ReturnNode toCheck) {
|
||||
|
||||
if(toCheck.expression != null){
|
||||
if (toCheck.expression != null) {
|
||||
var result = toCheck.expression.accept(this);
|
||||
if (result.isValid()) {
|
||||
if (!result.getType().equals(currentMethodReturnType)) {
|
||||
errors.add(new TypeMismatchException("Mismatched return Type from method"));
|
||||
}
|
||||
}
|
||||
return new TypeCheckResult(true, result.getType());
|
||||
} else {
|
||||
return new TypeCheckResult(false, null);
|
||||
} else if (toCheck.voidReturn) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.VOID));
|
||||
}
|
||||
return new TypeCheckResult(true, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(WhileNode toCheck) {
|
||||
return null;
|
||||
var expResult = toCheck.expression.accept(this);
|
||||
var blockRes = toCheck.block.accept(this);
|
||||
return new TypeCheckResult(expResult.isValid() && blockRes.isValid(), blockRes.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ParameterNode toCheck) {
|
||||
|
||||
|
||||
return new TypeCheckResult(true, null);
|
||||
return new TypeCheckResult(true, toCheck.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(BlockNode blockNode) {
|
||||
ITypeNode blockReturnType = null;
|
||||
if (blockNode.statements.isEmpty()) {
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
for (IStatementNode statementNode : blockNode.statements) {
|
||||
var result = statementNode.accept(this);
|
||||
if(result.getType() != null){
|
||||
if(blockReturnType == null){
|
||||
blockReturnType = result.getType();
|
||||
} else {
|
||||
errors.add(new MultipleReturnTypes("There are multiple Return types"));
|
||||
if(!(statementNode instanceof IncrementNode) && !(statementNode instanceof DecrementNode)){
|
||||
if (result.getType() != null) {
|
||||
if (blockReturnType == null) {
|
||||
blockReturnType = result.getType();
|
||||
} else {
|
||||
if (!blockReturnType.equals(result.getType())) {
|
||||
errors.add(new MultipleReturnTypes("There are multiple Return types"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,20 +241,31 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignableNode toCheck) {
|
||||
return new TypeCheckResult(true, currentFields.get(toCheck.identifier));
|
||||
|
||||
if (toCheck.memberAccess != null) {
|
||||
var result = toCheck.memberAccess.accept(this);
|
||||
toCheck.setTypeNode(result.getType());
|
||||
return result;
|
||||
} else {
|
||||
if (currentFields.get(toCheck.identifier) != null) {
|
||||
var type = currentFields.get(toCheck.identifier);
|
||||
toCheck.setTypeNode(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else if (currentScope.getLocalVar(toCheck.identifier) != null) {
|
||||
var type = currentScope.getLocalVar(toCheck.identifier);
|
||||
return new TypeCheckResult(true, type);
|
||||
}
|
||||
}
|
||||
|
||||
return new TypeCheckResult(true, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ElseNode toCheck) {
|
||||
return null;
|
||||
return toCheck.block.accept(this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public TypeCheckResult analyze(ForNode toCheck) {
|
||||
return null;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(AssignNode toCheck) {
|
||||
AssignableNode assignable = toCheck.assignable;
|
||||
@@ -258,33 +291,61 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
currentNullType = lResult.getType();
|
||||
var rResult = rExpression.accept(this);
|
||||
|
||||
if (!Objects.equals(currentScope.getLocalVar(toCheck.assignable.identifier), rExpression.getType())) {
|
||||
if (!Objects.equals(lResult.getType(), rResult.getType())) {
|
||||
errors.add(new TypeMismatchException(
|
||||
"Mismatch types in Assign-Statement: cannot convert from \"" + lResult.getType() + "\" to \""
|
||||
+ rResult.getType() + "\""));
|
||||
valid = false;
|
||||
}
|
||||
// else {
|
||||
// toCheck.setType(assignable.getType());
|
||||
// }
|
||||
valid = valid && lResult.isValid() && rResult.isValid();
|
||||
currentNullType = null;
|
||||
return new TypeCheckResult(valid, null); // return type is null to get the return type sufficently
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DecrementNode toCheck) {
|
||||
return null;
|
||||
public TypeCheckResult analyze(DecrementNode decrementNode) {
|
||||
return decrementNode.assignableExpression.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfElseNode toCheck) {
|
||||
return new TypeCheckResult(true, null);
|
||||
var resultIf = toCheck.ifStatement.accept(this);
|
||||
var resultElse = toCheck.elseStatement.accept(this);
|
||||
|
||||
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(MethodCallNode toCheck) {
|
||||
return null;
|
||||
|
||||
if (toCheck.target.identifier != null) {
|
||||
var targetType = currentScope.getLocalVar(toCheck.target.identifier);
|
||||
if (targetType == null) {
|
||||
targetType = currentFields.get(toCheck.target.identifier);
|
||||
}
|
||||
if (targetType instanceof ReferenceType reference) {
|
||||
var type = getTypeFromMethod(toCheck, reference);
|
||||
if (type != null) {
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (toCheck.target.thisTar) {
|
||||
var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier));
|
||||
if (type != null) {
|
||||
return new TypeCheckResult(true, type);
|
||||
}
|
||||
} else {
|
||||
var result = toCheck.target.accept(this);
|
||||
if (result.getType() instanceof ReferenceType reference) {
|
||||
return new TypeCheckResult(true, getTypeFromMethod(toCheck, reference));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,6 +356,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
TypeCheckResult result = localVarDecl.expression.accept(this);
|
||||
|
||||
var resultType = localVarDecl.expression.getType();
|
||||
if (result.getType() != null) {
|
||||
resultType = result.getType();
|
||||
}
|
||||
valid = result.isValid() && valid;
|
||||
|
||||
if (!Objects.equals(resultType, localVarDecl.type)) {
|
||||
@@ -316,12 +380,17 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(NewDeclarationNode toCheck) {
|
||||
|
||||
if (context.containsClass(toCheck.identifier)) {
|
||||
return new TypeCheckResult(true, new ReferenceType(toCheck.identifier));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IncrementNode toCheck) {
|
||||
return null;
|
||||
return toCheck.assignableExpression.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,38 +401,223 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
@Override
|
||||
public TypeCheckResult analyze(CalculationNode calcNode) {
|
||||
if (calcNode.calculationExpression != null) {
|
||||
calcNode.calculationExpression.accept(this);
|
||||
var calcRes = calcNode.calculationExpression.accept(this);
|
||||
if (calcNode.dotExpression != null) {
|
||||
var dotRes = calcNode.dotExpression.accept(this);
|
||||
|
||||
switch (calcNode.operator) {
|
||||
case PLUS, MINUS:
|
||||
if (calcRes.getType() instanceof BaseType calcType && dotRes.getType() instanceof BaseType dotType &&
|
||||
calcType.getTypeEnum().equals(TypeEnum.INT) && dotType.getTypeEnum().equals(TypeEnum.INT)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.INT));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
} else {
|
||||
return new TypeCheckResult(calcRes.isValid(), calcRes.getType());
|
||||
}
|
||||
} else if (calcNode.dotExpression != null) {
|
||||
var dotRes = calcNode.dotExpression.accept(this);
|
||||
return new TypeCheckResult(dotRes.isValid(), dotRes.getType());
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotNode toCheck) {
|
||||
if (toCheck.dotSubstractionExpression != null) {
|
||||
return toCheck.dotSubstractionExpression.accept(this);
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotSubstractionNode toCheck) {
|
||||
if (toCheck.value != null) {
|
||||
return toCheck.value.accept(this);
|
||||
} else if (toCheck.memberAccess != null) {
|
||||
return toCheck.memberAccess.accept(this);
|
||||
} else if (toCheck.methodCall != null) {
|
||||
return toCheck.methodCall.accept(this);
|
||||
} else if (toCheck.identifier != null) {
|
||||
if (currentScope.contains(toCheck.identifier)) {
|
||||
return new TypeCheckResult(true, currentScope.getLocalVar(toCheck.identifier));
|
||||
} else if (currentFields.get(toCheck.identifier) != null) {
|
||||
return new TypeCheckResult(true, currentFields.get(toCheck.identifier));
|
||||
}
|
||||
} else if (toCheck.calculationExpression != null) {
|
||||
return toCheck.calculationExpression.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
public TypeCheckResult analyze(NonCalculationNode nonCalculationNode) {
|
||||
var expResult = nonCalculationNode.expression.accept(this);
|
||||
var unaryResult = nonCalculationNode.unaryExpression.accept(this);
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotSubstractionNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
switch (nonCalculationNode.operator) {
|
||||
case LESS, LESS_EQUAL, GREATER, GREATER_EQUAL:
|
||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
|
||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.INT)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be Integer"));
|
||||
}
|
||||
break;
|
||||
case OR, AND:
|
||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
|
||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.INT)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be Boolean"));
|
||||
}
|
||||
break;
|
||||
case EQUAL, NOT_EQUAL:
|
||||
if (expResult.getType() instanceof BaseType expResultType && unaryResult.getType() instanceof BaseType unaryResultType
|
||||
&& Objects.equals(expResultType, unaryResultType)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be the same"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(NonCalculationNode toCheck) {
|
||||
return null;
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(UnaryNode unary) {
|
||||
var valid = true;
|
||||
|
||||
if (currentScope.contains(unary.identifier)) {
|
||||
return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier));
|
||||
} else if(currentFields.get(unary.identifier) != null) {
|
||||
return new TypeCheckResult(valid, currentFields.get(unary.identifier));
|
||||
} else {
|
||||
errors.add(new NotDeclaredException("Var is not Declared"));
|
||||
if (unary.identifier != null) {
|
||||
if (currentScope.contains(unary.identifier)) {
|
||||
return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier));
|
||||
} else if (currentFields.get(unary.identifier) != null) {
|
||||
return new TypeCheckResult(valid, currentFields.get(unary.identifier));
|
||||
} else if (unary.statement != null) {
|
||||
var result = unary.statement.accept(this);
|
||||
unary.setType(result.getType());
|
||||
return result;
|
||||
} else {
|
||||
errors.add(new NotDeclaredException("Var is not Declared"));
|
||||
}
|
||||
} else if (unary.statement != null) {
|
||||
var result = unary.statement.accept(this);
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.value != null) {
|
||||
var result = unary.value.accept(this);
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.memberAccess != null) {
|
||||
var result = unary.memberAccess.accept(this);
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.expression != null) {
|
||||
var result = unary.expression.accept(this);
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
}
|
||||
return new TypeCheckResult(valid, null);
|
||||
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(MemberAccessNode memberAccessNode) {
|
||||
|
||||
ITypeNode currentType = null;
|
||||
|
||||
for (String s : memberAccessNode.identifiers) {
|
||||
if (currentType == null) {
|
||||
if (currentScope.getLocalVar(s) != null) {
|
||||
currentType = currentScope.getLocalVar(s);
|
||||
|
||||
} else if (currentFields.get(s) != null) {
|
||||
currentType = currentFields.get(s);
|
||||
} else {
|
||||
errors.add(new NotDeclaredException(s + "Not Declared"));
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (currentType instanceof ReferenceType reference) {
|
||||
var currentTypeClass = context.getClass(reference.getIdentifier());
|
||||
|
||||
var currentField = currentTypeClass.getField(s);
|
||||
if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) {
|
||||
currentType = currentField.getType();
|
||||
} else {
|
||||
errors.add(new NotVisibleException("This field is not visible"));
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new TypeCheckResult(true, currentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(TargetNode targetNode) {
|
||||
|
||||
if (targetNode.memberAccess != null) {
|
||||
return targetNode.memberAccess.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(ValueNode valueNode) {
|
||||
|
||||
switch (valueNode.valueType) {
|
||||
case INT_VALUE -> {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.INT));
|
||||
}
|
||||
case CHAR_VALUE -> {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.CHAR));
|
||||
}
|
||||
case BOOLEAN_VALUE -> {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
}
|
||||
default -> {
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ITypeNode getTypeFromMethod(MethodCallNode toCheck, ReferenceType reference) {
|
||||
var classContext = context.getClass(reference.getIdentifier());
|
||||
|
||||
if (classContext == null) {
|
||||
errors.add(new NotDeclaredException(toCheck.target.identifier + "is not Defined"));
|
||||
} else {
|
||||
var methods = classContext.getMethods();
|
||||
for (var method : methods) {
|
||||
if (toCheck.identifier.equals(method.getIdentifier())) {
|
||||
if (method.getParameters().size() == toCheck.parameters.size() && !(method instanceof ConstructorNode)) {
|
||||
boolean same = true;
|
||||
for (int i = 0; i < method.getParameters().size(); i++) {
|
||||
var result1 = method.getParameters().get(i).accept(this);
|
||||
var result2 = toCheck.parameters.get(i).accept(this);
|
||||
if (!Objects.equals(result1.getType(), result2.getType())) {
|
||||
same = false;
|
||||
}
|
||||
}
|
||||
if (same) {
|
||||
if (method.accesModifier.accessType == EnumAccessModifierNode.PUBLIC) {
|
||||
if (method.getType() == null) {
|
||||
return new BaseType(TypeEnum.VOID);
|
||||
}
|
||||
return method.getType();
|
||||
} else {
|
||||
errors.add(new NotVisibleException("This Method is not Visible"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
errors.add(new WrongOverloading("No Method found with this parameters"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -2,6 +2,7 @@ package semantic;
|
||||
|
||||
import ast.*;
|
||||
import ast.expressions.binaryexpressions.*;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.*;
|
||||
import ast.parameters.ParameterNode;
|
||||
@@ -11,7 +12,9 @@ import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||
import ast.statements.*;
|
||||
import ast.type.ValueNode;
|
||||
import typechecker.TypeCheckResult;
|
||||
|
||||
public interface SemanticVisitor {
|
||||
@@ -38,8 +41,6 @@ public interface SemanticVisitor {
|
||||
|
||||
TypeCheckResult analyze(ElseNode toCheck);
|
||||
|
||||
//TypeCheckResult analyze(ForNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(AssignNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(DecrementNode toCheck);
|
||||
@@ -66,4 +67,10 @@ public interface SemanticVisitor {
|
||||
|
||||
TypeCheckResult analyze(UnaryNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(MemberAccessNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(TargetNode toCheck);
|
||||
|
||||
TypeCheckResult analyze(ValueNode toCheck);
|
||||
|
||||
}
|
@@ -2,11 +2,15 @@ package semantic.context;
|
||||
|
||||
import ast.ClassNode;
|
||||
import ast.members.FieldNode;
|
||||
import ast.members.MethodNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ClassContext {
|
||||
|
||||
private HashMap<String, FieldContext> fields;
|
||||
private ArrayList<MethodNode> methods = new ArrayList<>();
|
||||
|
||||
public ClassContext(ClassNode classNode) {
|
||||
|
||||
@@ -15,6 +19,8 @@ public class ClassContext {
|
||||
classNode.members.forEach(member -> {
|
||||
if(member instanceof FieldNode fieldNode) {
|
||||
fields.put(fieldNode.identifier, new FieldContext(fieldNode));
|
||||
}else if(member instanceof MethodNode methodNode) {
|
||||
methods.add(methodNode);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,4 +30,8 @@ public class ClassContext {
|
||||
return fields.get(name);
|
||||
}
|
||||
|
||||
public ArrayList<MethodNode> getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,4 +21,8 @@ public class Context {
|
||||
return classes.get(identifier);
|
||||
}
|
||||
|
||||
public boolean containsClass(String identifier) {
|
||||
return classes.containsKey(identifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,4 +18,8 @@ public class FieldContext {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AccessModifierNode getAccessModifier() {
|
||||
return accessModifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package semantic.exceptions;
|
||||
|
||||
public class NotVisibleException extends RuntimeException {
|
||||
|
||||
public NotVisibleException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
9
src/main/java/semantic/exceptions/WrongOverloading.java
Normal file
9
src/main/java/semantic/exceptions/WrongOverloading.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package semantic.exceptions;
|
||||
|
||||
public class WrongOverloading extends RuntimeException {
|
||||
|
||||
public WrongOverloading(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@@ -2,13 +2,15 @@ public class Compiler {
|
||||
public int add(int i, int j) {
|
||||
return i+j;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
int a = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public class Node {
|
||||
public void main() {
|
||||
Compiler compiler = new Compiler();
|
||||
int i = compiler.add(5, 8);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
src/main/resources/output/output.jar
Normal file
BIN
src/main/resources/output/output.jar
Normal file
Binary file not shown.
@@ -10,7 +10,7 @@ compile-javac:
|
||||
compile-raupenpiler:
|
||||
cd ../.. ; mvn -DskipTests install
|
||||
cd ../.. ; mvn exec:java -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' "
|
||||
cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler
|
||||
# cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler
|
||||
|
||||
test: compile-javac compile-raupenpiler test-javac test-raupenpiler
|
||||
|
||||
@@ -31,6 +31,7 @@ test-raupenpiler:
|
||||
clean:
|
||||
# clean output folders
|
||||
rm -f ../main/resources/output/*.class
|
||||
rm -f ../main/resources/output/*.jar
|
||||
rm -f ./resources/output/javac/*.class
|
||||
rm -f ./resources/output/raupenpiler/*.class
|
||||
# clean logs
|
||||
|
177
src/test/java/main/E2EReflectionsTest.java
Normal file
177
src/test/java/main/E2EReflectionsTest.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package main;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.ProgramNode;
|
||||
import bytecode.ByteCodeGenerator;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
import semantic.SemanticAnalyzer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class E2EReflectionsTest {
|
||||
|
||||
|
||||
private CharStream mockInputCharStream;
|
||||
private String outputDirectoryPath;
|
||||
private SimpleJavaLexer mockLexer;
|
||||
private CommonTokenStream mockTokenStream;
|
||||
private SimpleJavaParser mockParser;
|
||||
private ParseTree mockParseTree;
|
||||
private ASTBuilder mockASTBuilder;
|
||||
private ASTNode mockASTNode;
|
||||
private SemanticAnalyzer mockSemanticAnalyzer;
|
||||
private ASTNode mockTypedAST;
|
||||
private ByteCodeGenerator mockByteCodeGenerator;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
mockInputCharStream = mock(CharStream.class);
|
||||
outputDirectoryPath = "path/to/output";
|
||||
mockLexer = mock(SimpleJavaLexer.class);
|
||||
mockTokenStream = mock(CommonTokenStream.class);
|
||||
mockParser = mock(SimpleJavaParser.class);
|
||||
mockParseTree = mock(ParseTree.class);
|
||||
mockASTBuilder = mock(ASTBuilder.class);
|
||||
mockASTNode = mock(ASTNode.class);
|
||||
mockSemanticAnalyzer = mock(SemanticAnalyzer.class);
|
||||
mockTypedAST = mock(ASTNode.class);
|
||||
mockByteCodeGenerator = mock(ByteCodeGenerator.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompileFile() throws Exception {
|
||||
// Mock the dependencies
|
||||
SimpleJavaLexer mockLexer = mock(SimpleJavaLexer.class);
|
||||
CommonTokenStream mockTokenStream = mock(CommonTokenStream.class);
|
||||
SimpleJavaParser mockParser = mock(SimpleJavaParser.class);
|
||||
ParseTree mockParseTree = mock(ParseTree.class);
|
||||
ASTBuilder mockASTBuilder = mock(ASTBuilder.class);
|
||||
ASTNode mockASTNode = mock(ASTNode.class);
|
||||
SemanticAnalyzer mockSemanticAnalyzer = mock(SemanticAnalyzer.class);
|
||||
ASTNode mockTypedAST = mock(ASTNode.class);
|
||||
ByteCodeGenerator mockByteCodeGenerator = mock(ByteCodeGenerator.class);
|
||||
|
||||
// Mock the behavior
|
||||
when(mockLexer.nextToken()).thenReturn(null);
|
||||
when(mockTokenStream.getTokens()).thenReturn(new ArrayList<>());
|
||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
||||
|
||||
// Use reflection to invoke the compileFile method
|
||||
Method compileFileMethod = main.Main.class.getDeclaredMethod("compileFile", CharStream.class, String.class);
|
||||
compileFileMethod.setAccessible(true);
|
||||
|
||||
compileFileMethod.invoke(null, mockInputCharStream, outputDirectoryPath);
|
||||
|
||||
// Verify each step
|
||||
verify(mockLexer, times(1)).nextToken();
|
||||
verify(mockTokenStream, times(1)).getTokens();
|
||||
verify(mockParser, times(1)).program();
|
||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompileFile2() throws Exception {
|
||||
// Mock the behavior
|
||||
when(mockLexer.nextToken()).thenReturn(null);
|
||||
when(mockTokenStream.getTokens()).thenReturn(new ArrayList<>());
|
||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
||||
|
||||
// Use reflection to invoke the compileFile method
|
||||
Method compileFileMethod = main.Main.class.getDeclaredMethod("compileFile", CharStream.class, String.class);
|
||||
compileFileMethod.setAccessible(true);
|
||||
|
||||
compileFileMethod.invoke(null, mockInputCharStream, outputDirectoryPath);
|
||||
|
||||
// Verify each step
|
||||
verify(mockLexer, times(1)).nextToken();
|
||||
verify(mockTokenStream, times(1)).getTokens();
|
||||
verify(mockParser, times(1)).program();
|
||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testLexer() {
|
||||
// Mock the behavior
|
||||
when(mockLexer.nextToken()).thenReturn(null);
|
||||
|
||||
// Test the lexer
|
||||
SimpleJavaLexer lexer = new SimpleJavaLexer(mockInputCharStream);
|
||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||
tokenStream.fill();
|
||||
|
||||
assertNotNull(tokenStream.getTokens());
|
||||
verify(mockLexer, atLeastOnce()).nextToken();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser() {
|
||||
// Mock the behavior
|
||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
||||
|
||||
// Test the parser
|
||||
SimpleJavaParser parser = new SimpleJavaParser(mockTokenStream);
|
||||
ParseTree parseTree = parser.program();
|
||||
|
||||
assertNotNull(parseTree);
|
||||
verify(mockParser, times(1)).program();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testASTBuilder() {
|
||||
// Mock the behavior
|
||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
||||
|
||||
// Test the AST builder
|
||||
ASTBuilder astBuilder = new ASTBuilder();
|
||||
ASTNode abstractSyntaxTree = astBuilder.visit(mockParseTree);
|
||||
|
||||
assertNotNull(abstractSyntaxTree);
|
||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSemanticAnalyzer() {
|
||||
// Mock the behavior
|
||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
||||
|
||||
// Test the semantic analyzer
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(mockASTNode);
|
||||
|
||||
assertNotNull(typedAst);
|
||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testByteCodeGenerator() {
|
||||
// Test the bytecode generator
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, true, true);
|
||||
byteCodeGenerator.visit((ProgramNode) mockTypedAST);
|
||||
|
||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
||||
}
|
||||
}
|
||||
|
45
src/test/java/semantic/BeginnToTAST.java
Normal file
45
src/test/java/semantic/BeginnToTAST.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package semantic;
|
||||
|
||||
import ast.ProgramNode;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class BeginnToTAST {
|
||||
|
||||
@Test
|
||||
public void FieldTests() {
|
||||
SemanticAnalyzer.clearAnalyzer();
|
||||
|
||||
CharStream codeCharStream = null;
|
||||
try {
|
||||
codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/johnsTests/FieldTests.java"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||
|
||||
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
|
||||
ParseTree parseTree = parser.program(); // parse the input
|
||||
|
||||
/* ------------------------- AST builder -> AST ------------------------- */
|
||||
ASTBuilder astBuilder = new ASTBuilder();
|
||||
ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree);
|
||||
|
||||
var result = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
}
|
||||
|
||||
}
|
@@ -26,11 +26,37 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class EndToTypedAstTest {
|
||||
private static final Map<String, Class<?>> exceptionMap = new HashMap<>();
|
||||
|
||||
@Test
|
||||
public void testOnlyOneFile() {
|
||||
SemanticAnalyzer.clearAnalyzer();
|
||||
|
||||
CharStream codeCharStream = null;
|
||||
try {
|
||||
codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/typedAstFeaturesTests/CorrectTest.java"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||
|
||||
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
|
||||
ParseTree parseTree = parser.program(); // parse the input
|
||||
|
||||
/* ------------------------- AST builder -> AST ------------------------- */
|
||||
ASTBuilder astBuilder = new ASTBuilder();
|
||||
ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree);
|
||||
|
||||
var result = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionsTest() {
|
||||
String directoryPath = "src/test/resources/input/typedAstExceptionsTests";
|
||||
@@ -88,7 +114,7 @@ public class EndToTypedAstTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void featureTest(){
|
||||
public void featureTest() {
|
||||
String directoryPath = "src/test/resources/input/typedAstFeaturesTests";
|
||||
File folder = new File(directoryPath);
|
||||
if (folder.isDirectory()) {
|
||||
@@ -115,6 +141,9 @@ public class EndToTypedAstTest {
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
|
||||
System.out.println("Testing the file: " + file.getName());
|
||||
for(Exception runtimeException : SemanticAnalyzer.errors){
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
@@ -127,9 +156,8 @@ public class EndToTypedAstTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------ Helpers ------------------
|
||||
|
||||
/**
|
||||
* This method is used to extract the expected exception from a given file.
|
||||
* It reads the file line by line and uses a regular expression to match the expected exception annotation.
|
||||
@@ -158,25 +186,25 @@ public class EndToTypedAstTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to retrieve the Class object associated with a given exception name.
|
||||
* It first prints the original exception name, then appends the package name to the exception name and prints it.
|
||||
* It then retrieves the Class object from the exceptionMap using the fully qualified exception name.
|
||||
* If the Class object is not found in the exceptionMap, it throws a RuntimeException.
|
||||
*
|
||||
* @param exceptionName The name of the exception for which the Class object is to be retrieved.
|
||||
* @return The Class object associated with the given exception name.
|
||||
* @throws RuntimeException If the Class object for the given exception name is not found in the exceptionMap.
|
||||
*/
|
||||
private Class<?> getExceptionClass(String exceptionName) {
|
||||
System.out.println(exceptionName);
|
||||
exceptionName = "semantic.exceptions." + exceptionName;
|
||||
System.out.println(exceptionName);
|
||||
Class<?> exceptionClass = exceptionMap.get(exceptionName);
|
||||
if (exceptionClass == null) {
|
||||
throw new RuntimeException("Exception class not found: " + exceptionName);
|
||||
* This method is used to retrieve the Class object associated with a given exception name.
|
||||
* It first prints the original exception name, then appends the package name to the exception name and prints it.
|
||||
* It then retrieves the Class object from the exceptionMap using the fully qualified exception name.
|
||||
* If the Class object is not found in the exceptionMap, it throws a RuntimeException.
|
||||
*
|
||||
* @param exceptionName The name of the exception for which the Class object is to be retrieved.
|
||||
* @return The Class object associated with the given exception name.
|
||||
* @throws RuntimeException If the Class object for the given exception name is not found in the exceptionMap.
|
||||
*/
|
||||
private Class<?> getExceptionClass(String exceptionName) {
|
||||
System.out.println(exceptionName);
|
||||
exceptionName = "semantic.exceptions." + exceptionName;
|
||||
System.out.println(exceptionName);
|
||||
Class<?> exceptionClass = exceptionMap.get(exceptionName);
|
||||
if (exceptionClass == null) {
|
||||
throw new RuntimeException("Exception class not found: " + exceptionName);
|
||||
}
|
||||
return exceptionClass;
|
||||
}
|
||||
return exceptionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to load custom exceptions from a specified package.
|
||||
|
@@ -1,102 +0,0 @@
|
||||
package semantic;
|
||||
|
||||
import ast.*;
|
||||
import ast.members.FieldNode;
|
||||
import ast.members.MethodNode;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.type.*;
|
||||
|
||||
public class Mocker {
|
||||
|
||||
public static ASTNode mockTwoSameFields(){
|
||||
ProgramNode p = new ProgramNode();
|
||||
|
||||
ClassNode c = new ClassNode();
|
||||
c.identifier = "testClass";
|
||||
|
||||
FieldNode f1 = new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a");
|
||||
|
||||
c.members.add(f1);
|
||||
|
||||
FieldNode f2 = new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a");
|
||||
|
||||
c.members.add(f2);
|
||||
|
||||
p.classes.add(c);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static ASTNode mockSimpleMethod(){
|
||||
ProgramNode p = new ProgramNode();
|
||||
|
||||
ClassNode c = new ClassNode();
|
||||
|
||||
MethodNode methodNode = new MethodNode();
|
||||
|
||||
//Parameter
|
||||
ParameterNode parameterNode = new ParameterNode(new BaseType(TypeEnum.INT), "a");
|
||||
|
||||
methodNode.addParameter(parameterNode);
|
||||
|
||||
//Statements
|
||||
|
||||
//Block
|
||||
methodNode.block = new ast.statements.BlockNode();
|
||||
|
||||
c.members.add(methodNode);
|
||||
|
||||
p.classes.add(c);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public static ASTNode mockTwoSameMethods(){
|
||||
ProgramNode p = new ProgramNode();
|
||||
|
||||
ClassNode c = new ClassNode();
|
||||
|
||||
MethodNode methodNode = new MethodNode();
|
||||
methodNode.block = new ast.statements.BlockNode();
|
||||
methodNode.setType(new BaseType(TypeEnum.INT));
|
||||
|
||||
methodNode.setIdentifier("testMethod");
|
||||
|
||||
c.members.add(methodNode);
|
||||
|
||||
MethodNode methodNode1 = new MethodNode();
|
||||
methodNode1.block = new ast.statements.BlockNode();
|
||||
methodNode1.setType(new BaseType(TypeEnum.INT));
|
||||
|
||||
methodNode1.setIdentifier("testMethod");
|
||||
|
||||
c.members.add(methodNode1);
|
||||
|
||||
p.classes.add(c);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public static ASTNode mockTwoDifferentMethods(){
|
||||
ProgramNode p = new ProgramNode();
|
||||
|
||||
ClassNode c = new ClassNode();
|
||||
|
||||
MethodNode methodNode = new MethodNode();
|
||||
methodNode.block = new ast.statements.BlockNode();
|
||||
methodNode.setIdentifier("testMethod");
|
||||
|
||||
c.members.add(methodNode);
|
||||
|
||||
MethodNode methodNode1 = new MethodNode();
|
||||
methodNode1.block = new ast.statements.BlockNode();
|
||||
methodNode1.setIdentifier("testMethod1");
|
||||
|
||||
c.members.add(methodNode1);
|
||||
|
||||
p.classes.add(c);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
@@ -3,6 +3,18 @@ package semantic;
|
||||
public class SemanticTest {
|
||||
|
||||
|
||||
public void test(){
|
||||
|
||||
}
|
||||
|
||||
public void test(int a, boolean b){
|
||||
|
||||
}
|
||||
|
||||
public void test(boolean b, int a){
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void alreadyDeclaredLocalFieldVar() {
|
||||
// ProgramNode programNode = new ProgramNode();
|
||||
|
@@ -9,42 +9,25 @@ public class AllFeaturesClassExample {
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
}
|
||||
private class InnerClass {
|
||||
void innerMethod() {
|
||||
System.out.println("Inner class method");
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zur Demonstration von Kontrollstrukturen
|
||||
void controlStructures() {
|
||||
// if-else Anweisung
|
||||
if (a > 10) {
|
||||
System.out.println("a ist größer als 10");
|
||||
// System.out.println("a ist größer als 10");
|
||||
} else {
|
||||
System.out.println("a ist nicht größer als 10");
|
||||
// System.out.println("a ist nicht größer als 10");
|
||||
}
|
||||
|
||||
// while Schleife
|
||||
while (a > 0) {
|
||||
System.out.println("a ist " + a);
|
||||
// System.out.println("a ist " + a);
|
||||
a--;
|
||||
}
|
||||
|
||||
// for Schleife
|
||||
for (int i = 0; i < 5; i++) {
|
||||
System.out.println("for Schleife Iteration: " + i);
|
||||
}
|
||||
|
||||
// switch Anweisung
|
||||
switch (c) {
|
||||
case 'a':
|
||||
System.out.println("c ist ein 'a'");
|
||||
break;
|
||||
case 'b':
|
||||
System.out.println("c ist ein 'b'");
|
||||
break;
|
||||
default:
|
||||
System.out.println("c ist nicht 'a' oder 'b'");
|
||||
// System.out.println("for Schleife Iteration: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,15 +35,28 @@ public class AllFeaturesClassExample {
|
||||
void logicalOperations() {
|
||||
// Logische UND-Operation
|
||||
if (b && a > 5) {
|
||||
System.out.println("a ist größer als 5 und b ist wahr");
|
||||
// System.out.println("a ist größer als 5 und b ist wahr");
|
||||
}
|
||||
|
||||
// Logische ODER-Operation
|
||||
if (b || a < 5) {
|
||||
System.out.println("b ist wahr oder a ist kleiner als 5");
|
||||
// System.out.println("b ist wahr oder a ist kleiner als 5");
|
||||
}
|
||||
}
|
||||
|
||||
void mathOperations() {
|
||||
// Addition
|
||||
int sum = a + 5;
|
||||
// Subtraktion
|
||||
int difference = a - 5;
|
||||
// Multiplikation
|
||||
int product = a * 5;
|
||||
// Division
|
||||
int quotient = a / 5;
|
||||
// Modulo
|
||||
int remainder = a % 5;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||
obj.controlStructures();
|
||||
|
BIN
src/test/resources/input/featureTests/BooleanOperations.class
Normal file
BIN
src/test/resources/input/featureTests/BooleanOperations.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/featureTests/CharManipulation.class
Normal file
BIN
src/test/resources/input/featureTests/CharManipulation.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/featureTests/EmptyClassExample.class
Normal file
BIN
src/test/resources/input/featureTests/EmptyClassExample.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/featureTests/LoopExamples.class
Normal file
BIN
src/test/resources/input/featureTests/LoopExamples.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/featureTests/MethodOverloading.class
Normal file
BIN
src/test/resources/input/featureTests/MethodOverloading.class
Normal file
Binary file not shown.
10
src/test/resources/input/javaCases/SwitchCase.java
Normal file
10
src/test/resources/input/javaCases/SwitchCase.java
Normal file
@@ -0,0 +1,10 @@
|
||||
class TestClass{
|
||||
|
||||
TestClasd (){
|
||||
switch (a){
|
||||
case 1:
|
||||
b = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
5
src/test/resources/input/johnsTests/FieldTests.java
Normal file
5
src/test/resources/input/johnsTests/FieldTests.java
Normal file
@@ -0,0 +1,5 @@
|
||||
public class Test{
|
||||
|
||||
int a = 10;
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class AllFeaturesClassExample {
|
||||
|
||||
public void controlStructures(int a, boolean bool) {
|
||||
while (a > bool) {
|
||||
a--;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public void test(boolean b){
|
||||
if(b == 2){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
// @expected: NotVisibleException
|
||||
public class Test{
|
||||
|
||||
public Car c;
|
||||
|
||||
public int test(){
|
||||
return c.speed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
public int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public void test(int x){
|
||||
|
||||
if(x){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// @expected: NotVisibleException
|
||||
public class Test {
|
||||
|
||||
public int firstInt;
|
||||
public Car ca;
|
||||
|
||||
public int speed(){
|
||||
return ca.getSpeed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
private int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
// @expected: WrongOverloading
|
||||
public class Test{
|
||||
|
||||
public void test(int x){
|
||||
|
||||
if(this.get()){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public boolean b;
|
||||
|
||||
public boolean get(int c){
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
// @expected: MultipleReturnTypes
|
||||
// @expected: TypeMismatchException
|
||||
public class Example {
|
||||
|
||||
public static int testMethod(int x, char c){
|
||||
|
@@ -0,0 +1,22 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public int i;
|
||||
public boolean b;
|
||||
|
||||
public int test(){
|
||||
|
||||
return this.test(i);
|
||||
|
||||
}
|
||||
|
||||
public void test(int a){
|
||||
|
||||
}
|
||||
|
||||
public int test(boolean bool){
|
||||
int ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Example {
|
||||
|
||||
public static void testMethod(int x){
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
public class Test {
|
||||
|
||||
public int firstInt;
|
||||
public Car ca;
|
||||
|
||||
public int speed(){
|
||||
return ca.getSpeed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
public int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
public class Test{
|
||||
|
||||
public Car c;
|
||||
|
||||
public int test(){
|
||||
return c.getSpeed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
public int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
public class Test{
|
||||
|
||||
public void test(int x){
|
||||
|
||||
if(this.get(x)){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public boolean b;
|
||||
|
||||
public boolean get(int c){
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
public class Test{
|
||||
|
||||
public void test(boolean b){
|
||||
if(b == true){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,18 +1,38 @@
|
||||
public class Example {
|
||||
|
||||
public int a;
|
||||
|
||||
public static int testMethod(int b, boolean bo){
|
||||
a = b;
|
||||
if(bo){
|
||||
public class AllFeaturesClassExample {
|
||||
int a;
|
||||
boolean b;
|
||||
char c;
|
||||
|
||||
public void controlStructures(int adf, boolean bool) {
|
||||
if (a > (10 + 8)) {
|
||||
} else {
|
||||
}
|
||||
return a;
|
||||
|
||||
|
||||
while (a > adf) {
|
||||
a--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void testMethod(int b){
|
||||
// void logicalOperations() {
|
||||
// Logische UND-Operation
|
||||
// if (b && a > 5) {
|
||||
// System.out.println("a ist größer als 5 und b ist wahr");
|
||||
// }
|
||||
|
||||
}
|
||||
// Logische ODER-Operation
|
||||
// if (b || a < 5) {
|
||||
// System.out.println("b ist wahr oder a ist kleiner als 5");
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
// AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||
// obj.controlStructures();
|
||||
// }
|
||||
}
|
||||
|
64
src/test/resources/input/typedAstFeaturesTests/FullTest.java
Normal file
64
src/test/resources/input/typedAstFeaturesTests/FullTest.java
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
public class AllFeaturesClassExample {
|
||||
int a;
|
||||
boolean b;
|
||||
char c;
|
||||
|
||||
public void controlStructures(int adf, boolean bool) {
|
||||
if (a > (10 + 8)) {
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
while (a > adf) {
|
||||
a--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// void logicalOperations() {
|
||||
// // Logische UND-Operation
|
||||
// if (b && a > 5) {
|
||||
//// System.out.println("a ist größer als 5 und b ist wahr");
|
||||
// }
|
||||
//
|
||||
// // Logische ODER-Operation
|
||||
// if (b || a < 5) {
|
||||
//// System.out.println("b ist wahr oder a ist kleiner als 5");
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||
// obj.controlStructures();
|
||||
// }
|
||||
}
|
||||
|
||||
public class Test {
|
||||
|
||||
public Car c;
|
||||
|
||||
public int test(boolean b, int x) {
|
||||
if (b == true) {
|
||||
return c.getSpeed();
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car {
|
||||
|
||||
private int speed;
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
public class Car{
|
||||
|
||||
public void test(boolean boo){
|
||||
|
||||
if(boo){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
13
src/test/resources/input/typedAstFeaturesTests/IfReturn.java
Normal file
13
src/test/resources/input/typedAstFeaturesTests/IfReturn.java
Normal file
@@ -0,0 +1,13 @@
|
||||
public class Car{
|
||||
|
||||
public int getSpeed(boolean bool, int a, int b){
|
||||
|
||||
if(bool){
|
||||
return a;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
public class Test{
|
||||
|
||||
public int i;
|
||||
public boolean b;
|
||||
|
||||
public int test(){
|
||||
|
||||
return this.test(b);
|
||||
|
||||
}
|
||||
|
||||
public void test(int a){
|
||||
|
||||
}
|
||||
|
||||
public int test(boolean bool){
|
||||
int ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
public int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
public int test(){
|
||||
return this.getSpeed();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
public class Car{
|
||||
|
||||
private int speed;
|
||||
|
||||
public void getSpeed(boolean boo){
|
||||
if(boo){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user