From 990f4d3e4c662c401a08e3704a39878fd6c1c1b6 Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Tue, 2 May 2023 23:45:50 -0300 Subject: parser: Refactor return statement to return an ast_node During the refactoring process, I identified a memory leak where the return argument was allocated but not freed in case of an error. It also introduces the concept of keyword tokens. Where return is now a keyword simplifying the parser. Signed-off-by: Carlos Maniero --- test/parser_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/parser_test.c') diff --git a/test/parser_test.c b/test/parser_test.c index f923c46..52437ce 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -208,7 +208,7 @@ test_parse_basic_syntax_errors(const MunitParameter params[], void *user_data_or assert_parser_error("main(: i32 { return 42; }", "expected ')' but got ':'"); assert_parser_error("main() i32 { return 42; }", "expected ':' but got 'TOKEN_NAME'"); assert_parser_error("main(): { return 42; }", "expected 'TOKEN_NAME' but got '{'"); - assert_parser_error("main(): i32 return 42; }", "expected '{' but got 'TOKEN_NAME'"); + assert_parser_error("main(): i32 return 42; }", "expected '{' but got 'return'"); assert_parser_error("main(): i32 { 42; }", "expected 'TOKEN_NAME' but got 'TOKEN_NUMBER'"); assert_parser_error("main(): i32 { return; }", "unexpected '; (;)' token"); assert_parser_error("main(): i32 { return 42;", "expected '}' but got end of file"); -- cgit v1.2.3