Sorry I forget to attach the grammer. Here it is

grammar Query;

//=== Parser Option ===//
options {
  output = AST;
  k=*;
}




//=== Lexer ===//
OR: 'OR';
AND: 'AND';
NOT: 'NOT';
WORD: ('a'..'z' | 'A'..'Z' | '.' | ',' | '0'..'9')+ | '"'.+'"';
LEFT_PAREN: '(';
RIGHT_PAREN: ')';
WHITESPACE: (' ' | '\t' | '\r' | '\n') { $channel = HIDDEN; } ;



//=== Parser ===//
expr: orexpression*;
orexpression
 
     :   andexpression (OR orexpression)*
    ;

andexpression
    : notexpression (AND andexpression)*
    ;

notexpression
    : (NOT)? atom
    ;

atom
    : WORD+
    | LEFT_PAREN! expr RIGHT_PAREN!
    ;









--- On Thu, 9/18/08, jack zhang <[EMAIL PROTECTED]> wrote:
From: jack zhang <[EMAIL PROTECTED]>
Subject: Alternative(s) 2 were disabled for that input
To: [EMAIL PROTECTED]
Date: Thursday, September 18, 2008, 4:46 PM

Hi,
  I keep getting following errors:

warning(138): Query.g:0:0: grammar Query: no start rule (no rule can obviously 
be followed by EOF)
warning(200): Query.g:27:40: Decision can match input such as "OR" using 
multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): Query.g:31:39: Decision can match input such as "AND" using 
multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): Query.g:39:7: Decision can match input such as "WORD" using 
multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input

  I kind of understand why because if the input is "OR" the parser will just 
freak out. What I want do is a simple boolean query input validator

(1) valid input:
a OR b
c AND d
a OR b AND
 d

(2) invalid input:
a AND  
AND b (This is not working)

What's wrong with the grammer? I really cannot figure it out.

Thanks !




      


      
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address

Reply via email to