miniscm: add notices and change "macro" to more standard "define-macro"
This commit is contained in:
parent
b9a1460115
commit
ca1b77d013
|
@ -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
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
(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)
|
||||
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue