[Grace-core] Comment proposal
Andrew P Black
andrew.p.black at gmail.com
Wed Feb 4 14:58:50 PST 2015
On 4 Feb 2015, at 12:46 , Michael Homer <mwh at ecs.vuw.ac.nz> wrote:
> In particular, if you have to understand what a "syntactic unit" is
> and is not, it's not predictable. Novice programmers are not
> linguists.
This is a good point. A layout rule like Fortran's (C in column 6) or a lexical rule like Algol's (; comment ... ; can appear where a ; could appear) can be applied without understanding the language structure.
Unfortunately, such rules don't tell us what we need to know: where in the parse tree the comments belong. They also don't let the programmer
put short, partial-line comments close to the things that they wish to comment upon — which is, I believe, why modern languages use more flexible rules.
I like Lex's proposal of specifying where comments can go, and what they mean. Something like:
• at the end of a line, (but not at the end of a continuation that is continued on the following line).
Such comments attach to the first declaration or expression on that line.
• Following an opening { or (, that is, separated from the opening bracket only by newlines and spaces.
Such comments attach to the whole unit surrounded by the { or ( and the matching closing bracket.
These may be all that we need. Of course, interpreting such rules still means that the reader has to understand a what a declaration or expression is. Hence my contention that we should work on a publication grammar first, and then worry about comments.
Andrew
More information about the Grace-core
mailing list