Class ParseTreeAnnotationEvaluator

  • All Implemented Interfaces:
    ParseTreeVisitor
    Direct Known Subclasses:
    ParseTreeConstraintAnnotationEvaluator

    public class ParseTreeAnnotationEvaluator
    extends AbstractParseTreeVisitor
    This class visits parse trees and infers a property for each node in the parse tree. This property is stored in the parse tree.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Man-Kit Leung
    See Also:
    ASTPtRootNode
    Pt.AcceptedRating:
    Red (mankit)
    Pt.ProposedRating:
    Red (mankit)
    • Field Detail

      • _adapter

        protected OntologyAdapter _adapter
        The property adapter that contains the top level model component containing actors that could be referenced by the node label.
      • _evaluatedObject

        protected java.lang.Object _evaluatedObject
        The model component that the parse tree node refers to.
    • Constructor Detail

      • ParseTreeAnnotationEvaluator

        public ParseTreeAnnotationEvaluator()
    • Method Detail

      • evaluate

        public void evaluate​(ASTPtRootNode node,
                             OntologyAdapter adapter)
                      throws IllegalActionException
        Infer the property of the parse tree with the specified root node using the specified scope to resolve the values of variables.
        Parameters:
        node - The root of the parse tree.
        adapter - The given property adapter.
        Throws:
        IllegalActionException - If an error occurs during evaluation.
      • visitLeafNode

        public void visitLeafNode​(ASTPtLeafNode node)
                           throws IllegalActionException
        visitLeafNode method is called when parsing an Annotation for a manual constraint. Uncommented to get ontology solver to work. 12/16/09 Charles Shelton This visitLeafNode method assumes the node will refer to a component in the model and _evaluatedObject will be set to that component. If it is not, then an exception is thrown. In the derived class ParseTreeConstraintAnnotationEvaluator for constraint annotations, the node could also refer to a Concept in the Ontology. The derived class will override this method and catch its exception, then check to see if the node refers to a Concept rather than a model Component.
        Specified by:
        visitLeafNode in interface ParseTreeVisitor
        Overrides:
        visitLeafNode in class AbstractParseTreeVisitor
        Parameters:
        node - The leaf node to be visited
        Throws:
        IllegalActionException - If the node label cannot be resolved to a component in the model
      • _getNodeLabel

        protected java.lang.String _getNodeLabel​(ASTPtLeafNode node)
        Return the label for the leaf node.
        Parameters:
        node - The given leaf node
        Returns:
        The string label for the node; If the node is constant this is the token contained in the node as a string, if not then this is the name of the node.
      • _unsupportedVisitException

        protected IllegalActionException _unsupportedVisitException​(java.lang.String name)
        Return an exception that describes an unsupported node type.
        Overrides:
        _unsupportedVisitException in class AbstractParseTreeVisitor
        Parameters:
        name - The name of the node type.
        Returns:
        An exception that describes an unsupported node type.