Beispiel #1
0
 def test_when_analyzer_accepts_input_expect_is_accepted_equals_true(self):
     # given:
     action_table = ActionTable(StateFiniteAutomaton(self.grammar))
     analyzer = SemanticAnalyzer(action_table, Symbol.from_string("abbbc"))
     # when:
     actual = analyzer.shift().shift().shift().shift().shift().reduce(
     ).reduce().reduce().reduce().reduce().is_accepted
     # then:
     self.assertTrue(actual)
Beispiel #2
0
 def test_when_reducing_analyzer_expect_valid_next_parser_step(self):
     # given:
     action_table = ActionTable(StateFiniteAutomaton(self.grammar))
     analyzer = SemanticAnalyzer(action_table, Symbol.from_string("abbbc"))
     # when:
     next_parser_step = analyzer.shift().shift().shift().shift().shift(
     ).reduce().reduce().parser_step
     # then:
     self.assertEqual(next_parser_step.current_state.items,
                      [ParserItem.from_string('A -> bA.')])