|lexing backwards firstname.lastname@example.org (Stefan Monnier) (2003-04-05)|
|Re: lexing backwards email@example.com (2003-04-07)|
|Re: lexing backwards firstname.lastname@example.org (Chris F Clark) (2003-04-07)|
|Re: lexing backwards email@example.com (Marat Boshernitsan) (2003-04-07)|
|Re: lexing backwards firstname.lastname@example.org (Stan Zaborowski) (2003-04-13)|
|Re: lexing backwards Ron@Profit-Master.com (Ron Pinkas) (2003-04-13)|
|Re: lexing backwards email@example.com (Stefan Monnier) (2003-04-15)|
|Re: lexing backwards cfc@TheWorld.com (Chris F Clark) (2003-04-15)|
|Re: lexing backwards firstname.lastname@example.org (2003-05-06)|
|Re: lexing backwards Ron@Profit-Master.com (Ron Pinkas) (2003-05-14)|
|Re: lexing backwards Ron@Profit-Master.com (Ron Pinkas) (2003-05-16)|
|[3 later articles]|
|From:||"Stan Zaborowski" <email@example.com>|
|Date:||13 Apr 2003 12:18:16 -0400|
|Organization:||Posted via Supernews, http://www.supernews.com|
|Posted-Date:||13 Apr 2003 12:18:16 EDT|
"Chris F Clark" <firstname.lastname@example.org> wrote in message
> There is no trick to lexing backwards. Lexing locally, however, is in
> general impossible.
Chris, I was in total agreement with you until I got to thinking about
comments. And in particular I am thinking about languages that do not
have a closing comment delimiter but use end-of-line as the closing
delimiter. Examples would be "//" in C++ and "#" in Perl.
So attempting to parse backwards would create tokens that must be
thrown away once you realize that you are in a comment. This doesn't
seem too bad for C++. But consider what happens with Perl. You may
not use quoted strings which contain an end-of-line in C++. (Note you
can include a new-line "\n" which is different from end-of-line). But
there is no such restriction in Perl. And the comment delimiter can
be put inside a quoted string.
So you would have to parse back to the beginning of the program before
you can decide that a single quote mark is part of a comment and not a
This might sound unlikely, but Perl programmers often create Perl
programs that write Perl programs. So a large number of what may seem
like Perl tokens are actually only part of a string. And people do
put comments for the generated program inside this string.
Return to the
Search the comp.compilers archives again.