diff options
Diffstat (limited to 'ipl/packs/euler/semstk.icn')
-rw-r--r-- | ipl/packs/euler/semstk.icn | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ipl/packs/euler/semstk.icn b/ipl/packs/euler/semstk.icn new file mode 100644 index 0000000..e3a6467 --- /dev/null +++ b/ipl/packs/euler/semstk.icn @@ -0,0 +1,55 @@ +# Semantics stack manipulation routines to be called by +# parseLL1(...), the parser for the TLCLL1 LL(1) parser +# generator. +# (written by Dr. Thomas W. Christopher) +# + +global semanticsStack + +record ErrorToken(type,body,line,column) + +procedure initSemanticsStack() + semanticsStack:=[] +return +end + + +procedure outToken(tok) + push(semanticsStack,tok) +return +end + +procedure outAction(a) +a() +return +end + +procedure outError(t,l,c) +push(semanticsStack,ErrorToken(t,t,\l|0,\c|0)) +return +end + +procedure isError(v) + return type(v)=="ErrorToken" +end + +procedure popSem(n) +local V +V:=[] +every 1 to n do push(V,pop(semanticsStack)) +return V +end + +procedure pushSem(s) +push(semanticsStack,s) +return +end + +procedure anyError(V) +local v +if v:=!V & type(v)=="ErrorToken" then { + return v +} +fail +end + |