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
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.
-fignore-garbage-after-dot
There is reference in ISO 10206: see 6.13, especially rule for program-block. AFAICS the compiler is required to accept multi-module program in a single file. In particular Note 1 to 6.13 clarily states that "useless" modules may follow main program.
For sure I read paragraph 6.13 of ISO 10206 before asking your advice. I must say, for me the Note 1:
:1 This International Standard constrains the order of program-components of : a conforming program only by the partial ordering defined by 6.2.2.9. A : further restriction by a processor on the order of program-components can : be justified only by subclause 1.2 a).
does not state "clearly" one can freely put garbage in his/her source code provided that it is after the final "End." :-) I admire people like you who can see clearly something in a so cryptic text - at least for me -. This kind of things keeps me humble.
Thanks again.
Pascal Viandier
-----Message d'origine----- De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Waldek Hebisch Envoyé : March 1, 2006 15:01 À : gpc@gnu.de Objet : Re: Reading source past end of block
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.
-fignore-garbage-after-dot
There is reference in ISO 10206: see 6.13, especially rule for program-block. AFAICS the compiler is required to accept multi-module program in a single file. In particular Note 1 to 6.13 clarily states that "useless" modules may follow main program.
-- Waldek Hebisch hebisch@math.uni.wroc.pl
Please write below quotes, thanks.
Pascal Viandier wrote:
For sure I read paragraph 6.13 of ISO 10206 before asking your advice. I must say, for me the Note 1:
:1 This International Standard constrains the order of program-components of : a conforming program only by the partial ordering defined by 6.2.2.9. A : further restriction by a processor on the order of program-components can : be justified only by subclause 1.2 a).
does not state "clearly" one can freely put garbage in his/her source code provided that it is after the final "End." :-) I admire people like you who can see clearly something in a so cryptic text - at least for me -. This kind of things keeps me humble.
De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Waldek Hebisch
There is reference in ISO 10206: see 6.13, especially rule for program-block. AFAICS the compiler is required to accept multi-module program in a single file. In particular Note 1 to 6.13 clarily states that "useless" modules may follow main program.
I don't think it says you can put garbage after the `end.', but only useless, i.e. unused, modules, as Waldek said. In fact the syntax rules above this paragraph say:
program = programÂblock . programÂblock = programÂcomponent { programÂcomponent } . programÂcomponent = mainÂprogramÂdeclaration `.' | moduleÂdeclaration `.' .
Nothing about garbage there.
Frank
By "garbage" I mean something that is not Pascal code.
The sample code bellow illustrates what I mean:
Beginning of source>> Program GarbageAfterDot; Begin WriteLn('Ok'); End.
This line is not processed by GPC when -fignore-garbage-after-dot is on command-line.
<<End of source
This program compiles, links and executes properly only if "-fignore-garbage-after-dot" is on command-line, even if the last line has nothing to do with Pascal code. Also, the word "garbage" is contained in the command-line switch :-)
Kind regards
Pascal Viandier
<snip>
-----Message d'origine----- De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Frank Heckenbach Envoyé : March 2, 2006 11:36 À : gpc@gnu.de Objet : Re: RE : Reading source past end of block
Please write below quotes, thanks.
Pascal Viandier wrote:
For sure I read paragraph 6.13 of ISO 10206 before asking your advice. I must say, for me the Note 1:
:1 This International Standard constrains the order of program-components of : a conforming program only by the partial ordering defined by 6.2.2.9. A : further restriction by a processor on the order of program-components can : be justified only by subclause 1.2 a).
does not state "clearly" one can freely put garbage in his/her source code provided that it is after the final "End." :-) I admire people like you who can see clearly something in a so cryptic text
- at
least for me -. This kind of things keeps me humble.
De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Waldek
Hebisch
There is reference in ISO 10206: see 6.13, especially rule for program-
block.
AFAICS the compiler is required to accept multi-module program in a single file. In particular Note 1 to 6.13 clarily states that "useless" modules may follow main program.
I don't think it says you can put garbage after the `end.', but only useless, i.e. unused, modules, as Waldek said. In fact the syntax rules above this paragraph say:
program = programblock . programblock = programcomponent { programcomponent } . programcomponent = mainprogramdeclaration `.' | moduledeclaration `.' .
Nothing about garbage there.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8
Pascal Viandier wrote:
By "garbage" I mean something that is not Pascal code.
Me too.
Again, please write *BELOW* quotes, thanks.
The sample code bellow illustrates what I mean:
Beginning of source>> Program GarbageAfterDot; Begin WriteLn('Ok'); End.
This line is not processed by GPC when -fignore-garbage-after-dot is on command-line.
<<End of source
This program compiles, links and executes properly only if "-fignore-garbage-after-dot" is on command-line, even if the last line has nothing to do with Pascal code. Also, the word "garbage" is contained in the command-line switch :-)
I was referring to the ISO that you quoted. (The references really get messed up due to the top-posting, as you see.) ISO doesn't mention garbage, neither literally, nor in the meaning of it (AFAICS).
De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Frank Heckenbach
Pascal Viandier wrote:
For sure I read paragraph 6.13 of ISO 10206 before asking your advice. I must say, for me the Note 1:
:1 This International Standard constrains the order of program-components of : a conforming program only by the partial ordering defined by 6.2.2.9. A : further restriction by a processor on the order of program-components can : be justified only by subclause 1.2 a).
does not state "clearly" one can freely put garbage in his/her source code provided that it is after the final "End." :-) I admire people like you who can see clearly something in a so cryptic text
- at
least for me -. This kind of things keeps me humble.
De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Waldek
Hebisch
There is reference in ISO 10206: see 6.13, especially rule for program-
block.
AFAICS the compiler is required to accept multi-module program in a single file. In particular Note 1 to 6.13 clarily states that "useless" modules may follow main program.
I don't think it says you can put garbage after the `end.', but only useless, i.e. unused, modules, as Waldek said. In fact the syntax rules above this paragraph say:
program = programÂblock . programÂblock = programÂcomponent { programÂcomponent } . programÂcomponent = mainÂprogramÂdeclaration `.' | moduleÂdeclaration `.' .
Nothing about garbage there.
Frank
On Thu, 2 Mar 2006, Frank Heckenbach wrote:
Pascal Viandier wrote:
By "garbage" I mean something that is not Pascal code.
[..]
I don't think it says you can put garbage after the `end.', but only useless, i.e. unused, modules, as Waldek said. In fact the syntax rules above this paragraph say:
program = programblock . programblock = programcomponent { programcomponent } . programcomponent = mainprogramdeclaration `.' | moduledeclaration `.' .
Nothing about garbage there.
suggestion for a solution: after the "end." then skip comments, if any then if the next word is not program | module | unit: terminate reading.
Russ
Russell Whitaker wrote:
suggestion for a solution: after the "end." then skip comments, if any then if the next word is not program | module | unit: terminate reading.
Emil's example would not be caught this way.
An additional complication would be that BP allows omitting the `program' header, so the first token of a BP program can actually be many things.
Frank
Pascal Viandier wrote:
For sure I read paragraph 6.13 of ISO 10206 before asking your advice. I must say, for me the Note 1:
:1 This International Standard constrains the order of program-components of : a conforming program only by the partial ordering defined by 6.2.2.9. A : further restriction by a processor on the order of program-components can : be justified only by subclause 1.2 a).
does not state "clearly" one can freely put garbage in his/her source code provided that it is after the final "End." :-) I admire people like you who can see clearly something in a so cryptic text - at least for me -. This kind of things keeps me humble.
I wrote "useless modules" not garbage: 6.13 says that program is composed from modues, each module ended by a dot. The note in particular says that some modules may follow main program. Such modules are not garbage: we still should check if they are syntactically correct.
Some folks to not like such behaviour. The `-fignore-garbage-after-dot' option is for then.
BTW. We had long thread about this some time ago.
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
On Wed, Mar 01, 2006 at 02:42:11PM -0500, 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.
Another interpretation: if something _is_ there, it is not useful, and thus suspect of being erroneous, in which case an error message might help. Silly example:
program foo;
type qwe = record rty: integer; uio: char end;
var enf: qwe;
begin enf.rty := 42; end.uio := 'a'; ... etc, do stuff with enf... end.
Emil Jerabek
Emil Jerabek wrote:
On Wed, Mar 01, 2006 at 02:42:11PM -0500, 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.
Another interpretation: if something _is_ there, it is not useful, and thus suspect of being erroneous, in which case an error message might help. Silly example:
program foo;
type qwe = record rty: integer; uio: char end;
var enf: qwe;
begin enf.rty := 42; end.uio := 'a'; ... etc, do stuff with enf... end.
Nice example, thanks! I guess one could search for hours when trying to find out why something a few lines below the "..." isn't executed ;-)
Frank