From 022ab6cfef2f936db7b6adf1a82a4ac8564b6eea Mon Sep 17 00:00:00 2001 From: herbglitch Date: Mon, 4 Nov 2024 19:58:09 -0700 Subject: [PATCH] partial parserlang stup --- include/arc/std/lexer.h | 13 +++++++++++++ src/std/lexer.c | 2 ++ 2 files changed, 15 insertions(+) diff --git a/include/arc/std/lexer.h b/include/arc/std/lexer.h index 15ec6b4..86c5f86 100644 --- a/include/arc/std/lexer.h +++ b/include/arc/std/lexer.h @@ -194,6 +194,19 @@ uint32_t ARC_Lexer_AutomataMatchCharInStringFn(ARC_String **tokenData, ARC_Strin */ ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchCharRule(uint32_t id, char character); +/** + * @brief creates a ARC_LexerTokenRule with a given id and character range + * + * @note this is intended as a helper funtion + * + * @param[in] id a tokens id (basically the token value) + * @param[in] start the minimum character value to match against + * @param[in] end the maxamum character value to match against + * + * @return a token rule based in the id and character +*/ +ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(uint32_t id, char start, char end); + /** * @brief creates a ARC_LexerTokenRule with a given id and string * diff --git a/src/std/lexer.c b/src/std/lexer.c index 77203f7..e2f48d8 100644 --- a/src/std/lexer.c +++ b/src/std/lexer.c @@ -76,6 +76,8 @@ void ARC_Lexer_RegisterTokenRule(ARC_Lexer *lexer, ARC_LexerTokenRule tokenRule) ARC_LexerTokenRule *storedTokenRule = (ARC_LexerTokenRule *)malloc(sizeof(ARC_LexerTokenRule)); *storedTokenRule = tokenRule; + //TODO: add warning here for if arc_errno is already set + //add to the vector and check for error (I'd be surprised if the error ever happened because that would most likely mean overflow) ARC_Vector_Add(lexer->tokenRules, storedTokenRule); if(arc_errno){