1 (* Implementation restrictions
2 3 too many nodes in graph (>1500) CRG.NewNode
3 4 too many sets (ANY-symbols or SYNC symbols) CRT.NewAnySet,
5 6 too many symbols (>300) CRT.NewSym
6 7 too many character classes (>50) CRT.NewClass
7 9 too many conditions in generated code (>100) CRX.NewCondSet
9 Trace output (ddt settings: ${digit})
10 0 Prints states of automaton
11 1 Prints start symbols and followers of nonterminals (also option /s)
12 2 Prints the internal graph
13 3 Trace of start symbol set computation
14 4 Trace of follow set computation
15 5 suppresses FORWARD declarations in parser (for multipass compilers)
16 6 Prints the symbol list
17 7 Prints a cross reference list (also option /x)
19 ==========================================================================*)
22 IMPORT Oberon
, Texts
, CRS
, CRP
, CRT
;
26 VAR w
: Texts
.Writer
; lastErrPos
: LONGINT;
29 PROCEDURE Error (n
: INTEGER; pos
: LONGINT);
31 PROCEDURE Msg (s
: ARRAY OF CHAR);
32 BEGIN Texts
.WriteString(w
, s
)
37 IF pos
< lastErrPos
+ minErrDist
THEN lastErrPos
:= pos
; RETURN END;
39 Texts
.WriteInt(w
, pos
, 3); Texts
.WriteString(w
, ": ");
42 |
0: Msg("EOF expected")
43 |
1: Msg("ident expected")
44 |
2: Msg("string expected")
45 |
3: Msg("number expected")
46 |
4: Msg("'COMPILER' expected")
47 |
5: Msg("'IMPORT' expected")
48 |
6: Msg("';' expected")
49 |
7: Msg("'PRODUCTIONS' expected")
50 |
8: Msg("'=' expected")
51 |
9: Msg("'.' expected")
52 |
10: Msg("'END' expected")
53 |
11: Msg("'CHARACTERS' expected")
54 |
12: Msg("'TOKENS' expected")
55 |
13: Msg("'PRAGMAS' expected")
56 |
14: Msg("'COMMENTS' expected")
57 |
15: Msg("'FROM' expected")
58 |
16: Msg("'TO' expected")
59 |
17: Msg("'NESTED' expected")
60 |
18: Msg("'IGNORE' expected")
61 |
19: Msg("'CASE' expected")
62 |
20: Msg("'+' expected")
63 |
21: Msg("'-' expected")
64 |
22: Msg("'CHR' expected")
65 |
23: Msg("'(' expected")
66 |
24: Msg("')' expected")
67 |
25: Msg("'ANY' expected")
68 |
26: Msg("'|' expected")
69 |
27: Msg("'WEAK' expected")
70 |
28: Msg("'[' expected")
71 |
29: Msg("']' expected")
72 |
30: Msg("'{' expected")
73 |
31: Msg("'}' expected")
74 |
32: Msg("'SYNC' expected")
75 |
33: Msg("'CONTEXT' expected")
76 |
34: Msg("'<' expected")
77 |
35: Msg("'>' expected")
78 |
36: Msg("'(.' expected")
79 |
37: Msg("'.)' expected")
80 |
38: Msg("??? expected")
81 |
39: Msg("invalid TokenFactor")
82 |
40: Msg("invalid Factor")
83 |
41: Msg("invalid Factor")
84 |
42: Msg("invalid Term")
85 |
43: Msg("invalid Symbol")
86 |
44: Msg("invalid SimSet")
87 |
45: Msg("this symbol not expected in TokenDecl")
88 |
46: Msg("invalid TokenDecl")
89 |
47: Msg("invalid Declaration")
90 |
48: Msg("invalid Declaration")
91 |
49: Msg("invalid Declaration")
92 |
50: Msg("this symbol not expected in Coco")
93 |
51: Msg("invalid start of the program")
94 ELSE Texts
.WriteString(w
, "error "); Texts
.WriteInt(w
, n
, 0)
98 |
201: Msg("unexpected end of file");
99 |
202: Msg("string terminator not on this line");
100 |
203: Msg("a literal must not have attributes");
101 |
204: Msg("this symbol kind not allowed in production");
102 |
205: Msg("symbol declared without attributes");
103 |
206: Msg("symbol declared with attributes");
104 |
207: Msg("name declared twice");
105 |
208: Msg("this type not allowed on left side of production");
106 |
209: Msg("symbol earlier referenced without attributes");
107 |
210: Msg("symbol earlier referenced with attributes");
108 |
211: Msg("missing production for grammar name");
109 |
212: Msg("grammar symbol must not have attributes");
110 |
213: Msg("a literal must not be declared with a structure")
111 |
214: Msg("semantic action not allowed here")
112 |
215: Msg("undefined name")
113 |
216: Msg("attributes not allowed in token declaration")
114 |
217: Msg("name does not match name in heading")
115 |
220: Msg("token may be empty")
116 |
221: Msg("token must not start with an iteration")
117 |
222: Msg("only characters allowed in comment declaration")
118 |
223: Msg("only terminals may be weak")
120 |
225: Msg("comment delimiter must not exceed 2 characters")
121 |
226: Msg("character set contains more than one character")
122 ELSE Texts
.WriteString(w
, "error "); Texts
.WriteInt(w
, n
, 0)
125 Texts
.WriteLn(w
); Texts
.Append(Oberon
.Log
, w
.buf
)
128 PROCEDURE Options(VAR s
: Texts
.Scanner
);
131 IF s
.nextCh
= "/" THEN Texts
.Scan(s
); Texts
.Scan(s
);
132 IF s
.class
= Texts
.Name
THEN i
:= 0;
134 IF CAP(s
.s
[i
]) = "X" THEN CRT
.ddt
[7] := TRUE
135 ELSIF CAP(s
.s
[i
]) = "S" THEN CRT
.ddt
[1] := TRUE
145 VAR s
: Texts
.Scanner
; src
, t
: Texts
.Text
;
146 pos
, beg
, end
, time
: LONGINT; i
: INTEGER;
148 Texts
.OpenScanner(s
, Oberon
.Par
.text
, Oberon
.Par
.pos
); Texts
.Scan(s
);
149 src
:= NIL; pos
:= 0;
150 IF (s
.class
= Texts
.Char
) & (s
.c
= "^") THEN
151 Oberon
.GetSelection(t
, beg
, end
, time
);
152 IF time
>= 0 THEN Texts
.OpenScanner(s
, t
, beg
); Texts
.Scan(s
) END
154 IF s
.class
= Texts
.Name
THEN
155 NEW(src
); Texts
.Open(src
, s
.s
);
156 ELSIF (s
.class
= Texts
.Char
) & (s
.c
= "@") THEN
157 Oberon
.GetSelection(t
, beg
, end
, time
);
158 IF time
>= 0 THEN src
:= t
; pos
:= beg
; s
.s
:= " " END
161 Texts
.WriteString (w
, "Coco/R - Compiler-Compiler V2.2"); Texts
.Append(Oberon
.Log
, w
.buf
);
162 i
:= 0; WHILE i
< 10 DO CRT
.ddt
[i
] := FALSE
; INC(i
) END;
164 Texts
.WriteLn(w
); Texts
.WriteString(w
, s
.s
); Texts
.Append(Oberon
.Log
, w
.buf
);
165 CRS
.Reset(src
, pos
, Error
); lastErrPos
:= -10;