mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 23:22:25 +00:00
Much simplified text reader using Texts.Scanner (somewhat like the original Templ code.)
This commit is contained in:
parent
7dc38e98ea
commit
8c702a716e
2 changed files with 102 additions and 118 deletions
|
|
@ -1,93 +1,98 @@
|
||||||
0 undeclared identifier
|
The first line of this file is ignored.
|
||||||
1 multiply defined identifier
|
Any line not starting /^ *[0-9]/ is ignored.
|
||||||
2 illegal character in number
|
There should be only one space between the number and the message text.
|
||||||
3 illegal character in string
|
|
||||||
4 identifier does not match procedure name
|
|
||||||
5 comment not closed
|
|
||||||
|
|
||||||
9 '=' expected
|
Compiler error messages
|
||||||
|
0 undeclared identifier
|
||||||
|
1 multiply defined identifier
|
||||||
|
2 illegal character in number
|
||||||
|
3 illegal character in string
|
||||||
|
4 identifier does not match procedure name
|
||||||
|
5 comment not closed
|
||||||
|
|
||||||
12 type definition starts with incorrect symbol
|
9 '=' expected
|
||||||
13 factor starts with incorrect symbol
|
|
||||||
14 statement starts with incorrect symbol
|
|
||||||
15 declaration followed by incorrect symbol
|
|
||||||
16 MODULE expected
|
|
||||||
|
|
||||||
18 '.' missing
|
12 type definition starts with incorrect symbol
|
||||||
19 ',' missing
|
13 factor starts with incorrect symbol
|
||||||
20 ':' missing
|
14 statement starts with incorrect symbol
|
||||||
|
15 declaration followed by incorrect symbol
|
||||||
|
16 MODULE expected
|
||||||
|
|
||||||
22 ')' missing
|
18 '.' missing
|
||||||
23 ']' missing
|
19 ',' missing
|
||||||
24 '}' missing
|
20 ':' missing
|
||||||
25 OF missing
|
|
||||||
26 THEN missing
|
|
||||||
27 DO missing
|
|
||||||
28 TO missing
|
|
||||||
|
|
||||||
30 '(' missing
|
22 ')' missing
|
||||||
|
23 ']' missing
|
||||||
|
24 '}' missing
|
||||||
|
25 OF missing
|
||||||
|
26 THEN missing
|
||||||
|
27 DO missing
|
||||||
|
28 TO missing
|
||||||
|
|
||||||
34 ':=' missing
|
30 '(' missing
|
||||||
35 ',' or OF expected
|
|
||||||
|
|
||||||
38 identifier expected
|
34 ':=' missing
|
||||||
39 ';' missing
|
35 ',' or OF expected
|
||||||
|
|
||||||
41 END missing
|
38 identifier expected
|
||||||
|
39 ';' missing
|
||||||
|
|
||||||
44 UNTIL missing
|
41 END missing
|
||||||
|
|
||||||
46 EXIT not within loop statement
|
44 UNTIL missing
|
||||||
47 illegally marked identifier
|
|
||||||
|
|
||||||
50 expression should be constant
|
46 EXIT not within loop statement
|
||||||
51 constant not an integer
|
47 illegally marked identifier
|
||||||
52 identifier does not denote a type
|
|
||||||
53 identifier does not denote a record type
|
|
||||||
54 result type of procedure is not a basic type
|
|
||||||
55 procedure call of a function
|
|
||||||
56 assignment to non-variable
|
|
||||||
57 pointer not bound to record or array type
|
|
||||||
58 recursive type definition
|
|
||||||
59 illegal open array parameter
|
|
||||||
60 wrong type of case label
|
|
||||||
61 inadmissible type of case label
|
|
||||||
62 case label defined more than once
|
|
||||||
63 illegal value of constant
|
|
||||||
64 more actual than formal parameters
|
|
||||||
65 fewer actual than formal parameters
|
|
||||||
66 element types of actual array and formal open array differ
|
|
||||||
67 actual parameter corresponding to open array is not an array
|
|
||||||
68 control variable must be integer
|
|
||||||
69 parameter must be an integer constant
|
|
||||||
70 pointer or VAR record required as formal receiver
|
|
||||||
71 pointer expected as actual receiver
|
|
||||||
72 procedure must be bound to a record of the same scope
|
|
||||||
73 procedure must have level 0
|
|
||||||
74 procedure unknown in base type
|
|
||||||
75 invalid call of base procedure
|
|
||||||
76 this variable (field) is read only
|
|
||||||
77 object is not a record
|
|
||||||
78 dereferenced object is not a variable
|
|
||||||
79 indexed object is not a variable
|
|
||||||
80 index expression is not an integer
|
|
||||||
81 index out of specified bounds
|
|
||||||
82 indexed variable is not an array
|
|
||||||
83 undefined record field
|
|
||||||
84 dereferenced variable is not a pointer
|
|
||||||
85 guard or test type is not an extension of variable type
|
|
||||||
86 guard or testtype is not a pointer
|
|
||||||
87 guarded or tested variable is neither a pointer nor a VAR-parameter record
|
|
||||||
88 open array not allowed as variable, record field or array element
|
|
||||||
|
|
||||||
92 operand of IN not an integer, or not a set
|
50 expression should be constant
|
||||||
93 set element type is not an integer
|
51 constant not an integer
|
||||||
94 operand of & is not of type BOOLEAN
|
52 identifier does not denote a type
|
||||||
95 operand of OR is not of type BOOLEAN
|
53 identifier does not denote a record type
|
||||||
96 operand not applicable to (unary) +
|
54 result type of procedure is not a basic type
|
||||||
97 operand not applicable to (unary) -
|
55 procedure call of a function
|
||||||
98 operand of ~ is not of type BOOLEAN
|
56 assignment to non-variable
|
||||||
99 ASSERT fault
|
57 pointer not bound to record or array type
|
||||||
|
58 recursive type definition
|
||||||
|
59 illegal open array parameter
|
||||||
|
60 wrong type of case label
|
||||||
|
61 inadmissible type of case label
|
||||||
|
62 case label defined more than once
|
||||||
|
63 illegal value of constant
|
||||||
|
64 more actual than formal parameters
|
||||||
|
65 fewer actual than formal parameters
|
||||||
|
66 element types of actual array and formal open array differ
|
||||||
|
67 actual parameter corresponding to open array is not an array
|
||||||
|
68 control variable must be integer
|
||||||
|
69 parameter must be an integer constant
|
||||||
|
70 pointer or VAR record required as formal receiver
|
||||||
|
71 pointer expected as actual receiver
|
||||||
|
72 procedure must be bound to a record of the same scope
|
||||||
|
73 procedure must have level 0
|
||||||
|
74 procedure unknown in base type
|
||||||
|
75 invalid call of base procedure
|
||||||
|
76 this variable (field) is read only
|
||||||
|
77 object is not a record
|
||||||
|
78 dereferenced object is not a variable
|
||||||
|
79 indexed object is not a variable
|
||||||
|
80 index expression is not an integer
|
||||||
|
81 index out of specified bounds
|
||||||
|
82 indexed variable is not an array
|
||||||
|
83 undefined record field
|
||||||
|
84 dereferenced variable is not a pointer
|
||||||
|
85 guard or test type is not an extension of variable type
|
||||||
|
86 guard or testtype is not a pointer
|
||||||
|
87 guarded or tested variable is neither a pointer nor a VAR-parameter record
|
||||||
|
88 open array not allowed as variable, record field or array element
|
||||||
|
|
||||||
|
92 operand of IN not an integer, or not a set
|
||||||
|
93 set element type is not an integer
|
||||||
|
94 operand of & is not of type BOOLEAN
|
||||||
|
95 operand of OR is not of type BOOLEAN
|
||||||
|
96 operand not applicable to (unary) +
|
||||||
|
97 operand not applicable to (unary) -
|
||||||
|
98 operand of ~ is not of type BOOLEAN
|
||||||
|
99 ASSERT fault
|
||||||
100 incompatible operands of dyadic operator
|
100 incompatible operands of dyadic operator
|
||||||
101 operand type inapplicable to *
|
101 operand type inapplicable to *
|
||||||
102 operand type inapplicable to /
|
102 operand type inapplicable to /
|
||||||
|
|
@ -172,15 +177,15 @@ Compiler Warnings
|
||||||
307 no ELSE symbol after CASE statement sequence may lead to trap
|
307 no ELSE symbol after CASE statement sequence may lead to trap
|
||||||
|
|
||||||
Run-time Error Messages
|
Run-time Error Messages
|
||||||
-1 assertion failed, cf. SYSTEM_assert
|
-1 assertion failed, cf. SYSTEM_assert
|
||||||
-2 invalid array index
|
-2 invalid array index
|
||||||
-3 function procedure without RETURN statement
|
-3 function procedure without RETURN statement
|
||||||
-4 invalid case in CASE statement
|
-4 invalid case in CASE statement
|
||||||
-5 type guard failed
|
-5 type guard failed
|
||||||
-6 implicit type guard in record assignment failed
|
-6 implicit type guard in record assignment failed
|
||||||
-7 invalid case in WITH statement
|
-7 invalid case in WITH statement
|
||||||
-8 value out of range
|
-8 value out of range
|
||||||
-9 (delayed) interrupt
|
-9 (delayed) interrupt
|
||||||
-10 NIL access
|
-10 NIL access
|
||||||
-11 alignment error
|
-11 alignment error
|
||||||
-12 zero divide
|
-12 zero divide
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,19 @@
|
||||||
MODULE errors;
|
MODULE errors;
|
||||||
|
|
||||||
IMPORT Files, Console;
|
IMPORT Texts, Console;
|
||||||
|
|
||||||
VAR f: Files.File; r: Files.Rider;
|
VAR T: Texts.Text; S: Texts.Scanner;
|
||||||
|
|
||||||
PROCEDURE eoln(c: CHAR): BOOLEAN; BEGIN RETURN (c = 0DX) OR (c = 0AX) END eoln;
|
|
||||||
|
|
||||||
PROCEDURE Write*(n: INTEGER);
|
PROCEDURE Write*(n: INTEGER);
|
||||||
VAR done: BOOLEAN; e: INTEGER; c: CHAR;
|
VAR l: INTEGER; c: CHAR;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF f = NIL THEN f := Files.Old("VishapOberonErrors.txt") END;
|
IF T = NIL THEN NEW(T); Texts.Open(T, "VishapOberonErrors.txt") END;
|
||||||
ASSERT(f # NIL);
|
Texts.OpenScanner(S, T, 0);
|
||||||
Files.Set(r, f, 0); Files.Read(r, c); done := r.eof;
|
REPEAT l := S.line; Texts.Scan(S)
|
||||||
WHILE ~done DO (* Process one line each time round this loop *)
|
UNTIL (l # S.line) & (S.class = Texts.Int) & (S.i = n) OR S.eot;
|
||||||
IF (c >= '0') & (c <= '9') THEN (* Line begins with a number, parse it *)
|
IF ~S.eot THEN Texts.Read(S, c);
|
||||||
e := ORD(c) - ORD('0'); Files.Read(r, c);
|
WHILE ~S.eot & (c >= ' ') DO Console.Char(c); Texts.Read(S, c) END
|
||||||
WHILE (c >= '0') & (c <= '9') DO
|
END
|
||||||
e := e * 10 + ORD(c) - ORD('0');
|
|
||||||
Files.Read(r, c)
|
|
||||||
END
|
|
||||||
ELSE
|
|
||||||
e := n+1; (* Line does not begin with a number, make sure we don't match *)
|
|
||||||
END;
|
|
||||||
IF e = n THEN
|
|
||||||
WHILE c = ' ' DO Files.Read(r, c) END; (* Rest of this line is the message we want *)
|
|
||||||
WHILE ~eoln(c) & ~r.eof DO Console.Char(c); Files.Read(r, c) END;
|
|
||||||
done := TRUE
|
|
||||||
ELSE
|
|
||||||
(* This line does not contain our message *)
|
|
||||||
WHILE ~eoln(c) & ~r.eof DO Files.Read(r, c) END;
|
|
||||||
WHILE eoln(c) DO Files.Read(r, c) END;
|
|
||||||
done := r.eof
|
|
||||||
END
|
|
||||||
END;
|
|
||||||
END Write;
|
END Write;
|
||||||
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
END errors.
|
END errors.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue