Class SyntacticCodeGenerator

    • Constructor Detail

      • SyntacticCodeGenerator

        public SyntacticCodeGenerator​(NamedObj container,
                                      java.lang.String name)
                               throws IllegalActionException,
                                      NameDuplicationException
        Create a new instance of the SyntacticCodeGenerator. The value of the generatorPackageList parameter of the base class is set to generic.syntactic
        Parameters:
        container - The container.
        name - The name of the SyntacticCodeGenerator.
        Throws:
        IllegalActionException - If the super class throws the exception or error occurs when setting the file path.
        NameDuplicationException - If the super class throws the exception or an error occurs when setting the file path.
    • Method Detail

      • comment

        public java.lang.String comment​(java.lang.String comment)
        Format a string as a code comment. This format is specific to the grammar of the generated syntax. Inheriting classes should override this function for the appropriate conventions of the syntax.
        Overrides:
        comment in class GenericCodeGenerator
        Parameters:
        comment - The string to format as a comment.
        Returns:
        A formatted comment.
      • _generateCode

        protected int _generateCode​(java.lang.StringBuffer code)
                             throws KernelException
        Generate a syntactic representation and append it to the given string buffer. Write the code to the directory specified by the codeDirectory parameter. The file name is a sanitized version of the model name with a suffix that is based on last package name of the generatorPackage parameter. Thus if the codeDirectory is $HOME, the name of the model is Foo and the generatorPackage is ptolemy.cg.kernel.generic.syntactic, then the file that is written will be $HOME/Foo.html This method is the main entry point to generate code.
        Overrides:
        _generateCode in class GenericCodeGenerator
        Parameters:
        code - The given string buffer.
        Returns:
        The return value of the last subprocess that was executed. or -1 if no commands were executed.
        Throws:
        KernelException - If the target file cannot be overwritten or write-to-file throw any exception.
      • _getAdapterClassFilter

        protected java.lang.Class<?> _getAdapterClassFilter()
        Return the filter class to find adapters. All adapters have to extend this class.
        Overrides:
        _getAdapterClassFilter in class GenericCodeGenerator
        Returns:
        The base class for the adapters.
      • _showGraph

        protected void _showGraph()
                           throws IllegalActionException
        Show the SyntacticGraph in a Tableau.
        Throws:
        IllegalActionException - Thrown if there is a problem getting the configuration, opening the instance of the syntactic graph or showing the tableau.