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 +4 -4
- data/.gitignore +2 -0
- data/lib/mulang/ruby/ast_processor.rb +50 -2
- data/lib/mulang/ruby/sexp.rb +1 -1
- data/lib/mulang/ruby/version.rb +1 -1
- data/mulang-ruby.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc516897bffe4f75c21f68fda78e0c2490b106a99835f90d6183cca18fd4ac49
|
4
|
+
data.tar.gz: e5ef308fbdc39a5773a8b2e47197c4fb6d87ad3e34c203d683ea59b00a0358ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d18f36683e53a5b1d0211433a9725021d70a25afe5a6d8a5d63c90d56db085ee4fcc2399f632ded1e3e48623f1b310b8ef4784436ca1fbdb9ee11d5a524bd2
|
7
|
+
data.tar.gz: 485d1e6ea0118c89baaa34658d2e5e0e2fa7e7421439204cdfe2e91d9393585189eb14acde547646fd6fd98684bd464f24002c67c05a9655c4a0545aa1d7f0aa
|
data/.gitignore
CHANGED
@@ -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
|
-
|
123
|
+
mu_method :EqualMethod, process_all(args), process(body)
|
76
124
|
when :hash
|
77
|
-
|
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
|
data/lib/mulang/ruby/sexp.rb
CHANGED
data/lib/mulang/ruby/version.rb
CHANGED
data/mulang-ruby.gemspec
CHANGED
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.
|
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-
|
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.
|
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.
|
110
|
+
version: '3.5'
|
111
111
|
description: Ruby - Mulang Parser
|
112
112
|
email:
|
113
113
|
- franco@mumuki.org
|