skeem 0.0.28 → 0.1.00

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,7 @@
1
1
  # Classes that implement nodes of Abstract Syntax Trees (AST) representing
2
2
  # Skeem parse results.
3
3
 
4
- require_relative 'skm_simple_datum'
5
- require_relative 'skm_compound_datum'
4
+ require_relative 'datum_dsl'
6
5
  require_relative 'skm_unary_expression'
7
6
 
8
7
  module Skeem
@@ -46,6 +45,9 @@ module Skeem
46
45
  super(aPosition)
47
46
  @variable = aVariable
48
47
  @expression = theExpression
48
+ unless expression.kind_of?(SkmElement)
49
+ raise StandardError, "Bad definition"
50
+ end
49
51
  end
50
52
 
51
53
  def evaluate(aRuntime)
@@ -134,7 +136,11 @@ module Skeem
134
136
  else
135
137
  @operator = anOperator
136
138
  end
137
- @operands = SkmList.new(theOperands)
139
+ if theOperands.nil?
140
+ @operands = SkmEmptyList.instance
141
+ else
142
+ @operands = SkmPair.create_from_a(theOperands)
143
+ end
138
144
  @operands_consumed = false
139
145
  end
140
146
 
@@ -313,6 +319,8 @@ module Skeem
313
319
  end # class
314
320
 
315
321
  class SkmLambda < SkmMultiExpression
322
+ include DatumDSL
323
+
316
324
  # @!attribute [r] formals
317
325
  # @return [Array<SkmIdentifier>] the argument names
318
326
  attr_reader :formals
@@ -377,7 +385,7 @@ module Skeem
377
385
  private
378
386
 
379
387
  def bind_locals(aRuntime, aProcedureCall)
380
- actuals = aProcedureCall.operands.members
388
+ actuals = aProcedureCall.operands.to_a
381
389
  count_actuals = actuals.size
382
390
 
383
391
  if (count_actuals < required_arity) ||
@@ -392,12 +400,16 @@ module Skeem
392
400
  if actual.kind_of?(ProcedureCall)
393
401
  actual.evaluate(aRuntime)
394
402
  else
395
- actual
403
+ to_datum(actual)
396
404
  end
397
405
  end
398
406
  variadic_arg_name = formals.formals.last
399
- args_coll = SkmList.new(variadic_part)
407
+ args_coll = SkmPair.create_from_a(variadic_part)
400
408
  a_def = SkmDefinition.new(position, variadic_arg_name, args_coll)
409
+ # $stderr.puts "Tef #{a_def.inspect}"
410
+ # $stderr.puts "Tef #{actuals.inspect}"
411
+ # $stderr.puts "Tef #{variadic_part.inspect}"
412
+ # $stderr.puts "Tef #{aProcedureCall.inspect}"
401
413
  a_def.evaluate(aRuntime)
402
414
  end
403
415
  aProcedureCall.operands_consumed = true
@@ -423,7 +435,14 @@ module Skeem
423
435
  caller_index -= 1
424
436
  end
425
437
  else
426
- result = cmd.evaluate(aRuntime)
438
+ begin
439
+ result = cmd.evaluate(aRuntime)
440
+ rescue NoMethodError => exc
441
+ $stderr.puts self.inspect
442
+ $stderr.puts sequence.inspect
443
+ $stderr.puts cmd.inspect
444
+ raise exc
445
+ end
427
446
  end
428
447
  end
429
448
  end
@@ -434,14 +453,22 @@ module Skeem
434
453
  # Purpose: bind each formal from lambda to an actual value from the call
435
454
  def bind_required_locals(aRuntime, aProcedureCall)
436
455
  max_index = required_arity - 1
437
- actuals = aProcedureCall.operands.members
456
+ case aProcedureCall.operands
457
+ when SkmPair
458
+ actuals = aProcedureCall.operands.to_a
459
+ when SkmEmptyList
460
+ actuals = []
461
+ else
462
+ raise StandardError, "Unsupported type of operand list #{aProcedureCall.operands.inspect}"
463
+ actuals = aProcedureCall.operands.members
464
+ end
438
465
  formal_names = formals.formals.map(&:value)
