mulang-ruby 4.0.0 → 6.0.0
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 +2 -2
- data/lib/mulang/ruby/ast_processor.rb +41 -17
- data/lib/mulang/ruby/sexp.rb +5 -42
- data/lib/mulang/ruby/sexp_parser.rb +1 -1
- data/lib/mulang/ruby/version.rb +1 -1
- data/mulang-ruby.gemspec +4 -4
- metadata +25 -19
- 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: bffbfe0515ffc42d5a7cc62ac0c219f01efed7ca0a09867e081f87db7d60e17e
|
4
|
+
data.tar.gz: b4b58bb43f77bf21979922180af6a1dbcd2b99b9400e6a67b41cea7d618e8428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0259e8d0bd2b6ae8782381eb98fa3025d461b0e7f5735547575af614bad2900b187b4dca409fa78d95554300fa2500513bbfcbf448501231008915aae7eb2b62'
|
7
|
+
data.tar.gz: 3c3c1cf74dee097855440376b97a934e273523545a82a38ad1fc47778b3b8c4ed2e39333e39d2b51945fa748cb31b91c778d7f2d8d7d0e42a5c50c3ab5f3a877
|
@@ -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
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'ast'
|
2
|
-
require 'parser/
|
2
|
+
require 'parser/ruby23'
|
3
3
|
require 'mumukit/core'
|
4
4
|
|
5
5
|
require_relative "./ruby/version"
|
@@ -11,7 +11,7 @@ module Mulang
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.language
|
14
|
-
|
14
|
+
Mulang::Language::External.new { |it| parse(it) }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -28,13 +28,13 @@ module Mulang::Ruby
|
|
28
28
|
|
29
29
|
def on_rescue(node)
|
30
30
|
try, *catch, _ = *node
|
31
|
-
ms :Try, process(try), process_all(catch),
|
31
|
+
ms :Try, process(try), process_all(catch), none
|
32
32
|
end
|
33
33
|
|
34
34
|
def on_resbody(node)
|
35
35
|
patterns, variable, block = *node
|
36
36
|
|
37
|
-
[to_mulang_pattern(patterns, variable), process(block) ||
|
37
|
+
[to_mulang_pattern(patterns, variable), process(block) || none]
|
38
38
|
end
|
39
39
|
|
40
40
|
def _
|
@@ -120,9 +120,9 @@ module Mulang::Ruby
|
|
120
120
|
|
121
121
|
case id
|
122
122
|
when :equal?, :eql?, :==
|
123
|
-
|
123
|
+
primitive_method :Equal, process_all(args), process(body)
|
124
124
|
when :hash
|
125
|
-
|
125
|
+
primitive_method :Hash, process_all(args), process(body)
|
126
126
|
else
|
127
127
|
simple_method id, process_all(args), process(body)
|
128
128
|
end
|
@@ -130,7 +130,7 @@ module Mulang::Ruby
|
|
130
130
|
|
131
131
|
def on_block(node)
|
132
132
|
send, parameters, body = *node
|
133
|
-
lambda = ms(:Lambda, process_all(parameters), process(body))
|
133
|
+
lambda = ms(:Lambda, process_all(parameters), process(body) || none)
|
134
134
|
handle_send_with_args send, [lambda]
|
135
135
|
end
|
136
136
|
|
@@ -151,6 +151,17 @@ module Mulang::Ruby
|
|
151
151
|
ms :VariablePattern, name
|
152
152
|
end
|
153
153
|
|
154
|
+
def on_for(node)
|
155
|
+
variable, list, block = *node
|
156
|
+
|
157
|
+
pattern = ms(:VariablePattern, variable.children.first)
|
158
|
+
ms(:For, [ms(:Generator, pattern, process(list))], process(block) || none)
|
159
|
+
end
|
160
|
+
|
161
|
+
def on_optarg(node)
|
162
|
+
ms :OtherPattern, node.to_s, nil
|
163
|
+
end
|
164
|
+
|
154
165
|
alias on_restarg on_arg
|
155
166
|
alias on_procarg0 on_arg
|
156
167
|
|
@@ -206,7 +217,7 @@ module Mulang::Ruby
|
|
206
217
|
|
207
218
|
def var_assignment(assignee, message, value)
|
208
219
|
id = assignee.to_a.first
|
209
|
-
ms :Assignment, id,
|
220
|
+
ms :Assignment, id, ms(:Send, ms(:Reference, id), message_reference(message), [process(value)])
|
210
221
|
end
|
211
222
|
|
212
223
|
def property_assignment(assignee, message, value)
|
@@ -218,9 +229,9 @@ module Mulang::Ruby
|
|
218
229
|
def reasign(accessor, args, id, message, value)
|
219
230
|
simple_send id,
|
220
231
|
"#{accessor}=".to_sym,
|
221
|
-
args + [
|
232
|
+
args + [ms(:Send,
|
222
233
|
simple_send(id, accessor, args),
|
223
|
-
message,
|
234
|
+
message_reference(message),
|
224
235
|
[value])]
|
225
236
|
end
|
226
237
|
|
@@ -256,7 +267,6 @@ module Mulang::Ruby
|
|
256
267
|
end
|
257
268
|
|
258
269
|
def handler_missing(*args)
|
259
|
-
puts args
|
260
270
|
ms :Other, args.to_s, nil
|
261
271
|
end
|
262
272
|
|
@@ -264,15 +274,29 @@ module Mulang::Ruby
|
|
264
274
|
receptor, message, *args = *node
|
265
275
|
receptor ||= s(:self)
|
266
276
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
277
|
+
ms :Send, process(receptor), message_reference(message), (process_all(args) + extra_args)
|
278
|
+
end
|
279
|
+
|
280
|
+
def message_reference(message)
|
281
|
+
case message
|
282
|
+
when :== then primitive :Equal
|
283
|
+
when :!= then primitive :NotEqual
|
284
|
+
when :! then primitive :Negation
|
285
|
+
when :'&&' then primitive :And
|
286
|
+
when :'||' then primitive :Or
|
287
|
+
when :hash then primitive :Hash
|
288
|
+
when :>= then primitive :GreatherOrEqualThan
|
289
|
+
when :> then primitive :GreatherThan
|
290
|
+
when :<= then primitive :LessOrEqualThan
|
291
|
+
when :< then primitive :LessThan
|
292
|
+
when :+ then primitive :Plus
|
293
|
+
when :- then primitive :Minus
|
294
|
+
when :* then primitive :Multiply
|
295
|
+
when :/ then primitive :Divide
|
296
|
+
when :length then primitive :Size
|
297
|
+
when :size then primitive :Size
|
298
|
+
else ms :Reference, message
|
273
299
|
end
|
274
|
-
|
275
|
-
ms :Send, process(receptor), message, (process_all(args) + extra_args)
|
276
300
|
end
|
277
301
|
|
278
302
|
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
|
@@ -4,7 +4,7 @@ module Mulang::Ruby
|
|
4
4
|
Parser::Builders::Default.emit_procarg0 = true
|
5
5
|
|
6
6
|
def self.parser(ruby_code)
|
7
|
-
parser = Parser::
|
7
|
+
parser = Parser::Ruby23.new
|
8
8
|
parser.diagnostics.consumer = lambda {|it|}
|
9
9
|
buffer = Parser::Source::Buffer.new('(string)')
|
10
10
|
buffer.source = ruby_code
|
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.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:
|
11
|
+
date: 2021-01-19 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
|
@@ -166,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
173
|
- !ruby/object:Gem::Version
|
167
174
|
version: '0'
|
168
175
|
requirements: []
|
169
|
-
|
170
|
-
rubygems_version: 2.7.7
|
176
|
+
rubygems_version: 3.0.3
|
171
177
|
signing_key:
|
172
178
|
specification_version: 4
|
173
179
|
summary: Ruby integration for the Mulang Language Analyzer
|
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
|