|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.data.expr.AbstractParseTreeVisitor
ptolemy.codegen.rtmaude.kernel.RTMaudeParseTreeCodeGenerator
public class RTMaudeParseTreeCodeGenerator
Generate RTMaude code for expressions.
Red (kquine) |
Red (kquine)* |
Field Summary | |
---|---|
protected java.io.PrintWriter |
_writer
Used to accumulate generated strings. |
private java.lang.String |
result
|
Constructor Summary | |
---|---|
RTMaudeParseTreeCodeGenerator()
Create a new instance of the RTMaude parse tree code generator. |
Method Summary | |
---|---|
private void |
_printChild(ASTPtRootNode node,
int index)
Visits the index-th child of the given node, so that the expression of the child node is generated. |
private void |
_printChildrenSeparated(ASTPtRootNode node,
java.util.List separatorList)
Visits all children of the given node, and the resulting expression is the list with the given separators. |
private void |
_printChildrenSeparated(ASTPtRootNode node,
java.lang.String string,
boolean paran)
Visits all children of the given node, and the resulting expression is the list with the given separator. |
private java.lang.String |
_transformLeaf(java.lang.String id)
Returns a RTMaude term from the given (Leaf) Ptolemy expression. |
private static java.lang.String |
_transformOp(java.lang.String op)
Returns a RTMaude operator from the given Ptolemy expression operator. |
java.lang.String |
escapeForTargetLanguage(java.lang.String string)
Given a string, escape special characters as necessary for the target language. |
Token |
evaluateParseTree(ASTPtRootNode node,
ParserScope scope)
Evaluate the parse tree with the specified root node using the specified scope to resolve the values of variables. |
java.lang.String |
generateFireCode()
Generate code that corresponds with the fire() method. |
void |
visitArrayConstructNode(ASTPtArrayConstructNode node)
|
void |
visitBitwiseNode(ASTPtBitwiseNode node)
|
void |
visitFunctionalIfNode(ASTPtFunctionalIfNode node)
|
void |
visitFunctionApplicationNode(ASTPtFunctionApplicationNode node)
|
void |
visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node)
|
void |
visitLeafNode(ASTPtLeafNode node)
|
void |
visitLogicalNode(ASTPtLogicalNode node)
|
void |
visitMatrixConstructNode(ASTPtMatrixConstructNode node)
|
void |
visitMethodCallNode(ASTPtMethodCallNode node)
|
void |
visitPowerNode(ASTPtPowerNode node)
|
void |
visitProductNode(ASTPtProductNode node)
|
void |
visitRecordConstructNode(ASTPtRecordConstructNode node)
|
void |
visitRelationalNode(ASTPtRelationalNode node)
|
void |
visitShiftNode(ASTPtShiftNode node)
|
void |
visitSumNode(ASTPtSumNode node)
|
void |
visitUnaryNode(ASTPtUnaryNode node)
|
Methods inherited from class ptolemy.data.expr.AbstractParseTreeVisitor |
---|
_unsupportedVisitException, _visitAllChildren, _visitChild, visitAssignmentNode, visitUnionConstructNode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.PrintWriter _writer
private java.lang.String result
Constructor Detail |
---|
public RTMaudeParseTreeCodeGenerator()
Method Detail |
---|
public Token evaluateParseTree(ASTPtRootNode node, ParserScope scope) throws IllegalActionException
ParseTreeCodeGenerator
evaluateParseTree
in interface ParseTreeCodeGenerator
node
- The root of the parse tree.scope
- The scope for evaluation.
IllegalActionException
- If an error occurs during
evaluation.public java.lang.String generateFireCode()
ParseTreeCodeGenerator
generateFireCode
in interface ParseTreeCodeGenerator
public void visitLeafNode(ASTPtLeafNode node) throws IllegalActionException
visitLeafNode
in interface ParseTreeVisitor
visitLeafNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitArrayConstructNode(ASTPtArrayConstructNode node) throws IllegalActionException
visitArrayConstructNode
in interface ParseTreeVisitor
visitArrayConstructNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitLogicalNode(ASTPtLogicalNode node) throws IllegalActionException
visitLogicalNode
in interface ParseTreeVisitor
visitLogicalNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitBitwiseNode(ASTPtBitwiseNode node) throws IllegalActionException
visitBitwiseNode
in interface ParseTreeVisitor
visitBitwiseNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitPowerNode(ASTPtPowerNode node) throws IllegalActionException
visitPowerNode
in interface ParseTreeVisitor
visitPowerNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitProductNode(ASTPtProductNode node) throws IllegalActionException
visitProductNode
in interface ParseTreeVisitor
visitProductNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitRelationalNode(ASTPtRelationalNode node) throws IllegalActionException
visitRelationalNode
in interface ParseTreeVisitor
visitRelationalNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitShiftNode(ASTPtShiftNode node) throws IllegalActionException
visitShiftNode
in interface ParseTreeVisitor
visitShiftNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitSumNode(ASTPtSumNode node) throws IllegalActionException
visitSumNode
in interface ParseTreeVisitor
visitSumNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitUnaryNode(ASTPtUnaryNode node) throws IllegalActionException
visitUnaryNode
in interface ParseTreeVisitor
visitUnaryNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitFunctionalIfNode(ASTPtFunctionalIfNode node) throws IllegalActionException
visitFunctionalIfNode
in interface ParseTreeVisitor
visitFunctionalIfNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException
visitFunctionApplicationNode
in interface ParseTreeVisitor
visitFunctionApplicationNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node) throws IllegalActionException
visitFunctionDefinitionNode
in interface ParseTreeVisitor
visitFunctionDefinitionNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitMatrixConstructNode(ASTPtMatrixConstructNode node) throws IllegalActionException
visitMatrixConstructNode
in interface ParseTreeVisitor
visitMatrixConstructNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException
visitMethodCallNode
in interface ParseTreeVisitor
visitMethodCallNode
in class AbstractParseTreeVisitor
IllegalActionException
public void visitRecordConstructNode(ASTPtRecordConstructNode node) throws IllegalActionException
visitRecordConstructNode
in interface ParseTreeVisitor
visitRecordConstructNode
in class AbstractParseTreeVisitor
IllegalActionException
private void _printChild(ASTPtRootNode node, int index) throws IllegalActionException
node
- The nodeindex
- The index which will be visited
IllegalActionException
private void _printChildrenSeparated(ASTPtRootNode node, java.util.List separatorList) throws IllegalActionException
node
- The nodeseparatorList
- The list of separators
IllegalActionException
private void _printChildrenSeparated(ASTPtRootNode node, java.lang.String string, boolean paran) throws IllegalActionException
node
- The nodestring
- The separator
IllegalActionException
private static java.lang.String _transformOp(java.lang.String op)
op
- The given Ptolemy expression operator
private java.lang.String _transformLeaf(java.lang.String id)
id
- The given Ptolemy expression.
public java.lang.String escapeForTargetLanguage(java.lang.String string)
ParseTreeCodeGenerator
escapeForTargetLanguage
in interface ParseTreeCodeGenerator
string
- The string to escape.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |