Class GTParameter.Evaluator

  • All Implemented Interfaces:
    ParseTreeVisitor
    Enclosing class:
    GTParameter

    public static class GTParameter.Evaluator
    extends ParseTreeEvaluator
    The evaluator used in a transformation rule. It differs from other evaluators in that it uses a pattern and a match result to resolve names in both the pattern and the host model that the pattern matches in the match result. If a name is found in the host model, its value in the host model is returned, regardless of whether the same name exists in the pattern or not (even if this evaluator is used to evaluate a parameter specified in the pattern).
    Since:
    Ptolemy II 7.1
    Version:
    $Id$
    Author:
    Thomas Huining Feng
    Pt.AcceptedRating:
    Red (tfeng)
    Pt.ProposedRating:
    Yellow (tfeng)
    • Constructor Detail

      • Evaluator

        public Evaluator​(Pattern pattern,
                         MatchResult matchResult)
        Construct an evaluator.
        Parameters:
        pattern - The pattern.
        matchResult - The match result for the match between the pattern and a host model.
    • Method Detail

      • evaluateParseTree

        public Token evaluateParseTree​(ASTPtRootNode node,
                                       ParserScope scope)
                                throws IllegalActionException
        Evaluate the parse tree with a scope that can resolve more names than the given scope. The used scope first searches for names in the host model. If the attempt fails, it invokes the given scope to resolve the names.
        Overrides:
        evaluateParseTree in class ParseTreeEvaluator
        Parameters:
        node - The node to be evaluated.
        scope - The scope to be used as a fallback.
        Returns:
        The result of evaluation.
        Throws:
        IllegalActionException - If an error occurs during evaluation.
      • _createScope

        protected ParserScope _createScope​(Pattern pattern,
                                           MatchResult matchResult,
                                           ParserScope superScope)
        Create the scope to be used for name resolution.
        Parameters:
        pattern - The pattern.
        matchResult - The match result.
        superScope - The scope to fall back on if a name cannot be resolved.
        Returns:
        The scope.