Package ptolemy.data.ontologies
Class ParseTreeAnnotationEvaluator
- java.lang.Object
-
- ptolemy.data.expr.AbstractParseTreeVisitor
-
- ptolemy.data.ontologies.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 Summary
Fields Modifier and Type Field Description protected OntologyAdapter
_adapter
The property adapter that contains the top level model component containing actors that could be referenced by the node label.protected java.lang.Object
_evaluatedObject
The model component that the parse tree node refers to.
-
Constructor Summary
Constructors Constructor Description ParseTreeAnnotationEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_getNodeLabel(ASTPtLeafNode node)
Return the label for the leaf node.protected IllegalActionException
_unsupportedVisitException(java.lang.String name)
Return an exception that describes an unsupported node type.void
evaluate(ASTPtRootNode node, OntologyAdapter adapter)
Infer the property of the parse tree with the specified root node using the specified scope to resolve the values of variables.void
visitAssignmentNode(ASTPtAssignmentNode node)
Visit the assignment node when parsing a user-defined ontology annotation.void
visitLeafNode(ASTPtLeafNode node)
visitLeafNode method is called when parsing an Annotation for a manual constraint.void
visitMethodCallNode(ASTPtMethodCallNode node)
Visit the method node when parsing a user-defined ontology annotation.-
Methods inherited from class ptolemy.data.expr.AbstractParseTreeVisitor
_visitAllChildren, _visitChild, visitArrayConstructNode, visitBitwiseNode, visitFunctionalIfNode, visitFunctionApplicationNode, visitFunctionDefinitionNode, visitLogicalNode, visitMatrixConstructNode, visitPowerNode, visitProductNode, visitRecordConstructNode, visitRelationalNode, visitShiftNode, visitSumNode, visitUnaryNode, visitUnionConstructNode
-
-
-
-
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.
-
-
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.
-
visitAssignmentNode
public void visitAssignmentNode(ASTPtAssignmentNode node) throws IllegalActionException
Visit the assignment node when parsing a user-defined ontology annotation. This is for a manual annotation that assigns a Concept to a specified model component.- Specified by:
visitAssignmentNode
in interfaceParseTreeVisitor
- Overrides:
visitAssignmentNode
in classAbstractParseTreeVisitor
- Parameters:
node
- The assignment node to be visited.- Throws:
IllegalActionException
- If the assignment is not possible.
-
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 interfaceParseTreeVisitor
- Overrides:
visitLeafNode
in classAbstractParseTreeVisitor
- Parameters:
node
- The leaf node to be visited- Throws:
IllegalActionException
- If the node label cannot be resolved to a component in the model
-
visitMethodCallNode
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException
Visit the method node when parsing a user-defined ontology annotation.- Specified by:
visitMethodCallNode
in interfaceParseTreeVisitor
- Overrides:
visitMethodCallNode
in classAbstractParseTreeVisitor
- Parameters:
node
- The method call node to be visited- Throws:
IllegalActionException
- If the method label cannot be resolved.
-
_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 classAbstractParseTreeVisitor
- Parameters:
name
- The name of the node type.- Returns:
- An exception that describes an unsupported node type.
-
-