Add some error-handling to cat.rla. Add support for #! lines.
Also fix an off-by-one error in the column counter and suppress GC stats.
This commit is contained in:
parent
ce3c4f1ce9
commit
912a620c5a
|
|
@ -1,3 +1,5 @@
|
||||||
|
#! /home/nybble/src/c/rosella/rosella
|
||||||
|
|
||||||
;(lambda (pathname)
|
;(lambda (pathname)
|
||||||
; (let [(fd (posix-open pathname O_RDONLY))]
|
; (let [(fd (posix-open pathname O_RDONLY))]
|
||||||
; (let [(str (make-byte-string 4096))]
|
; (let [(str (make-byte-string 4096))]
|
||||||
|
|
@ -5,6 +7,7 @@
|
||||||
; (let [(size (posix-read fd str (byte-string-size str)))]
|
; (let [(size (posix-read fd str (byte-string-size str)))]
|
||||||
; (posix-write 1 str size))
|
; (posix-write 1 str size))
|
||||||
; (loop)))))
|
; (loop)))))
|
||||||
|
|
||||||
#S(#="lambda"
|
#S(#="lambda"
|
||||||
#(
|
#(
|
||||||
0
|
0
|
||||||
|
|
@ -68,16 +71,28 @@
|
||||||
0x40 ; i0
|
0x40 ; i0
|
||||||
0x41 ; i1
|
0x41 ; i1
|
||||||
)
|
)
|
||||||
|
#S(#="template"
|
||||||
|
#(0 #f)
|
||||||
|
"\x81\xfe" ; f1 k
|
||||||
|
1
|
||||||
|
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||||
|
\x80\x80\x40\x41"; (set! f0 (if f0 i0 i1))
|
||||||
|
0x80 ; f0
|
||||||
|
0xfd ; argv
|
||||||
|
0x02 ; g2
|
||||||
|
0x02 ; g2
|
||||||
|
)
|
||||||
)
|
)
|
||||||
#()
|
#()
|
||||||
2
|
3
|
||||||
"\x02\x80\x01\x00\; (set! f0 (cons g1 nil))
|
"\x02\x80\x01\x00\; (set! f0 (cons g1 nil))
|
||||||
\x00\x81\x03\xfd\; (set! f1 (car argv))
|
\x00\x81\x03\xfd\; (set! f1 (car argv))
|
||||||
\x02\x80\x81\x80\; (set! f0 (cons f1 f0))
|
\x02\x80\x81\x80\; (set! f0 (cons f1 f0))
|
||||||
\x00\x81\x1b\x03"; (set! f1 (lambda g3))
|
\x00\x81\x1b\x03\; (set! f1 (lambda g3))
|
||||||
|
\x00\x82\x1b\x04"; (set! f2 (lambda g4))
|
||||||
0x02 ; g2
|
0x02 ; g2
|
||||||
0x80 ; f0
|
0x80 ; f0
|
||||||
0x81 ; f1
|
0x82 ; f2
|
||||||
0xff ; ctx
|
0xff ; ctx
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /home/nybble/src/c/rosella/rosella
|
||||||
#S(#="lambda"
|
#S(#="lambda"
|
||||||
#(
|
#(
|
||||||
#S(#="template" ; g1
|
#S(#="template" ; g1
|
||||||
|
|
|
||||||
11
reader.c
11
reader.c
|
|
@ -55,7 +55,8 @@ value_t read_value(FILE *f)
|
||||||
register_gc_root(&state.ref_list, NIL);
|
register_gc_root(&state.ref_list, NIL);
|
||||||
|
|
||||||
state.file = f;
|
state.file = f;
|
||||||
state.line = state.column = 1;
|
state.line = 1;
|
||||||
|
state.column = 0;
|
||||||
next_char(&state);
|
next_char(&state);
|
||||||
result = read_one_value(&state);
|
result = read_one_value(&state);
|
||||||
ungetc(state.ch, f);
|
ungetc(state.ch, f);
|
||||||
|
|
@ -120,6 +121,12 @@ static value_t read_special(reader_state_t *state)
|
||||||
|
|
||||||
switch (state->ch)
|
switch (state->ch)
|
||||||
{
|
{
|
||||||
|
case '!':
|
||||||
|
release_assert((state->line == 1) && (state->column == 2));
|
||||||
|
do {
|
||||||
|
next_char(state);
|
||||||
|
} while (state->ch != '\n');
|
||||||
|
return read_one_value(state);
|
||||||
case 'F':
|
case 'F':
|
||||||
case 'f':
|
case 'f':
|
||||||
next_char(state);
|
next_char(state);
|
||||||
|
|
@ -799,7 +806,7 @@ static void next_char(reader_state_t *state)
|
||||||
if (state->ch == '\n')
|
if (state->ch == '\n')
|
||||||
{
|
{
|
||||||
++state->line;
|
++state->line;
|
||||||
state->column = 1;
|
state->column = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue