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
Renamed rest of calls to node_cache in specs to result_cache
Nathan Sobo (author)
Fri Apr 04 14:22:40 -0700 2008
commit  ecab80683f42ae4a4a64f9a4acadf1adc54b216c
tree    01192280375335bf6e167775f26868e859309621
parent  03ec89fc09c2c74d517c5e5066e94e72de750212
...
68
69
70
71
 
72
73
74
 
75
76
77
...
94
95
96
97
 
98
99
100
 
101
102
 
103
104
105
...
125
126
127
128
 
129
130
131
 
132
133
 
134
135
136
...
151
152
153
154
 
155
156
157
158
159
 
160
161
162
...
68
69
70
 
71
72
73
 
74
75
76
77
...
94
95
96
 
97
98
99
 
100
101
 
102
103
104
105
...
125
126
127
 
128
129
130
 
131
132
 
133
134
135
136
...
151
152
153
 
154
155
156
157
158
 
159
160
161
162
0
@@ -68,10 +68,10 @@ module AndPredicateSpec
0
       end
0
 
0
       it "is expired when a character is inserted between 'foo' and 'bar'" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
         input.replace('fooxbar')
0
         expire(3..3, 1)
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
       end
0
     end
0
 
0
@@ -94,12 +94,12 @@ module AndPredicateSpec
0
       end
0
 
0
       it "will subsequently expire the result if input is inserted at index 3" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
         input.replace('foobarlish')
0
- node_cache.expire(3..3, 3)
0
+ result_cache.expire(3..3, 3)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
         parser.consume_all_input = false
0
         reparse.should_not be_nil
0
       end
0
@@ -125,12 +125,12 @@ module AndPredicateSpec
0
       end
0
 
0
       it "will subsequently expire the result if input is inserted at index 3" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
         input.replace('foobar')
0
- node_cache.expire(3..3, 3)
0
+ result_cache.expire(3..3, 3)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
       end
0
     end
0
   end
0
@@ -151,12 +151,12 @@ module AndPredicateSpec
0
       end
0
 
0
       it "expires the failure when a character is subsequently inserted between the character and the space" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
         input.replace('ab ')
0
         parser.expire(1..1, 1)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
         reparse.should_not be_nil
0
       end
0
     end
...
175
176
177
178
 
179
180
181
182
183
184
 
 
185
186
187
...
175
176
177
 
178
179
180
181
182
 
 
183
184
185
186
187
0
@@ -175,13 +175,13 @@ module ChoiceSpec
0
       end
0
 
0
       it "is expired if a character is inserted, and not relocated" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
         input.replace('aa ')
0
         expire(0..0, 2)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
- node_cache.should_not have_result(:expression_under_test, 1)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 1)
0
         reparse.should_not be_nil
0
       end
0
     end
...
58
59
60
61
 
62
63
64
 
65
66
 
67
68
69
...
89
90
91
92
 
93
94
95
 
96
97
 
98
99
100
...
58
59
60
 
61
62
63
 
64
65
 
66
67
68
69
...
89
90
91
 
92
93
94
 
95
96
 
97
98
99
100
0
@@ -58,12 +58,12 @@ module NotPredicateSpec
0
       end
0
 
0
       it "is expired when a character is inserted between the terminals" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
         input.replace('foolbar')
0
- node_cache.expire(3..3, 1)
0
+ result_cache.expire(3..3, 1)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
       end
0
     end
0
 
0
@@ -89,12 +89,12 @@ module NotPredicateSpec
0
         end
0
 
0
         it "is expired if anything is inserted immediately after it" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
           input.replace('foobar')
0
- node_cache.expire(3..3, 3)
0
+ result_cache.expire(3..3, 3)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
           reparse.should be_nil
0
         end
0
       end
...
41
42
43
44
 
45
46
47
 
48
49
 
50
51
52
...
41
42
43
 
44
45
46
 
47
48
 
49
50
51
52
0
@@ -41,12 +41,12 @@ module OptionalSpec
0
         end
