Related articles |
---|
[4 earlier articles] |
Re: Java Comment-Preserving Grammar dobes@dobesland.com (Dobes Vandermeer) (2004-05-30) |
Re: Java Comment-Preserving Grammar tbauer@cadrc.calpoly.edu (Tim Bauer) (2004-05-30) |
Re: Java Comment-Preserving Grammar jens.troeger@light-speed.de (2004-06-06) |
Re: Java Comment-Preserving Grammar clint@0lsen.net (Clint Olsen) (2004-06-06) |
Re: Java Comment-Preserving Grammar gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-06-09) |
Re: Java Comment-Preserving Grammar cfc@shell01.TheWorld.com (Chris F Clark) (2004-06-11) |
Re: Java Comment-Preserving Grammar alexc@std.com (Alex Colvin) (2004-06-13) |
Re: Java Comment-Preserving Grammar gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-06-13) |
Re: Java Comment-Preserving Grammar cfc@shell01.TheWorld.com (Chris F Clark) (2004-06-15) |
From: | Alex Colvin <alexc@std.com> |
Newsgroups: | comp.compilers |
Date: | 13 Jun 2004 11:18:20 -0400 |
Organization: | The World : www.TheWorld.com : Since 1989 |
References: | 04-05-075 04-06-004 04-06-022 04-06-041 |
Keywords: | Java, parse |
Posted-Date: | 13 Jun 2004 11:18:20 EDT |
>> Scanner Usually Skips Over Comments In The Source Code Already,
>> Such That The Parser Doesn'T Even See Them. However, You Can Write
>> Your Own Scanner And Parser, That Make Comments Explicit In The Grammer.
>> But If You Want To Allow Comments _Anywhere_ In Yout Language, The
>> Good Luck!! :-) That Grammar Is Going To Be A Mess....
>> Would it be that hard? Most languages that I know
>> of allow comments in places where blank space is allowed.
Many languages allow space/comments between any adjacent tokens. In such
cases, you could replace every <token> in the grammar with
<token><whitespace/comment?> (with some extra cruft at the start).
But this (regular) behavior is can also be captured in the lexer by
associating the whitespace/comment to the preceding token. Or maybe the
following.
--
mac the naïf
Return to the
comp.compilers page.
Search the
comp.compilers archives again.