net.sourceforge.nrl.parser.type
Class ConstraintTypeChecker

java.lang.Object
  extended by net.sourceforge.nrl.parser.type.ConstraintTypeChecker
All Implemented Interfaces:
INRLConstraintDetailVisitor, ITypeChecker
Direct Known Subclasses:
ActionTypeChecker

public class ConstraintTypeChecker
extends Object
implements INRLConstraintDetailVisitor, ITypeChecker

Default type checker implementation. This uses the built-in visitor pattern to type-check every node in the AST.

The type checker uses a depth-first strategy. Types are assigned to children and then to their parents. In addition, the following strategy is used to deal with elements or operators where the NRL type is unknown:

See Also:
ITypeChecker

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sourceforge.nrl.parser.ast.constraints.INRLConstraintDetailVisitor
INRLConstraintDetailVisitor.Stub
 
Constructor Summary
ConstraintTypeChecker()
           
 
Method Summary
 void addTypeMapping(ITypeMapping mapping)
          Add a type mapping for the checker to map model types to abstract internal types.
 List<NRLError> check(IOperators operators)
          Type check an operator collection.
 List<NRLError> check(IRuleFile ruleFile)
          Type check a rule file and assign a type to all constraints.
 List<NRLError> getErrors()
           
 boolean isImplicitIterationAllowed()
          Is implicit iteration currently allowed?
 boolean isNumber(NRLDataType type)
          Helper method to idenitfy if a type is a number (integer or decimal)
 void setImplicitIterationAllowed(boolean isImplicitIterationAllowed)
          Set the implicit iteration status
 void visitArithmeticExpressionAfter(IArithmeticExpression expr)
           
 boolean visitArithmeticExpressionBefore(IArithmeticExpression expr)
           
 void visitBinaryOperatorStatementAfter(IBinaryOperatorStatement statement)
           
 boolean visitBinaryOperatorStatementBefore(IBinaryOperatorStatement statement)
           
 void visitBinaryPredicateAfter(IBinaryPredicate predicate)
           
 boolean visitBinaryPredicateBefore(IBinaryPredicate predicate)
           
 void visitBooleanLiteral(IBooleanLiteral bool)
           
 void visitCardinalityConstraint(ICardinalityConstraint constraint)
           
 void visitCastExpressionAfter(ICastExpression expr)
           
 boolean visitCastExpressionBefore(ICastExpression expr)
           
 void visitCollectionIndexAfter(ICollectionIndex index)
           
 boolean visitCollectionIndexBefore(ICollectionIndex index)
           
 void visitCompoundReportAfter(ICompoundReport report)
           
 boolean visitCompoundReportBefore(ICompoundReport report)
           
 void visitConcatenatedReportAfter(IConcatenatedReport report)
           
 boolean visitConcatenatedReportBefore(IConcatenatedReport report)
           
 void visitConditionalReportAfter(IConditionalReport report)
           
 boolean visitConditionalReportBefore(IConditionalReport report)
           
 void visitConstraintRuleDeclarationAfter(IConstraintRuleDeclaration decl)
           
 boolean visitConstraintRuleDeclarationBefore(IConstraintRuleDeclaration decl)
           
 void visitDecimalNumber(IDecimalNumber number)
           
 void visitExistsStatementAfter(IExistsStatement exists)
           
 boolean visitExistsStatementBefore(IExistsStatement exists)
           
 void visitForallStatementAfter(IForallStatement forall)
           
 boolean visitForallStatementBefore(IForallStatement forall)
           
 void visitFunctionalExpressionAfter(IFunctionalExpression expr)
           
 boolean visitFunctionalExpressionBefore(IFunctionalExpression expr)
           
 void visitGlobalExistsStatementAfter(IGlobalExistsStatement exists)
           
 boolean visitGlobalExistsStatementBefore(IGlobalExistsStatement exists)
           
 void visitIfThenStatementAfter(IIfThenStatement ifThen)
           
 boolean visitIfThenStatementBefore(IIfThenStatement ifThen)
           
 void visitIntegerNumber(IIntegerNumber number)
           
 void visitIsInPredicateAfter(IIsInPredicate isIn)
           
 boolean visitIsInPredicateBefore(IIsInPredicate isIn)
           
 void visitIsNotInPredicateAfter(IIsNotInPredicate isNotIn)
           
 boolean visitIsNotInPredicateBefore(IIsNotInPredicate isNotIn)
           
 void visitIsSubtypePredicateAfter(IIsSubtypePredicate subType)
           
 boolean visitIsSubtypePredicateBefore(IIsSubtypePredicate subType)
           
 void visitLiteralString(ILiteralString literal)
           
 void visitModelReferenceAfter(IModelReference ref)
           
 boolean visitModelReferenceBefore(IModelReference ref)
           
 void visitMultipleExistsStatementAfter(IMultipleExistsStatement statement)
           
 boolean visitMultipleExistsStatementBefore(IMultipleExistsStatement statement)
           
 void visitMultipleNotExistsStatementAfter(IMultipleNotExistsStatement statement)
           
 boolean visitMultipleNotExistsStatementBefore(IMultipleNotExistsStatement statement)
           
 void visitNotExistsStatementAfter(INotExistsStatement exists)
           
 boolean visitNotExistsStatementBefore(INotExistsStatement exists)
           
 void visitOperatorInvocationAfter(IOperatorInvocation op)
           
 boolean visitOperatorInvocationBefore(IOperatorInvocation op)
           
 void visitRuleFileAfter(IRuleFile file)
           
 boolean visitRuleFileBefore(IRuleFile file)
           
 void visitRuleSetDeclarationAfter(IRuleSetDeclaration decl)
           
 boolean visitRuleSetDeclarationBefore(IRuleSetDeclaration decl)
           
 void visitSelectionExpressionAfter(ISelectionExpression expr)
           
 boolean visitSelectionExpressionBefore(ISelectionExpression expr)
           
 void visitValidationFragmentApplicationAfter(IValidationFragmentApplication app)
           
 boolean visitValidationFragmentApplicationBefore(IValidationFragmentApplication app)
           
 void visitValidationFragmentDeclarationAfter(IValidationFragmentDeclaration decl)
           
 boolean visitValidationFragmentDeclarationBefore(IValidationFragmentDeclaration decl)
           
 void visitVariableDeclarationAfter(IVariableDeclaration decl)
           
 boolean visitVariableDeclarationBefore(IVariableDeclaration decl)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintTypeChecker

