Add support for including Guile files.
* module/mes/guile.mes: New file. * module/mes/pretty-print.mes: New file.
This commit is contained in:
parent
276ffdd7ba
commit
77a9146aa5
|
@ -0,0 +1,62 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 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:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-macro (define-module module . rest) #t)
|
||||
(define-macro (use-modules . rest) #t)
|
||||
|
||||
(define (port-filename p) "<stdin>")
|
||||
(define (port-line p) 0)
|
||||
(define (simple-format port format . rest) (map (lambda (x) (display x port)) rest))
|
||||
|
||||
(define (with-input-from-string string thunk)
|
||||
(define save-peek-char peek-char)
|
||||
(define save-read-char read-char)
|
||||
(define save-unread-char unread-char)
|
||||
(let ((tell 0)
|
||||
(end (string-length string)))
|
||||
(set! peek-char
|
||||
(lambda () (if (= tell end) (integer->char -1)
|
||||
(string-ref string (- tell 1)))))
|
||||
(set! read-char
|
||||
(lambda () (if (= tell end) (integer->char -1)
|
||||
(begin
|
||||
(set! tell (1+ tell))
|
||||
(string-ref string (- tell 1))))))
|
||||
(set! unread-char
|
||||
(lambda (c) (set! tell (1- tell)) c)))
|
||||
(let ((r (thunk)))
|
||||
(set! peek-char save-peek-char)
|
||||
(set! read-char save-read-char)
|
||||
(set! unread-char save-unread-char)
|
||||
r))
|
||||
|
||||
(define (with-input-from-file file thunk)
|
||||
(let ((port (open-input-file file)))
|
||||
(if (= port -1)
|
||||
(begin (display "no such file:") (display file) (newline))
|
||||
(let* ((save (current-input-port))
|
||||
(foo (set-current-input-port port))
|
||||
(r (thunk)))
|
||||
(set-current-input-port save)
|
||||
r))))
|
|
@ -0,0 +1,29 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 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:
|
||||
|
||||
;;; base-0.mes is the first file being loaded from the Mes core. It
|
||||
;;; provides primitives that use Mes internals to create the illusion
|
||||
;;; of compatibility with Guile. It is not safe to be run by Guile.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define pretty-print display)
|
Loading…
Reference in New Issue