mulang-ruby 4.0.1 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test_and_deploy.yml +31 -0
- data/.ruby-version +1 -0
- data/lib/mulang/ruby.rb +1 -1
- data/lib/mulang/ruby/ast_processor.rb +51 -19
- data/lib/mulang/ruby/sexp.rb +5 -42
- data/lib/mulang/ruby/version.rb +1 -1
- data/mulang-ruby.gemspec +4 -4
- metadata +24 -17
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c6d1ce223e3d229c5e4c7f3483fcd81e87548515c7edd2689859d257594078
|
4
|
+
data.tar.gz: 1771c2958eff5b7a1afb06adee2cf1ec005fc20c42ee91841bce8a566f773dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e742ffb822e379a604761d329027bca396baf1176d9ad65cb898df3a875f424a97fb2c3a044de64316c95375238ac20cdd03823787fd5a789e8075fc34a17b54
|
7
|
+
data.tar.gz: b5a91310d27d1eba544437b54aaef7e6f9218b49c96e522c70e5e74d18880c56029d04fbfd8e78db250bbc281108a599c8b5e9068df7b73586a8f897d48ce998
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Test and deploy
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- workflow_dispatch
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test_and_deploy:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- name: Set up Ruby
|
13
|
+
uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6.3
|
16
|
+
- name: Install dependencies
|
17
|
+
run: bundle install
|
18
|
+
- name: Run tests
|
19
|
+
run: bundle exec rake
|
20
|
+
- name: Deploy
|
21
|
+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
22
|
+
run: |
|
23
|
+
mkdir -p $HOME/.gem
|
24
|
+
touch $HOME/.gem/credentials
|
25
|
+
chmod 0600 $HOME/.gem/credentials
|
26
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
27
|
+
gem build *.gemspec
|
28
|
+
gem push *.gem
|
29
|
+
env:
|
30
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
31
|
+
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.3
|
data/lib/mulang/ruby.rb
CHANGED
@@ -23,18 +23,22 @@ module Mulang::Ruby
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def on_begin(node)
|
26
|
-
|
26
|
+
if node.children.size == 1 && node.children[0].nil?
|
27
|
+
none # ruby < 2.6 only
|
28
|
+
else
|
29
|
+
sequence(*process_all(node))
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def on_rescue(node)
|
30
34
|
try, *catch, _ = *node
|
31
|
-
ms :Try, process(try), process_all(catch),
|
35
|
+
ms :Try, process(try), process_all(catch), none
|
32
36
|
end
|
33
37
|
|
34
38
|
def on_resbody(node)
|
35
39
|
patterns, variable, block = *node
|
36
40
|
|
37
|
-
[to_mulang_pattern(patterns, variable), process(block) ||
|
41
|
+
[to_mulang_pattern(patterns, variable), process(block) || none]
|
38
42
|
end
|
39
43
|
|
40
44
|
def _
|
@@ -120,9 +124,9 @@ module Mulang::Ruby
|
|
120
124
|
|
121
125
|
case id
|
122
126
|
when :equal?, :eql?, :==
|
123
|
-
|
127
|
+
primitive_method :Equal, process_all(args), process(body)
|
124
128
|
when :hash
|
125
|
-
|
129
|
+
primitive_method :Hash, process_all(args), process(body)
|
126
130
|
else
|
127
131
|
simple_method id, process_all(args), process(body)
|
128
132
|
end
|
@@ -130,7 +134,7 @@ module Mulang::Ruby
|
|
130
134
|
|
131
135
|
def on_block(node)
|
132
136
|
send, parameters, body = *node
|
133
|
-
lambda = ms(:Lambda, process_all(parameters), process(body))
|
137
|
+
lambda = ms(:Lambda, process_all(parameters), process(body) || none)
|
134
138
|
handle_send_with_args send, [lambda]
|
135
139
|
end
|
136
140
|
|
@@ -148,7 +152,22 @@ module Mulang::Ruby
|
|
148
152
|
|
149
153
|
def on_arg(node)
|
150
154
|
name, _ = *node
|
151
|
-
|
155
|
+
if name.is_a? Parser::AST::Node
|
156
|
+
process name
|
157
|
+
else
|
158
|
+
ms :VariablePattern, name
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def on_for(node)
|
163
|
+
variable, list, block = *node
|
164
|
+
|
165
|
+
pattern = ms(:VariablePattern, variable.children.first)
|
166
|
+
ms(:For, [ms(:Generator, pattern, process(list))], process(block) || none)
|
167
|
+
end
|
168
|
+
|
169
|
+
def on_optarg(node)
|
170
|
+
ms :OtherPattern, node.to_s, nil
|
152
171
|
end
|
153
172
|
|
154
173
|
alias on_restarg on_arg
|
@@ -206,7 +225,7 @@ module Mulang::Ruby
|
|
206
225
|
|
207
226
|
def var_assignment(assignee, message, value)
|
208
227
|
id = assignee.to_a.first
|
209
|
-
ms :Assignment, id,
|
228
|
+
ms :Assignment, id, ms(:Send, ms(:Reference, id), message_reference(message), [process(value)])
|
210
229
|
end
|
211
230
|
|
212
231
|
def property_assignment(assignee, message, value)
|
@@ -218,9 +237,9 @@ module Mulang::Ruby
|
|
218
237
|
def reasign(accessor, args, id, message, value)
|
219
238
|
simple_send id,
|
220
239
|
"#{accessor}=".to_sym,
|
221
|
-
args + [
|
240
|
+
args + [ms(:Send,
|
222
241
|
simple_send(id, accessor, args),
|
223
|
-
message,
|
242
|
+
message_reference(message),
|
224
243
|
[value])]
|
225
244
|
end
|
226
245
|
|
@@ -256,7 +275,6 @@ module Mulang::Ruby
|
|
256
275
|
end
|
257
276
|
|
258
277
|
def handler_missing(*args)
|
259
|
-
puts args
|
260
278
|
ms :Other, args.to_s, nil
|
261
279
|
end
|
262
280
|
|
@@ -264,15 +282,29 @@ module Mulang::Ruby
|
|
264
282
|
receptor, message, *args = *node
|
265
283
|
receptor ||= s(:self)
|
266
284
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
285
|
+
ms :Send, process(receptor), message_reference(message), (process_all(args) + extra_args)
|
286
|
+
end
|
287
|
+
|
288
|
+
def message_reference(message)
|
289
|
+
case message
|
290
|
+
when :== then primitive :Equal
|
291
|
+
when :!= then primitive :NotEqual
|
292
|
+
when :! then primitive :Negation
|
293
|
+
when :'&&' then primitive :And
|
294
|
+
when :'||' then primitive :Or
|
295
|
+
when :hash then primitive :Hash
|
296
|
+
when :>= then primitive :GreatherOrEqualThan
|
297
|
+
when :> then primitive :GreatherThan
|
298
|
+
when :<= then primitive :LessOrEqualThan
|
299
|
+
when :< then primitive :LessThan
|
300
|
+
when :+ then primitive :Plus
|
301
|
+
when :- then primitive :Minus
|
302
|
+
when :* then primitive :Multiply
|
303
|
+
when :/ then primitive :Divide
|
304
|
+
when :length then primitive :Size
|
305
|
+
when :size then primitive :Size
|
306
|
+
else ms :Reference, message
|
273
307
|
end
|
274
|
-
|
275
|
-
ms :Send, process(receptor), message, (process_all(args) + extra_args)
|
276
308
|
end
|
277
309
|
|
278
310
|
end
|
data/lib/mulang/ruby/sexp.rb
CHANGED
@@ -1,48 +1,11 @@
|
|
1
|
+
require "mulang"
|
2
|
+
|
1
3
|
module Mulang::Ruby
|
2
4
|
module Sexp
|
3
|
-
|
4
|
-
if contents.empty?
|
5
|
-
ms(:MuNil)
|
6
|
-
elsif contents.size == 1
|
7
|
-
contents[0]
|
8
|
-
else
|
9
|
-
ms(:Sequence, *contents)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def ms(tag, *contents)
|
14
|
-
if contents.empty?
|
15
|
-
{tag: tag}
|
16
|
-
elsif contents.size == 1
|
17
|
-
{tag: tag, contents: contents.first}
|
18
|
-
else
|
19
|
-
{tag: tag, contents: contents}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def simple_method(name, args, body)
|
24
|
-
{
|
25
|
-
tag: :Method,
|
26
|
-
contents: [
|
27
|
-
name,
|
28
|
-
[
|
29
|
-
[ args, {tag: :UnguardedBody, contents: body }]
|
30
|
-
]
|
31
|
-
]
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
def mu_method(tag, args, body)
|
36
|
-
{
|
37
|
-
tag: tag,
|
38
|
-
contents: [
|
39
|
-
[ args, {tag: :UnguardedBody, contents: body }]
|
40
|
-
]
|
41
|
-
}
|
42
|
-
end
|
5
|
+
include Mulang::Sexp
|
43
6
|
|
44
|
-
def
|
45
|
-
ms(:
|
7
|
+
def none
|
8
|
+
ms(:MuNil)
|
46
9
|
end
|
47
10
|
end
|
48
11
|
end
|
data/lib/mulang/ruby/version.rb
CHANGED
data/mulang-ruby.gemspec
CHANGED
@@ -21,13 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler",
|
24
|
+
spec.add_development_dependency "bundler", '>= 1.1', '< 3'
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
27
|
spec.add_development_dependency "pry"
|
28
28
|
|
29
|
-
spec.add_dependency "parser"
|
30
|
-
spec.add_dependency "ast"
|
29
|
+
spec.add_dependency "parser", "~> 2.6"
|
30
|
+
spec.add_dependency "ast", "~> 2.4"
|
31
31
|
spec.add_dependency "mumukit-core", "~> 1.0"
|
32
|
-
spec.add_dependency "mulang", "~>
|
32
|
+
spec.add_dependency "mulang", "~> 6.0"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mulang-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.1
|
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:
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '3'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
29
|
+
version: '1.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,30 +76,30 @@ dependencies:
|
|
70
76
|
name: parser
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '2.6'
|
76
82
|
type: :runtime
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- - "
|
86
|
+
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '2.6'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: ast
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '2.4'
|
90
96
|
type: :runtime
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
102
|
+
version: '2.4'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: mumukit-core
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +120,14 @@ dependencies:
|
|
114
120
|
requirements:
|
115
121
|
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
123
|
+
version: '6.0'
|
118
124
|
type: :runtime
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
128
|
- - "~>"
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
130
|
+
version: '6.0'
|
125
131
|
description: Ruby - Mulang Parser
|
126
132
|
email:
|
127
133
|
- franco@mumuki.org
|
@@ -129,9 +135,10 @@ executables: []
|
|
129
135
|
extensions: []
|
130
136
|
extra_rdoc_files: []
|
131
137
|
files:
|
138
|
+
- ".github/workflows/test_and_deploy.yml"
|
132
139
|
- ".gitignore"
|
133
140
|
- ".rspec"
|
134
|
-
- ".
|
141
|
+
- ".ruby-version"
|
135
142
|
- CODE_OF_CONDUCT.md
|
136
143
|
- COPYRIGHT.txt
|
137
144
|
- Gemfile
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.3.1
|
5
|
-
before_install:
|
6
|
-
# Extend Path
|
7
|
-
- mkdir -p ~/.local/bin
|
8
|
-
- export PATH=$HOME/.local/bin:$PATH
|
9
|
-
# Install bundler
|
10
|
-
- gem install bundler -v 1.14.6
|
11
|
-
deploy:
|
12
|
-
provider: rubygems
|
13
|
-
api_key:
|
14
|
-
secure: UReab6XV1hLEiB+qmV2z7urHDApuD8MLINMOXxjaU7X6jplHmTttgci+wuP3w8Q+oqAy1s97j270ofQszHogppOtxa+AZzmXvI9TPZ5XRJJXFNH4Bt5RguP/gIN2bZEmCESdbpsTC6w5gxvDAfSQTPSE0mO/MLY5xRUYja/RdmhxdrvQuzir+c9L+hzGT4ysoiJ7UXkaKEUsfi2ief9/XRflmzTytf+C0uNSjFbVo0JCB5StBJwxmaUAMH2F5LQTZPUBDu+/FFJJO3w/yyYcRrqsNxujqJozXQZAwsmR3myMxyKIOZFAGCeC22+6XKPDHDSBLnNsQzWFdCieUzgsd3jZJFYeorXY63Uv5cGa1F+S7tbLmdXHBlbSfN2e5g6AUse1HyFXqgzgVUUftgZ8Uv7Ttc+BN9R1uzxMTJ7ox1wGncc01rbfQ/KPD0W0XEwON18aiCYjM5XvVNb4F1W4e7mNk28tdrxIC6RNkScpKLg5E0td1xPRkRDo2ZO2KWRZGGrabzjr05TTTWrI1+YVx3Mm4N1RiirjC5HybdHy5JO7eLDYU/FIXlVRwjCN7LKnP42zUsic1Y5JCYNs1RzZdJlH5sQaC/boy0bi2pVbehh3BlAbdCQu/ckqla7RG0ab5Bbw01m4aNSO5PkdIksxAN6yuelKkFXrSrs3pXEr528=
|
15
|
-
gem: mulang-ruby
|
16
|
-
on:
|
17
|
-
tags: true
|
18
|
-
repo: mumuki/mulang-ruby
|