Annotate

buildscripts/squish @ 472:864c9dc27c60

buildscripts: Update included squish (now supports Lua 5.2)
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Mar 2023 11:07:02 +0000
parent 428:bde804b01f28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1 #!/usr/bin/lua5.2
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 package.preload['optlex']=(function(...)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3 local _ENV=_ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
4 local function e(t,...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
5 local e=package.loaded[t]or _ENV[t]or{_NAME=t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
6 package.loaded[t]=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
7 for t=1,select("#",...)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
8 (select(t,...))(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
9 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
10 _ENV=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
11 _M=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
12 return e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
13 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 local s=_G
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local u=require"string"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 local i=u.match
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 local e=u.sub
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 local r=u.find
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
19 local l=u.rep
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 local c
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 error=s.error
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 warn={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
23 local n,o,d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
24 local q={
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 TK_KEYWORD=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 TK_NAME=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 TK_NUMBER=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 TK_STRING=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 TK_LSTRING=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 TK_OP=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 TK_EOS=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 }
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
33 local b={
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 TK_COMMENT=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 TK_LCOMMENT=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 TK_EOL=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 TK_SPACE=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 }
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local h
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
40 local function k(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 local t=n[e-1]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 if e<=1 or t=="TK_EOL"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 return true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 elseif t==""then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
45 return k(e-1)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 return false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 local function g(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 local t=n[e+1]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 if e>=#n or t=="TK_EOL"or t=="TK_EOS"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 return true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 elseif t==""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 return g(e+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 return false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
58 local function E(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 local t=#i(a,"^%-%-%[=*%[")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 local a=e(a,t+1,-(t-1))
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 local e,t=1,0
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 while true do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
63 local a,n,i,o=r(a,"([\r\n])([\r\n]?)",e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
64 if not a then break end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
65 e=a+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 t=t+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
67 if#o>0 and i~=o then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 e=e+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 return t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 local function v(s,h)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 local a=i
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 local t,e=n[s],n[h]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 if t=="TK_STRING"or t=="TK_LSTRING"or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 e=="TK_STRING"or e=="TK_LSTRING"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 return""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 elseif t=="TK_OP"or e=="TK_OP"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 if(t=="TK_OP"and(e=="TK_KEYWORD"or e=="TK_NAME"))or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 (e=="TK_OP"and(t=="TK_KEYWORD"or t=="TK_NAME"))then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 return""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 if t=="TK_OP"and e=="TK_OP"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 local t,e=o[s],o[h]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 if(a(t,"^%.%.?$")and a(e,"^%."))or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 (a(t,"^[~=<>]$")and e=="=")or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 (t=="["and(e=="["or e=="="))then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 return" "
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 return""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 local t=o[s]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 if e=="TK_OP"then t=o[h]end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 if a(t,"^%.%.?%.?$")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 return" "
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 return""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 return" "
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
103 local function j()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
104 local a,s,i={},{},{}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 local e=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 for t=1,#n do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 local n=n[t]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 if n~=""then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
109 a[e],s[e],i[e]=n,o[t],d[t]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 e=e+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
113 n,o,d=a,s,i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
114 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
115 local function x(r)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 local t=o[r]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 local n
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 if i(t,"^0[xX]")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 local e=s.tostring(s.tonumber(t))
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 if#e<=#t then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 t=e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 if i(t,"^%d+%.?0*$")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 t=i(t,"^(%d+)%.?0*$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 if t+0>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 t=i(t,"^0*([1-9]%d*)$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 local a=#i(t,"0*$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 local o=s.tostring(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 if a>#o+1 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 t=e(t,1,#t-a).."e"..o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 n=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 n="0"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 elseif not i(t,"[eE]")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 local a,t=i(t,"^(%d*)%.(%d+)$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 if a==""then a=0 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 if t+0==0 and a==0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 n="0"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 local o=#i(t,"0*$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 if o>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 t=e(t,1,#t-o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 if a+0>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 n=a.."."..t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 n="."..t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 local a=#i(t,"^0*")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
155 local o=#t-a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
156 local a=s.tostring(#t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
157 if o+2+#a<1+#t then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
158 n=e(t,-o).."e-"..a
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 local t,a=i(t,"^([^eE]+)[eE]([%+%-]?%d+)$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 a=s.tonumber(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 local h,o=i(t,"^(%d*)%.(%d*)$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 if h then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 a=a-#o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 t=h..o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 if t+0==0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 n="0"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173 local o=#i(t,"^0*")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 t=e(t,o+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 o=#i(t,"0*$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 if o>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 t=e(t,1,#t-o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 a=a+o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 local i=s.tostring(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
181 if a==0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
182 n=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
183 elseif a>0 and(a<=1+#i)then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
184 n=t..l("0",a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 elseif a<0 and(a>=-#t)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
186 o=#t+a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
187 n=e(t,1,o).."."..e(t,o+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
188 elseif a<0 and(#i>=-a-#t)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
189 o=-a-#t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
190 n="."..l("0",o)..t
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
191 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
192 n=t.."e"..a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
193 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
194 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
195 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
196 if n and n~=o[r]then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
197 if h then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
198 c("<number> (line "..d[r]..") "..o[r].." -> "..n)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
199 h=h+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
200 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
201 o[r]=n
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
202 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
203 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
204 local function z(m)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
205 local t=o[m]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
206 local n=e(t,1,1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
207 local f=(n=="'")and'"'or"'"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
208 local t=e(t,2,-2)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209 local a=1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
210 local l,s=0,0
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 while a<=#t do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
212 local c=e(t,a,a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 if c=="\\"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 local o=a+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
215 local d=e(t,o,o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
216 local h=r("abfnrtv\\\n\r\"\'0123456789",d,1,true)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
217 if not h then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
218 t=e(t,1,a-1)..e(t,o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219 a=a+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 elseif h<=8 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
221 a=a+2
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
222 elseif h<=10 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
223 local i=e(t,o,o+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 if i=="\r\n"or i=="\n\r"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
225 t=e(t,1,a).."\n"..e(t,o+2)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
226 elseif h==10 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 t=e(t,1,a).."\n"..e(t,o+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 a=a+2
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230 elseif h<=12 then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
231 if d==n then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
232 l=l+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 a=a+2
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
235 s=s+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
236 t=e(t,1,a-1)..e(t,o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
237 a=a+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
238 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
239 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
240 local i=i(t,"^(%d%d?%d?)",o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
241 o=a+1+#i
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
242 local d=i+0
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
243 local h=u.char(d)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
244 local r=r("\a\b\f\n\r\t\v",h,1,true)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 if r then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246 i="\\"..e("abfnrtv",r,r)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
247 elseif d<32 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
248 i="\\"..d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
249 elseif h==n then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
250 i="\\"..h
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
251 l=l+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
252 elseif h=="\\"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
253 i="\\\\"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
254 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
255 i=h
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256 if h==f then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
257 s=s+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
258 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
259 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
260 t=e(t,1,a-1)..i..e(t,o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
261 a=a+#i
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
262 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
263 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
264 a=a+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
265 if c==f then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
266 s=s+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
267 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
268 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
269 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
270 if l>s then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
271 a=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
272 while a<=#t do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
273 local o,s,i=r(t,"([\'\"])",a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
274 if not o then break end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
275 if i==n then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
276 t=e(t,1,o-2)..e(t,o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
277 a=o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
278 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
279 t=e(t,1,o-1).."\\"..e(t,o)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
280 a=o+2
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
281 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
282 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
283 n=f
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
284 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
285 t=n..t..n
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
286 if t~=o[m]then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
287 if h then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
288 c("<string> (line "..d[m]..") "..o[m].." -> "..t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
289 h=h+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
290 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
291 o[m]=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
292 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
293 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
294 local function _(u)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
295 local t=o[u]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
296 local h=i(t,"^%[=*%[")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
297 local a=#h
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
298 local c=e(t,-a,-1)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
299 local s=e(t,a+1,-(a+1))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
300 local n=""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
301 local t=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
302 while true do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
303 local a,o,r,h=r(s,"([\r\n])([\r\n]?)",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
304 local o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
305 if not a then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
306 o=e(s,t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
307 elseif a>=t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
308 o=e(s,t,a-1)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
309 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
310 if o~=""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
311 if i(o,"%s+$")then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
312 warn.lstring="trailing whitespace in long string near line "..d[u]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
313 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
314 n=n..o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
315 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
316 if not a then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
317 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
318 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
319 t=a+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
320 if a then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
321 if#h>0 and r~=h then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
322 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
323 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
324 if not(t==1 and t==a)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
325 n=n.."\n"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
326 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
327 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
328 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
329 if a>=3 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
330 local e,t=a-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
331 while e>=2 do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
332 local a="%]"..l("=",e-2).."%]"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
333 if not i(n,a)then t=e end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
334 e=e-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
335 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
336 if t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
337 a=l("=",t-2)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
338 h,c="["..a.."[","]"..a.."]"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
339 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
340 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
341 o[u]=h..n..c
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
342 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
343 local function w(u)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
344 local a=o[u]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
345 local h=i(a,"^%-%-%[=*%[")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
346 local t=#h
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
347 local d=e(a,-t,-1)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
348 local s=e(a,t+1,-(t-1))
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
349 local n=""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
350 local a=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
351 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
352 local o,t,r,h=r(s,"([\r\n])([\r\n]?)",a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
353 local t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
354 if not o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
355 t=e(s,a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
356 elseif o>=a then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
357 t=e(s,a,o-1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
358 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
359 if t~=""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
360 local a=i(t,"%s*$")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
361 if#a>0 then t=e(t,1,-(a+1))end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
362 n=n..t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
363 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
364 if not o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
365 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
366 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
367 a=o+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
368 if o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
369 if#h>0 and r~=h then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
370 a=a+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
371 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
372 n=n.."\n"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
373 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
374 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
375 t=t-2
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
376 if t>=3 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
377 local e,a=t-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
378 while e>=2 do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
379 local t="%]"..l("=",e-2).."%]"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
380 if not i(n,t)then a=e end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
381 e=e-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
382 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
383 if a then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
384 t=l("=",a-2)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
385 h,d="--["..t.."[","]"..t.."]"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
386 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
387 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
388 o[u]=h..n..d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
389 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
390 local function p(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
391 local t=o[a]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
392 local i=i(t,"%s*$")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
393 if#i>0 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
394 t=e(t,1,-(i+1))
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
395 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
396 o[a]=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
397 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
398 local function A(o,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
399 if not o then return false end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
400 local t=i(a,"^%-%-%[=*%[")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
401 local t=#t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
402 local i=e(a,-t,-1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
403 local e=e(a,t+1,-(t-1))
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
404 if r(e,o,1,true)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
405 return true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
406 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
407 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
408 function optimize(t,i,r,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
409 local m=t["opt-comments"]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
410 local u=t["opt-whitespace"]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
411 local f=t["opt-emptylines"]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
412 local y=t["opt-eols"]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
413 local I=t["opt-strings"]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
414 local T=t["opt-numbers"]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
415 local O=t.KEEP
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
416 h=t.DETAILS and 0
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
417 c=c or s.print
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
418 if y then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
419 m=true
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
420 u=true
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
421 f=true
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
422 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
423 n,o,d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
424 =i,r,a
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
425 local t=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
426 local a,r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
427 local s
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
428 local function i(i,a,e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
429 e=e or t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
430 n[e]=i or""
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
431 o[e]=a or""
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
432 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
433 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
434 a,r=n[t],o[t]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
435 local h=k(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
436 if h then s=nil end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
437 if a=="TK_EOS"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
438 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
439 elseif a=="TK_KEYWORD"or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
440 a=="TK_NAME"or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
441 a=="TK_OP"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
442 s=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
443 elseif a=="TK_NUMBER"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
444 if T then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
445 x(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
446 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
447 s=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
448 elseif a=="TK_STRING"or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
449 a=="TK_LSTRING"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
450 if I then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
451 if a=="TK_STRING"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
452 z(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
453 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
454 _(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
455 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
456 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
457 s=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
458 elseif a=="TK_COMMENT"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
459 if m then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
460 if t==1 and e(r,1,1)=="#"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
461 p(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
462 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
463 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
464 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
465 elseif u then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
466 p(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
467 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
468 elseif a=="TK_LCOMMENT"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
469 if A(O,r)then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
470 if u then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
471 w(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
472 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
473 s=t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
474 elseif m then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
475 local e=E(r)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
476 if b[n[t+1]]then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
477 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
478 a=""
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
479 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
480 i("TK_SPACE"," ")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
481 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
482 if not f and e>0 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
483 i("TK_EOL",l("\n",e))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
484 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
485 if u and a~=""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
486 t=t-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
487 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
488 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
489 if u then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
490 w(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
491 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
492 s=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
493 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
494 elseif a=="TK_EOL"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
495 if h and f then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
496 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
497 elseif r=="\r\n"or r=="\n\r"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
498 i("TK_EOL","\n")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
499 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
500 elseif a=="TK_SPACE"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
501 if u then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
502 if h or g(t)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
503 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
504 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
505 local a=n[s]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
506 if a=="TK_LCOMMENT"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
507 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
508 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
509 local e=n[t+1]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
510 if b[e]then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
511 if(e=="TK_COMMENT"or e=="TK_LCOMMENT")and
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
512 a=="TK_OP"and o[s]=="-"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
513 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
514 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
515 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
516 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
517 local e=v(s,t+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
518 if e==""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
519 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
520 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
521 i("TK_SPACE"," ")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
522 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
523 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
524 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
525 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
526 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
527 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
528 error("unidentified token encountered")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
529 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
530 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
531 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
532 j()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
533 if y then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
534 t=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
535 if n[1]=="TK_COMMENT"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
536 t=3
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
537 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
538 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
539 a,r=n[t],o[t]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
540 if a=="TK_EOS"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
541 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
542 elseif a=="TK_EOL"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
543 local e,a=n[t-1],n[t+1]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
544 if q[e]and q[a]then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
545 local e=v(t-1,t+1)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
546 if e==""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
547 i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
548 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
549 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
550 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
551 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
552 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
553 j()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
554 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
555 if h and h>0 then c()end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
556 return n,o,d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
557 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
558 return{optimize=optimize}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
559 end)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
560 package.preload['optparser']=(function(...)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
561 local _ENV=_ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
562 local function e(t,...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
563 local e=package.loaded[t]or _ENV[t]or{_NAME=t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
564 package.loaded[t]=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
565 for t=1,select("#",...)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
566 (select(t,...))(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
567 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
568 _ENV=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
569 _M=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
570 return e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
571 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
572 local e=_G
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
573 local a=require"string"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
574 local l=require"table"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
575 local s="etaoinshrdlucmfwypvbgkqjxz_ETAOINSHRDLUCMFWYPVBGKQJXZ"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
576 local d="etaoinshrdlucmfwypvbgkqjxz_0123456789ETAOINSHRDLUCMFWYPVBGKQJXZ"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
577 local w={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
578 for e in a.gmatch([[
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
579 and break do else elseif end false for function if in
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
580 local nil not or repeat return then true until while
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
581 self _ENV]],"%S+")do
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
582 w[e]=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
583 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
584 local h,u,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
585 m,o,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
586 c,v,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
587 r,
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
588 n
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
589 local function f(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
590 local i={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
591 for n=1,#e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
592 local e=e[n]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
593 local o=e.name
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
594 if not i[o]then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
595 i[o]={
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
596 decl=0,token=0,size=0,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
597 }
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
598 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
599 local t=i[o]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
600 t.decl=t.decl+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
601 local i=e.xref
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
602 local a=#i
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
603 t.token=t.token+a
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
604 t.size=t.size+a*#o
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
605 if e.decl then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
606 e.id=n
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
607 e.xcount=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
608 if a>1 then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
609 e.first=i[2]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
610 e.last=i[a]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
611 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
612 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
613 t.id=n
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
614 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
615 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
616 return i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
617 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
618 local function y(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
619 local i=a.byte
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
620 local n=a.char
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
621 local a={
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
622 TK_KEYWORD=true,TK_NAME=true,TK_NUMBER=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
623 TK_STRING=true,TK_LSTRING=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
624 }
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
625 if not e["opt-comments"]then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
626 a.TK_COMMENT=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
627 a.TK_LCOMMENT=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
628 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
629 local e={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
630 for t=1,#h do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
631 e[t]=u[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
632 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
633 for t=1,#o do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
634 local t=o[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
635 local a=t.xref
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
636 for t=1,t.xcount do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
637 local t=a[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
638 e[t]=""
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
639 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
640 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
641 local t={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
642 for e=0,255 do t[e]=0 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
643 for o=1,#h do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
644 local o,e=h[o],e[o]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
645 if a[o]then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
646 for a=1,#e do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
647 local e=i(e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
648 t[e]=t[e]+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
649 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
650 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
651 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
652 local function o(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
653 local e={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
654 for o=1,#a do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
655 local a=i(a,o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
656 e[o]={c=a,freq=t[a],}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
657 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
658 l.sort(e,
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
659 function(t,e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
660 return t.freq>e.freq
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
661 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
662 )
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
663 local t={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
664 for a=1,#e do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
665 t[a]=n(e[a].c)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
666 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
667 return l.concat(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
668 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
669 s=o(s)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
670 d=o(d)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
671 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
672 local function p()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
673 local t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
674 local n,h=#s,#d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
675 local e=r
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
676 if e<n then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
677 e=e+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
678 t=a.sub(s,e,e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
679 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
680 local i,o=n,1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
681 repeat
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
682 e=e-i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
683 i=i*h
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
684 o=o+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
685 until i>e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
686 local i=e%n
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
687 e=(e-i)/n
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
688 i=i+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
689 t=a.sub(s,i,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
690 while o>1 do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
691 local i=e%h
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
692 e=(e-i)/h
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
693 i=i+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
694 t=t..a.sub(d,i,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
695 o=o-1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
696 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
697 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
698 r=r+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
699 return t,c[t]~=nil
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
700 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
701 function optimize(e,i,t,s,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
702 h,u,m,o
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
703 =i,t,s,a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
704 r=0
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
705 n={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
706 c=f(m)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
707 v=f(o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
708 if e["opt-entropy"]then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
709 y(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
710 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
711 local e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
712 for t=1,#o do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
713 e[t]=o[t]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
714 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
715 l.sort(e,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
716 function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
717 return t.xcount>e.xcount
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
718 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
719 )
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
720 local a,t,r={},1,false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
721 for o=1,#e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
722 local e=e[o]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
723 if not e.preserve then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
724 a[t]=e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
725 t=t+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
726 elseif e.name=="self"then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
727 r=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
728 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
729 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
730 e=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
731 local s=#e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
732 while s>0 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
733 local h,t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
734 repeat
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
735 h,t=p()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
736 until not w[h]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
737 n[#n+1]=h
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
738 local a=s
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
739 if t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
740 local i=m[c[h].id].xref
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
741 local n=#i
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
742 for t=1,s do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
743 local t=e[t]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
744 local s,e=t.act,t.rem
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
745 while e<0 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
746 e=o[-e].rem
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
747 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
748 local o
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
749 for t=1,n do
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
750 local t=i[t]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
751 if t>=s and t<=e then o=true end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
752 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
753 if o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
754 t.skip=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
755 a=a-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
756 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
757 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
758 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
759 while a>0 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
760 local t=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
761 while e[t].skip do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
762 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
763 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
764 a=a-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
765 local i=e[t]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
766 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
767 i.newname=h
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
768 i.skip=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
769 i.done=true
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
770 local s,h=i.first,i.last
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
771 local r=i.xref
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
772 if s and a>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
773 local n=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
774 while n>0 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
775 while e[t].skip do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
776 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
777 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
778 n=n-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
779 local e=e[t]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
780 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
781 local n,t=e.act,e.rem
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
782 while t<0 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
783 t=o[-t].rem
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
784 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
785 if not(h<n or s>t)then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
786 if n>=i.act then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
787 for o=1,i.xcount do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
788 local o=r[o]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
789 if o>=n and o<=t then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
790 a=a-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
791 e.skip=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
792 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
793 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
794 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
795 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
796 if e.last and e.last>=i.act then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
797 a=a-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
798 e.skip=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
799 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
800 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
801 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
802 if a==0 then break end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
803 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
804 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
805 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
806 local a,t={},1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
807 for o=1,s do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
808 local e=e[o]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
809 if not e.done then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
810 e.skip=false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
811 a[t]=e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
812 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
813 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
814 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
815 e=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
816 s=#e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
817 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
818 for e=1,#o do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
819 local e=o[e]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
820 local t=e.xref
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
821 if e.newname then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
822 for a=1,e.xcount do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
823 local t=t[a]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
824 u[t]=e.newname
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
825 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
826 e.name,e.oldname
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
827 =e.newname,e.name
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
828 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
829 e.oldname=e.name
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
830 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
831 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
832 if r then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
833 n[#n+1]="self"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
834 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
835 local e=f(o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
836 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
837 return{optimize=optimize}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
838 end)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
839 package.preload['llex']=(function(...)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
840 local _ENV=_ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
841 local function e(t,...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
842 local e=package.loaded[t]or _ENV[t]or{_NAME=t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
843 package.loaded[t]=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
844 for t=1,select("#",...)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
845 (select(t,...))(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
846 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
847 _ENV=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
848 _M=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
849 return e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
850 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
851 local y=_G
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
852 local s=require"string"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
853 local l=s.find
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
854 local c=s.match
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
855 local n=s.sub
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
856 local e=''
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
857 local r=''
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
858 local a=1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
859 local d=1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
860 local m={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
861 local w={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
862 local p={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
863 local i=''
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
864 local v={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
865 for e in s.gmatch([[
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
866 and break do else elseif end false for function if in
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
867 local nil not or repeat return then true until while]],"%S+")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
868 v[e]=true
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
869 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
870 local function o(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
871 local e=#m+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
872 m[e]=a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
873 w[e]=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
874 p[e]=d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
875 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
876 local function h(t,s)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
877 local n=n
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
878 local i=n(e,t,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
879 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
880 local e=n(e,t,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
881 if(e=="\n"or e=="\r")and(e~=i)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
882 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
883 i=i..e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
884 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
885 if s then o("TK_EOL",i)end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
886 d=d+1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
887 a=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
888 return t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
889 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
890 function init(i,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
891 e=i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
892 r=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
893 local t,n,e,i=l(e,"^(#[^\r\n]*)(\r?\n?)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
894 if t then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
895 a=a+#e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
896 o("TK_COMMENT",e)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
897 if#i>0 then h(a,true)end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
898 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
899 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
900 function chunkid()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
901 if r and c(r,"^[=@]")then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
902 return n(r,2)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
903 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
904 return"[string]"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
905 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
906 function errorline(t,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
907 local e=error or y.error
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
908 e(s.format("%s:%d: %s",chunkid(),a or d,t))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
909 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
910 local r=errorline
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
911 local function u(t)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
912 local i=n
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
913 local n=i(e,t,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
914 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
915 local o=#c(e,"=*",t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
916 t=t+o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
917 a=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
918 return(i(e,t,t)==n)and o or(-o)-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
919 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
920 local function f(d,s)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
921 local t=a+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
922 local n=n
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
923 local o=n(e,t,t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
924 if o=="\r"or o=="\n"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
925 t=h(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
926 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
927 local o=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
928 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
929 local o,c,l=l(e,"([\r\n%]])",t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
930 if not o then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
931 r(d and"unfinished long string"or
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
932 "unfinished long comment")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
933 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
934 t=o
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
935 if l=="]"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
936 if u(t)==s then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
937 i=n(e,i,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
938 a=a+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
939 return i
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
940 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
941 t=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
942 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
943 i=i.."\n"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
944 t=h(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
945 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
946 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
947 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
948 local function b(u)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
949 local t=a
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
950 local s=l
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
951 local d=n
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
952 while true do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
953 local n,l,o=s(e,"([\n\r\\\"\'])",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
954 if n then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
955 if o=="\n"or o=="\r"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
956 r("unfinished string")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
957 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
958 t=n
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
959 if o=="\\"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
960 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
961 o=d(e,t,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
962 if o==""then break end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
963 n=s("abfnrtv\n\r",o,1,true)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
964 if n then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
965 if n>7 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
966 t=h(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
967 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
968 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
969 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
970 elseif s(o,"%D")then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
971 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
972 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
973 local o,a,e=s(e,"^(%d%d?%d?)",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
974 t=a+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
975 if e+1>256 then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
976 r("escape sequence too large")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
977 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
978 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
979 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
980 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
981 if o==u then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
982 a=t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
983 return d(e,i,t-1)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
984 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
985 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
986 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
987 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
988 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
989 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
990 r("unfinished string")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
991 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
992 function llex()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
993 local s=l
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
994 local d=c
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
995 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
996 local t=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
997 while true do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
998 local c,m,l=s(e,"^([_%a][_%w]*)",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
999 if c then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1000 a=t+#l
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1001 if v[l]then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1002 o("TK_KEYWORD",l)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1003 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1004 o("TK_NAME",l)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1005 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1006 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1007 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1008 local l,m,c=s(e,"^(%.?)%d",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1009 if l then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1010 if c=="."then t=t+1 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1011 local u,h,i=s(e,"^%d*[%.%d]*([eE]?)",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1012 t=h+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1013 if#i==1 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1014 if d(e,"^[%+%-]",t)then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1015 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1016 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1017 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1018 local i,t=s(e,"^[_%w]*",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1019 a=t+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1020 local e=n(e,l,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1021 if not y.tonumber(e)then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1022 r("malformed number")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1023 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1024 o("TK_NUMBER",e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1025 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1026 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1027 local m,w,c,l=s(e,"^((%s)[ \t\v\f]*)",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1028 if m then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1029 if l=="\n"or l=="\r"then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1030 h(t,true)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1031 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1032 a=w+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1033 o("TK_SPACE",c)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1034 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1035 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1036 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1037 local h=d(e,"^%p",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1038 if h then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1039 i=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1040 local l=s("-[\"\'.=<>~",h,1,true)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1041 if l then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1042 if l<=2 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1043 if l==1 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1044 local r=d(e,"^%-%-(%[?)",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1045 if r then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1046 t=t+2
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1047 local h=-1
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1048 if r=="["then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1049 h=u(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1050 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1051 if h>=0 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1052 o("TK_LCOMMENT",f(false,h))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1053 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1054 a=s(e,"[\n\r]",t)or(#e+1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1055 o("TK_COMMENT",n(e,i,a-1))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1056 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1057 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1058 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1059 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1060 local e=u(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1061 if e>=0 then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1062 o("TK_LSTRING",f(true,e))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1063 elseif e==-1 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1064 o("TK_OP","[")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1065 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1066 r("invalid long string delimiter")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1067 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1068 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1069 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1070 elseif l<=5 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1071 if l<5 then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1072 a=t+1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1073 o("TK_STRING",b(h))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1074 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1075 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1076 h=d(e,"^%.%.?%.?",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1077 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1078 h=d(e,"^%p=?",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1079 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1080 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1081 a=t+#h
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1082 o("TK_OP",h)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1083 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1084 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1085 local e=n(e,t,t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1086 if e~=""then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1087 a=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1088 o("TK_OP",e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1089 break
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1090 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1091 o("TK_EOS","")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1092 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1093 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1094 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1095 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1096 return{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1097 llex=llex,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1098 init=init,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1099 chunkid=chunkid,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1100 tok=m,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1101 tokln=p,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1102 seminfo=w
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1103 }
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1104 end)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1105 package.preload['lparser']=(function(...)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1106 local _ENV=_ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1107 local function e(t,...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1108 local e=package.loaded[t]or _ENV[t]or{_NAME=t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1109 package.loaded[t]=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1110 for t=1,select("#",...)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1111 (select(t,...))(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1112 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1113 _ENV=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1114 _M=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1115 return e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1116 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1117 local U=_G
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1118 local b=require"string"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1119 local D={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1120 local T,
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1121 j,
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1122 A,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1123 C,
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1124 d,
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1125 r,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1126 P,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1127 t,k,l,y,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1128 p,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1129 a,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1130 W,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1131 q,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1132 N,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1133 u,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1134 g,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1135 E
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1136 local f,n,w,_,x,v
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1137 local e=b.gmatch
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1138 local H={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1139 for e in e("else elseif end until <eof>","%S+")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1140 H[e]=true
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1141 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1142 local Y={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1143 for e in e("if while do for repeat function local return break","%S+")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1144 Y[e]=e.."_stat"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1145 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1146 local S={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1147 local V={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1148 for e,a,t in e([[
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1149 {+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{% 7 7}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1150 {^ 10 9}{.. 5 4}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1151 {~= 3 3}{== 3 3}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1152 {< 3 3}{<= 3 3}{> 3 3}{>= 3 3}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1153 {and 2 2}{or 1 1}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1154 ]],"{(%S+)%s(%d+)%s(%d+)}")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1155 S[e]=a+0
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1156 V[e]=t+0
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1157 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1158 local Z={["not"]=true,["-"]=true,
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1159 ["#"]=true,}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1160 local ee=8
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1161 local function o(t,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1162 local e=error or U.error
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1163 e(b.format("(source):%d: %s",a or l,t))
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1164 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1165 local function e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1166 P=A[d]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1167 t,k,l,y
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1168 =T[d],j[d],A[d],C[d]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1169 d=d+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1170 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1171 local function X()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1172 return T[d]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1173 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1174 local function s(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1175 local e=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1176 if e~="<number>"and e~="<string>"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1177 if e=="<name>"then e=k end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1178 e="'"..e.."'"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1179 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1180 o(a.." near "..e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1181 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1182 local function c(e)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1183 s("'"..e.."' expected")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1184 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1185 local function o(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1186 if t==a then e();return true end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1187 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1188 local function L(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1189 if t~=e then c(e)end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1190 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1191 local function i(t)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1192 L(t);e()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1193 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1194 local function F(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1195 if not e then s(t)end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1196 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1197 local function h(e,a,t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1198 if not o(e)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1199 if t==l then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1200 c(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1201 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1202 s("'"..e.."' expected (to close '"..a.."' at line "..t..")")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1203 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1204 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1205 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1206 local function c()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1207 L("<name>")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1208 local t=k
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1209 p=y
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1210 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1211 return t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1212 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1213 local function I(e,t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1214 e.k="VK"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1215 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1216 local function R(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1217 I(e,c())
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1218 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1219 local function m(o,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1220 local e=a.bl
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1221 local t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1222 if e then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1223 t=e.locallist
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1224 else
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1225 t=a.locallist
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1226 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1227 local e=#u+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1228 u[e]={
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1229 name=o,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1230 xref={p},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1231 decl=p,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1232 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1233 if i or o=="_ENV"then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1234 u[e].preserve=true
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1235 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1236 local a=#g+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1237 g[a]=e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1238 E[a]=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1239 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1240 local function z(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1241 local t=#g
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1242 while e>0 do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1243 e=e-1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1244 local t=t-e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1245 local a=g[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1246 local e=u[a]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1247 local o=e.name
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1248 e.act=y
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1249 g[t]=nil
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1250 local i=E[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1251 E[t]=nil
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1252 local t=i[o]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1253 if t then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1254 e=u[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1255 e.rem=-a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1256 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1257 i[o]=a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1258 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1259 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1260 local function O()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1261 local t=a.bl
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1262 local e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1263 if t then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1264 e=t.locallist
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1265 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1266 e=a.locallist
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1267 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1268 for t,e in U.pairs(e)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1269 local e=u[e]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1270 e.rem=y
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1271 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1272 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1273 local function y(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1274 if b.sub(e,1,1)=="("then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1275 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1276 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1277 m(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1278 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1279 local function U(o,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1280 local t=o.bl
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1281 local e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1282 if t then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1283 e=t.locallist
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1284 while e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1285 if e[a]then return e[a]end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1286 t=t.prev
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1287 e=t and t.locallist
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1288 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1289 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1290 e=o.locallist
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1291 return e[a]or-1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1292 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1293 local function b(t,o,e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1294 if t==nil then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1295 e.k="VGLOBAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1296 return"VGLOBAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1297 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1298 local a=U(t,o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1299 if a>=0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1300 e.k="VLOCAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1301 e.id=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1302 return"VLOCAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1303 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1304 if b(t.prev,o,e)=="VGLOBAL"then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1305 return"VGLOBAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1306 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1307 e.k="VUPVAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1308 return"VUPVAL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1309 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1310 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1311 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1312 local function Q(o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1313 local t=c()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1314 b(a,t,o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1315 if o.k=="VGLOBAL"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1316 local e=N[t]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1317 if not e then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1318 e=#q+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1319 q[e]={
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1320 name=t,
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1321 xref={p},
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1322 }
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1323 N[t]=e
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1324 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1325 local e=q[e].xref
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1326 e[#e+1]=p
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1327 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1328 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1329 local e=o.id
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1330 local e=u[e].xref
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1331 e[#e+1]=p
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1332 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1333 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1334 local function p(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1335 local e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1336 e.isbreakable=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1337 e.prev=a.bl
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1338 e.locallist={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1339 a.bl=e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1340 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1341 local function b()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1342 local e=a.bl
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1343 O()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1344 a.bl=e.prev
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1345 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1346 local function B()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1347 local e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1348 if not a then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1349 e=W
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1350 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1351 e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1352 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1353 e.prev=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1354 e.bl=nil
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1355 e.locallist={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1356 a=e
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1357 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1358 local function G()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1359 O()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1360 a=a.prev
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1361 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1362 local function U(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1363 local a={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1364 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1365 R(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1366 t.k="VINDEXED"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1367 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1368 local function K(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1369 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1370 n(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1371 i("]")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1372 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1373 local function M(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1374 local e,a={},{}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1375 if t=="<name>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1376 R(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1377 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1378 K(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1379 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1380 i("=")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1381 n(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1382 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1383 local function O(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1384 if e.v.k=="VVOID"then return end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1385 e.v.k="VVOID"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1386 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1387 local function O(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1388 n(e.v)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1389 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1390 local function J(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1391 local n=l
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1392 local e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1393 e.v={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1394 e.t=a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1395 a.k="VRELOCABLE"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1396 e.v.k="VVOID"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1397 i("{")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1398 repeat
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1399 if t=="}"then break end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1400 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1401 if t=="<name>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1402 if X()~="="then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1403 O(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1404 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1405 M(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1406 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1407 elseif t=="["then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1408 M(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1409 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1410 O(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1411 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1412 until not o(",")and not o(";")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1413 h("}","{",n)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1414 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1415 local function X()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1416 local i=0
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1417 if t~=")"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1418 repeat
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1419 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1420 if t=="<name>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1421 m(c())
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1422 i=i+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1423 elseif t=="..."then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1424 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1425 a.is_vararg=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1426 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1427 s("<name> or '...' expected")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1428 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1429 until a.is_vararg or not o(",")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1430 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1431 z(i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1432 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1433 local function M(n)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1434 local a={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1435 local i=l
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1436 local o=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1437 if o=="("then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1438 if i~=P then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1439 s("ambiguous syntax (function call x new statement)")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1440 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1441 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1442 if t==")"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1443 a.k="VVOID"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1444 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1445 f(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1446 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1447 h(")","(",i)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1448 elseif o=="{"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1449 J(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1450 elseif o=="<string>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1451 I(a,k)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1452 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1453 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1454 s("function arguments expected")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1455 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1456 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1457 n.k="VCALL"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1458 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1459 local function P(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1460 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1461 if t=="("then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1462 local t=l
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1463 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1464 n(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1465 h(")","(",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1466 elseif t=="<name>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1467 Q(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1468 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1469 s("unexpected symbol")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1470 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1471 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1472 local function O(a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1473 P(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1474 while true do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1475 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1476 if t=="."then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1477 U(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1478 elseif t=="["then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1479 local e={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1480 K(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1481 elseif t==":"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1482 local t={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1483 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1484 R(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1485 M(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1486 elseif t=="("or t=="<string>"or t=="{"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1487 M(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1488 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1489 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1490 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1491 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1492 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1493 local function R(o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1494 local t=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1495 if t=="<number>"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1496 o.k="VKNUM"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1497 elseif t=="<string>"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1498 I(o,k)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1499 elseif t=="nil"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1500 o.k="VNIL"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1501 elseif t=="true"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1502 o.k="VTRUE"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1503 elseif t=="false"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1504 o.k="VFALSE"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1505 elseif t=="..."then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1506 F(a.is_vararg==true,
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1507 "cannot use '...' outside a vararg function");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1508 o.k="VVARARG"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1509 elseif t=="{"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1510 J(o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1511 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1512 elseif t=="function"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1513 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1514 x(o,false,l)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1515 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1516 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1517 O(o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1518 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1519 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1520 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1521 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1522 local function k(o,n)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1523 local a=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1524 local i=Z[a]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1525 if i then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1526 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1527 k(o,ee)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1528 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1529 R(o)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1530 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1531 a=t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1532 local t=S[a]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1533 while t and t>n do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1534 local o={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1535 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1536 local e=k(o,V[a])
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1537 a=e
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1538 t=S[a]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1539 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1540 return a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1541 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1542 function n(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1543 k(e,0)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1544 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1545 local function I(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1546 local t={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1547 local e=e.v.k
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1548 F(e=="VLOCAL"or e=="VUPVAL"or e=="VGLOBAL"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1549 or e=="VINDEXED","syntax error")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1550 if o(",")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1551 local e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1552 e.v={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1553 O(e.v)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1554 I(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1555 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1556 i("=")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1557 f(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1558 return
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1559 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1560 t.k="VNONRELOC"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1561 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1562 local function k(e,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1563 i("do")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1564 p(false)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1565 z(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1566 w()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1567 b()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1568 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1569 local function R(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1570 local t=r
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1571 y("(for index)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1572 y("(for limit)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1573 y("(for step)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1574 m(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1575 i("=")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1576 _()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1577 i(",")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1578 _()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1579 if o(",")then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1580 _()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1581 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1582 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1583 k(1,true)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1584 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1585 local function M(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1586 local t={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1587 y("(for generator)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1588 y("(for state)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1589 y("(for control)")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1590 m(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1591 local e=1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1592 while o(",")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1593 m(c())
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1594 e=e+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1595 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1596 i("in")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1597 local a=r
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1598 f(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1599 k(e,false)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1600 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1601 local function F(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1602 local a=false
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1603 Q(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1604 while t=="."do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1605 U(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1606 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1607 if t==":"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1608 a=true
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1609 U(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1610 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1611 return a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1612 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1613 function _()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1614 local e={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1615 n(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1616 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1617 local function k()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1618 local e={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1619 n(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1620 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1621 local function S()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1622 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1623 k()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1624 i("then")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1625 w()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1626 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1627 local function P()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1628 local t,e={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1629 m(c())
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1630 t.k="VLOCAL"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1631 z(1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1632 x(e,false,l)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1633 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1634 local function U()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1635 local e=0
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1636 local t={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1637 repeat
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1638 m(c())
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1639 e=e+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1640 until not o(",")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1641 if o("=")then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1642 f(t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1643 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1644 t.k="VVOID"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1645 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1646 z(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1647 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1648 function f(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1649 n(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1650 while o(",")do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1651 n(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1652 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1653 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1654 function x(a,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1655 B()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1656 i("(")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1657 if t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1658 y("self",true)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1659 z(1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1660 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1661 X()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1662 i(")")
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1663 v()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1664 h("end","function",e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1665 G()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1666 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1667 function w()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1668 p(false)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1669 v()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1670 b()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1671 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1672 function for_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1673 local o=r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1674 p(true)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1675 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1676 local a=c()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1677 local e=t
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1678 if e=="="then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1679 R(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1680 elseif e==","or e=="in"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1681 M(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1682 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1683 s("'=' or 'in' expected")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1684 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1685 h("end","for",o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1686 b()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1687 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1688 function while_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1689 local t=r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1690 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1691 k()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1692 p(true)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1693 i("do")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1694 w()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1695 h("end","while",t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1696 b()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1697 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1698 function repeat_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1699 local t=r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1700 p(true)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1701 p(false)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1702 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1703 v()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1704 h("until","repeat",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1705 k()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1706 b()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1707 b()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1708 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1709 function if_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1710 local a=r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1711 local o={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1712 S()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1713 while t=="elseif"do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1714 S()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1715 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1716 if t=="else"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1717 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1718 w()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1719 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1720 h("end","if",a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1721 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1722 function return_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1723 local a={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1724 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1725 local e=t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1726 if H[e]or e==";"then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1727 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1728 f(a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1729 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1730 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1731 function break_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1732 local t=a.bl
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1733 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1734 while t and not t.isbreakable do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1735 t=t.prev
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1736 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1737 if not t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1738 s("no loop to break")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1739 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1740 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1741 function expr_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1742 local e={}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1743 e.v={}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1744 O(e.v)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1745 if e.v.k=="VCALL"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1746 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1747 e.prev=nil
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1748 I(e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1749 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1750 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1751 function function_stat()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1752 local a=r
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1753 local o,t={},{}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1754 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1755 local e=F(o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1756 x(t,e,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1757 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1758 function do_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1759 local t=r
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1760 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1761 w()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1762 h("end","do",t)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1763 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1764 function local_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1765 e()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1766 if o("function")then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1767 P()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1768 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1769 U()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1770 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1771 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1772 local function i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1773 r=l
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1774 local e=t
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1775 local t=Y[e]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1776 if t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1777 D[t]()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1778 if e=="return"or e=="break"then return true end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1779 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1780 expr_stat()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1781 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1782 return false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1783 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1784 function v()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1785 local e=false
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1786 while not e and not H[t]do
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1787 e=i()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1788 o(";")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1789 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1790 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1791 function parser()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1792 B()
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1793 a.is_vararg=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1794 e()
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1795 v()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1796 L("<eof>")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1797 G()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1798 return q,u
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1799 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1800 function init(e,o,n)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1801 d=1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1802 W={}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1803 local t=1
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1804 T,j,A,C={},{},{},{}
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1805 for a=1,#e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1806 local e=e[a]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1807 local i=true
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1808 if e=="TK_KEYWORD"or e=="TK_OP"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1809 e=o[a]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1810 elseif e=="TK_NAME"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1811 e="<name>"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1812 j[t]=o[a]
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1813 elseif e=="TK_NUMBER"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1814 e="<number>"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1815 j[t]=0
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1816 elseif e=="TK_STRING"or e=="TK_LSTRING"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1817 e="<string>"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1818 j[t]=""
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1819 elseif e=="TK_EOS"then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1820 e="<eof>"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1821 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1822 i=false
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1823 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1824 if i then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1825 T[t]=e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1826 A[t]=n[a]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1827 C[t]=a
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1828 t=t+1
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1829 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1830 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1831 q,N,u={},{},{}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1832 g,E={},{}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1833 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1834 D={
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1835 expr=n,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1836 exp1=_,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1837 explist1=f,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1838 body=x,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1839 block=w,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1840 for_stat=for_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1841 while_stat=while_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1842 repeat_stat=repeat_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1843 if_stat=if_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1844 return_stat=return_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1845 break_stat=break_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1846 expr_stat=expr_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1847 function_stat=function_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1848 do_stat=do_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1849 local_stat=local_stat,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1850 chunk=v,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1851 parser=parser,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1852 init=init
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1853 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1854 return D
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1855 end)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1856 package.preload['minichunkspy']=(function(...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1857 local _ENV=_ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1858 local function e(t,...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1859 local e=package.loaded[t]or _ENV[t]or{_NAME=t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1860 package.loaded[t]=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1861 for t=1,select("#",...)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1862 (select(t,...))(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1863 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1864 _ENV=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1865 _M=e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1866 return e;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1867 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1868 local m,t,u=string,table,math
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1869 local a,v,n,e=ipairs,setmetatable,type,assert
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1870 local a=__END_OF_GLOBALS__
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1871 local c,l,i=m.char,m.byte,m.sub
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1872 local w,d,g=u.frexp,u.ldexp,u.abs
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1873 local p=t.concat
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1874 local a=u.huge
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1875 local k=a-a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1876 local o=false
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1877 local r=4
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1878 local s=4
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1879 local h=8
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1880 local t={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1881 local function y()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1882 t[#t+1]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1883 ={o,r,s,h}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1884 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1885 local function b()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1886 o,r,s,h
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1887 =unpack(t[#t])
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1888 t[#t]=nil
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1889 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1890 local function t(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1891 return e.new(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1892 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1893 local f={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1894 local t=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1895 new=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1896 function(e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1897 local a=a or{}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1898 local t=f[e]or{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1899 __index=e,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1900 __call=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1901 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1902 f[e]=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1903 return v(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1904 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1905 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1906 local j=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1907 unpack=function(t,t,e)return nil,e end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1908 pack=function(e,e)return""end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1909 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1910 local f={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1911 local function v(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1912 local t=f[e]or t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1913 unpack=function(o,a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1914 return i(a,t,t+e-1),t+e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1915 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1916 pack=function(a,t)return i(t,1,e)end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1917 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1918 f[e]=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1919 return t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1920 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1921 local q=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1922 unpack=function(a,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1923 return l(t,e,e),e+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1924 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1925 pack=function(t,e)return c(e)end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1926 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1927 local i=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1928 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1929 function(t,e,n)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1930 local i,e,t,a=l(e,n,n+3)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1931 if o then i,e,t,a=a,t,e,i end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1932 return i+e*256+t*256^2+a*256^3,n+4
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1933 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1934 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1935 function(t,s)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1936 e(n(s)=="number",
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1937 "unexpected value type to pack as an uint32")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1938 local i,a,t,e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1939 e=s%2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1940 i=e%256;e=(e-i)/256
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1941 a=e%256;e=(e-a)/256
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1942 t=e%256;e=(e-t)/256
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1943 if o then i,a,t,e=e,t,a,i end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1944 return c(i,a,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1945 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1946 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1947 local x=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1948 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1949 function(a,e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1950 local a=i:unpack(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1951 local e=i:unpack(e,t+4)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1952 if o then a,e=e,a end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1953 return a+e*2^32,t+8
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1954 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1955 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1956 function(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1957 e(n(t)=="number",
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1958 "unexpected value type to pack as an uint64")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1959 local e=t%2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1960 local t=(t-e)/2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1961 if o then e,t=t,e end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1962 return i:pack(e)..i:pack(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1963 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1964 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1965 local function E(e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1966 local t=i:unpack(e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1967 local e=i:unpack(e,a+4)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1968 if o then t,e=e,t end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1969 local a=e%2^20
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1970 local t=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1971 local o=t+a*2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1972 e=(e-a)/2^20
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1973 local t=e%2^11
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1974 local e=e<=t and 1 or-1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1975 return e,t,o
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1976 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1977 local function c(n,a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1978 local e=t%2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1979 local t=(t-e)/2^32
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1980 local e=e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1981 local t=((n<0 and 2^11 or 0)+a)*2^20+t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1982 if o then e,t=t,e end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1983 return i.pack(nil,e)..i.pack(nil,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1984 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1985 local function _(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1986 if e~=e then return e end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1987 if e==0 then e=1/e end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1988 return e>0 and 1 or-1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1989 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1990 local l=d(1,-1022-52)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1991 local f=l*2^52
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1992 local z=d(2^52-1,-1022-52)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1993 local f=d(2^53-1,1023-52)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1994 e(l~=0 and l/2==0)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1995 e(f~=a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1996 e(f*2==a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1997 local d=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1998 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
1999 function(t,e,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2000 local n,o,t=E(e,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2001 local e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2002 if o==0 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2003 e=d(t,-1022-52)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2004 elseif o==2047 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2005 e=t==0 and a or k
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2006 else
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2007 e=d(2^52+t,o-1023-52)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2008 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2009 e=n*e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2010 return e,i+8
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2011 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2012 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2013 function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2014 if e~=e then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2015 return c(1,2047,2^52-1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2016 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2017 local o=_(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2018 e=g(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2019 if e==a then return c(o,2047,0)end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2020 if e==0 then return c(o,0,0)end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2021 local t,a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2022 if e<=z then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2023 t=0
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2024 a=e/l
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2025 else
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2026 local o,e=w(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2027 a=(2*o-1)*2^52
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2028 t=e+1022
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2029 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2030 return c(o,t,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2031 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2032 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2033 local a=q
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2034 local l={
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2035 [4]=i,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2036 [8]=x
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2037 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2038 local w={
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2039 [4]=float,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2040 [8]=d
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2041 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2042 local c=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2043 unpack=function(a,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2044 return l[r]:unpack(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2045 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2046 pack=function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2047 return l[r]:pack(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2048 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2049 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2050 local i=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2051 unpack=function(a,e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2052 return l[s]:unpack(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2053 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2054 pack=function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2055 return l[s]:pack(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2056 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2057 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2058 local g=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2059 unpack=function(a,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2060 return w[h]:unpack(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2061 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2062 pack=function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2063 return w[h]:pack(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2064 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2065 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2066 local k=v(4)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2067 local f=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2068 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2069 function(t,s,o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2070 local i={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2071 local e,a=1,1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2072 while t[e]do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2073 local n=t[e]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2074 local t=n.name
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2075 if not t then t,a=a,a+1 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2076 i[t],o=n:unpack(s,o)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2077 e=e+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2078 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2079 return i,o
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2080 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2081 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2082 function(a,n)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2083 local i={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2084 local e,t=1,1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2085 while a[e]do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2086 local o=a[e]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2087 local a=o.name
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2088 if not a then a,t=t,t+1 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2089 i[e]=o:pack(n[a])
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2090 e=e+1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2091 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2092 return p(i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2093 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2094 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2095 local d=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2096 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2097 function(n,t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2098 local o,e=i:unpack(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2099 local a={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2100 local i=n.type
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2101 for o=1,o do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2102 a[o],e=i:unpack(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2103 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2104 return a,e
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2105 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2106 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2107 function(o,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2108 local t=#a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2109 local e={i:pack(t)}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2110 local o=o.type
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2111 for t=1,t do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2112 e[#e+1]=o:pack(a[t])
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2113 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2114 return p(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2115 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2116 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2117 local q=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2118 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2119 function(o,a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2120 local t,a=i:unpack(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2121 e(t==0 or t==1,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2122 "unpacked an unexpected value "..t.." for a Boolean")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2123 return t==1,a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2124 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2125 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2126 function(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2127 e(n(t)=="boolean",
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2128 "unexpected value type to pack as a Boolean")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2129 return i:pack(t and 1 or 0)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2130 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2131 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2132 local c=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2133 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2134 function(t,a,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2135 local t,e=c:unpack(a,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2136 local o=nil
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2137 if t>0 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2138 local t=t-1
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2139 o=a:sub(e,e+t-1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2140 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2141 return o,e+t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2142 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2143 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2144 function(a,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2145 e(n(t)=="nil"or n(t)=="string",
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2146 "unexpected value type to pack as a String")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2147 if t==nil then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2148 return c:pack(0)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2149 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2150 return c:pack(#t+1)..t.."\000"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2151 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2152 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2153 local p=f{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2154 v(4){name="signature"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2155 a{name="version"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2156 a{name="format"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2157 a{name="endianness"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2158 a{name="sizeof_int"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2159 a{name="sizeof_size_t"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2160 a{name="sizeof_insn"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2161 a{name="sizeof_Number"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2162 a{name="integral_flag"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2163 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2164 local v={
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2165 [0]=j,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2166 [1]=q,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2167 [3]=g,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2168 [4]=c,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2169 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2170 local g=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2171 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2172 function(i,o,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2173 local t,i=a:unpack(o,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2174 local a=v[t]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2175 e(a,"unknown constant type "..t.." to unpack")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2176 local a,o=a:unpack(o,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2177 if t==3 then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2178 e(n(a)=="number")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2179 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2180 return{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2181 type=t,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2182 value=a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2183 },o
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2184 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2185 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2186 function(t,e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2187 local e,t=e.type,e.value
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2188 return a:pack(e)..v[e]:pack(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2189 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2190 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2191 local v=f{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2192 c{name="name"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2193 i{name="startpc"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2194 i{name="endpc"}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2195 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2196 local a=f{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2197 c{name="name"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2198 i{name="line"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2199 i{name="last_line"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2200 a{name="num_upvalues"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2201 a{name="num_parameters"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2202 a{name="is_vararg"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2203 a{name="max_stack_size"},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2204 d{name="insns",type=k},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2205 d{name="constants",type=g},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2206 d{name="prototypes",type=nil},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2207 d{name="source_lines",type=i},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2208 d{name="locals",type=v},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2209 d{name="upvalues",type=c},
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2210 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2211 e(a[10].name=="prototypes",
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2212 "missed the function prototype list")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2213 a[10].type=a
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2214 local a=t{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2215 unpack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2216 function(i,d,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2217 local n={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2218 local t,i=p:unpack(d,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2219 e(t.signature=="\027Lua","signature check failed")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2220 e(t.version==81,"version mismatch")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2221 e(t.format==0,"format mismatch")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2222 e(t.endianness==0 or
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2223 t.endianness==1,"endianness mismatch")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2224 e(l[t.sizeof_int],"int size unsupported")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2225 e(l[t.sizeof_size_t],"size_t size unsupported")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2226 e(t.sizeof_insn==4,"insn size unsupported")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2227 e(w[t.sizeof_Number],"number size unsupported")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2228 e(t.integral_flag==0,"integral flag mismatch; only floats supported")
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2229 y()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2230 o=t.endianness==0
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2231 r=t.sizeof_size_t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2232 s=t.sizeof_int
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2233 h=t.sizeof_Number
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2234 n.header=t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2235 n.body,i=a:unpack(d,i)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2236 b()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2237 return n,i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2238 end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2239 pack=
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2240 function(e,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2241 local i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2242 y()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2243 local e=t.header
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2244 o=e.endianness==0
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2245 r=e.sizeof_size_t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2246 s=e.sizeof_int
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2247 h=e.sizeof_Number
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2248 i=p:pack(t.header)..a:pack(t.body)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2249 b()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2250 return i
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2251 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2252 }
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2253 local function o(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2254 if n(e)=="function"then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2255 return o(m.dump(e))
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2256 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2257 local t=a:unpack(e,1)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2258 local a=a:pack(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2259 if e==a then return true end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2260 local t
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2261 local t=u.min(#e,#a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2262 for t=1,t do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2263 local a=e:sub(t,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2264 local e=e:sub(t,t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2265 if a~=e then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2266 return false,("chunk roundtripping failed: "..
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2267 "first byte difference at index %d"):format(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2268 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2269 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2270 return false,("chunk round tripping failed: "..
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2271 "original length %d vs. %d"):format(#e,#a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2272 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2273 return{
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2274 disassemble=function(e)return a:unpack(e,1)end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2275 assemble=function(e)return a:pack(e)end,
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2276 validate=o
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2277 }
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2278 end)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2279 do local e={};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2280 e["vio"]="local vio = {};\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2281 vio.__index = vio; \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2282 \9\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2283 function vio.open(string)\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2284 \9return setmetatable({ pos = 1, data = string }, vio);\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2285 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2286 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2287 function vio:read(format, ...)\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2288 \9if self.pos >= #self.data then return; end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2289 \9if format == \"*a\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2290 \9\9local oldpos = self.pos;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2291 \9\9self.pos = #self.data;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2292 \9\9return self.data:sub(oldpos, self.pos);\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2293 \9elseif format == \"*l\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2294 \9\9local data;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2295 \9\9data, self.pos = self.data:match(\"([^\\r\\n]*)\\r?\\n?()\", self.pos)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2296 \9\9return data;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2297 \9elseif format == \"*n\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2298 \9\9local data;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2299 \9\9data, self.pos = self.data:match(\"(%d+)()\", self.pos)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2300 \9\9return tonumber(data);\9\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2301 \9elseif type(format) == \"number\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2302 \9\9local oldpos = self.pos;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2303 \9\9self.pos = self.pos + format;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2304 \9\9return self.data:sub(oldpos, self.pos-1);\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2305 \9end\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2306 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2307 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2308 function vio:seek(whence, offset)\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2309 \9if type(whence) == \"number\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2310 \9\9whence, offset = \"cur\", whence;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2311 \9end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2312 \9offset = offset or 0;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2313 \9\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2314 \9if whence == \"cur\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2315 \9\9self.pos = self.pos + offset;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2316 \9elseif whence == \"set\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2317 \9\9self.pos = offset + 1;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2318 \9elseif whence == \"end\" then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2319 \9\9self.pos = #self.data - offset;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2320 \9end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2321 \9\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2322 \9return self.pos;\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2323 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2324 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2325 local function _readline(f) return f:read(\"*l\"); end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2326 function vio:lines()\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2327 \9return _readline, self;\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2328 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2329 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2330 function vio:write(...)\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2331 \9for i=1,select('#', ...) do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2332 \9\9local dat = tostring(select(i, ...));\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2333 \9\9self.data = self.data:sub(1, self.pos-1)..dat..self.data:sub(self.pos+#dat, -1);\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2334 \9end\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2335 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2336 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2337 function vio:close()\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2338 \9self.pos, self.data = nil, nil;\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2339 end\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2340 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2341 "e["gunzip.lua"]="local base_char,keywords=128,{\"and\",\"break\",\"do\",\"else\",\"elseif\",\"end\",\"false\",\"for\",\"function\",\"if\",\"in\",\"local\",\"nil\",\"not\",\"or\",\"repeat\",\"return\",\"then\",\"true\",\"until\",\"while\",\"read\",\"nbits\",\"nbits_left_in_byte\",\"wnd_pos\",\"output\",\"val\",\"input\",}; function prettify(code) return code:gsub(\"[\"..string.char(base_char)..\"-\"..string.char(base_char+#keywords)..\"]\", \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2342 \9function (c) return keywords[c:byte()-base_char]; end) end return setfenv(assert(loadstring(prettify[===[ i,h,b,m,l,d,e,y,r,w,\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2343 u,v,l,l=\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2344 assert,error,ipairs,pairs,tostring,type,setmetatable,io,math,table.sort,\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2345 math.max,string.char,io.open,_G;\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2346 p(n)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2347 l={};\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2348 e=e({},l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2349 l:__index(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2350 n=n(l);e[l]=n\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2351 n\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2352 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2353 e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2354 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2355 l(n,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2356 l=l 1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2357 h({n},l+1)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2358 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2359 _(n)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2360 l={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2361 l.outbs=n\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2362 l.wnd={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2363 l.=1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2364 l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2365 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2366 t(l,e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2367 n=l.\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2368 l.outbs(e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2369 l.wnd[n]=e\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2370 l.=n%32768+1\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2371 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2372 n(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2373 i(l,'unexpected end of file')\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2374 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2375 o(n,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2376 n%(l+l)>=l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2377 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2378 a=p((l) 2^l )\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2379 c=e({},{__mode='k'})\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2380 g(o)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2381 l=1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2382 e={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2383 e:()\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2384 n\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2385 l<=#o \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2386 n=o:byte(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2387 l=l+1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2388 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2389 n\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2390 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2391 e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2392 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2393 l\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2394 s(d)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2395 n,l,o=0,0,{};\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2396 o:()\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2397 l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2398 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2399 o:(e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2400 e=e 1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2401 l<e \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2402 e=d:()\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2403 e \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2404 n=n+a[l]*e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2405 l=l+8\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2406 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2407 o=a[e]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2408 a=n%o\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2409 n=(n-a)/o\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2410 l=l-e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2411 a\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2412 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2413 c[o]=\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2414 o\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2415 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2416 f(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2417 c[l] l s(g(l))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2418 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2419 s(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2420 n\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2421 y.type(l)=='file'\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2422 n=(n)l:write(v(n))\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2423 d(l)=='function'\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2424 n=l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2425 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2426 n\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2427 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2428 d(e,o)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2429 l={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2430 o \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2431 e,n m(e)\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2432 n~=0 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2433 l[#l+1]={=e,=n}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2434 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2435 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2436 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2437 n=1,#e-2,2 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2438 o,n,e=e[n],e[n+1],e[n+2]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2439 n~=0 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2440 e=o,e-1 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2441 l[#l+1]={=e,=n}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2442 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2443 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2444 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2445 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2446 w(l,(n,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2447 n.==l. n.<l. n.<l.\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2448 )\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2449 e=1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2450 o=0\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2451 n,l b(l)\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2452 l.~=o \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2453 e=e*a[l.-o]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2454 o=l.\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2455 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2456 l.code=e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2457 e=e+1\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2458 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2459 e=r.huge\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2460 c={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2461 n,l b(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2462 e=r.min(e,l.)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2463 c[l.code]=l.\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2464 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2465 o(n,e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2466 l=0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2467 e=1,e \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2468 e=n%2\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2469 n=(n-e)/2\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2470 l=l*2+e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2471 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2472 l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2473 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2474 d=p(\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2475 (l) a[e]+o(l,e))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2476 l:(a)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2477 o,l=1,0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2478 1 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2479 l==0 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2480 o=d[n(a:(e))]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2481 l=l+e\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2482 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2483 n=n(a:())\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2484 l=l+1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2485 o=o*2+n\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2486 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2487 l=c[o]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2488 l \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2489 l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2490 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2491 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2492 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2493 l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2494 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2495 b(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2496 a=2^1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2497 e=2^2\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2498 c=2^3\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2499 d=2^4\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2500 n=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2501 n=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2502 n=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2503 n=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2504 t=l:(32)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2505 t=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2506 t=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2507 o(n,e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2508 n=l:(16)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2509 e=0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2510 n=1,n \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2511 e=l:(8)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2512 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2513 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2514 o(n,c)\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2515 l:(8)~=0 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2516 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2517 o(n,d)\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2518 l:(8)~=0 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2519 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2520 o(n,a)\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2521 l:(16)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2522 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2523 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2524 p(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2525 f=l:(5)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2526 i=l:(5)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2527 e=n(l:(4))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2528 a=e+4\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2529 e={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2530 o={\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2531 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2532 n=1,a \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2533 l=l:(3)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2534 n=o[n]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2535 e[n]=l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2536 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2537 e=d(e,)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2538 r(o)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2539 t={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2540 a\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2541 c=0\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2542 c<o \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2543 o=e:(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2544 e\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2545 o<=15 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2546 e=1\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2547 a=o\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2548 o==16 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2549 e=3+n(l:(2))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2550 o==17 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2551 e=3+n(l:(3))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2552 a=0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2553 o==18 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2554 e=11+n(l:(7))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2555 a=0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2556 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2557 h'ASSERT'\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2558 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2559 l=1,e \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2560 t[c]=a\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2561 c=c+1\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2562 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2563 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2564 l=d(t,)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2565 l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2566 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2567 n=f+257\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2568 l=i+1\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2569 n=r(n)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2570 l=r(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2571 n,l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2572 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2573 a\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2574 o\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2575 c\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2576 r\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2577 h(e,n,l,d)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2578 l=l:(e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2579 l<256 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2580 t(n,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2581 l==256 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2582 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2583 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2584 a \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2585 l={[257]=3}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2586 e=1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2587 n=258,285,4 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2588 n=n,n+3 l[n]=l[n-1]+e \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2589 n~=258 e=e*2 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2590 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2591 l[285]=258\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2592 a=l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2593 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2594 o \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2595 l={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2596 e=257,285 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2597 n=u(e-261,0)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2598 l[e]=(n-(n%4))/4\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2599 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2600 l[285]=0\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2601 o=l\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2602 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2603 a=a[l]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2604 l=o[l]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2605 l=e:(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2606 o=a+l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2607 c \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2608 e={[0]=1}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2609 l=1\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2610 n=1,29,2 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2611 n=n,n+1 e[n]=e[n-1]+l \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2612 n~=1 l=l*2 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2613 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2614 c=e\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2615 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2616 r \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2617 n={}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2618 e=0,29 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2619 l=u(e-2,0)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2620 n[e]=(l-(l%2))/2\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2621 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2622 r=n\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2623 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2624 l=d:(e)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2625 a=c[l]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2626 l=r[l]\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2627 l=e:(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2628 l=a+l\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2629 e=1,o \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2630 l=(n.-1-l)%32768+1\
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2631 t(n,i(n.wnd[l],'invalid distance'))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2632 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2633 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2634 \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2635 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2636 u(l,a)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2637 i=l:(1)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2638 e=l:(2)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2639 r=0\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2640 o=1\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2641 c=2\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2642 f=3\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2643 e==r \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2644 l:(l:())\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2645 e=l:(16)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2646 o=n(l:(16))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2647 e=1,e \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2648 l=n(l:(8))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2649 t(a,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2650 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2651 e==o e==c \
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2652 n,o\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2653 e==c \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2654 n,o=p(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2655 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2656 n=d{0,8,144,9,256,7,280,8,288,}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2657 o=d{0,5,32,}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2658 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2659 h(\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2660 l,a,n,o\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2661 );\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2662 \
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2663 i~=0\
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2664 \
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2665 e(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2666 n,l=f(l.)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2667 ,_(s(l.))\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2668 u(n,l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2669 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2670 (n)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2671 l=f(n.)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2672 n=s(n.)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2673 b(l)\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2674 e{=l,=n}\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2675 l:(l:())\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2676 l:()\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2677 \
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2678 ]===], '@gunzip.lua')), getfenv())()"e["squish.debug"]="package.preload['minichunkspy']=(function(...)local _ENV=_ENV;local function module(name,...)local t=package.loaded[name]or _ENV[name]or{_NAME=name};package.loaded[name]=t;for i=1,select(\"#\",...)do(select(i,...))(t);end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2679 _ENV=t;_M=t;return t;end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2680 local string,table,math=string,table,math\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2681 local ipairs,setmetatable,type,assert=ipairs,setmetatable,type,assert\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2682 local _=__END_OF_GLOBALS__\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2683 local string_char,string_byte,string_sub=string.char,string.byte,string.sub\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2684 local table_concat=table.concat\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2685 local math_abs,math_ldexp,math_frexp=math.abs,math.ldexp,math.frexp\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2686 local Inf=math.huge\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2687 local Nan=Inf-Inf\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2688 local BIG_ENDIAN=false\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2689 local function construct(class,...)return class.new(class,...)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2690 local mt_memo={}local Field=construct{new=function(class,self)local self=self or{}local mt=mt_memo[class]or{__index=class,__call=construct}mt_memo[class]=mt\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2691 return setmetatable(self,mt)end,}local None=Field{unpack=function(self,bytes,ix)return nil,ix end,pack=function(self,val)return\"\"end}local char_memo={}local function char(n)local field=char_memo[n]or Field{unpack=function(self,bytes,ix)return string_sub(bytes,ix,ix+n-1),ix+n\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2692 end,pack=function(self,val)return string_sub(val,1,n)end}char_memo[n]=field\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2693 return field\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2694 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2695 local uint8=Field{unpack=function(self,bytes,ix)return string_byte(bytes,ix,ix),ix+1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2696 end,pack=function(self,val)return string_char(val)end}local uint32=Field{unpack=function(self,bytes,ix)local a,b,c,d=string_byte(bytes,ix,ix+3)if BIG_ENDIAN then a,b,c,d=d,c,b,a end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2697 return a+b*256+c*256^2+d*256^3,ix+4\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2698 end,pack=function(self,val)assert(type(val)==\"number\",\"unexpected value type to pack as an uint32\")local a,b,c,d\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2699 d=val%2^32\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2700 a=d%256;d=(d-a)/256\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2701 b=d%256;d=(d-b)/256\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2702 c=d%256;d=(d-c)/256\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2703 if BIG_ENDIAN then a,b,c,d=d,c,b,a end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2704 return string_char(a,b,c,d)end}local int32=uint32{unpack=function(self,bytes,ix)local val,ix=uint32:unpack(bytes,ix)return val<2^32 and val or(val-2^31),ix\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2705 end}local Byte=uint8\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2706 local Size_t=uint32\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2707 local Integer=int32\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2708 local Number=char(8)local Insn=char(4)local Struct=Field{unpack=function(self,bytes,ix)local val={}local i,j=1,1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2709 while self[i]do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2710 local field=self[i]local key=field.name\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2711 if not key then key,j=j,j+1 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2712 val[key],ix=field:unpack(bytes,ix)i=i+1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2713 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2714 return val,ix\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2715 end,pack=function(self,val)local data={}local i,j=1,1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2716 while self[i]do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2717 local field=self[i]local key=field.name\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2718 if not key then key,j=j,j+1 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2719 data[i]=field:pack(val[key])i=i+1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2720 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2721 return table_concat(data)end}local List=Field{unpack=function(self,bytes,ix)local len,ix=Integer:unpack(bytes,ix)local vals={}local field=self.type\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2722 for i=1,len do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2723 vals[i],ix=field:unpack(bytes,ix)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2724 return vals,ix\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2725 end,pack=function(self,vals)local len=#vals\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2726 local data={Integer:pack(len)}local field=self.type\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2727 for i=1,len do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2728 data[#data+1]=field:pack(vals[i])end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2729 return table_concat(data)end}local Boolean=Field{unpack=function(self,bytes,ix)local val,ix=Integer:unpack(bytes,ix)assert(val==0 or val==1,\"unpacked an unexpected value \"..val..\" for a Boolean\")return val==1,ix\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2730 end,pack=function(self,val)assert(type(val)==\"boolean\",\"unexpected value type to pack as a Boolean\")return Integer:pack(val and 1 or 0)end}local String=Field{unpack=function(self,bytes,ix)local len,ix=Integer:unpack(bytes,ix)local val=nil\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2731 if len>0 then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2732 local string_len=len-1\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2733 val=bytes:sub(ix,ix+string_len-1)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2734 return val,ix+len\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2735 end,pack=function(self,val)assert(type(val)==\"nil\"or type(val)==\"string\",\"unexpected value type to pack as a String\")if val==nil then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2736 return Integer:pack(0)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2737 return Integer:pack(#val+1)..val..\"\\0\"end}local ChunkHeader=Struct{char(4){name=\"signature\"},Byte{name=\"version\"},Byte{name=\"format\"},Byte{name=\"endianness\"},Byte{name=\"sizeof_int\"},Byte{name=\"sizeof_size_t\"},Byte{name=\"sizeof_insn\"},Byte{name=\"sizeof_Number\"},Byte{name=\"integral_flag\"},}local ConstantTypes={[0]=None,[1]=Boolean,[3]=Number,[4]=String,}local Constant=Field{unpack=function(self,bytes,ix)local t,ix=Byte:unpack(bytes,ix)local field=ConstantTypes[t]assert(field,\"unknown constant type \"..t..\" to unpack\")local v,ix=field:unpack(bytes,ix)return{type=t,value=v},ix\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2738 end,pack=function(self,val)local t,v=val.type,val.value\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2739 return Byte:pack(t)..ConstantTypes[t]:pack(v)end}local Local=Struct{String{name=\"name\"},Integer{name=\"startpc\"},Integer{name=\"endpc\"}}local Function=Struct{String{name=\"name\"},Integer{name=\"line\"},Integer{name=\"last_line\"},Byte{name=\"num_upvalues\"},Byte{name=\"num_parameters\"},Byte{name=\"is_vararg\"},Byte{name=\"max_stack_size\"},List{name=\"insns\",type=Insn},List{name=\"constants\",type=Constant},List{name=\"prototypes\",type=nil},List{name=\"source_lines\",type=Integer},List{name=\"locals\",type=Local},List{name=\"upvalues\",type=String},}assert(Function[10].name==\"prototypes\",\"missed the function prototype list\")Function[10].type=Function\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2740 local Chunk=Struct{ChunkHeader{name=\"header\"},Function{name=\"body\"}}local function validate(chunk)if type(chunk)==\"function\"then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2741 return validate(string.dump(chunk))end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2742 local f=Chunk:unpack(chunk,1)local chunk2=Chunk:pack(f)if chunk==chunk2 then return true end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2743 local i\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2744 local len=math.min(#chunk,#chunk2)for i=1,len do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2745 local a=chunk:sub(i,i)local b=chunk:sub(i,i)if a~=b then\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2746 return false,(\"chunk roundtripping failed: \"..\"first byte difference at index %d\"):format(i)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2747 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2748 return false,(\"chunk round tripping failed: \"..\"original length %d vs. %d\"):format(#chunk,#chunk2)end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2749 return{disassemble=function(chunk)return Chunk:unpack(chunk,1)end,assemble=function(disassembled)return Chunk:pack(disassembled)end,validate=validate}end)local cs=require\"minichunkspy\"local function ___adjust_chunk(chunk,newname,lineshift)local c=cs.disassemble(string.dump(chunk));c.body.name=newname;lineshift=-c.body.line;local function shiftlines(c)c.line=c.line+lineshift;c.last_line=c.last_line+lineshift;for i,line in ipairs(c.source_lines)do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2750 c.source_lines[i]=line+lineshift;end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2751 for i,f in ipairs(c.prototypes)do\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2752 shiftlines(f);end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2753 end\
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2754 shiftlines(c.body);return assert(loadstring(cs.assemble(c),newname))();end\
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2755 "function require_resource(t)return e[t]or error("resource '"..tostring(t).."' not found");end end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2756 pcall(require,"luarocks.require");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2757 local o={v="verbose",vv="very_verbose",o="output",q="quiet",qq="very_quiet",g="debug"}
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2758 local e={use_http=false,module_compat=not not _ENV};
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2759 for t,a in ipairs(arg)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2760 if a:match("^%-")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2761 local t=a:match("^%-%-?([^%s=]+)()")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2762 t=(o[t]or t):gsub("%-+","_");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2763 if t:match("^no_")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2764 t=t:sub(4,-1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2765 e[t]=false;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2766 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2767 e[t]=a:match("=(.*)$")or true;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2768 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2769 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2770 base_path=a;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2771 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2772 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2773 if e.very_verbose then e.verbose=true;end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2774 if e.very_quiet then e.quiet=true;end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2775 local t=function()end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2776 local t,o,s,h=t,t,t,t;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2777 if not e.very_quiet then t=print;end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2778 if not e.quiet then o=print;end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2779 if e.verbose or e.very_verbose then s=print;end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2780 if e.very_verbose then h=print;end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2781 print=s;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2782 local i,d,n={},{},{};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2783 function Module(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2784 if i[e]then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2785 s("Ignoring duplicate module definition for "..e);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2786 return function()end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2787 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2788 local t=#i+1;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2789 i[t]={name=e,url=___fetch_url};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2790 i[e]=i[t];
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2791 return function(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2792 i[t].path=e;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2793 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2794 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2795 function Resource(t,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2796 local e=#n+1;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2797 n[e]={name=t,path=a or t};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2798 return function(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2799 n[e].path=t;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2800 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2801 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2802 function AutoFetchURL(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2803 ___fetch_url=e;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2804 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2805 function Main(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2806 table.insert(d,e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2807 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2808 function Output(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2809 if e.output==nil then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2810 out_fn=t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2811 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2812 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2813 function Option(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2814 t=t:gsub("%-","_");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2815 if e[t]==nil then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2816 e[t]=true;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2817 return function(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2818 e[t]=a;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2819 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2820 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2821 return function()end;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2822 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2823 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2824 function GetOption(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2825 return e[t:gsub('%-','_')];
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2826 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2827 function Message(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2828 if not e.quiet then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2829 o(t);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2830 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2831 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2832 function Error(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2833 if not e.very_quiet then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2834 t(a);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2835 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2836 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2837 function Exit()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2838 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2839 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2840 base_path=(base_path or"."):gsub("/$","").."/"
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2841 squishy_file=base_path.."squishy";
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2842 out_fn=e.output;
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2843 local r,a=pcall(dofile,squishy_file);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2844 if not r then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2845 t("Couldn't read squishy file: "..a);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2846 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2847 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2848 if not out_fn then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2849 t("No output file specified by user or squishy file");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2850 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2851 elseif#d==0 and#i==0 and#n==0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2852 t("No files, modules or resources. Not going to generate an empty file.");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2853 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2854 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2855 local r={};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2856 function r.filesystem(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2857 local e,t=io.open(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2858 if not e then return false,t;end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2859 local t=e:read("*a");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2860 e:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2861 return t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2862 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2863 if e.use_http then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2864 function r.http(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2865 local e=require"socket.http";
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2866 local t,e=e.request(t);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2867 if e==200 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2868 return t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2869 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2870 return false,"HTTP status code: "..tostring(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2871 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2872 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2873 function r.http(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2874 return false,"Module not found. Re-squish with --use-http option to fetch it from "..e;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2875 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2876 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2877 s("Resolving modules...");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2878 do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2879 local e=package.config:sub(1,1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2880 local n=package.config:sub(5,5);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2881 local o=package.path:gsub("[^;]+",function(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2882 if not t:match("^%"..e)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2883 return base_path..t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2884 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2885 end):gsub("/%./","/");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2886 local a=package.cpath:gsub("[^;]+",function(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2887 if not t:match("^%"..e)then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2888 return base_path..t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2889 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2890 end):gsub("/%./","/");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2891 function resolve_module(t,a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2892 t=t:gsub("%.",e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2893 for e in a:gmatch("[^;]+")do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2894 e=e:gsub("%"..n,t);
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2895 h("Looking for "..e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2896 local t=io.open(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2897 if t then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2898 h("Found!");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2899 t:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2900 return e;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2901 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2902 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2903 return nil;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2904 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2905 for a,e in ipairs(i)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2906 if not e.path then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2907 e.path=resolve_module(e.name,o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2908 if not e.path then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2909 t("Couldn't resolve module: "..e.name);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2910 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2911 e.path=e.path:gsub("^"..base_path:gsub("%p","%%%1"),"");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2912 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2913 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2914 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2915 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2916 for a,e in ipairs(i)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2917 if not e.path then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2918 t("Exiting due to missing modules without a path");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2919 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2920 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2921 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2922 if e.list_files or e.list_missing_files then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2923 local function t(t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2924 if e.list_missing_files then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2925 local e=io.open(t);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2926 if e then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2927 e:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2928 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2929 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2930 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2931 io.write(t,"\n");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2932 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2933 for a,e in pairs(d)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2934 t(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2935 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2936 for a,e in ipairs(i)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2937 t(e.path);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2938 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2939 for a,e in ipairs(n)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2940 t(e.path);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2941 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2942 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2943 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2944 o("Writing "..out_fn.."...");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2945 local a,l=io.open(out_fn,"w+");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2946 if not a then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2947 t("Couldn't open output file: "..tostring(l));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2948 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2949 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2950 if e.executable then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2951 if e.executable==true then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2952 a:write("#!/usr/bin/env lua\n");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2953 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2954 a:write("#!"..e.executable,"\n");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2955 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2956 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2957 s("Packing modules...");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2958 for o,i in ipairs(i)do
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2959 local d,s=i.name,i.path;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2960 if i.path:sub(1,1)~="/"then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2961 s=base_path..i.path;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2962 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2963 h("Packing "..d.." ("..s..")...");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2964 local o,n=r.filesystem(s);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2965 if(not o)and i.url then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2966 local e=i.url:gsub("%?",i.path);
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2967 h("Fetching: "..e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2968 if e:match("^https?://")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2969 o,n=r.http(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2970 elseif e:match("^file://")or e:match("^[/%.]")then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2971 local e,t=io.open((e:gsub("^file://","")));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2972 if e then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2973 o,n=e:read("*a");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2974 e:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2975 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2976 o,n=nil,t;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2977 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2978 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2979 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2980 if o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2981 o=o:gsub("^#[^\r\n]*\r?\n","");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2982 if not e.debug then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2983 a:write("package.preload['",d,"'] = (function (...)\n");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2984 if e.module_compat then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2985 a:write[[
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2986 local _ENV = _ENV;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2987 local function module(name, ...)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2988 local t = package.loaded[name] or _ENV[name] or { _NAME = name };
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2989 package.loaded[name] = t;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2990 for i = 1, select("#", ...) do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2991 (select(i, ...))(t);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2992 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2993 _ENV = t;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2994 _M = t;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2995 return t;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2996 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2997 ]];
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
2998 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2999 a:write(o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3000 a:write(" end)\n");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3001 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3002 a:write("package.preload['",d,"'] = assert(loadstring(\n");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3003 a:write(("%q\n"):format(o));
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3004 a:write(", ",("%q"):format("@"..s),"))\n");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3005 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3006 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3007 t("Couldn't pack module '"..d.."': "..(n or"unknown error... path to module file correct?"));
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3008 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3009 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3010 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3011 if#n>0 then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3012 s("Packing resources...")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3013 a:write("do local resources = {};\n");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3014 for o,e in ipairs(n)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3015 local o,e=e.name,e.path;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3016 local e,i=io.open(base_path..e,"rb");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3017 if not e then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3018 t("Couldn't load resource: "..tostring(i));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3019 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3020 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3021 local t=e:read("*a");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3022 local e=0;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3023 t:gsub("(=+)",function(t)e=math.max(e,#t);end);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3024 a:write(("resources[%q] = %q"):format(o,t));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3025 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3026 if e.virtual_io then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3027 local e=require_resource("vio");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3028 if not e then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3029 t("Virtual IO requested but is not enabled in this build of squish");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3030 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3031 a:write(e,"\n")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3032 a:write[[local io_open, io_lines = io.open, io.lines; function io.open(fn, mode)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3033 if not resources[fn] then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3034 return io_open(fn, mode);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3035 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3036 return vio.open(resources[fn]);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3037 end end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3038 function io.lines(fn)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3039 if not resources[fn] then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3040 return io_lines(fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3041 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3042 return vio.open(resources[fn]):lines()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3043 end end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3044 local _dofile = dofile;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3045 function dofile(fn)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3046 if not resources[fn] then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3047 return _dofile(fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3048 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3049 return assert(loadstring(resources[fn]))();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3050 end end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3051 local _loadfile = loadfile;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3052 function loadfile(fn)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3053 if not resources[fn] then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3054 return _loadfile(fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3055 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3056 return loadstring(resources[fn], "@"..fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3057 end end ]]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3058 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3059 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3060 a:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]]
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3061 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3062 h("Finalising...")
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3063 for e,o in pairs(d)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3064 local e,i=io.open(base_path..o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3065 if not e then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3066 t("Failed to open "..o..": "..i);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3067 os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3068 else
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3069 a:write((e:read("*a"):gsub("^#.-\n","")));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3070 e:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3071 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3072 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3073 a:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3074 o("OK!");
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3075 local h=require"optlex"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3076 local r=require"optparser"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3077 local a=require"llex"
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3078 local d=require"lparser"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3079 local i={
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3080 none={};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3081 debug={"whitespace","locals","entropy","comments","numbers"};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3082 default={"comments","whitespace","emptylines","numbers","locals"};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3083 basic={"comments","whitespace","emptylines"};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3084 full={"comments","whitespace","emptylines","eols","strings","numbers","locals","entropy"};
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3085 }
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3086 if e.minify_level and not i[e.minify_level]then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3087 t("Unknown minify level: "..e.minify_level);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3088 t("Available minify levels: none, basic, default, full, debug");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3089 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3090 for a,t in ipairs(i[e.minify_level or"default"]or{})do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3091 if e["minify_"..t]==nil then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3092 e["minify_"..t]=true;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3093 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3094 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3095 local n={
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3096 ["opt-locals"]=e.minify_locals;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3097 ["opt-comments"]=e.minify_comments;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3098 ["opt-entropy"]=e.minify_entropy;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3099 ["opt-whitespace"]=e.minify_whitespace;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3100 ["opt-emptylines"]=e.minify_emptylines;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3101 ["opt-eols"]=e.minify_eols;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3102 ["opt-strings"]=e.minify_strings;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3103 ["opt-numbers"]=e.minify_numbers;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3104 }
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3105 local function i(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3106 t("minify: "..e);os.exit(1);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3107 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3108 local function l(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3109 local t=io.open(e,"rb")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3110 if not t then i("cannot open \""..e.."\" for reading")end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3111 local a=t:read("*a")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3112 if not a then i("cannot read from \""..e.."\"")end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3113 t:close()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3114 return a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3115 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3116 local function u(e,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3117 local t=io.open(e,"wb")
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3118 if not t then i("cannot open \""..e.."\" for writing")end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3119 local a=t:write(a)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3120 if not a then i("cannot write to \""..e.."\"")end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3121 t:close()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3122 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3123 function minify_string(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3124 a.init(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3125 a.llex()
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3126 local t,e,a
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3127 =a.tok,a.seminfo,a.tokln
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3128 if n["opt-locals"]then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3129 r.print=print
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3130 d.init(t,e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3131 local o,a=d.parser()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3132 r.optimize(n,t,e,o,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3133 end
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3134 h.print=print
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3135 t,e,a
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3136 =h.optimize(n,t,e,a)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3137 local e=table.concat(e)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3138 if string.find(e,"\r\n",1,1)or
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3139 string.find(e,"\n\r",1,1)then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3140 h.warn.mixedeol=true
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3141 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3142 return e;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3143 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3144 function minify_file(e,t)
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3145 local e=l(e);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3146 e=minify_string(e);
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3147 u(t,e);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3148 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3149 if e.minify~=false then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3150 o("Minifying "..out_fn.."...");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3151 minify_file(out_fn,out_fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3152 o("OK!");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3153 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3154 local h=require"llex"
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3155 local i=128;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3156 local n={"and","break","do","else","elseif",
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3157 "end","false","for","function","if",
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3158 "in","local","nil","not","or","repeat",
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3159 "return","then","true","until","while"}
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3160 function uglify_file(l,o)
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3161 local r,a=io.open(l);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3162 if not r then
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3163 t("Can't open input file for reading: "..tostring(a));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3164 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3165 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3166 local a,s=io.open(o..".uglified","w+b");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3167 if not a then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3168 t("Can't open output file for writing: "..tostring(s));
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3169 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3170 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3171 local s=r:read("*a");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3172 r:close();
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3173 local r,t=s:match("^(#.-\n)(.+)$");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3174 local t=t or s;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3175 if r then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3176 a:write(r)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3177 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3178 while i+#n<=255 and t:find("["..string.char(i).."-"..string.char(i+#n-1).."]")do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3179 i=i+1;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3180 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3181 if i+#n>255 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3182 a:write(t);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3183 a:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3184 os.rename(o..".uglified",o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3185 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3186 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3187 local d={}
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3188 for t,e in ipairs(n)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3189 d[e]=string.char(i+t);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3190 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3191 local r=0;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3192 s:gsub("(=+)",function(e)r=math.max(r,#e);end);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3193 h.init(t,"@"..l);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3194 h.llex()
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3195 local s=h.seminfo;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3196 if e.uglify_level=="full"and i+#n<255 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3197 local e={};
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3198 for o,a in ipairs(h.tok)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3199 if a=="TK_NAME"or a=="TK_STRING"then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3200 local t=string.format("%q,%q",a,s[o]);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3201 if not e[t]then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3202 e[t]={type=a,value=s[o],count=0};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3203 e[#e+1]=e[t];
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3204 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3205 e[t].count=e[t].count+1;
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3206 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3207 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3208 for t=1,#e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3209 local e=e[t];
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3210 e.score=(e.count)*(#e.value-1)-#string.format("%q",e.value)-1;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3211 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3212 table.sort(e,function(e,t)return e.score>t.score;end);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3213 local t=255-(i+#n);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3214 for t=t+1,#e do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3215 e[t]=nil;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3216 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3217 local t=#n;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3218 for a,e in ipairs(e)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3219 if e.score>0 then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3220 table.insert(n,e.value);
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3221 d[e.value]=string.char(i+t+a);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3222 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3223 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3224 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3225 a:write("local base_char,keywords=",tostring(i),",{");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3226 for t,e in ipairs(n)do
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3227 a:write(string.format("%q",e),',');
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3228 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3229 a:write[[}; function prettify(code) return code:gsub("["..string.char(base_char).."-"..string.char(base_char+#keywords).."]",
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3230 function (c) return keywords[c:byte()-base_char]; end) end ]]
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3231 a:write[[return setfenv(assert(loadstring(prettify]]
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3232 a:write("[",string.rep("=",r+1),"[");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3233 for e,t in ipairs(h.tok)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3234 if t=="TK_KEYWORD"or t=="TK_NAME"or t=="TK_STRING"then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3235 local t=d[s[e]];
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3236 if t then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3237 a:write(t);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3238 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3239 a:write(s[e]);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3240 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3241 else
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3242 a:write(s[e]);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3243 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3244 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3245 a:write("]",string.rep("=",r+1),"]");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3246 a:write(", '@",o,"')), getfenv())()");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3247 a:close();
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3248 os.rename(o..".uglified",o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3249 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3250 if e.uglify then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3251 o("Uglifying "..out_fn.."...");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3252 uglify_file(out_fn,out_fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3253 o("OK!");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3254 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3255 local i=require"minichunkspy"
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3256 function compile_string(t,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3257 local o=string.dump(loadstring(t,a));
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3258 if((not e.debug)or e.compile_strip)and e.compile_strip~=false then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3259 local t=i.disassemble(o);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3260 local function a(e)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3261 e.source_lines,e.locals,e.upvalues={},{},{};
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3262 for t,e in ipairs(e.prototypes)do
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3263 a(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3264 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3265 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3266 s("Stripping debug info...");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3267 a(t.body);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3268 return i.assemble(t);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3269 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3270 return o;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3271 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3272 function compile_file(a,e)
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3273 local o,a=io.open(a);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3274 if not o then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3275 t("Can't open input file for reading: "..tostring(a));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3276 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3277 end
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3278 local a,i=io.open(e..".compiled","w+");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3279 if not a then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3280 t("Can't open output file for writing: "..tostring(i));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3281 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3282 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3283 local i=o:read("*a");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3284 o:close();
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3285 local t,o=i:match("^(#.-\n)(.+)$");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3286 local o=o or i;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3287 if t then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3288 a:write(t)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3289 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3290 a:write(compile_string(o,e));
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3291 os.rename(e..".compiled",e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3292 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3293 if e.compile then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3294 o("Compiling "..out_fn.."...");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3295 compile_file(out_fn,out_fn);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3296 o("OK!");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3297 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3298 function gzip_file(e,a)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3299 local o,e=io.open(e);
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3300 if not o then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3301 t("Can't open input file for reading: "..tostring(e));
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3302 return;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3303 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3304 local e,i=io.open(a..".gzipped","wb+");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3305 if not e then
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3306 t("Can't open output file for writing: "..tostring(i));
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3307 return;
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3308 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3309 local i=o:read("*a");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3310 o:close();
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3311 local n,o=i:match("^(#.-\n)(.+)$");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3312 local o=o or i;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3313 if n then
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3314 e:write(n)
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3315 end
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3316 local i,n=io.open(a..".pregzip","wb+");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3317 if not i then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3318 t("Can't open temp file for writing: "..tostring(n));
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3319 return;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3320 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3321 i:write(o);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3322 i:close();
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3323 local t=io.popen("gzip -c '"..a..".pregzip'");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3324 o=t:read("*a");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3325 t:close();
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3326 os.remove(a..".pregzip");
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3327 local t=0;
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3328 o:gsub("(=+)",function(e)t=math.max(t,#e);end);
472
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3329 e:write("local ungz = (function ()",require_resource"gunzip.lua"," end)()\n");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3330 e:write[[return assert(loadstring((function (i)local o={} ungz{input=i,output=function(b)table.insert(o,string.char(b))end}return table.concat(o)end) ]];
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3331 e:write((string.format("%q",o):gsub("\026","\\026")));
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3332 e:write(", '@",a,"'))()");
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3333 e:close();
864c9dc27c60 buildscripts: Update included squish (now supports Lua 5.2)
Matthew Wild <mwild1@gmail.com>
parents: 428
diff changeset
3334 os.rename(a..".gzipped",a);
370
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3335 end
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3336 if e.gzip then
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3337 o("Gzipping "..out_fn.."...");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3338 gzip_file(out_fn,out_fn);
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3339 o("OK!");
75e7917761c0 Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3340 end