net.sourceforge.nrl.parser.ast.impl
Class ConstraintAstResolver

java.lang.Object
  extended by net.sourceforge.nrl.parser.ast.impl.ConstraintAstResolver
Direct Known Subclasses:
ActionAstResolver

public class ConstraintAstResolver
extends Object

A resolver class that performs basic processing of the AST and returns semantic errors if it fails.

The main method is resolve(RuleFileImpl).

Author:
Christian Nentwich

Field Summary
protected  Map<String,IValidationFragmentDeclaration> fragmentIds
           
protected  Map<String,IVariableDeclaration> globalVariableIds
           
protected  Set<String> ruleIds
           
protected  Set<String> ruleSetIds
           
 
Constructor Summary
ConstraintAstResolver()
           
 
Method Summary
protected  void collectFragmentIds(RuleFileImpl ruleFile, List<NRLError> errors)
          Collect all fragment ids
protected  void collectGlobalVariableIds(RuleFileImpl ruleFile, List<NRLError> errors)
          Collect global variables.
protected  void collectIdentifiers(RuleFileImpl ruleFile, List<NRLError> errors)
          Collect all identifiable parts.
protected  void collectRuleIds(RuleFileImpl ruleFile, List<NRLError> errors)
          Collect all rule ids
protected  void collectRuleSetIds(RuleFileImpl ruleFile, List<NRLError> errors)
          Collect all rule set ids
 List<NRLError> resolve(RuleFileImpl ruleFile)
          Resolve the rule file and return a list of SemanticError objects if errors occurred.
protected  void resolveIncompleteExistsStatements(RuleFileImpl ruleFile, List<NRLError> errors)
          This resolves inclompete exists statements.
protected  void resolveReferences(RuleFileImpl ruleFile, List<NRLError> errors)
          Resolve references within the AST.
protected  void resolveRuleSets(RuleFileImpl ruleFile, List<NRLError> errors)
          Resolve rule set references.
protected  void validateRuleParameters(IRuleFile ruleFile, List<NRLError> errors)
          Ensure that the names of rule parameters are ok.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ruleIds

protected Set<String> ruleIds

ruleSetIds

protected Set<String> ruleSetIds

fragmentIds

protected Map<String,IValidationFragmentDeclaration> fragmentIds

globalVariableIds

protected Map<String,IVariableDeclaration> globalVariableIds
Constructor Detail

ConstraintAstResolver

public ConstraintAstResolver()
Method Detail

resolve

public List<NRLError> resolve(RuleFileImpl ruleFile)
Resolve the rule file and return a list of SemanticError objects if errors occurred.

Parameters:
ruleFile - the rule file to resolve
Returns:
the list of errors

collectIdentifiers

protected void collectIdentifiers(RuleFileImpl ruleFile,
                                  List<NRLError> errors)
Collect all identifiable parts. The default implementation collects rule ids, property ids and rule set ids.

Parameters:
ruleFile - the rule file
errors - errors, if any are found during collection

collectFragmentIds

protected void collectFragmentIds(RuleFileImpl ruleFile,
                                  List<NRLError> errors)
Collect all fragment ids

Parameters:
ruleFile - the rule file
errors - errors, if any are found during collection

collectRuleIds

protected void collectRuleIds(RuleFileImpl ruleFile,
                              List<NRLError> errors)
Collect all rule ids

Parameters:
ruleFile - the rule file
errors - errors, if any are found during collection

collectRuleSetIds

protected void collectRuleSetIds(RuleFileImpl ruleFile,
                                 List<NRLError> errors)
Collect all rule set ids

Parameters:
ruleFile - the rule file
errors - errors to add to , if any

collectGlobalVariableIds

protected void collectGlobalVariableIds(RuleFileImpl ruleFile,
                                        List<NRLError> errors)
Collect global variables.

Parameters:
ruleFile - the rule file
errors - error list

resolveReferences

protected void resolveReferences(RuleFileImpl ruleFile,
                                 List<NRLError> errors)
Resolve references within the AST. This:

Parameters:
ruleFile - the rule file to process
errors - the error list to add to if errors occur

resolveIncompleteExistsStatements

protected void resolveIncompleteExistsStatements(RuleFileImpl ruleFile,
                                                 List<NRLError> errors)
This resolves inclompete exists statements. This is a rather tricky method. It replaces statements like "one trade has a = b and one has a = c" with a complete statement like "one trade has a = b and one trade has a = c", by determining which model reference came up in the tree before the incomplete exists statement.

Parameters:
ruleFile - the rule file
errors - the error list to add to

resolveRuleSets

protected void resolveRuleSets(RuleFileImpl ruleFile,
                               List<NRLError> errors)
Resolve rule set references. This ensures that

Parameters:
ruleFile - the rule file to process
errors - the error list to add to

validateRuleParameters

protected void validateRuleParameters(IRuleFile ruleFile,
                                      List<NRLError> errors)
Ensure that the names of rule parameters are ok.

Parameters:
ruleFile - the rule file
errors - the errors to add to


Copyright © 2006-2013. All Rights Reserved.