Class JavaParseTreeCodeGenerator

  • All Implemented Interfaces:
    ParseTreeCodeGenerator, ParseTreeVisitor

    public class JavaParseTreeCodeGenerator
    extends ProceduralParseTreeCodeGenerator
    Evaluate a parse tree given a reference to its root node and generate Java code. It implements a visitor that visits the parse tree in depth-first order, evaluating each node and storing the result as a token in the node. Two exceptions are logic nodes and the ternary if node (the ? : construct), which do not necessarily evaluate all children nodes.

    This class has the following limitations:

    • It is a copy of ParseTreeEvaluator from data/expr and thus has lots of code for evaluating expressions, which we don't need
    • It is not properly converting types: We need to add logic to convert types.
    • The .tcl test has known failures involving nulls.
    • It does not evaluate constants.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Christopher Brooks
    See Also:
    ASTPtRootNode
    Pt.AcceptedRating:
    Red
    Pt.ProposedRating:
    Red
    • Constructor Detail

      • JavaParseTreeCodeGenerator

        public JavaParseTreeCodeGenerator​(ProgramCodeGenerator generator)
        Create a JavaParseTreeCodeGenerator that is used by the given code generator to generate code for expressions.
        Parameters:
        generator - The given code generator.