[antlr-interest] Literals, Predicates and Actions

Julian Mensch jmensch at shaw.ca
Fri Mar 6 13:27:28 PST 2009


> No, you cannot do this. I strongly advise that you do not use 
> literals 
> in your grammar. 

  Oh. That sucks.

> Well, it is just re-inventing the wheel really. I understand 
> where you are coming from, but if you go with what the tool
> does now, you will soon find it all second nature.

  I have to cope with Pascal/Delphi at my day job, and as
a result I find programming languages that try to enforce
the designer's conception of best practices over the coder's
conception really distasteful. Still, I have very little experience
with ANTLR, so I will try to go with the grain for now.

> use $type where you can of course.

  Thanks for the heads-up; I'll watch for that.

> I tend not to use the ident 
> method, I 
> just use an identifier rule that allows the keywords. 

  I don't understand what you're talking about here. You
mean you just use a single IDENT token and check for
keywords with syntactic predicates that test token
attributes?

  That sounds like it would make the grammar really
hard to read -- unless, I guess, you make a /parser/
rule for every keyword, which could then be parse-
context sensitive. I never thought of that till now.

-- Julian Mensch


More information about the antlr-interest mailing list