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 / ipl / packs / euler / semstk.icn < prev    next >
Text File  |  2001-06-06  |  780b  |  56 lines

  1. # Semantics stack manipulation routines to be called by
  2. # parseLL1(...), the parser for the TLCLL1 LL(1) parser
  3. # generator.
  4. #    (written by Dr. Thomas W. Christopher)
  5. #
  6.  
  7. global semanticsStack
  8.  
  9. record ErrorToken(type,body,line,column)
  10.  
  11. procedure initSemanticsStack()
  12.  semanticsStack:=[]
  13. return
  14. end
  15.  
  16.  
  17. procedure outToken(tok)
  18.  push(semanticsStack,tok)
  19. return
  20. end
  21.  
  22. procedure outAction(a)
  23. a()
  24. return
  25. end
  26.  
  27. procedure outError(t,l,c)
  28. push(semanticsStack,ErrorToken(t,t,\l|0,\c|0))
  29. return
  30. end
  31.  
  32. procedure isError(v)
  33.  return type(v)=="ErrorToken"
  34. end
  35.  
  36. procedure popSem(n)
  37. local V
  38. V:=[]
  39. every 1 to n do push(V,pop(semanticsStack))
  40. return V
  41. end
  42.  
  43. procedure pushSem(s)
  44. push(semanticsStack,s)
  45. return
  46. end
  47.  
  48. procedure anyError(V)
  49. local v
  50. if v:=!V & type(v)=="ErrorToken" then {
  51.     return v
  52. }
  53. fail
  54. end
  55.  
  56.