[comp.lang.modula2] FYI: M2 Comments

nagler@seismo.CSS.GOV@olsen.UUCP (Robert Nagler) (03/10/87)

Did any language implementers out there ever notice that Wirth does
not define the syntax of a "comment" in the "Syntax of Modula-2" in
the back of PIM2. They don't appear in the railroad diagrams, either.
He mentions them on page 16 (3rd edition), but even there
he doesn't mention that they can be nested.  I realized this after
playing with EBNF for some language stuff and found it very
difficult to describe "arbitrary sequences of characters" in EBNF.

My question is: "Was it an oversight or was it intentionally avoided?"

Rob

PS. Don't bother looking in the index, they aren't mentioned there.

farnum@renoir.Berkeley.EDU (Charles D. Farnum) (03/10/87)

In article <8703101615.AA14931@frey.olsen.uucp> nagler@seismo.CSS.GOV@olsen.UUCP (Robert Nagler) writes:
>Did any language implementers out there ever notice that Wirth does
>not define the syntax of a "comment" in the "Syntax of Modula-2" in
>the back of PIM2. They don't appear in the railroad diagrams, either.

You'll also notice that spaces, tabs, and newlines aren't included in the
syntax descriptions.  Doing so would be very tedious --- a comment
can appear between any two symbols of the program.  Some heirarchy is 
generally imposed to keep things manageable, both in the descriptions and
in compilers; at the syntactic level, details concerning the composition of
individual tokens and whitespace (blanks, tabs, newlines, comments, etc)
are generally ignored, having already been covered in some lexical 
description.  Wirth does include the spelling of numeric constants
and identifiers in his ``syntax description'', but this is not normal.

The definition of comments, including the fact that they nest, is in section 3,
part 5 of the Report (bottom of page 145 in the 3rd edition of PIM-2).

  /charlie

tla@kaiser.UUCP (03/13/87)

>	Did any language implementers out there ever notice that 
>	Wirth does not define the syntax of a "comment" in the 
>	"Syntax of Modula-2" in the back of PIM2. They don't 
>	appear in the railroad diagrams, either. He mentions 
>	them on page 16 (3rd edition), but even there he
>	doesn't mention that they can be nested.  I realized this 
>	after playing with EBNF for some language stuff and found 
>	it very difficult to describe "arbitrary sequences of 
>	characters" in EBNF.
>
>	My question is: "Was it an oversight or was it intentionally
>	avoided?"
>
>	Rob
>
>	PS. Don't bother looking in the index, they aren't mentioned 
>	there.

There is one more reference, (ed 3) page 145, where it IS stated that
comments CAN be nested.  And both ARE in my index under "comment".  
You may have missed it because of its being in the second column 
or maybe is was missing from the older first printing (mine is the
"Third, corrected edition".  

I find the odd ordering of the index annoying ie
	a	b
	c	d
	e	f
rather than 
	a	d
	b	e
	c	f
The columns are toooo far apart for the first ordering to 
be easy to use.  Does anyone LIKE it?

Back to comments, I imagine they are missing from the syntax
(both EBNF and railroad) because they are not considered a part
of the "language" ie they are removed and replaced by white space
during lexical analysis and not seen by the parser.

			     --	Terry L Anderson
				AT&T Bell Laboratories -- Liberty Corners
				UUCP:     ...!ihnp4!daimler!kaiser!tla
				TeleMail: Terry.Anderson
				(201) 580-4428