Class ExpressionConceptFunctionParseTreeEvaluator

  • All Implemented Interfaces:
    ParseTreeVisitor

    public class ExpressionConceptFunctionParseTreeEvaluator
    extends ParseTreeEvaluator
    Visit a parse tree for a string expression that defines a concept function and evaluate to the string name of the concept that should be the output.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Charles Shelton
    See Also:
    ASTPtRootNode
    Pt.AcceptedRating:
    Red (cshelton)
    Pt.ProposedRating:
    Green (cshelton)
    • Field Detail

      • _scopeOntologies

        protected java.util.List<Ontology> _scopeOntologies
        The list of ontologies that specify the domain for each input argument to the concept function defined by the parsed expression.
    • Constructor Detail

      • ExpressionConceptFunctionParseTreeEvaluator

        public ExpressionConceptFunctionParseTreeEvaluator​(java.util.List<java.lang.String> argumentNames,
                                                           java.util.List<Concept> inputConceptValues,
                                                           OntologySolverModel solverModel,
                                                           java.util.List<Ontology> argumentDomainOntologies,
                                                           Ontology outputRangeOntology)
                                                    throws IllegalActionException
        Construct an ExpressionConceptFunctionParseTreeEvaluator for evaluating expressions that represent concept functions.
        Parameters:
        argumentNames - The array of argument names used in the concept function expression.
        inputConceptValues - The array of concept values to which the arguments are set.
        solverModel - The ontology solver model that contains the scope of other concept functions that can be called in the expression.
        argumentDomainOntologies - The array of ontologies that represent the concept domain for each input concept argument.
        outputRangeOntology - The ontology that represents the concept range for the concept function.
        Throws:
        IllegalActionException - If there is a problem instantiating the parse tree evaluator object.
      • ExpressionConceptFunctionParseTreeEvaluator

        public ExpressionConceptFunctionParseTreeEvaluator​(java.util.Map<java.lang.String,​Concept> arguments,
                                                           OntologySolverModel solverModel,
                                                           java.util.List<Ontology> domainOntologies,
                                                           Ontology outputRangeOntology)
                                                    throws IllegalActionException
        Construct an ExpressionConceptFunctionParseTreeEvaluator for evaluating expressions that represent concept functions.
        Parameters:
        arguments - A map of argument names to concept values.
        solverModel - The ontology solver model that contains the scope of other concept functions that can be called in the expression.
        domainOntologies - Ontologies over which the parser is defined.
        outputRangeOntology - The ontology that represents the concept range for the concept function.
        Throws:
        IllegalActionException - If there is a problem instantiating the parse tree evaluator object.
    • Method Detail

      • evaluateParseTree

        public ConceptToken evaluateParseTree​(ASTPtRootNode node,
                                              ParserScope scope)
                                       throws IllegalActionException
        Evaluate the parse tree for the expression concept function with the specified root node using the specified scope to resolve the values of variables.
        Overrides:
        evaluateParseTree in class ParseTreeEvaluator
        Parameters:
        node - The root of the parse tree.
        scope - The scope for evaluation.
        Returns:
        The result of evaluation which must be a ConceptToken.
        Throws:
        IllegalActionException - If an error occurs during evaluation or if the result is not a ConceptToken or an ObjectToken containing a Concept.
      • _getNamedConcept

        protected Concept _getNamedConcept​(java.lang.String conceptString)
                                    throws IllegalActionException
        Return the concept with the specified string representation. If it cannot be found in any of the argument domain ontologies, throw an exception.
        Parameters:
        conceptString - The specified string the concept should have.
        Returns:
        The concept with the specified string if it is found.
        Throws:
        IllegalActionException - If the concept cannot be found.
      • _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.