summaryrefslogtreecommitdiff
path: root/ipl/packs/tcll1/semstk.icn
blob: 1197d8fe13192f4f7104b2d57d29be8e66cab74a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Semantics stack manipulation routines to be called by
# parseLL1(...), the parser for the TCLL1 LL(1) parser
# generator.
#	(written by Thomas W. Christopher)
#

invocable all
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