miniscm: add notices and change "macro" to more standard "define-macro"

This commit is contained in:
Peter McGoron 2024-10-13 22:12:53 -04:00
parent b9a1460115
commit ca1b77d013
3 changed files with 56 additions and 31 deletions

11
miniscm/README.rst Normal file
View File

@ -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

View File

@ -1,5 +1,17 @@
; This is a init file for Mini-Scheme. ; 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 <https://www.gnu.org/licenses/>.
(define modulo remainder) (define modulo remainder)
@ -146,11 +158,10 @@
(lambda args (lambda args
(list->string args))) (list->string args)))
(macro (define-macro cond-expand
cond-expand (lambda (body)
(lambda (body) (letrec
(letrec ((loop
((loop
(lambda (body) (lambda (body)
(if (null? body) (if (null? body)
#f #f
@ -159,24 +170,24 @@
((eqv? (car elem) 'else) ((eqv? (car elem) 'else)
(cons 'begin (cdr elem))) (cons 'begin (cdr elem)))
((and (pair? elem) ((and (pair? elem)
(passes? (car elem))) (passes? (car elem)))
(cons 'begin (cdr elem))) (cons 'begin (cdr elem)))
(else (loop (cdr body)))))))) (else (loop (cdr body))))))))
(passes? (passes?
(lambda (boolean-form) (lambda (boolean-form)
(cond (cond
((eqv? boolean-form 'miniscm-unslisp) #t) ((eqv? boolean-form 'miniscm-unslisp) #t)
((eqv? boolean-form 'r3rs) #t) ((eqv? boolean-form 'r3rs) #t)
((symbol? boolean-form) #f) ((symbol? boolean-form) #f)
((not (pair? boolean-form)) (error "invalid boolean form")) ((not (pair? boolean-form)) (error "invalid boolean form"))
((eqv? (car boolean-form) 'and) ((eqv? (car boolean-form) 'and)
(all passes? (cdr boolean-form))) (all passes? (cdr boolean-form)))
((eqv? (car boolean-form) 'or) ((eqv? (car boolean-form) 'or)
(any passes? (cdr boolean-form))) (any passes? (cdr boolean-form)))
((eqv? (car boolean-form) 'not) ((eqv? (car boolean-form) 'not)
(not (passes? (cadr boolean-form)))) (not (passes? (cadr boolean-form))))
(else (error "invalid boolean function")))))) (else (error "invalid boolean function"))))))
(loop (cdr body))))) (loop (cdr body)))))
(define (abs x) (define (abs x)
(if (< x 0) (if (< x 0)

View File

@ -26,16 +26,19 @@
*/ */
/* This version of MiniScheme has been modified to bootstrap UNSLISP. /* This version of MiniScheme has been modified to bootstrap UNSLISP.
* Copyright (C) 2024 Peter McGoron
* *
* Additions: * This program is free software: you can redistribute it and/or modify
* * Proper support for disabling quasiquote * it under the terms of the GNU General Public License as published by
* * Chars * the Free Software Foundation, version 3 of the License.
* * Proper support for changing init file by preprocessor define
* * Ports
* *
* Ports and chars only support the minimum necessary to run UNSLISP. * This program is distributed in the hope that it will be useful,
* The eof-object is #f. (Defining an entire type for EOF seems like * but WITHOUT ANY WARRANTY; without even the implied warranty of
* a kludge. An EOF test function would be a better design.) * 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 <https://www.gnu.org/licenses/>.
*/ */
/* /*
@ -2628,7 +2631,7 @@ init_syntax()
mk_syntax(OP_OR0, "or"); mk_syntax(OP_OR0, "or");
mk_syntax(OP_C0STREAM, "cons-stream"); mk_syntax(OP_C0STREAM, "cons-stream");
#ifdef USE_MACRO #ifdef USE_MACRO
mk_syntax(OP_0MACRO, "macro"); mk_syntax(OP_0MACRO, "define-macro");
#endif #endif
mk_syntax(OP_CASE0, "case"); mk_syntax(OP_CASE0, "case");
} }