[antlr-interest] lexer: matching float vs int
Jim Idle
jimi at temporal-wave.com
Tue Sep 9 12:15:54 PDT 2008
On Tue, 2008-09-09 at 13:10 -0500, Sam Harwell wrote:
> Here is the numeric lexer section of a C++ grammar. This method is
> very different from Jim’s method, as it doesn’t use any semantic
> predicates,
See the leading points in the article, being that ANTLR is working out
the lookahead for you, whereas the example is minimal in this regard,
you don't have a range operator '..' here and the only language specific
things are input.LA(), which is just LA() in C. Finally, your code does
not accommodate erroneous input, it will just throw lexer exceptions. If
you are using IDEs or want good error messages from a parser, then you
need to code for that rather than try to intercept exceptions and work
it out afterwards.
But use whatever flaots your boat ;-). The examples was just for all the
new people that find this particular problem very thorny :-)
Jim
> and has no dependency on the target language. I
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080909/ba00f350/attachment.html
More information about the antlr-interest
mailing list