Convert cat.rla to high-level language and rename as cat.rls.
This commit is contained in:
parent
387ff63a48
commit
2f67f502f7
|
|
@ -1,118 +0,0 @@
|
|||
#! /home/nybble/src/c/rosella/rosella
|
||||
|
||||
#S(#="lambda"
|
||||
; (lambda (pathname . _)
|
||||
; (call-with-values
|
||||
; (lambda () (posix-open pathname O_RDONLY))
|
||||
; (lambda (fd errno . _)
|
||||
; ((if fd
|
||||
; (lambda (fd errno . _)
|
||||
; (let [(str (make-byte-string 4096))]
|
||||
; (letrec [(loop (lambda ()
|
||||
; (call-with-values
|
||||
; (lambda () (posix-read fd str (byte-string-size str)))
|
||||
; (lambda (result . _)
|
||||
; (unless (eq? size 0)
|
||||
; (posix-write 1 str size))
|
||||
; (loop)))))]
|
||||
; (loop))))
|
||||
; k)
|
||||
; fd errno))))
|
||||
#(
|
||||
0 ; O_RDONLY
|
||||
#="posix-open"
|
||||
#S(#="template"
|
||||
; (let/cc k
|
||||
; (lambda (fd errno . _)
|
||||
; (if fd
|
||||
; (k (apply ... argv))
|
||||
; (k argv))))
|
||||
#(
|
||||
#S(#="lambda"
|
||||
; (lambda (fd errno . _)
|
||||
; (let/cc k
|
||||
; (let [(str (make-byte-string 4096 0))]
|
||||
; (letrec [(loop (lambda () ... k fd ...))]
|
||||
; (loop)))))
|
||||
#(
|
||||
4096
|
||||
0
|
||||
#S(#="template" ; loop
|
||||
; (let (fd str)
|
||||
; (letrec [(loop (lambda ()
|
||||
; (let/cc k
|
||||
; (call-with-values
|
||||
; (lambda () (posix-read fd str (byte-string-size str)))
|
||||
; (lambda (result . _) ... k str loop ...)))))]
|
||||
; loop))
|
||||
#(
|
||||
#="posix-read"
|
||||
#S(#="template"
|
||||
; (lambda (result . _)
|
||||
; (unless (eq? result 0)
|
||||
; ((lambda _ (loop)) (posix-write 1 str result))
|
||||
; (k)))
|
||||
#(0 1 #="posix-write")
|
||||
"\x41\xfc\xfe\xff" ; #(i1=str self=loop ctx k)
|
||||
2
|
||||
"\x00\x81\x03\xfd\; (set! f1 (car argv))
|
||||
\x02\x80\x81\x00\; (set! f0 (cons f1 nil))
|
||||
\x02\x80\x40\x80\; (set! f0 (cons i0 f0))
|
||||
\x02\x80\x02\x80\; (set! f0 (cons g2 f0))
|
||||
\x01\x81\x81\x01\; (set! f1 (eq? f1 g1))
|
||||
\x80\x81\x00\x80\; (set! f0 (if f1 nil f0))
|
||||
\x81\x81\x43\x03"; (set! f1 (if f1 i3 g3))
|
||||
0x81 ; f1
|
||||
0x80 ; f0
|
||||
0x42 ; i2
|
||||
0x41 ; i1
|
||||
)
|
||||
)
|
||||
"\x80\x81" ; #(f0 f1)
|
||||
2
|
||||
"\x00\x80\x29\x41\; (set! f0 (byte-string-size i1))
|
||||
\x02\x80\x80\x00\; (set! f0 (cons f0 nil))
|
||||
\x02\x80\x41\x80\; (set! f0 (cons i1 f0))
|
||||
\x02\x80\x40\x80\; (set! f0 (cons i0 f0))
|
||||
\x00\x81\x1b\x02"; (set! f1 (lambda g2))
|
||||
0x01 ; g1
|
||||
0x80 ; f0
|
||||
0xfe ; ctx
|
||||
0x81 ; f1
|
||||
)
|
||||
)
|
||||
#()
|
||||
3
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x04\x81\x01\x02\; (set! f1 (make-byte-string g1 g2))
|
||||
\x00\x82\x1b\x03"; (set! f2 (lambda g3))
|
||||
0x82 ; f2
|
||||
0x00 ; nil
|
||||
0xfe ; ctx
|
||||
0xff ; k
|
||||
)
|
||||
)
|
||||
"\xfe\xff" ; ctx k
|
||||
1
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x80\x80\x01\x40\; (set! f0 (if f0 g1 i0))
|
||||
\x00\x80\x1b\x80"; (set! f0 (lambda f0))
|
||||
0x80 ; f0
|
||||
0xfd ; argv
|
||||
0x40 ; i0
|
||||
0x41 ; i1
|
||||
)
|
||||
)
|
||||
#()
|
||||
2
|
||||
"\x02\x80\x01\x00\; (set! f0 (cons g1 nil))
|
||||
\x00\x81\x03\xfd\; (set! f1 (car argv))
|
||||
\x02\x80\x81\x80\; (set! f0 (cons f1 f0))
|
||||
\x00\x81\x1b\x03"; (set! f1 (lambda g3))
|
||||
0x02 ; g2
|
||||
0x80 ; f0
|
||||
0xfe ; ctx
|
||||
0x81 ; f1
|
||||
)
|
||||
|
||||
; vim:set sw=2 expandtab syntax=:
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
(define O_RDONLY 0)
|
||||
|
||||
(define fd (posix-open (car *argv*) O_RDONLY))
|
||||
(define str (make-byte-string 4096 0))
|
||||
|
||||
(define (read-write-loop)
|
||||
(let ([size (posix-read fd str (byte-string-size str))])
|
||||
(if (eq? size 0)
|
||||
(values)
|
||||
(begin
|
||||
(posix-write 1 str size)
|
||||
(read-write-loop)))))
|
||||
|
||||
(read-write-loop)
|
||||
Loading…
Reference in New Issue