1 require File.expand_path(File.join(__dir__, 'case'))
4 class TestScanY < TestCase
7 file = File.join(ASSET_DIR, 'scan.y')
8 @debug_flags = Racc::DebugFlags.parse_option_string('o')
9 parser = Racc::GrammarFileParser.new(@debug_flags)
10 @result = parser.parse(File.read(file), File.basename(file))
11 @states = Racc::States.new(@result.grammar).nfa
16 generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
18 # it generates valid ruby
20 self.class_eval(generator.generate_parser)
23 grammar = @states.grammar
25 assert_equal 0, @states.n_srconflicts
26 assert_equal 0, @states.n_rrconflicts
27 assert_equal 0, grammar.n_useless_nonterminals
28 assert_equal 0, grammar.n_useless_rules
29 assert_nil grammar.n_expected_srconflicts
32 def test_compile_line_convert
33 params = @result.params.dup
34 params.convert_line_all = true
36 generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
38 # it generates valid ruby
40 self.class_eval(generator.generate_parser)
43 grammar = @states.grammar
45 assert_equal 0, @states.n_srconflicts
46 assert_equal 0, @states.n_rrconflicts
47 assert_equal 0, grammar.n_useless_nonterminals
48 assert_equal 0, grammar.n_useless_rules
49 assert_nil grammar.n_expected_srconflicts