From 6c3adfa6b8f75006a486b10ecbc49bcd2517fe74 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 11 Aug 2017 17:33:41 +0000 Subject: [PATCH] WIP --- read.scm | 6 +++++- runtime.c | 17 +++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/read.scm b/read.scm index 37dca303..345fe40a 100644 --- a/read.scm +++ b/read.scm @@ -693,7 +693,11 @@ ; (repl)) ;(repl) -(write 'TODO) +(define-c read-token + "(void *data, int argc, closure _, object k, object port)" + " Cyc_io_read_token(data, k, port);") + +(read-token (open-input-file "generate-c.scm")) ;; Notes on writing a fast parser: ; - Interface to the user is (read). This needs to be fast diff --git a/runtime.c b/runtime.c index daa48dc4..3f64cd8a 100644 --- a/runtime.c +++ b/runtime.c @@ -5708,20 +5708,13 @@ void _read_whitespace(port_type *p) {} void _read_error(void *data, port_type *p, const char *msg) { -/* TODO: need equivalent of this: -(define (parse-error msg lnum cnum) - (error - (string-append - "Error (line " - (number->string lnum) - ", char " - (number->string cnum) - "): " - msg))) -*/ + char buf[1024]; + snprintf(buf, 1023, "Error (line %d, column %d): %s", + p->line_num, p->col_num, msg); + Cyc_rt_raise_msg(data, buf); } -void Cyc_read_token(void *data, object cont, object port) +void Cyc_io_read_token(void *data, object cont, object port) { Cyc_check_port(data, port); port_type *p = (port_type *)port;