home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / common / pscript.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  34 lines

  1. #  Program to sanitize Yacc output and  minor changes to it to suit the Icon
  2. #  translator.
  3.  
  4. procedure main()
  5.    local line, prefix
  6.  
  7.    while line := read() do {
  8.       if line == "#" then next        # omit lone #s -- illegal now
  9.       else line ? {
  10.          if write(="#endif") then next    # omit illegal stuff
  11.          else if (prefix := tab(find("yyerror("))) & ="yyerror(" &
  12.             tab(upto('"')+1) then {
  13.             #
  14.             # We are beyond the 'yyerror( "'. Write the part of the
  15.             # line before the call, then decide what to do about
  16.             # the error message that follows.
  17.             #
  18.             writes(prefix)
  19.             if ="syntax error\"" then
  20.                writes("yyerror(yychar, yylval, yy_state")
  21.             else if ="yacc stack overflow\"" then
  22.                writes("tsyserr(\"parse stack overflow\"")
  23.             else
  24.                writes("tsyserr(\"parser: ")
  25.              write(tab(0))
  26.              }
  27.           else if ="extern char *malloc(), *realloc();" then {
  28.              # let proto.h handle this declaration.
  29.              }
  30.           else write(tab(0))
  31.           }
  32.       }
  33. end
  34.