From bdc8e2a05f4d647deec81249546cc7582eefaf74 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 17 Feb 2023 22:54:34 -0800 Subject: fixed parsing negative numbers, added float functions --- src/parse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index 79c1dc4..fcaab5d 100644 --- a/src/parse.c +++ b/src/parse.c @@ -23,6 +23,11 @@ sym_t* init_sym_int(int value) { *vp = value; return init_sym(LITERAL, INT, vp); } +sym_t* init_sym_float(float value) { + int* vp = malloc(sizeof(float)); + *vp = value; + return init_sym(LITERAL, FLOAT, vp); +} sym_t* init_sym_str(char* value) { char* vp = malloc((strlen(value) + 1) * sizeof(char)); strcpy(vp, value); @@ -77,7 +82,7 @@ symset_t* parse_symbols(char** str) { symbolSet->count = 0; while (1) { /* clear whitespace */ - while (!isalnum(**str) && **str != '(' && **str != ')' && **str != '\0') { + while (!isalnum(**str) && **str != '-' && **str != '(' && **str != ')' && **str != '\0') { (*str)++; } if (**str == ')') { -- cgit v1.3.1