delorean_lang 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitlab-ci.yml +1 -2
- data/.rubocop.yml +45 -5
- data/.rubocop_todo.yml +1 -634
- data/Gemfile +3 -1
- data/README.md +22 -0
- data/Rakefile +3 -1
- data/delorean.gemspec +18 -17
- data/lib/delorean/abstract_container.rb +4 -2
- data/lib/delorean/base.rb +30 -27
- data/lib/delorean/cache.rb +2 -0
- data/lib/delorean/cache/adapters.rb +2 -0
- data/lib/delorean/cache/adapters/base.rb +2 -0
- data/lib/delorean/cache/adapters/ruby_cache.rb +5 -0
- data/lib/delorean/const.rb +5 -3
- data/lib/delorean/debug.rb +6 -5
- data/lib/delorean/delorean.rb +466 -147
- data/lib/delorean/delorean.treetop +13 -1
- data/lib/delorean/engine.rb +61 -50
- data/lib/delorean/error.rb +2 -1
- data/lib/delorean/model.rb +12 -9
- data/lib/delorean/nodes.rb +130 -67
- data/lib/delorean/ruby.rb +2 -0
- data/lib/delorean/ruby/whitelists.rb +2 -0
- data/lib/delorean/ruby/whitelists/base.rb +7 -3
- data/lib/delorean/ruby/whitelists/default.rb +6 -6
- data/lib/delorean/ruby/whitelists/empty.rb +3 -2
- data/lib/delorean/ruby/whitelists/matchers.rb +2 -0
- data/lib/delorean/ruby/whitelists/matchers/arguments.rb +2 -0
- data/lib/delorean/ruby/whitelists/matchers/method.rb +5 -2
- data/lib/delorean/ruby/whitelists/whitelist_error.rb +2 -0
- data/lib/delorean/version.rb +3 -1
- data/lib/delorean_lang.rb +3 -1
- data/spec/cache_spec.rb +4 -2
- data/spec/dev_spec.rb +68 -69
- data/spec/eval_spec.rb +824 -729
- data/spec/func_spec.rb +172 -176
- data/spec/parse_spec.rb +516 -522
- data/spec/ruby/whitelist_spec.rb +6 -3
- data/spec/spec_helper.rb +26 -23
- metadata +27 -27
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in delorean.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
8
|
group :development, :test do
|
7
|
-
gem 'rspec-instafail', require: false
|
8
9
|
gem 'pry'
|
10
|
+
gem 'rspec-instafail', require: false
|
9
11
|
end
|
data/README.md
CHANGED
@@ -121,6 +121,28 @@ newly defined `teen_min`. Therefore, `IndiaInfo.is_teenager` with
|
|
121
121
|
input of `age = 10` will evaluate to `true`. Whereas,
|
122
122
|
`USInfo.is_teenager` with input of `age = 10` will evaluate to `false`.
|
123
123
|
|
124
|
+
### Debugging
|
125
|
+
|
126
|
+
You can use `(ERR())` to add a breakpoint:
|
127
|
+
|
128
|
+
```
|
129
|
+
USInfo:
|
130
|
+
age = ?
|
131
|
+
teen_max = 19
|
132
|
+
teen_min = 13
|
133
|
+
is_teenager = (ERR()) && age >= teen_min && age <= teen_max
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
Then you can call attributes by using their mangled name (e.g. attr__D) and passing the context. attr__D(_e). Of course, you can use `ls` to list available methods.
|
138
|
+
|
139
|
+
```
|
140
|
+
teen_max__D(_e) # 19
|
141
|
+
age__D(_e)
|
142
|
+
```
|
143
|
+
|
144
|
+
### TODO
|
145
|
+
|
124
146
|
TODO: provide details on the following topics:
|
125
147
|
|
126
148
|
* Supported data types
|
data/Rakefile
CHANGED
data/delorean.gemspec
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/delorean/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |gem|
|
4
|
-
gem.authors = [
|
5
|
-
gem.email = [
|
6
|
-
gem.description =
|
7
|
-
gem.summary =
|
8
|
-
gem.homepage =
|
6
|
+
gem.authors = ['Arman Bostani']
|
7
|
+
gem.email = ['arman.bostani@pnmac.com']
|
8
|
+
gem.description = 'A "compiler" for the Delorean programming language'
|
9
|
+
gem.summary = 'Delorean compiler'
|
10
|
+
gem.homepage = 'https://github.com/arman000/delorean_lang'
|
9
11
|
|
10
|
-
gem.files = `git ls-files`.split(
|
11
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
12
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
-
gem.name =
|
14
|
-
gem.require_paths = [
|
15
|
+
gem.name = 'delorean_lang'
|
16
|
+
gem.require_paths = ['lib']
|
15
17
|
gem.version = Delorean::VERSION
|
16
18
|
gem.licenses = ['MIT']
|
17
19
|
|
18
|
-
|
19
|
-
gem.add_dependency
|
20
|
-
gem.
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency "rubocop"
|
20
|
+
gem.add_dependency 'activerecord', '>= 3.2'
|
21
|
+
gem.add_dependency 'treetop', '~> 1.5'
|
22
|
+
gem.add_development_dependency 'pry'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.1'
|
24
|
+
gem.add_development_dependency 'rubocop'
|
25
|
+
gem.add_development_dependency 'sqlite3', '~> 1.3.10'
|
25
26
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'delorean/base'
|
2
4
|
|
3
5
|
module Delorean
|
4
6
|
class AbstractContainer
|
5
|
-
def get_engine(
|
6
|
-
raise
|
7
|
+
def get_engine(_name)
|
8
|
+
raise 'get_engine needs to be overriden'
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/delorean/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/time'
|
2
4
|
require 'active_record'
|
3
5
|
require 'bigdecimal'
|
@@ -6,7 +8,6 @@ require 'delorean/ruby/whitelists/default'
|
|
6
8
|
require 'delorean/cache'
|
7
9
|
|
8
10
|
module Delorean
|
9
|
-
|
10
11
|
::Delorean::Ruby.whitelist = ::Delorean::Ruby::Whitelists::Default.new
|
11
12
|
|
12
13
|
::Delorean::Cache.adapter = ::Delorean::Cache::Adapters::RubyCache.new(
|
@@ -22,7 +23,7 @@ module Delorean
|
|
22
23
|
# This is pretty awful. NOTE: can't sanitize params as Marty
|
23
24
|
# patches NodeCall and modifies params to send _parent_id.
|
24
25
|
# This whole thing needs to be redone.
|
25
|
-
@
|
26
|
+
@cloned_params ||= Hash[params]
|
26
27
|
end
|
27
28
|
|
28
29
|
def evaluate(attr)
|
@@ -30,30 +31,28 @@ module Delorean
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def /(args)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
raise "non-array/string arg to /"
|
41
|
-
end
|
42
|
-
rescue => exc
|
43
|
-
Delorean::Engine.grok_runtime_exception(exc)
|
34
|
+
case args
|
35
|
+
when Array
|
36
|
+
engine.eval_to_hash(node, args, cloned_params)
|
37
|
+
when String
|
38
|
+
evaluate(args)
|
39
|
+
else
|
40
|
+
raise 'non-array/string arg to /'
|
44
41
|
end
|
42
|
+
rescue StandardError => exc
|
43
|
+
Delorean::Engine.grok_runtime_exception(exc)
|
45
44
|
end
|
46
45
|
|
47
46
|
# FIXME: % should also support string as args
|
48
47
|
def %(args)
|
49
|
-
raise
|
48
|
+
raise 'non-array arg to %' unless args.is_a?(Array)
|
50
49
|
|
51
50
|
engine.eval_to_hash(node, args, cloned_params)
|
52
51
|
end
|
53
52
|
|
54
53
|
# add new arguments, results in a new NodeCall
|
55
54
|
def +(args)
|
56
|
-
raise
|
55
|
+
raise 'bad arg to %' unless args.is_a?(Hash)
|
57
56
|
|
58
57
|
NodeCall.new(_e, engine, node, params.merge(args))
|
59
58
|
end
|
@@ -72,6 +71,7 @@ module Delorean
|
|
72
71
|
# {}.length. i.e. length is a whitelisted function, but not
|
73
72
|
# an attr. This implementation returns nil instead of 0.
|
74
73
|
return obj[attr] if obj.member?(attr)
|
74
|
+
|
75
75
|
return attr.is_a?(String) ? obj[attr.to_sym] : nil
|
76
76
|
end
|
77
77
|
|
@@ -91,9 +91,11 @@ module Delorean
|
|
91
91
|
|
92
92
|
begin
|
93
93
|
return _instance_call(obj, attr, [], _e)
|
94
|
-
rescue => exc
|
95
|
-
raise
|
96
|
-
|
94
|
+
rescue StandardError => exc
|
95
|
+
raise(
|
96
|
+
InvalidGetAttribute,
|
97
|
+
"attr lookup failed: '#{attr}' on <#{obj.class}> #{obj} - #{exc}"
|
98
|
+
)
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
@@ -105,14 +107,16 @@ module Delorean
|
|
105
107
|
when nil
|
106
108
|
# FIXME: even Javascript which is superpermissive raises an
|
107
109
|
# exception on null getattr.
|
108
|
-
|
110
|
+
nil
|
109
111
|
when Hash, NodeCall, Class, OpenStruct
|
110
112
|
raise InvalidIndex unless args.length == 1
|
113
|
+
|
111
114
|
_get_attr(obj, args[0], _e)
|
112
115
|
when Array, String, MatchData
|
113
116
|
raise InvalidIndex unless args.length <= 2 &&
|
114
117
|
args[0].is_a?(Integer) &&
|
115
118
|
(args[1].nil? || args[1].is_a?(Integer))
|
119
|
+
|
116
120
|
obj[*args]
|
117
121
|
else
|
118
122
|
raise InvalidIndex
|
@@ -122,8 +126,7 @@ module Delorean
|
|
122
126
|
######################################################################
|
123
127
|
|
124
128
|
def self._sanitize_hash(_e)
|
125
|
-
_e.each_with_object({}) do
|
126
|
-
|(k,v), h|
|
129
|
+
_e.each_with_object({}) do |(k, v), h|
|
127
130
|
h[k] = v if k.is_a?(Integer) || k =~ /\A[a-z][A-Za-z0-9_]*\z/
|
128
131
|
end
|
129
132
|
end
|
@@ -131,7 +134,7 @@ module Delorean
|
|
131
134
|
######################################################################
|
132
135
|
|
133
136
|
def self._err(*args)
|
134
|
-
str = args.map(&:to_s).join(
|
137
|
+
str = args.map(&:to_s).join(', ')
|
135
138
|
raise str
|
136
139
|
end
|
137
140
|
|
@@ -164,15 +167,15 @@ module Delorean
|
|
164
167
|
return obj.send(msg, *args)
|
165
168
|
end
|
166
169
|
|
167
|
-
cls = obj.class
|
168
|
-
|
169
170
|
matcher = ::Delorean::Ruby.whitelist.matcher(method_name: msg)
|
170
171
|
|
171
172
|
raise "no such method #{method}" unless matcher
|
172
173
|
|
173
|
-
|
174
|
-
|
175
|
-
|
174
|
+
if matcher.match_to?
|
175
|
+
return(
|
176
|
+
_instance_call(obj, matcher.match_to, args, _e)
|
177
|
+
)
|
178
|
+
end
|
176
179
|
|
177
180
|
matcher.match!(klass: obj.class, args: args)
|
178
181
|
|
data/lib/delorean/cache.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './base'
|
2
4
|
|
3
5
|
module Delorean
|
@@ -20,14 +22,17 @@ module Delorean
|
|
20
22
|
def fetch_item(klass:, cache_key:, default: nil)
|
21
23
|
subh = lookup_cache.fetch(klass, default)
|
22
24
|
return default if subh == default
|
25
|
+
|
23
26
|
v = subh.fetch(cache_key, default)
|
24
27
|
return default if v == default
|
28
|
+
|
25
29
|
v
|
26
30
|
end
|
27
31
|
|
28
32
|
def cache_key(klass:, method_name:, args:)
|
29
33
|
[method_name] + args.map do |arg|
|
30
34
|
next arg.id if arg.respond_to?(:id)
|
35
|
+
|
31
36
|
arg
|
32
37
|
end.freeze
|
33
38
|
end
|
data/lib/delorean/const.rb
CHANGED
data/lib/delorean/debug.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Delorean
|
2
4
|
class Debug
|
3
5
|
@debug_set = Set[]
|
@@ -8,15 +10,14 @@ module Delorean
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.log(obj)
|
11
|
-
File.open(@log_file, 'a+')
|
12
|
-
|f|
|
13
|
+
File.open(@log_file, 'a+') do |f|
|
13
14
|
f.write obj.inspect
|
14
15
|
f.write "\n"
|
15
|
-
|
16
|
+
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
class << self
|
20
|
+
attr_reader :debug_set
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/delorean/delorean.rb
CHANGED
@@ -140,7 +140,6 @@ module Delorean
|
|
140
140
|
def m
|
141
141
|
elements[0]
|
142
142
|
end
|
143
|
-
|
144
143
|
end
|
145
144
|
|
146
145
|
module Formula4
|
@@ -151,20 +150,37 @@ module Delorean
|
|
151
150
|
def mod
|
152
151
|
elements[3]
|
153
152
|
end
|
153
|
+
end
|
154
|
+
|
155
|
+
module Formula5
|
156
|
+
def m
|
157
|
+
elements[0]
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
module Formula6
|
163
|
+
def n
|
164
|
+
elements[0]
|
165
|
+
end
|
166
|
+
|
167
|
+
def mod
|
168
|
+
elements[3]
|
169
|
+
end
|
154
170
|
|
155
171
|
def p
|
156
172
|
elements[4]
|
157
173
|
end
|
158
174
|
end
|
159
175
|
|
160
|
-
module
|
176
|
+
module Formula7
|
161
177
|
def n
|
162
178
|
elements[0]
|
163
179
|
end
|
164
180
|
|
165
181
|
end
|
166
182
|
|
167
|
-
module
|
183
|
+
module Formula8
|
168
184
|
def sp
|
169
185
|
elements[1]
|
170
186
|
end
|
@@ -344,41 +360,22 @@ module Delorean
|
|
344
360
|
end
|
345
361
|
s25 << r28
|
346
362
|
if r28
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
if
|
351
|
-
|
352
|
-
|
353
|
-
@index += match_len
|
354
|
-
else
|
355
|
-
terminal_parse_failure('\'::\'')
|
356
|
-
r33 = nil
|
357
|
-
end
|
358
|
-
s31 << r33
|
359
|
-
end
|
360
|
-
if s31.last
|
361
|
-
r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
|
362
|
-
r31.extend(Formula3)
|
363
|
+
i30, s30 = index, []
|
364
|
+
r31 = _nt_class_name_import_nested
|
365
|
+
s30 << r31
|
366
|
+
if s30.last
|
367
|
+
r30 = instantiate_node(SyntaxNode,input, i30...index, s30)
|
368
|
+
r30.extend(Formula3)
|
363
369
|
else
|
364
|
-
@index =
|
365
|
-
|
366
|
-
end
|
367
|
-
if r31
|
368
|
-
r30 = r31
|
369
|
-
else
|
370
|
-
r30 = instantiate_node(SyntaxNode,input, index...index)
|
370
|
+
@index = i30
|
371
|
+
r30 = nil
|
371
372
|
end
|
372
373
|
s25 << r30
|
373
|
-
if r30
|
374
|
-
r34 = _nt_class_name
|
375
|
-
s25 << r34
|
376
|
-
end
|
377
374
|
end
|
378
375
|
end
|
379
376
|
end
|
380
377
|
if s25.last
|
381
|
-
r25 = instantiate_node(
|
378
|
+
r25 = instantiate_node(SubNodeNested,input, i25...index, s25)
|
382
379
|
r25.extend(Formula4)
|
383
380
|
else
|
384
381
|
@index = i25
|
@@ -388,60 +385,126 @@ module Delorean
|
|
388
385
|
r25 = SyntaxNode.new(input, (index-1)...index) if r25 == true
|
389
386
|
r0 = r25
|
390
387
|
else
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
if
|
388
|
+
i32, s32 = index, []
|
389
|
+
r33 = _nt_class_name
|
390
|
+
s32 << r33
|
391
|
+
if r33
|
395
392
|
if (match_len = has_terminal?(':', false, index))
|
396
|
-
|
393
|
+
r34 = true
|
397
394
|
@index += match_len
|
398
395
|
else
|
399
396
|
terminal_parse_failure('\':\'')
|
400
|
-
|
397
|
+
r34 = nil
|
398
|
+
end
|
399
|
+
s32 << r34
|
400
|
+
if r34
|
401
|
+
r36 = _nt_sp
|
402
|
+
if r36
|
403
|
+
r35 = r36
|
404
|
+
else
|
405
|
+
r35 = instantiate_node(SyntaxNode,input, index...index)
|
406
|
+
end
|
407
|
+
s32 << r35
|
408
|
+
if r35
|
409
|
+
i38, s38 = index, []
|
410
|
+
r39 = _nt_class_name
|
411
|
+
s38 << r39
|
412
|
+
if r39
|
413
|
+
if (match_len = has_terminal?('::', false, index))
|
414
|
+
r40 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
415
|
+
@index += match_len
|
416
|
+
else
|
417
|
+
terminal_parse_failure('\'::\'')
|
418
|
+
r40 = nil
|
419
|
+
end
|
420
|
+
s38 << r40
|
421
|
+
end
|
422
|
+
if s38.last
|
423
|
+
r38 = instantiate_node(SyntaxNode,input, i38...index, s38)
|
424
|
+
r38.extend(Formula5)
|
425
|
+
else
|
426
|
+
@index = i38
|
427
|
+
r38 = nil
|
428
|
+
end
|
429
|
+
if r38
|
430
|
+
r37 = r38
|
431
|
+
else
|
432
|
+
r37 = instantiate_node(SyntaxNode,input, index...index)
|
433
|
+
end
|
434
|
+
s32 << r37
|
435
|
+
if r37
|
436
|
+
r41 = _nt_class_name
|
437
|
+
s32 << r41
|
438
|
+
end
|
439
|
+
end
|
401
440
|
end
|
402
|
-
s35 << r37
|
403
441
|
end
|
404
|
-
if
|
405
|
-
|
406
|
-
|
442
|
+
if s32.last
|
443
|
+
r32 = instantiate_node(SubNode,input, i32...index, s32)
|
444
|
+
r32.extend(Formula6)
|
407
445
|
else
|
408
|
-
@index =
|
409
|
-
|
446
|
+
@index = i32
|
447
|
+
r32 = nil
|
410
448
|
end
|
411
|
-
if
|
412
|
-
|
413
|
-
r0 =
|
449
|
+
if r32
|
450
|
+
r32 = SyntaxNode.new(input, (index-1)...index) if r32 == true
|
451
|
+
r0 = r32
|
414
452
|
else
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
r40 = _nt_sp
|
426
|
-
s38 << r40
|
427
|
-
if r40
|
428
|
-
r41 = _nt_class_name
|
429
|
-
s38 << r41
|
453
|
+
i42, s42 = index, []
|
454
|
+
r43 = _nt_class_name
|
455
|
+
s42 << r43
|
456
|
+
if r43
|
457
|
+
if (match_len = has_terminal?(':', false, index))
|
458
|
+
r44 = true
|
459
|
+
@index += match_len
|
460
|
+
else
|
461
|
+
terminal_parse_failure('\':\'')
|
462
|
+
r44 = nil
|
430
463
|
end
|
464
|
+
s42 << r44
|
431
465
|
end
|
432
|
-
if
|
433
|
-
|
434
|
-
|
466
|
+
if s42.last
|
467
|
+
r42 = instantiate_node(BaseNode,input, i42...index, s42)
|
468
|
+
r42.extend(Formula7)
|
435
469
|
else
|
436
|
-
@index =
|
437
|
-
|
470
|
+
@index = i42
|
471
|
+
r42 = nil
|
438
472
|
end
|
439
|
-
if
|
440
|
-
|
441
|
-
r0 =
|
473
|
+
if r42
|
474
|
+
r42 = SyntaxNode.new(input, (index-1)...index) if r42 == true
|
475
|
+
r0 = r42
|
442
476
|
else
|
443
|
-
|
444
|
-
|
477
|
+
i45, s45 = index, []
|
478
|
+
if (match_len = has_terminal?('import', false, index))
|
479
|
+
r46 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
480
|
+
@index += match_len
|
481
|
+
else
|
482
|
+
terminal_parse_failure('\'import\'')
|
483
|
+
r46 = nil
|
484
|
+
end
|
485
|
+
s45 << r46
|
486
|
+
if r46
|
487
|
+
r47 = _nt_sp
|
488
|
+
s45 << r47
|
489
|
+
if r47
|
490
|
+
r48 = _nt_class_name_import
|
491
|
+
s45 << r48
|
492
|
+
end
|
493
|
+
end
|
494
|
+
if s45.last
|
495
|
+
r45 = instantiate_node(Import,input, i45...index, s45)
|
496
|
+
r45.extend(Formula8)
|
497
|
+
else
|
498
|
+
@index = i45
|
499
|
+
r45 = nil
|
500
|
+
end
|
501
|
+
if r45
|
502
|
+
r45 = SyntaxNode.new(input, (index-1)...index) if r45 == true
|
503
|
+
r0 = r45
|
504
|
+
else
|
505
|
+
@index = i0
|
506
|
+
r0 = nil
|
507
|
+
end
|
445
508
|
end
|
446
509
|
end
|
447
510
|
end
|
@@ -509,6 +572,241 @@ module Delorean
|
|
509
572
|
r0
|
510
573
|
end
|
511
574
|
|
575
|
+
module ClassNameImport0
|
576
|
+
end
|
577
|
+
|
578
|
+
module ClassNameImport1
|
579
|
+
end
|
580
|
+
|
581
|
+
def _nt_class_name_import
|
582
|
+
start_index = index
|
583
|
+
if node_cache[:class_name_import].has_key?(index)
|
584
|
+
cached = node_cache[:class_name_import][index]
|
585
|
+
if cached
|
586
|
+
node_cache[:class_name_import][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
587
|
+
@index = cached.interval.end
|
588
|
+
end
|
589
|
+
return cached
|
590
|
+
end
|
591
|
+
|
592
|
+
i0, s0 = index, []
|
593
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
594
|
+
r1 = true
|
595
|
+
@index += 1
|
596
|
+
else
|
597
|
+
terminal_parse_failure('[A-Z]')
|
598
|
+
r1 = nil
|
599
|
+
end
|
600
|
+
s0 << r1
|
601
|
+
if r1
|
602
|
+
s2, i2 = [], index
|
603
|
+
loop do
|
604
|
+
if has_terminal?(@regexps[gr = '\A[a-zA-Z0-9_]'] ||= Regexp.new(gr), :regexp, index)
|
605
|
+
r3 = true
|
606
|
+
@index += 1
|
607
|
+
else
|
608
|
+
terminal_parse_failure('[a-zA-Z0-9_]')
|
609
|
+
r3 = nil
|
610
|
+
end
|
611
|
+
if r3
|
612
|
+
s2 << r3
|
613
|
+
else
|
614
|
+
break
|
615
|
+
end
|
616
|
+
end
|
617
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
618
|
+
s0 << r2
|
619
|
+
if r2
|
620
|
+
s4, i4 = [], index
|
621
|
+
loop do
|
622
|
+
i5, s5 = index, []
|
623
|
+
if (match_len = has_terminal?('::', false, index))
|
624
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
625
|
+
@index += match_len
|
626
|
+
else
|
627
|
+
terminal_parse_failure('\'::\'')
|
628
|
+
r6 = nil
|
629
|
+
end
|
630
|
+
s5 << r6
|
631
|
+
if r6
|
632
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
633
|
+
r7 = true
|
634
|
+
@index += 1
|
635
|
+
else
|
636
|
+
terminal_parse_failure('[A-Z]')
|
637
|
+
r7 = nil
|
638
|
+
end
|
639
|
+
s5 << r7
|
640
|
+
if r7
|
641
|
+
s8, i8 = [], index
|
642
|
+
loop do
|
643
|
+
if has_terminal?(@regexps[gr = '\A[a-zA-Z0-9_]'] ||= Regexp.new(gr), :regexp, index)
|
644
|
+
r9 = true
|
645
|
+
@index += 1
|
646
|
+
else
|
647
|
+
terminal_parse_failure('[a-zA-Z0-9_]')
|
648
|
+
r9 = nil
|
649
|
+
end
|
650
|
+
if r9
|
651
|
+
s8 << r9
|
652
|
+
else
|
653
|
+
break
|
654
|
+
end
|
655
|
+
end
|
656
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
657
|
+
s5 << r8
|
658
|
+
end
|
659
|
+
end
|
660
|
+
if s5.last
|
661
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
662
|
+
r5.extend(ClassNameImport0)
|
663
|
+
else
|
664
|
+
@index = i5
|
665
|
+
r5 = nil
|
666
|
+
end
|
667
|
+
if r5
|
668
|
+
s4 << r5
|
669
|
+
else
|
670
|
+
break
|
671
|
+
end
|
672
|
+
end
|
673
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
674
|
+
s0 << r4
|
675
|
+
end
|
676
|
+
end
|
677
|
+
if s0.last
|
678
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
679
|
+
r0.extend(ClassNameImport1)
|
680
|
+
else
|
681
|
+
@index = i0
|
682
|
+
r0 = nil
|
683
|
+
end
|
684
|
+
|
685
|
+
node_cache[:class_name_import][start_index] = r0
|
686
|
+
|
687
|
+
r0
|
688
|
+
end
|
689
|
+
|
690
|
+
module ClassNameImportNested0
|
691
|
+
end
|
692
|
+
|
693
|
+
module ClassNameImportNested1
|
694
|
+
end
|
695
|
+
|
696
|
+
def _nt_class_name_import_nested
|
697
|
+
start_index = index
|
698
|
+
if node_cache[:class_name_import_nested].has_key?(index)
|
699
|
+
cached = node_cache[:class_name_import_nested][index]
|
700
|
+
if cached
|
701
|
+
node_cache[:class_name_import_nested][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
702
|
+
@index = cached.interval.end
|
703
|
+
end
|
704
|
+
return cached
|
705
|
+
end
|
706
|
+
|
707
|
+
i0, s0 = index, []
|
708
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
709
|
+
r1 = true
|
710
|
+
@index += 1
|
711
|
+
else
|
712
|
+
terminal_parse_failure('[A-Z]')
|
713
|
+
r1 = nil
|
714
|
+
end
|
715
|
+
s0 << r1
|
716
|
+
if r1
|
717
|
+
s2, i2 = [], index
|
718
|
+
loop do
|
719
|
+
if has_terminal?(@regexps[gr = '\A[a-zA-Z0-9_]'] ||= Regexp.new(gr), :regexp, index)
|
720
|
+
r3 = true
|
721
|
+
@index += 1
|
722
|
+
else
|
723
|
+
terminal_parse_failure('[a-zA-Z0-9_]')
|
724
|
+
r3 = nil
|
725
|
+
end
|
726
|
+
if r3
|
727
|
+
s2 << r3
|
728
|
+
else
|
729
|
+
break
|
730
|
+
end
|
731
|
+
end
|
732
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
733
|
+
s0 << r2
|
734
|
+
if r2
|
735
|
+
s4, i4 = [], index
|
736
|
+
loop do
|
737
|
+
i5, s5 = index, []
|
738
|
+
if (match_len = has_terminal?('::', false, index))
|
739
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
740
|
+
@index += match_len
|
741
|
+
else
|
742
|
+
terminal_parse_failure('\'::\'')
|
743
|
+
r6 = nil
|
744
|
+
end
|
745
|
+
s5 << r6
|
746
|
+
if r6
|
747
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
748
|
+
r7 = true
|
749
|
+
@index += 1
|
750
|
+
else
|
751
|
+
terminal_parse_failure('[A-Z]')
|
752
|
+
r7 = nil
|
753
|
+
end
|
754
|
+
s5 << r7
|
755
|
+
if r7
|
756
|
+
s8, i8 = [], index
|
757
|
+
loop do
|
758
|
+
if has_terminal?(@regexps[gr = '\A[a-zA-Z0-9_]'] ||= Regexp.new(gr), :regexp, index)
|
759
|
+
r9 = true
|
760
|
+
@index += 1
|
761
|
+
else
|
762
|
+
terminal_parse_failure('[a-zA-Z0-9_]')
|
763
|
+
r9 = nil
|
764
|
+
end
|
765
|
+
if r9
|
766
|
+
s8 << r9
|
767
|
+
else
|
768
|
+
break
|
769
|
+
end
|
770
|
+
end
|
771
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
772
|
+
s5 << r8
|
773
|
+
end
|
774
|
+
end
|
775
|
+
if s5.last
|
776
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
777
|
+
r5.extend(ClassNameImportNested0)
|
778
|
+
else
|
779
|
+
@index = i5
|
780
|
+
r5 = nil
|
781
|
+
end
|
782
|
+
if r5
|
783
|
+
s4 << r5
|
784
|
+
else
|
785
|
+
break
|
786
|
+
end
|
787
|
+
end
|
788
|
+
if s4.size < 2
|
789
|
+
@index = i4
|
790
|
+
r4 = nil
|
791
|
+
else
|
792
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
793
|
+
end
|
794
|
+
s0 << r4
|
795
|
+
end
|
796
|
+
end
|
797
|
+
if s0.last
|
798
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
799
|
+
r0.extend(ClassNameImportNested1)
|
800
|
+
else
|
801
|
+
@index = i0
|
802
|
+
r0 = nil
|
803
|
+
end
|
804
|
+
|
805
|
+
node_cache[:class_name_import_nested][start_index] = r0
|
806
|
+
|
807
|
+
r0
|
808
|
+
end
|
809
|
+
|
512
810
|
module Expression0
|
513
811
|
def args
|
514
812
|
elements[2]
|
@@ -2455,13 +2753,19 @@ module Delorean
|
|
2455
2753
|
end
|
2456
2754
|
|
2457
2755
|
module Value0
|
2756
|
+
def c
|
2757
|
+
elements[0]
|
2758
|
+
end
|
2759
|
+
end
|
2760
|
+
|
2761
|
+
module Value1
|
2458
2762
|
def m
|
2459
2763
|
elements[0]
|
2460
2764
|
end
|
2461
2765
|
|
2462
2766
|
end
|
2463
2767
|
|
2464
|
-
module
|
2768
|
+
module Value2
|
2465
2769
|
def mod
|
2466
2770
|
elements[0]
|
2467
2771
|
end
|
@@ -2471,7 +2775,7 @@ module Delorean
|
|
2471
2775
|
end
|
2472
2776
|
end
|
2473
2777
|
|
2474
|
-
module
|
2778
|
+
module Value3
|
2475
2779
|
def e
|
2476
2780
|
elements[2]
|
2477
2781
|
end
|
@@ -2546,39 +2850,11 @@ module Delorean
|
|
2546
2850
|
r0 = r11
|
2547
2851
|
else
|
2548
2852
|
i12, s12 = index, []
|
2549
|
-
|
2550
|
-
r15 = _nt_class_name
|
2551
|
-
s14 << r15
|
2552
|
-
if r15
|
2553
|
-
if (match_len = has_terminal?('::', false, index))
|
2554
|
-
r16 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2555
|
-
@index += match_len
|
2556
|
-
else
|
2557
|
-
terminal_parse_failure('\'::\'')
|
2558
|
-
r16 = nil
|
2559
|
-
end
|
2560
|
-
s14 << r16
|
2561
|
-
end
|
2562
|
-
if s14.last
|
2563
|
-
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
2564
|
-
r14.extend(Value0)
|
2565
|
-
else
|
2566
|
-
@index = i14
|
2567
|
-
r14 = nil
|
2568
|
-
end
|
2569
|
-
if r14
|
2570
|
-
r13 = r14
|
2571
|
-
else
|
2572
|
-
r13 = instantiate_node(SyntaxNode,input, index...index)
|
2573
|
-
end
|
2853
|
+
r13 = _nt_class_name_import
|
2574
2854
|
s12 << r13
|
2575
|
-
if r13
|
2576
|
-
r17 = _nt_class_name
|
2577
|
-
s12 << r17
|
2578
|
-
end
|
2579
2855
|
if s12.last
|
2580
|
-
r12 = instantiate_node(
|
2581
|
-
r12.extend(
|
2856
|
+
r12 = instantiate_node(NodeAsValueNested,input, i12...index, s12)
|
2857
|
+
r12.extend(Value0)
|
2582
2858
|
else
|
2583
2859
|
@index = i12
|
2584
2860
|
r12 = nil
|
@@ -2587,60 +2863,103 @@ module Delorean
|
|
2587
2863
|
r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
|
2588
2864
|
r0 = r12
|
2589
2865
|
else
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2866
|
+
i14, s14 = index, []
|
2867
|
+
i16, s16 = index, []
|
2868
|
+
r17 = _nt_class_name
|
2869
|
+
s16 << r17
|
2870
|
+
if r17
|
2871
|
+
if (match_len = has_terminal?('::', false, index))
|
2872
|
+
r18 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2873
|
+
@index += match_len
|
2874
|
+
else
|
2875
|
+
terminal_parse_failure('\'::\'')
|
2876
|
+
r18 = nil
|
2877
|
+
end
|
2878
|
+
s16 << r18
|
2879
|
+
end
|
2880
|
+
if s16.last
|
2881
|
+
r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
|
2882
|
+
r16.extend(Value1)
|
2594
2883
|
else
|
2595
|
-
|
2596
|
-
|
2884
|
+
@index = i16
|
2885
|
+
r16 = nil
|
2597
2886
|
end
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2887
|
+
if r16
|
2888
|
+
r15 = r16
|
2889
|
+
else
|
2890
|
+
r15 = instantiate_node(SyntaxNode,input, index...index)
|
2891
|
+
end
|
2892
|
+
s14 << r15
|
2893
|
+
if r15
|
2894
|
+
r19 = _nt_class_name
|
2895
|
+
s14 << r19
|
2896
|
+
end
|
2897
|
+
if s14.last
|
2898
|
+
r14 = instantiate_node(NodeAsValue,input, i14...index, s14)
|
2899
|
+
r14.extend(Value2)
|
2900
|
+
else
|
2901
|
+
@index = i14
|
2902
|
+
r14 = nil
|
2903
|
+
end
|
2904
|
+
if r14
|
2905
|
+
r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
|
2906
|
+
r0 = r14
|
2907
|
+
else
|
2908
|
+
i20, s20 = index, []
|
2909
|
+
if (match_len = has_terminal?('(', false, index))
|
2910
|
+
r21 = true
|
2911
|
+
@index += match_len
|
2603
2912
|
else
|
2604
|
-
|
2913
|
+
terminal_parse_failure('\'(\'')
|
2914
|
+
r21 = nil
|
2605
2915
|
end
|
2606
|
-
|
2607
|
-
if
|
2608
|
-
|
2609
|
-
|
2916
|
+
s20 << r21
|
2917
|
+
if r21
|
2918
|
+
r23 = _nt_sp
|
2919
|
+
if r23
|
2920
|
+
r22 = r23
|
2921
|
+
else
|
2922
|
+
r22 = instantiate_node(SyntaxNode,input, index...index)
|
2923
|
+
end
|
2924
|
+
s20 << r22
|
2610
2925
|
if r22
|
2611
|
-
r24 =
|
2926
|
+
r24 = _nt_expression
|
2927
|
+
s20 << r24
|
2612
2928
|
if r24
|
2613
|
-
|
2614
|
-
|
2615
|
-
|
2616
|
-
end
|
2617
|
-
s18 << r23
|
2618
|
-
if r23
|
2619
|
-
if (match_len = has_terminal?(')', false, index))
|
2620
|
-
r25 = true
|
2621
|
-
@index += match_len
|
2929
|
+
r26 = _nt_sp
|
2930
|
+
if r26
|
2931
|
+
r25 = r26
|
2622
2932
|
else
|
2623
|
-
|
2624
|
-
|
2933
|
+
r25 = instantiate_node(SyntaxNode,input, index...index)
|
2934
|
+
end
|
2935
|
+
s20 << r25
|
2936
|
+
if r25
|
2937
|
+
if (match_len = has_terminal?(')', false, index))
|
2938
|
+
r27 = true
|
2939
|
+
@index += match_len
|
2940
|
+
else
|
2941
|
+
terminal_parse_failure('\')\'')
|
2942
|
+
r27 = nil
|
2943
|
+
end
|
2944
|
+
s20 << r27
|
2625
2945
|
end
|
2626
|
-
s18 << r25
|
2627
2946
|
end
|
2628
2947
|
end
|
2629
2948
|
end
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2949
|
+
if s20.last
|
2950
|
+
r20 = instantiate_node(Expr,input, i20...index, s20)
|
2951
|
+
r20.extend(Value3)
|
2952
|
+
else
|
2953
|
+
@index = i20
|
2954
|
+
r20 = nil
|
2955
|
+
end
|
2956
|
+
if r20
|
2957
|
+
r20 = SyntaxNode.new(input, (index-1)...index) if r20 == true
|
2958
|
+
r0 = r20
|
2959
|
+
else
|
2960
|
+
@index = i0
|
2961
|
+
r0 = nil
|
2962
|
+
end
|
2644
2963
|
end
|
2645
2964
|
end
|
2646
2965
|
end
|