Class JavaTemplateParser
- java.lang.Object
-
- ptolemy.cg.kernel.generic.program.TemplateParser
-
- ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
-
- ptolemy.cg.kernel.generic.program.procedural.java.JavaTemplateParser
-
public class JavaTemplateParser extends ProceduralTemplateParser
A class that allows to parse macros of templates in a code generator perspective.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Bert Rodiers
- Pt.AcceptedRating:
- Red (rodiers)
- Pt.ProposedRating:
- Red (rodiers)
-
-
Field Summary
-
Fields inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
_includeFiles
-
Fields inherited from class ptolemy.cg.kernel.generic.program.TemplateParser
_codeGenerator, _component, _parseTreeCodeGenerator
-
-
Constructor Summary
Constructors Constructor Description JavaTemplateParser()
Construct the JavaTemplateParser associated with the given component and the given adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JavaCodeGenerator
_getCodeGenerator()
Get the code generator associated with this adapter class.protected java.lang.String
_replaceMacro(java.lang.String macro, java.lang.String parameter)
Return the replacement string of the given macro.java.lang.String
getFunctionInvocation(java.lang.String functionString, boolean isStatic)
Return the translated token instance function invocation string.java.lang.String
getNewInvocation(java.lang.String constructorString)
Return the translated new constructor invocation string.ParseTreeCodeGenerator
getParseTreeCodeGenerator()
Return a new parse tree code generator to use with expressions.-
Methods inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
generateFireCode, getHeaderFiles, init
-
Methods inherited from class ptolemy.cg.kernel.generic.program.TemplateParser
_findClosedParen, addFunctionUsed, addNewTypesUsed, escapeName, escapePortName, generateBlockCode, generateTypeConvertMethod, generateTypeConvertStatement, getCodeStream, getParameterValue, getPort, getSize, indexOf, parseList, processCode, setCodeGenerator, unescapeName, unescapePortName
-
-
-
-
Method Detail
-
getFunctionInvocation
public java.lang.String getFunctionInvocation(java.lang.String functionString, boolean isStatic) throws IllegalActionException
Return the translated token instance function invocation string.- Overrides:
getFunctionInvocation
in classTemplateParser
- Parameters:
functionString
- The string within the $tokenFunc() macro.isStatic
- True if the method is static.- Returns:
- The translated type function invocation string.
- Throws:
IllegalActionException
- The given function string is not well-formed.
-
getParseTreeCodeGenerator
public ParseTreeCodeGenerator getParseTreeCodeGenerator()
Return a new parse tree code generator to use with expressions.- Overrides:
getParseTreeCodeGenerator
in classProceduralTemplateParser
- Returns:
- the parse tree code generator to use with expressions.
-
getNewInvocation
public java.lang.String getNewInvocation(java.lang.String constructorString) throws IllegalActionException
Return the translated new constructor invocation string. Keep the types referenced in the info table of this adapter. The kernel will retrieve this information to determine the total number of referenced types in the model.- Overrides:
getNewInvocation
in classTemplateParser
- Parameters:
constructorString
- The string within the $new() macro.- Returns:
- The translated new constructor invocation string.
- Throws:
IllegalActionException
- The given constructor string is not well-formed.
-
_getCodeGenerator
protected JavaCodeGenerator _getCodeGenerator()
Get the code generator associated with this adapter class.- Overrides:
_getCodeGenerator
in classTemplateParser
- Returns:
- The code generator associated with this adapter class.
- See Also:
TemplateParser.setCodeGenerator(ProgramCodeGenerator)
-
_replaceMacro
protected java.lang.String _replaceMacro(java.lang.String macro, java.lang.String parameter) throws IllegalActionException
Return the replacement string of the given macro. Subclass of GenericCodeGenerator may overriding this method to extend or support a different set of macros.- Overrides:
_replaceMacro
in classTemplateParser
- Parameters:
macro
- The given macro.parameter
- The given parameter to the macro.- Returns:
- The replacement string of the given macro.
- Throws:
IllegalActionException
- Thrown if the given macro or parameter is not valid.
-
-