439
466
 
440
467
  formals.formals.each_with_index do |arg_name, index|
441
468
  arg = actuals[index]
442
469
  if arg.nil?
443
470
  if actuals.empty? && formals.variadic?
444
- arg = SkmList.new([])
471
+ arg = SkmPair.create_from_a([])
445
472
  else
446
473
  raise StandardError, "Unbound variable: '#{arg_name.value}'"
447
474
  end
@@ -449,6 +476,9 @@ module Skeem
449
476
 
450
477
  # IMPORTANT: execute procedure call in argument list now
451
478
  arg = arg.evaluate(aRuntime) if arg.kind_of?(ProcedureCall)
479
+ unless arg.kind_of?(SkmElement)
480
+ arg = to_datum(arg)
481
+ end
452
482
  a_def = SkmDefinition.new(position, arg_name, arg)
453
483
  # $stderr.puts "Procedure call #{aProcedureCall.operator.inspect}"
454
484
  # $stderr.puts "LOCAL #{arg_name.value} #{arg.inspect}"
@@ -26,7 +26,7 @@ module Skeem
26
26
  members == other
27
27
  end
28
28
  end
29
-
29
+
30
30
  alias eqv? equal?
31
31
 
32
32
  def evaluate(aRuntime)
@@ -58,6 +58,7 @@ module Skeem
58
58
  end
59
59
  end # class
60
60
 
61
+ # @deprecated Use {#SkmPair} class instead.
61
62
  class SkmList < SkmCompoundDatum
62
63
  def tail()
63
64
  SkmList.new(members.slice(1..-1))
@@ -70,7 +71,7 @@ module Skeem
70
71
  def null?
71
72
  empty?
72
73
  end
73
-
74
+
74
75
  def evaluate(aRuntime)
75
76
  if empty?
76
77
  self.class.new(nil)
@@ -36,6 +36,10 @@ module Skeem
36
36
  def null?
37
37
  false
38
38
  end
39
+
40
+ def pair?
41
+ false
42
+ end
39
43
 
40
44
  def vector?
41
45
  false
