![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395231x1.png)
9
When Pascal encounters a syntax error in the input text, the compiler invokes an error recovery procedure. This procedure examines the input text immediately after the point of error and uses a set of simple corrections to determine whether or not to allow the analysis to continue. These corrections involve replacing an input token with a different token or inserting a token. Most of these changes do not cause fatal syntax errors.
The exception is the insertion of or replacement with a symbol, such as an identifier or a number; in these cases, the recovery makes no attempt to determine which identifier or what number should be inserted. Thus, these are considered fatal syntax errors.
The Pascal program, synerr.p, which uses ** as an exponentiation operator
synerr.p produces a fatal syntax error when you compile it because Pascal does not have an exponentiation operator.
program synerr_example(output);
var i, j are integer;
begin
for j :* 1 to 20 begin write(j);
i = 2 ** j; writeln(i))
end
end. { synerr_example }
hostname% pc synerr.p |
|
|
| |
Mon Feb 13 10:56:19 1995 synerr.p: |
|
| ||
3 | var i, j are integer; |
|
| |
e | Replaced identifier with a ':' | |||
6 | for j :* 1 to 20 begin | |||
E | Expected keyword (null) | |||
E | Replaced ':' with a identifier | |||
e |
| ^ | ||
8 | i = 2 ** j; |
|
| |
e | Inserted keyword if | |||
E | Inserted identifier | |||
e | Inserted keyword then | |||
9 | writeln(i)) |
|
| |
e | Deleted ')' | |||
|
|
|
|
|
Error Diagnostics | 207 |