Hi,
This is my sample grammar.. this did not work.. another thing is
that my variables and connectors both can have digits so I created Alpha
: LETTER (LETTER | DIGIT)*; for this but it also give an error.
primitiveType
: 'real'
| 'integer'
| 'char'
| 'boolean'
| 'void'
;
CONNECTOR : LETTER+ ('In' | 'Out');
ID: LETTER+ ;
fragment LETTER : ('a'..'z' | 'A'..'Z') ;
fragment DIGIT : '0'..'9';
INT : DIGIT+ ;
Regards
Roohul
S/W Engineer, LIU, Sweden
--- On Thu, 2/10/11, Bart Kiers <[email protected]> wrote:
From: Bart Kiers <[email protected]>
Subject: Re: [antlr-interest] Ident with ending In or Out word
To: "Roohul" <[email protected]>
Cc: "ANTLR" <[email protected]>
Date: Thursday, February 10, 2011, 10:40 AM
On Thu, Feb 10, 2011 at 6:08 PM, Roohul <[email protected]> wrote:
Hi,
I am working on a grammar which have some variables ending with In or Out which
is treated as the connector between two components. I do not know how to handle
this.
For example:
real abcIn
real abcOut
these are treated as connectors. while abcI or abcOu will be treated as normal
variables.
You could handle this on a "lexer level" like this:
REAL : 'real'
;
CONNECTOR : Alpha+ ('In' | 'Out')
;
VARIABLE : Alpha+
;
fragmentAlpha : 'a'..'z' | 'A'..'Z' ;
(the order of the rules is important here!)
Regards,
Bart.
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.