diff --git a/.vscode/ipch/29adc1225747c2d1/mmap_address.bin b/.vscode/ipch/29adc1225747c2d1/mmap_address.bin new file mode 100644 index 0000000000000000000000000000000000000000..f8ee5b757268c312107fda6a1b2a507ef77221fe Binary files /dev/null and b/.vscode/ipch/29adc1225747c2d1/mmap_address.bin differ diff --git a/Parser b/Parser index dbea1bd2b3293bfe456130c5db600b6d1ada64dd..7f0903551c6ad2b1ca45c34e133fd0d696813382 100755 Binary files a/Parser and b/Parser differ diff --git a/parser.c b/parser.c index 0a32c4dadc10860db6ba30c065ceec3bddf77f38..dfe573360cb7109b04b082704a10b6b7b72fa803 100644 --- a/parser.c +++ b/parser.c @@ -6,6 +6,7 @@ cons_cell* parse(char* input, int size) { if (input[0] == NULL) { + assert(size == 0); return NULL; } if (input[0] == '(') { @@ -14,14 +15,14 @@ cons_cell* parse(char* input, int size) { end--; } char buffer[end]; - strncpy(buffer, input[1], end - 1); + strncpy(buffer, &input[1], end - 1); cons_cell* car_cons = parse(buffer, end - 1); int next_char = end + 1; while (input[next_char] == ' ' && input[next_char] != NULL) { next_char++; } char buffer_next[500]; - strncpy(buffer_next, input[next_char], size - next_char); + 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 { @@ -46,15 +47,14 @@ cons_cell* parse(char* input, int size) { int main() { char str[500]; - printf("Enter the json-string to parse: "); + printf("Enter the json-string to parse: \n"); scanf("%s", str); - printf("You entered: %s", str); + printf("You entered: %s\n", str); int size = 0; while (str[size] != NULL) { size++; } - size++; cons_cell* cons = parse(str, size); print_cons_tree(cons); return 0;