rufus-lua-moon 0.2.3.2 → 0.2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rufus/lua/moon/version.rb +1 -1
- data/vendor/lua/moon/all.moon +5 -7
- data/vendor/lua/moon/init.moon +6 -8
- data/vendor/lua/moonscript/base.lua +2 -0
- data/vendor/lua/moonscript/compile/statement.lua +25 -26
- data/vendor/lua/moonscript/compile/value.lua +43 -36
- data/vendor/lua/moonscript/compile.lua +69 -128
- data/vendor/lua/moonscript/data.lua +9 -21
- data/vendor/lua/moonscript/dump.lua +6 -6
- data/vendor/lua/moonscript/errors.lua +18 -12
- data/vendor/lua/moonscript/init.lua +15 -13
- data/vendor/lua/moonscript/parse.lua +5 -5
- data/vendor/lua/moonscript/transform/destructure.lua +44 -39
- data/vendor/lua/moonscript/transform/names.lua +12 -41
- data/vendor/lua/moonscript/transform.lua +298 -322
- data/vendor/lua/moonscript/types.lua +18 -11
- data/vendor/lua/moonscript/util.lua +26 -22
- data/vendor/lua/moonscript/version.lua +1 -1
- metadata +2 -1
@@ -3,36 +3,40 @@ local dump = require("moonscript.dump")
|
|
3
3
|
local transform = require("moonscript.transform")
|
4
4
|
local NameProxy, LocalName
|
5
5
|
do
|
6
|
-
local
|
7
|
-
NameProxy, LocalName =
|
6
|
+
local _obj_0 = require("moonscript.transform.names")
|
7
|
+
NameProxy, LocalName = _obj_0.NameProxy, _obj_0.LocalName
|
8
8
|
end
|
9
9
|
local Set
|
10
10
|
do
|
11
|
-
local
|
12
|
-
Set =
|
11
|
+
local _obj_0 = require("moonscript.data")
|
12
|
+
Set = _obj_0.Set
|
13
13
|
end
|
14
14
|
local ntype, has_value
|
15
15
|
do
|
16
|
-
local
|
17
|
-
ntype, has_value =
|
16
|
+
local _obj_0 = require("moonscript.types")
|
17
|
+
ntype, has_value = _obj_0.ntype, _obj_0.has_value
|
18
18
|
end
|
19
19
|
local statement_compilers
|
20
20
|
do
|
21
|
-
local
|
22
|
-
statement_compilers =
|
21
|
+
local _obj_0 = require("moonscript.compile.statement")
|
22
|
+
statement_compilers = _obj_0.statement_compilers
|
23
23
|
end
|
24
24
|
local value_compilers
|
25
25
|
do
|
26
|
-
local
|
27
|
-
value_compilers =
|
26
|
+
local _obj_0 = require("moonscript.compile.value")
|
27
|
+
value_compilers = _obj_0.value_compilers
|
28
28
|
end
|
29
|
-
local concat, insert
|
30
|
-
|
29
|
+
local concat, insert
|
30
|
+
do
|
31
|
+
local _obj_0 = table
|
32
|
+
concat, insert = _obj_0.concat, _obj_0.insert
|
33
|
+
end
|
34
|
+
local pos_to_line, get_closest_line, trim, unpack
|
35
|
+
pos_to_line, get_closest_line, trim, unpack = util.pos_to_line, util.get_closest_line, util.trim, util.unpack
|
31
36
|
local mtype = util.moon.type
|
32
37
|
local indent_char = " "
|
33
38
|
local Line, DelayedLine, Lines, Block, RootBlock
|
34
39
|
do
|
35
|
-
local _parent_0 = nil
|
36
40
|
local _base_0 = {
|
37
41
|
mark_pos = function(self, pos, line)
|
38
42
|
if line == nil then
|
@@ -115,17 +119,14 @@ do
|
|
115
119
|
local strip
|
116
120
|
strip = function(t)
|
117
121
|
if "table" == type(t) then
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
local
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
127
|
-
return _accum_0
|
128
|
-
end)()
|
122
|
+
local _accum_0 = { }
|
123
|
+
local _len_0 = 1
|
124
|
+
for _index_0 = 1, #t do
|
125
|
+
local v = t[_index_0]
|
126
|
+
_accum_0[_len_0] = strip(v)
|
127
|
+
_len_0 = _len_0 + 1
|
128
|
+
end
|
129
|
+
return _accum_0
|
129
130
|
else
|
130
131
|
return t
|
131
132
|
end
|
@@ -134,25 +135,14 @@ do
|
|
134
135
|
end
|
135
136
|
}
|
136
137
|
_base_0.__index = _base_0
|
137
|
-
if _parent_0 then
|
138
|
-
setmetatable(_base_0, _parent_0.__base)
|
139
|
-
end
|
140
138
|
local _class_0 = setmetatable({
|
141
139
|
__init = function(self)
|
142
140
|
self.posmap = { }
|
143
141
|
end,
|
144
142
|
__base = _base_0,
|
145
|
-
__name = "Lines"
|
146
|
-
__parent = _parent_0
|
143
|
+
__name = "Lines"
|
147
144
|
}, {
|
148
|
-
__index =
|
149
|
-
local val = rawget(_base_0, name)
|
150
|
-
if val == nil and _parent_0 then
|
151
|
-
return _parent_0[name]
|
152
|
-
else
|
153
|
-
return val
|
154
|
-
end
|
155
|
-
end,
|
145
|
+
__index = _base_0,
|
156
146
|
__call = function(cls, ...)
|
157
147
|
local _self_0 = setmetatable({}, _base_0)
|
158
148
|
cls.__init(_self_0, ...)
|
@@ -160,13 +150,9 @@ do
|
|
160
150
|
end
|
161
151
|
})
|
162
152
|
_base_0.__class = _class_0
|
163
|
-
if _parent_0 and _parent_0.__inherited then
|
164
|
-
_parent_0.__inherited(_parent_0, _class_0)
|
165
|
-
end
|
166
153
|
Lines = _class_0
|
167
154
|
end
|
168
155
|
do
|
169
|
-
local _parent_0 = nil
|
170
156
|
local _base_0 = {
|
171
157
|
pos = nil,
|
172
158
|
_append_single = function(self, item)
|
@@ -174,9 +160,8 @@ do
|
|
174
160
|
if not (self.pos) then
|
175
161
|
self.pos = item.pos
|
176
162
|
end
|
177
|
-
|
178
|
-
|
179
|
-
local value = _list_0[_index_0]
|
163
|
+
for _index_0 = 1, #item do
|
164
|
+
local value = item[_index_0]
|
180
165
|
self:_append_single(value)
|
181
166
|
end
|
182
167
|
else
|
@@ -210,14 +195,13 @@ do
|
|
210
195
|
buffer:add(concat(current))
|
211
196
|
return buffer:mark_pos(self.pos)
|
212
197
|
end
|
213
|
-
|
214
|
-
|
215
|
-
local chunk = _list_0[_index_0]
|
198
|
+
for _index_0 = 1, #self do
|
199
|
+
local chunk = self[_index_0]
|
216
200
|
local _exp_0 = mtype(chunk)
|
217
201
|
if Block == _exp_0 then
|
218
|
-
local
|
219
|
-
for _index_1 = 1, #
|
220
|
-
local block_chunk =
|
202
|
+
local _list_0 = chunk:render(Lines())
|
203
|
+
for _index_1 = 1, #_list_0 do
|
204
|
+
local block_chunk = _list_0[_index_1]
|
221
205
|
if "string" == type(block_chunk) then
|
222
206
|
insert(current, block_chunk)
|
223
207
|
else
|
@@ -240,27 +224,12 @@ do
|
|
240
224
|
end
|
241
225
|
}
|
242
226
|
_base_0.__index = _base_0
|
243
|
-
if _parent_0 then
|
244
|
-
setmetatable(_base_0, _parent_0.__base)
|
245
|
-
end
|
246
227
|
local _class_0 = setmetatable({
|
247
|
-
__init = function(
|
248
|
-
if _parent_0 then
|
249
|
-
return _parent_0.__init(self, ...)
|
250
|
-
end
|
251
|
-
end,
|
228
|
+
__init = function() end,
|
252
229
|
__base = _base_0,
|
253
|
-
__name = "Line"
|
254
|
-
__parent = _parent_0
|
230
|
+
__name = "Line"
|
255
231
|
}, {
|
256
|
-
__index =
|
257
|
-
local val = rawget(_base_0, name)
|
258
|
-
if val == nil and _parent_0 then
|
259
|
-
return _parent_0[name]
|
260
|
-
else
|
261
|
-
return val
|
262
|
-
end
|
263
|
-
end,
|
232
|
+
__index = _base_0,
|
264
233
|
__call = function(cls, ...)
|
265
234
|
local _self_0 = setmetatable({}, _base_0)
|
266
235
|
cls.__init(_self_0, ...)
|
@@ -268,13 +237,9 @@ do
|
|
268
237
|
end
|
269
238
|
})
|
270
239
|
_base_0.__class = _class_0
|
271
|
-
if _parent_0 and _parent_0.__inherited then
|
272
|
-
_parent_0.__inherited(_parent_0, _class_0)
|
273
|
-
end
|
274
240
|
Line = _class_0
|
275
241
|
end
|
276
242
|
do
|
277
|
-
local _parent_0 = nil
|
278
243
|
local _base_0 = {
|
279
244
|
prepare = function() end,
|
280
245
|
render = function(self)
|
@@ -283,25 +248,14 @@ do
|
|
283
248
|
end
|
284
249
|
}
|
285
250
|
_base_0.__index = _base_0
|
286
|
-
if _parent_0 then
|
287
|
-
setmetatable(_base_0, _parent_0.__base)
|
288
|
-
end
|
289
251
|
local _class_0 = setmetatable({
|
290
252
|
__init = function(self, fn)
|
291
253
|
self.prepare = fn
|
292
254
|
end,
|
293
255
|
__base = _base_0,
|
294
|
-
__name = "DelayedLine"
|
295
|
-
__parent = _parent_0
|
256
|
+
__name = "DelayedLine"
|
296
257
|
}, {
|
297
|
-
__index =
|
298
|
-
local val = rawget(_base_0, name)
|
299
|
-
if val == nil and _parent_0 then
|
300
|
-
return _parent_0[name]
|
301
|
-
else
|
302
|
-
return val
|
303
|
-
end
|
304
|
-
end,
|
258
|
+
__index = _base_0,
|
305
259
|
__call = function(cls, ...)
|
306
260
|
local _self_0 = setmetatable({}, _base_0)
|
307
261
|
cls.__init(_self_0, ...)
|
@@ -309,13 +263,9 @@ do
|
|
309
263
|
end
|
310
264
|
})
|
311
265
|
_base_0.__class = _class_0
|
312
|
-
if _parent_0 and _parent_0.__inherited then
|
313
|
-
_parent_0.__inherited(_parent_0, _class_0)
|
314
|
-
end
|
315
266
|
DelayedLine = _class_0
|
316
267
|
end
|
317
268
|
do
|
318
|
-
local _parent_0 = nil
|
319
269
|
local _base_0 = {
|
320
270
|
header = "do",
|
321
271
|
footer = "end",
|
@@ -354,14 +304,14 @@ do
|
|
354
304
|
end
|
355
305
|
end,
|
356
306
|
declare = function(self, names)
|
357
|
-
local undeclared
|
307
|
+
local undeclared
|
308
|
+
do
|
358
309
|
local _accum_0 = { }
|
359
310
|
local _len_0 = 1
|
360
|
-
|
361
|
-
for _index_0 = 1, #_list_0 do
|
311
|
+
for _index_0 = 1, #names do
|
362
312
|
local _continue_0 = false
|
363
313
|
repeat
|
364
|
-
local name =
|
314
|
+
local name = names[_index_0]
|
365
315
|
local is_local = false
|
366
316
|
local real_name
|
367
317
|
local _exp_0 = mtype(name)
|
@@ -391,8 +341,8 @@ do
|
|
391
341
|
break
|
392
342
|
end
|
393
343
|
end
|
394
|
-
|
395
|
-
end
|
344
|
+
undeclared = _accum_0
|
345
|
+
end
|
396
346
|
return undeclared
|
397
347
|
end,
|
398
348
|
whitelist_names = function(self, names)
|
@@ -429,6 +379,19 @@ do
|
|
429
379
|
return yes
|
430
380
|
end
|
431
381
|
end,
|
382
|
+
is_local = function(self, node)
|
383
|
+
local t = mtype(node)
|
384
|
+
if t == "string" then
|
385
|
+
return self:has_name(node, false)
|
386
|
+
end
|
387
|
+
if t == NameProxy or t == LocalName then
|
388
|
+
return true
|
389
|
+
end
|
390
|
+
if t == "table" and node[1] == "chain" and #node == 2 then
|
391
|
+
return self:is_local(node[2])
|
392
|
+
end
|
393
|
+
return false
|
394
|
+
end,
|
432
395
|
free_name = function(self, prefix, dont_put)
|
433
396
|
prefix = prefix or "moon"
|
434
397
|
local searching = true
|
@@ -533,9 +496,8 @@ do
|
|
533
496
|
_with_0:append_list((function()
|
534
497
|
local _accum_0 = { }
|
535
498
|
local _len_0 = 1
|
536
|
-
|
537
|
-
|
538
|
-
local v = _list_0[_index_0]
|
499
|
+
for _index_0 = 1, #values do
|
500
|
+
local v = values[_index_0]
|
539
501
|
_accum_0[_len_0] = self:value(v)
|
540
502
|
_len_0 = _len_0 + 1
|
541
503
|
end
|
@@ -583,10 +545,7 @@ do
|
|
583
545
|
error("deprecated stms call, use transformer")
|
584
546
|
end
|
585
547
|
local current_stms, current_stm_i
|
586
|
-
|
587
|
-
local _obj_0 = self
|
588
|
-
current_stms, current_stm_i = _obj_0.current_stms, _obj_0.current_stm_i
|
589
|
-
end
|
548
|
+
current_stms, current_stm_i = self.current_stms, self.current_stm_i
|
590
549
|
self.current_stms = stms
|
591
550
|
for i = 1, #stms do
|
592
551
|
self.current_stm_i = i
|
@@ -606,9 +565,6 @@ do
|
|
606
565
|
end
|
607
566
|
}
|
608
567
|
_base_0.__index = _base_0
|
609
|
-
if _parent_0 then
|
610
|
-
setmetatable(_base_0, _parent_0.__base)
|
611
|
-
end
|
612
568
|
local _class_0 = setmetatable({
|
613
569
|
__init = function(self, parent, header, footer)
|
614
570
|
self.parent, self.header, self.footer = parent, header, footer
|
@@ -617,10 +573,9 @@ do
|
|
617
573
|
self._state = { }
|
618
574
|
self._listeners = { }
|
619
575
|
do
|
620
|
-
local _with_0 = transform
|
621
576
|
self.transform = {
|
622
|
-
value =
|
623
|
-
statement =
|
577
|
+
value = transform.Value:bind(self),
|
578
|
+
statement = transform.Statement:bind(self)
|
624
579
|
}
|
625
580
|
end
|
626
581
|
if self.parent then
|
@@ -637,17 +592,9 @@ do
|
|
637
592
|
end
|
638
593
|
end,
|
639
594
|
__base = _base_0,
|
640
|
-
__name = "Block"
|
641
|
-
__parent = _parent_0
|
595
|
+
__name = "Block"
|
642
596
|
}, {
|
643
|
-
__index =
|
644
|
-
local val = rawget(_base_0, name)
|
645
|
-
if val == nil and _parent_0 then
|
646
|
-
return _parent_0[name]
|
647
|
-
else
|
648
|
-
return val
|
649
|
-
end
|
650
|
-
end,
|
597
|
+
__index = _base_0,
|
651
598
|
__call = function(cls, ...)
|
652
599
|
local _self_0 = setmetatable({}, _base_0)
|
653
600
|
cls.__init(_self_0, ...)
|
@@ -655,9 +602,6 @@ do
|
|
655
602
|
end
|
656
603
|
})
|
657
604
|
_base_0.__class = _class_0
|
658
|
-
if _parent_0 and _parent_0.__inherited then
|
659
|
-
_parent_0.__inherited(_parent_0, _class_0)
|
660
|
-
end
|
661
605
|
Block = _class_0
|
662
606
|
end
|
663
607
|
do
|
@@ -681,9 +625,7 @@ do
|
|
681
625
|
end
|
682
626
|
}
|
683
627
|
_base_0.__index = _base_0
|
684
|
-
|
685
|
-
setmetatable(_base_0, _parent_0.__base)
|
686
|
-
end
|
628
|
+
setmetatable(_base_0, _parent_0.__base)
|
687
629
|
local _class_0 = setmetatable({
|
688
630
|
__init = function(self, options)
|
689
631
|
self.options = options
|
@@ -696,7 +638,7 @@ do
|
|
696
638
|
}, {
|
697
639
|
__index = function(cls, name)
|
698
640
|
local val = rawget(_base_0, name)
|
699
|
-
if val == nil
|
641
|
+
if val == nil then
|
700
642
|
return _parent_0[name]
|
701
643
|
else
|
702
644
|
return val
|
@@ -709,7 +651,7 @@ do
|
|
709
651
|
end
|
710
652
|
})
|
711
653
|
_base_0.__class = _class_0
|
712
|
-
if _parent_0
|
654
|
+
if _parent_0.__inherited then
|
713
655
|
_parent_0.__inherited(_parent_0, _class_0)
|
714
656
|
end
|
715
657
|
RootBlock = _class_0
|
@@ -769,8 +711,7 @@ tree = function(tree, options)
|
|
769
711
|
end
|
770
712
|
end
|
771
713
|
do
|
772
|
-
local
|
773
|
-
local data = _with_0
|
714
|
+
local data = require("moonscript.data")
|
774
715
|
for name, cls in pairs({
|
775
716
|
Line = Line,
|
776
717
|
Lines = Lines,
|
@@ -1,17 +1,19 @@
|
|
1
|
-
local concat, remove, insert
|
1
|
+
local concat, remove, insert
|
2
|
+
do
|
3
|
+
local _obj_0 = table
|
4
|
+
concat, remove, insert = _obj_0.concat, _obj_0.remove, _obj_0.insert
|
5
|
+
end
|
2
6
|
local Set
|
3
7
|
Set = function(items)
|
4
8
|
local self = { }
|
5
|
-
|
6
|
-
|
7
|
-
local key = _list_0[_index_0]
|
9
|
+
for _index_0 = 1, #items do
|
10
|
+
local key = items[_index_0]
|
8
11
|
self[key] = true
|
9
12
|
end
|
10
13
|
return self
|
11
14
|
end
|
12
15
|
local Stack
|
13
16
|
do
|
14
|
-
local _parent_0 = nil
|
15
17
|
local _base_0 = {
|
16
18
|
__tostring = function(self)
|
17
19
|
return "<Stack {" .. concat(self, ", ") .. "}>"
|
@@ -28,9 +30,6 @@ do
|
|
28
30
|
end
|
29
31
|
}
|
30
32
|
_base_0.__index = _base_0
|
31
|
-
if _parent_0 then
|
32
|
-
setmetatable(_base_0, _parent_0.__base)
|
33
|
-
end
|
34
33
|
local _class_0 = setmetatable({
|
35
34
|
__init = function(self, ...)
|
36
35
|
local _list_0 = {
|
@@ -43,17 +42,9 @@ do
|
|
43
42
|
return nil
|
44
43
|
end,
|
45
44
|
__base = _base_0,
|
46
|
-
__name = "Stack"
|
47
|
-
__parent = _parent_0
|
45
|
+
__name = "Stack"
|
48
46
|
}, {
|
49
|
-
__index =
|
50
|
-
local val = rawget(_base_0, name)
|
51
|
-
if val == nil and _parent_0 then
|
52
|
-
return _parent_0[name]
|
53
|
-
else
|
54
|
-
return val
|
55
|
-
end
|
56
|
-
end,
|
47
|
+
__index = _base_0,
|
57
48
|
__call = function(cls, ...)
|
58
49
|
local _self_0 = setmetatable({}, _base_0)
|
59
50
|
cls.__init(_self_0, ...)
|
@@ -61,9 +52,6 @@ do
|
|
61
52
|
end
|
62
53
|
})
|
63
54
|
_base_0.__class = _class_0
|
64
|
-
if _parent_0 and _parent_0.__inherited then
|
65
|
-
_parent_0.__inherited(_parent_0, _class_0)
|
66
|
-
end
|
67
55
|
Stack = _class_0
|
68
56
|
end
|
69
57
|
local lua_keywords = Set({
|
@@ -9,17 +9,17 @@ flat_value = function(op, depth)
|
|
9
9
|
if type(op) ~= "table" then
|
10
10
|
return tostring(op)
|
11
11
|
end
|
12
|
-
local items
|
12
|
+
local items
|
13
|
+
do
|
13
14
|
local _accum_0 = { }
|
14
15
|
local _len_0 = 1
|
15
|
-
|
16
|
-
|
17
|
-
local item = _list_0[_index_0]
|
16
|
+
for _index_0 = 1, #op do
|
17
|
+
local item = op[_index_0]
|
18
18
|
_accum_0[_len_0] = flat_value(item, depth + 1)
|
19
19
|
_len_0 = _len_0 + 1
|
20
20
|
end
|
21
|
-
|
22
|
-
end
|
21
|
+
items = _accum_0
|
22
|
+
end
|
23
23
|
local pos = op[-1]
|
24
24
|
return "{" .. (pos and "[" .. pos .. "] " or "") .. table.concat(items, ", ") .. "}"
|
25
25
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
local util = require("moonscript.util")
|
2
2
|
local lpeg = require("lpeg")
|
3
|
-
local concat, insert
|
4
|
-
|
3
|
+
local concat, insert
|
4
|
+
do
|
5
|
+
local _obj_0 = table
|
6
|
+
concat, insert = _obj_0.concat, _obj_0.insert
|
7
|
+
end
|
8
|
+
local split, pos_to_line
|
9
|
+
split, pos_to_line = util.split, util.pos_to_line
|
5
10
|
local user_error
|
6
11
|
user_error = function(...)
|
7
12
|
return error({
|
@@ -42,18 +47,17 @@ truncate_traceback = function(traceback, chunk_func)
|
|
42
47
|
end
|
43
48
|
stop = stop - 1
|
44
49
|
end
|
45
|
-
|
50
|
+
do
|
46
51
|
local _accum_0 = { }
|
47
52
|
local _len_0 = 1
|
48
|
-
local _list_0 = traceback
|
49
53
|
local _max_0 = stop
|
50
|
-
for _index_0 = 1, _max_0 < 0 and #
|
51
|
-
local t =
|
54
|
+
for _index_0 = 1, _max_0 < 0 and #traceback + _max_0 or _max_0 do
|
55
|
+
local t = traceback[_index_0]
|
52
56
|
_accum_0[_len_0] = t
|
53
57
|
_len_0 = _len_0 + 1
|
54
58
|
end
|
55
|
-
|
56
|
-
end
|
59
|
+
traceback = _accum_0
|
60
|
+
end
|
57
61
|
local rep = "function '" .. chunk_func .. "'"
|
58
62
|
traceback[#traceback] = traceback[#traceback]:gsub(rep, "main chunk")
|
59
63
|
return concat(traceback, "\n")
|
@@ -61,7 +65,8 @@ end
|
|
61
65
|
local rewrite_traceback
|
62
66
|
rewrite_traceback = function(text, err)
|
63
67
|
local line_tables = require("moonscript.line_tables")
|
64
|
-
local V, S, Ct, C
|
68
|
+
local V, S, Ct, C
|
69
|
+
V, S, Ct, C = lpeg.V, lpeg.S, lpeg.Ct, lpeg.C
|
65
70
|
local header_text = "stack traceback:"
|
66
71
|
local Header, Line = V("Header"), V("Line")
|
67
72
|
local Break = lpeg.S("\n")
|
@@ -80,10 +85,10 @@ rewrite_traceback = function(text, err)
|
|
80
85
|
fname,
|
81
86
|
":",
|
82
87
|
reverse_line_number(fname, tbl, line, cache),
|
88
|
+
": ",
|
83
89
|
"(",
|
84
90
|
line,
|
85
|
-
")",
|
86
|
-
": ",
|
91
|
+
") ",
|
87
92
|
msg
|
88
93
|
})
|
89
94
|
else
|
@@ -107,5 +112,6 @@ end
|
|
107
112
|
return {
|
108
113
|
rewrite_traceback = rewrite_traceback,
|
109
114
|
truncate_traceback = truncate_traceback,
|
110
|
-
user_error = user_error
|
115
|
+
user_error = user_error,
|
116
|
+
reverse_line_number = reverse_line_number
|
111
117
|
}
|
@@ -1,10 +1,14 @@
|
|
1
1
|
local compile = require("moonscript.compile")
|
2
2
|
local parse = require("moonscript.parse")
|
3
|
-
local concat, insert
|
3
|
+
local concat, insert
|
4
|
+
do
|
5
|
+
local _obj_0 = table
|
6
|
+
concat, insert = _obj_0.concat, _obj_0.insert
|
7
|
+
end
|
4
8
|
local split, dump, get_options, unpack
|
5
9
|
do
|
6
|
-
local
|
7
|
-
split, dump, get_options, unpack =
|
10
|
+
local _obj_0 = require("moonscript.util")
|
11
|
+
split, dump, get_options, unpack = _obj_0.split, _obj_0.dump, _obj_0.get_options, _obj_0.unpack
|
8
12
|
end
|
9
13
|
local lua = {
|
10
14
|
loadstring = loadstring,
|
@@ -29,15 +33,15 @@ to_lua = function(text, options)
|
|
29
33
|
end
|
30
34
|
if "string" ~= type(text) then
|
31
35
|
local t = type(text)
|
32
|
-
|
36
|
+
return nil, "expecting string (got " .. t .. ")", 2
|
33
37
|
end
|
34
38
|
local tree, err = parse.string(text)
|
35
39
|
if not tree then
|
36
|
-
|
40
|
+
return nil, err
|
37
41
|
end
|
38
42
|
local code, ltable, pos = compile.tree(tree, options)
|
39
43
|
if not code then
|
40
|
-
|
44
|
+
return nil, compile.format_error(ltable, pos, text), 2
|
41
45
|
end
|
42
46
|
return code, ltable
|
43
47
|
end
|
@@ -73,14 +77,12 @@ end
|
|
73
77
|
loadstring = function(...)
|
74
78
|
local options, str, chunk_name, mode, env = get_options(...)
|
75
79
|
chunk_name = chunk_name or "=(moonscript.loadstring)"
|
76
|
-
local
|
77
|
-
|
78
|
-
|
79
|
-
if not passed then
|
80
|
-
error(chunk_name .. ": " .. code, 2)
|
80
|
+
local code, ltable_or_err = to_lua(str, options)
|
81
|
+
if not (code) then
|
82
|
+
return nil, ltable_or_err
|
81
83
|
end
|
82
84
|
if chunk_name then
|
83
|
-
line_tables[chunk_name] =
|
85
|
+
line_tables[chunk_name] = ltable_or_err
|
84
86
|
end
|
85
87
|
return (lua.loadstring or lua.load)(code, chunk_name, unpack({
|
86
88
|
mode,
|
@@ -89,7 +91,7 @@ loadstring = function(...)
|
|
89
91
|
end
|
90
92
|
loadfile = function(fname, ...)
|
91
93
|
local file, err = io.open(fname)
|
92
|
-
if not file then
|
94
|
+
if not (file) then
|
93
95
|
return nil, err
|
94
96
|
end
|
95
97
|
local text = assert(file:read("*a"))
|
@@ -227,7 +227,7 @@ local function symx(chars)
|
|
227
227
|
end
|
228
228
|
|
229
229
|
local function simple_string(delim, allow_interpolation)
|
230
|
-
local inner = P('\\'..delim) + "\\\\" + (1 -
|
230
|
+
local inner = P('\\'..delim) + "\\\\" + (1 - P(delim))
|
231
231
|
if allow_interpolation then
|
232
232
|
inter = symx"#{" * V"Exp" * sym"}"
|
233
233
|
inner = (C((inner - inter)^1) + inter / mark"interpolate")^0
|
@@ -409,9 +409,9 @@ local build_grammar = wrap_env(function()
|
|
409
409
|
|
410
410
|
Local = key"local" * ((op"*" + op"^") / mark"declare_glob" + Ct(NameList) / mark"declare_with_shadows"),
|
411
411
|
|
412
|
-
Import = key"import" *
|
412
|
+
Import = key"import" * Ct(ImportNameList) * SpaceBreak^0 * key"from" * Exp / mark"import",
|
413
413
|
ImportName = (sym"\\" * Ct(Cc"colon_stub" * Name) + Name),
|
414
|
-
ImportNameList = ImportName * (sym"," * ImportName)^0,
|
414
|
+
ImportNameList = SpaceBreak^0 * ImportName * ((SpaceBreak^1 + sym"," * SpaceBreak^0) * ImportName)^0,
|
415
415
|
|
416
416
|
NameList = Name * (sym"," * Name)^0,
|
417
417
|
|
@@ -575,7 +575,7 @@ local build_grammar = wrap_env(function()
|
|
575
575
|
op"*" + op"^" +
|
576
576
|
Ct(NameList) * (sym"=" * Ct(ExpListLow))^-1) / mark"export",
|
577
577
|
|
578
|
-
KeyValue = (sym":" * Name) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)),
|
578
|
+
KeyValue = (sym":" * -SomeSpace * Name) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)),
|
579
579
|
KeyValueList = KeyValue * (sym"," * KeyValue)^0,
|
580
580
|
KeyValueLine = CheckIndent * KeyValueList * sym","^-1,
|
581
581
|
|
@@ -597,7 +597,7 @@ local build_grammar = wrap_env(function()
|
|
597
597
|
ExpList = Exp * (sym"," * Exp)^0,
|
598
598
|
ExpListLow = Exp * ((sym"," + sym";") * Exp)^0,
|
599
599
|
|
600
|
-
InvokeArgs = ExpList * (sym"," * (TableBlock + SpaceBreak * Advance * ArgBlock * TableBlock^-1) + TableBlock)^-1 + TableBlock,
|
600
|
+
InvokeArgs = -P"-" * (ExpList * (sym"," * (TableBlock + SpaceBreak * Advance * ArgBlock * TableBlock^-1) + TableBlock)^-1 + TableBlock),
|
601
601
|
ArgBlock = ArgLine * (sym"," * SpaceBreak * ArgLine)^0 * PopIndent,
|
602
602
|
ArgLine = CheckIndent * ExpList
|
603
603
|
}
|