[antlr-interest] Problem with existence of the same literal in two rules

ramyasivadas ramyasivadas at yahoo.co.in
Wed Apr 30 04:49:45 PDT 2003


Hi,

Let me quote an example to help me explain the problem.

I have a rule as follows
STRING
:('a'..'z' | 'A'..'Z')+ (INT)
;

I also have a rule
WFCS
:'L'|'H'|'Z'|'X'
;

INT
:('0'..'9')+
;

The issue is, if I have a set of literals constituting a rule and if 
one or more of the same literals form a part of another independent 
rule, the parser generates an exception. How can I avoid this.

For example, the rule STRING is defined to be made up of a 
combination of any alphabets followed by a numeral. Another rule WFCS 
which has nothing to do with STRING can be made up of a combination 
of L,H,Z and/or X.

When the parsing for WFCS block is done, the parser expects an INT 
after the alphabet. I assume it is applying the STRING rule on the 
WFCS block since it has encountered an alphabet. Can we override this 
behaviour.


Thanks in advance.

Regards,
Ramya


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list