mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
WIP
This commit is contained in:
parent
e9dc22a296
commit
2d7839c264
2 changed files with 24 additions and 1 deletions
|
@ -266,6 +266,7 @@ object Cyc_io_flush_output_port(void *data, object port);
|
||||||
object Cyc_io_read_char(void *data, object cont, object port);
|
object Cyc_io_read_char(void *data, object cont, object port);
|
||||||
object Cyc_io_peek_char(void *data, object cont, object port);
|
object Cyc_io_peek_char(void *data, object cont, object port);
|
||||||
object Cyc_io_read_line(void *data, object cont, object port);
|
object Cyc_io_read_line(void *data, object cont, object port);
|
||||||
|
void Cyc_io_read_token(void *data, object cont, object port);
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
24
runtime.c
24
runtime.c
|
@ -5706,7 +5706,22 @@ void _read_line_comment(port_type *p)
|
||||||
void _read_multiline_comment(port_type *p) {}
|
void _read_multiline_comment(port_type *p) {}
|
||||||
void _read_whitespace(port_type *p) {}
|
void _read_whitespace(port_type *p) {}
|
||||||
|
|
||||||
void Cyc_read(void *data, object cont, object port)
|
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)))
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cyc_read_token(void *data, object cont, object port)
|
||||||
{
|
{
|
||||||
Cyc_check_port(data, port);
|
Cyc_check_port(data, port);
|
||||||
port_type *p = (port_type *)port;
|
port_type *p = (port_type *)port;
|
||||||
|
@ -5743,7 +5758,14 @@ void Cyc_read(void *data, object cont, object port)
|
||||||
if (c == ';') {
|
if (c == ';') {
|
||||||
_read_line_comment(p);
|
_read_line_comment(p);
|
||||||
// TODO: but then what, want to go back
|
// TODO: but then what, want to go back
|
||||||
|
} else if (c == '\n') {
|
||||||
|
p->line_num++;
|
||||||
|
} else if (isspace(c)) {
|
||||||
|
_read_whitespace(p);
|
||||||
|
} else {
|
||||||
|
_read_error(data, p, "Unhandled input sequence");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Want to use buffer instead of copying chars each time, but
|
// Want to use buffer instead of copying chars each time, but
|
||||||
// need a solution when another read is required, since that would
|
// need a solution when another read is required, since that would
|
||||||
// overwrite buffer
|
// overwrite buffer
|
||||||
|
|
Loading…
Add table
Reference in a new issue