b4a4e39050
* guix.scm (%source-dir): New variable. (git-file?): New function. (mes): Use them to simplify building/installing from git. * make/install.make (READMES): Add INSTALL, README. * (install): Install mescc.scm and read-0-32.mo.
143 lines
3.6 KiB
Scheme
143 lines
3.6 KiB
Scheme
;;; -*-scheme-*-
|
||
|
||
;;; Mes --- Maxwell Equations of Software
|
||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||
;;;
|
||
;;; This file is part of Mes.
|
||
;;;
|
||
;;; Mes 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; either version 3 of the License, or (at
|
||
;;; your option) any later version.
|
||
;;;
|
||
;;; Mes 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||
|
||
;;; Commentary:
|
||
|
||
;;; Implement core functionality that depends on implementation
|
||
;;; specifics of Mes cell types.
|
||
|
||
;;; Code:
|
||
|
||
(define <cell:char> 0)
|
||
(define <cell:closure> 1)
|
||
(define <cell:continuation> 2)
|
||
(define <cell:function> 3)
|
||
(define <cell:keyword> 4)
|
||
(define <cell:macro> 5)
|
||
(define <cell:number> 6)
|
||
(define <cell:pair> 7)
|
||
(define <cell:ref> 8)
|
||
(define <cell:special> 9)
|
||
(define <cell:string> 10)
|
||
(define <cell:symbol> 11)
|
||
(define <cell:values> 12)
|
||
(define <cell:vector> 13)
|
||
(define <cell:broken-heart> 14)
|
||
|
||
(define cell:type-alist
|
||
(list (cons <cell:char> (quote <cell:char>))
|
||
(cons <cell:closure> (quote <cell:closure>))
|
||
(cons <cell:continuation> (quote <cell:continuation>))
|
||
(cons <cell:function> (quote <cell:function>))
|
||
(cons <cell:keyword> (quote <cell:keyword>))
|
||
(cons <cell:macro> (quote <cell:macro>))
|
||
(cons <cell:number> (quote <cell:number>))
|
||
(cons <cell:pair> (quote <cell:pair>))
|
||
(cons <cell:ref> (quote <cell:ref>))
|
||
(cons <cell:special> (quote <cell:special>))
|
||
(cons <cell:string> (quote <cell:string>))
|
||
(cons <cell:symbol> (quote <cell:symbol>))
|
||
(cons <cell:values> (quote <cell:values>))
|
||
(cons <cell:vector> (quote <cell:vector>))
|
||
(cons <cell:broken-heart> (quote <cell:broken-heart>))))
|
||
|
||
(define (cell:type-name x)
|
||
(cond ((assq (core:type x) cell:type-alist) => cdr)))
|
||
|
||
(define (char? x)
|
||
(eq? (core:type x) <cell:char>))
|
||
|
||
(define (closure? x)
|
||
(eq? (core:type x) <cell:closure>))
|
||
|
||
(define (continuation? x)
|
||
(eq? (core:type x) <cell:continuation>))
|
||
|
||
(define (function? x)
|
||
(eq? (core:type x) <cell:function>))
|
||
|
||
(define builtin? function?)
|
||
|
||
(define (keyword? x)
|
||
(eq? (core:type x) <cell:keyword>))
|
||
|
||
(define (macro? x)
|
||
(eq? (core:type x) <cell:macro>))
|
||
|
||
(define (number? x)
|
||
(eq? (core:type x) <cell:number>))
|
||
|
||
(define (pair? x)
|
||
(eq? (core:type x) <cell:pair>))
|
||
|
||
(define (pair? x)
|
||
(eq? (core:type x) <cell:pair>))
|
||
|
||
(define (special? x)
|
||
(eq? (core:type x) <cell:special>))
|
||
|
||
(define (string? x)
|
||
(eq? (core:type x) <cell:string>))
|
||
|
||
(define (symbol? x)
|
||
(eq? (core:type x) <cell:symbol>))
|
||
|
||
;; Hmm?
|
||
(define (values? x)
|
||
(eq? (core:type x) <cell:values>))
|
||
|
||
(define (vector? x)
|
||
(eq? (core:type x) <cell:vector>))
|
||
|
||
;; Non-types
|
||
;; In core
|
||
;; (define (null? x)
|
||
;; (eq? x '()))
|
||
|
||
(define (atom? x)
|
||
(not (pair? x)))
|
||
|
||
(define (boolean? x)
|
||
(or (eq? x #f) (eq? x #t)))
|
||
|
||
|
||
;;; core: accessors
|
||
(define (string . lst)
|
||
(core:make-cell <cell:string> lst 0))
|
||
|
||
(define (string->list s)
|
||
(core:car s))
|
||
|
||
(define (string->symbol s)
|
||
(if (not (pair? (core:car s))) '()
|
||
(core:lookup-symbol (core:car s))))
|
||
|
||
(define (symbol->list s)
|
||
(core:car s))
|
||
|
||
(define (keyword->list s)
|
||
(core:car s))
|
||
|
||
(define (integer->char x)
|
||
(core:make-cell <cell:character> 0 x))
|
||
|
||
(define (char->integer x)
|
||
(core:make-cell <cell:number> 0 x))
|