stdin works on an expressin-base and not line-base now
This commit is contained in:
+10
-2
@@ -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,8 +217,14 @@ char* read_line() {
|
|||||||
linep = linen;
|
linep = linen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((*line++ = (char)c) == '\n')
|
*line++;
|
||||||
break;
|
if((*line = (char)c) == '(')
|
||||||
|
++nesting;
|
||||||
|
else if((*line = (char)c) == ')')
|
||||||
|
--nesting;
|
||||||
|
else if((*line = (char)c) == '\n')
|
||||||
|
if (nesting == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
(*line)--; // we dont want the \n actually
|
(*line)--; // we dont want the \n actually
|
||||||
*line = '\0';
|
*line = '\0';
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user