Debian Codegraph @

ipl/packs/tcll1/semstk.icn

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