[stringtemplate-interest] Passing values into templates

Zenaan Harkness zen at freedbms.net
Sun Apr 20 03:24:38 PDT 2008


On Sun, Apr 20, 2008 at 09:28:41AM +0100, Ben Hood wrote:
> 
> On 20 Apr 2008, at 06:26, Terence Parr wrote:
> 
> >
> > On Apr 19, 2008, at 4:32 PM, Ben Hood wrote:
> >>> Eg:
> >>>  return <readBytes("length= next - 0x20")>;
> >>
> >> If I do this, i.e. return <readBytes(length="next - 0x20")>; then I
> >> run into this error:
> >>
> >> action parse error in group GenricReader line 7; template context is
> >> [decode]
> >> line 1:1: unexpected token: readBytes
> >
> >
> > problem is in template decode it appears.  did you terminate it?
> > Ter
> 
> I've tried to break the problem down into it's simplest form.
> 
> If I do this:
> 
> decode() ::= <<
>      int next = <readByte()>;
>      if (next <ge()> 0x20 && next <le()> 0x2f) {
>          return <readBytes(length="next - 0x20")>;
>      }
>  >>
> 
> readBytes(length) ::= "inputStream.readBytes(<length>)"

"length" is a reserved word. You have to change that.

On the wiki for StringTemplate 3.0 documentation, see the bottom of the
"StringTemplate cheat sheet" section, which lists all the ST reserved
words.

TODO: Put "Reserved Words" in its own section. This is really important,
and bit me the other day too. I know its really short, but it's really
important, so there's no reason to not give it its own section with a
top-level heading, so people can easily click on it. Perhaps with a link
inside the "cheat sheet" page.

Zen

-- 
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.


More information about the stringtemplate-interest mailing list