From 788a067280ae69222774f07982f3eee7534b886f Mon Sep 17 00:00:00 2001 From: expan <expan@student.cs.uwaterloo.ca> Date: Thu, 28 Mar 2019 23:02:09 -0400 Subject: [PATCH] Stuff for parser --- parser.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index 52f7b3d..0a32c4d 100644 --- a/parser.c +++ b/parser.c @@ -24,7 +24,24 @@ cons_cell* parse(char* input, int size) { strncpy(buffer_next, input[next_char], size - next_char); cons_cell* cdr_cons = parse(buffer_next, size - next_char); return create_cons_cell(car_cons, cdr_cons); - } + } else { + int first_space_idx = 0; + while (input[first_space_idx] != " ") + first_space_idx++; + + char buff_first[500]; + strncpy(buff_first, input, first_space_idx); + cons_cell* car_cons = parse(buff_first, first_space_idx); + char buff_other[500]; + int next_char = first_space_idx; + while (input[next_char] == ' ' && input[next_char] != NULL) { + next_char++; + } + + strncpy(buff_other, input[next_char], size - next_char); + cons_cell* cdr_cons = parse(buff_other, size-next_char); + return create_cons_cell(car_cons, cdr_cons); + } } int main() { -- GitLab