diff --git a/miniscm/README.rst b/miniscm/README.rst new file mode 100644 index 0000000..1a5b7fe --- /dev/null +++ b/miniscm/README.rst @@ -0,0 +1,11 @@ +======= +Miniscm +======= + +A lightly modified version of minischeme. Includes + +1) String access operators (``string-ref``, ``string-length``) +2) ability to create strings and symbols using ``list->string``, + ``string->symbol`` +3) ports (``open-input-port``, etc.) +4) chars diff --git a/miniscm/init.scm b/miniscm/init.scm index 2427772..0cf7593 100644 --- a/miniscm/init.scm +++ b/miniscm/init.scm @@ -1,5 +1,17 @@ ; This is a init file for Mini-Scheme. -; Modified for UNSLISP. +; Copyright (C) 2024 Peter McGoron +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, version 3 of the License. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . (define modulo remainder) @@ -146,11 +158,10 @@ (lambda args (list->string args))) -(macro - cond-expand - (lambda (body) - (letrec - ((loop +(define-macro cond-expand + (lambda (body) + (letrec + ((loop (lambda (body) (if (null? body) #f @@ -159,24 +170,24 @@ ((eqv? (car elem) 'else) (cons 'begin (cdr elem))) ((and (pair? elem) - (passes? (car elem))) + (passes? (car elem))) (cons 'begin (cdr elem))) (else (loop (cdr body)))))))) - (passes? - (lambda (boolean-form) - (cond - ((eqv? boolean-form 'miniscm-unslisp) #t) - ((eqv? boolean-form 'r3rs) #t) - ((symbol? boolean-form) #f) - ((not (pair? boolean-form)) (error "invalid boolean form")) - ((eqv? (car boolean-form) 'and) - (all passes? (cdr boolean-form))) - ((eqv? (car boolean-form) 'or) - (any passes? (cdr boolean-form))) - ((eqv? (car boolean-form) 'not) - (not (passes? (cadr boolean-form)))) - (else (error "invalid boolean function")))))) - (loop (cdr body))))) + (passes? + (lambda (boolean-form) + (cond + ((eqv? boolean-form 'miniscm-unslisp) #t) + ((eqv? boolean-form 'r3rs) #t) + ((symbol? boolean-form) #f) + ((not (pair? boolean-form)) (error "invalid boolean form")) + ((eqv? (car boolean-form) 'and) + (all passes? (cdr boolean-form))) + ((eqv? (car boolean-form) 'or) + (any passes? (cdr boolean-form))) + ((eqv? (car boolean-form) 'not) + (not (passes? (cadr boolean-form)))) + (else (error "invalid boolean function")))))) + (loop (cdr body))))) (define (abs x) (if (< x 0) diff --git a/miniscm/miniscm.c b/miniscm/miniscm.c index 315ed8e..561633a 100644 --- a/miniscm/miniscm.c +++ b/miniscm/miniscm.c @@ -26,16 +26,19 @@ */ /* This version of MiniScheme has been modified to bootstrap UNSLISP. + * Copyright (C) 2024 Peter McGoron * - * Additions: - * * Proper support for disabling quasiquote - * * Chars - * * Proper support for changing init file by preprocessor define - * * Ports + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. * - * Ports and chars only support the minimum necessary to run UNSLISP. - * The eof-object is #f. (Defining an entire type for EOF seems like - * a kludge. An EOF test function would be a better design.) + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /* @@ -2628,7 +2631,7 @@ init_syntax() mk_syntax(OP_OR0, "or"); mk_syntax(OP_C0STREAM, "cons-stream"); #ifdef USE_MACRO - mk_syntax(OP_0MACRO, "macro"); + mk_syntax(OP_0MACRO, "define-macro"); #endif mk_syntax(OP_CASE0, "case"); }