[antlr-interest] lexical nondeterminism between IDENT & LABEL
Paul J. Lucas
pauljlucas at mac.com
Wed Nov 3 11:36:41 PST 2004
On Wed, 3 Nov 2004, John D. Mitchell wrote:
> >>>>> "thoth2487" == thoth2487 <thoth2487 at libero.it> writes:
>
> > Hi to all, I've a very simple language in which there are IDENTifiers and
> > jump LABELs. An IDENTifier start with ('a'...'z')|('A'..'Z') and continue
> > with ('a'...'z')|('A'..'Z')|('0'..'9') and a LABEL is like an IDENTifier
> > but ends with a ':'. When I try following .g I obtain always a lexical
> > nondeterminsim which I isn't to solve:
>
> Stop trying to do that in the lexer. Let the lexer return the ID for both
> and then have your parsing rules distinguish between ID ":" being a label
> or the ID is just an ID.
What's wrong with using a syntaxtic predicate in the lexer?
Just because a label happens to have the same character pattern
as an identifier doesn't mean it's conceptually the same kind
of token.
Since ANTLR has a much more powerful lexer than most, why not
take advantage of it?
- Paul
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list