0
 
0
         it "is expired when something is inserted at the site at which the optional expression was originally not found" do
0
- node_cache.should have_result(:expression_under_test, 0)
0
+ result_cache.should have_result(:expression_under_test, 0)
0
 
0
           input.replace('foo')
0
- node_cache.expire(0..0, 3)
0
+ result_cache.expire(0..0, 3)
0
 
0
- node_cache.should_not have_result(:expression_under_test, 0)
0
+ result_cache.should_not have_result(:expression_under_test, 0)
0
         end
0
       end
0
       
...
14
15
16
17
 
18
19
 
20
21
22
23
 
24
25
26
...
32
33
34
35
 
36
37
 
38
39
40
41
42
 
 
43
44
45
...
14
15
16
 
17
18
 
19
20
21
22
 
23
24
25
26
...
32
33
34
 
35
36
 
37
38
39
40
 
 
41
42
43
44
45
0
@@ -14,13 +14,13 @@ module ParsingRuleSpec
0
     it "stores and retrieves successful results for that rule in its node cache, correctly updating the index upon retrieval" do
0
       parser = self.class.const_get(:FooParser).new
0
       parser.send(:prepare_to_parse, 'baz')
0
- node_cache = parser.send(:expirable_result_cache)
0
+ result_cache = parser.send(:expirable_result_cache)
0
 
0
- node_cache.should_not have_result(:bar, 0)
0
+ result_cache.should_not have_result(:bar, 0)
0
     
0
       parser._nt_bar
0
     
0
- cached_node = node_cache.get_result(:bar, 0)
0
+ cached_node = result_cache.get_result(:bar, 0)
0
       cached_node.should be_an_instance_of(Runtime::SyntaxNode)
0
       cached_node.text_value.should == 'baz'
0
     
0
@@ -32,14 +32,14 @@ module ParsingRuleSpec
0
     it "stores and retrieves failed results for that rule in its node cache" do
0
       parser = self.class.const_get(:FooParser).new
0
       parser.send(:prepare_to_parse, 'bogus')
0
- node_cache = parser.send(:expirable_result_cache)
0
+ result_cache = parser.send(:expirable_result_cache)
0
 
0
- node_cache.should_not have_result(:bar, 0)
0
+ result_cache.should_not have_result(:bar, 0)
0
 
0
       parser._nt_bar
0
 
0
- node_cache.should have_result(:bar, 0)
0
- result = node_cache.get_result(:bar, 0)
0
+ result_cache.should have_result(:bar, 0)
0
+ result = result_cache.get_result(:bar, 0)
0
       result.should be_an_instance_of(Runtime::TerminalParseFailure)
0
 
0
       parser.send(:reset_index)
...
55
56
57
58
 
59
60
61
 
62
63
64
 
65
66
67
68
69
70
71
72
73
 
 
 
74
75
76
...
102
103
104
105
106
107
108
 
 
 
 
109
110
 
111
112
113
114
 
 
 
115
116
117
...
131
132
133
134
135
 
 
136
137
138
139
140
141
 
 
142
143
144
145
146
 
 
147
148
149
150
151
152
 
 
153
154
155
156
157
158
159
 
 
 
 
160
161
162
...
180
181
182
183
184
185
 
 
 
186
187
188
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
215
216
 
 
 
 
 
 
217
218
219
220
221
222
223
224
225
226
227
228
 
 
 
 
 
 
 
 
 
229
230
231
...
266
267
268
269
 
270
271
272
273
274
 
275
276
277
...
55
56
57
 
58
59
60
 
61
62
63
 
64
65
66
67
68
69
70
 
 
 
71
72
73
74
75
76
...
102
103
104
 
 
 
 
105
106
107
108
109
 
110
111
 
 
 
112
113
114
115
116
117
...
131
132
133
 
 
134
135
136
137
138
139
 
 
140
141
142
143
144
 
 
145
146
147
148
149
150
 
 
151
152
153
154
155
 
 
 
 
156
157
158
159
160
161
162
...
180
181
182
 
 
 
