delorean_lang 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delorean/nodes.rb +25 -20
- data/lib/delorean/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f883290f82867edc3d1c7d8fa4414bb5dccbc9561619a1af1ab99348518828cd
|
4
|
+
data.tar.gz: b7f0128847fbb2ac7ff0f1364f549e3911a981a64ed07a2b0de8005ae2e7abb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27541d90b44f21b3dcc24055c548059282c4a857ef32aec58b97a20c0ded8f752aa1bc1be763e207e7222914711935baa9f3d1295132a6719ab5a3b664c1f836
|
7
|
+
data.tar.gz: 516c7f76522351367deb20ed771dc87b239cee2665dc05ddcebd2b0fcba106396db9a9d0e12e3f7b9729470a530739e6f756298b1c46780dc7d27407fc3566c2
|
data/lib/delorean/nodes.rb
CHANGED
@@ -367,19 +367,24 @@ eos
|
|
367
367
|
|
368
368
|
class FnArgs < SNode
|
369
369
|
def check(context, *)
|
370
|
-
|
371
|
-
(
|
372
|
-
|
370
|
+
[
|
371
|
+
arg0.check(context),
|
372
|
+
(args_rest.args.check(context) if
|
373
|
+
defined?(args_rest.args) && !args_rest.args.text_value.empty?)
|
374
|
+
].compact.sum
|
373
375
|
end
|
374
376
|
|
375
377
|
def rewrite(context)
|
376
|
-
|
377
|
-
(
|
378
|
-
|
378
|
+
[
|
379
|
+
arg0.rewrite(context),
|
380
|
+
(", " + args_rest.args.rewrite(context) if
|
381
|
+
defined?(args_rest.args) && !args_rest.args.text_value.empty?),
|
382
|
+
].compact.sum
|
379
383
|
end
|
380
384
|
|
381
385
|
def arg_count
|
382
|
-
defined?(args_rest.args)
|
386
|
+
defined?(args_rest.args) && !args_rest.args.text_value.empty? ?
|
387
|
+
1 + args_rest.args.arg_count : 1
|
383
388
|
end
|
384
389
|
end
|
385
390
|
|
@@ -391,8 +396,8 @@ eos
|
|
391
396
|
end
|
392
397
|
|
393
398
|
def rewrite(context)
|
394
|
-
"(
|
395
|
-
|
399
|
+
"(#{v.rewrite(context)}) ? (#{e1.rewrite(context)}) :
|
400
|
+
(#{e2.rewrite(context)})"
|
396
401
|
end
|
397
402
|
end
|
398
403
|
|
@@ -442,16 +447,16 @@ eos
|
|
442
447
|
end
|
443
448
|
|
444
449
|
def rewrite(context)
|
445
|
-
res = "(#{e1.rewrite(context)})"
|
450
|
+
res = ["(#{e1.rewrite(context)})"]
|
446
451
|
unpack_vars = args.check(context)
|
447
452
|
unpack_vars.each {|vname| context.parse_define_var(vname)}
|
448
453
|
args_str = args.rewrite(context)
|
449
454
|
|
450
|
-
res
|
455
|
+
res << ".select{|#{args_str}|(#{ifexp.e3.rewrite(context)})}" if
|
451
456
|
defined?(ifexp.e3)
|
452
|
-
res
|
457
|
+
res << ".map{|#{args_str}| (#{e2.rewrite(context)}) }"
|
453
458
|
unpack_vars.each {|vname| context.parse_undef_var(vname)}
|
454
|
-
res
|
459
|
+
res.sum
|
455
460
|
end
|
456
461
|
end
|
457
462
|
|
@@ -493,23 +498,23 @@ eos
|
|
493
498
|
end
|
494
499
|
|
495
500
|
def rewrite(context)
|
496
|
-
res = "(#{e1.rewrite(context)})"
|
501
|
+
res = ["(#{e1.rewrite(context)})"]
|
497
502
|
unpack_vars = args.check(context)
|
498
503
|
unpack_vars.each {|vname| context.parse_define_var(vname)}
|
499
504
|
args_str = args.rewrite(context)
|
500
505
|
|
501
506
|
hid = @@comp_count += 1
|
502
507
|
|
503
|
-
res
|
508
|
+
res << ".select{|#{args_str}| (#{ifexp.ei.rewrite(context)}) }" if
|
504
509
|
defined?(ifexp.ei)
|
505
510
|
|
506
511
|
unpack_str = unpack_vars.count > 1 ? "(#{args_str})" : args_str
|
507
512
|
|
508
|
-
res
|
513
|
+
res << ".each_with_object({}){|#{unpack_str}, _h#{hid}| " +
|
509
514
|
"_h#{hid}[#{el.rewrite(context)}]=(#{er.rewrite(context)})}"
|
510
515
|
|
511
516
|
unpack_vars.each {|vname| context.parse_undef_var(vname)}
|
512
|
-
res
|
517
|
+
res.sum
|
513
518
|
end
|
514
519
|
end
|
515
520
|
|
@@ -564,10 +569,10 @@ eos
|
|
564
569
|
end
|
565
570
|
|
566
571
|
def rewrite(context, var)
|
567
|
-
if defined?(splat)
|
568
|
-
|
572
|
+
res = if defined?(splat)
|
573
|
+
"#{var}.merge!(#{e0.rewrite(context)})"
|
569
574
|
else
|
570
|
-
|
575
|
+
"#{var}[#{e0.rewrite(context)}]=(#{e1.rewrite(context)})"
|
571
576
|
end
|
572
577
|
res += " if (#{ifexp.e3.rewrite(context)})" if defined?(ifexp.e3)
|
573
578
|
res += ";"
|
data/lib/delorean/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delorean_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|