diff --git a/Parser b/Parser index 7f0903551c6ad2b1ca45c34e133fd0d696813382..10847e0c3ae579d8d17f6bd242b9f866f8375f1a 100755 Binary files a/Parser and b/Parser differ diff --git a/parser.c b/parser.c index b346bf0849c9a957fe5c5be4aa31f2f26c81336b..e2d61398836f2ee11e18fe15f551c5a0333c9e57 100644 --- a/parser.c +++ b/parser.c @@ -5,6 +5,7 @@ #include "parser.h" cons_cell* parse(char* input, int size) { + printf("%s\n", input); if (input[0] == NULL) { assert(size == 0); return NULL; @@ -22,12 +23,12 @@ cons_cell* parse(char* input, int size) { next_char++; } char buffer_next[500]; - strncpy(buffer_next, &input[next_char], size - next_char); - cons_cell* cdr_cons = parse(buffer_next, size - next_char); + strncpy(buffer_next, &input[next_char], size - next_char + 1); + cons_cell* cdr_cons = parse(buffer_next, size - next_char + 1); return create_cons_cell(car_cons, cdr_cons); } else { int first_space_idx = 0; - while (input[first_space_idx] != " " && input[first_space_idx] != NULL) + while (input[first_space_idx] != ' ' && input[first_space_idx] != NULL) first_space_idx++; char buff_first[500]; @@ -39,8 +40,8 @@ cons_cell* parse(char* input, int size) { next_char++; } - strncpy(buff_other, &input[next_char], size - next_char); - cons_cell* cdr_cons = parse(buff_other, size-next_char); + strncpy(buff_other, &input[next_char], size - next_char + 1); + cons_cell* cdr_cons = parse(buff_other, size - next_char + 1); car_cons->cdr = cdr_cons; return car_cons; }