183
184
185
186
187
 
 
 
188
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
215
216
217
218
219
 
 
 
 
 
 
 
 
 
220
221
222
223
224
225
226
227
228
229
230
231
...
266
267
268
 
269
270
271
272
273
 
274
275
276
277
0
@@ -55,22 +55,22 @@ module IterativeParsingSpec
0
 
0
       parser.max_terminal_failure_last_index.should == 13
0
 
0
- the = node_cache.get_result(:the, 0)
0
+ the = result_cache.get_result(:the, 0)
0
       the.text_value.should == "the"
0
 
0
- green = node_cache.get_result(:color, 4)
0
+ green = result_cache.get_result(:color, 4)
0
       green.element.text_value.should == "green"
0
 
0
- failure = node_cache.get_result(:dog, 10)
0
+ failure = result_cache.get_result(:dog, 10)
0
       failure.should be_an_instance_of(ParseFailure)
0
       failure.interval.should == (10..10)
0
       
0
       input[12] = 'g'
0
 
0
       parser.expire(12..13, 0)
0
- node_cache.should_not have_result(:dog, 10)
0
- node_cache.should_not have_result(:color, 4)
0
- node_cache.should_not have_result(:foo, 0)
0
+ result_cache.should_not have_result(:dog, 10)
0
+ result_cache.should_not have_result(:color, 4)
0
+ result_cache.should_not have_result(:foo, 0)
0
 
0
       new_result = parser.reparse
0
 
0
@@ -102,16 +102,16 @@ module IterativeParsingSpec
0
       result = parse('foobarbaz')
0
       result.should_not be_nil
0
 
0
- node_cache = parser.send(:expirable_result_cache)
0
- node_cache.should have_result(:a, 0)
0
- node_cache.should have_result(:b, 0)
0
- node_cache.should have_result(:c, 3)
0
+ result_cache = parser.send(:expirable_result_cache)
0
+ result_cache.should have_result(:a, 0)
0
+ result_cache.should have_result(:b, 0)
0
+ result_cache.should have_result(:c, 3)
0
 
0
- node_cache.expire(7..8, 0)
0
+ result_cache.expire(7..8, 0)
0
 
0
- node_cache.should_not have_result(:a, 0)
0
- node_cache.should_not have_result(:b, 0)
0
- node_cache.should_not have_result(:c, 3)
0
+ result_cache.should_not have_result(:a, 0)
0
+ result_cache.should_not have_result(:b, 0)
0
+ result_cache.should_not have_result(:c, 3)
0
     end
0
   end
0
 
0
@@ -131,32 +131,32 @@ module IterativeParsingSpec
0
     it "expires the results of choices that depend on failures that are invalidated as the user types" do
0
       input = '1'
0
       parse(input).should_not be_nil
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       input.replace('1+')
0
       expire(1..1, 1)
0
 
0
- node_cache.should_not have_result(:addition, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should_not have_result(:addition, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       reparse.should be_nil
0
 
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       input.replace('1+1')
0
       expire(2..2, 1)
0
 
0
- node_cache.should_not have_result(:addition, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should_not have_result(:addition, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       reparse.should_not be_nil
0
 
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:number, 0)
0
- node_cache.should have_result(:addition, 2)
0
- node_cache.should have_result(:number, 2)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:addition, 2)
0
+ result_cache.should have_result(:number, 2)
0
     end
0
   end
0
 
0
@@ -180,52 +180,52 @@ module IterativeParsingSpec
0
     it "expires the stale failure of addition as successive characters are added to the buffer" do
0
       input = '('
0
       parse(input, :return_parse_failure => true, :return_propagations => true)
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:primary, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:primary, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       expire(1..1, 1)
0
- node_cache.should_not have_result(:addition, 0)
0
- node_cache.should_not have_result(:primary, 0)
0
- node_cache.should have_result(:number, 0)
0
+ result_cache.should_not have_result(:addition, 0)
0
+ result_cache.should_not have_result(:primary, 0)
0
+ result_cache.should have_result(:number, 0)
0
 
0
       input.replace('(1')
0
       reparse
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:addition, 1)
0
- node_cache.should have_result(:primary, 0)
0
- node_cache.should have_result(:primary, 1)
0
- node_cache.should have_result(:number, 0)
0
- node_cache.should have_result(:number, 1)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:addition, 1)
0
+ result_cache.should have_result(:primary, 0)
0
+ result_cache.should have_result(:primary, 1)
0
+ result_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:number, 1)
0
       