@@ -0,0 +1,60 @@
1
+ require 'singleton'
2
+ require_relative 'skm_element'
3
+
4
+ module Skeem
5
+ # From R7RS: The empty list is a special object of its own type.
6
+ # It is not a pair, it has no elements, and its length is zero.
7
+ class SkmEmptyList < SkmElement
8
+ include Singleton
9
+
10
+ def list?
11
+ true
12
+ end
13
+
14
+ def null?
15
+ true
16
+ end
17
+
18
+ def pair?
19
+ false
20
+ end
21
+
22
+ def length
23
+ 0
24
+ end
25
+
26
+ def to_a
27
+ []
28
+ end
29
+
30
+ def empty?
31
+ true
32
+ end
33
+
34
+ def evaluate(_runtime)
35
+ self
36
+ end
37
+
38
+ def quasiquote(_runtime)
39
+ self
40
+ end
41
+
42
+ # Part of the 'visitee' role in Visitor design pattern.
43
+ # @param _visitor [SkmElementVisitor] the visitor
44
+ def accept(aVisitor)
45
+ aVisitor.visit_empty_list(self)
46
+ end
47
+
48
+ protected
49
+
50
+ def inspect_specific
51
+ '()'
52
+ end
53
+
54
+ private
55
+
56
+ def initialize()
57
+ super(0)
58
+ end
59
+ end # class
60
+ end # module
@@ -0,0 +1,126 @@
1
+ require_relative 'skm_empty_list'
2
+
3
+ module Skeem
4
+ class SkmPair < SkmElement
5
+ attr_accessor :car
6
+ attr_accessor :cdr
7
+
8
+ alias first car
9
+ alias members to_a
10
+
11
+ def initialize(head, tail)
12
+ super(0)
13
+ @car = head
14
+ @cdr = tail
15
+ end
16
+
17
+ def self.create_from_a(anArray)
18
+ current = nil
19
+ return SkmEmptyList.instance if anArray.empty?
20
+ anArray.reverse_each do |elem|
21
+ if current.nil?
22
+ current = self.new(elem, SkmEmptyList.instance)
23
+ else
24
+ current = self.new(elem, current)
25
+ end
26
+ end
27
+
28
+ current
29
+ end
30
+
31
+ def empty?
32
+ return false if car
33
+ if [SkmPair, SkmEmptyList].include? cdr.class
34
+ cdr.empty?
35
+ else
36
+ false
37
+ end
38
+ end
39
+
40
+ def list?
41
+ if cdr.nil?
42
+ false
43
+ else
44
+ cdr.list?
45
+ end
46
+ end
47
+
48
+ def pair?
49
+ true
50
+ end
51
+
52
+ def length
53
+ if [SkmPair, SkmEmptyList].include?(cdr.class)
54
+ cdr.length + 1
55
+ else
56
+ raise StandardError, 'Improper list'
57
+ end
58
+ end
59
+
60
+ def to_a
61
+ result = [car]
62
+ if cdr && !cdr.null?
63
+ result.concat(cdr.to_a)
64
+ end
65
+
66
+ result
67
+ end
68
+
69
+ def last
70
+ self.to_a.last
71
+ end
72
+
73
+ def each(&aBlock)
74
+ aBlock.call(car)
75
+ cdr.each(&aBlock) if cdr && !cdr.null?
76
+ end
77
+
78
+ def append(anElement)
79
+ if cdr.nil? || cdr.kind_of?(SkmEmptyList)
80
+ self.cdr = SkmPair.new(anElement, SkmEmptyList.instance)
81
+ elsif cdr.kind_of?(SkmPair)
82
+ self.cdr.append(anElement)
83
+ else
84
+ raise StandardError, "Cannot append #{anElement.inspect}"
85
+ end
86
+ end
87
+
88
+ def evaluate(aRuntime)
89
+ return SkmEmptyList.instance if empty?
90
+ if car.kind_of?(SkmIdentifier)
91
+ result = aRuntime.evaluate_form(self)
92
+ else
93
+ members_eval = self.to_a.map { |elem| elem.evaluate(aRuntime) }
94
+ result = self.class.create_from_a(members_eval)
95
+ end
96
+ result
97
+ end
98
+
99
+ def quasiquote(aRuntime)
100
+ members_eval = self.to_a.map { |elem| elem.quasiquote(aRuntime) }
101
+ self.class.create_from_a(members_eval)
102
+ end
103
+
104
+ # Part of the 'visitee' role in Visitor design pattern.
105
+ # @param _visitor [SkmElementVisitor] the visitor
106
+ def accept(aVisitor)
107
+ aVisitor.visit_pair(self)
108
+ end
109
+
110
+ def done!()
111
+ # Do nothing
112
+ end
113
+
114
+ protected
115
+
116
+ def inspect_specific
117
+ result = car.inspect
118
+ if cdr && !cdr.null?
119
+ result << ', ' << cdr.send(:inspect_specific)
120
+ end
121
+
122
+ result
123
+ end
124
+
125
+ end # class
126
+ end # module
@@ -81,8 +81,7 @@ module Skeem
81
81
  value.to_s
82
82
  end
83
83
  end # class
84
-
85
-
84
+
86
85
  class SkmBoolean < SkmSimpleDatum
87
86
  def boolean?
88
87
  true
@@ -72,6 +72,30 @@
72
72
  ; Allocates and returns a new list from its arguments
73
73
  (define list
74
74
  (lambda args args))
75
+
76
+ ; (define caar
77
+ ; (lambda (x)
78
+ ; (car (car x))))
75
79
 
80
+ ; (define cadr
81
+ ; (lambda (x)
82
+ ; (car (cdr x))))
76
83
 
