Error Diagnostics
207
9
Replacements, Insertions, and Deletions
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
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 }
synerr.p
produces a fatal
syntax error when you compile it
because Pascal does not have
an exponentiation operator.
hostname% pc synerr.p
Mon Feb 13 10:56:19 1995 synerr.p:
3 var i, j are integer;
e 18460----------------^--- Replaced identifier with a ':'
6 for j :* 1 to 20 begin
E 18490-----------------^--- Expected keyword (null)
E 18460-----------------^--- Replaced ':' with a identifier
e 18480----------------------------^--- Inserted keyword do
8 i = 2 ** j;
e 18480---------------^--- Inserted keyword if
E 18480----------------------^--- Inserted identifier
e 18480-------------------------^--- Inserted keyword then
9 writeln(i))
e 18450-------------------------^--- Deleted ')'
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......