[fpc-pascal] "Unexpected end of file" when having an open comment after the final "end."
Ralf Quint
freedos.la at gmail.com
Fri Feb 9 20:36:41 CET 2024
On 2/8/2024 11:01 AM, Martin Wynne via fpc-pascal wrote:
> Hi Thomas,
>
> The error is not the file content after "end.".
>
> The error is not having the expected "end;" after "begin".
>
> This works ok:
>
> _________________________
>
> program test;
>
> begin
> end;
>
> end.
>
> abc 123
>
> _________________________
>
> Martin.
This is not a valid Pascal source code to begin with (pun intended)...
The "begin" is the start of the actual Pascal program and by definition,
that program is terminated by matching that with an "end." That's what
the code completion in Lazarus for example is adding into a new "simple
program" project source code.
Just adding a random "end;" should also just yield an error message...
Well, I actually did just tested this and it gives as expected an
"Error: Syntax error, "." expected but ";" found. It Doesn't even
process past the "end." in that case.
What is however interesting is that an open comment, as mention by the
OP, immediately after the "end." results in the "Error: unexpected end
of file" message, however any other addition text past that "end." will
result in no error message and completing to compile the program
successfully...
I just tried a couple more things, and it seems it is just the "{" or
"(*" opening of a comment that is causing the error message, having a
"//" comment until end of line after the "end." will also compile just
fine
Ralf
More information about the fpc-pascal
mailing list