0
       expire(2..2, 1)
0
- node_cache.should_not have_result(:addition, 0)
0
- node_cache.should_not have_result(:addition, 1)
0
- node_cache.should_not have_result(:primary, 0)
0
- node_cache.should have_result(:primary, 1)
0
- node_cache.should have_result(:number, 0)
0
- node_cache.should have_result(:number, 1)
0
+ result_cache.should_not have_result(:addition, 0)
0
+ result_cache.should_not have_result(:addition, 1)
0
+ result_cache.should_not have_result(:primary, 0)
0
+ result_cache.should have_result(:primary, 1)
0
+ result_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:number, 1)
0
 
0
       input.replace('(1+')
0
       reparse
0
- node_cache.should have_result(:addition, 0)
0
- node_cache.should have_result(:addition, 1)
0
- node_cache.should have_result(:primary, 0)
0
- node_cache.should have_result(:primary, 1)
0
- node_cache.should have_result(:number, 0)
0
- node_cache.should have_result(:number, 1)
0
+ result_cache.should have_result(:addition, 0)
0
+ result_cache.should have_result(:addition, 1)
0
+ result_cache.should have_result(:primary, 0)
0
+ result_cache.should have_result(:primary, 1)
0
+ result_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:number, 1)
0
 
0
       expire(3..3, 1)
0
 
0
- node_cache.should_not have_result(:addition, 0)
0
- node_cache.should_not have_result(:addition, 1)
0
- node_cache.should_not have_result(:addition, 2)
0
- node_cache.should_not have_result(:primary, 0)
0
- node_cache.should have_result(:primary, 1) # is this true?
0
- node_cache.should_not have_result(:primary, 2)
0
- node_cache.should have_result(:number, 0)
0
- node_cache.should have_result(:number, 1)
0
- node_cache.should_not have_result(:number, 2)
0
+ result_cache.should_not have_result(:addition, 0)
0
+ result_cache.should_not have_result(:addition, 1)
0
+ result_cache.should_not have_result(:addition, 2)
0
+ result_cache.should_not have_result(:primary, 0)
0
+ result_cache.should have_result(:primary, 1) # is this true?
0
+ result_cache.should_not have_result(:primary, 2)
0
+ result_cache.should have_result(:number, 0)
0
+ result_cache.should have_result(:number, 1)
0
+ result_cache.should_not have_result(:number, 2)
0
 
0
       input.replace('(1+2')
0
       reparse
0
@@ -266,12 +266,12 @@ module IterativeParsingSpec
0
       input.replace('(12)')
0
       expire(2..2, 1)
0
 
0
- node_cache.should_not have_result(:number, 1)
0
+ result_cache.should_not have_result(:number, 1)
0
       parser.reparse.should_not be_nil
0
 
0
       input.replace('(122)')
0
       expire(3..3, 1)
0
- node_cache.should_not have_result(:number, 1)
0
+ result_cache.should_not have_result(:number, 1)
0
       parser.reparse.should_not be_nil
0
     end
0
   end
...
83
84
85
86
 
87
88
89
...
83
84
85
 
86
87
88
89
0
@@ -83,7 +83,7 @@ module Treetop
0
       parser.reparse
0
     end
0
 
0
- def node_cache
0
+ def result_cache
0
       parser.send(:expirable_result_cache)
0
     end
0
 

Comments

    No one has commented yet.