From 5cecbaf11de81294414dea40e3043e1038e8288f Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Tue, 28 Nov 2023 19:34:51 +0100 Subject: [PATCH] Fixed a bug in the AST Grower which made the keyword word unusable --- code/src/ast.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/src/ast.c b/code/src/ast.c index d9dfec0..d99c07e 100644 --- a/code/src/ast.c +++ b/code/src/ast.c @@ -68,8 +68,8 @@ i32_t pac_grow_item(pac_tlist_s *tlist, pac_ast_item_s *item) { item->type = PAC_AST_ITEM_SET; item->data.set = PAC_AST_SET_WORD; - return 1; SKIP_TOKEN; + return 1; } if(CURRENT.type == PAC_TOKEN_KEYWORD_INTEGER) @@ -101,17 +101,20 @@ i32_t pac_grow_variant(pac_tlist_s *tlist, pac_ast_variant_s *variant) ++variant->num_items; if(success < 0) + { return success - 1; - - if(CURRENT.type == PAC_TOKEN_SIGN_VERTICAL_BAR) - return tlist->cursor - start_index; - - if(CURRENT.type == PAC_TOKEN_SIGN_SEMICOLON) + } + if( + (CURRENT.type == PAC_TOKEN_SIGN_VERTICAL_BAR) + || (CURRENT.type == PAC_TOKEN_SIGN_SEMICOLON) + ) { return tlist->cursor - start_index; + } if(CURRENT.type != PAC_TOKEN_SIGN_COMMA) + { return -1; - + } SKIP_TOKEN; } return -1; @@ -183,6 +186,7 @@ i32_t pac_grow_rule(pac_tlist_s *tlist, pac_ast_rule_s *rule) if(CURRENT.type == PAC_TOKEN_SIGN_SEMICOLON) { printf("Continuing with next rule.\n"); + SKIP_TOKEN; return 2; } SKIP_TOKEN;