[antlr-interest] Re: SQL grammar, help on ambig warns
lgcraymer
lgc at mail1.jpl.nasa.gov
Mon Aug 26 13:59:42 PDT 2002
--- In antlr-interest at y..., Ruslan Zasukhin <sunshine at p...> wrote:
> on 8/26/02 7:59, lgcraymer at lgc at m... wrote:
>
> > Ruslan--
> >
> > One likely scenario is that somewhere in your grammar you have a
rule
> > which follows character_string_type with "LPAREN" and ANTLR can't
tell
> > whether to assign an LPAREN to that or to "character_string_type"
in
> > the optional subrule. You may need a syntactic predicate to
> > disambiguate ...
>
> As I understand using of syntax predicate is THE ONLY way to run
around
> this?
>
> I just do all my best to keep grammar k=1 and avoid syntax
predicates to get
The k value affects ANTLR grammar analysis much more than it affects
generated code. Setting k=50, for example, can cause the analysis to
take "forever" to generate code from an input grammar, but the
generated code does not change (if k is already large enough to remove
ambiguities). In your case, k=2 may be a good choice: "LPAREN
unsigned_integer" may not be ambiguous.
> it as fat as possible. I need this SQL parser for real-life DBMS.
>
> If speak about syntax predicate...
> How it must looks to still have optional branch.
> I think about adding empty alternative.
> Is this correct?
Yes, in fact that is what ANTLR does internally.
>
> character_string_type
> : ( "character" | "char" )
> ( "varying" LPAREN! unsigned_integer RPAREN!
> |
> (( LPAREN! unsigned_integer RPAREN! ) =>
> ( LPAREN! unsigned_integer RPAREN! )
> | /* nothing */
> )
> )
>
> Just for interest. I assume that it is possible redo some grammar
rules so
> it will be possible to avoid syntax predicate, yes? Because for YACC
it is
> possible.
Usually, although it can be hard to figure out what changes will work.
That's one of the reasons that I'd like to have an ANTLR IDE with
refactoring browser/editor included ...
--Loring
>
>
> >> --------------------------------------------------------------
> >> character_string_type
> >> : ( "character" | "char" )
> >> ( "varying" LPAREN! unsigned_integer RPAREN!
> >> | ( LPAREN! unsigned_integer RPAREN! )?
<<<<<<
> > here
> >> )
> >> | ("varchar" | "string")
> >> ( LPAREN! unsigned_integer
> >> (COMMA! character_string_literal)? RPAREN! )
> >> ;
> >> --------------------------------------------------------------
>
> --
> Best regards,
> Ruslan Zasukhin [ I feel the need...the need for speed ]
> -------------------------------------------------------------
> e-mail: ruslan at p...
> web: http://www.paradigmasoft.com
>
> To subscribe to the Valentina mail list
> send a letter to valentina-on at l...
> -------------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list