Date: Fri, 29 Mar 2024 13:29:18 +0000 (UTC) Message-ID: <171335312.7.1711718958569@5849bc242374> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_6_1355083768.1711718958568" ------=_Part_6_1355083768.1711718958568 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
I changed these files to make it happen:
tool/src/main/resources/org/antlr/codegen/templates/Java/ST.stg
runtime/Java/src/main/java/org/antlr/runtime/tree/DOTTreeGenerator.java
You can ignore the following files that I had to change because they are= part of my test suite:
tool/src/test/java/org/antlr/test/BaseTest.java
tool/src/test/java/org/antlr/test/TestRewriteTemplates.java
tool/src/test/java/org/antlr/test/TestTemplates.java
tool/src/test/java/org/antlr/test/TestTreeParsing.java
In general, these are the changes I had to make:
((Token= RewriteStream)input).replace( ((Token)retval.start).getTokenIndex(), input.LT(-1).getTokenIndex(), retval.st.render()); <--------------- was just retval.st
So, in a nutshell, there are a few changes in one runtime support file f=
or generating DOT from trees. All of the magic happens in the ST.stg file, =
if your target supports output=3Dtemplate
option. Here is a pl=
ay-by-play:
protect= ed StringTemplateGroup templateLib =3D new StringTemplateGroup("<name>Templates", AngleBracketTemplateLexe= r.class);
protect= ed STGroup templateLib =3D new STGroup();
rewrite= ExternalTemplate(name,args) ::=3D << templateLib.getInstanceOf("<name>"<if(args)>, new STAttrMap()<args:{a | .put("<a.name>", <a.value>)}> <endif>) >>
rewrite= ExternalTemplate(name,args) ::=3D << templateLib.getInstanceOf("<name>") <if(args)><args:{a | .add("<a.name>", <a.value>)}>= ;<endif> >>
If you look at an ST.stg dif= ference, there's not much to do.