84
+ ;(define cdar
85
+ ; (lambda(x)
86
+ ; (cdr (car x))))
87
+
88
+ ;(define cddr
89
+ ; (lambda (x)
90
+ ; (cdr (cdr x))))
91
+
92
+ ;; (list-ref list n)
93
+ ;; Return the nth (sero-based) element of list
94
+ ;; n must be a nonnegative integer
95
+ ;(define list-ref
96
+ ; (lambda (ls n)
97
+ ; (if (= n 0)
98
+ ; (car ls)
99
+ ; (list-ref (cdr ls) (- n 1)))))
100
+
77
101
  (define symbol=? string=?)
data/lib/skeem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skeem
2
- VERSION = '0.0.28'.freeze
2
+ VERSION = '0.1.00'.freeze
3
3
  end
@@ -24,7 +24,7 @@ module Skeem
24
24
  ['false', false]
25
25
  ]
26
26
  end
27
-
27
+
28
28
  let(:integer_tests) do
29
29
  [
30
30
  [0, 0],
@@ -33,10 +33,10 @@ module Skeem
33
33
  ['0', 0],
34
34
  ['-123', -123],
35
35
  ['+456', 456]
36
- ]
36
+ ]
37
37
  end
38
38
 
39
- let(:real_tests) do
39
+ let(:real_tests) do
40
40
  [
41
41
  [0, 0],
42
42
  [-123.4, -123.4],
@@ -48,18 +48,18 @@ module Skeem
48
48
  ['-1.234e+3', -1234]
49
49
  ]
50
50
  end
51
-
52
- let(:string_tests) do
51
+
52
+ let(:string_tests) do
53
53
  [
54
54
  ['hello', 'hello']
55
- ]
55
+ ]
56
56
  end
57
-
58
- let(:identifier_tests) do
57
+
58
+ let(:identifier_tests) do
59
59
  [
60
60
  ['define', 'define'],
61
61
  [SkmString.create('positive?'), 'positive?']
62
- ]
62
+ ]
63
63
  end
64
64
 
65
65
  let(:simple_datum_tests) do
@@ -102,38 +102,38 @@ module Skeem
102
102
  end
103
103
  end
104
104
  end # context
105
-
106
-
105
+
106
+
107
107
  context 'Compound datums:' do
108
- it 'should convert empty array into one-member list' do
108
+ it 'should convert empty array into one-member list' do
109
109
  result = subject.list([])
110
- expect(result).to be_kind_of(SkmList)
111
- expect(result).to be_null
110
+ expect(result).to be_kind_of(SkmEmptyList)
111
+ expect(result).to be_null
112
112
  end
113
-
113
+
114
114
  it 'should convert array of simple datums into list' do
115
115
  literals = simple_datum_tests.map { |(datum, _predicted)| datum }
116
116
  predictions = simple_datum_tests.map { |(_datum, predicted)| predicted }
117
117
  list_result = subject.list(literals)
118
- expect(list_result).to be_kind_of(SkmList)
119
- list_result.members.each_with_index do |member, index|
118
+ expect(list_result).to be_kind_of(SkmPair)
119
+ list_result.to_a.each_with_index do |member, index|
120
120
  expect(member).to eq(predictions[index])
121
121
  end
122
122
  end
123
-
124
- it 'should convert a single datum into one-member list' do
123
+
124
+ it 'should convert a single datum into one-member list' do
125
125
  result = subject.list('123')
126
- expect(result).to be_kind_of(SkmList)
127
- expect(result.members.first).to eq(123)
128
- end
129
-
130
- it 'should convert empty array into one-member list' do
126
+ expect(result).to be_kind_of(SkmPair)
127
+ expect(result.car).to eq(123)
128
+ end
129
+
130
+ it 'should convert empty array into one-member list' do
131
131
  result = subject.vector([])
132
132
  expect(result).to be_kind_of(SkmVector)
133
- expect(result.members).to be_empty
133
+ expect(result.members).to be_empty
134
134
  end
135
-
136
-
135
+
136
+
137
137
  it 'should convert array of simple datums into vector' do
138
138
  literals = simple_datum_tests.map { |(datum, _predicted)| datum }
