public
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/nathansobo/treetop.git
Expiration is propagated to non-local dependents, but not parents in order 
to avoid much duplicate expiration
Nathan Sobo (author)
Sun Apr 06 17:28:12 -0700 2008
commit  2a0d504674aaa1a2250fbd6cf97ae4a6d231c66f
tree    4abcc8678ac9c933d8cebc011f20b87480604b29
parent  b7cbd6cda710d671947542aa3d0120da8e487575
...
12
13
14
15
 
16
17
18
19
20
 
21
22
23
...
12
13
14
 
15
16
17
18
19
 
20
21
22
23
0
@@ -12,12 +12,12 @@ module Treetop
0
         @memoizations = []
0
       end
0
 
0
- def expire
0
+ def expire(expire_parent=false)
0
         result_cache.schedule_result_deletion(self)
0
         memoizations.each do |memoization|
0
           result_cache.schedule_memoization_expiration(memoization)
0
         end
0
- dependents.each { |dependent| dependent.expire }
0
+ dependents.each { |dependent| dependent.expire(true) }
0
       end
0
       
0
       def relocate(length_change)
...
51
52
53
54
 
 
55
56
 
57
58
59
...
51
52
53
 
54
55
56
 
57
58
59
60
0
@@ -51,9 +51,10 @@ module Treetop
0
         end
0
       end
0
 
0
- def expire
0
+
0
+ def expire(expire_parent=false)
0
         super
0
- parent.expire if parent
0
+ parent.expire(expire_parent) if expire_parent && parent
0
       end
0
 
0
       protected
...
189
190
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
193
194
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
0
@@ -189,6 +189,26 @@ module ResultCacheSpec
0
       end
0
     end
0
 
0
+ describe "with a result with with a grandchild that has a non-local dependency stored in it" do
0
+ attr_reader :parent, :child, :grandchild, :dependency
0
+
0
+ before do
0
+ @grandchild = SyntaxNode.new(input, 3..5)
0
+ @dependency = SyntaxNode.new(input, 5...8)
0
+ grandchild.dependencies.push(dependency)
0
+ @child = SyntaxNode.new(input, 0..5, [SyntaxNode.new(input, 0...3), grandchild])
0
+ @parent = SyntaxNode.new(input, 0..5, [child])
0
+
0
+ cache.store_result(:foo, parent)
0
+ end
0
+
0
+ it "expires the result when the non-local dependency of its grandchild is expired" do
0
+ cache.should have_result(:foo, 0)
0
+ cache.expire(7..7, 1)
0
+ cache.should_not have_result(:foo, 0)
0
+ end
0
+ end
0
+
0
     describe "with a results for the same rule with intervals 1..2 and 2..3" do
0
       attr_reader :result_1, :result_2
0
 

Comments

    No one has commented yet.