Class OutputModelWalker

java.lang.Object
org.antlr.v4.codegen.OutputModelWalker

public class OutputModelWalker extends Object
Convert an output model tree to template hierarchy by walking the output model. Each output model object has a corresponding template of the same name. An output model object can have nested objects. We identify those nested objects by the list of arguments in the template definition. For example, here is the definition of the parser template: Parser(parser, scopes, funcs) ::= <<...>> The first template argument is always the output model object from which this walker will create the template. Any other arguments identify the field names within the output model object of nested model objects. So, in this case, template Parser is saying that output model object Parser has two fields the walker should chase called a scopes and funcs. This simple mechanism means we don't have to include code in every output model object that says how to create the corresponding template.
  • Field Details

    • tool

      Tool tool
    • templates

      org.stringtemplate.v4.STGroup templates
  • Constructor Details

    • OutputModelWalker

      public OutputModelWalker(Tool tool, org.stringtemplate.v4.STGroup templates)
  • Method Details

    • walk

      public org.stringtemplate.v4.ST walk(OutputModelObject omo, boolean header)