|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| 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 ParseTreeCodeGeneratornode - 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 ParseTreeVisitorvisitLeafNode in class AbstractParseTreeVisitorIllegalActionException
public void visitArrayConstructNode(ASTPtArrayConstructNode node)
throws IllegalActionException
visitArrayConstructNode in interface ParseTreeVisitorvisitArrayConstructNode in class AbstractParseTreeVisitorIllegalActionException
public void visitLogicalNode(ASTPtLogicalNode node)
throws IllegalActionException
visitLogicalNode in interface ParseTreeVisitorvisitLogicalNode in class AbstractParseTreeVisitorIllegalActionException
public void visitBitwiseNode(ASTPtBitwiseNode node)
throws IllegalActionException
visitBitwiseNode in interface ParseTreeVisitorvisitBitwiseNode in class AbstractParseTreeVisitorIllegalActionException
public void visitPowerNode(ASTPtPowerNode node)
throws IllegalActionException
visitPowerNode in interface ParseTreeVisitorvisitPowerNode in class AbstractParseTreeVisitorIllegalActionException
public void visitProductNode(ASTPtProductNode node)
throws IllegalActionException
visitProductNode in interface ParseTreeVisitorvisitProductNode in class AbstractParseTreeVisitorIllegalActionException
public void visitRelationalNode(ASTPtRelationalNode node)
throws IllegalActionException
visitRelationalNode in interface ParseTreeVisitorvisitRelationalNode in class AbstractParseTreeVisitorIllegalActionException
public void visitShiftNode(ASTPtShiftNode node)
throws IllegalActionException
visitShiftNode in interface ParseTreeVisitorvisitShiftNode in class AbstractParseTreeVisitorIllegalActionException
public void visitSumNode(ASTPtSumNode node)
throws IllegalActionException
visitSumNode in interface ParseTreeVisitorvisitSumNode in class AbstractParseTreeVisitorIllegalActionException
public void visitUnaryNode(ASTPtUnaryNode node)
throws IllegalActionException
visitUnaryNode in interface ParseTreeVisitorvisitUnaryNode in class AbstractParseTreeVisitorIllegalActionException
public void visitFunctionalIfNode(ASTPtFunctionalIfNode node)
throws IllegalActionException
visitFunctionalIfNode in interface ParseTreeVisitorvisitFunctionalIfNode in class AbstractParseTreeVisitorIllegalActionException
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node)
throws IllegalActionException
visitFunctionApplicationNode in interface ParseTreeVisitorvisitFunctionApplicationNode in class AbstractParseTreeVisitorIllegalActionException
public void visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node)
throws IllegalActionException
visitFunctionDefinitionNode in interface ParseTreeVisitorvisitFunctionDefinitionNode in class AbstractParseTreeVisitorIllegalActionException
public void visitMatrixConstructNode(ASTPtMatrixConstructNode node)
throws IllegalActionException
visitMatrixConstructNode in interface ParseTreeVisitorvisitMatrixConstructNode in class AbstractParseTreeVisitorIllegalActionException
public void visitMethodCallNode(ASTPtMethodCallNode node)
throws IllegalActionException
visitMethodCallNode in interface ParseTreeVisitorvisitMethodCallNode in class AbstractParseTreeVisitorIllegalActionException
public void visitRecordConstructNode(ASTPtRecordConstructNode node)
throws IllegalActionException
visitRecordConstructNode in interface ParseTreeVisitorvisitRecordConstructNode in class AbstractParseTreeVisitorIllegalActionException
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
IllegalActionExceptionprivate 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 ParseTreeCodeGeneratorstring - The string to escape.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||