[antlr-interest] Lexer vs Parser

Matthew Ford Matthew.Ford at forward.com.au
Mon May 20 16:15:29 PDT 2002


My general rule is make the final decision as early as possible.
This simplifies the later processes and enhances error detection.
matthew
----- Original Message -----
From: "micheal_jor" <open.zone at virgin.net>
To: <antlr-interest at yahoogroups.com>
Sent: Tuesday, May 21, 2002 5:31 AM
Subject: [antlr-interest] Lexer vs Parser


> Hi All,
>
> Following on from my Unicode post, I would appreciate some advice on
> where to place some lexing/parsing decisions.
>
> For instance with my definitions for Unicode categories, the
> characters to be recognized include the individual characters in the
> category as well as Unicode escape sequences that resolve to a
> characters in the category.
>
> This what I did in the lexer:
>
> protected UNICODE_CLASS_Nl
>   : ( { IsUnicodeClass_Nl(LA(1)) }? .
>     | { IsUnicodeClass_Nl(esc_char.getText()) }?
> esc_char:UNICODE_ESCAPE_SEQUENCE
>     )
>   ;
>
> My question is should I be checking that the escape sequence resolves
> to a character in the category in the Lexer or should that be
> postponed to the Parser's battery of semantic analysis.
>
> In general, what is a good rule of thumb for deciding what goes into
> a Lexer or a Parser. With Flex/Bison it is much easier since the
> lexer/parser have very different capabilities.
>
> What do you fine people suggest?
>
>
> Cheers,
>
> Micheal
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list