updated to fix breaking recusrion when a good tag was found, it now segfaults though
This commit is contained in:
parent
58986021de
commit
963b99c6bd
2 changed files with 15 additions and 6 deletions
|
|
@ -47,7 +47,7 @@ void ARC_Parser_Destroy(ARC_Parser *parser){
|
|||
}
|
||||
|
||||
//private recusive function to parse a tag
|
||||
void ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t tagId){
|
||||
ARC_Bool ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t tagId){
|
||||
//get the current tag
|
||||
ARC_ParserLanguageTag *tag = NULL;
|
||||
for(uint32_t index = 0; index < parser->language.size; index++){
|
||||
|
|
@ -62,7 +62,7 @@ void ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t tagI
|
|||
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;
|
||||
return ARC_False;
|
||||
}
|
||||
|
||||
//loop through each or section of the tags and tokens
|
||||
|
|
@ -71,12 +71,20 @@ void ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t tagI
|
|||
uint32_t lexerCheckIndex = *lexerIndex;
|
||||
ARC_Bool foundRule = ARC_True;
|
||||
for(uint32_t tokenOrTagIndex = 1; tokenOrTagIndex < tag->tokensOrTags[orIndex][0] + 1; tokenOrTagIndex++){
|
||||
//check if it is lambda (can return safely)
|
||||
if(tag->tokensOrTags[orIndex][tokenOrTagIndex] == 0){
|
||||
return ARC_True;
|
||||
}
|
||||
|
||||
//if the value isn't a token it is a tag, so recurs if it isn't a token
|
||||
ARC_Bool isToken = ARC_Lexer_IsTokenId(parser->lexer, tag->tokensOrTags[orIndex][tokenOrTagIndex]);
|
||||
uint32_t nextTagId = tag->tokensOrTags[orIndex][tokenOrTagIndex];
|
||||
if(isToken == ARC_False){
|
||||
ARC_Parser_ParseTag(parser, lexerIndex, nextTagId);
|
||||
return;
|
||||
//check if the tag works if not break to continue checking next or
|
||||
ARC_Bool tagFound = ARC_Parser_ParseTag(parser, lexerIndex, nextTagId);
|
||||
if(tagFound == ARC_False){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//get the next token in the lexer and increment the lexers index
|
||||
|
|
@ -94,13 +102,14 @@ void ARC_Parser_ParseTag(ARC_Parser *parser, uint32_t *lexerIndex, uint32_t tagI
|
|||
if(foundRule == ARC_True){
|
||||
*lexerIndex = lexerCheckIndex;
|
||||
//TODO: set tag into datastructure
|
||||
return;
|
||||
return ARC_True;
|
||||
}
|
||||
}
|
||||
|
||||
//no rule was found, so set an error and log
|
||||
arc_errno = ARC_ERRNO_DATA;
|
||||
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_Parser_ParseTag(parser, lexerIndex, tagId), tag id: %u could not find a matching rule at token index %u", tagId, *lexerIndex);
|
||||
return ARC_False;
|
||||
}
|
||||
|
||||
void ARC_Parser_Parse(ARC_Parser *parser, ARC_String **data){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue