[antlr-interest] Interpretation of Parser Rule w/ Alternative Lexer RHS

Randall R Schulz rschulz at sonic.net
Sun Nov 12 17:37:33 PST 2006


Hi,

I have a question about the meaning of a rule such as this:

name
	:	LowerWord
	|	SingleQuoted
	|	UnsignedInteger
	;


LowerWord is an initial lower-case followed by any number (including 
zero) alphanumeric characters. Singlequoted is a classic quoted string 
using single quote marks. Unsigned integer is an integer with no sign, 
i.e. one or more decimal digits.

When I look at this rule in ANTLRworks Syntax Diagram view, it shows:

    +--------------------------+
----|LowerWord..UnsignedInteger|---
    +--------------------------+

I know how to interpret 'a'..'z' in these diagrams (I think) but not 
this notation using lexer rule names.


When I use the interpreter in ANTLRworks it will not match an input that 
is a match for LowerWord ("irreflexivity_gt", e.g.).

However, the same input _is_ matched successfully against LowerWord 
directly (in the ANTLRworks interpreter).

So I'm confused about how lexer rules are interpreted when reference 
from parser rules. How do I write a parser rule that can accept one of 
several lexeme types?


Can someone clarify this?

Thanks.


Randall Schulz


More information about the antlr-interest mailing list