Merge branch 'Endabgabe' into Tests
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
commit
1c327705d8
@ -9,7 +9,6 @@ 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;
|
||||
@ -22,10 +21,12 @@ public class CalculationNode extends BinaryNode {
|
||||
}
|
||||
|
||||
private void setOperator(String operator) {
|
||||
if(operator.equals("+")) {
|
||||
this.operator = EnumLineOperator.PLUS;
|
||||
} else if(operator.equals("-")) {
|
||||
this.operator = EnumLineOperator.MINUS;
|
||||
if(operator != null) {
|
||||
if(operator.equals("+")) {
|
||||
this.operator = EnumLineOperator.PLUS;
|
||||
} else if(operator.equals("-")) {
|
||||
this.operator = EnumLineOperator.MINUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,4 +41,4 @@ public class CalculationNode extends BinaryNode {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class MainMethodNode extends MethodNode implements Visitable {
|
||||
public BlockNode block;
|
||||
|
||||
public MainMethodNode(BlockNode block) {
|
||||
this.block = block;
|
||||
|
@ -1,11 +0,0 @@
|
||||
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;}
|
||||
}
|
@ -2,6 +2,7 @@ package ast.statementexpressions.methodcallstatementnexpressions;
|
||||
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.statements.IStatementNode;
|
||||
import ast.type.type.ITypeNode;
|
||||
import bytecode.visitor.MethodVisitor;
|
||||
import semantic.SemanticVisitor;
|
||||
import typechecker.TypeCheckResult;
|
||||
@ -11,6 +12,7 @@ import java.util.List;
|
||||
|
||||
public class MethodCallNode implements IStatementNode {
|
||||
public TargetNode target;
|
||||
public ITypeNode type;
|
||||
public List<ChainedMethodNode> chainedMethods = new ArrayList<>();
|
||||
public String identifier;
|
||||
public List<IExpressionNode> parameters = new ArrayList<>();
|
||||
|
@ -30,11 +30,6 @@ public class TargetNode implements ASTNode, Visitable {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MethodVisitor methodVisitor) {
|
||||
methodVisitor.visit(this);
|
||||
}
|
||||
|
||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||
return visitor.analyze(this);
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ 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<>();
|
||||
}
|
||||
|
||||
|
||||
@ -60,10 +60,10 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVaribales.add("this");
|
||||
localVariables.add("this");
|
||||
// Add all method parameters to localVariables
|
||||
for (ParameterNode parameterNode : constructorNode.parameters) {
|
||||
localVaribales.add(parameterNode.identifier);
|
||||
localVariables.add(parameterNode.identifier);
|
||||
}
|
||||
|
||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||
@ -89,8 +89,8 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVaribales.add("this");
|
||||
localVaribales.add("args");
|
||||
localVariables.add("this");
|
||||
localVariables.add("args");
|
||||
|
||||
// Visit all statements
|
||||
for (IStatementNode statementNode : mainMethodNode.block.statements) {
|
||||
@ -110,10 +110,10 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
null);
|
||||
|
||||
methodVisitor.visitCode();
|
||||
localVaribales.add("this");
|
||||
localVariables.add("this");
|
||||
// Add all method parameters to localVariables
|
||||
for (ParameterNode parameterNode : methodNode.parameters) {
|
||||
localVaribales.add(parameterNode.identifier);
|
||||
localVariables.add(parameterNode.identifier);
|
||||
}
|
||||
|
||||
// Visit all statements
|
||||
@ -181,7 +181,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
if (dotSubstractionNode.value != null) {
|
||||
dotSubstractionNode.value.accept(this);
|
||||
} else if (dotSubstractionNode.identifier != null) {
|
||||
methodVisitor.visitVarInsn(ILOAD, localVaribales.indexOf(dotSubstractionNode.identifier));
|
||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(dotSubstractionNode.identifier));
|
||||
} else if (dotSubstractionNode.memberAccess != null) {
|
||||
dotSubstractionNode.memberAccess.accept(this);
|
||||
} else if (dotSubstractionNode.methodCall != null) {
|
||||
@ -195,7 +195,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
public void visit(NonCalculationNode nonCalculationNode) {
|
||||
Label labelFalse = new Label();
|
||||
Label labelTrue = new Label();
|
||||
// TODO: Null check
|
||||
switch (nonCalculationNode.operator) {
|
||||
case AND:
|
||||
nonCalculationNode.unaryExpression.accept(this);
|
||||
@ -266,8 +265,10 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MemberAccessNode memberAccessNode) {
|
||||
if (memberAccessNode.thisExpr) {
|
||||
// methodVisitor.visitFieldInsn(PUTFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), );
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +297,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
if (unaryNode.thisExp != null) {
|
||||
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
||||
} else if (unaryNode.identifier != null) {
|
||||
methodVisitor.visitVarInsn(ILOAD, localVaribales.indexOf(unaryNode.identifier));
|
||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(unaryNode.identifier));
|
||||
} else if (unaryNode.memberAccess != null) {
|
||||
unaryNode.memberAccess.accept(this);
|
||||
} else if (unaryNode.value != null) {
|
||||
@ -362,23 +363,23 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
// Process expression
|
||||
localVariableDeclarationNode.expression.accept(this);
|
||||
// Store result of expression in variable
|
||||
if (localVaribales.contains(localVariableDeclarationNode.identifier)) {
|
||||
if (localVariables.contains(localVariableDeclarationNode.identifier)) {
|
||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
}
|
||||
} else {
|
||||
localVaribales.add(localVariableDeclarationNode.identifier);
|
||||
localVariables.add(localVariableDeclarationNode.identifier);
|
||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!localVaribales.contains(localVariableDeclarationNode.identifier)) {
|
||||
localVaribales.add(localVariableDeclarationNode.identifier);
|
||||
if (!localVariables.contains(localVariableDeclarationNode.identifier)) {
|
||||
localVariables.add(localVariableDeclarationNode.identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,43 +390,49 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
if (assignNode.expression instanceof IncrementNode) {
|
||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
||||
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
||||
methodVisitor.visitIincInsn(localVaribales.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||
assign(assignNode);
|
||||
} else if (incrementNode.crementType.equals(CrementType.SUFFIX)) { // Suffix: i++
|
||||
assign(assignNode);
|
||||
methodVisitor.visitIincInsn(localVaribales.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||
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(localVaribales.indexOf(decrementNode.assignableExpression.identifier), -1);
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), -1);
|
||||
assign(assignNode);
|
||||
} else if (decrementNode.crementType.equals(CrementType.SUFFIX)) {
|
||||
assign(assignNode);
|
||||
methodVisitor.visitIincInsn(localVaribales.indexOf(decrementNode.assignableExpression.identifier), 1);
|
||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), 1);
|
||||
}
|
||||
} else {
|
||||
assignNode.expression.accept(this);
|
||||
assign(assignNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void assign(AssignNode assignNode) {
|
||||
// Store result of expression in variable
|
||||
if (assignNode.assignable.memberAccess.thisExpr) {
|
||||
// Global var
|
||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||
if (assignNode.expression instanceof BaseType) {
|
||||
//methodVisitor.visitFieldInsn(PUTFIELD, class name, var identifier, mapper.getTypeChar(((BaseTypeNode) type).enumType));
|
||||
} else if (assignNode.expression instanceof ReferenceType) {
|
||||
//methodVisitor.visitFieldInsn(PUTFIELD, class name, var identifier, "L"class name object +";");
|
||||
}
|
||||
assignField(assignNode);
|
||||
} else {
|
||||
// Local var
|
||||
if (assignNode.expression instanceof BaseType) {
|
||||
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(assignNode.assignable.identifier));
|
||||
} else if (assignNode.expression instanceof ReferenceType) {
|
||||
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(assignNode.assignable.identifier));
|
||||
}
|
||||
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()+";");
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,13 +440,13 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
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(), ""));
|
||||
}
|
||||
// TODO
|
||||
//methodVisitor.visitMethodInsn(INVOKESPECIAL, class name, "<init>", mapper.generateMethodDescriptor(), false);
|
||||
// TODO: kann ein Field auch definiert werden? Abfrage ob local var oder field
|
||||
localVaribales.add(newDeclarationNode.identifier);
|
||||
methodVisitor.visitMethodInsn(INVOKESPECIAL, newDeclarationNode.identifier, "<init>", mapper.generateMethodDescriptor(new BaseType(TypeEnum.VOID),parameterNodes), false);
|
||||
localVariables.add(newDeclarationNode.identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -505,13 +512,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
whileNode.expression.accept(this);
|
||||
methodVisitor.visitJumpInsn(IFEQ, endOfLoopLabel); // if condition is false, jump out of loop
|
||||
|
||||
// TODO: Unterscheidung bei increment/decrement der for Schleife
|
||||
if (whileNode.block.statements.size() == 2) { // For loop
|
||||
whileNode.block.statements.get(0).accept(this);
|
||||
|
||||
} else {
|
||||
whileNode.block.statements.get(0).accept(this);
|
||||
}
|
||||
whileNode.block.accept(this);
|
||||
methodVisitor.visitJumpInsn(GOTO, loopLabel);
|
||||
|
||||
@ -520,16 +520,17 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(ChainedMethodNode chainedMethodNode) {
|
||||
|
||||
// TODO: Erstmal abwarten
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCallNode methodCallNode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TargetNode targetNode) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public interface MethodVisitor {
|
||||
// statement expression
|
||||
void visit(ChainedMethodNode chainedMethodNode);
|
||||
void visit(MethodCallNode methodCallNode);
|
||||
void visit(TargetNode targetNode);
|
||||
|
||||
void visit(AssignNode assignNode);
|
||||
void visit(NewDeclarationNode newDeclarationNode);
|
||||
|
@ -96,16 +96,24 @@ public class Main {
|
||||
// Log the typed AST
|
||||
RaupenLogger.logSemanticAnalyzer(typedAst);
|
||||
|
||||
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
||||
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
||||
if(SemanticAnalyzer.errors.isEmpty()){
|
||||
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
||||
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
||||
|
||||
final boolean genJar = Optional.ofNullable(System.getProperty("genJar")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
|
||||
final boolean genClass = Optional.ofNullable(System.getProperty("genClass")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
|
||||
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, genJar, genClass);
|
||||
assert typedAst != null;
|
||||
byteCodeGenerator.visit((ProgramNode) typedAst);
|
||||
// Log the bytecode generation
|
||||
RaupenLogger.logBytecodeGenerator();
|
||||
} else {
|
||||
for(Exception exception : SemanticAnalyzer.errors){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
final boolean genJar = Optional.ofNullable(System.getProperty("genJar")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
|
||||
final boolean genClass = Optional.ofNullable(System.getProperty("genClass")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
|
||||
|
||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, genJar, genClass);
|
||||
assert typedAst != null;
|
||||
byteCodeGenerator.visit((ProgramNode) typedAst);
|
||||
// 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;
|
||||
@ -14,6 +11,7 @@ import ast.members.*;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.statementexpressions.AssignNode;
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.IStatementExpressionNode;
|
||||
import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.CrementType;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
@ -75,7 +73,12 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@Override
|
||||
public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) {
|
||||
ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
||||
ConstructorNode constructorNode;
|
||||
if(ctx.AccessModifier() != null) {
|
||||
constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
||||
} else {
|
||||
constructorNode = new ConstructorNode("public", ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
||||
}
|
||||
if(ctx.parameterList() != null) {
|
||||
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
||||
constructorNode.addParameter((ParameterNode) visit(parameter));
|
||||
@ -164,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());
|
||||
}
|
||||
@ -177,7 +182,12 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@Override
|
||||
public ASTNode visitLocalVariableDeclaration(SimpleJavaParser.LocalVariableDeclarationContext ctx) {
|
||||
return new LocalVariableDeclarationNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression()));
|
||||
if(ctx.Assign() != null) {
|
||||
return new LocalVariableDeclarationNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText(), ctx.Assign().getText(), (IExpressionNode) visit(ctx.expression()));
|
||||
} else {
|
||||
return new LocalVariableDeclarationNode(createTypeNode(ctx.type().getText()), ctx.Identifier().getText(), null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -209,46 +219,60 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@Override
|
||||
public ASTNode visitForStatement(SimpleJavaParser.ForStatementContext ctx) {
|
||||
|
||||
List<IStatementNode> statements = new ArrayList<>();
|
||||
|
||||
//init
|
||||
// Initialisierung
|
||||
int i = 0;
|
||||
if(ctx.localVariableDeclaration() != null) {
|
||||
if (ctx.localVariableDeclaration() != null) {
|
||||
statements.add((IStatementNode) visit(ctx.localVariableDeclaration()));
|
||||
} else if(ctx.statementExpression(i) != null){
|
||||
} else if (ctx.statementExpression(i) != null) {
|
||||
statements.add((IStatementNode) visit(ctx.statementExpression(i)));
|
||||
i++;
|
||||
}
|
||||
|
||||
//condition
|
||||
// Bedingung
|
||||
IExpressionNode condition = (IExpressionNode) visit(ctx.expression());
|
||||
|
||||
//ink
|
||||
IStatementNode crement = null;
|
||||
if(ctx.statementExpression(i) != null){
|
||||
crement = (IStatementNode) visit(ctx.statementExpression(i));
|
||||
// Inkrement
|
||||
IStatementExpressionNode crement = null;
|
||||
boolean isPrefix = false;
|
||||
if (ctx.statementExpression(i) != null) {
|
||||
crement = (IStatementExpressionNode) visit(ctx.statementExpression(i));
|
||||
|
||||
if (crement instanceof IncrementNode) {
|
||||
isPrefix = ((IncrementNode) crement).crementType == CrementType.PREFIX;
|
||||
} else if (crement instanceof DecrementNode) {
|
||||
isPrefix = ((DecrementNode) crement).crementType == CrementType.PREFIX;
|
||||
}
|
||||
}
|
||||
|
||||
BlockNode forBlock = new BlockNode();
|
||||
BlockNode forBlock = (BlockNode) visit(ctx.blockStatement());
|
||||
|
||||
BlockNode forStatements = (BlockNode) visit(ctx.blockStatement());
|
||||
if(forStatements != null) {
|
||||
forBlock.addStatement((IStatementNode) forStatements);
|
||||
// While-Schleife
|
||||
BlockNode whileBody = new BlockNode();
|
||||
|
||||
// Prä-Inkrement: Das Inkrement kommt vor dem Block
|
||||
if (crement != null && isPrefix) {
|
||||
whileBody.addStatement((IStatementNode) crement);
|
||||
}
|
||||
|
||||
if(crement != null){
|
||||
BlockNode forCrement = new BlockNode();
|
||||
forCrement.addStatement((crement));
|
||||
forBlock.addStatement(forCrement);
|
||||
// Block Statements der For-Schleife in den While-Block kopieren
|
||||
for (IStatementNode statement : forBlock.statements) {
|
||||
whileBody.addStatement(statement);
|
||||
}
|
||||
|
||||
WhileNode While = new WhileNode(condition, forBlock);
|
||||
// Post-Inkrement: Das Inkrement kommt nach dem Block
|
||||
if (crement != null && !isPrefix) {
|
||||
whileBody.addStatement((IStatementNode) crement);
|
||||
}
|
||||
|
||||
statements.add(While);
|
||||
// Bedingung der While-Schleife
|
||||
WhileNode whileNode = new WhileNode(condition, whileBody);
|
||||
|
||||
statements.add(whileNode);
|
||||
|
||||
BlockNode resultBlock = new BlockNode();
|
||||
for(IStatementNode statement : statements) {
|
||||
for (IStatementNode statement : statements) {
|
||||
resultBlock.addStatement((IStatementNode) statement);
|
||||
}
|
||||
|
||||
@ -257,8 +281,13 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@Override
|
||||
public ASTNode visitIfElseStatement(SimpleJavaParser.IfElseStatementContext ctx) {
|
||||
IfElseNode ifElseStatementNode = new IfElseNode((IfNode) visit(ctx.ifStatement()),
|
||||
(ElseNode) visit(ctx.elseStatement()));
|
||||
IfElseNode ifElseStatementNode;
|
||||
if(ctx.elseStatement() != null) {
|
||||
ifElseStatementNode = new IfElseNode((IfNode) visit(ctx.ifStatement()),
|
||||
(ElseNode) visit(ctx.elseStatement()));
|
||||
} else {
|
||||
ifElseStatementNode = new IfElseNode((IfNode) visit(ctx.ifStatement()), null);
|
||||
}
|
||||
|
||||
for (SimpleJavaParser.ElseIfStatementContext elseIf : ctx.elseIfStatement()){
|
||||
ifElseStatementNode.addElseIfStatement(((IfNode) visit(elseIf)));
|
||||
@ -296,6 +325,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()));
|
||||
@ -532,6 +604,4 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
default -> new ReferenceType(identifier);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/janni/Desktop/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
@ -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}
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/janni/Desktop/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
@ -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
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/janni/Desktop/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/janni/Desktop/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
@ -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
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/janni/Desktop/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/Maxi/Documents/DHBW/Compilerbau/NichtHaskell2.0/src/main/java/parser/grammar/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
@ -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]* '\'';
|
||||
|
@ -21,6 +21,7 @@ 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.*;
|
||||
@ -29,6 +30,7 @@ import ast.type.EnumAccessModifierNode;
|
||||
import ast.type.ValueNode;
|
||||
import ast.type.type.*;
|
||||
import com.sun.jdi.IntegerType;
|
||||
import semantic.context.ClassContext;
|
||||
import semantic.context.Context;
|
||||
import semantic.exceptions.*;
|
||||
import typechecker.TypeCheckResult;
|
||||
@ -163,6 +165,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(FieldNode toCheck) {
|
||||
if (toCheck.type instanceof ReferenceType referenceType) {
|
||||
if (!context.containsClass(referenceType.getIdentifier())) {
|
||||
errors.add(new NotDeclaredException(referenceType.getIdentifier() + " not declared"));
|
||||
}
|
||||
}
|
||||
if (currentFields.get(toCheck.identifier) != null) {
|
||||
errors.add(new AlreadyDeclaredException("Already declared " + toCheck.identifier));
|
||||
return new TypeCheckResult(false, null);
|
||||
@ -170,6 +177,8 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
currentFields.put(toCheck.identifier, toCheck.type);
|
||||
}
|
||||
return new TypeCheckResult(true, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -224,7 +233,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
}
|
||||
for (IStatementNode statementNode : blockNode.statements) {
|
||||
var result = statementNode.accept(this);
|
||||
if(!(statementNode instanceof IncrementNode) && !(statementNode instanceof DecrementNode)){
|
||||
if (!(statementNode instanceof IncrementNode) && !(statementNode instanceof DecrementNode)) {
|
||||
if (result.getType() != null) {
|
||||
if (blockReturnType == null) {
|
||||
blockReturnType = result.getType();
|
||||
@ -249,6 +258,10 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
} else {
|
||||
if (currentFields.get(toCheck.identifier) != null) {
|
||||
var type = currentFields.get(toCheck.identifier);
|
||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||
memberAccessNode.identifiers.add(currentClass.identifier);
|
||||
memberAccessNode.identifiers.add(toCheck.identifier);
|
||||
toCheck.memberAccess = memberAccessNode;
|
||||
toCheck.setTypeNode(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else if (currentScope.getLocalVar(toCheck.identifier) != null) {
|
||||
@ -275,13 +288,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
currentNullType = oldNullType;
|
||||
var valid = true;
|
||||
|
||||
// This check currently handles things like :
|
||||
/**
|
||||
* private int i;
|
||||
* void foo(int i){
|
||||
* i = i;
|
||||
* }
|
||||
*/
|
||||
if (assignable.equals(rExpression)) {
|
||||
errors.add(new TypeMismatchException("Cannot assign to self"));
|
||||
valid = false;
|
||||
@ -318,33 +324,72 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
@Override
|
||||
public TypeCheckResult analyze(MethodCallNode toCheck) {
|
||||
|
||||
if (toCheck.target.identifier != null) {
|
||||
var targetType = currentScope.getLocalVar(toCheck.target.identifier);
|
||||
if (targetType == null) {
|
||||
targetType = currentFields.get(toCheck.target.identifier);
|
||||
if (toCheck.target != null) {
|
||||
if(toCheck.target.memberAccess == null){
|
||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||
memberAccessNode.identifiers.add(currentClass.identifier);
|
||||
memberAccessNode.identifiers.add(toCheck.target.identifier);
|
||||
toCheck.target.memberAccess = memberAccessNode;
|
||||
}
|
||||
if (targetType instanceof ReferenceType reference) {
|
||||
var type = getTypeFromMethod(toCheck, reference);
|
||||
if (type != null) {
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
return new TypeCheckResult(false, 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) {
|
||||
if (!toCheck.chainedMethods.isEmpty()) {
|
||||
for (ChainedMethodNode chainedMethod : toCheck.chainedMethods) {
|
||||
var type = getTypeFromMethod(chainedMethod, reference);
|
||||
if (type instanceof ReferenceType referenceType)
|
||||
reference = referenceType;
|
||||
else
|
||||
errors.add(new TypeMismatchException("Ein Basetyp hat keine funktionen"));
|
||||
}
|
||||
}
|
||||
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));
|
||||
if (toCheck.target.thisTar != null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
ReferenceType reference = new ReferenceType(currentClass.identifier);
|
||||
if (!toCheck.chainedMethods.isEmpty()) {
|
||||
for (ChainedMethodNode chainedMethod : toCheck.chainedMethods) {
|
||||
var type = getTypeFromMethod(chainedMethod, reference);
|
||||
if (type instanceof ReferenceType referenceType)
|
||||
reference = referenceType;
|
||||
else
|
||||
errors.add(new TypeMismatchException("Ein Basetyp hat keine funktionen"));
|
||||
}
|
||||
}
|
||||
var type = getTypeFromMethod(toCheck, reference);
|
||||
if (type != null) {
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
|
||||
@ -383,9 +428,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
if (context.containsClass(toCheck.identifier)) {
|
||||
return new TypeCheckResult(true, new ReferenceType(toCheck.identifier));
|
||||
} else {
|
||||
throw new RuntimeException("Cannot find class " + toCheck.identifier);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -409,6 +454,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
case PLUS, MINUS:
|
||||
if (calcRes.getType() instanceof BaseType calcType && dotRes.getType() instanceof BaseType dotType &&
|
||||
calcType.getTypeEnum().equals(TypeEnum.INT) && dotType.getTypeEnum().equals(TypeEnum.INT)) {
|
||||
calcNode.setType(new BaseType(TypeEnum.INT));
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.INT));
|
||||
}
|
||||
break;
|
||||
@ -416,10 +462,12 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
}
|
||||
|
||||
} else {
|
||||
calcNode.setType(calcNode.getType());
|
||||
return new TypeCheckResult(calcRes.isValid(), calcRes.getType());
|
||||
}
|
||||
} else if (calcNode.dotExpression != null) {
|
||||
var dotRes = calcNode.dotExpression.accept(this);
|
||||
calcNode.setType(dotRes.getType());
|
||||
return new TypeCheckResult(dotRes.isValid(), dotRes.getType());
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
@ -428,7 +476,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotNode toCheck) {
|
||||
if (toCheck.dotSubstractionExpression != null) {
|
||||
return toCheck.dotSubstractionExpression.accept(this);
|
||||
var result = toCheck.dotSubstractionExpression.accept(this);
|
||||
toCheck.setType(result.getType());
|
||||
return result;
|
||||
}
|
||||
return new TypeCheckResult(false, null);
|
||||
}
|
||||
@ -436,19 +486,35 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
@Override
|
||||
public TypeCheckResult analyze(DotSubstractionNode toCheck) {
|
||||
if (toCheck.value != null) {
|
||||
return toCheck.value.accept(this);
|
||||
var result = toCheck.value.accept(this);
|
||||
toCheck.setType(result.getType());
|
||||
return result;
|
||||
} else if (toCheck.memberAccess != null) {
|
||||
return toCheck.memberAccess.accept(this);
|
||||
var result = toCheck.memberAccess.accept(this);
|
||||
toCheck.setType(result.getType());
|
||||
return result;
|
||||
} else if (toCheck.methodCall != null) {
|
||||
return toCheck.methodCall.accept(this);
|
||||
var result = toCheck.methodCall.accept(this);
|
||||
toCheck.setType(result.getType());
|
||||
return result;
|
||||
} else if (toCheck.identifier != null) {
|
||||
if (currentScope.contains(toCheck.identifier)) {
|
||||
return new TypeCheckResult(true, currentScope.getLocalVar(toCheck.identifier));
|
||||
var type = currentScope.getLocalVar(toCheck.identifier);
|
||||
toCheck.setType(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else if (currentFields.get(toCheck.identifier) != null) {
|
||||
return new TypeCheckResult(true, currentFields.get(toCheck.identifier));
|
||||
var type = currentFields.get(toCheck.identifier);
|
||||
toCheck.setType(type);
|
||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||
memberAccessNode.identifiers.add(currentClass.identifier);
|
||||
memberAccessNode.identifiers.add(toCheck.identifier);
|
||||
toCheck.memberAccess = memberAccessNode;
|
||||
return new TypeCheckResult(true, type);
|
||||
}
|
||||
} else if (toCheck.calculationExpression != null) {
|
||||
return toCheck.calculationExpression.accept(this);
|
||||
var result = toCheck.calculationExpression.accept(this);
|
||||
toCheck.setType(result.getType());
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -468,8 +534,8 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
}
|
||||
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)) {
|
||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) &&
|
||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.BOOL)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be Boolean"));
|
||||
@ -493,9 +559,17 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
if (unary.identifier != null) {
|
||||
if (currentScope.contains(unary.identifier)) {
|
||||
return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier));
|
||||
var type = currentScope.getLocalVar(unary.identifier);
|
||||
unary.setType(type);
|
||||
return new TypeCheckResult(valid, type);
|
||||
} else if (currentFields.get(unary.identifier) != null) {
|
||||
return new TypeCheckResult(valid, currentFields.get(unary.identifier));
|
||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||
memberAccessNode.identifiers.add(currentClass.identifier);
|
||||
memberAccessNode.identifiers.add(unary.identifier);
|
||||
unary.memberAccess = memberAccessNode;
|
||||
var type = currentFields.get(unary.identifier);
|
||||
unary.setType(type);
|
||||
return new TypeCheckResult(valid,type );
|
||||
} else if (unary.statement != null) {
|
||||
var result = unary.statement.accept(this);
|
||||
unary.setType(result.getType());
|
||||
@ -505,15 +579,19 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
}
|
||||
} else if (unary.statement != null) {
|
||||
var result = unary.statement.accept(this);
|
||||
unary.setType(result.getType());
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.value != null) {
|
||||
var result = unary.value.accept(this);
|
||||
unary.setType(result.getType());
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.memberAccess != null) {
|
||||
var result = unary.memberAccess.accept(this);
|
||||
unary.setType(result.getType());
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
} else if (unary.expression != null) {
|
||||
var result = unary.expression.accept(this);
|
||||
unary.setType(result.getType());
|
||||
return new TypeCheckResult(result.isValid(), result.getType());
|
||||
}
|
||||
|
||||
@ -524,8 +602,16 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
public TypeCheckResult analyze(MemberAccessNode memberAccessNode) {
|
||||
|
||||
ITypeNode currentType = null;
|
||||
int start = 0;
|
||||
if(!memberAccessNode.identifiers.isEmpty()){
|
||||
if(currentFields.get(memberAccessNode.identifiers.get(0)) != null){
|
||||
memberAccessNode.identifiers.add(0, currentClass.identifier);
|
||||
start = 1;
|
||||
}
|
||||
}
|
||||
for (int i = start; i < memberAccessNode.identifiers.size(); i++) {
|
||||
|
||||
for (String s : memberAccessNode.identifiers) {
|
||||
String s = memberAccessNode.identifiers.get(i);
|
||||
if (currentType == null) {
|
||||
if (currentScope.getLocalVar(s) != null) {
|
||||
currentType = currentScope.getLocalVar(s);
|
||||
@ -561,6 +647,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
if (targetNode.memberAccess != null) {
|
||||
return targetNode.memberAccess.accept(this);
|
||||
} else if(targetNode.identifier != null) {
|
||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||
memberAccessNode.identifiers.add(currentClass.identifier);
|
||||
memberAccessNode.identifiers.add(targetNode.identifier);
|
||||
targetNode.memberAccess = memberAccessNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -620,4 +711,37 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ITypeNode getTypeFromMethod(ChainedMethodNode toCheck, ReferenceType reference) {
|
||||
var classContext = context.getClass(reference.getIdentifier());
|
||||
|
||||
var methods = classContext.getMethods();
|
||||
for (var method : methods) {
|
||||
if (toCheck.identifier.equals(method.getIdentifier())) {
|
||||
if (method.getParameters().size() == toCheck.expressions.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.expressions.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"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,10 @@ public class Context {
|
||||
return classes.get(identifier);
|
||||
}
|
||||
|
||||
public HashMap<String, ClassContext> getClasses() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
public boolean containsClass(String identifier) {
|
||||
return classes.containsKey(identifier);
|
||||
}
|
||||
|
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: main.Main
|
||||
|
@ -12,11 +12,16 @@ import java.nio.file.Paths;
|
||||
* run every test: mvn test
|
||||
* Nutzen dieser Klasse: Eigentlich nicht vorhanden, in der Main gibts nichts zu testen
|
||||
*/
|
||||
@Deprecated
|
||||
public class MainTest {
|
||||
@Test
|
||||
void test() {
|
||||
System.out.println("MainTest");
|
||||
CharStream codeCharStream = null;
|
||||
try {
|
||||
codeCharStream = CharStreams.fromPath(Paths.get("src/main/test/resources/CompilerInput.java"));
|
||||
Main.compileFile(codeCharStream, "src/main/test/resources/output");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error reading the file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@Deprecated
|
||||
|
||||
public class ReflectionsTest {
|
||||
|
||||
@Test
|
||||
|
@ -1,25 +1,31 @@
|
||||
package parser;
|
||||
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.ClassNode;
|
||||
import ast.ProgramNode;
|
||||
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.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.FieldNode;
|
||||
import ast.members.MethodNode;
|
||||
import ast.members.*;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.statementexpressions.AssignNode;
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.NewDeclarationNode;
|
||||
import ast.statementexpressions.crementexpressions.CrementType;
|
||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statements.BlockNode;
|
||||
import ast.statements.ReturnNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||
import ast.statements.*;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.EnumValueNode;
|
||||
import ast.type.ValueNode;
|
||||
import ast.type.type.BaseType;
|
||||
import ast.type.type.ReferenceType;
|
||||
import ast.type.type.TypeEnum;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -316,7 +322,7 @@ class AstBuilderTest {
|
||||
ConstructorNode constructor = new ConstructorNode("public", "Null", blockCon);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "Null");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new ReferenceType("Null"), "a"));
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
@ -328,67 +334,359 @@ class AstBuilderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Self Reference Test")
|
||||
public void selfReferenceTest() {
|
||||
@DisplayName("If Test")
|
||||
public void ifTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "intValue", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))));
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode ifBlock = new BlockNode();
|
||||
ifBlock.addStatement(new DecrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
block.addStatement(new IfElseNode(new IfNode(new NonCalculationNode(new UnaryNode("intValue"), "==", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))), ifBlock), null));
|
||||
|
||||
block.addStatement(new ReturnNode(null));
|
||||
|
||||
ConstructorNode constructor = new ConstructorNode("public", "If", block);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "If");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "If.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("If Else Test")
|
||||
public void ifElseTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "intValue", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))));
|
||||
|
||||
BlockNode ifBlock = new BlockNode();
|
||||
ifBlock.addStatement(new DecrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
BlockNode elseBlock = new BlockNode();
|
||||
elseBlock.addStatement(new IncrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
block.addStatement(new IfElseNode(new IfNode(new NonCalculationNode(new UnaryNode("intValue"), "==", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))), ifBlock), new ElseNode(elseBlock)));
|
||||
|
||||
block.addStatement(new ReturnNode(null));
|
||||
|
||||
ConstructorNode constructor = new ConstructorNode("public", "IfElse", block);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "IfElse");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "IfElse.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("If Else If ElseTest")
|
||||
public void ifElseIfElseTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "intValue", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))));
|
||||
|
||||
BlockNode ifBlock = new BlockNode();
|
||||
ifBlock.addStatement(new DecrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
BlockNode elseBlock = new BlockNode();
|
||||
elseBlock.addStatement(new IncrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
|
||||
IfElseNode ifElseStatement = new IfElseNode(new IfNode(new NonCalculationNode(new UnaryNode("intValue"), "==", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "5"))), ifBlock), new ElseNode(elseBlock));
|
||||
|
||||
BlockNode ifElseBlock = new BlockNode();
|
||||
ifElseBlock.addStatement(new IncrementNode(CrementType.SUFFIX, new AssignableNode("intValue")));
|
||||
ifElseStatement.addElseIfStatement(new IfNode(new NonCalculationNode(new UnaryNode("intValue"), "==", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "4"))), ifElseBlock));
|
||||
|
||||
block.addStatement(ifElseStatement);
|
||||
|
||||
block.addStatement(new ReturnNode(null));
|
||||
|
||||
ConstructorNode constructor = new ConstructorNode("public", "IfElseIfElse", block);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "IfElseIfElse");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "IfElseIfElse.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Self Reference Test")
|
||||
public void selfReferneceTest(){
|
||||
|
||||
ClassNode testClass = Helper.generateEmptyClass("SelfReference");
|
||||
|
||||
MemberNode testClassObject = new FieldNode(new AccessModifierNode("public"), new ReferenceType("SelfReference"),"selfReference");
|
||||
|
||||
BlockNode testMethod1Block = new BlockNode();
|
||||
testMethod1Block.addStatement(new ReturnNode(new UnaryNode(new MethodCallNode(new TargetNode(true), "testMethod2"))));
|
||||
MethodNode testMethod1 = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod1", testMethod1Block);
|
||||
|
||||
BlockNode testMethod2Block = new BlockNode();
|
||||
testMethod2Block.addStatement(new ReturnNode(new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE,"1"))));
|
||||
MethodNode testMethod2 = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod2", testMethod2Block);
|
||||
|
||||
BlockNode testMethod3Block = new BlockNode();
|
||||
testMethod3Block.addStatement(new LocalVariableDeclarationNode(new ReferenceType("SelfReference"),"selfReference1", "=", new UnaryNode(new NewDeclarationNode("SelfReference")))); // Assing einfach "=" ?
|
||||
MemberAccessNode methodAccess = new MemberAccessNode(false);
|
||||
methodAccess.addIdentifier("selfReference1");
|
||||
methodAccess.addIdentifier("selfReference");
|
||||
TargetNode methodTarget = new TargetNode(methodAccess);
|
||||
testMethod3Block.addStatement(new ReturnNode(new UnaryNode(new MethodCallNode(methodTarget,"testMethod1"))));
|
||||
MethodNode testMethod3 = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod3", testMethod3Block);
|
||||
|
||||
testClass.addMember(testClassObject);
|
||||
testClass.addMember(testMethod1);
|
||||
testClass.addMember(testMethod2);
|
||||
testClass.addMember(testMethod3);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(testClass);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "SelfReference.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Variable Compare Test")
|
||||
public void variableCompareTest() {
|
||||
public void variableCompareTest(){
|
||||
ClassNode class1 = Helper.generateEmptyClass("VariableCompare");
|
||||
UnaryNode trueValue = new UnaryNode(new ValueNode(EnumValueNode.BOOLEAN_VALUE,"true"));
|
||||
UnaryNode falseValue = new UnaryNode(new ValueNode(EnumValueNode.BOOLEAN_VALUE,"false"));
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode trueBlock = new BlockNode();
|
||||
trueBlock.addStatement(new ReturnNode(trueValue));
|
||||
MethodNode trueMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "trueMethod", trueBlock);
|
||||
|
||||
BlockNode falseBlock = new BlockNode();
|
||||
falseBlock.addStatement(new ReturnNode(falseValue));
|
||||
MethodNode falseMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "falseMethod", falseBlock);
|
||||
|
||||
BlockNode trueAndTrueBlock = new BlockNode();
|
||||
trueAndTrueBlock.addStatement(new ReturnNode(new NonCalculationNode(trueValue, "&&", trueValue)));
|
||||
MethodNode trueAndTrueMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "trueAndTrueMethod", trueAndTrueBlock);
|
||||
|
||||
BlockNode trueAndFalseBlock = new BlockNode();
|
||||
trueAndFalseBlock.addStatement(new ReturnNode(new NonCalculationNode(trueValue, "&&", falseValue)));
|
||||
MethodNode trueAndFalseMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "trueAndFalseMethod", trueAndFalseBlock);
|
||||
|
||||
BlockNode falseAndFalseBlock = new BlockNode();
|
||||
falseAndFalseBlock.addStatement(new ReturnNode(new NonCalculationNode(falseValue, "&&", falseValue)));
|
||||
MethodNode falseAndFalseMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "falseAndFalseMethod", falseAndFalseBlock);
|
||||
|
||||
BlockNode trueOrTrueBlock = new BlockNode();
|
||||
trueOrTrueBlock.addStatement(new ReturnNode(new NonCalculationNode(trueValue, "||", trueValue)));
|
||||
MethodNode trueOrFalseMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "trueOrTrueMethod", trueOrTrueBlock);
|
||||
|
||||
BlockNode falseOrFalseBlock = new BlockNode();
|
||||
falseOrFalseBlock.addStatement(new ReturnNode(new NonCalculationNode(falseValue, "||", falseValue)));
|
||||
MethodNode falseOrFalseMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "falseOrFalseMethod", falseOrFalseBlock);
|
||||
|
||||
class1.addMember(trueMethod);
|
||||
class1.addMember(falseMethod);
|
||||
class1.addMember(trueAndTrueMethod);
|
||||
class1.addMember(trueAndFalseMethod);
|
||||
class1.addMember(falseAndFalseMethod);
|
||||
class1.addMember(trueOrFalseMethod);
|
||||
class1.addMember(falseOrFalseMethod);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "VariableCompare.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Variable Calculation Test")
|
||||
public void variableCalculationTest() {
|
||||
public void variableCalculationTest(){
|
||||
ClassNode class1 = Helper.generateEmptyClass("VariableCalculation");
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode aPlusBBlock = new BlockNode();
|
||||
aPlusBBlock.addStatement(new ReturnNode(new CalculationNode(new CalculationNode(new DotNode(new DotSubstractionNode("a"))), "+", new DotNode(new DotSubstractionNode("b")))));
|
||||
MethodNode aPlusBMethod = new MethodNode("public", new BaseType(TypeEnum.INT), false, "aPlusB", aPlusBBlock);
|
||||
aPlusBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aPlusBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aMinusBBlock = new BlockNode();
|
||||
aMinusBBlock.addStatement(new ReturnNode(new CalculationNode(new CalculationNode(new DotNode(new DotSubstractionNode("a"))), "-", new DotNode(new DotSubstractionNode("b")))));
|
||||
MethodNode aMinusBMethod = new MethodNode("public", new BaseType(TypeEnum.INT), false, "aMinusB", aMinusBBlock);
|
||||
aMinusBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aMinusBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aTimeBBlock = new BlockNode();
|
||||
aTimeBBlock.addStatement(new ReturnNode(new CalculationNode(new DotNode(new DotNode(new DotSubstractionNode("a")), "*", new DotSubstractionNode("b")))));
|
||||
MethodNode aTimeBMethod = new MethodNode("public", new BaseType(TypeEnum.INT), false, "aTimeB", aTimeBBlock);
|
||||
aTimeBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aTimeBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aDivBBlock = new BlockNode();
|
||||
aDivBBlock.addStatement(new ReturnNode(new CalculationNode(new DotNode(new DotNode(new DotSubstractionNode("a")), "/", new DotSubstractionNode("b")))));
|
||||
MethodNode aDivBMethod = new MethodNode("public", new BaseType(TypeEnum.INT), false, "aDivB", aDivBBlock);
|
||||
aDivBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aDivBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode complexCalcBlock = new BlockNode();
|
||||
complexCalcBlock.addStatement(new ReturnNode(new CalculationNode(null, null, new DotNode(new DotNode(new DotNode(new DotNode(new DotSubstractionNode("a")), "*", new DotSubstractionNode("b")), "/", new DotSubstractionNode(new ValueNode(EnumValueNode.INT_VALUE, "1"))), "*", new DotSubstractionNode(new ValueNode(EnumValueNode.INT_VALUE, "3"))))));
|
||||
MethodNode complexCalcMethod = new MethodNode("public", new BaseType(TypeEnum.INT), false, "complexCalc", complexCalcBlock);
|
||||
complexCalcMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
complexCalcMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aSmallerBBlock = new BlockNode();
|
||||
aSmallerBBlock.addStatement(new ReturnNode(new NonCalculationNode(new UnaryNode("a"), "<", new UnaryNode("b"))));
|
||||
MethodNode aSmallerBMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "aSmallerB", aSmallerBBlock);
|
||||
aSmallerBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aSmallerBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aGreaterBBlock = new BlockNode();
|
||||
aGreaterBBlock.addStatement(new ReturnNode(new NonCalculationNode(new UnaryNode("a"), ">", new UnaryNode("b"))));
|
||||
MethodNode aGreaterBMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "aGreaterB", aGreaterBBlock);
|
||||
aGreaterBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aGreaterBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
BlockNode aEqualsBBlock = new BlockNode();
|
||||
aEqualsBBlock.addStatement(new ReturnNode(new NonCalculationNode(new UnaryNode("a"), "==", new UnaryNode("b"))));
|
||||
MethodNode aEqualsBMethod = new MethodNode("public", new BaseType(TypeEnum.BOOL), false, "aEqualsB", aEqualsBBlock);
|
||||
aEqualsBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
aEqualsBMethod.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
class1.addMember(aPlusBMethod);
|
||||
class1.addMember(aMinusBMethod);
|
||||
class1.addMember(aTimeBMethod);
|
||||
class1.addMember(aDivBMethod);
|
||||
class1.addMember(complexCalcMethod);
|
||||
class1.addMember(aSmallerBMethod);
|
||||
class1.addMember(aGreaterBMethod);
|
||||
class1.addMember(aEqualsBMethod);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "VariableCalculation.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Main Method Test")
|
||||
public void mainMethodTest() {
|
||||
public void mainMethodTest(){
|
||||
ClassNode class1 = Helper.generateEmptyClass("MainMethod");
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new ReturnNode(null));
|
||||
|
||||
class1.addMember(new MainMethodNode(block));
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "MainMethod.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("While Test")
|
||||
public void whileTest() {
|
||||
public void whileTest(){
|
||||
NonCalculationNode condition = new NonCalculationNode(new UnaryNode("i"), ">", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "0")));
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode whileBlock = new BlockNode();
|
||||
whileBlock.addStatement(new DecrementNode(CrementType.SUFFIX, new AssignableNode("i")));
|
||||
|
||||
WhileNode whileStatement = new WhileNode(condition, whileBlock);
|
||||
|
||||
BlockNode blockCon = new BlockNode();
|
||||
blockCon.addStatement(new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "i", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "10"))));
|
||||
blockCon.addStatement(whileStatement);
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "TestClass", blockCon);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "While");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "While.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Do While Test")
|
||||
public void doWhileTest() {
|
||||
public void doWhileTest(){
|
||||
NonCalculationNode condition = new NonCalculationNode(new UnaryNode("i"), "<", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "10")));
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
BlockNode whileBlock = new BlockNode();
|
||||
whileBlock.addStatement(new IncrementNode(CrementType.SUFFIX, new AssignableNode("i")));
|
||||
|
||||
WhileNode whileStatement = new WhileNode(condition, whileBlock);
|
||||
|
||||
BlockNode blockDoWhile = new BlockNode();
|
||||
blockDoWhile.addStatement(whileBlock);
|
||||
blockDoWhile.addStatement(whileStatement);
|
||||
|
||||
BlockNode blockCon = new BlockNode();
|
||||
blockCon.addStatement(new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "i", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "0"))));
|
||||
blockCon.addStatement(blockDoWhile);
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "TestClass", blockCon);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "DoWhile");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "DoWhile.java");
|
||||
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("For Test")
|
||||
public void forTest() {
|
||||
public void forTest(){
|
||||
LocalVariableDeclarationNode forDeclaration = new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "i", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "0")));
|
||||
|
||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
AssignableNode assignable = new AssignableNode("i");
|
||||
IncrementNode increment = new IncrementNode(CrementType.SUFFIX, assignable);
|
||||
|
||||
//Noch nicht speziell Increment nur zum Development Testen per Debug
|
||||
@Test
|
||||
@DisplayName("Increment Test")
|
||||
public void incrementTest() {
|
||||
ClassNode classNode = Helper.generateEmptyClass("Increment");
|
||||
classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
LocalVariableDeclarationNode declaration = new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "a", null, null);
|
||||
|
||||
BlockNode whileBlock = new BlockNode();
|
||||
whileBlock.addStatement(declaration);
|
||||
whileBlock.addStatement(increment);
|
||||
|
||||
WhileNode whileStatement = new WhileNode(new NonCalculationNode(new UnaryNode("i"), "<", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "10"))), whileBlock);
|
||||
|
||||
BlockNode forStatement = new BlockNode();
|
||||
forStatement.addStatement(forDeclaration);
|
||||
forStatement.addStatement(whileStatement);
|
||||
|
||||
BlockNode blockCon = new BlockNode();
|
||||
blockCon.addStatement(forStatement);
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "TestClass", blockCon);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "For");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode expected = new ProgramNode();
|
||||
expected.addClass(classNode);
|
||||
expected.addClass(class1);
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "For.java");
|
||||
|
||||
ASTNode actual = Helper.generateAST(directoryPath + "Increment.java");
|
||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -26,6 +26,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import semantic.exceptions.*;
|
||||
import semantic.exceptions.NotDeclaredException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@ -152,6 +154,189 @@ public class EndToTypedAstTest {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void notDeclared() {
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/johnsTests/NotDeclared.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof NotDeclaredException));
|
||||
}*/
|
||||
|
||||
@Test
|
||||
public void typeMismatchTest() {
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/TypeMismatchIntBool.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof TypeMismatchException));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterAlreadyDecleared() {
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/ParameterAlreadyDecleared.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof AlreadyDeclaredException));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldAlreadyDecleared(){
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/FieldAlreadyDecleared.java");
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof AlreadyDeclaredException));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeMismatchRefType(){
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/TypeMismatchRefType.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof TypeMismatchException));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctRetType(){
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/CorrectRetType.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retTypeMismatch(){
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/RetTypeMismatch.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof TypeMismatchException));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleRetType(){
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/MultipleRetTypes.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof MultipleReturnTypes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void BothTypesMustBeSameGreaterSmallerEqual(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/BothTypesMustBeSame.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof TypeMismatchException));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NoSuchType(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/ClassNotDeclared.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof NotDeclaredException));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FieldIsNotVisible(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/FieldIsNotVisible.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof NotVisibleException));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ChainedMethods(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/ChainedMethods.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void VariableCompare(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void IfExpressionInt(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/IfExpressionInt.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SelectWrongMethodCauseParameter(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/SelectWrongMethodCauseParameter.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SelectRightMethodCauseParameter(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void VariableCalculation(){
|
||||
|
||||
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java");
|
||||
|
||||
SemanticAnalyzer.generateTast(tast);
|
||||
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
// ------------------ Helpers ------------------
|
||||
|
||||
|
35
src/test/java/semantic/SemanticHelper.java
Normal file
35
src/test/java/semantic/SemanticHelper.java
Normal file
@ -0,0 +1,35 @@
|
||||
package semantic;
|
||||
|
||||
import ast.ASTNode;
|
||||
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 parser.astBuilder.ASTBuilder;
|
||||
import parser.generated.SimpleJavaLexer;
|
||||
import parser.generated.SimpleJavaParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SemanticHelper {
|
||||
public static ASTNode generateTypedASTFrom(String filePath) {
|
||||
|
||||
SemanticAnalyzer.clearAnalyzer();
|
||||
|
||||
CharStream testFile = null;
|
||||
try {
|
||||
testFile = CharStreams.fromFileName(filePath);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SimpleJavaLexer lexer = new SimpleJavaLexer(testFile);
|
||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||
tokenStream.fill();
|
||||
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
|
||||
ParseTree parseTree = parser.program();
|
||||
ASTBuilder astBuilder = new ASTBuilder();
|
||||
|
||||
return (ProgramNode) astBuilder.visit(parseTree);
|
||||
}
|
||||
}
|
@ -1,443 +1,5 @@
|
||||
package semantic;
|
||||
|
||||
import ast.ASTNode;
|
||||
import ast.ClassNode;
|
||||
import ast.ProgramNode;
|
||||
import ast.expressions.IExpressionNode;
|
||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||
import ast.expressions.unaryexpressions.UnaryNode;
|
||||
import ast.members.ConstructorNode;
|
||||
import ast.members.FieldNode;
|
||||
import ast.members.MethodNode;
|
||||
import ast.parameters.ParameterNode;
|
||||
import ast.statementexpressions.AssignNode;
|
||||
import ast.statementexpressions.AssignableNode;
|
||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||
import ast.statements.BlockNode;
|
||||
import ast.statements.ReturnNode;
|
||||
import ast.type.AccessModifierNode;
|
||||
import ast.type.EnumValueNode;
|
||||
import ast.type.ValueNode;
|
||||
import ast.type.type.BaseType;
|
||||
import ast.type.type.TypeEnum;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import parser.Helper;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SemanticTest {
|
||||
|
||||
private final static String directoryPath = "src/test/resources/input/singleFeatureTests/";
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
SemanticAnalyzer.clearAnalyzer();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Empty Class Test")
|
||||
public void emptyClassTest() {
|
||||
ClassNode emptyClass = Helper.generateEmptyClass("EmptyClass");
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(emptyClass);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Multiple Empty Classes Test")
|
||||
public void multipleEmptyClassesTest() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("MultipleClasses");
|
||||
ClassNode class2 = Helper.generateEmptyClass("TestClass2");
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
abstractSyntaxTree.addClass(class2);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Empty Class Test with Constructor")
|
||||
public void emptyClassWithConstructorTest() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("EmptyClassWithConstructor");
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Field Test")
|
||||
public void fieldTest() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("Field");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Field Test with Accessmodifier")
|
||||
public void fieldTestWithModifier() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("FieldWithAccessModifier");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Comments Ignore Test")
|
||||
public void commentsIgnoreTest() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("Comments");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("private"), new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Constructor Parameter Test")
|
||||
public void constructorParameterTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "ConstructorParameter", block);
|
||||
constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b"));
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "ConstructorParameter");
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("This Dot Test")
|
||||
public void thisDotTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
ValueNode value = new ValueNode(EnumValueNode.INT_VALUE, "1");
|
||||
IExpressionNode expression = new UnaryNode(value);
|
||||
|
||||
block.addStatement(new AssignNode(assignable, expression));
|
||||
block.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "ThisDot", block);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "ThisDot");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Constructor This Dot Test")
|
||||
public void constructorThisDotTest() {
|
||||
BlockNode block = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
IExpressionNode expression = new UnaryNode("a");
|
||||
|
||||
block.addStatement(new AssignNode(assignable, expression));
|
||||
block.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "ConstructorThisDot", block);
|
||||
constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "ConstructorThisDot");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("private"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Void Methoden Test")
|
||||
public void voidMethodenTest() {
|
||||
ClassNode class1 = Helper.generateEmptyClass("VoidMethod");
|
||||
BlockNode block = new BlockNode();
|
||||
block.addStatement(new ReturnNode(null));
|
||||
class1.addMember(new MethodNode("public", null, true, "test", block));
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Constructor Method call Test")
|
||||
public void constructorMethodCallTest() {
|
||||
BlockNode blockCon = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
IExpressionNode expression = new UnaryNode(new MethodCallNode(null, "testMethod"));
|
||||
|
||||
blockCon.addStatement(new AssignNode(assignable, expression));
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "ConstructorMethodCall", blockCon);
|
||||
|
||||
BlockNode blockMethod = new BlockNode();
|
||||
blockMethod.addStatement(new ReturnNode(new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "1"))));
|
||||
MethodNode method = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod", blockMethod);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "ConstructorMethodCall");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(constructor);
|
||||
class1.addMember(method);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Constructor Method call Parameters Test")
|
||||
public void constructorMethodCallParametersTest() {
|
||||
BlockNode blockCon = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
MethodCallNode methodCall = new MethodCallNode(null, "testMethod");
|
||||
methodCall.addExpression(new UnaryNode("a"));
|
||||
IExpressionNode expression = new UnaryNode(methodCall);
|
||||
|
||||
blockCon.addStatement(new AssignNode(assignable, expression));
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "ConstructorMethodCallParameters", blockCon);
|
||||
constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
BlockNode blockMethod = new BlockNode();
|
||||
blockMethod.addStatement(new ReturnNode(new UnaryNode("a")));
|
||||
MethodNode method = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod", blockMethod);
|
||||
method.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "ConstructorMethodCallParameters");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(constructor);
|
||||
class1.addMember(method);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Char Test")
|
||||
public void charTest() {
|
||||
BlockNode blockCon = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
MethodCallNode methodCall = new MethodCallNode(null, "testMethod");
|
||||
methodCall.addExpression(new UnaryNode("a"));
|
||||
IExpressionNode expression = new UnaryNode(methodCall);
|
||||
|
||||
blockCon.addStatement(new AssignNode(assignable, expression));
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "Char", blockCon);
|
||||
constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.CHAR), "a"));
|
||||
|
||||
BlockNode blockMethod = new BlockNode();
|
||||
blockMethod.addStatement(new ReturnNode(new UnaryNode("a")));
|
||||
MethodNode method = new MethodNode("public", new BaseType(TypeEnum.CHAR), false, "testMethod", blockMethod);
|
||||
method.addParameter(new ParameterNode(new BaseType(TypeEnum.CHAR), "a"));
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "Char");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.CHAR), "a"));
|
||||
class1.addMember(constructor);
|
||||
class1.addMember(method);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Null Test")
|
||||
public void nullTest() {
|
||||
BlockNode blockCon = new BlockNode();
|
||||
MemberAccessNode memberAccess = new MemberAccessNode(true);
|
||||
memberAccess.addIdentifier("a");
|
||||
|
||||
AssignableNode assignable = new AssignableNode(memberAccess);
|
||||
|
||||
blockCon.addStatement(new AssignNode(assignable, new UnaryNode(new ValueNode(EnumValueNode.NULL_VALUE, "null"))));
|
||||
blockCon.addStatement(new ReturnNode(null));
|
||||
ConstructorNode constructor = new ConstructorNode("public", "Null", blockCon);
|
||||
|
||||
ClassNode class1 = new ClassNode("public", "Null");
|
||||
class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
class1.addMember(constructor);
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(class1);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Self Reference Test")
|
||||
public void selfReferenceTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Variable Compare Test")
|
||||
public void variableCompareTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Variable Calculation Test")
|
||||
public void variableCalculationTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Main Method Test")
|
||||
public void mainMethodTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("While Test")
|
||||
public void whileTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Do While Test")
|
||||
public void doWhileTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("For Test")
|
||||
public void forTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Increment Test")
|
||||
public void incrementTest() {
|
||||
ClassNode classNode = Helper.generateEmptyClass("Increment");
|
||||
classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||
|
||||
ProgramNode abstractSyntaxTree = new ProgramNode();
|
||||
abstractSyntaxTree.addClass(classNode);
|
||||
|
||||
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
for (Exception runtimeException : SemanticAnalyzer.errors) {
|
||||
runtimeException.printStackTrace();
|
||||
}
|
||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
||||
assertNotNull(typedAst);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/combinedFeatureTests/LoopExamples.class
Normal file
BIN
src/test/resources/input/combinedFeatureTests/LoopExamples.class
Normal file
Binary file not shown.
Binary file not shown.
25
src/test/resources/input/endabgabeTests/Car.java
Normal file
25
src/test/resources/input/endabgabeTests/Car.java
Normal file
@ -0,0 +1,25 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Car myCar = new Car(2020);
|
||||
int tires = 0;
|
||||
int year = myCar.getYear();
|
||||
|
||||
if (year == 2020) {
|
||||
tires = 4;
|
||||
} else {
|
||||
tires = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Car {
|
||||
private int year;
|
||||
|
||||
public Car(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return this.year;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
public class ControlStructures {
|
||||
|
||||
public int sum(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public cahr checkNumber(int num) {
|
||||
if (num > 0) {
|
||||
return "p";
|
||||
} else if (num < 0) {
|
||||
return "n";
|
||||
} else {
|
||||
return "z";
|
||||
}
|
||||
}
|
||||
|
||||
public void printNumbersUpTo(int limit) {
|
||||
int even = 0;
|
||||
int uneven = 0;
|
||||
int i = 0;
|
||||
while (i < limit) {
|
||||
if (i % 2 == 0) {
|
||||
even++;
|
||||
} else {
|
||||
uneven = uneven + 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ControlStructures cs = new ControlStructures();
|
||||
cs.printNumbersUpTo(5);
|
||||
int result = cs.sum(5, 5);
|
||||
}
|
||||
}
|
11
src/test/resources/input/endabgabeTests/Person.java
Normal file
11
src/test/resources/input/endabgabeTests/Person.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class Person {
|
||||
private int age;
|
||||
|
||||
public Person(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
}
|
@ -5,5 +5,18 @@ public class AllFeaturesClassExample {
|
||||
while (a > bool) {
|
||||
a--;
|
||||
}
|
||||
|
||||
if (a == bool) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if (a < bool) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
public class Test {
|
||||
|
||||
public House h;
|
||||
|
||||
public int test(House h){
|
||||
return h.getW().getSize();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class House {
|
||||
|
||||
private Window w;
|
||||
|
||||
public Window getW(){
|
||||
return w;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Window{
|
||||
|
||||
private int size;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
// @expected: NotDeclaredException
|
||||
public class Test {
|
||||
|
||||
public House1 h;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class CorrectRetType {
|
||||
public static int testMethod(int x){
|
||||
return x;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
public class FieldAlreadyDecleared {
|
||||
public int a;
|
||||
public int a;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class Test{
|
||||
|
||||
int a = 10;
|
||||
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public void test(int x){
|
@ -0,0 +1,6 @@
|
||||
public class MultipleRetTypes {
|
||||
public static int testMethod(int x, char c){
|
||||
return x;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class NotDeclared {
|
||||
public void Method() {
|
||||
i = 10;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class ParameterAlreadyDecleared {
|
||||
public void Method(int a, int a) {}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class Example {
|
||||
public static int testMethod(char x){
|
||||
return x;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public int i;
|
||||
public boolean b;
|
||||
|
||||
public int test(){
|
||||
|
||||
return test(b);
|
||||
|
||||
}
|
||||
|
||||
public void test(int a){
|
||||
|
||||
}
|
||||
|
||||
public int test(boolean bool){
|
||||
int ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ public class Test{
|
||||
|
||||
public int test(){
|
||||
|
||||
return this.test(i);
|
||||
return test(i);
|
||||
|
||||
}
|
||||
|
||||
@ -19,4 +19,4 @@ public class Test{
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class TypeMismatchIntBool {
|
||||
public void Method() {
|
||||
int intVariable;
|
||||
intVariable = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
public class TypeMismatchRefType {
|
||||
public static int Methode(Class1 class1, Class2 class2){
|
||||
class1 = class2;
|
||||
}
|
||||
}
|
||||
|
||||
public class Class1{
|
||||
public int a;
|
||||
}
|
||||
|
||||
public class Class2{
|
||||
public boolean a;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
class VariableCalculationTest{
|
||||
class VariableCalculation{
|
||||
|
||||
int aPlusB(int a, int b){
|
||||
return a + b;
|
||||
@ -16,8 +16,8 @@ class VariableCalculationTest{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
int colmplexCalc (int a, int b){
|
||||
return a * (b / 1);
|
||||
int complexCalc (int a, int b){
|
||||
return a * b / 1 * 3;
|
||||
}
|
||||
|
||||
boolean aSmallerB (int a, int b){
|
@ -0,0 +1,30 @@
|
||||
class VariableCompare{
|
||||
|
||||
boolean trueMethod() {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean falseMethod(){
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean trueAndTrueMethod(){
|
||||
return true && true;
|
||||
}
|
||||
|
||||
boolean trueAndFalseMethod(){
|
||||
return true && false;
|
||||
}
|
||||
|
||||
boolean falseAndFalseMethod(){
|
||||
return false && false;
|
||||
}
|
||||
|
||||
boolean trueOrTrueMethod(){
|
||||
return true || true;
|
||||
}
|
||||
|
||||
boolean falseOrFalseMethod(){
|
||||
return false || false;
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/Char.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Char.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Comments.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Comments.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/DoWhile.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/DoWhile.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/EmptyClass.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/EmptyClass.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Field.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Field.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/For.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/For.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/If.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/If.class
Normal file
Binary file not shown.
8
src/test/resources/input/singleFeatureTests/If.java
Normal file
8
src/test/resources/input/singleFeatureTests/If.java
Normal file
@ -0,0 +1,8 @@
|
||||
public class If {
|
||||
public If() {
|
||||
int intValue = 5;
|
||||
if(intValue == 5) {
|
||||
intValue--;
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/IfElse.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/IfElse.class
Normal file
Binary file not shown.
10
src/test/resources/input/singleFeatureTests/IfElse.java
Normal file
10
src/test/resources/input/singleFeatureTests/IfElse.java
Normal file
@ -0,0 +1,10 @@
|
||||
public class IfElse {
|
||||
public IfElse() {
|
||||
int intValue = 5;
|
||||
if(intValue == 5) {
|
||||
intValue--;
|
||||
} else {
|
||||
intValue++;
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/IfElseIfElse.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/IfElseIfElse.class
Normal file
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
public class IfElseIfElse {
|
||||
public IfElseIfElse() {
|
||||
int intValue = 5;
|
||||
if(intValue == 5) {
|
||||
intValue--;
|
||||
} else if(intValue ==4) {
|
||||
intValue++;
|
||||
} else {
|
||||
intValue++;
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/Increment.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Increment.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/MainMethod.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/MainMethod.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Null.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Null.class
Normal file
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
class Null{
|
||||
|
||||
int a;
|
||||
Null a;
|
||||
|
||||
public Null(){
|
||||
this.a = null;
|
||||
this.a = null;
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/SelfReference.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/SelfReference.class
Normal file
Binary file not shown.
@ -10,7 +10,7 @@ class SelfReference{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int testMehtod3(){
|
||||
int testMethod3(){
|
||||
SelfReference selfReference1 = new SelfReference();
|
||||
return selfReference1.selfReference.testMethod1();
|
||||
}
|
||||
|
BIN
src/test/resources/input/singleFeatureTests/TestClass2.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/TestClass2.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/ThisDot.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/ThisDot.class
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1,34 @@
|
||||
class VariableCalculation{
|
||||
|
||||
int aPlusB(int a, int b){
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int aMinusB(int a, int b){
|
||||
return a - b;
|
||||
}
|
||||
|
||||
int aTimeB(int a, int b){
|
||||
return a * b;
|
||||
}
|
||||
|
||||
int aDivB(int a, int b){
|
||||
return a / b;
|
||||
}
|
||||
|
||||
int complexCalc (int a, int b){
|
||||
return a * b / 1 * 3;
|
||||
}
|
||||
|
||||
boolean aSmallerB (int a, int b){
|
||||
return a < b;
|
||||
}
|
||||
|
||||
boolean aGreaterB (int a, int b){
|
||||
return a > b;
|
||||
}
|
||||
|
||||
boolean aEqualsB (int a, int b){
|
||||
return a == b;
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1,30 @@
|
||||
class VariableCompare{
|
||||
|
||||
boolean trueMethod() {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean falseMethod(){
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean trueAndTrueMethod(){
|
||||
return true && true;
|
||||
}
|
||||
|
||||
boolean trueAndFalseMethod(){
|
||||
return true && false;
|
||||
}
|
||||
|
||||
boolean falseAndFalseMethod(){
|
||||
return false && false;
|
||||
}
|
||||
|
||||
boolean trueOrTrueMethod(){
|
||||
return true || true;
|
||||
}
|
||||
|
||||
boolean falseOrFalseMethod(){
|
||||
return false || false;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
class VariableCompareTest{
|
||||
|
||||
boolean trueMethod(){
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean falseMethod(){
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean trueAndTrue(){
|
||||
return trueMethod() && trueMethod();
|
||||
}
|
||||
|
||||
boolean trueAndFalse(){
|
||||
return trueMethod() && falseMethod();
|
||||
}
|
||||
|
||||
boolean falseAndFalse(){
|
||||
return falseMethod() && falseMethod();
|
||||
}
|
||||
|
||||
boolean trueOrFalse(){
|
||||
return trueMethod() || falseMethod();
|
||||
}
|
||||
|
||||
boolean falseOrFalse(){
|
||||
return falseMethod() || falseMethod();
|
||||
}
|
||||
}
|
BIN
src/test/resources/input/singleFeatureTests/VoidMethod.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/VoidMethod.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/While.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/While.class
Normal file
Binary file not shown.
@ -1,13 +0,0 @@
|
||||
// @expected: TypeMismatchException
|
||||
public class Test{
|
||||
|
||||
public void test(boolean b){
|
||||
if(b == 2){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// @expected: WrongOverloading
|
||||
public class Test{
|
||||
|
||||
public void test(int x){
|
||||
|
||||
if(this.get()){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public boolean b;
|
||||
|
||||
public boolean get(int c){
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -3,10 +3,10 @@ public class CallMethodFromObjekt {
|
||||
public int firstInt;
|
||||
public Car ca;
|
||||
|
||||
public int speed(){
|
||||
public int speed() {
|
||||
return ca.getSpeed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Car{
|
||||
|
||||
@ -16,5 +16,4 @@ public class Car{
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
public class Test {
|
||||
|
||||
public House h;
|
||||
|
||||
public int test(House h){
|
||||
return h.getW().getSize();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class House {
|
||||
|
||||
private Window w;
|
||||
|
||||
public Window getW(){
|
||||
return w;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Window{
|
||||
|
||||
private int size;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
public class CorrectMemberAccess{
|
||||
public class CorrectMemberAccess {
|
||||
|
||||
public Car c;
|
||||
|
||||
public int test(){
|
||||
public int test() {
|
||||
return c.getSpeed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class Car{
|
||||
|
||||
@ -15,5 +16,4 @@ private class Car{
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +1,13 @@
|
||||
public class CorrectTest {
|
||||
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++) {
|
||||
}
|
||||
|
||||
public class Klasse1 {
|
||||
public int test;
|
||||
|
||||
public int test1() {
|
||||
test = 5;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void test2() {
|
||||
int testInt;
|
||||
testInt = this.test1();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user