Package ptolemy.data.expr
Class ParseTreeWriter
- java.lang.Object
-
- ptolemy.data.expr.AbstractParseTreeVisitor
-
- ptolemy.data.expr.ParseTreeWriter
-
- All Implemented Interfaces:
ParseTreeVisitor
public class ParseTreeWriter extends AbstractParseTreeVisitor
This class implements a visitor that writes parse trees in the expression language.- Since:
- Ptolemy II 2.1
- Version:
- $Id$
- Author:
- Steve Neuendorffer
- See Also:
ASTPtRootNode
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (neuendor)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.PrintWriter
_writer
-
Constructor Summary
Constructors Constructor Description ParseTreeWriter()
-
Method Summary
-
Methods inherited from class ptolemy.data.expr.AbstractParseTreeVisitor
_unsupportedVisitException, _visitAllChildren, _visitChild, visitAssignmentNode, visitUnionConstructNode
-
-
-
-
Method Detail
-
displayParseTree
public void displayParseTree(ASTPtRootNode root)
-
parseTreeToExpression
public java.lang.String parseTreeToExpression(ASTPtRootNode root) throws IllegalActionException
Produce an expression for this parse tree.- Parameters:
root
- The root of the parse tree.- Returns:
- The expression.
- Throws:
IllegalActionException
- If the parse tree has an error.
-
printParseTree
public java.lang.String printParseTree(ASTPtRootNode root)
Return an expression for this parse tree, or a description of the exception if an exception occurs.- Parameters:
root
- The root of the parse tree.- Returns:
- The expression.
-
setStringMode
public void setStringMode(boolean stringMode)
Specify whether the expression to write is in string mode. FIXME string mode has only been implemented for leaf and sum nodes.- Parameters:
stringMode
- True to put the expression to write in string mode.
-
visitArrayConstructNode
public void visitArrayConstructNode(ASTPtArrayConstructNode node) throws IllegalActionException
- Specified by:
visitArrayConstructNode
in interfaceParseTreeVisitor
- Overrides:
visitArrayConstructNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitBitwiseNode
public void visitBitwiseNode(ASTPtBitwiseNode node) throws IllegalActionException
- Specified by:
visitBitwiseNode
in interfaceParseTreeVisitor
- Overrides:
visitBitwiseNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitFunctionApplicationNode
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException
- Specified by:
visitFunctionApplicationNode
in interfaceParseTreeVisitor
- Overrides:
visitFunctionApplicationNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitFunctionDefinitionNode
public void visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node) throws IllegalActionException
- Specified by:
visitFunctionDefinitionNode
in interfaceParseTreeVisitor
- Overrides:
visitFunctionDefinitionNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitFunctionalIfNode
public void visitFunctionalIfNode(ASTPtFunctionalIfNode node) throws IllegalActionException
- Specified by:
visitFunctionalIfNode
in interfaceParseTreeVisitor
- Overrides:
visitFunctionalIfNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitLeafNode
public void visitLeafNode(ASTPtLeafNode node) throws IllegalActionException
- Specified by:
visitLeafNode
in interfaceParseTreeVisitor
- Overrides:
visitLeafNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitLogicalNode
public void visitLogicalNode(ASTPtLogicalNode node) throws IllegalActionException
- Specified by:
visitLogicalNode
in interfaceParseTreeVisitor
- Overrides:
visitLogicalNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitMatrixConstructNode
public void visitMatrixConstructNode(ASTPtMatrixConstructNode node) throws IllegalActionException
- Specified by:
visitMatrixConstructNode
in interfaceParseTreeVisitor
- Overrides:
visitMatrixConstructNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitMethodCallNode
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException
- Specified by:
visitMethodCallNode
in interfaceParseTreeVisitor
- Overrides:
visitMethodCallNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitPowerNode
public void visitPowerNode(ASTPtPowerNode node) throws IllegalActionException
- Specified by:
visitPowerNode
in interfaceParseTreeVisitor
- Overrides:
visitPowerNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitProductNode
public void visitProductNode(ASTPtProductNode node) throws IllegalActionException
- Specified by:
visitProductNode
in interfaceParseTreeVisitor
- Overrides:
visitProductNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitRecordConstructNode
public void visitRecordConstructNode(ASTPtRecordConstructNode node) throws IllegalActionException
- Specified by:
visitRecordConstructNode
in interfaceParseTreeVisitor
- Overrides:
visitRecordConstructNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitRelationalNode
public void visitRelationalNode(ASTPtRelationalNode node) throws IllegalActionException
- Specified by:
visitRelationalNode
in interfaceParseTreeVisitor
- Overrides:
visitRelationalNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitShiftNode
public void visitShiftNode(ASTPtShiftNode node) throws IllegalActionException
- Specified by:
visitShiftNode
in interfaceParseTreeVisitor
- Overrides:
visitShiftNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitSumNode
public void visitSumNode(ASTPtSumNode node) throws IllegalActionException
- Specified by:
visitSumNode
in interfaceParseTreeVisitor
- Overrides:
visitSumNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
visitUnaryNode
public void visitUnaryNode(ASTPtUnaryNode node) throws IllegalActionException
- Specified by:
visitUnaryNode
in interfaceParseTreeVisitor
- Overrides:
visitUnaryNode
in classAbstractParseTreeVisitor
- Throws:
IllegalActionException
-
-