From cd77ac7997fa956c1d67ef91cde056e817aa16c7 Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Wed, 26 Apr 2023 01:57:42 -0300 Subject: ast: Include a Binary Operation kind enum The AST was using a string view to distinguish the operation kind. An enum was created for this purpose simplifying code generation. Signed-off-by: Carlos Maniero Reviewed-by: Johnny Richard --- test/parser_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/parser_test.c') diff --git a/test/parser_test.c b/test/parser_test.c index d8aee07..251054d 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -145,13 +145,14 @@ test_parse_arithmetic_expression(const MunitParameter params[], void *user_data_ { assert_int(AST_BINARY_OPERATION, ==, exp1->kind); - assert_string_view_equal("-", exp1->data.binary_operation.op); + assert_int(AST_BINARY_OPERATION, ==, exp1->kind); + assert_int(AST_BINOP_SUBTRACTION, ==, exp1->data.binary_operation.kind); ast_node_t *exp2 = exp1->data.binary_operation.left; { assert_int(AST_BINARY_OPERATION, ==, exp2->kind); - assert_string_view_equal("+", exp2->data.binary_operation.op); + assert_int(AST_BINOP_ADITION, ==, exp2->data.binary_operation.kind); assert_int(AST_LITERAL, ==, exp2->data.binary_operation.left->kind); assert_int(exp2->data.binary_operation.left->data.literal.value.integer, ==, 1); @@ -160,12 +161,12 @@ test_parse_arithmetic_expression(const MunitParameter params[], void *user_data_ { assert_int(AST_BINARY_OPERATION, ==, exp3->kind); - assert_string_view_equal("/", exp3->data.binary_operation.op); + assert_int(AST_BINOP_DIVISION, ==, exp3->data.binary_operation.kind); ast_node_t *exp4 = exp3->data.binary_operation.left; { assert_int(AST_BINARY_OPERATION, ==, exp4->kind); - assert_string_view_equal("*", exp4->data.binary_operation.op); + assert_int(AST_BINOP_MULTIPLICATION, ==, exp4->data.binary_operation.kind); assert_int(AST_LITERAL, ==, exp4->data.binary_operation.left->kind); assert_int(exp4->data.binary_operation.left->data.literal.value.integer, ==, 3); -- cgit v1.2.3