Hello,

I am trying to build a grammar which accepts boolean expressions for filtering. 
I found some interesting articles on the web, but now I got stuck.
I try to parse something like this:

  not not or abc

The first "not" is the boolean operator and the second is a text.

Or even worse

  not not and not or and not and

My grammar look like this:

grammar TextFilterGrammar;
options {
        output=AST;
}
content :       orexpression
        ;
orexpression 
        :       andexpression (OR^ andexpression)*
        ;
andexpression 
        :       expression (AND^ expression)*
        ;
expression 
        :       (NOT^)? term
        ;
term    :       WORD
        ;

NOT     :       'not'
        ;
AND     :       'and'
        ;
OR      :       'or'
        ;
WORD    :       ('a'..'z' | '0'..'9' | '%' | '_')+
        ;
WS      :       (' ' | '\r' | '\n' | '\t')  { skip(); }
        ;

In ANTLRWorks I always get a MismatchedTokenException when trying to parse "not 
not or ljsdf". Parsing e.g. "not noti or ljsdf" works fine.

I managed to get it working with quotation marks, but I would prefer to have a 
solution without.

Best regards,
Lordi

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-- 
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.


Reply via email to