[antlr-interest] Is '!' operator working with ANTLR 3.1.2

Colin Macdonald Colin.Macdonald at us.gbs.com
Wed Nov 17 12:42:59 PST 2010


Jim,

Don't you mean that the ! operator is not supported in the Lexer?

Phil would need a parser rule to discard the token.  Something like:

//Convert ID from a fragment to a token
ID: ALPHA (ALPHA | INT)*;
EXT: 'EXT.';
external_call: EXT! ID;

rule: call=external_call '(' { stack.push(new
        FuncName($call.text)); } (expressList { ... } )? ')'
        expressList: ...;



Colin Macdonald
Senior Consultant
_____________________________________ 

GROUP Business Software
Phone: 770 720 1300 ext: 6132

http://www.gbs.com/




From:   "Jim Idle" <jimi at temporal-wave.com>
To:     <antlr-interest at antlr.org>
Date:   2010-11-17 11:19 AM
Subject:        Re: [antlr-interest] Is '!' operator working with ANTLR 
3.1.2
Sent by:        antlr-interest-bounces at antlr.org



Remember antlr.markmail.org 

This operator is not supported in ANTLR3 for performance reasons. But if 
the
pieces you don't want are at the start or end, then you can just change 
the
start and/or end points of the token.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Philippe Frankson
> Sent: Wednesday, November 17, 2010 4:51 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Is '!' operator working with ANTLR 3.1.2
> 
> 
> When I call my parser with -> EXT.MyFunc() The value returned by
> $EXTERNAL_CALL.getText() is 'EXT.MyFunc' where I would expect to have
> only 'MyFunc' (because I'm using the '!' operator in the lexer here
> below).
> 
> fragment INT                           : ('0'..'9');
> fragment ALPHA                                 : 
('a'..'z'|'A'..'Z'|'_');
> fragment ID                                            : ALPHA (ALPHA | 
INT)*;
> 
> EXTERNAL_CALL: 'EXT.'! ID;
> 
> 
> rule: EXTERNAL_CALL '(' { stack.push(new
> FuncName($EXTERNAL_CALL.getText())); } (expressList { ... } )? ')'
> expressList: ...;
> 
> 
> Any idea why the '!' operator looks like not working ? What am I doing
> wrong ?
> 
> Thank you.
> Philippe Frankson
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


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



More information about the antlr-interest mailing list