[antlr-interest] Clarification on documentation

Alexey Demakov demakov at ispras.ru
Tue Aug 23 05:18:14 PDT 2005


----- Original Message ----- 
From: "Ciaran Treanor" <ciaran.treanor at gmail.com>
To: "Alexey Demakov" <demakov at ispras.ru>
Sent: Tuesday, August 23, 2005 3:55 PM
Subject: Re: [antlr-interest] Clarification on documentation


> HI Alexey - thanks for the response. Unfortunately my keywords aren't
> keywords in the traditional sense. My keywords are a constant prefix
> suffixed with an integer (see my followup mail).
> 
> I'd really appreciate any help here. I've tried a number of approaches
> (obviously I'm an antlr newbie) and now I'm stuck with the following
> error:
> 
> expecting THING_ID, found THING123

So, you want to match any tokens of the following structure:

protected DIGIT : '0'..'9' ;

THING_ID: "Thing" ( DIGIT )+ ;

And where is the problem? Do you want to qualify Thing456 as ID instead of THING_ID
if Thing456 was not defined? You can check for it in code:

THING_ID
: "Thing" ( DIGIT )+ 
  { if( !isDefined( $getText ) ) $setType( ID ); }
;

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com




More information about the antlr-interest mailing list