139
139
  predictions = simple_datum_tests.map { |(_datum, predicted)| predicted }
@@ -144,11 +144,11 @@ module Skeem
144
144
  end
145
145
  end
146
146
 
147
- it 'should convert a single datum into one-member vector' do
147
+ it 'should convert a single datum into one-member vector' do
148
148
  result = subject.vector('123')
149
149
  expect(result).to be_kind_of(SkmVector)
150
150
  expect(result.members.first).to eq(123)
151
- end
151
+ end
152
152
  end # context
153
153
 
154
154
  context 'Arbitrary datums:' do
@@ -157,7 +157,7 @@ module Skeem
157
157
  expect(subject.to_datum(literal)).to eq(predicted)
158
158
  end
159
159
  end
160
-
160
+
161
161
  it 'should recognize & convert integer literals' do
162
162
  integer_tests.each do |(literal, predicted)|
163
163
  expect(subject.to_datum(literal)).to eq(predicted)
@@ -178,14 +178,26 @@ module Skeem
178
178
 
179
179
  it 'should convert nested compound datums' do
180
180
  literals = [
181
- 'false', '123', '-1.41',
181
+ 'false', '123', '-1.41',
182
182
  'foo', SkmVector.new(['uno', '2', 3.0]), 'bar'
183
183
  ]
184
184
  result = subject.list(literals)
185
- expect(result).to be_kind_of(SkmList)
186
- expect(result).to eq([false, 123, -1.41, 'foo', ['uno', 2, 3], 'bar'])
185
+ expect(result).to be_kind_of(SkmPair)
186
+ expect(result.to_a).to eq([false, 123, -1.41, 'foo', ['uno', 2, 3], 'bar'])
187
187
  end
188
188
  end
189
189
 
190
+ it 'should duplicate a given list' do
191
+ f = subject.identifier('f')
192
+ g = subject.identifier('g')
193
+ one_list = subject.list([f, g])
194
+ expect(one_list).to be_list
195
+ expect(one_list.to_a).to eq([f, g])
196
+ duplicate = subject.to_datum(one_list)
197
+ expect(duplicate).to be_list
198
+ # $stderr.puts duplicate.inspect
199
+ expect(duplicate.to_a).to eq([f, g])
200
+ end
201
+
190
202
  end # describe
191
203
  end # module
@@ -75,16 +75,32 @@ module Skeem
75
75
  ls = list ['#false', 3, 'foo']
76
76
  instance = SkmElementVisitor.new(ls)
77
77
  instance.subscribe(listener)
