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
The result of successful repetitions include the endpoint.

The endpoint of a repetition is always the start site of a 
repetition-terminating failure. If this site is disturbed, the repetition 
might not terminate at this site any longer.
Nathan Sobo (author)
Fri Mar 14 16:13:17 -0700 2008
commit  e40455859525899be4057b6cec730d54c8ff503f
tree    8395506def5c8cf09d1c01a0ee96b2e6cefd6f70
parent  b6ffcfd009e7dcb4ab0227233b103a51b72c8446
...
25
26
27
28
 
29
30
31
...
25
26
27
 
28
29
30
31
0
@@ -25,7 +25,7 @@ module Treetop
0
       end
0
       
0
       def assign_and_extend_result
0
- assign_result "#{node_class_name}.new(input, #{start_index_var}...index, #{accumulator_var})"
0
+ assign_result "#{node_class_name}.new(input, #{start_index_var}..index, #{accumulator_var})"
0
         extend_result_with_inline_module
0
       end
0
     end
...
18
19
20
21
 
 
 
 
 
22
23
24
...
50
51
52
53
 
 
 
 
 
54
55
56
...
18
19
20
 
21
22
23
24
25
26
27
28
...
54
55
56
 
57
58
59
60
61
62
63
64
0
@@ -18,7 +18,11 @@ module OneOrMoreSpec
0
         it "is a failure" do
0
           result.should be_an_instance_of(Runtime::ParseFailure)
0
         end
0
-
0
+
0
+ it "has an interval that includes the site of the failure of the repeated subexpression" do
0
+ result.interval.should == (0..0)
0
+ end
0
+
0
         it "depends on the failure of the repeated subexpression" do
0
           dependencies = result.dependencies
0
           dependencies.size.should == 1
0
@@ -50,7 +54,11 @@ module OneOrMoreSpec
0
         it "responds to the method defined in the inline block" do
0
           result.should respond_to(:a_method)
0
         end
0
-
0
+
0
+ it "has an interval that includes the site of the repetition-terminating failure" do
0
+ result.interval.should == (0..6)
0
+ end
0
+
0
         it "depends on the 2 successful parsings and one failed parsing of the repeated subexpression" do
0
           dependencies = result.dependencies
0
           dependencies.size.should == 3
...
22
23
24
25
 
 
 
 
 
26
27
28
...
55
56
57
58
 
 
 
 
 
59
60
61
...
82
83
84
85
 
86
87
88
 
89
90
91
...
22
23
24
 
25
26
27
28
29
30
31
32
...
59
60
61
 
62
63
64
65
66
67
68
69
...
90
91
92
 
93
94
95
 
96
97
98
99
0
@@ -22,7 +22,11 @@ module ZeroOrMoreSpec
0
         it "responds to the method defined in the inline block" do
0
           result.should respond_to(:a_method)
0
         end
0
-
0
+
0
+ it "has an interval that includes the site of the repetition-terminating failure" do
0
+ result.interval.should == (0..0)
0
+ end
0
+
0
         it "depends on failure of the repeated subexpression" do
0
           dependencies = result.dependencies
0
           dependencies.size.should == 1
0
@@ -55,7 +59,11 @@ module ZeroOrMoreSpec
0
         it "responds to the method defined in the inline block" do
0
           result.should respond_to(:a_method)
0
         end
0
-
0
+
0
+ it "has an interval that includes the site of the repetition-terminating failure" do
0
+ result.interval.should == (0..6)
0
+ end
0
+
0
         it "depends on the 2 successful parsings and one failed parsing of the repeated subexpression" do
0
           dependencies = result.dependencies
0
           dependencies.size.should == 3
0
@@ -82,10 +90,10 @@ module ZeroOrMoreSpec
0
   describe "Zero or more of a sequence" do
0
     testing_expression '("foo" "bar")*'
0
   
0
- it "resets the index appropriately following partially matcing input" do
0
+ it "returns a result that whose interval inclusively ends at the site of the repetition-terminating failure" do
0
       parse('foobarfoo', :consume_all_input => false) do |result|
0
         result.should_not be_nil
0
- result.interval.should == (0...6)
0
+ result.interval.should == (0..6)
0
       end
0
     end
0
   end
...
267
268
269
 
 
 
 
 
270
271
272
273
...
267
268
269
270
271
272
273
274
275
276
277
278
0
@@ -267,6 +267,11 @@ module IterativeParsingSpec
0
       expire(2..2, 1)
0
       node_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
+ parser.reparse.should_not be_nil
0
     end
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.