working on parsing recursively

This commit is contained in:
herbglitch 2024-10-16 23:46:16 -06:00
parent e4aa4a8b6d
commit 24fd8d6b25
3 changed files with 33 additions and 4 deletions

View file

@ -7,7 +7,7 @@ extern "C" {
#include "arc/std/array.h"
//#include "arc/std/bool.h"
//#include "arc/std/lexer.h"
#include "arc/std/lexer.h"
#include <stdint.h>
/**

View file

@ -1,4 +1,5 @@
#include "arc/std/parser.h"
#include "arc/std/errno.h"
#include "arc/std/lexer.h"
#include <stdint.h>
#include <stdlib.h>
@ -43,6 +44,30 @@ void ARC_Parser_Destroy(ARC_Parser *parser){
free(parser);
}
void ARC_Parser_Parse(ARC_Parser *parser, ARC_String *data);
//private recusive function to parse a tag
void ARC_Parser_ParseTag(ARC_Parser *parser, ARC_String *subdata, uint32_t tagId){
//get the current tag
ARC_ParserLanguageTag *tag = NULL;
for(uint32_t index = 0; index < parser->language.size; index++){
ARC_ParserLanguageTag *foundTag = ((ARC_ParserLanguageTag *)parser->language.data) + index;
if(foundTag->tagId == tagId){
tag = foundTag;
break;
}
}
void ARC_Parser_ParseFile(ARC_Parser *parser, ARC_String *path);
//if the tag was not found can't do much, so throw an error
if(tag == NULL){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_Parser_ParseTag(parser, subdata, tagId), could not find tag with id: %u", tagId);
return;
}
}
void ARC_Parser_Parse(ARC_Parser *parser, ARC_String *data){
}
void ARC_Parser_ParseFile(ARC_Parser *parser, ARC_String *path){
}

View file

@ -8,6 +8,10 @@
#define VARIABLE_NAME 4
#define VARIABLE 5
void TEST_Parser_InitLexerRulesFn(ARC_Lexer *lexer){
ARC_Lexer_InitBasicTokenRules(lexer);
}
ARC_TEST(Lexer_Char_Match){
ARC_Parser *parser;
@ -37,7 +41,7 @@ ARC_TEST(Lexer_Char_Match){
testTags //data
};
ARC_Parser_Create(&parser, &languageArray);
ARC_Parser_Create(&parser, &languageArray, TEST_Parser_InitLexerRulesFn);
ARC_Parser_Destroy(parser);