28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5<br />

product := this * that;<br />

*ERROR 11 -- a semicolon is required here<br />

As you can see, the error is not reported at the exact point at which the<br />

mistake was made.<br />

It is also common for errors in one part of a program to cause consequential -<br />

errors in other parts. For example, consider the following program:<br />

PROGRAM test(output);<br />

VAR sum.difference:integer; (error . should be ,)<br />

BEGIN<br />

END.<br />

sum := 12 + 7;<br />

difference := 12 - 7;<br />

Because there is an error in the declarations of 'sum' and 'difference', the<br />

compiler will report spurious errors when they are used. The actual errors<br />

generated by this program are:<br />

2 VAR sum.difference:integer; (error . should be ,1<br />

*ERROR 15 -- ':' is required here<br />

5 difference := 12 - 7;<br />

*ERROR 23 -- DIFFERENCE has not been declared<br />

Note that even though the compiler has detected the error in line 2 at the<br />

correct place, it has made the wrong guess as to the cause. A statement of<br />

the form:<br />

VAR sum:integer;<br />

was expected.<br />

If you cannot understand why an error has been reported on a particular<br />

statement, it may be that an error exists earlier in the program, and the<br />

error message is a result of a previous mistake.<br />

Appendix A contains descriptions of error messages which may be<br />

produced by the compiler. Each description is accompanied by one or more<br />

complete (albeit incorrect) programs which demonstrate the fault, or the<br />

28 <strong>Pascal</strong> Issue 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!