Search code examples
url-rewritingantlr4stringtemplate

antlr4 and string template groups and rewrite option in grammar


In ANtlr3 I could specify the template group from the parser. The grammar itself had the following options

options {
    output=template;
    rewrite=true;
    language=CSharp4;   
}

parser.TemplateGroup = template;

How is this done in Antlr4 and ST4?


Solution

  • ANTLR 4 does not have an output option (or rewrite option). In ANTLR 4, you would implement a listener for the parse tree automatically generated by the grammar, and perform all of the StringTemplate operations within the listener.