mulang-ruby 6.0.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mulang/ruby.rb +12 -6
- data/lib/mulang/ruby/ast_processor.rb +5 -7
- data/lib/mulang/ruby/sexp.rb +2 -1
- data/lib/mulang/ruby/sexp_parser.rb +3 -2
- data/lib/mulang/ruby/version.rb +1 -1
- data/mulang-ruby.gemspec +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 534bc3c5a44381a2ba606c51162b1ccc664a20cdfe20470e3cd1c328fd43285b
|
4
|
+
data.tar.gz: abddef43c33abb13f13ae185ba94e310d384e0257fb7a62a1192b18e8b0bd6b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 523da2d9961e079ddc1061988dfee999ae73f753ac386588066f8942676eb01e66725af10777da41a31f5ecc2037841e5574a7c11ceb2387bec245a99ee40973
|
7
|
+
data.tar.gz: 6eba9d4083da3c9e63932c491c7b90d4b8b95ebe7e50fbb7c9bd99206e7ee56d41c938920ece70cdefc0baa72d6413f882991332e4efd0c5fe6485fa7e1331f8
|
data/lib/mulang/ruby.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
require 'ast'
|
2
|
-
require 'parser/ruby23'
|
3
2
|
require 'mumukit/core'
|
4
|
-
|
3
|
+
require 'parser/ruby26'
|
5
4
|
require_relative "./ruby/version"
|
6
5
|
|
7
6
|
module Mulang
|
8
7
|
module Ruby
|
9
|
-
def self.parse(ruby_code)
|
10
|
-
|
8
|
+
def self.parse(ruby_code, parser_class: nil)
|
9
|
+
parser_class ||= default_parser_class
|
10
|
+
Mulang::Ruby::AstProcessor.new.process Mulang::Ruby::SexpParser.parser(ruby_code, parser_class)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.language(parser_class: nil)
|
14
|
+
Mulang::Language::External.new("Ruby") { |it| parse(it, parser_class: parser_class) }
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.default_parser_class
|
20
|
+
Parser::Ruby26
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -3,9 +3,12 @@ module Mulang::Ruby
|
|
3
3
|
include AST::Sexp
|
4
4
|
include Mulang::Ruby::Sexp
|
5
5
|
|
6
|
+
def process(node)
|
7
|
+
node.nil? ? none : super
|
8
|
+
end
|
9
|
+
|
6
10
|
def on_class(node)
|
7
11
|
name, superclass, body = *node
|
8
|
-
body ||= s(:nil)
|
9
12
|
|
10
13
|
_, class_name = *name
|
11
14
|
_, superclass_name = *superclass
|
@@ -15,7 +18,6 @@ module Mulang::Ruby
|
|
15
18
|
|
16
19
|
def on_module(node)
|
17
20
|
name, body = *node
|
18
|
-
body ||= s(:nil)
|
19
21
|
|
20
22
|
_, module_name = *name
|
21
23
|
|
@@ -113,14 +115,12 @@ module Mulang::Ruby
|
|
113
115
|
|
114
116
|
def on_defs(node)
|
115
117
|
_target, id, args, body = *node
|
116
|
-
body ||= s(:nil)
|
117
118
|
|
118
119
|
simple_method id, process_all(args), process(body)
|
119
120
|
end
|
120
121
|
|
121
122
|
def on_def(node)
|
122
123
|
id, args, body = *node
|
123
|
-
body ||= s(:nil)
|
124
124
|
|
125
125
|
case id
|
126
126
|
when :equal?, :eql?, :==
|
@@ -143,7 +143,7 @@ module Mulang::Ruby
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def on_nil(_)
|
146
|
-
|
146
|
+
mnil
|
147
147
|
end
|
148
148
|
|
149
149
|
def on_self(_)
|
@@ -192,8 +192,6 @@ module Mulang::Ruby
|
|
192
192
|
|
193
193
|
def on_if(node)
|
194
194
|
condition, if_true, if_false = *node
|
195
|
-
if_true ||= s(:nil)
|
196
|
-
if_false ||= s(:nil)
|
197
195
|
|
198
196
|
ms :If, process(condition), process(if_true), process(if_false)
|
199
197
|
end
|
data/lib/mulang/ruby/sexp.rb
CHANGED
@@ -3,9 +3,10 @@ module Mulang::Ruby
|
|
3
3
|
Parser::Builders::Default.emit_lambda = true
|
4
4
|
Parser::Builders::Default.emit_procarg0 = true
|
5
5
|
|
6
|
-
def self.parser(ruby_code)
|
7
|
-
parser =
|
6
|
+
def self.parser(ruby_code, parser_class)
|
7
|
+
parser = parser_class.new
|
8
8
|
parser.diagnostics.consumer = lambda {|it|}
|
9
|
+
parser.diagnostics.all_errors_are_fatal = true
|
9
10
|
buffer = Parser::Source::Buffer.new('(string)')
|
10
11
|
buffer.source = ruby_code
|
11
12
|
parser.parse(buffer).tap do |result|
|
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: 6.0
|
4
|
+
version: 6.1.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: 2021-02-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,9 @@ dependencies:
|
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '6.0'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 6.0.3
|
124
127
|
type: :runtime
|
125
128
|
prerelease: false
|
126
129
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -128,6 +131,9 @@ dependencies:
|
|
128
131
|
- - "~>"
|
129
132
|
- !ruby/object:Gem::Version
|
130
133
|
version: '6.0'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 6.0.3
|
131
137
|
description: Ruby - Mulang Parser
|
132
138
|
email:
|
133
139
|
- franco@mumuki.org
|