Related articles |
---|
[20 earlier articles] |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) plong@perf.com (1995-05-11) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) stidev@gate.net (1995-05-12) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) rabin@CS.YALE.EDU (1995-05-12) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) plong@perf.com (1995-05-12) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) bevan@cs.man.ac.uk (1995-05-15) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) bevan@cs.man.ac.uk (1995-05-15) |
Re: The semicolon habit (was: Q: Definition of a scripting lang.) Charles.Fiterman@bluebird.uchicago.edu (1995-05-28) |
Newsgroups: | comp.compilers |
From: | Charles.Fiterman@bluebird.uchicago.edu |
Keywords: | design, syntax |
Organization: | Geodesic Systems |
References: | 95-04-013 95-05-104 |
Date: | Sun, 28 May 1995 22:47:01 GMT |
Stephen J Bevan <bevan@cs.man.ac.uk> wrote:
>Stefan Monnier <monnier@di.epfl.ch> writes:
> ... Wouldn't it be so much easier to store your source as a syntax-tree ?
>
>I theory I agree, but practice seems to be lagging a long way behind
>(examples to the contrary are welcome). One of the thorniest problems
>is what to do with comments i.e. what syntactical construct to you
>attach a comment to? If you have the luxury of working with a new
>language these issues can be taken into account in the language
>design, but with legacy code/languages things are tougher without
>resorting to style guides and their enforcement. Once you do that
>you'll find you've solved most of the problem without the need for
>syntax tree storage.
>[Editing a syntax tree is a pain, too, since editing operations you do on
>source text rarely map cleanly to syntax changes. -John]
There are a few problems with comments. The first is how to
distinguish 3 comments on 3 lines from 1 comment on 3 lines.
a <- b # initialize three fields
b <- 12 ## this continues the first comment.
c <- 13 # this is an independent comment.
I like the notion of ## continuing the previous comment.
The # operator says the comment until end of line but attaches the
comment to the expression to the left. That is the first comment
is on the expression a = b. Where there is no expression to the
left # binds the comment to the expression under the comment.
# this comment describes a function
## it binds to the definition because there
## is nothing to the left.
sqrt : real
x : in real
Now we need something to bind a comment to something less than
a line.
a = b #? [b is an initial value]
Binds the string [b is an initial value] to b as a comment.
It is unusual to have comments bound to parts of lines so this
can be a little verbose.
Since the parser or interactive code builder creates trees,
and since the trees can be viewed by many users the distinction
between comment and code is a little slippery. To a debugger
viewing a tree a comment is a sort of instruction. We also have
the problem of directing specially formatted comments to special
viewers. I like
#(text_formater) escape
As a way of directing a comment to a specific viewer.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.