[antlr-interest] Help on /*empty command*/ ; ; ; ;

Ruslan Zasukhin sunshine at public.kherson.ua
Sat Jul 12 03:50:03 PDT 2008


On 7/12/08 8:06 AM, "Thomas Brandon" <tbrandonau at gmail.com> wrote:

>>> I'm a newbie, but i think the possible lookahead through sql_statement
>>> might be the problem.
>>> Have you tried:
>>> 
>>> sql_single
>>>    : sql_statement? SEMI
>>>    ;
>> 
>> Not yet, and I think this will bring performance troubles.
>> 
>> I know that such empty commands are allowed e.g. In C++.
>> I have take C++ grammars, and later realize why in SQL I have problems.
>> 
>> * because in C++ SEMI must present.
>> * but in SQL it MAY present.
>> 
>> So in SQL I need something as
>> 
>> sql_single
>>    :    SEMI
>>    |    statement (SEMI)?
>> 
>> But  this not works also...
>> 
>> I think because ANTLR cannot differ when add SEMI to second branch, and when
>> it is really just SEMI.
> Is this a problem? ANTLR3 will issue a warning but it should work as
> desired matching the optional SEMI if possible. I thought ANTLR2 would
> do the same but it's been awhile.
> Otherwise you could do:
> sql_single
>     :    SEMI
>     |    statement
> Assuming you don't need to include the SEMI in the tree this should be ok.
> Otherwise you would need to add a predicate to the optional SEMI or
> (maybe) make it greedy.

1) I am using yet 2.7.2

2) greedy will eat all following SEMI, but we also need extract EXACTLY one
command from start to its end, because e.g. VIEWs, TRIGGERs and Stored
Procedures should remember original string


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the antlr-interest mailing list