From 37259a3ac39135a7e6cedf8525bc26d8d8298a0f Mon Sep 17 00:00:00 2001 From: herbglitch Date: Tue, 10 Dec 2024 01:06:34 -0700 Subject: [PATCH] added in file reading for parsing --- src/std/parser.c | 10 ++++++++++ tests/std/parser/csv.c | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/std/parser.c b/src/std/parser.c index 2825bb4..b52518b 100644 --- a/src/std/parser.c +++ b/src/std/parser.c @@ -2,6 +2,7 @@ #include "arc/std/parser.h" #include "arc/std/bool.h" #include "arc/std/errno.h" +#include "arc/std/io.h" #include "arc/std/lexer.h" #include "arc/std/vector.h" #include @@ -342,7 +343,16 @@ void ARC_Parser_Parse(ARC_Parser *parser, ARC_String **data){ } void ARC_Parser_ParseFile(ARC_Parser *parser, ARC_String *path){ + ARC_String *fileString; + ARC_IO_FileToStr(path, &fileString); + if(fileString == NULL){ + arc_errno = ARC_ERRNO_NULL; + ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_Parser_ParseFile(parser, data), could not read file \"%s\"", path->data); + return; + } + + ARC_Parser_Parse(parser, &fileString); } void ARC_Parser_ClearData(ARC_Parser *parser){ diff --git a/tests/std/parser/csv.c b/tests/std/parser/csv.c index 5270b1b..5e6bbce 100644 --- a/tests/std/parser/csv.c +++ b/tests/std/parser/csv.c @@ -15,7 +15,6 @@ void TEST_ParserCSV_DestroyTypeFn(void *data){ free((int32_t *)data); } - ARC_TEST(Parser_ParserCSV_BasicTest){ ARC_Parser *parser; ARC_ParserCSV_CreateAsParser(&parser, ARC_False, TEST_ParserCSV_CastTypeFn, TEST_ParserCSV_DestroyTypeFn);