78
- expect(listener).to receive(:before_compound_datum).with(runtime, ls).ordered
79
- expect(listener).to receive(:before_children).with(runtime, ls, ls.members).ordered
80
- expect(listener).to receive(:before_simple_datum).with(runtime, ls.members[0]).ordered
81
- expect(listener).to receive(:after_simple_datum).with(runtime, ls.members[0]).ordered
82
- expect(listener).to receive(:before_simple_datum).with(runtime, ls.members[1]).ordered
83
- expect(listener).to receive(:after_simple_datum).with(runtime, ls.members[1]).ordered
84
- expect(listener).to receive(:before_simple_datum).with(runtime, ls.members[2]).ordered
85
- expect(listener).to receive(:after_simple_datum).with(runtime, ls.members[2]).ordered
86
- expect(listener).to receive(:after_children).with(runtime, ls, ls.members).ordered
87
- expect(listener).to receive(:after_compound_datum).with(runtime, ls).ordered
78
+ expect(listener).to receive(:before_pair).with(runtime, ls).ordered
79
+ expect(listener).to receive(:before_car).with(runtime, ls, ls.car).ordered
80
+ expect(listener).to receive(:before_simple_datum).with(runtime, ls.car).ordered
81
+ expect(listener).to receive(:after_simple_datum).with(runtime, ls.car).ordered
82
+ expect(listener).to receive(:after_car).with(runtime, ls, ls.car).ordered
83
+ expect(listener).to receive(:before_cdr).with(runtime, ls, ls.cdr).ordered
84
+ expect(listener).to receive(:before_pair).with(runtime, ls.cdr).ordered
85
+ expect(listener).to receive(:before_car).with(runtime, ls.cdr, ls.cdr.car).ordered
86
+ expect(listener).to receive(:before_simple_datum).with(runtime, ls.cdr.car).ordered
87
+ expect(listener).to receive(:after_simple_datum).with(runtime, ls.cdr.car).ordered
88
+ expect(listener).to receive(:after_car).with(runtime, ls.cdr, ls.cdr.car).ordered
89
+ expect(listener).to receive(:before_cdr).with(runtime, ls.cdr, ls.cdr.cdr).ordered
90
+ expect(listener).to receive(:before_pair).with(runtime, ls.cdr.cdr).ordered
91
+ expect(listener).to receive(:before_car).with(runtime, ls.cdr.cdr, ls.cdr.cdr.car).ordered
92
+ expect(listener).to receive(:before_simple_datum).with(runtime, ls.cdr.cdr.car).ordered
93
+ expect(listener).to receive(:after_simple_datum).with(runtime, ls.cdr.cdr.car).ordered
94
+ expect(listener).to receive(:after_car).with(runtime, ls.cdr.cdr, ls.cdr.cdr.car).ordered
95
+ expect(listener).to receive(:before_cdr).with(runtime, ls.cdr.cdr, ls.cdr.cdr.cdr).ordered
96
+ expect(listener).to receive(:before_empty_list).with(runtime, ls.cdr.cdr.cdr).ordered
97
+ expect(listener).to receive(:after_empty_list).with(runtime, ls.cdr.cdr.cdr).ordered
98
+ expect(listener).to receive(:after_cdr).with(runtime, ls.cdr.cdr, ls.cdr.cdr.cdr).ordered
99
+ expect(listener).to receive(:after_pair).with(runtime, ls.cdr.cdr).ordered
100
+ expect(listener).to receive(:after_cdr).with(runtime, ls.cdr, ls.cdr.cdr).ordered
101
+ expect(listener).to receive(:after_pair).with(runtime, ls.cdr).ordered
102
+ expect(listener).to receive(:after_cdr).with(runtime, ls, ls.cdr).ordered
103
+ expect(listener).to receive(:after_pair).with(runtime, ls).ordered
88
104
  instance.start(runtime)
89
105
  end
90
106
 
@@ -116,55 +132,40 @@ module Skeem
116
132
  expect(listener).to receive(:after_simple_datum).with(runtime, vec.members[0]).ordered
117
133
  expect(listener).to receive(:before_simple_datum).with(runtime, vec.members[1]).ordered
118
134
  expect(listener).to receive(:after_simple_datum).with(runtime, vec.members[1]).ordered