public ConstraintTypeChecker()
Method Detail

addTypeMapping

public void addTypeMapping(ITypeMapping mapping)
Description copied from interface: ITypeChecker
Add a type mapping for the checker to map model types to abstract internal types.

Specified by:
addTypeMapping in interface ITypeChecker
Parameters:
mapping - the mapping

getErrors

public List<NRLError> getErrors()

check

public List<NRLError> check(IOperators operators)
Description copied from interface: ITypeChecker
Type check an operator collection. This assigns types to all parameters.

Specified by:
check in interface ITypeChecker
Parameters:
operators - the operators to check
Returns:
a collection of errors

check

public List<NRLError> check(IRuleFile ruleFile)
Description copied from interface: ITypeChecker
Type check a rule file and assign a type to all constraints.

Specified by:
check in interface ITypeChecker
Parameters:
ruleFile - the rule file to check
Returns:
a collection of error objects, can be empty

isNumber

public boolean isNumber(NRLDataType type)
Helper method to idenitfy if a type is a number (integer or decimal)


isImplicitIterationAllowed

public boolean isImplicitIterationAllowed()
Is implicit iteration currently allowed?

Returns:
flag

setImplicitIterationAllowed

public void setImplicitIterationAllowed(boolean isImplicitIterationAllowed)
Set the implicit iteration status

Parameters:
isImplicitIterationAllowed - flag

visitArithmeticExpressionAfter

public void visitArithmeticExpressionAfter(IArithmeticExpression expr)
Specified by:
visitArithmeticExpressionAfter in interface INRLConstraintDetailVisitor

visitBinaryOperatorStatementAfter

