static void _parse_parent_child_nonterminal(){ ParserContext context; Ast ast; AstBuilder builder; _build_child_rule_fsm(&fix.parser.fsm); ast_init(&ast, NULL, &fix.parser.table); ast_builder_init(&builder, &ast); ast_builder_append_follow(&builder, &(Token){1, 1, 'a'}); ast_builder_append(&builder, &(Token){2, 1, 'b'}); ast_builder_append(&builder, &(Token){3, 1, 'c'}); ast_builder_done(&builder); ast_builder_dispose(&builder); parser_context_init(&context, &fix.parser); parser_context_set_source_ast(&context, &ast); int error = parser_context_execute(&context); t_assert(!error); parser_context_dispose(&context); ast_dispose(&ast); }
void _parser_basic_parse(){ ParserContext context; Ast ast; AstBuilder builder; _build_simple_ab_fsm(&fix.parser.fsm); ast_init(&ast, NULL, &fix.parser.table); ast_builder_init(&builder, &ast); ast_builder_append_follow(&builder, &(Token){1, 1, 'a'}); ast_builder_append(&builder, &(Token){2, 1, 'b'}); ast_builder_done(&builder); ast_builder_dispose(&builder); parser_context_init(&context, &fix.parser); parser_context_set_source_ast(&context, &ast); int error = parser_context_execute(&context); t_assert(!error); parser_context_dispose(&context); ast_dispose(&ast); }
static void _parse_sibling_with_children_test(){ ParserContext context; Ast ast; AstBuilder builder; _build_siblings_with_children(&fix.parser.fsm); ast_init(&ast, NULL, &fix.parser.table); ast_builder_init(&builder, &ast); ast_builder_append_follow(&builder, &(Token){1, 1, 'a'}); ast_builder_append(&builder, &(Token){2, 1, 'b'}); ast_builder_append(&builder, &(Token){3, 1, 'c'}); ast_builder_parent(&builder); ast_builder_append_follow(&builder, &(Token){4, 1, 'd'}); ast_builder_append(&builder, &(Token){5, 1, 'e'}); ast_builder_append(&builder, &(Token){6, 1, 'f'}); ast_builder_done(&builder); ast_builder_dispose(&builder); parser_context_init(&context, &fix.parser); parser_context_set_source_ast(&context, &ast); int error = parser_context_execute(&context); t_assert(!error); parser_context_dispose(&context); ast_dispose(&ast); }
void t_teardown(){ ast_dispose(&fix.ast); symbol_table_dispose(&fix.table); input_dispose(&fix.input); }