What is the best pattern (language independent, for retargetable generation code) to translate antlr token to camel case StringTemplate attribute in a tree conversion? Example: My DSL has MY_FIELD definition and in the StringTemplate output I need myField.

有帮助吗?

解决方案

In your parser you could set the text of the Token, and that should flow through to the StringTemplate. Something like this grammar fragment should work:

my=MY_FIELD { $my.setText("myField"); }

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top