Re: Incorporating comments in syntax tree?

Steve_Kilbane@cegelecproj.co.uk (Steve_Kilbane)
31 Jan 1996 23:25:47 -0500

          From comp.compilers

Related articles
Incorporating comments in syntax tree? ag129@ucs.cam.ac.uk (1996-01-30)
Re: Incorporating comments in syntax tree? Steve_Kilbane@cegelecproj.co.uk (1996-01-31)
Re: Incorporating comments in syntax tree? ok@cs.rmit.edu.au (1996-02-01)
Re: Incorporating comments in syntax tree? solution@gate.net (1996-02-01)
Re: Incorporating comments in syntax tree? synaptx!thymus!daveg@uunet.uu.net (Dave Gillespie) (1996-02-02)
Re: Incorporating comments in syntax tree? nadav@cc.huji.ac.il (Nadav Aharoni) (1996-02-02)
Re: Incorporating comments in syntax tree? cef@geodesic.com (Charles Fiterman) (1996-02-02)
Re: Incorporating comments in syntax tree? Uwe.Assmann@inria.fr (1996-02-09)
[2 later articles]
| List of all articles for this month |

From: Steve_Kilbane@cegelecproj.co.uk (Steve_Kilbane)
Newsgroups: comp.compilers,comp.compilers.tools.pccts
Date: 31 Jan 1996 23:25:47 -0500
Organization: DSDIC Team, Cegelec Projects Ltd.
References: 96-01-121
Keywords: analysis, syntax

ag129@ucs.cam.ac.uk (A. Grant) writes:
> Does anyone know of any techniques for reading comments in compiler
> input and associating them with the syntax tree [...] .


The approach I've used in the past -- admitted in desperation -- was
to include an additional type of comment which was part of the syntax.
Normal comments in the language were delimited with "(* ... *)", and
were stripped by the scanner as normal. Comments delimited with "(**
... **)" were converted into comment tokens, which were allowed at
significant points in the grammar - such as after variable
declarations. This made the grammar hugely unwieldy, but it did
work. I was slightly consoled when I discovered that Sun's Java uses a
similar (if not identical) technique. :-)


> [The most common technique I know of is to hang them from the preceding or
> following token, or if you're feeling clever, maybe a nearby control
> structure to which they seem to apply. I've never heard of a technique
> that was entirely satisfactory. -John]


Indeed. I tried this approach first. All the comments next to
variables moved up one variable. :-)


steve
--
<Steve_Kilbane@cegelecproj.co.uk>
--


Post a followup to this message

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