119
- expect(listener).to receive(:before_compound_datum).with(runtime, vec.members[2]).ordered
120
- expect(listener).to receive(:before_children).with(runtime, nested_list, nested_list.members).ordered
121
- expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.members[0]).ordered
122
- expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.members[0]).ordered
123
- expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.members[1]).ordered
124
- expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.members[1]).ordered
125
- expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.members[2]).ordered
126
- expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.members[2]).ordered
127
- expect(listener).to receive(:after_children).with(runtime, nested_list, nested_list.members).ordered
128
- expect(listener).to receive(:after_compound_datum).with(runtime, nested_list).ordered
135
+
136
+ expect(listener).to receive(:before_pair).with(runtime, nested_list).ordered
137
+ expect(listener).to receive(:before_car).with(runtime, nested_list, nested_list.car).ordered
138
+ expect(nested_list.car).to eq('uno')
139
+ expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.car).ordered
140
+ expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.car).ordered
141
+ expect(listener).to receive(:after_car).with(runtime, nested_list, nested_list.car).ordered
142
+ expect(listener).to receive(:before_cdr).with(runtime, nested_list, nested_list.cdr).ordered
143
+ expect(listener).to receive(:before_pair).with(runtime, nested_list.cdr).ordered
144
+ expect(listener).to receive(:before_car).with(runtime, nested_list.cdr, nested_list.cdr.car).ordered
145
+ expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.cdr.car).ordered
146
+ expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.cdr.car).ordered
147
+ expect(listener).to receive(:after_car).with(runtime, nested_list.cdr, nested_list.cdr.car).ordered
148
+ expect(listener).to receive(:before_cdr).with(runtime, nested_list.cdr, nested_list.cdr.cdr).ordered
149
+ expect(listener).to receive(:before_pair).with(runtime, nested_list.cdr.cdr).ordered
150
+ expect(listener).to receive(:before_car).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.car).ordered
151
+ expect(listener).to receive(:before_simple_datum).with(runtime, nested_list.cdr.cdr.car).ordered
152
+ expect(listener).to receive(:after_simple_datum).with(runtime, nested_list.cdr.cdr.car).ordered
153
+ expect(listener).to receive(:after_car).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.car).ordered
154
+ expect(listener).to receive(:before_cdr).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.cdr).ordered
155
+ expect(listener).to receive(:before_empty_list).with(runtime, nested_list.cdr.cdr.cdr).ordered
156
+ expect(listener).to receive(:after_empty_list).with(runtime, nested_list.cdr.cdr.cdr).ordered
157
+ expect(listener).to receive(:after_cdr).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.cdr).ordered
158
+ expect(listener).to receive(:after_pair).with(runtime, nested_list.cdr.cdr).ordered
159
+ expect(listener).to receive(:after_cdr).with(runtime, nested_list.cdr, nested_list.cdr.cdr).ordered
160
+ expect(listener).to receive(:after_pair).with(runtime, nested_list.cdr).ordered
161
+ expect(listener).to receive(:after_cdr).with(runtime, nested_list, nested_list.cdr).ordered
162
+ expect(listener).to receive(:after_pair).with(runtime, nested_list).ordered
129
163
  expect(listener).to receive(:before_simple_datum).with(runtime, vec.members[3]).ordered
130
164
  expect(listener).to receive(:after_simple_datum).with(runtime, vec.members[3]).ordered
131
165
  expect(listener).to receive(:after_children).with(runtime, vec, vec.members).ordered
132
166
  expect(listener).to receive(:after_compound_datum).with(runtime, vec).ordered
133
167
  instance.start(runtime)
134
168
  end
135
-
136
- # it 'should allow the visit of list datum object' do
137
- # subject.subscribe(listener)
138
- # expect(listener).to receive(:before_compound_datum).with(runtime, simple_datum)
139
- # expect(listener).to receive(:after_compound_datum).with(runtime, simple_datum)
140
- # subject.start(runtime)
141
- # expect(subject.runtime).to eq(runtime)
142
- # end
143
169
  end # context
144
-
145
- =begin
146
- it 'should react to the start_visit_nonterminal message' do
147
- # Notify subscribers when start the visit of a non-terminal node
148
- expect(listener1).to receive(:before_non_terminal).with(nterm_node)
149
- subject.visit_nonterminal(nterm_node)
150
- end
151
-
152
- it 'should react to the visit_children message' do
153
- # Notify subscribers when start the visit of children nodes
154
- children = nterm_node.subnodes
155
- args = [nterm_node, children]
156
- expect(listener1).to receive(:before_subnodes).with(*args)
157
- expect(listener1).to receive(:before_terminal).with(children[0])
158
- expect(listener1).to receive(:after_terminal).with(children[0])
159
- expect(listener1).to receive(:after_subnodes).with(nterm_node, children)
160
- subject.send(:traverse_subnodes, nterm_node)
161
- end
162
-
163
- it 'should react to the end_visit_nonterminal message' do
164
- # Notify subscribers when ending the visit of a non-terminal node
165
- expect(listener1).to receive(:after_non_terminal).with(nterm_node)
166
- subject.end_visit_nonterminal(nterm_node)
167
- end
168
- =end
169
170
  end # describe
170
171
  end # module