That does not seem to change anything. Did I miss something ?
Edgar Espina a écrit :
> Hi,
>
> try this:
>
> WS : ( ' ' | '\t' ) { $channel=HIDDEN; } ;
>
> Regards
>
> On Mon, Jan 11, 2010 at 8:51 AM, Aurélien LARIVE
> <[email protected] <mailto:[email protected]>>
> wrote:
>
> Hi,
>
> I'm currently writing a small grammar to parse a searchbar
> language and
> I'm failing at making whitespaces behave like the AND keyword.
>
> Here is my grammar :
>
> grammar SearchBar;
>
> options {
> output=AST;
> }
>
> WS : ( ' ' | '\t' ) { skip(); } ;
> AND : 'AND' ;
> OR : 'OR' ;
> NOT : 'NOT' ;
> LEFT_PAREN : '(' ;
> RIGHT_PAREN : ')' ;
> TERM : ~(' '|'\t'|'"'|RIGHT_PAREN|LEFT_PAREN|NOT|OR|AND)* ;
> QUOTEDTERM : '"' ~('"')* '"' ;
>
> orexpression
> : andexpression ( OR^ andexpression )*
> ;
>
> andexpression
> : notexpression ( (AND^)? notexpression )*
> ;
>
> notexpression
> : (NOT^)? searchterm
> ;
>
> searchterm
> : TERM
> | QUOTEDTERM
> | LEFT_PAREN! orexpression RIGHT_PAREN!
> ;
>
> And here is my tree grammar :
>
> tree grammar SearchBarEval;
>
> options {
> ASTLabelType=CommonTree;
> tokenVocab=SearchBar;
> }
>
> prog
> : expr+ ;
>
> expr returns [XMSExpression expression]
> : ^(OR a=expr b=expr) {
> $expression = new Or($a.expression, $b.expression);
> }
> | ^(AND a=expr b=expr) {
> $expression = new And($a.expression, $b.expression);
> }
> | ^(NOT a=expr) {
> $expression = new Not($a.expression);
> }
> | TERM {
> $expression = new Term($TERM.text);
> }
> | QUOTEDTERM {
> $expression = new QuotedTerm($QUOTEDTERM.text);
> }
> ;
>
> When I try to evaluate, for example, the input 'apples bananas
> tomatos',
> I only get the Term 'apples'. I understand why I'm having this problem
> but I was unable to find a good solution.
>
> Thanks in advance,
>
> --
> Aurélien
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
>
> --
> edgar
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.