[antlr-interest] soliciting language recipes book outline feedback

Monty Zukowski monty at codetransform.com
Mon Jan 7 11:10:23 PST 2008


> > I'm also really happy with my little expression language which
> > generates Java code.  All operators and functions are stored in the
> > tree as functions, and the functions themselves are defined in a
> > separate file as snippets of ST templates.  I think that would be a
> > good little recipe, we can chat further about it if you like.  Sample:
> >
> > expression:  a+b
> > grammar: addition!: x:atom PLUS y:atom {##=#[#(FUNCTION, "add:2"),
> > x, y];}
> > tree: (FUNCTION "add:2" a b)
> > function definition: add($x, $y) ::= <<$x + $y>>
> > alternate function definition for BigIntegers: add($x, $y) ::= <<
> > $x.add($y)>>
>
> So the function "name" dictates which template to load?

Exactly.


More information about the antlr-interest mailing list