def test_options(self): g = parse_buffer(""" WORLD %language = C %prefix = yy %lexer_function = Lex_getNextToken() %token_type = Lex_Token %% main := hello hello := WORLD %% hello world """) ctx = OutputFormatter(g, {"prefix": "bar_"}) opts = { "prefix": "bar_", "lexer_function": "Lex_getNextToken()", "token_type": "Lex_Token", "node_type": "bar_node_t*", "token_type_access": '', "lexer_include": "lexer.h" } assert ctx.options == Struct(opts)
def test_write_grammar(self): g = parse_buffer(""" WORLD %prefix = yy %lexer_function = Lex_getNextToken() %token_type = Lex_Token %% main := hello main main := hello := WORLD %% hello world """) write_grammar(g, sys.stdout, language="pretty_print") write_grammar(g, sys.stdout, language="c")