9

Undefined or Improper Identifiers

If an identifier is encountered in the input but is undeclared, the error recovery mechanism replaces it with an identifier of the appropriate class.

Further references to this identifier are summarized at the end of the containing procedure, function, or at the end of the program. This is the case if the reference occurs in the main program.

Similarly, if you use an identifier in an inappropriate way, for example, if a type identifier is used in an assignment statement, pc produces a diagnostic and inserts an identifier of the appropriate class. Further incorrect references to this identifier are flagged only if they involve incorrect use in a different way. pc summarizes all incorrect uses in the same way it summarizes uses of undeclared variables.

Expected Symbols and Malformed Constructs

The Pascal program, synerr2.p. Here output is misspelled, and a is given a FORTRAN-style variable declaration.

If none of the corrections mentioned previously appears reasonable, the error recovery routine examines the input to the left of the point of error to see if there is only one symbol that can follow this input. If so, the recovery prints a diagnostic which indicates that the given symbol is expected.

In cases where none of these corrections resolve the problems in the input, the recovery may issue a diagnostic that indicates “malformed” input. If necessary, pc can then skip forward in the input to a place where analysis can continue. This process may cause some errors in the missed text to be skipped.

See this example:

program synerr2_example(input,outpu);

integer a(10)

begin read(b);

for c := 1 to 10 do a(c) := b * c

end. { synerr2_example }

208

Pascal 4.0 User’s Guide

Page 232
Image 232
HP SunSoft Pascal 4.0 manual Undefined or Improper Identifiers, Expected Symbols and Malformed Constructs, 208