[stringtemplate-interest] Passing values into templates
Ben Hood
0x6e6562 at gmail.com
Sat Apr 19 16:32:44 PDT 2008
On 19 Apr 2008, at 23:18, Zenaan Harkness wrote:
>> I'd like to be able to implement the readBytes(length) template in a
>> subtemplate that is specific to the target language.
>
> So your sub-group has a line near the top that says something like:
>
> group my-language-or-subgroup-name : super-group-name;
No, I was doing that programmatically rather than using any syntax
available in the template definition. I didn't even know you could do
something like
group sub : super;
because it doesn't seem to appear in the documentation.
> And then your sub-groups (one for each language), implement
> readBytes(length)?
>
> Then it should work.
>
> I haven't used STGroup interfaces yet, so someone else would have to
> comment on that.
>
> If it's not running, perhaps your value being passed to readbytes is
> all
> that needs to change (you do know you can't do any maths
> calculations in
> ST yes (except for if/endif)?).
>
> 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
when the readBytes template is defined as
readBytes(length) ::= "foo"
Ben
More information about the stringtemplate-interest
mailing list