@@ -9,7 +9,7 @@ print("hi")
9
9
10
10
A = 123
11
11
12
- local function a ([ object Object ], [ object Object ], [ object Object ] )
12
+ local function a (p1 , p2 , ... )
13
13
print (' b' )
14
14
end
15
15
local function a ()
20
20
--[[ LOGGING ]] --[[ ]]
21
21
22
22
23
- local TostringValue , TupleToString , List , pprint = do
23
+ local TostringValue , TupleToString , List , pprint do
24
24
local tostring , pcall = tostring , pcall
25
- local function doPathKey ([ object Object ] )
25
+ local function doPathKey (key )
26
26
if type (key ) == " string" and key :find (" ^[%a_][%w_]*$" )then
27
27
return ' .' .. key
28
28
end return ' [' .. TostringValue (key , true ) .. ' ]'
29
29
end local prims = {[" boolean" ] = true [" number" ] = true [" string" ] = true [" userdata" ] = true }
30
- function TostringValue ([ object Object ], [ object Object ], [ object Object ], [ object Object ] )
30
+ function TostringValue (val , short , tab , inline )
31
31
tab = tab or 0
32
32
local typ = type (val )
33
33
local tss , ts = pcall (tostring , val )
@@ -72,13 +72,13 @@ local TostringValue, TupleToString, List, pprint = do
72
72
73
73
else return prefix .. typ .. ' \32 ' .. ts end
74
74
end
75
- function TupleToString ([ object Object ] )
75
+ function TupleToString (... )
76
76
local res = {... }
77
77
for i = 1 , select (' #' , ... ) do
78
78
res [i ] = TostringValue (res [i ])
79
79
end return table.concat (res , " ,\32 " )
80
80
end
81
- function List ([ object Object ] )print ()
81
+ function List (tab )print ()
82
82
for k , v in pairs (tab ) do
83
83
print (" -\32 [" .. TostringValue (k , true ) .. " ]\32 =" , TostringValue (v , true ) .. ' ;' )
84
84
end
@@ -105,7 +105,7 @@ local TostringValue, TupleToString, List, pprint = do
105
105
end
106
106
end
107
107
BLOCKS = 0
108
- function pprint ([ object Object ] )
108
+ function pprint (... )
109
109
print (' [' .. level () .. ' |' .. BLOCKS .. ' ]' , TupleToString (... ))
110
110
end
111
111
end
@@ -114,7 +114,7 @@ function a()
114
114
out :write ()
115
115
end
116
116
117
- local function cprint ([ object Object ], [ object Object ], [ object Object ] )
117
+ local function cprint (txt , col , maxl )
118
118
local out = io.open (" out.ps1" , ' w' )
119
119
local ln , nl = 1
120
120
txt = txt :gsub (' \n ' , " \32 \n " )
@@ -130,7 +130,7 @@ local function cprint([object Object], [object Object], [object Object])
130
130
--[[ os.execute("powershell write-host -NoNewline -foreground "..col.." "..test)]]
131
131
end
132
132
133
- local function splitprint ([ object Object ], [ object Object ] )
133
+ local function splitprint (txt , i )
134
134
local begin , lns = txt :sub (1 , i - 1 ), {}
135
135
for line in begin :gmatch (" [^\n ]+" ) do
136
136
lns [ # lns + 1 ] = line
141
141
142
142
--[[ PARSER ]] --[[ ]]
143
143
144
- local function map ([ object Object ] )
144
+ local function map (tab )
145
145
local res = {}
146
146
for i = 1 , # tab do
147
147
res [tab [i ]] = true
@@ -169,7 +169,7 @@ local Binops, BinopsPriority = {
169
169
170
170
171
171
local Parser = {}
172
- function Parser .new ([ object Object ] )
172
+ function Parser .new (str )
173
173
local lines = {1 }
174
174
for i = 1 , # str do
175
175
if str :byte (i , i ) == 10 then
@@ -183,7 +183,7 @@ function Parser.new([object Object])
183
183
end
184
184
185
185
--[[ Parser stuff]] do
186
- function Parser :Line ([ object Object ] )
186
+ function Parser :Line (i )
187
187
i = i or self .i
188
188
local lines = self .lines
189
189
for line = # lines , 1 , - 1 do
193
193
end
194
194
end error ()
195
195
end
196
- function Parser :Peek ([ object Object ], [ object Object ] )
196
+ function Parser :Peek (func , ... )
197
197
local old = self .i
198
198
return self [func ](self , ... )old
199
199
end
@@ -221,24 +221,24 @@ end
221
221
while self :Comment ()do end
222
222
return self :ActualTrim ()
223
223
end
224
- function Parser :String ([ object Object ], [ object Object ] )
224
+ function Parser :String (str , noTrim )
225
225
local i = noTrim and self .i or self :Trim ()
226
226
if self .str :sub (i , i + # str - 1 ) == str then
227
227
self .i = i + # str return str
228
228
end
229
229
end
230
- function Parser :Match ([ object Object ], [ object Object ] )
230
+ function Parser :Match (pat , noTrim )
231
231
local i = noTrim and self .i or self :Trim ()
232
232
local a , b = self .str :find (pat , i )
233
233
if a == i then
234
234
self .i = b + 1
235
235
return self .str :sub (a , b )
236
236
end
237
237
end
238
- function Parser :Find ([ object Object ], [ object Object ] )
238
+ function Parser :Find (pat , plain )
239
239
return self .str :find (pat , self .i , plain )
240
240
end
241
- function Parser :Keyword ([ object Object ] )
241
+ function Parser :Keyword (word )
242
242
local i , str = self :Trim (), self .str
243
243
local a , b = str :find (" %w+" , i )
244
244
if a == i then
253
253
end
254
254
255
255
--[[ Error handling]] do
256
- function Parser :Assert ([ object Object ], [ object Object ], [ object Object ] )
256
+ function Parser :Assert (cond , err , ... )
257
257
if cond then return end
258
258
err = err :gsub (" %%l" , self :Line ())
259
259
error (err :format (... ))
631
631
assert (expr , " Expected\32 an expression" )
632
632
assert (self :Keyword (" then" ), " Expected\32 `then`" )
633
633
blocks [ # blocks + 1 ] = {expr (self :Block ())}
634
- end local otherwise =
634
+ end local otherwise
635
635
if self :Keyword (" else" )then
636
636
otherwise = self :Block ()
637
637
end
652
652
assert (self :String (' ,' ), " Expected\32 a `,`" )
653
653
local limit = self :Expression ()
654
654
assert (limit , " Expected\32 an expression" )
655
- local step =
655
+ local step
656
656
if self :String (' ,' )then
657
657
step = self :Expression ()
658
658
assert (step , " Expected\32 an expression" )
771
771
else self .i = old local expr , o = self :Peek (" Expression" )if expr and (expr .Type == " FunctionCall" or expr .Type == " FunctionSelfCall" )then return expr end self .i = o local vars = self :Varlist ()if vars then assert (self :String (' \61 ' ), " Expected\32 `=`" )local exprs = self :Explist ()assert (exprs , " Expected\32 an expression" )return {[" Line" ] = start [" Type" ] = " Assignment" [" Variables" ] = vars [" Expressions" ] = exprs }end self .i = o end
772
772
self .i = old
773
773
end
774
- function Parser :CheckBinop ([ object Object ] )
774
+ function Parser :CheckBinop (expr )
775
775
local left = expr .Left
776
776
if left .Priority then
777
777
if left .Priority < expr .Priority then
787
787
[" FunctionSelfCall" ] = true
788
788
[" Brackets" ] = true }
789
789
790
- function Parser :PostExpression ([ object Object ] )
790
+ function Parser :PostExpression (prev )
791
791
local start = self :Line ()
792
792
local binop , old = self :Peek (" Binop" )
793
793
local isPrefix = IsPrefix [prev .Type ]
@@ -958,11 +958,11 @@ end
958
958
959
959
end
960
960
local escapes = {[' a' ] = ' a' [' b' ] = ' \8 ' [' f' ] = ' \12 ' [' n' ] = ' \n ' [' r' ] = ' \13 ' [' t' ] = ' \t ' [' v' ] = ' \11 ' [' \13 ' ] = ' \n ' [" \\ " ] = " \\\\ " }
961
- local function escaped ([ object Object ] )
961
+ local function escaped (str )
962
962
str = str :gsub (" \\ (%d%d?%d?)" , string.char )
963
963
return
964
964
965
- str :gsub (" \\ x(%d+%d+)" , function ([ object Object ] )return string.char (tonumber (c , 16 ))end ):gsub (" \\ (.)" , function ([ object Object ] )return escapes [c ] or c end )
965
+ str :gsub (" \\ x(%d+%d+)" , function (c )return string.char (tonumber (c , 16 ))end ):gsub (" \\ (.)" , function (c )return escapes [c ] or c end )
966
966
end
967
967
function Parser :StringConstant ()
968
968
local q = self :Match (" ['\" ]" )
@@ -1078,7 +1078,7 @@ end
1078
1078
local old = self .i
1079
1079
local prefix = self :Prefixexp ()
1080
1080
if N prefix then self .i = old return end
1081
- local methodname =
1081
+ local methodname
1082
1082
if self :String (' :' )then
1083
1083
methodname = self :Name ()
1084
1084
assert (methodname , " Expected\32 a name" )
@@ -1104,7 +1104,7 @@ end
1104
1104
self .i = o return
1105
1105
end return m
1106
1106
end
1107
- function Parser :Namelist ([ object Object ] )
1107
+ function Parser :Namelist (vararg )
1108
1108
local name = self :Name ()
1109
1109
local names = {name }
1110
1110
if name then
@@ -1166,7 +1166,7 @@ xpcall(function()
1166
1166
print (" Took" , os.clock () - start , " to\32 parse" )
1167
1167
local f = io.open (" output.lua" , ' w' )
1168
1168
f :write (TostringValue (res ))f :close ()
1169
- end , function ([ object Object ] )
1169
+ end , function (e )
1170
1170
print (" ERROR:" , e )
1171
1171
print (" stack\32 traceback:" )
1172
1172
print (debug.traceback ():match (" .-\n .-\10 (.*)" ))
0 commit comments