@Test public void checkTypeChecker() { final int EXPECTED_RESULT = 2; QLParser parser = ASTBuilder.getQlParser("form testform { \"test1\" test1:boolean; \"test2\" test2:integer = 12 + test1"); Form form = ASTBuilder.getForm(parser); TypeTable typeTable = new TypeTable(); typeTable.addEntry("test1", new BooleanType()); typeTable.addEntry("test2", new IntegerType()); TypeChecker checker = new TypeChecker(); ErrorLogger logger = checker.checkExpressionTypes(form, typeTable); assertEquals(EXPECTED_RESULT, logger.getErrorNumber()); }
public ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable) { this.typeTable = typeTable; for (Statement statement : form.getStatements()) { statement.accept(this, null); } return logger; }
TypeChecker implements StatementVisitor<Type, String>, ExpressionVisitor<Type, String>, TypeVisitor<Type, String> { public ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable) { this.typeTable = typeTable; for (Statement statement : form.getStatements()) { statement.accept(this, null); } return logger; } }
TypeChecker implements StatementVisitor<Type, String>, ExpressionVisitor<Type, String>, TypeVisitor<Type, String> { public ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable) { this.typeTable = typeTable; for (Statement statement : form.getStatements()) { statement.accept(this, null); } return logger; } TypeChecker(); }
TypeChecker implements StatementVisitor<Type, String>, ExpressionVisitor<Type, String>, TypeVisitor<Type, String> { public ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable) { this.typeTable = typeTable; for (Statement statement : form.getStatements()) { statement.accept(this, null); } return logger; } TypeChecker(); ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable); @Override Type visit(Question question, String context); @Override Type visit(IfStatement ifStatement, String context); @Override Type visit(IfElseStatement ifElseStatement, String context); @Override Type visit(CalculatedQuestion calculatedQuestion, String context); @Override Type visit(StringLiteral stringLiteral, String context); @Override Type visit(IntegerLiteral integerLiteral, String context); @Override Type visit(BooleanLiteral booleanLiteral, String context); @Override Type visit(Parameter parameter, String context); @Override Type visit(ParameterGroup parameterGroup, String context); @Override Type visit(Addition addition, String context); @Override Type visit(Subtraction subtraction, String context); @Override Type visit(Multiplication multiplication, String context); @Override Type visit(Division division, String context); @Override Type visit(Equal equal, String context); @Override Type visit(NotEqual notEqual, String context); @Override Type visit(GreaterThan greaterThan, String context); @Override Type visit(GreaterThanEqualTo greaterThanEqualTo, String context); @Override Type visit(LessThan lessThan, String context); @Override Type visit(LessThanEqualTo lessThanEqualTo, String context); @Override Type visit(LogicalAnd logicalAnd, String context); @Override Type visit(LogicalOr logicalOr, String context); @Override Type visit(Negation negation, String context); @Override Type visit(BooleanType booleanType, String context); @Override Type visit(StringType stringType, String context); @Override Type visit(ErrorType errorType, String context); @Override Type visit(IntegerType integerType, String context); }
TypeChecker implements StatementVisitor<Type, String>, ExpressionVisitor<Type, String>, TypeVisitor<Type, String> { public ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable) { this.typeTable = typeTable; for (Statement statement : form.getStatements()) { statement.accept(this, null); } return logger; } TypeChecker(); ErrorLogger checkExpressionTypes(Form form, TypeTable typeTable); @Override Type visit(Question question, String context); @Override Type visit(IfStatement ifStatement, String context); @Override Type visit(IfElseStatement ifElseStatement, String context); @Override Type visit(CalculatedQuestion calculatedQuestion, String context); @Override Type visit(StringLiteral stringLiteral, String context); @Override Type visit(IntegerLiteral integerLiteral, String context); @Override Type visit(BooleanLiteral booleanLiteral, String context); @Override Type visit(Parameter parameter, String context); @Override Type visit(ParameterGroup parameterGroup, String context); @Override Type visit(Addition addition, String context); @Override Type visit(Subtraction subtraction, String context); @Override Type visit(Multiplication multiplication, String context); @Override Type visit(Division division, String context); @Override Type visit(Equal equal, String context); @Override Type visit(NotEqual notEqual, String context); @Override Type visit(GreaterThan greaterThan, String context); @Override Type visit(GreaterThanEqualTo greaterThanEqualTo, String context); @Override Type visit(LessThan lessThan, String context); @Override Type visit(LessThanEqualTo lessThanEqualTo, String context); @Override Type visit(LogicalAnd logicalAnd, String context); @Override Type visit(LogicalOr logicalOr, String context); @Override Type visit(Negation negation, String context); @Override Type visit(BooleanType booleanType, String context); @Override Type visit(StringType stringType, String context); @Override Type visit(ErrorType errorType, String context); @Override Type visit(IntegerType integerType, String context);  }