mulang-ruby 1.2.0 → 1.3.0

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: 9ce25f9ddfa919462478020c4996eb79df700ffe92846a351823c330d7e011ed
4
- data.tar.gz: 13a07d738b7ff03172b3c52cc2d2c5596fd8e14afac84fc920a6185acd9773ec
3
+ metadata.gz: cc516897bffe4f75c21f68fda78e0c2490b106a99835f90d6183cca18fd4ac49
4
+ data.tar.gz: e5ef308fbdc39a5773a8b2e47197c4fb6d87ad3e34c203d683ea59b00a0358ad
5
5
  SHA512:
6
- metadata.gz: 93ecfa1b6813275b19b0a598725a14df5269c7f5728ac0e77eb665c4fca702ae148f67311bc8c502648bd2f04d3cfad456f09377d98ff0d1e95d87ca7ffc8aa6
7
- data.tar.gz: 770b47bd8c440644c8ee7e54b6d8ccaec6dd6ccee562c238cee09e8992061bfb5d6cf99b97e92abb72dc9bd2ba1d5366050487e9c3c10270ef77fe52ce1b2096
6
+ metadata.gz: 25d18f36683e53a5b1d0211433a9725021d70a25afe5a6d8a5d63c90d56db085ee4fcc2399f632ded1e3e48623f1b310b8ef4784436ca1fbdb9ee11d5a524bd2
7
+ data.tar.gz: 485d1e6ea0118c89baaa34658d2e5e0e2fa7e7421439204cdfe2e91d9393585189eb14acde547646fd6fd98684bd464f24002c67c05a9655c4a0545aa1d7f0aa
data/.gitignore CHANGED
@@ -11,4 +11,6 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
+ .idea
15
+
14
16
  bin/mulang
@@ -26,6 +26,54 @@ module Mulang::Ruby
26
26
  sequence(*process_all(node))
27
27
  end
28
28
 
29
+ def on_rescue(node)
30
+ try, *catch, _ = *node
31
+ ms :Try, process(try), process_all(catch), ms(:MuNull)
32
+ end
33
+
34
+ def on_resbody(node)
35
+ patterns, variable, block = *node
36
+
37
+ [to_mulang_pattern(patterns, variable), process(block) || ms(:MuNull)]
38
+ end
39
+
40
+ def _
41
+ Object.new.tap { |it| it.define_singleton_method(:==) { |_| true } }
42
+ end
43
+
44
+ def to_mulang_pattern(patterns, variable)
45
+ case [patterns, variable]
46
+ when [nil, nil]
47
+ ms :WildcardPattern
48
+ when [nil, _]
49
+ ms :VariablePattern, variable.to_a.first
50
+ when [_, nil]
51
+ to_single_pattern patterns
52
+ else
53
+ ms(:AsPattern, variable.to_a.first, to_single_pattern(patterns))
54
+ end
55
+ end
56
+
57
+ def to_single_pattern(patterns)
58
+ mu_patterns = patterns.to_a.map { |it| to_type_pattern it }
59
+ mu_patterns.size == 1 ? mu_patterns.first : ms(:UnionPattern, mu_patterns)
60
+ end
61
+
62
+ def to_type_pattern(node)
63
+ _, type = *node
64
+ ms :TypePattern, type
65
+ end
66
+
67
+ def on_kwbegin(node)
68
+ process node.to_a.first
69
+ end
70
+
71
+ def on_ensure(node)
72
+ catch, finally = *node
73
+ try, catches = on_rescue(catch)[:contents]
74
+ ms :Try, try, catches, process(finally)
75
+ end
76
+
29
77
  def on_irange(node)
30
78
  ms :Other
31
79
  end
@@ -72,9 +120,9 @@ module Mulang::Ruby
72
120
 
73
121
  case id
74
122
  when :equal?, :eql?, :==
75
- method :EqualMethod, process_all(args), process(body)
123
+ mu_method :EqualMethod, process_all(args), process(body)
76
124
  when :hash
77
- method :HashMethod, process_all(args), process(body)
125
+ mu_method :HashMethod, process_all(args), process(body)
78
126
  else
79
127
  simple_method id, process_all(args), process(body)
80
128
  end
@@ -32,7 +32,7 @@ module Mulang::Ruby
32
32
  }
33
33
  end
34
34
 
35
- def method(tag, args, body)
35
+ def mu_method(tag, args, body)
36
36
  {
37
37
  tag: tag,
38
38
  contents: [
@@ -1,5 +1,5 @@
1
1
  module Mulang
2
2
  module Ruby
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
data/mulang-ruby.gemspec CHANGED
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "parser"
29
29
  spec.add_dependency "ast"
30
30
  spec.add_dependency "mumukit-core", "~> 1.0"
31
- spec.add_dependency "mulang", "~> 3.4"
31
+ spec.add_dependency "mulang", "~> 3.5"
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulang-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2017-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.4'
103
+ version: '3.5'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.4'
110
+ version: '3.5'
111
111
  description: Ruby - Mulang Parser
112
112
  email:
113
113
  - franco@mumuki.org