[antlr-interest] A newbie question about warning:nondeterminism and Parser

Jean-Francois Allard shomano at hotmail.com
Tue Jan 24 12:19:37 PST 2006


Sorry, forgot to diseable HTML editor in previous post...

--------------------------------------------------------------

Hi,

    I am working on a grammar for a very small query language.  The problem 
I get is that for this language, operators (and or) may sometime be a 
litteral, sometime be part of the condition expressions.

    Currently, I get a "warning:nondeterminism" problem as soon as I add 
theses operators to the condition expressions rules.  Is there any way to 
solve it?  I know it is possible to ends up with very bizarre constructs, 
like (or and or or)  In that case, the last matching conditional expression 
should be returned and other token should not be treated as operators:
((or and) OR (or)).

Parser rules:

query
    :   (orExpr)* EOF^
    ;
subExpr
    :   (PAREN_OPEN_ PAREN_CLOSE_) => (PAREN_OPEN_! PAREN_CLOSE_!)
    |   PAREN_OPEN_^ (orExpr)* PAREN_CLOSE_!
    ;
orExpr
    :   andExpr (OR_^ andExpr (OR_! andExpr)*)?
    ;
andExpr
    :   condExpr (AND_^ condExpr (AND_! condExpr)*)?
    ;
condExpr
    : (atom | subExpr)
    ;
atom
    :   (WORD_) <== Would like to add OR_ and AND_ here if not a condition 
operator.
    ;

Thanks in advance
Jeff

_________________________________________________________________
Gardez le contrôle grâce à la protection contre les fenêtres pop-up 
articulée sur la technologie brevetée Microsoft SmartScreen 
http://join.msn.com/?pgmarket=fr-ca&page=features/popup Commencez dès 
maintenant à profiter de tous les avantages de MSN Premium et obtenez les 
deux premiers mois GRATUITS*.



More information about the antlr-interest mailing list