[antlr-interest] A proposal for keywords

shmuel siegel antlr at shmuelhome.mine.nu
Tue May 23 15:50:04 PDT 2006


Loring Craymer wrote:
>...
> For option 2, literal types should be bound in the parser:  that is, the 
> lexer binds the generic type to the token (TEXT or NUMBER, for example) 
> and the dynamically looks up the next token in the literals table 
> whenever attempting to match a literal.  That is, “if” would be first 
> typed as TEXT but matched (and retyped) as LITERAL_if when matching an 
> occurrence of “if” in the parser.
> 

Why are you limiting yourself to this type of situation. Why don't we 
expand the concept. Why not let the lexer return a set of token types 
that match the TEXT. The parser rule would have to resolve the 
ambiguity. The grammar rule would be considered ambiguous if the parser 
would accept two different types that had the same TEXT.

Let's say that I have a positional parameter in a function call that can 
take on the number zero or an empty string (I actually have such a 
grammar). It would be nice to be able to specify this explicitly 
(without predicates) even though "zero" is also an "integer" and "empty 
string" is also a "string".

Or is this what you are saying?

Shmuel


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006



More information about the antlr-interest mailing list