|[3 earlier articles]|
|Re: Incorporating comments in syntax tree? email@example.com (1996-02-01)|
|Re: Incorporating comments in syntax tree? firstname.lastname@example.org (Dave Gillespie) (1996-02-02)|
|Re: Incorporating comments in syntax tree? email@example.com (Nadav Aharoni) (1996-02-02)|
|Re: Incorporating comments in syntax tree? firstname.lastname@example.org (Charles Fiterman) (1996-02-02)|
|Re: Incorporating comments in syntax tree? Uwe.Assmann@inria.fr (1996-02-09)|
|Re: Incorporating comments in syntax tree? email@example.com (Greg Titus) (1996-02-13)|
|Re: Incorporating comments in syntax tree? Conor@puddle.demon.co.uk (Conor O'Neill) (1996-02-23)|
|From:||"Conor O'Neill" <Conor@puddle.demon.co.uk>|
|Date:||23 Feb 1996 00:19:33 -0500|
"A. Grant" <firstname.lastname@example.org> writes
>Does anyone know of any techniques for reading comments in compiler
>input and associating them with the syntax tree, e.g. for debugging
>("what has been said about variable X"), inclusion in assembler output
>or translation into a different language? The trick being to maximise
>flexibility in placing comments while being able to make good guesses
>about what they refer to.
>[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]
Occam 2 has various rules applicable to comments to aid this.
Basically, comments are indicated by '--', and are either
a) On the end of a line - which therefore apply to the statement
on that line
b) Indented to the same level as following code, and therefore apply
to that code.
(Note that occam has fixed indentation rules for all syntax)
The intention of these rules is specifically to permit the compiler to
associate the comment with the appropriate statment. However, as far
as I know, no compilers have really made use of this, and they cause
many complaints from programmers used to more 'flexible' languages.
(Curiously enough, it also causes problems for some compiler-generated
In later INMOS occam compilers the indentation rules were (are?)
dropped, and comments are discarded in an early parse phase.
Conor O'Neill, at home in Bristol, UK
Return to the
Search the comp.compilers archives again.