Hi,

I have an issue with a parser that is using certain keywords within the parser 
rules, and these keywords can also appear as random identifiers in other rules. 
When this happens, the parser reports an error, and I see no way to avoid this. 
The grammar and the test input can be found below.
When the parser reaches the second HELLO rule, it stumbles on the token 
MEASUREMENT (evidently because it's present as a word in the meas rule). Is 
there a workaround for this?

Thanks
Anders

Grammar (testkeyword.g):
----------------------------------------------------

grammar testkeyword;

prog    : body+ ;       
body    :  meas | words         ;
        
meas    :       
        BEGIN 'MEASUREMENT'
                INT
        END 'MEASUREMENT' ;
        
words   :       
        BEGIN id1=ID
                INT ID+
        END id2=ID ;

BEGIN   :       '/begin';
END     :       '/end';

ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
INT :   '0'..'9'+ ;
WS  :   ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;}  ;


Test input:
-----------------------------------------------------------
/begin HELLO
        13 I say hello
/end HELLO
/begin MEASUREMENT
        44
/end MEASUREMENT
/begin HELLO
        55 Use MEASUREMENT word
/end HELLO






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