[antlr-interest] StringTemplate questions
Terence Parr
parrt at cs.usfca.edu
Fri Nov 9 17:44:56 PST 2007
On Nov 8, 2007, at 5:32 AM, G R wrote:
> Hi,
>
> I'm trying to use ST to translate relational algebra into SQL, and
> I'm stuck with a template :
> "minus(left, right, keys)" where left, and right are just text, and
> keys is a list of string (I want it to be a list of String).
>
> So first question is how in Java do I build a ST list of string ?
howdy do.
Just pass in List<String> of your choice.
> Then, using my 3 attributes (left, right and keys), I'd like to
> generate the following code :
>
> SELECT * FROM <left>
> WHERE key1 NOT IN (SELECT key1 FROM <right>)
> AND key2 NOT IN (SELECT key2 FROM <right>)
> ...
> AND keyN NOT IN (SELECT keyN FROM <right>)
>
> where key1, key2, ... keyN are the element of my list.
>
> How can i do this ? Can i use an attribute within the separator of
> a list ?
Yes. Separator option can be a template. :) separator={..$a$..}
But, i don't think that's what you want. You want to apply a
template for each keys
SELECT * FROM <left>
WHERE <keys:{k | <k> NOT IN (SELECT <k> FROM <right>)}; separator="
AND ">
Ain't that cool?
Ter
More information about the antlr-interest
mailing list