spec/rley/parser/earley_parser_spec.rb in rley-0.2.12 vs spec/rley/parser/earley_parser_spec.rb in rley-0.2.14

- old
+ new

@@ -161,10 +161,11 @@ end it 'should parse a valid simple input' do parse_result = subject.parse(grm1_tokens) expect(parse_result.success?).to eq(true) + expect(parse_result.ambiguous?).to eq(false) ###################### # Expectation chart[0]: expected = [ 'S => . A | 0', # start rule @@ -261,10 +262,11 @@ it 'should parse a valid simple expression' do instance = EarleyParser.new(grammar_expr) parse_result = instance.parse(grm2_tokens) expect(parse_result.success?).to eq(true) + expect(parse_result.ambiguous?).to eq(false) ###################### S(0): . 2 + 3 * 4 # Expectation chart[0]: expected = [ 'P => . S | 0', # start rule @@ -395,10 +397,11 @@ ] instance = EarleyParser.new(builder.grammar) expect { instance.parse(tokens) }.not_to raise_error parse_result = instance.parse(tokens) expect(parse_result.success?).to eq(true) + expect(parse_result.ambiguous?).to eq(true) ###################### S(0): . 2 + 3 * 4 # Expectation chart[0]: expected = [ 'P => . S | 0', # Start rule @@ -482,10 +485,11 @@ instance = EarleyParser.new(grammar) tokens = tokenize('abc + def + ghi', grammar) expect { instance.parse(tokens) }.not_to raise_error parse_result = instance.parse(tokens) expect(parse_result.success?).to eq(true) + expect(parse_result.ambiguous?).to eq(true) ###################### S(0): . abc + def + ghi # Expectation chart[0]: expected = [ 'S => . E | 0', # Start rule @@ -563,12 +567,11 @@ MSG err = StandardError expect { subject.parse(wrong) } .to raise_error(err, err_msg.chomp) =begin - expect(parse_result.success?).to eq(false) - + # This code is never reached (because of exception) ###################### S(0) == . a a c c # Expectation chart[0]: expected = [ 'S => . A | 0', # start rule "A => . 'a' A 'c' | 0", # predict from 0 @@ -589,10 +592,9 @@ "A => 'a' . A 'c' | 1", # scan from S(0) 1 "A => . 'a' A 'c' | 2", # predict from 0 "A => . 'b' | 2" # predict from 0 ] compare_state_texts(parse_result.chart[2], expected) - ###################### S(3) == a a c? c state_set_3 = parse_result.chart[3] expect(state_set_3.states).to be_empty # This is an error symptom =end