ridl 2.8.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +9 -3
- data/lib/ridl/backend.rb +11 -12
- data/lib/ridl/delegate.rb +89 -59
- data/lib/ridl/expression.rb +65 -27
- data/lib/ridl/genfile.rb +22 -16
- data/lib/ridl/node.rb +328 -189
- data/lib/ridl/options.rb +9 -11
- data/lib/ridl/optparse_ext.rb +32 -34
- data/lib/ridl/parser.rb +456 -236
- data/lib/ridl/runner.rb +33 -26
- data/lib/ridl/scanner.rb +171 -141
- data/lib/ridl/type.rb +113 -13
- data/lib/ridl/version.rb +2 -4
- metadata +4 -4
data/lib/ridl/runner.rb
CHANGED
@@ -18,23 +18,21 @@ require 'ridl/options'
|
|
18
18
|
# -----------------------------------------------------------------------
|
19
19
|
|
20
20
|
module IDL
|
21
|
-
|
22
21
|
OPTIONS = Options.new({
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
22
|
+
outputdir: nil,
|
23
|
+
includepaths: [],
|
24
|
+
xincludepaths: [],
|
25
|
+
verbose: (ENV['RIDL_VERBOSE'] || 0).to_i,
|
26
|
+
debug: false,
|
27
|
+
namespace: nil,
|
28
|
+
search_incpath: false,
|
29
|
+
backend: nil,
|
30
|
+
macros: {
|
32
31
|
}
|
33
32
|
})
|
34
33
|
CORE_OPTIONS = OPTIONS.keys
|
35
34
|
|
36
35
|
class Engine
|
37
|
-
|
38
36
|
class ProductionStack
|
39
37
|
def initialize
|
40
38
|
@stack = []
|
@@ -56,6 +54,7 @@ module IDL
|
|
56
54
|
|
57
55
|
def pop
|
58
56
|
return nil if empty?
|
57
|
+
|
59
58
|
id, prod = @stack.shift
|
60
59
|
@index.delete(id)
|
61
60
|
prod
|
@@ -63,12 +62,14 @@ module IDL
|
|
63
62
|
|
64
63
|
def peek
|
65
64
|
return nil if empty?
|
65
|
+
|
66
66
|
id, _ = @stack.first
|
67
67
|
id
|
68
68
|
end
|
69
69
|
|
70
70
|
def remove(id)
|
71
71
|
return nil unless has?(id)
|
72
|
+
|
72
73
|
i = @index.delete(id.to_sym)
|
73
74
|
_, producer = @productionstack.delete(i)
|
74
75
|
producer
|
@@ -129,6 +130,7 @@ module IDL
|
|
129
130
|
|
130
131
|
def push_production(id, producer)
|
131
132
|
raise "Producer #{id} already queued" if @productionstack.has?(id)
|
133
|
+
|
132
134
|
@productionstack.push(id, producer)
|
133
135
|
end
|
134
136
|
|
@@ -183,9 +185,9 @@ module IDL
|
|
183
185
|
# parse arguments
|
184
186
|
begin
|
185
187
|
@optparser.parse!(argv)
|
186
|
-
rescue ArgumentError =>
|
187
|
-
IDL.error(
|
188
|
-
IDL.error(
|
188
|
+
rescue ArgumentError => e
|
189
|
+
IDL.error(e.inspect)
|
190
|
+
IDL.error(e.backtrace.join("\n")) if IDL.verbose_level.positive?
|
189
191
|
return false
|
190
192
|
end
|
191
193
|
|
@@ -231,7 +233,7 @@ module IDL
|
|
231
233
|
# process parse result -> code generation
|
232
234
|
IDL.log(2, 'RIDL - processing input')
|
233
235
|
|
234
|
-
GenFile.transaction
|
236
|
+
GenFile.transaction do
|
235
237
|
begin
|
236
238
|
|
237
239
|
backend.process_input(_parser, _opts)
|
@@ -250,9 +252,9 @@ module IDL
|
|
250
252
|
rescue Backend::ProcessStop
|
251
253
|
IDL.log(2, "RIDL - processing #{IO === _idlfile ? 'from STDIN' : (StringIO === _idlfile ? 'from string' : _idlfile)} stopped with \"#{$!.message}\"")
|
252
254
|
|
253
|
-
rescue =>
|
254
|
-
IDL.error(
|
255
|
-
IDL.error(
|
255
|
+
rescue => e
|
256
|
+
IDL.error(e)
|
257
|
+
IDL.error(e.backtrace.join("\n")) unless e.is_a? IDL::ParseError
|
256
258
|
return false
|
257
259
|
end
|
258
260
|
end
|
@@ -272,9 +274,9 @@ module IDL
|
|
272
274
|
|
273
275
|
begin
|
274
276
|
_parser.parse(io)
|
275
|
-
rescue =>
|
276
|
-
IDL.error(
|
277
|
-
IDL.error(
|
277
|
+
rescue => e
|
278
|
+
IDL.error(e.inspect)
|
279
|
+
IDL.error(e.backtrace.join("\n")) unless e.is_a? IDL::ParseError
|
278
280
|
return nil
|
279
281
|
ensure
|
280
282
|
io.close unless String === io || io == $stdin
|
@@ -328,7 +330,7 @@ module IDL
|
|
328
330
|
|
329
331
|
def init_optparser
|
330
332
|
script_name = File.basename($0, '.*')
|
331
|
-
|
333
|
+
unless script_name =~ /ridlc/
|
332
334
|
script_name = 'ruby ' + $0
|
333
335
|
end
|
334
336
|
|
@@ -398,11 +400,12 @@ module IDL
|
|
398
400
|
opts.separator ""
|
399
401
|
|
400
402
|
opts.on('-h', '--help',
|
401
|
-
'Show this help message.') { puts opts
|
403
|
+
'Show this help message.') { puts opts
|
404
|
+
puts
|
405
|
+
exit }
|
402
406
|
|
403
407
|
opts
|
404
408
|
end
|
405
|
-
|
406
409
|
end
|
407
410
|
|
408
411
|
def IDL.engine?
|
@@ -419,11 +422,13 @@ module IDL
|
|
419
422
|
|
420
423
|
def IDL.pop_input
|
421
424
|
return nil unless engine?
|
425
|
+
|
422
426
|
Thread.current[:ridl_engine].pop_input
|
423
427
|
end
|
424
428
|
|
425
429
|
def IDL.peek_input
|
426
430
|
return nil unless engine?
|
431
|
+
|
427
432
|
Thread.current[:ridl_engine].peek_input
|
428
433
|
end
|
429
434
|
|
@@ -437,11 +442,13 @@ module IDL
|
|
437
442
|
|
438
443
|
def IDL.pop_production
|
439
444
|
return nil unless engine?
|
445
|
+
|
440
446
|
Thread.current[:ridl_engine].pop_production
|
441
447
|
end
|
442
448
|
|
443
449
|
def IDL.remove_production(id)
|
444
450
|
return nil unless engine?
|
451
|
+
|
445
452
|
Thread.current[:ridl_engine].remove_production(id)
|
446
453
|
end
|
447
454
|
|
@@ -455,6 +462,7 @@ module IDL
|
|
455
462
|
|
456
463
|
def IDL.production(id)
|
457
464
|
return nil unless engine?
|
465
|
+
|
458
466
|
Thread.current[:ridl_engine].production(id)
|
459
467
|
end
|
460
468
|
|
@@ -503,7 +511,7 @@ module IDL
|
|
503
511
|
# add optional search paths for RIDL backends
|
504
512
|
options[:be_path] ||= []
|
505
513
|
options[:be_path].unshift(*ENV['RIDL_BE_PATH'].split(/#{File::PATH_SEPARATOR}/)) if ENV['RIDL_BE_PATH']
|
506
|
-
options[:be_path].collect! {|p| p.gsub('\\', '/') } # cleanup to prevent mixed path separators
|
514
|
+
options[:be_path].collect! { |p| p.gsub('\\', '/') } # cleanup to prevent mixed path separators
|
507
515
|
$:.concat(options[:be_path]) unless options[:be_path].empty?
|
508
516
|
|
509
517
|
# check for special bootstrapping switches
|
@@ -527,5 +535,4 @@ module IDL
|
|
527
535
|
exit(1) unless Thread.current[:ridl_engine].run(argv)
|
528
536
|
end
|
529
537
|
end # IDL.run
|
530
|
-
|
531
538
|
end
|