public void visitBinaryOperatorStatementAfter(IBinaryOperatorStatement statement)
Specified by:
visitBinaryOperatorStatementAfter in interface INRLConstraintDetailVisitor

visitBinaryPredicateAfter

public void visitBinaryPredicateAfter(IBinaryPredicate predicate)
Specified by:
visitBinaryPredicateAfter in interface INRLConstraintDetailVisitor

visitBooleanLiteral

public void visitBooleanLiteral(IBooleanLiteral bool)
Specified by:
visitBooleanLiteral in interface INRLConstraintDetailVisitor

visitCardinalityConstraint

public void visitCardinalityConstraint(ICardinalityConstraint constraint)
Specified by:
visitCardinalityConstraint in interface INRLConstraintDetailVisitor

visitCollectionIndexAfter

public void visitCollectionIndexAfter(ICollectionIndex index)
Specified by:
visitCollectionIndexAfter in interface INRLConstraintDetailVisitor

visitCompoundReportAfter

public void visitCompoundReportAfter(ICompoundReport report)
Specified by:
visitCompoundReportAfter in interface INRLConstraintDetailVisitor

visitConcatenatedReportAfter

public void visitConcatenatedReportAfter(IConcatenatedReport report)
Specified by:
visitConcatenatedReportAfter in interface INRLConstraintDetailVisitor

visitConditionalReportAfter

public void visitConditionalReportAfter(IConditionalReport report)
Specified by:
visitConditionalReportAfter in interface INRLConstraintDetailVisitor

visitCastExpressionAfter

public void visitCastExpressionAfter(ICastExpression expr)
Specified by:
visitCastExpressionAfter in interface INRLConstraintDetailVisitor

visitExistsStatementAfter

public void visitExistsStatementAfter(IExistsStatement exists)
Specified by:
visitExistsStatementAfter in interface INRLConstraintDetailVisitor

visitForallStatementAfter

public void visitForallStatementAfter(IForallStatement forall)
Specified by:
visitForallStatementAfter in interface INRLConstraintDetailVisitor

visitFunctionalExpressionBefore

public boolean visitFunctionalExpressionBefore(IFunctionalExpression expr)
Specified by:
visitFunctionalExpressionBefore in interface INRLConstraintDetailVisitor

visitFunctionalExpressionAfter

public void visitFunctionalExpressionAfter(IFunctionalExpression expr)
Specified by:
visitFunctionalExpressionAfter in interface INRLConstraintDetailVisitor

visitGlobalExistsStatementAfter

public void visitGlobalExistsStatementAfter(IGlobalExistsStatement exists)
Specified by:
visitGlobalExistsStatementAfter in interface INRLConstraintDetailVisitor

visitIfThenStatementAfter

public void visitIfThenStatementAfter(IIfThenStatement ifThen)
Specified by:
visitIfThenStatementAfter in interface INRLConstraintDetailVisitor

visitIsInPredicateAfter

public void visitIsInPredicateAfter(IIsInPredicate isIn)
Specified by:
visitIsInPredicateAfter in interface INRLConstraintDetailVisitor

visitIsNotInPredicateAfter

public void visitIsNotInPredicateAfter(IIsNotInPredicate isNotIn)
Specified by:
visitIsNotInPredicateAfter in interface INRLConstraintDetailVisitor

visitIsSubtypePredicateAfter

public void visitIsSubtypePredicateAfter(IIsSubtypePredicate subType)
Specified by:
visitIsSubtypePredicateAfter in interface INRLConstraintDetailVisitor

visitLiteralString

public void visitLiteralString(ILiteralString literal)
Specified by:
visitLiteralString in interface INRLConstraintDetailVisitor

visitModelReferenceAfter

public void visitModelReferenceAfter(IModelReference ref)
Specified by:
visitModelReferenceAfter in interface INRLConstraintDetailVisitor

visitMultipleExistsStatementAfter

public void visitMultipleExistsStatementAfter(IMultipleExistsStatement statement)
Specified by:
visitMultipleExistsStatementAfter in interface INRLConstraintDetailVisitor

visitMultipleNotExistsStatementAfter

