public
Fork of nathansobo/treetop
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/juretta/treetop.git
The failure of sequence expressions depends on the successes preceding the 
failing subexpression
Nathan Sobo (author)
Sat Mar 08 22:58:41 -0800 2008
commit  42e36eb37c3a004eb1741ea5bdced23053818cab
tree    4f7c474c958248c137bc5d89f333b95f8d840e0f
parent  fd1e22fab0c2648b3860ac6bfae9ebbf67237ba1
...
15
16
17
18
 
19
20
21
...
15
16
17
 
18
19
20
21
0
@@ -15,7 +15,7 @@ module Treetop
0
         builder.else_ do
0
           reset_index
0
           assign_failure start_index_var
0
- accumulate_dependency "#{accumulator_var}.last"
0
+ builder << "#{result_var}.dependencies.concat(#{accumulator_var})"
0
         end
0
         end_comment(self)
0
       end
...
49
50
51
52
 
53
54
55
56
 
 
 
 
 
57
58
59
...
49
50
51
 
52
53
 
 
 
54
55
56
57
58
59
60
61
0
@@ -49,11 +49,13 @@ module SequenceSpec
0
           result.should be_an_instance_of(Runtime::ParseFailure)
0
         end
0
         
0
- it "depends on the failure of the first failing subexpression" do
0
+ it "depends on the success of the first subexpression and failure of the second" do
0
           dependencies = result.dependencies
0
- dependencies.size.should == 1
0
- dependencies.first.index.should == 6
0
- dependencies.first.expected_string.should == 'bar'
0
+ dependencies.size.should == 2
0
+ dependencies[0].interval.should == (3...6)
0
+ dependencies[0].text_value.should == 'foo'
0
+ dependencies[1].index.should == 6
0
+ dependencies[1].expected_string.should == 'bar'
0
         end
0
       end
0
       
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
...
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
...
264
265
266
267
268
269
270
271
272
...
160
161
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
164
165
...
179
180
181
 
 
 
 
 
 
 
182
 
 
 
 
 
 
 
 
 
 
 
183
184
185
186
...
220
221
222
 
 
 
223
224
225
0
@@ -160,33 +160,6 @@ module IterativeParsingSpec
0
     end
0
   end
0
 
0
- describe "A really simple grammar" do
0
- include PrintDependencies
0
-
0
- testing_grammar %{
0
- grammar Addition
0
- rule primary
0
- '(' addition ')'
0
- end
0
-
0
- rule addition
0
- number '+' number
0
- end
0
-
0
- rule number
0
- [0-9]
0
- end
0
- end
0
- }
0
-
0
- xit "blah" do
0
- result = parse('(1+', :return_parse_failure => true)
0
- puts
0
- print_dependencies(result)
0
-
0
- end
0
- end
0
-
0
   describe "A parser for a simplified addition grammar" do
0
     testing_grammar %{
0
       grammar Addition
0
@@ -206,25 +179,8 @@ module IterativeParsingSpec
0
 
0
     include PrintDependencies
0
 
0
- it "constructs the correct parse failure" do
0
- result = parse('(1+', :return_parse_failure => true)
0
- puts
0
- print_dependencies(result)
0
-
0
- puts
0
- print_dependencies(node_cache.get(:addition, 1))
0
 
0
- end
0
-
0
- xit "other one" do
0
- result = parse('(1+', :return_parse_failure => true, :consume_all_input => false, :index => 1)
0
- puts
0
- print_dependencies(result)
0
-
0
-
0
- end
0
-
0
- xit "expires the stale failure of addition as successive characters are added to the buffer" do
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
@@ -264,9 +220,6 @@ module IterativeParsingSpec
0
 
0
       expire(3..3, 1)
0
 
0
- puts
0
- print_dependencies node_cache.get(:addition, 0)
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)

Comments

    No one has commented yet.