Pascal,
It's actually an interesting design problem, which we faced in our "Dr. Pascal" compiler/interpreter.
Omission of an earlier "end;" in your program, or in the lexically "last" procedure before the main program, will lead the compiler to see the "end." as an end of a block, and continue parsing, looking for more code and the last 'end'. A stray "." in a program is not uncommon, and we certainly don't want the compiler scan to stop for it. On the other hand, if the programmer incorrectly adds an earlier "end" or omits a "begin", if the scan stopped at supposedly the last end, would make the final block of code invisible to the compiler.
I haven't fully laid out all the contingencies here, but you may see why there is an advantage in clarity by having the scan continue. You can always enclose that trailing text in comment delimiters.
willett kempton www.visible-software.com
On 1 Mar 2006, at 2:42 PM, Pascal Viandier wrote:
I encountered an unexpected error with GPC when compiling a Pascal source that contains "some text" (not Pascal code) after the final "End." of the program. GPC tries to compile this extra text and finds syntax errors in it.
Although I did not see any reference to this in ISO 10206, I think it could be a nice feature for GPC to ignore everything after the final "End." in a program or a unit since nothing useful for it should be there.
I am using gpc 20050331 under Debian Linux X86 and gpc 20051116 on Sparc Solaris 2.6.
Kind Regards
Pascal Viandier