Class Antlr4Mojo.CustomTool

  • Enclosing class:
    Antlr4Mojo

    private final class Antlr4Mojo.CustomTool
    extends Tool
    • Constructor Detail

      • CustomTool

        public CustomTool​(java.lang.String[] args)
    • Method Detail

      • process

        public void process​(Grammar g,
                            boolean gencode)
        Description copied from class: Tool
        To process a grammar, we load all of its imported grammars into subordinate grammar objects. Then we merge the imported rules into the root grammar. If a root grammar is a combined grammar, we have to extract the implicit lexer. Once all this is done, we process the lexer first, if present, and then the parser grammar
        Overrides:
        process in class Tool
      • getOutputFileWriter

        public java.io.Writer getOutputFileWriter​(Grammar g,
                                                  java.lang.String fileName)
                                           throws java.io.IOException
        Description copied from class: Tool
        This method is used by all code generators to create new output files. If the outputDir set by -o is not present it will be created. The final filename is sensitive to the output directory and the directory where the grammar file was found. If -o is /tmp and the original grammar file was foo/t.g4 then output files go in /tmp/foo. The output dir -o spec takes precedence if it's absolute. E.g., if the grammar file dir is absolute the output dir is given precedence. "-o /tmp /usr/lib/t.g4" results in "/tmp/T.java" as output (assuming t.g4 holds T.java). If no -o is specified, then just write to the directory where the grammar file was found. If outputDirectory==null then write a String.
        Overrides:
        getOutputFileWriter in class Tool
        Throws:
        java.io.IOException