[antlr-interest] Scanning whether a dot is part of a keyword or of a namespace.
Niek Sombekke
sombekke at gmail.com
Thu Sep 14 07:01:57 PDT 2006
Hi all,
The problem I have can be described as follows. I'm trying to write a lexer
to scan a .NET IL file. A number of keywords in IL can contain a dot.
E.gboth next instructions are valid.
tokens
{
DOT_ASSEMBLY = ".assembly" ;
ASSEMBLY = "assembly";
}
On the other hand, it is possible to have a namespace System.Object, which
after scanning should deliver the tokentypes
System - ID
. - DOT
Object - ID
While testing a bogus line, e.g. ".assembly System.Object", my scanner
delivers (depending on my grammar) either the tokens
.assembly - DOT_ASSEMBLY
System - ID
.Object - ID
or
. - DOT
assembly - ASSEMBLY
System - ID
. - DOT
Object - ID
Obviously, both are incorrect! In the first case, the '.' should be
seperated from 'Object'. In the second case, the '.' should be combined with
'assembly' making it a DOT_ASSEMBLY token.
How can I let ANTLR determine whether the dot is part of a keyword, or that
it seperates two identifiers within a namespace?
-- Niek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060914/5ffb2268/attachment-0001.html
More information about the antlr-interest
mailing list