Expected and unexpected end-of-file – HP SunSoft Pascal 4.0 User Manual

Page 233

Advertising
background image

Error Diagnostics

209

9

Expected and Unexpected End-of-file

If

pc

finds a complete program, but there is more (noncomment) text in the

input file, then it indicates that an end-of-file is expected. This situation may
occur after a bracketing error, or if too many

end

s are present in the input. The

message may appear after the recovery says that it

Expected '.'

because a

period (

.

) is the symbol that terminates a program.

If severe errors in the input prohibit further processing,

pc

may produce a

diagnostic message followed by

QUIT

. Examples include unterminated

comments and lines longer than 1,024 characters.

These are the error messages
you receive when you compile

synerr2.p

. On line 6,

parentheses are used for
subscripting (as in FORTRAN),
rather than the square brackets
that are used in Pascal.

The compiler noted that

a

was

not defined as a procedure
(delimited by parentheses in
Pascal). Since you cannot
assign values to procedure
calls,

pc

diagnosed a

malformed statement at the
point of assignment.

hostname% pc synerr2.p

Mon Feb 13 11:02:04 1995 synerr2.p:

3 integer a(10)

e 18480-------^--- Inserted '['

E 18490-----------------^--- Expected identifier

6 read(b);

E 18420----------------^--- Undefined variable

7 for c := 1 to 10 do

E 18420---------------^--- Undefined variable

8 a(c) := b * c

E 18420---------------^--- Undefined procedure

E 15010 line 1 - File output listed in program statement but not

declared

In program synerr2_example:

E 18240 a undefined on line 8

E 18240 b undefined on lines 6 8

E 18240 c undefined on lines 7 8

The Pascal program,

mism.p

program mismatch_example(output);

begin

writeln('***');

{ The next line is the last line in the file. }

writeln

Advertising