[stringtemplate-interest] Attaching model to stringtemplate group

Johannes Luber jaluber at gmx.de
Tue Sep 25 07:16:31 PDT 2007


Terence Parr wrote:
> When you create an instance of CreateContent, use setAttribute to set  
> "element", right?

It is so embarrassing, but I found the reason why it didn't work. The
problem was that when I rewrote the templates, I changed the
capitalization of the parameter names - and I put changing the call site
on my todo list. As it took longer than expected to update the call
site, I had already forgotten that minor detail. I suppose that if there
would be a debug mode which tells the programmer about unused/unsupplied
parameters, this would have been easier to find out. I switched in ANTLR
to the line

"-> Grammar(Name={$ID.Text}, StartRule={startRule},
Elements={elementTree.Children})"

where elementTree.Children are indeed tree objects already, as John
inquired. I got the following result when invoking the program:

Class
C5.GuardedList`1[[Kerriv.Antlr3ToRelaxNG.Interpreter.TypeInterpreter,
Tool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] has no
such attribute:
 IsRootType in template context [Grammar anonymous CreateContent]
Class
C5.GuardedList`1[[Kerriv.Antlr3ToRelaxNG.Interpreter.TypeInterpreter,
Tool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] has no
such attribute:
 IsAndType in template context [Grammar anonymous CreateContent]
Class
C5.GuardedList`1[[Kerriv.Antlr3ToRelaxNG.Interpreter.TypeInterpreter,
Tool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] has no
such attribute:
 IsOrType in template context [Grammar anonymous CreateContent]
# Grammar Backslashbugtest
grammar{
start = element  { Content }




EpsilonToken = empty

}

StringTemplate doesn't seem to use for arrays the interface IList,
otherwise it would load the elements from the C5 collection library type
GuardedList (which is a read only list). I changed the invocation to

-> Grammar(Name={$ID.Text}, StartRule={startRule},
Elements={elementTree.Children.ToArray()})

and received the following error:

Class Kerriv.Antlr3ToRelaxNG.Interpreter.TypeInterpreter[] has no such
attribute
: Children in template context [Grammar]
# Grammar BackslashBugTest
grammar{
start = element  { Content }


EpsilonToken = empty

}

Now StringTemplate seems to take the array object and not its elements
as argument for the CreateContent template. What do I do wrong here?

> 
> Yeah, tried dvorak etc...  Basically I type 12 hours a day every  
> day...tha'ts the issue ;)
> Tr

What is etc.? Regarding Dvorak - it has a number of disadvantages
compared to Colemak, the most prominent may be that Colemak moves most
keys only one position, if at all, while Dvorak changes all positions.
This increases learnability tremendously for switchers - but if you
don't want to try it once for a few weeks... well, I can't force you to
your luck then.

Johannes


More information about the stringtemplate-interest mailing list