blob: 10d10d2fa292dab97441a7dfd044e84ab0831db7 (
plain)
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
|
# Program to sanitize Yacc output and minor changes to it to suit the Icon
# translator.
# procedure to skip optional white space.
procedure sws()
return tab( many( ' \t' ) ) | ""
end
$define YY_STATE "yy_state"
procedure main()
local line, prefix
while line := read() do {
if line == "#" then next # omit lone #s -- illegal now
else line ? {
if write(="#endif") then next # omit illegal stuff
else if (prefix := tab(find("yyerror"))) & ="yyerror" & sws() & ="(" &
sws() & ="\"" then {
#
# We are beyond the 'yyerror( "'. Write the part of the
# line before the call, then decide what to do about
# the error message that follows.
#
writes(prefix)
if ="syntax error\"" then
writes("yyerror(yychar, yylval, ", YY_STATE)
else if ="yacc stack overflow\"" then
writes("tsyserr(\"parse stack overflow\"")
else
writes("tsyserr(\"parser: ")
write(tab(0))
}
else if ="extern char *malloc(), *realloc();" then {
# let proto.h handle this declaration.
}
else write(tab(0))
}
}
end
|