From fcc41aa576d18f1e58409e69099f1ded5a43e80f Mon Sep 17 00:00:00 2001 From: herbglitch Date: Thu, 14 Nov 2024 00:59:04 -0700 Subject: [PATCH] fixed basic parse test, by updated lexer check index after successful recurse --- src/std/parser.c | 3 +++ tests/std/parser.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/std/parser.c b/src/std/parser.c index f4557ab..75bb45c 100644 --- a/src/std/parser.c +++ b/src/std/parser.c @@ -118,6 +118,9 @@ ARC_Bool ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t break; } + //increase the lexer check index as a recursed rule was found + lexerCheckIndex = *lexerIndex; + //this will probably never be called as lambda is usually the last instruction, but just in case we can continue instead of break continue; } diff --git a/tests/std/parser.c b/tests/std/parser.c index 0ef8b73..34d7423 100644 --- a/tests/std/parser.c +++ b/tests/std/parser.c @@ -80,17 +80,46 @@ ARC_TEST(Parser_Basic_Parse){ }; ARC_Parser_Create(&parser, &languageArray, TEST_Parser_InitLexerRulesFn); - ARC_String *tempString; - //ARC_String_CreateWithStrlen(&tempString, "myvar1"); - ARC_String_CreateWithStrlen(&tempString, "m"); + + + //first variable test + ARC_String_CreateWithStrlen(&tempString, "myvar1"); //this destroys string, so no need for cleanup ARC_Parser_Parse(parser, &tempString); - ARC_Parser_Destroy(parser); + ARC_CHECK(arc_errno == 0); + + + //second variable test + ARC_String_CreateWithStrlen(&tempString, "z1xwvq"); + + //this destroys string, so no need for cleanup + ARC_Parser_Parse(parser, &tempString); ARC_CHECK(arc_errno == 0); + + + //third variable test + ARC_String_CreateWithStrlen(&tempString, "z1234"); + + //this destroys string, so no need for cleanup + ARC_Parser_Parse(parser, &tempString); + + ARC_CHECK(arc_errno == 0); + + + //fourth variable test + ARC_String_CreateWithStrlen(&tempString, "aaaaa"); + + //this destroys string, so no need for cleanup + ARC_Parser_Parse(parser, &tempString); + + ARC_CHECK(arc_errno == 0); + + + ARC_Parser_Destroy(parser); } ARC_TEST(Parser_Basic_ParseError){