Compiler version: 10.2017
What I like about C++ style comments: they need not be terminated, that is: you can start them by two slashes and they terminate automatically at the end of the line.
In my money job, I am coding in C and PL/1 most of the time, and the C compilers today most often have a compiler option that allows C++ style comments on C programs, too, and this is used by me and my co-workers all the time.
The new scanner PASSCAN was introduced with the idea in mind, that C++ style comments should be possible in Stanford Pascal, too.
When I started working on the details, I soon discovered that it would be better to let the scanner only handle the comment starting symbol and to do the other comment handling manually. Well, that's not quite right: the comment handling is done by hand-written logic, but inside the skeleton which is used by the scanner generator, so it is generated logic, too - after all.
Here you have some relevant parts of PASSCAN.PAS:
|
this is just after the finite state machine, which is at the core of the scanner procedure, has terminated. The final state (German: Endzustand) is in the variable ALTZUST, and the procedure SCANNER2 computes the SYMBOLNR from the ALTZUST. If the SYMBOLNR is one of the five comment starting symbols, the routine COMMENT is called, which reads characters from the source program until the comment terminates.
Of course, the routine COMMENT has to take care of line ends, "page full" conditions, and: comments may be nested, so there are recursive calls of COMMENT, too. For more detail, you may look at the source of PASSCAN.
COMMENT type 5 is the new C++ style comment.
Here an example:
|
At the moment, the source program formatter PASFORM does not work with C++ style comments !!
I would like to rework PASFORM in such a way, that is uses the scanner PASSCAN, too; this way solving all the problems that PASFORM currently has (no good reaction on syntax errors etc.). And, of course, the new version of PASFORM will handle C++ comments correctly.