[antlr-interest] Identifiers starting with numbers

Thomas Brandon tbrandonau at gmail.com
Wed Jul 19 20:37:25 PDT 2006


Or is it that identifiers can start with a number but must still
contain a letter somewhere? If so then (under Antlr 2.7.6 anyway) you
will need to match identifiers starting with a number in your numeric
literal rule and set the token type. Something like:
NUMBER: DIGIT ( DIGIT | LETTER { _ttype = IDENT; } )*;
should do it.

Tom.
On 7/20/06, Martin Probst <mail at martin-probst.com> wrote:
> Hi,
>
> > In our scripting language, the identifier can start with numbers. We
> > changed IDENT to be like this
>
> So what is the lexical difference between an identifier and a number?
> How do you decide if the single token: '5'
> is a number or an identifier? Or 55123 for that matter?
>
>
> Regards,
> Martin
>
>
>


More information about the antlr-interest mailing list