[antlr-interest] Re: SQL grammar, help on ambig warns
lgcraymer
lgc at mail1.jpl.nasa.gov
Sun Aug 25 21:59:00 PDT 2002
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 ...
--Loring
--- In antlr-interest at y..., Ruslan Zasukhin <sunshine at p...> wrote:
> Hi Guys,
>
> At last of end we have found time to work on our own SQL 92 grammar.
> We can compile grammar without errors.
> Problem only with some ambig warns.
>
> For example, I get warn
>
> > E:\antlr272a2\OBL\OBL_SQLGrammar.g:342:23: warning: nondeterminism
upon
> > E:\antlr272a2\OBL\OBL_SQLGrammar.g:342:23: k==1:LPAREN
> > E:\antlr272a2\OBL\OBL_SQLGrammar.g:342:23: between alts 1 and
2 of block
>
> on this rule: (By the way, k = 1 for parser, for k = 2 the same
problem)
>
> --------------------------------------------------------------
> 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! )
> ;
> --------------------------------------------------------------
>
> Is this rule incorrect ???
>
> If remove ? Then it compiles fine.
>
> Also when I look into generated C++ Parser, for code of problematic
line
> I see that ANTLR test on tokens from MANY MANY other rules (that
probably
> call this one).
>
> I can understand why this is needed, just was surprised.
> I did think that each rule is self-contained, but it seems generated
code
> depend on where and how a rule is called also.
>
>
> --
> 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