UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

26 lines (25 loc) 1.3 kB
import { STGroup, type IST } from "stringtemplate4ts"; import { Tool } from "../Tool.js"; import { OutputModelObject } from "./model/OutputModelObject.js"; /** * 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. */ export declare class OutputModelWalker { protected tool: Tool; protected templates: STGroup; constructor(tool: Tool, templates: STGroup); walk(omo: OutputModelObject, header: boolean): IST; }