public void visitMultipleNotExistsStatementAfter(IMultipleNotExistsStatement statement)
Specified by:
visitMultipleNotExistsStatementAfter in interface INRLConstraintDetailVisitor

visitNotExistsStatementAfter

public void visitNotExistsStatementAfter(INotExistsStatement exists)
Specified by:
visitNotExistsStatementAfter in interface INRLConstraintDetailVisitor

visitDecimalNumber

public void visitDecimalNumber(IDecimalNumber number)
Specified by:
visitDecimalNumber in interface INRLConstraintDetailVisitor

visitIntegerNumber

public void visitIntegerNumber(IIntegerNumber number)
Specified by:
visitIntegerNumber in interface INRLConstraintDetailVisitor

visitOperatorInvocationAfter

public void visitOperatorInvocationAfter(IOperatorInvocation op)
Specified by:
visitOperatorInvocationAfter in interface INRLConstraintDetailVisitor

visitSelectionExpressionAfter

public void visitSelectionExpressionAfter(ISelectionExpression expr)
Specified by:
visitSelectionExpressionAfter in interface INRLConstraintDetailVisitor

visitValidationFragmentApplicationAfter

public void visitValidationFragmentApplicationAfter(IValidationFragmentApplication app)
Specified by:
visitValidationFragmentApplicationAfter in interface INRLConstraintDetailVisitor

visitValidationFragmentDeclarationAfter

public void visitValidationFragmentDeclarationAfter(IValidationFragmentDeclaration decl)
Specified by:
visitValidationFragmentDeclarationAfter in interface INRLConstraintDetailVisitor

visitConstraintRuleDeclarationAfter

public void visitConstraintRuleDeclarationAfter(IConstraintRuleDeclaration decl)
Specified by:
visitConstraintRuleDeclarationAfter in interface INRLConstraintDetailVisitor

visitRuleFileAfter

public void visitRuleFileAfter(IRuleFile file)
Specified by:
visitRuleFileAfter in interface INRLConstraintDetailVisitor

visitRuleSetDeclarationAfter

public void visitRuleSetDeclarationAfter(IRuleSetDeclaration decl)
Specified by:
visitRuleSetDeclarationAfter in interface INRLConstraintDetailVisitor

visitVariableDeclarationBefore

public boolean visitVariableDeclarationBefore(IVariableDeclaration decl)
Specified by:
visitVariableDeclarationBefore in interface INRLConstraintDetailVisitor

visitVariableDeclarationAfter

public void visitVariableDeclarationAfter(IVariableDeclaration decl)
Specified by:
visitVariableDeclarationAfter in interface INRLConstraintDetailVisitor

visitArithmeticExpressionBefore

public boolean visitArithmeticExpressionBefore(IArithmeticExpression expr)
Specified by:
visitArithmeticExpressionBefore in interface INRLConstraintDetailVisitor

visitBinaryOperatorStatementBefore

public boolean visitBinaryOperatorStatementBefore(IBinaryOperatorStatement statement)
Specified by:
visitBinaryOperatorStatementBefore in interface INRLConstraintDetailVisitor

visitBinaryPredicateBefore

public boolean visitBinaryPredicateBefore(IBinaryPredicate predicate)
Specified by:
visitBinaryPredicateBefore in interface INRLConstraintDetailVisitor

visitCastExpressionBefore

public boolean visitCastExpressionBefore(ICastExpression expr)
Specified by:
visitCastExpressionBefore in interface INRLConstraintDetailVisitor

visitCollectionIndexBefore

public boolean visitCollectionIndexBefore(ICollectionIndex index)
Specified by:
visitCollectionIndexBefore in interface INRLConstraintDetailVisitor

visitCompoundReportBefore

public boolean visitCompoundReportBefore(ICompoundReport report)
Specified by:
visitCompoundReportBefore in interface INRLConstraintDetailVisitor

visitConcatenatedReportBefore

public boolean visitConcatenatedReportBefore(IConcatenatedReport report)
Specified by:
visitConcatenatedReportBefore in interface INRLConstraintDetailVisitor

