diff --git a/gc.c b/gc.c index bf433078..243c24ee 100644 --- a/gc.c +++ b/gc.c @@ -489,6 +489,10 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd) hp->line_num = ((port_type *) obj)->line_num; hp->col_num = ((port_type *) obj)->col_num; hp->buf_idx = ((port_type *) obj)->buf_idx; + hp->tok_start = ((port_type *) obj)->tok_start; + hp->tok_end = ((port_type *) obj)->tok_end; + hp->tok_buf = ((port_type *) obj)->tok_buf; + hp->tok_buf_len = ((port_type *) obj)->tok_buf_len; hp->mem_buf = ((port_type *)obj)->mem_buf; hp->mem_buf_len = ((port_type *)obj)->mem_buf_len; return (char *)hp; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 052dbb06..fa32c375 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -782,6 +782,10 @@ typedef struct { unsigned int line_num; unsigned int col_num; unsigned int buf_idx; + unsigned int tok_start; // Start of token in mem_buf (end is unknown yet) + unsigned int tok_end; // End of token in tok_buf (start is tok_buf[0]) + char *tok_buf; // Alternative buffer for tokens + size_t tok_buf_len; char *mem_buf; size_t mem_buf_len; } port_type; @@ -800,6 +804,10 @@ typedef struct { p.line_num = 0; \ p.col_num = 0; \ p.buf_idx = 0; \ + p.tok_start = 0; \ + p.tok_end = 0; \ + p.tok_buf = NULL; \ + p.tok_buf_len = 0; \ p.mem_buf = NULL; \ p.mem_buf_len = 0; @@ -814,6 +822,10 @@ typedef struct { p.line_num = 0; \ p.col_num = 0; \ p.buf_idx = 0; \ + p.tok_start = 0; \ + p.tok_end = 0; \ + p.tok_buf = NULL; \ + p.tok_buf_len = 0; \ p.mem_buf = malloc(CYC_IO_BUF_LEN); \ p.mem_buf_len = 0; diff --git a/runtime.c b/runtime.c index 2d53e64c..7b66801e 100644 --- a/runtime.c +++ b/runtime.c @@ -3442,6 +3442,11 @@ object Cyc_io_close_port(void *data, object port) ((port_type *)port)->mem_buf = NULL; ((port_type *)port)->mem_buf_len = 0; } + if (((port_type *)port)->tok_buf != NULL){ + free( ((port_type *)port)->tok_buf ); + ((port_type *)port)->tok_buf = NULL; + ((port_type *)port)->tok_buf_len = 0; + } } return port; } @@ -5759,9 +5764,10 @@ void Cyc_io_read_token(void *data, object cont, object port) // TODO: if buffer is not empty, return that instead, otherwise return this: return_closcall1(data, cont, obj_char2obj(c)); - // TODO: " (string) - // TODO: # - // TODO: | (literal identifier) + } else if (c == '"') { + Cyc_rt_raise_msg(data, "TODO: parsing for strings"); + } else if (c == '#') { + Cyc_rt_raise_msg(data, "TODO: parsing for #"); } else { // TODO: no, need to read chars into a new buffer. can be part of mem_buf with a // starting idx, except: