Browse Source

tweak peek-char

master
Gabriel Pariat 3 years ago
parent
commit
5eacd6ebc1
  1. 17
      implementations/c/src/reader.c

17
implementations/c/src/reader.c

@ -100,11 +100,9 @@ Pointer read_char_fn(Pointer args, Pointer env) {
} }
static Pointer buffer; static Pointer buffer;
Pointer read_fn(Pointer args, Pointer env) {
Pointer streamPtr = CAR(args); Pointer read1(Pointer streamPtr, Pointer env) {
Stream stream = streamPtr == NIL Stream stream = STREAM(streamPtr);
? STREAM(environment_get(env, STANDARD_INPUT))
: STREAM(streamPtr);
double num = 0; double num = 0;
Pointer macro; Pointer macro;
Char c = peek_char(T, stream); Char c = peek_char(T, stream);
@ -138,6 +136,15 @@ Pointer read_fn(Pointer args, Pointer env) {
return symbol(STRING(buffer).data, STRING(buffer).length - 1); return symbol(STRING(buffer).data, STRING(buffer).length - 1);
} }
Pointer read_fn(Pointer args, Pointer env) {
Pointer streamPtr = CAR(args);
streamPtr = streamPtr == NIL ? environment_get(env, STANDARD_INPUT) : streamPtr;
Stream stream = STREAM(streamPtr);
Pointer result = read1(streamPtr, env);
peek_char(T, stream);
return result;
}
Pointer set_reader_macro(Pointer c, Pointer fn) { Pointer set_reader_macro(Pointer c, Pointer fn) {
READTABLE = table_set(READTABLE, c, fn); READTABLE = table_set(READTABLE, c, fn);
return T; return T;

Loading…
Cancel
Save