Debian Codegraph @

ipl/packs/euler/euler.icn

raw
1 link eulerscn,readll1 #,parsell1
2
3 global primTbl
4
5 procedure main(L)
6 local filename,flags,splitFilename
7 local ptbl
8 #write("hi")
9 #&trace:=-1
10 if *L<1 then
11 stop("usage: [iconx] euler [-s] filename.eul")
12
13 flags := ""
14 if L[1][1]=="-" then {
15 flags := L[1]
16 filename := L[2]
17 } else {
18 filename:=L[1]
19 }
20 if /filename then
21 stop("usage: [iconx] euler [-s] filename.eul")
22
23 splitFilename:=fileSuffix(filename)
24 if \splitFilename[2] then initScanner(filename)
25 else initScanner(splitFilename[1]||".eul")
26
27 initSemanticsStack()
28 initTrans()
29
30 #write("before readLL1")
31
32 ptbl:=readLL1("euler.ll1")
33 #write("after readLL1")
34 parseLL1(ptbl)
35
36 if find("s",flags) then showCode()
37 interpreter()
38
39 end
40
41 # From: filename.icn in Icon Program Library
42 # Author: Robert J. Alexander, 5 Dec. 89
43 # Modified: Thomas Christopher, 12 Oct. 94
44
45 procedure fileSuffix(s,separator)
46 local i
47 /separator := "."
48 i := *s + 1
49 every i := find(separator,s)
50 return [s[1:i],s[(*s >= i) + 1:0] | &null]
51 end
52
53 #
54 #required by parseLL1()
55 #
56 procedure reportParseError(t)
57 write("unexpected input ",t.body,
58 " at line ",t.line," column ",t.column)
59 return
60 end