[antlr-interest] PL/SQL grammar

Andrew Haritonkin thikone at gmail.com
Thu Jun 25 14:51:42 PDT 2009


> Date: Wed, 24 Jun 2009 09:30:32 +0200
> From: Markus M?ller <Markus.Mueller at 34DataBanking.ch>
> Subject: [antlr-interest] PL/SQL grammar
> To: antlr-interest at antlr.org
> Message-ID:
>        <1103140614.70911245828632692.JavaMail.root at menkar.cosmox.ch>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi there,
> this is my first posting to this list, and I'm not sure if this the right place for my question... But anyway:
> Does anyone has experience with the PL/SQL grammar provided on the ANTLR grammar list?
> When doing a "check grammar" there is one warning (ok...) and also an error (something like "ID DOT ID DOT ID DOT... : cannot determine how to continue", beginning in the sql_statement >> expr_expr >> function_call etc.).
> Is this because of the ANTLR version or is this an error in the grammar? Does any one know a fix for that, or is there another PL/SQL grammar out there? Asking google delivers only a few hits, most of them not really what I'm looking for...
> Thanks,
> Markus

Hi Markus,

Yep, it's known issue. This grammar was tested with ANTLR 3.0.1, but
ever since ANTLR 3.1 it raises this error. Shame on me, I didn't have
the time to figure out why... I have a hot fix for that, though.

You need to change one rule to make it work with ANTLR 3.1.x:

column_spec
   :       sql_identifier ( DOT sql_identifier )*;

ANTLR 3.1.x cannot compile it, but raises a error:

error(206): PLSQL3.g:791:4: Alternative 2: after matching input such
as ID DOT ID DOT ID DOT ID DOT decision cannot predict what comes next
due to recursion overflow to expr_add from sql_expression and to
expr_mul from expr_add

While with ANTLR 3.0.1 it was compiling just fine... Anyway, replace
it with this:

column_spec
   :       sql_identifier ( DOT sql_identifier ( DOT sql_identifier )? )?;

Another interesting detail, ANTLR 3.1.3 doesn't recorgnize option k=*,
not a big problem though, since it's default option anyway.

Also change maximum allowed memory for Java VM before starting ANTLR.
It needs at least 256 Mb to process this grammar ;-)

Attached is my latest version with some other fixes (many thanks to
people who provided feedback) for C# and Java.

This was my second ANTLR grammar (first one failed half of my tests)
and it's not perfect. But quite comprehensive and can parse lots of
nasty code. I'm thinking about making a new revision, but I cannot say
when I would do that...

Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PLSQL3.g
Type: application/octet-stream
Size: 41725 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090625/ecbb1671/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PLSQL3j.g
Type: application/octet-stream
Size: 44741 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090625/ecbb1671/attachment-0003.obj 


More information about the antlr-interest mailing list