[antlr-interest] matchRange in parser?

Jim Idle jimi at temporal-wave.com
Tue Jul 24 08:50:52 PDT 2007


Your use of lexer ranges in parser rule is addressed in another
response, but you have also written a yacc style definition of
systemIdList, you need to expunge yacc from you mind ;-) :

systemIdList : systemId (',' systemId)* ;

Jim 

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of jrc at skylon.demon.co.uk
> Sent: Tuesday, July 24, 2007 6:39 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] matchRange in parser?
> 
> Should the following work?
> ----------------------------------------------------------------------
> grammar Simple;
> line         : systemIdList NEWLINE ;
> systemIdList : systemId | systemId ',' systemIdList ;
> systemId     : '0'..'9' ;
> NEWLINE      : '\r'? '\n' ;
> ----------------------------------------------------------------------
> Here's what I get:
> ----------------------------------------------------------------------
> $ java org.antlr.Tool Simple.g
> ANTLR Parser Generator  Version 3.0 (May 17, 2007)  1989-2007
> $ javac *.java
> SimpleParser.java:119: cannot find symbol
> symbol  : method matchRange(char,char)
> location: class SimpleParser
>             matchRange('0','9');
>             ^
> 1 error
> ----------------------------------------------------------------------
> Swapping 'systemId' (parser rule) to 'SystemId' (lexer rule) causes
> matchRange() to be found ...
> --
> John Connett
> 



More information about the antlr-interest mailing list