Merge commit '3b381b9c7d7c4d32b9ae8e83c549c9c821bf70cb'

This commit is contained in:
Benjamin Vedder 2022-09-24 09:08:36 +02:00
commit 035c223793
9 changed files with 27 additions and 4 deletions

View File

@ -282,7 +282,7 @@ void print_error_message(lbm_value error, unsigned int row, unsigned int col) {
printf_callback("***\tError:\t%s\n", buf);
if (lbm_is_symbol(error) &&
error == SYM_RERROR) {
error == ENC_SYM_RERROR) {
printf_callback("***\t\tLine: %u\n", row);
printf_callback("***\t\tColumn: %u\n", col);
}
@ -2381,8 +2381,9 @@ static inline void cont_read_start_array(eval_context_t *ctx) {
CHECK_STACK(lbm_push(&ctx->K, READ_APPEND_ARRAY));
ctx->app_cont = true;
} else {
lbm_channel_reader_close(lbm_dec_channel(stream));
error_ctx(ENC_SYM_RERROR);
lbm_char_channel_t *str = lbm_dec_channel(stream);
lbm_channel_reader_close(str);
read_error_ctx(lbm_channel_row(str), lbm_channel_column(str));
}
}
@ -2544,6 +2545,7 @@ static inline void cont_read_dot_terminate(eval_context_t *ctx) {
lbm_dec_sym(ctx->r) == SYM_DOT)) {
lbm_set_error_reason((char*)parse_error_dot);
read_error_ctx(lbm_channel_row(str), lbm_channel_column(str));
done_reading(ctx->id);
return;
} else {
if (lbm_type_of(last_cell) == LBM_TYPE_CONS) {
@ -2587,6 +2589,7 @@ static inline void cont_read_done(eval_context_t *ctx) {
} else {
ctx->app_cont = true;
}
done_reading(ctx->id);
}
static inline void cont_read_quote_result(eval_context_t *ctx) {

View File

@ -152,6 +152,11 @@ bool buffered_read(lbm_char_channel_t *chan, char *res) {
mutex_lock(&st->lock);
if (!buffered_channel_is_empty(chan)) {
*res = buffer[st->read_pos];
st->column++;
if (*res == '\n') {
st->column = 0;
st->row ++;
}
st->read_pos = (st->read_pos + 1) % TOKENIZER_BUFFER_SIZE;
ret = true;
}

View File

@ -260,7 +260,7 @@ int tok_string(lbm_char_channel_t *chan) {
// read string into buffer
r = lbm_channel_peek(chan,n,&c);
while (r == CHANNEL_SUCCESS && c != '\"' &&
while (r == CHANNEL_SUCCESS && (c != '\"' || (c == '\"' && encode)) &&
len < TOKENIZER_MAX_SYMBOL_AND_STRING_LENGTH) {
if (c == '\\') encode = true;
else {

View File

@ -0,0 +1,4 @@
(and (< -3.14 3)
(> 3.14 3))

View File

@ -0,0 +1,4 @@
(and (< -3.14f64 3)
(> 3.14f64 3))

View File

@ -0,0 +1,3 @@
(and (< -3.14f32 3)
(> 3.14f32 3))

View File

@ -0,0 +1,2 @@
(eq (read "\"hello world\"") "hello world")

View File

@ -0,0 +1 @@
(eq (read "[1 2 3 4]") [1 2 3 4])

View File

@ -0,0 +1 @@
(eq (type-of "hello world") type-array)