change over to a linked list system and start trying to fix bug which causes the parser to not output anything meaningful due to memory deallocation

This commit is contained in:
2025-05-28 22:51:27 +01:00
parent 43bc7663fc
commit b82e351daf
13 changed files with 465 additions and 176 deletions

View File

@@ -1,12 +1,14 @@
#include "string.h"
#include "../../string/string.h"
#include "../../lexer/token.h"
#include <cjson/cJSON.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *swap_quotes(const char *input) {
char *swap_quotes(char *input) {
size_t len = strlen(input);
char *result = malloc(len + 1);
if (!result)
@@ -24,7 +26,8 @@ char *swap_quotes(const char *input) {
return result;
}
char *unquote(const char *str) {
char *unquote(char *str) {
return str;
if (*str == '\0')
return NULL;
@@ -72,7 +75,7 @@ char *unquote(const char *str) {
TaggedValue parse_string(Token token) {
return (TaggedValue){
TYPE_STRING,
unquote(token.value)
AST_STRING,
cloneString(token.value),
};
}

View File

@@ -1,8 +1,8 @@
#include "../../lexer/token.h"
#include "../taggedValue.h"
char *swap_quotes(const char *input);
char *swap_quotes(char *input);
char *unquote(const char *str);
char *unquote(char *str);
TaggedValue parse_string(Token token);