-
Notifications
You must be signed in to change notification settings - Fork 0
/
yyerror.icn
165 lines (163 loc) · 7.89 KB
/
yyerror.icn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#PD:
#: yyerror(s)
#:
#:@param s error message to be process
#:@returns &null is the normal value returned
#:@aborts too many errors have occurred, at this point more
#:@ than 10.
#:
procedure yyerror(s)
static t, #SV: table of parser states, the value
#: is another table whose keys are
#: token numbers where values are
#: messages
__merr_errors #SV: counter of merr errors encountered
#: to a point, starting value is set to
#: 0
#
# cleaned up order of table entries. placed in numerical order
#
initial {
t := table(table("syntax error"))
t[0] := table("invalid declaration")
t[3] := table("global, class, or link expected")
t[3, 283] := "method declaration outside any class"
t[3, 308] := "global, class, or link expected"
t[7] := table("unexpected end of file")
t[9] := table("invocable list expected")
t[10] := table("link list expected")
t[12] := table("procedure name expected")
t[23] := table("procedure not allowed within a class")
t[24] := table("missing semicolon")
t[24, 272] := "missing semicolon"
t[24, 275] := "semicolon expected"
t[26] := table("left parenthesis expected to start class fieldlist")
t[26, 257] := "left parenthesis expected to start class fieldlist"
t[26, 374] := "fieldlist starts with left *parenthesis*, not curly brace!"
t[28] := table("invalid global declaration")
t[38] := table("invalid link declaration")
t[40] := table("missing parameter list in procedure declaration")
t[48] := table("missing identifier")
t[53] := table("parameter name expected")
t[55] := table("method expected")
t[57] := table("unclosed literal or missing operator")
t[63] := table("invalid case control expression")
t[64] := table("invalid create expression")
t[66] := table("invalid every control expression")
t[68] := table("invalid if control expression")
t[71] := table("invalid repeat control expression")
t[75] := table("invalid until control expression")
t[76] := table("invalid while control expression")
t[77] := table("invalid argument to unary !")
t[78] := table("bad keyword name or bogus & precedes this token")
t[104] := table("unclosed list")
t[105] := table("invalid compound expression")
t[105, 272] := "invalid compound expression"
t[105, 319] := "assignment missing its left operand"
t[117] := table("missing semicolon or operator")
t[117, 272] := "missing semicolon or operator"
t[117, 375] := "too many closing curly braces"
t[117, 367] := "missing semicolon or operator"
t[130] := table("missing operator or \"do\" keyword")
t[139] := table("invalid procedure body")
t[142] := table("missing fieldname or right parenthesis")
t[148] := table("missing comma or unclosed class field arguments")
t[148, 257] := "missing comma or unclosed class field arguments"
t[148, 283] := "unclosed class field arguments"
t[160] := table("procedure not allowed within a class")
t[161] := table("a ; or \\n is missing between method header and body")
t[164] := table("missing \"of\" in case expression")
t[168] := table("missing then")
t[168, 365] := "spurious close-parenthesis"
t[168, 371] := "missing then"
t[221] := table("expression expected, or need to move declaration to top of procedure or method")
t[232] := table("Assignment is missing right operand value.")
t[283] := table("missing or invalid second argument to *")
t[299] := table("invalid initial expression")
t[204] := table("unclosed parenthesis")
t[208] := table("unclosed list")
t[208, 272] := "missing operator or closing bracket"
t[208, 371] := "unclosed list"
t[212] := table("missing operator or unbalanced parenthesis/bracket")
t[274] := table("missing operand after ||")
t[274, 309] := "missing operand after ||"
t[274, 319] := "illegal space inside ||:="
t[275] := table("missing operand after |||")
t[275, 309] := "missing operand after |||"
t[275, 319] := "illegal space inside |||:="
t[276] := table("missing or invalid second argument to +")
t[286] := table("missing or invalid second argument to !")
t[294] := table("field name expected")
t[300] := table("invalid local declaration")
t[313] := table("parameter name expected")
t[328] := table("missing expression or loop body after do")
t[329] := table("missing then-part")
t[358] := table("missing } somewhere before \"end\"")
t[436] := table("unclosed parenthesis")
t[441] := table("missing \"do\" or some such keyword earlier, or expected a comma or right brace here")
t[442] := table("parenthesis is required for method invocation")
t[444] := table("missing semi-colon or operator")
t[445] := table("missing semi-colon or operator")
t[446] := table("missing semi-colon or operator")
t[450] := table("missing field name")
t[455] := table("parameter modifier must be a (atomic) literal or a convertor")
t[494] := table("malformed case expression")
t[544] := table("unclosed parenthesis")
__merr_errors := 0
}
#
# we can reinitialise the number of merr errors to 0 by supplying
# the string "reinitialize merr errors". However, at this point in time,
# there is no place that this is done in the code for the unicon
# compiler.
#
if s == "reinitialize merr errors" then {
__merr_errors := 0
return
}
if __merr_errors = 0 then {
iwrite(&errout)
} else if map(s) == "stack underflow. aborting..." then {
return
}
__merr_errors +:= 1
if __merr_errors > 10 then {
if *\parsingErrors > 0 then {
every pe := !parsingErrors do {
iwrite(&errout, pe.errorMessage)
}
}
istop("too many errors, aborting")
}
prefix := (\yyfilename || ":") | ""
if s == "syntax error" then {
s := t[(\statestk)[1], yychar]
}
if s == "syntax error" then {
s ||:= " (" || (\statestk)[1] || ";" || yychar || ")"
if /merrflag then {
s ||:= "\n(use -M for assistance with this error)"
}
}
s := prefix || yylineno || ": # \"" || yytext || "\" " || s
if \merrflag then {
if ferr2 := open(\yyfilename) then {
if ferr := open("mail " || merraddress, "pw") then {
iwrite(&errout, "Reporting (-M) your error to the Oracle (",
merraddress,
") for assistance.")
iwrite(&errout, "Type any question you have on the lines below.",
" Type a blank line to finish.")
while iwrite(ferr, "" ~== read())
iwrite(ferr, "\n", s, "\n")
while iwrite(ferr, read(ferr2))
close(ferr)
}
close(ferr2)
}
}
/parsingErrors := []
errorObject := ParseError(yylineno, s)
put(parsingErrors, errorObject)
return
end