[antlr-interest] digit-ended literals (was New faq entries - import/export)

Bogdan Mitu bogdan at nobugconsulting.ro
Tue Oct 30 10:45:15 PST 2001


> Isn't the "if0" in the .txt (persistence) file?  That should be how it
> communicates.
>
> Ter

Yes, "if0" is in the .txt file, as
"if0"=4

By contrast, "if" is written in .txt file as
LITERAL_if="if"=4
and can be referred from outside as XxxTokenTypes.LITERAL_if.

My question is why "if0" is treated different then "if". When I wrote a
syntax highlighter for Verilog, I wanted to associate keywords with colors
using a property file, and I went into some trouble because Verilog has
digit-ended keywords, and the only way to refer them was by some ever
changing numbers. Not that it would be a great deal, I am just wondering.

Regards,
Bogdan


----- Original Message -----
From: "Terence Parr" <parrt at jguru.com>
To: "Bogdan Mitu" <bogdan at nobugconsulting.ro>
Cc: <antlr-interest at yahoogroups.com>
Sent: Tuesday, October 30, 2001 7:57 PM
Subject: Re: [antlr-interest] digit-ended literals (was New faq entries -
import/export)


>
> On Tuesday, October 30, 2001, at 04:30  AM, Bogdan Mitu wrote:
>
> > ----- Original Message -----
> > From: "Terence Parr" <parrt at jguru.com>
> >
> >> What exactly is the bug you refer to?  "if0" is specifically a literal
> >> that doesn't work or is the whole literals scheme broken from your
> >> perspective?
> >>
> >> Ter
> >
> > I looked more closely to what is generated, and it's not a bug, indeed,
> > but
> > still is something weird. If I have a string "if" in the parser, it
> > generates an entry:
> > int LITERAL_if = 4
> > in the interface XxxParserTokenTypes.java
> >
> > But if the string is "if0", the generated line is just a comment:
> > // "if0" = 4
> >
> > I thought this is a bug, but it works, because a number is still
> > reserved
> > for the token. There is still a problem, however: if I want to refer the
> > tokens from outside, I can only use the number (in this example 4), and
> > this
> > number is likely to change whenever I change the grammar. I don't see
> > any
> > reason why literals ended with digits are treated different.
> >
>
> Isn't the "if0" in the .txt (persistence) file?  That should be how it
> communicates.
>
> Ter



More information about the antlr-interest mailing list