From d69acb11483edad9b003bf14c61d318647e29384 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 14 Aug 2017 13:20:18 +0000 Subject: [PATCH] WIP --- runtime.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/runtime.c b/runtime.c index 518d4568..f1c3b0e7 100644 --- a/runtime.c +++ b/runtime.c @@ -5702,14 +5702,35 @@ void _read_line_comment(port_type *p) } } if (p->mem_buf[p->buf_idx++] == '\n') { - p->line_num++; // TODO: do we care about col_num above? + p->line_num++; // Ignore col_num since we are just skipping over chars + p->col_num = 0; break; } } } void _read_multiline_comment(port_type *p) {} -void _read_whitespace(port_type *p) {} +void _read_whitespace(port_type *p) +{ + while(1) { + // Read more data into buffer, if needed + if (p->buf_idx == p->mem_buf_len) { + if (!read_from_port(p)){ + break; // Return if buf is empty + } + } + p->buf_idx++; + if (p->mem_buf[p->buf_idx] == '\n') { + p->line_num++; // Ignore col_num since we are just skipping over chars + p->col_num = 0; + break; + } else if (isspace(p->mem_buf[p->buf_idx])) { + p->col_num++; + } else { + break; // Terminate on non-whitespace char + } + } +} void _read_error(void *data, port_type *p, const char *msg) {