Просмотр исходного кода

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

master
FelixBrendel 7 лет назад
Родитель
Сommit
00e10f3536
2 измененных файлов: 12 добавлений и 2 удалений
  1. +10
    -2
      src/helpers.c
  2. +2
    -0
      src/parse.c

+ 10
- 2
src/helpers.c Просмотреть файл

@@ -195,6 +195,8 @@ char* read_line() {
size_t lenmax = 100, len = lenmax;
int c;

int nesting = 0;

if(line == NULL)
return NULL;

@@ -215,8 +217,14 @@ char* read_line() {
linep = linen;
}

if((*line++ = (char)c) == '\n')
break;
*line++;
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 = '\0';


+ 2
- 0
src/parse.c Просмотреть файл

@@ -303,6 +303,8 @@ Ast_Node* parse_single_expression(char* text) {
int index_in_text = 0;
Ast_Node* result;
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)] == '\'' )
try {
result = parse_expression(text, &index_in_text);


Загрузка…
Отмена
Сохранить