visitConditionalReportBefore

public boolean visitConditionalReportBefore(IConditionalReport report)
Specified by:
visitConditionalReportBefore in interface INRLConstraintDetailVisitor

visitExistsStatementBefore

public boolean visitExistsStatementBefore(IExistsStatement exists)
Specified by:
visitExistsStatementBefore in interface INRLConstraintDetailVisitor

visitForallStatementBefore

public boolean visitForallStatementBefore(IForallStatement forall)
Specified by:
visitForallStatementBefore in interface INRLConstraintDetailVisitor

visitGlobalExistsStatementBefore

public boolean visitGlobalExistsStatementBefore(IGlobalExistsStatement exists)
Specified by:
visitGlobalExistsStatementBefore in interface INRLConstraintDetailVisitor

visitIfThenStatementBefore

public boolean visitIfThenStatementBefore(IIfThenStatement ifThen)
Specified by:
visitIfThenStatementBefore in interface INRLConstraintDetailVisitor

visitIsInPredicateBefore

public boolean visitIsInPredicateBefore(IIsInPredicate isIn)
Specified by:
visitIsInPredicateBefore in interface INRLConstraintDetailVisitor

visitIsNotInPredicateBefore

public boolean visitIsNotInPredicateBefore(IIsNotInPredicate isNotIn)
Specified by:
visitIsNotInPredicateBefore in interface INRLConstraintDetailVisitor

visitIsSubtypePredicateBefore

public boolean visitIsSubtypePredicateBefore(IIsSubtypePredicate subType)
Specified by:
visitIsSubtypePredicateBefore in interface INRLConstraintDetailVisitor

visitModelReferenceBefore

public boolean visitModelReferenceBefore(IModelReference ref)
Specified by:
visitModelReferenceBefore in interface INRLConstraintDetailVisitor

visitMultipleExistsStatementBefore

public boolean visitMultipleExistsStatementBefore(IMultipleExistsStatement statement)
Specified by:
visitMultipleExistsStatementBefore in interface INRLConstraintDetailVisitor

visitMultipleNotExistsStatementBefore

public boolean visitMultipleNotExistsStatementBefore(IMultipleNotExistsStatement statement)
Specified by:
visitMultipleNotExistsStatementBefore in interface INRLConstraintDetailVisitor

visitNotExistsStatementBefore

public boolean visitNotExistsStatementBefore(INotExistsStatement exists)
Specified by:
visitNotExistsStatementBefore in interface INRLConstraintDetailVisitor

visitOperatorInvocationBefore

public boolean visitOperatorInvocationBefore(IOperatorInvocation op)
Specified by:
visitOperatorInvocationBefore in interface INRLConstraintDetailVisitor

visitValidationFragmentApplicationBefore

public boolean visitValidationFragmentApplicationBefore(IValidationFragmentApplication app)
Specified by:
visitValidationFragmentApplicationBefore in interface INRLConstraintDetailVisitor

visitValidationFragmentDeclarationBefore

public boolean visitValidationFragmentDeclarationBefore(IValidationFragmentDeclaration decl)
Specified by:
visitValidationFragmentDeclarationBefore in interface INRLConstraintDetailVisitor

visitConstraintRuleDeclarationBefore

public boolean visitConstraintRuleDeclarationBefore(IConstraintRuleDeclaration decl)
Specified by:
visitConstraintRuleDeclarationBefore in interface INRLConstraintDetailVisitor

visitRuleFileBefore

public boolean visitRuleFileBefore(IRuleFile file)
Specified by:
visitRuleFileBefore in interface INRLConstraintDetailVisitor

visitRuleSetDeclarationBefore

public boolean visitRuleSetDeclarationBefore(IRuleSetDeclaration decl)
Specified by:
visitRuleSetDeclarationBefore in interface INRLConstraintDetailVisitor

visitSelectionExpressionBefore

public boolean visitSelectionExpressionBefore(ISelectionExpression expr)
Specified by:
visitSelectionExpressionBefore in interface INRLConstraintDetailVisitor


Copyright © 2006-2010 Christian Nentwich and others