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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ee6c299a28d2661c437cfc0553212fea130fd66ecf24c0ffee3e107862c39cf
4
- data.tar.gz: c4e175afaddad9ef6ec2f8c8f38627b0ccae1dc0221750c330fee618eede8797
3
+ metadata.gz: f883290f82867edc3d1c7d8fa4414bb5dccbc9561619a1af1ab99348518828cd
4
+ data.tar.gz: b7f0128847fbb2ac7ff0f1364f549e3911a981a64ed07a2b0de8005ae2e7abb7
5
5
  SHA512:
6
- metadata.gz: 40e755c1bc18b01c98a91954dd7b1885c3b36d807cd596fe6c867f94a8194d8475d3e0e5bc6784a7b64af40e4f55d39f125e3bcd63b020e163b18c95f5e24392
7
- data.tar.gz: ad92b4bca8c7707fb3995799eb1de2b838972be97da2934d51f32dd2bc97c59f6f40dedf44be9f60ad74711bdb4eed4c8d6c557035d0e7d6765afacc53bbee9b
6
+ metadata.gz: 27541d90b44f21b3dcc24055c548059282c4a857ef32aec58b97a20c0ded8f752aa1bc1be763e207e7222914711935baa9f3d1295132a6719ab5a3b664c1f836
7
+ data.tar.gz: 516c7f76522351367deb20ed771dc87b239cee2665dc05ddcebd2b0fcba106396db9a9d0e12e3f7b9729470a530739e6f756298b1c46780dc7d27407fc3566c2
@@ -367,19 +367,24 @@ eos
367
367
 
368
368
  class FnArgs < SNode
369
369
  def check(context, *)
370
- arg0.check(context) +
371
- (defined?(args_rest.args) && !args_rest.args.text_value.empty? ?
372
- args_rest.args.check(context) : [])
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
- arg0.rewrite(context) +
377
- (defined?(args_rest.args) && !args_rest.args.text_value.empty? ?
378
- ", " + args_rest.args.rewrite(context) : "")
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) ? 1 + args_rest.args.arg_count : 1
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
- "(" + v.rewrite(context) + ") ? (" +
395
- e1.rewrite(context) + ") : (" + e2.rewrite(context) + ")"
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 += ".select{|#{args_str}|(#{ifexp.e3.rewrite(context)})}" if
455
+ res << ".select{|#{args_str}|(#{ifexp.e3.rewrite(context)})}" if
451
456
  defined?(ifexp.e3)
452
- res += ".map{|#{args_str}| (#{e2.rewrite(context)}) }"
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 += ".select{|#{args_str}| (#{ifexp.ei.rewrite(context)}) }" if
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 += ".each_with_object({}){|#{unpack_str}, _h#{hid}| " +
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
- res = "#{var}.merge!(#{e0.rewrite(context)})"
572
+ res = if defined?(splat)
573
+ "#{var}.merge!(#{e0.rewrite(context)})"
569
574
  else
570
- res = "#{var}[#{e0.rewrite(context)}]=(#{e1.rewrite(context)})"
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 += ";"
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
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
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-19 00:00:00.000000000 Z
11
+ date: 2018-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop