stdin works on an expressin-base and not line-base now

This commit is contained in:
FelixBrendel
2018-11-21 13:54:56 +01:00
parent f179eda6f1
commit 00e10f3536
2 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -195,6 +195,8 @@ char* read_line() {
size_t lenmax = 100, len = lenmax; size_t lenmax = 100, len = lenmax;
int c; int c;
int nesting = 0;
if(line == NULL) if(line == NULL)
return NULL; return NULL;
@@ -215,7 +217,13 @@ char* read_line() {
linep = linen; linep = linen;
} }
if((*line++ = (char)c) == '\n') *line++;
if((*line = (char)c) == '(')
++nesting;
else if((*line = (char)c) == ')')
--nesting;
else if((*line = (char)c) == '\n')
if (nesting == 0)
break; break;
} }
(*line)--; // we dont want the \n actually (*line)--; // we dont want the \n actually
+2
View File
@@ -303,6 +303,8 @@ Ast_Node* parse_single_expression(char* text) {
int index_in_text = 0; int index_in_text = 0;
Ast_Node* result; Ast_Node* result;
eat_until_code(text, &index_in_text); eat_until_code(text, &index_in_text);
if (text[(index_in_text)] == '\0')
return create_ast_node_nil();
if (text[(index_in_text)] == '(' || text[(index_in_text)] == '\'' ) if (text[(index_in_text)] == '(' || text[(index_in_text)] == '\'' )
try { try {
result = parse_expression(text, &index_in_text); result = parse_expression(text, &index_in_text);