From 88ebc7ca77124130015d6c41bc5b28fa201b7374 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 14 Nov 2009 19:13:16 -0600 Subject: [PATCH] Print results individually, on separate lines, rather than as a list. --- Makefile | 2 +- core-image.rla | 71 +++++++++++++++++++++++++------------------------- rosella.c | 11 ++++++-- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 1b53fb9..ef0190e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif all: rosella .PHONY: all clean -ifneq ($(PROFILE),no) +ifeq ($(PROFILE),yes) CFLAGS += -fprofile-generate LDFLAGS += -fprofile-generate endif diff --git a/core-image.rla b/core-image.rla index da70159..96e84ff 100644 --- a/core-image.rla +++ b/core-image.rla @@ -1,23 +1,23 @@ #S(#="lambda" #( - #S(#="template" + #S(#="template" ; g1 #( - #0=#S(#="lambda" + #0=#S(#="lambda" ; g1 #( - #S(#="lambda" - #(1 #f) - #() - 1 + #S(#="lambda" ; g1 + #(1 #f) ; g1 g2 + #1=#() + 1 ; f0 "\x02\x80\x01\x00"; (set! f0 (cons g1 nil)) - 0xfe - 0x80 - 0x02 - 0xff + 0xfe ; k + 0x80 ; f0 + 0x02 ; g2 (#f) + 0xff ; ctx ) #S(#="template" #( - #=0 - #S(#="template" + #=0 ; g1 + #S(#="template" ; g2 #(#f) "\x40\xff\xfe" ; i0 ctx k 1 @@ -29,49 +29,48 @@ 0x01 ; g1 0x41 ; i1 ) - 1 + 1 ; g3 ) "\x80" ; f0 - 2 + 2 ; f0-f1 "\x09\x80\x40\x03\; (set! f0 (fix- i0 g3)) \x02\x80\x80\x00\; (set! f0 (cons f0 nil)) \x00\x81\x1b\x02"; (set! f1 (lambda g2)) - 0x01 - 0x80 - 0x81 - 0xff + 0x01 ; g1 + 0x80 ; f0 + 0x81 ; f1 + 0xff ; ctx ) - 1 + 1 ; g3 ) - #() + #=1 ; #() 2 "\x00\x80\x03\xfd\; (set! f0 (car argv)) \x0d\x81\x80\x03\; (set! f1 (fix< f0 g3)) \x81\x81\x01\x02\; (set! f1 (if f1 g1 g2)) \x00\x81\x1b\x81"; (set! f1 (lambda f1)) - 0x81 - 0x00 - 0xfe - 0xff + 0x81 ; f1 + 0x00 ; nil + 0xfe ; k + 0xff ; ctx ) - #f ) "\xfe\xff" ; k ctx 0 "" - 0x01 - 0xfd - 0x40 - 0x41 + 0x01 ; f1 + 0xfd ; argv + 0x40 ; i0 + 0x41 ; i1 ) - #="string->number" + #="string->number" ; g2 ) - #() - 1 + #=1 ; #() + 1 ; f0 "\x00\x80\x1b\x01"; (set! f0 (lambda g1)) - 0x02 - 0xfd - 0x80 - 0xff + 0x02 ; g2 + 0xfd ; argv + 0x80 ; f0 + 0xff ; ctx ) ; vim:set syntax= sw=2 expandtab: diff --git a/rosella.c b/rosella.c index 68783fb..93c1dc5 100644 --- a/rosella.c +++ b/rosella.c @@ -51,6 +51,7 @@ int main(int argc, char **argv) { gc_root_t argv_root; value_t program; + value_t results; register_gc_root(&argv_root, NIL); @@ -62,10 +63,16 @@ int main(int argc, char **argv) } program = read_value(f); - print_value(run_interpreter(program, argv_root.value)); - nl(); fclose(f); + unregister_gc_root(&argv_root); + results = run_interpreter(program, argv_root.value); + + for (value_t result = results; !is_nil(result); result = _CDR(result)) + { + print_value(CAR(result)); + nl(); + } } else {