[antlr-interest] Re: lexical nondeterminism between IDENT & LABEL

Anthony Youngman Anthony.Youngman at ECA-International.com
Fri Nov 5 01:24:27 PST 2004


I don't know the OP's language, but I do know (very well) the AREV class
of languages that Monty mentioned.

And the original lexer that parsed that language used a "state
transition table". It's damn difficult to implement that table in an
ANTLR lexer. It's damn difficult to implement that table in an ANTLR
parser.

But creating a filter between the lexer and parser, who's sole purpose
is to provide semantic analysis of the token stream from the lexer
before it gets to the parser, makes analysing these languages a doddle.

Currently the lexer does both token and semantic analysis. It works a
lot of the time. But for some languages its a disaster, and it would be
nice to be able to split the two jobs apart.

Cheers,
Wol

-----Original Message-----
From: John D. Mitchell [mailto:johnm-antlr at non.net] 
Sent: 04 November 2004 17:01
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: lexical nondeterminism between IDENT &
LABEL


Well, I don't know what language you're trying to build so it's hard to
give you specific advice.

If your label construct is truly syntactic then using the fixed version
of
Monty's example of doing it in the lexer is a reasonable approach.

However, if the colon is is overloaded (like '.' in the C language) but
the
ambiguities are all purely syntactic in nature then doing the more
complicated factoring as exemplified by the Number rule in the StdC
lexer
is a reasonable approach.

However, if the ambiguities related to ':' in your language require
semantic context then how you should resolve it in the parser depends on
the semantics of the language.  For an example of this, check out the
StdCParser.g and look for the rules using COLON.



****************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

****************************************************************************



 
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