diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
commit | 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (patch) | |
tree | 926065cf45450116098db664e3c61dced9e1f21a /src/common/pscript.icn | |
download | icon-6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1.tar.gz |
Initial upstream version 9.4.3upstream/9.4.3
Diffstat (limited to 'src/common/pscript.icn')
-rw-r--r-- | src/common/pscript.icn | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/common/pscript.icn b/src/common/pscript.icn new file mode 100644 index 0000000..d9b2ee7 --- /dev/null +++ b/src/common/pscript.icn @@ -0,0 +1,44 @@ +# 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 + +$ifdef _CYGWIN + $define YY_STATE "yystate" +$else # _CYGWIN + $define YY_STATE "yy_state" +$endif # _CYGWIN + +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 |