[stringtemplate-interest] Problems migrating v3 template group inheritance to v4

Terence Parr parrt at cs.usfca.edu
Sun Dec 4 15:41:39 PST 2011


Hi Balazs,

ok, after extensive conversations with Sam Harwell, the C# ST author, I decided that it is just too confusing mixing inheritance and subdirectories, especially when we start thinking about polymorphism. So, I simply made it illegal. This won't break backward compatibility in the sense that it will continue to not work, it's just that you will get a message now ;) I throw an unsupported operation exception if you try to do an import when the group file is not the outermost group you're trying to create. For more details, please see the bottom section on this page that I just updated:

http://www.antlr.org/wiki/display/ST4/Group+inheritance

 Sorry I don't have a more pleasant answer for you.
Ter
On Oct 26, 2011, at 3:55 AM, Balazs Varnai wrote:

> Hi All,
> 
> I'm updating my project to v4. The goal is to minimize the changes in template structure, but I got stuck with inheritance. Any help would be appreciated. Thanks!
> 
> So the setup with inheritance:
> 
> CContainerDef.stg (in v3: group CContainerDef : CModuleDef)
> CEnumerationParamDef.stg (in v3: group CEnumerationParamDef : CContainerDef)
> CModuleDef.stg 
> ...
> 
> It's running inside an Eclipse bundle, so I created a STGroup subclass. Same as STGroupDir, just using bundle URLs. I updated the templates with "import"
> 
> CContainerDef.stg
> 
> import "CModuleDef.stg"
> 
> Templates from 'CContainerDef'  are loaded as '/CContainerDef/<template>, I guess it's parent<>template relationship. I have a template 'container' in 'CModuleDef', so after import it should be available in 'CContainerDef'. ST sees it's not available and tries to load it as '/CContainerDef/container'. Ends up loading itself again?? This is done without looking at the imported stg. Maybe I am completely misunderstanding the template group concept.
> 
> B
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20111204/2a19b3f2/attachment.html 


More information about the stringtemplate-interest mailing list