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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4c6d1ce223e3d229c5e4c7f3483fcd81e87548515c7edd2689859d257594078
4
- data.tar.gz: 1771c2958eff5b7a1afb06adee2cf1ec005fc20c42ee91841bce8a566f773dc1
3
+ metadata.gz: 534bc3c5a44381a2ba606c51162b1ccc664a20cdfe20470e3cd1c328fd43285b
4
+ data.tar.gz: abddef43c33abb13f13ae185ba94e310d384e0257fb7a62a1192b18e8b0bd6b9
5
5
  SHA512:
6
- metadata.gz: e742ffb822e379a604761d329027bca396baf1176d9ad65cb898df3a875f424a97fb2c3a044de64316c95375238ac20cdd03823787fd5a789e8075fc34a17b54
7
- data.tar.gz: b5a91310d27d1eba544437b54aaef7e6f9218b49c96e522c70e5e74d18880c56029d04fbfd8e78db250bbc281108a599c8b5e9068df7b73586a8f897d48ce998
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
- Mulang::Ruby::AstProcessor.new.process Mulang::Ruby::SexpParser.parser(ruby_code)
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
- def self.language
14
- Mulang::Language::External.new("Ruby") { |it| parse(it) }
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
- ms :MuNil
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
@@ -4,8 +4,9 @@ module Mulang::Ruby
4
4
  module Sexp
5
5
  include Mulang::Sexp
6
6
 
7
- def none
7
+ def mnil
8
8
  ms(:MuNil)
9
9
  end
10
10
  end
11
+
11
12
  end
@@ -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 = Parser::Ruby23.new
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|
@@ -1,5 +1,5 @@
1
1
  module Mulang
2
2
  module Ruby
3
- VERSION = "6.0.1"
3
+ VERSION = "6.1.0"
4
4
  end
5
5
  end
data/mulang-ruby.gemspec CHANGED
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "parser", "~> 2.6"
30
30
  spec.add_dependency "ast", "~> 2.4"
31
31
  spec.add_dependency "mumukit-core", "~> 1.0"
32
- spec.add_dependency "mulang", "~> 6.0"
32
+ spec.add_dependency "mulang", '~> 6.0', '>= 6.0.3'
33
33
  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: 6.0.1
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-04 00:00:00.000000000 Z
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