Re: Java Comment-Preserving Grammar

Chris Dodd <cdodd@acm.org>
30 May 2004 13:20:16 -0400

          From comp.compilers

Related articles
Java Comment-Preserving Grammar matthew-google@faredge.com.au (2004-05-24)
Re: Java Comment-Preserving Grammar sreeni@viswanadha.net (Sreenivasa Viswanadha) (2004-05-30)
Re: Java Comment-Preserving Grammar martin@cs.uu.nl (Martin Bravenboer) (2004-05-30)
Re: Java Comment-Preserving Grammar cdodd@acm.org (Chris Dodd) (2004-05-30)
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)
[3 later articles]
| List of all articles for this month |
From: Chris Dodd <cdodd@acm.org>
Newsgroups: comp.compilers
Date: 30 May 2004 13:20:16 -0400
Organization: Compilers Central
References: 04-05-075
Keywords: Java, parse
Posted-Date: 30 May 2004 13:20:16 EDT

matthew-google@faredge.com.au (Matthew Herrmann) wrote


> My end goal is to parse commented-out extensions to the java language:
>
> class /*#immutable*/ Blah {
>
> public /*#input*/ int x;
> public /*#result*/ int y;
>
> }
>
> Any suggestions appreciated,


Comments are usually handled by the lexer/tokenizer,, not the parser, and
are just stripped out and thrown away. So the usual way to deal with this
sort of thing is to modify the lexer to recognize your "special" comments
and return keyword tokens for them. Then you just modify the grammar to
accept and deal with these extra keywords where appropriate.


Chris Dodd
cdodd@acm.org


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.