0

I'm looking at how best to use StringTemplate for code generation for a compiler using ANTLR as the parser. I decided to look to the ANTLR source for inspiration on how to leverage StringTemplate. Since this code is part of the ANTLR tool, rather than the runtime, is it considered "fair game" for usage in my own code? (I realize that would require using either the "complete" jar at runtime, or both the runtime jar as well as the tool jar).

Or, should I considered it "off limits" and implement my own solution modeled after it?

Mike Cargal
  • 6,610
  • 3
  • 21
  • 27

2 Answers2

0

If you're referring to the license, the ANTLR 4 Tool uses the same 3-clause BSD license throughout as the ANTLR 4 Runtime does.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • I was relatively confident of the licensing concerns. My question was more around whether classes from the tool jar (like OutputModelWalker and the @ModelElement attribute) are considered "internal use only" for the ANTLR tool. If I chose to use them, will I be taking a risk, that the ANTLR team could substantially change them in the future, in such a way as to potentially break my code that uses them? I.e. are they considered public consumption classes? – Mike Cargal Jan 23 '14 at 21:42
0

Well, the code generator is pretty stable so you can pretty much assume those suckers will stick around but the code gen is internal so might change on you.

Terence Parr
  • 5,912
  • 26
  • 32
  • I might be a bit dense on the distinction. I like the approach taken with the OutputModelWalker and using the ModelElement attribute to determine the correct template to call. I can easily see that the specifics of OutputModelController and OutputModelFactory are very particular to generating Java source from ANTLR grammars (and wouldn't be useful to me anyway for that very reason). Would I be on shaky ground to use OutputModelWalker and the ModelElement attributes to drive STringTemplate calling in my own code? They both seem (at a cursory look) to be fairly generalized and reusable. – Mike Cargal Jan 23 '14 at 22:05