0
@@ -159,4 +159,79 @@ module IterativeParsingSpec
0
node_cache.should have_result(:number, 2)
0
+ describe "A parser for a simplified addition grammar" do
0
+ primary '+' addition / primary
0
+ '(' addition ')' / number
0
+ it "expires the stale failure of addition as successive characters are added to the buffer" do
0
+ parse(input).should be_nil
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
+ 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
+ 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
+ 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) # is this true?
0
+ node_cache.should have_result(:number, 0)
0
+ node_cache.should have_result(:number, 1)
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
+ 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
+ input.replace('(1+2)')
0
+ reparse.should_not be_nil
0
\ No newline at end of file
Comments
No one has commented yet.