Prepare for 0.1 release: new directory structure.
* scripts/elf.mes: New file. * scripts/include.mes: New file. * scripts/mescc.mes: New file. * scripts/paren.mes: New file. * scripts/repl.mes: New file. * doc/examples/main.c: Move from ./main.c. * module/mes/base-0.mes: Move from ./base0.mes. * module/mes/base.mes: Move from top. * module/mes/elf.mes: Likewise. * module/mes/let-syntax.mes: Likewise. * module/mes/let.mes: Likewise. * module/mes/mes.mes: Likewise. * module/mes/quasiquote.mes: Likewise. * module/mes/repl.mes: Likewise. * module/mes/scm.mes: Likewise. * module/mes/syntax.mes: Likewise. * module/mes/lalr-0.mes: Move from lib/lalr.mes. * module/mes/lalr.mes: Move from lib/lalr.scm. * module/mes/match.mes: Move from lib/match.scm. * module/mes/record-0.mes: Move from lib/record.mes. * module/mes/record.mes: Move from lib/record.scm. * module/mes/test.mes: Move flom lib/. * module/rnrs/bytevectors.mes: Move from lib/rnrs. * module/srfi/srfi-0.mes: Move from lib/srfi. * module/srfi/srfi-1.mes: Likewise. * module/srfi/srfi-9.mes: Likewise. * module/language/c/lexer.mes: Move from ./c-lexer.scm. * module/language/c/parser.mes: Move from ./mescc.scm. * module/language/c/compiler.mes: New file, split from parser.mes. * module/language/paren.mes: Move from ./paren.scm. * module/mes/libc-i386.mes: New file, split from elf.mes. * tests/base.test: Move from test/. * tests/closure.test: Likewise. * tests/let-syntax.test: Likewise. * tests/let.test: Likewise. * tests/match.test: Likewise. * tests/quasiquote.test: Likewise. * tests/record.test: Likewise. * tests/scm.test: Likewise. * hello.S: Remove. * hello.c: Remove. * loop2.mes: Remove. * test/foo.test: Remove.
This commit is contained in:
parent
bd2b81755a
commit
d114634203
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,5 +10,3 @@
|
|||
/*.cat
|
||||
?
|
||||
?.mes
|
||||
/hello
|
||||
/hello.o
|
||||
|
|
121
GNUmakefile
121
GNUmakefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all check default
|
||||
.PHONY: all check clean default
|
||||
#CFLAGS:=-std=c99 -O0
|
||||
CFLAGS:=-std=c99 -O3 -finline-functions
|
||||
#CFLAGS:=-pg -std=c99 -O0
|
||||
|
@ -10,6 +10,9 @@ all: mes
|
|||
|
||||
mes: mes.c mes.h
|
||||
|
||||
clean:
|
||||
rm -f mes environment.i symbol.i mes.h *.cat a.out
|
||||
|
||||
mes.h: mes.c GNUmakefile
|
||||
( echo '#if MES_C'; echo '#if MES_FULL' 1>&2;\
|
||||
grep -E '^(scm [*])*[a-z0-9_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
|
||||
|
@ -38,98 +41,42 @@ mes.h: mes.c GNUmakefile
|
|||
|
||||
check: all guile-check mes-check
|
||||
|
||||
mes-check: all
|
||||
# ./mes.test
|
||||
# ./mes.test ./mes
|
||||
cat base0.mes base0-if.mes base.mes lib/test.mes test/base.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes lib/test.mes test/closure.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes lib/test.mes test/quasiquote.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/test.mes test/let.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/srfi/srfi-0.scm scm.mes lib/test.mes test/scm.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/srfi/srfi-0.scm scm.mes syntax.mes lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/test.mes test/record.test |./mes
|
||||
ifneq ($(SYNTAX),)
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/test.mes test/let-syntax.test | ./mes
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/match.scm lib/test.mes test/match.test | ./mes
|
||||
else
|
||||
@echo skipping slooowwww syntax tests
|
||||
endif
|
||||
TESTS:=\
|
||||
tests/base.test\
|
||||
tests/closure.test\
|
||||
tests/quasiquote.test\
|
||||
tests/let.test\
|
||||
tests/scm.test\
|
||||
tests/record.test\
|
||||
tests/let-syntax.test\
|
||||
tests/match.test\
|
||||
#
|
||||
|
||||
repl:
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/match.scm repl.mes /dev/stdin | ./mes
|
||||
BASE-0:=module/mes/base-0.mes
|
||||
MES-0:=guile/mes-0.scm
|
||||
MES:=./mes
|
||||
|
||||
mes-check: all
|
||||
for i in $(TESTS); do\
|
||||
cat $(BASE-0) $$(scripts/include.mes $$i) $$i | $(MES);\
|
||||
done
|
||||
|
||||
guile-check:
|
||||
guile -s <(cat base.mes lib/test.mes test/base.test)
|
||||
guile -s <(cat base.mes lib/test.mes test/closure.test)
|
||||
guile -s <(cat base.mes lib/test.mes test/quasiquote.test)
|
||||
guile -s <(cat quasiquote.mes lib/test.mes test/quasiquote.test)
|
||||
# guile -s <(cat base.mes quasiquote.mes let.mes lib/test.mes test/let.test)
|
||||
# guile -s <(cat base.mes let.mes test/foo.test)
|
||||
# exit 1
|
||||
guile -s <(cat lib/test.mes test/base.test)
|
||||
guile -s <(cat lib/test.mes test/quasiquote.test)
|
||||
guile -s <(cat lib/test.mes test/let.test)
|
||||
guile -s <(cat quasiquote.mes lib/test.mes test/base.test)
|
||||
guile -s <(cat quasiquote.mes lib/test.mes test/quasiquote.test)
|
||||
guile -s <(cat lib/test.mes test/record.test)
|
||||
guile -s <(cat lib/test.mes test/let-syntax.test)
|
||||
guile -s <(cat lib/test.mes test/match.test)
|
||||
|
||||
run: all
|
||||
cat scm.mes test.mes | ./mes
|
||||
|
||||
psyntax: all
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes psyntax.mes psyntax.pp psyntax2.mes | ./mes
|
||||
|
||||
syntax-case: all
|
||||
cat scm.mes syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes syntax-case-test.mes | ./mes
|
||||
|
||||
syntax-case.cat: syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes syntax-case-test.mes
|
||||
cat $^ > $@
|
||||
|
||||
guile-syntax-case: syntax-case.cat
|
||||
guile -s $^
|
||||
|
||||
peg: all
|
||||
cat scm.mes syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes peg.mes peg/codegen.scm peg/string-peg.scm peg/simplify-tree.scm peg/using-parsers.scm peg/cache.scm peg-test.mes | ./mes
|
||||
|
||||
peg.cat: peg/pmatch.scm peg.mes peg/codegen.scm peg/string-peg.scm peg/simplify-tree.scm peg/using-parsers.scm peg/cache.scm peg-test.mes
|
||||
cat $^ | sed 's,\(;; Packages the results of a parser\),(when (guile?) (set! compile-peg-pattern (@@ (ice-9 peg codegen) compile-peg-pattern)))\n\1,' > $@
|
||||
|
||||
guile-peg: peg.cat
|
||||
# guile -s peg-test.mes
|
||||
# @echo "======================================="
|
||||
guile -s $^
|
||||
|
||||
clean:
|
||||
rm -f mes environment.i symbol.i mes.h *.cat hello.o main.o a.out
|
||||
|
||||
paren: all
|
||||
echo -e 'EOF\n___P((()))' | cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm paren.scm - | ./mes
|
||||
|
||||
paren.cat: lib/lalr.scm paren.scm
|
||||
cat $^ > $@
|
||||
|
||||
guile-paren: paren.cat
|
||||
echo '___P((()))' | guile -s $^
|
||||
for i in $(TESTS); do\
|
||||
guile -s <(cat $(MES-0) $$(scripts/include.mes $$i | grep -Ev 'let.mes|quasiquote.mes|srfi-0') $$i);\
|
||||
done
|
||||
for i in $(TESTS); do\
|
||||
guile -s <(cat $(MES-0) module/mes/test.mes $$i);\
|
||||
done
|
||||
|
||||
mescc: all
|
||||
echo ' EOF ' | cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm lib/rnrs/bytevectors.scm lib/srfi/srfi-1.scm lib/match.scm lib/elf.mes c-lexer.scm mescc.scm - main.c | ./mes > a.out
|
||||
chmod +x a.out
|
||||
scripts/mescc.mes
|
||||
./a.out
|
||||
|
||||
mescc.cat: lib/lalr.scm lib/rnrs/bytevectors.scm lib/srfi/srfi-1.scm lib/match.scm lib/elf.mes c-lexer.scm mescc.scm
|
||||
cat $^ > $@
|
||||
mescc.cat: $(MES-0) module/mes/lalr.mes module/mes/elf.mes module/mes/libc-i386.mes $(shell scripts/include.mes scripts/mescc.mes | grep -Ev '/mes/|/srfi/')
|
||||
echo '(compile)' | cat $^ - > $@
|
||||
|
||||
guile-mescc: mescc.cat
|
||||
cat main.c | guile -s $^ > a.out
|
||||
chmod +x a.out
|
||||
|
||||
hello.o: hello.S
|
||||
as --32 -march=i386 -o $@ $^
|
||||
|
||||
hello: hello.o
|
||||
ld -A i386 -m elf_i386 -nostdlib -nodefaultlibs -A i386 -o $@ $^
|
||||
# ld -A i386 -m elf_i386 -A i386 -o $@ $^
|
||||
|
||||
a.out: lib/elf.mes elf.mes GNUmakefile
|
||||
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes lib/rnrs/bytevectors.scm lib/elf.mes elf.mes | ./mes > a.out
|
||||
cat doc/examples/main.c | guile -s $^ > a.out
|
||||
chmod +x a.out
|
||||
./a.out
|
||||
|
|
7
TODO
7
TODO
|
@ -62,6 +62,13 @@ http://www.muppetlabs.com/~breadbox/software/tiny/
|
|||
http://www.cirosantilli.com/elf-hello-world/
|
||||
|
||||
** SCM
|
||||
** RNRS
|
||||
http://www.scheme-reports.org/
|
||||
*** Scheme
|
||||
ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-349.pdf
|
||||
*** RRS
|
||||
ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf
|
||||
|
||||
http://groups.csail.mit.edu/mac/ftpdir/scm/OLD/scm2e.tar.Z
|
||||
wget http://groups.csail.mit.edu/mac/ftpdir/scm/OLD/scm3c13.tar.Z
|
||||
http://groups.csail.mit.edu/mac/ftpdir/scm/OLD/scm4a5.tar.Z
|
||||
|
|
31
guile/mes-0.scm
Normal file
31
guile/mes-0.scm
Normal file
|
@ -0,0 +1,31 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; mes-0.scm: 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:
|
||||
|
||||
;;; mes-0.scm is the first file being loaded into Guile. It provides
|
||||
;;; non-standard definitions that Mes modules and tests depend on.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-macro (mes-use-module . rest) #t)
|
||||
(define builtin? procedure?) ; not strictly true, but ok for tests/*.test
|
||||
(define guile? (not (pair? (current-module))))
|
||||
(define EOF (if #f #f))
|
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
exec guile -L $(pwd) -e '(mes)' -s "$0" "$@"
|
||||
exec guile -L $(pwd)/module -e '(mes)' -s "$0" "$@"
|
||||
!#
|
||||
|
||||
;;; Mes --- The Maxwell Equations of Software
|
||||
|
@ -97,7 +97,7 @@ exec guile -L $(pwd) -e '(mes)' -s "$0" "$@"
|
|||
(define number? guile:number?)
|
||||
(define call guile:apply)
|
||||
|
||||
(include "mes.mes")
|
||||
(include-from-path "mes/mes.mes")
|
||||
|
||||
(define (pairlis x y a)
|
||||
;;(debug "pairlis x=~a y=~a a=~a\n" x y a)
|
29
hello.S
29
hello.S
|
@ -1,29 +0,0 @@
|
|||
|
||||
.text # section declaration
|
||||
|
||||
# we must export the entry point to the ELF linker or
|
||||
.global _start # loader. They conventionally recognize _start as their
|
||||
# entry point. Use ld -e foo to override the default.
|
||||
|
||||
_start:
|
||||
|
||||
# write our string to stdout
|
||||
|
||||
movl $len,%edx # third argument: message length
|
||||
movl $msg,%ecx # second argument: pointer to message to write
|
||||
movl $1,%ebx # first argument: file handle (stdout)
|
||||
movl $4,%eax # system call number (sys_write)
|
||||
int $0x80 # call kernel
|
||||
|
||||
# and exit
|
||||
|
||||
movl $0,%ebx # first argument: exit code
|
||||
movl $1,%eax # system call number (sys_exit)
|
||||
int $0x80 # call kernel
|
||||
|
||||
.data # section declaration
|
||||
|
||||
msg:
|
||||
.ascii "Hello, world!\n" # our dear string
|
||||
len = . - msg # length of our dear string
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
(define pprint display)
|
||||
(define lalr-keyword? symbol?)
|
||||
(define-macro (BITS-PER-WORD) 30)
|
||||
(define-macro (logical-or x . y) `(logior ,x ,@y))
|
||||
(define-macro (lalr-error msg obj) `(error ,msg ,obj))
|
||||
(define (note-source-location lvalue tok) lvalue)
|
||||
(define *eoi* -1)
|
|
@ -1,6 +0,0 @@
|
|||
(define (unspecific) (if #f #f))
|
||||
(define make-record make-vector)
|
||||
(define record-set! vector-set!)
|
||||
(define record? vector?)
|
||||
(define (record-type x) (vector-ref x 0))
|
||||
(define record-ref vector-ref)
|
|
@ -1,22 +0,0 @@
|
|||
;; rnrs compatibility
|
||||
(define (bytevector-u32-native-set! bv index value)
|
||||
(when (not (= 0 index)) (error "bytevector-u32-native-set! index not zero: " index " value: " value))
|
||||
(let ((x (list
|
||||
(modulo value #x100)
|
||||
(quotient (modulo value #x10000) #x100)
|
||||
(quotient (modulo value #x1000000) #x10000)
|
||||
(quotient value #x1000000))))
|
||||
(set-car! bv (car x))
|
||||
(set-cdr! bv (cdr x))
|
||||
x))
|
||||
|
||||
(define (bytevector-u16-native-set! bv index value)
|
||||
(when (not (= 0 index)) (error "bytevector-u16-native-set! index not zero: " index " value: " value))
|
||||
(let ((x (list (modulo value #x100)
|
||||
(quotient (modulo value #x10000) #x100))))
|
||||
(set-car! bv (car x))
|
||||
(set-cdr! bv (cdr x))
|
||||
x))
|
||||
|
||||
(define (make-bytevector length)
|
||||
(make-list length 0))
|
|
@ -1,13 +0,0 @@
|
|||
(define mes '(0 1))
|
||||
|
||||
(define-macro (defined? x)
|
||||
`(assq ,x (cddr (current-module))))
|
||||
|
||||
(define (cond-expand-expander clauses)
|
||||
(let loop ((clauses clauses))
|
||||
(if (defined? (caar clauses))
|
||||
(eval (cons 'begin (cdar clauses)) (current-module))
|
||||
(loop (cdr clauses)))))
|
||||
|
||||
(define-macro (cond-expand . clauses)
|
||||
`(cond-expand-expander (quote ,clauses)))
|
|
@ -1,15 +0,0 @@
|
|||
(define (find pred lst)
|
||||
(let loop ((lst lst))
|
||||
(if (null? lst) #f
|
||||
(if (pred (car lst)) (car lst)
|
||||
(loop (cdr lst))))))
|
||||
|
||||
(define (filter pred lst)
|
||||
(let loop ((lst lst))
|
||||
(if (null? lst) '()
|
||||
(if (pred (car lst))
|
||||
(cons (car lst) (loop (cdr lst)))
|
||||
(loop (cdr lst))))))
|
||||
|
||||
(define (append-map f lst)
|
||||
(apply append (map f lst)))
|
|
@ -1,44 +0,0 @@
|
|||
;; Copyright (c) 1993 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
|
||||
;; There's no implicit name concatenation, so it can be defined
|
||||
;; entirely using syntax-rules. Example:
|
||||
;; (define-record-type foo
|
||||
;; (make-foo x y)
|
||||
;; foo? - predicate name is optional
|
||||
;; (x foo-x)
|
||||
;; (y foo-y)
|
||||
;; (z foo-z set-foo-z!))
|
||||
|
||||
;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
|
||||
(define-syntax define-record-type
|
||||
(syntax-rules ()
|
||||
((define-record-type type
|
||||
(constructor arg ...)
|
||||
(field . field-stuff)
|
||||
...)
|
||||
(begin (define type (make-record-type 'type '(field ...)))
|
||||
(define constructor (record-constructor type '(arg ...)))
|
||||
(define-accessors type (field . field-stuff) ...)))
|
||||
((define-record-type type
|
||||
(constructor arg ...)
|
||||
pred
|
||||
more ...)
|
||||
(begin (define-record-type type
|
||||
(constructor arg ...)
|
||||
more ...)
|
||||
(define pred (record-predicate type))))))
|
||||
|
||||
;; Straightforward version
|
||||
(define-syntax define-accessors
|
||||
(syntax-rules ()
|
||||
((define-accessors type field-spec ...)
|
||||
(begin (define-accessor type . field-spec) ...))))
|
||||
|
||||
(define-syntax define-accessor
|
||||
(syntax-rules ()
|
||||
((define-accessor type field accessor)
|
||||
(define accessor (record-accessor type 'field)))
|
||||
((define-accessor type field accessor modifier)
|
||||
(begin (define accessor (record-accessor type 'field))
|
||||
(define modifier (record-modifier type 'field))))))
|
53
loop2.mes
53
loop2.mes
|
@ -1,53 +0,0 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; loop.mes: 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/>.
|
||||
|
||||
;; The Maxwell Equations of Software -- John McCarthy page 13
|
||||
;; http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
|
||||
|
||||
(define (scm-define x a)
|
||||
(cond ((atom? (cadr x)) (cons (cadr x) (eval (caddr x) a)))
|
||||
(#t (cons (caadr x) (cons 'lambda (cons (cdadr x) (cddr x)))))))
|
||||
|
||||
(define (scm-define-macro x a)
|
||||
(cons '*macro*
|
||||
(cons (cons (caadr e) (cons 'lambda (cons (cdadr e) (cddr e))))
|
||||
(cdr (assq '*macro* a)))))
|
||||
|
||||
(define (loop2 r e a)
|
||||
;; (display '____loop2)
|
||||
;; (newline)
|
||||
;; (display 'e:)
|
||||
;; (display e)
|
||||
;; (newline)
|
||||
(cond ((null? e) r)
|
||||
((eq? e 'EOF2)
|
||||
(display 'loop2-exiting...)
|
||||
(newline))
|
||||
((atom? e)
|
||||
(loop2 (eval e a) (readenv a) a))
|
||||
((eq? (car e) 'define)
|
||||
(loop2 *unspecified* (readenv a) (cons (scm-define e a) a)))
|
||||
((eq? (car e) 'define-macro)
|
||||
(loop2 *unspecified* (readenv a) (cons (scm-define-macro e a) a)))
|
||||
((eq? (car e) 'set!)
|
||||
(loop2 (set-cdr! (assq (cadr e) a) (eval (caddr e) a)) (readenv a) a))
|
||||
(#t (loop2 (eval e a) (readenv a) a))))
|
||||
|
||||
'EOF
|
22
mes.test
22
mes.test
|
@ -1,22 +0,0 @@
|
|||
#! /bin/sh
|
||||
#set -x
|
||||
mes=${1-./mes.scm}
|
||||
echo 0 | $mes
|
||||
echo 1 | $mes
|
||||
echo "(car '(0 1))" | $mes
|
||||
echo "(car (quote (0 1)))" | $mes
|
||||
echo "(car '(0 1))" | $mes
|
||||
echo "(cdr '(0 1))" | $mes
|
||||
echo "(cons 0 1)" | $mes
|
||||
echo "((lambda (x y) (cons x y)) 0 1)" | $mes
|
||||
echo "(< 0 0)" | $mes
|
||||
echo "(< 0 1)" | $mes
|
||||
# LISP-1.5 label dropped for now
|
||||
# echo "((label fun\
|
||||
# (lambda (x) (cons x\
|
||||
# (cond ((< 0 x) (fun (- x 1)))\
|
||||
# (#t '())))))\
|
||||
# 3)" | $mes
|
||||
echo "'(0 . 1)" | $mes
|
||||
echo "(cdr '(0 . 1))" | $mes
|
||||
echo "(define (list . rest) rest)" | $mes
|
144
module/language/c/compiler.mes
Normal file
144
module/language/c/compiler.mes
Normal file
|
@ -0,0 +1,144 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; compiler.mes: 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:
|
||||
|
||||
;;; compiler.mes produces an i386 binary from the C produced by
|
||||
;;; c-parser.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define mescc
|
||||
(let ((errorp
|
||||
(lambda args
|
||||
(for-each display args)
|
||||
(newline))))
|
||||
(lambda ()
|
||||
(c-parser (c-lexer errorp) errorp))))
|
||||
|
||||
(define (write-any x) (write-char (if (char? x) x (integer->char (if (>= x 0) x (+ x 256))))))
|
||||
|
||||
(define (ast:function? o)
|
||||
(and (pair? o) (eq? (car o) 'function)))
|
||||
|
||||
(define (.name o)
|
||||
(cadr o))
|
||||
|
||||
;; (define (.statement o)
|
||||
;; (match o
|
||||
;; (('function name signature statement) statement)
|
||||
;; (_ #f)))
|
||||
|
||||
;; (define (statement->data o)
|
||||
;; (match o
|
||||
;; (('call 'puts ('arguments string)) (string->list string))
|
||||
;; (_ '())))
|
||||
|
||||
;; (define (statement->text o)
|
||||
;; (match o
|
||||
;; (('call 'puts ('arguments string)) (list (lambda (data) (i386:puts data (string-length string)))))
|
||||
;; (('return code) (list (lambda (data) (i386:exit code))))
|
||||
;; (_ '())))
|
||||
|
||||
(define (.statement o)
|
||||
(and (pair? o)
|
||||
(eq? (car o) 'function)
|
||||
(cadddr o)))
|
||||
|
||||
(define (statement->data o)
|
||||
(or (and (pair? o)
|
||||
(eq? (car o) 'call)
|
||||
(string->list (cadr (caddr o))))
|
||||
(and (pair? o) (eq? (car o) 'for)
|
||||
(let ((statement (cadr (cdddr o))))
|
||||
(statement->data statement)))
|
||||
'()))
|
||||
|
||||
(define (statement->text data o)
|
||||
(cond
|
||||
((and (pair? o) (eq? (car o) 'call))
|
||||
(let ((string (cadr (caddr o)))
|
||||
(offset (length data)))
|
||||
(list (lambda (data) (i386:puts (+ data offset) (string-length string))))))
|
||||
((and (pair? o) (eq? (car o) 'for))
|
||||
(let ((start (cadr o))
|
||||
(test (caddr o))
|
||||
(step (cadddr o))
|
||||
(statement (cadr (cdddr o))))
|
||||
(display "start:" (current-error-port))
|
||||
(display start (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "test:" (current-error-port))
|
||||
(display test (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "step:" (current-error-port))
|
||||
(display step (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "for-statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(let ((start (cadr (cdadr start)))
|
||||
(test (cadr (cdadr test)))
|
||||
;;(step (cadr (cdadr step)))
|
||||
(step 1)
|
||||
(statement (car (statement->text data statement)))
|
||||
)
|
||||
(display "2start:" (current-error-port))
|
||||
(display start (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "2for-statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(list (lambda (d) (i386:for start test step (statement d)))))))
|
||||
((and (pair? o) (eq? (car o) 'return))
|
||||
(list (lambda (data) (i386:exit (cadr o)))))
|
||||
(else '())))
|
||||
|
||||
(define (compile)
|
||||
(let* ((ast (mescc))
|
||||
(functions (filter ast:function? (cdr ast)))
|
||||
(main (find (lambda (x) (eq? (.name x) 'main)) functions))
|
||||
(statements (cdr (.statement main))))
|
||||
(display "program: " (current-error-port))
|
||||
(display ast (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(let loop ((statements statements) (text '()) (data '()))
|
||||
(display "text:" (current-error-port))
|
||||
(display text (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(if (null? statements)
|
||||
(begin
|
||||
(display "dumping to a.out:\n" (current-error-port))
|
||||
(map write-any (make-elf (lambda (data)
|
||||
(append-map (lambda (f) (f data)) text)) data)))
|
||||
(let* ((statement (car statements)))
|
||||
(display "statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(loop (cdr statements)
|
||||
(append text (statement->text data statement))
|
||||
(append data (statement->data statement))))))))
|
||||
|
|
@ -1,3 +1,30 @@
|
|||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; lexer.mes: 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:
|
||||
|
||||
;;; lexer.mes WIP rudimentary c-lexer based on Guile ECMAScript
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
|
||||
;;; ECMAScript for Guile
|
||||
|
||||
;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
|
@ -26,7 +53,7 @@
|
|||
|
||||
(cond-expand
|
||||
(guile
|
||||
;;(use-modules ((ice-9 rdelim)))
|
||||
;; (use-modules (ice-9 rdelim))
|
||||
|
||||
(define (syntax-error what loc form . args)
|
||||
(throw 'syntax-error #f what
|
|
@ -1,9 +1,56 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; parser.mes: 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:
|
||||
|
||||
;;; parser.mes is a translation of cgram.y to Dominique Boucher's LALR.
|
||||
;;; It parses a minimal int main () {}, see examples/main.c
|
||||
|
||||
;;; Code:
|
||||
|
||||
(cond-expand
|
||||
(guile
|
||||
;;(use-modules ((system base lalr)))
|
||||
)
|
||||
(use-modules (srfi srfi-1))
|
||||
;;(use-modules (system base lalr))
|
||||
(use-modules (ice-9 match)))
|
||||
(mes
|
||||
))
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes lalr-0))
|
||||
(mes-use-module (mes lalr))
|
||||
|
||||
(mes-use-module (mes let-syntax))
|
||||
(mes-use-module (srfi srfi-1))
|
||||
(mes-use-module (mes match))
|
||||
|
||||
(mes-use-module (rnrs bytevectors))
|
||||
(mes-use-module (mes elf))
|
||||
(mes-use-module (mes libc-i386))))
|
||||
|
||||
(define c-parser
|
||||
(lalr-parser
|
||||
|
@ -409,168 +456,3 @@
|
|||
(argument-expression-list
|
||||
(assignment-expression) : `(arguments ,$1)
|
||||
(argument-expression-list comma assignment-expression): `(,@$1 ,@(cdr $3)))))
|
||||
|
||||
(define (i386:exit code)
|
||||
`(
|
||||
#xbb ,@(int->bv32 code) ;; mov $code,%ebx
|
||||
#xb8 #x01 #x00 #x00 #x00 ;; mov $0x1,%eax
|
||||
#xcd #x80 ;; int $0x80
|
||||
))
|
||||
|
||||
(define (i386:puts data length)
|
||||
`(
|
||||
#xba ,@(int->bv32 length) ;; mov $length,%edx
|
||||
#xb9 ,@(int->bv32 data) ;; mov $data,%ecx
|
||||
#xbb #x01 #x00 #x00 #x00 ;; mov $0x1,%ebx
|
||||
#xb8 #x04 #x00 #x00 #x00 ;; mov $0x4,%eax
|
||||
#xcd #x80 ;; int $0x80
|
||||
))
|
||||
|
||||
(define (i386:for start test step statement)
|
||||
`(
|
||||
|
||||
;; b:
|
||||
#x89 #xe5 ;; mov %esp,%ebp
|
||||
;;21:
|
||||
#xc7 #x45 #xf4 ,@(int->bv32 start) ;; movl $start,-0xc(%ebp)
|
||||
;;28:
|
||||
#xeb ,(+ (length statement) 9) ;;x14 jmp 3e <main+0x3e>
|
||||
;;2a:
|
||||
;;#x83 #xec #x0c ;; sub $0xc,%esp
|
||||
|
||||
;; 9:
|
||||
#x55 ;; push %ebp
|
||||
|
||||
,@statement
|
||||
#x5d ;; pop %ebp
|
||||
;;2d:
|
||||
;;;;;;#x68 #x09 #x00 #x00 #x00 ;; push $0x9
|
||||
;;32:
|
||||
;;;;;;#xe8 #xfc #xff #xff #xff ;; call 33 <main+0x33>
|
||||
;;37:
|
||||
;;;;;;#x83 #xc4 #x10 ;; add $0x10,%esp
|
||||
;;3a:
|
||||
;;;;#x83 #x45 #xf4 ,step ;; addl $step,-0xc(%ebp)
|
||||
;;3e:
|
||||
;;;;#x83 #x7d #xf4 ,test ;; cmpl $test,-0xc(%ebp)
|
||||
#x81 #x45 #xf4 ,@(int->bv32 step) ;;addl $step,-0xc(%ebp)
|
||||
#x81 #x7d #xf4 ,@(int->bv32 test) ;;cmpl $0x7cff,-0xc(%ebp)
|
||||
;;42:
|
||||
;;;;#x7e ,(- 0 (length statement) 18) ;;#xe6 ;; jle 2a <main+0x2a>
|
||||
#x75 ,(- 0 (length statement) 18) ;;#xe6 ;; jne 2a <main+0x2a>
|
||||
))
|
||||
|
||||
|
||||
(define mescc
|
||||
(let ((errorp
|
||||
(lambda args
|
||||
(for-each display args)
|
||||
(newline))))
|
||||
(lambda ()
|
||||
(c-parser (c-lexer errorp) errorp))))
|
||||
|
||||
(define (write-any x) (write-char (if (char? x) x (integer->char (if (>= x 0) x (+ x 256))))))
|
||||
|
||||
(define (ast:function? o)
|
||||
(and (pair? o) (eq? (car o) 'function)))
|
||||
|
||||
(define (.name o)
|
||||
(cadr o))
|
||||
|
||||
;; (define (.statement o)
|
||||
;; (match o
|
||||
;; (('function name signature statement) statement)
|
||||
;; (_ #f)))
|
||||
|
||||
;; (define (statement->data o)
|
||||
;; (match o
|
||||
;; (('call 'puts ('arguments string)) (string->list string))
|
||||
;; (_ '())))
|
||||
|
||||
;; (define (statement->text o)
|
||||
;; (match o
|
||||
;; (('call 'puts ('arguments string)) (list (lambda (data) (i386:puts data (string-length string)))))
|
||||
;; (('return code) (list (lambda (data) (i386:exit code))))
|
||||
;; (_ '())))
|
||||
|
||||
(define (.statement o)
|
||||
(and (pair? o)
|
||||
(eq? (car o) 'function)
|
||||
(cadddr o)))
|
||||
|
||||
(define (statement->data o)
|
||||
(or (and (pair? o)
|
||||
(eq? (car o) 'call)
|
||||
(string->list (cadr (caddr o))))
|
||||
(and (pair? o) (eq? (car o) 'for)
|
||||
(let ((statement (cadr (cdddr o))))
|
||||
(statement->data statement)))
|
||||
'()))
|
||||
|
||||
(define (statement->text data o)
|
||||
(cond
|
||||
((and (pair? o) (eq? (car o) 'call))
|
||||
(let ((string (cadr (caddr o)))
|
||||
(offset (length data)))
|
||||
(list (lambda (data) (i386:puts (+ data offset) (string-length string))))))
|
||||
((and (pair? o) (eq? (car o) 'for))
|
||||
(let ((start (cadr o))
|
||||
(test (caddr o))
|
||||
(step (cadddr o))
|
||||
(statement (cadr (cdddr o))))
|
||||
(display "start:" (current-error-port))
|
||||
(display start (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "test:" (current-error-port))
|
||||
(display test (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "step:" (current-error-port))
|
||||
(display step (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "for-statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(let ((start (cadr (cdadr start)))
|
||||
(test (cadr (cdadr test)))
|
||||
;;(step (cadr (cdadr step)))
|
||||
(step 1)
|
||||
(statement (car (statement->text data statement)))
|
||||
)
|
||||
(display "2start:" (current-error-port))
|
||||
(display start (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(display "2for-statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
|
||||
(list (lambda (d) (i386:for start test step (statement d)))))))
|
||||
((and (pair? o) (eq? (car o) 'return))
|
||||
(list (lambda (data) (i386:exit (cadr o)))))
|
||||
(else '())))
|
||||
|
||||
(let* ((ast (mescc))
|
||||
(functions (filter ast:function? (cdr ast)))
|
||||
(main (find (lambda (x) (eq? (.name x) 'main)) functions))
|
||||
(statements (cdr (.statement main))))
|
||||
(display "program: " (current-error-port))
|
||||
(display ast (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(let loop ((statements statements) (text '()) (data '()))
|
||||
(display "text:" (current-error-port))
|
||||
(display text (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(if (null? statements)
|
||||
(map write-any (make-elf (lambda (data)
|
||||
(append-map (lambda (f) (f data)) text)) data))
|
||||
(let* ((statement (car statements)))
|
||||
(display "statement:" (current-error-port))
|
||||
(display statement (current-error-port))
|
||||
(newline (current-error-port))
|
||||
(loop (cdr statements)
|
||||
(append text (statement->text data statement))
|
||||
(append data (statement->data statement)))))))
|
|
@ -1,3 +1,56 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2008 Derek Peschel
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; paren.mes: 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:
|
||||
|
||||
;;; paren.mes is a simple yet full lalr test for Mes taken from the
|
||||
;;; Gambit wiki.
|
||||
;;;
|
||||
;;; Run with Guile:
|
||||
;;; echo '___P((()))' | guile -s <(echo '(paren-depth)' | cat cc/paren.mes -)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(cond-expand
|
||||
(guile
|
||||
(use-modules (system base lalr))
|
||||
)
|
||||
(mes
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes lalr-0))
|
||||
(mes-use-module (mes lalr))
|
||||
))
|
||||
|
||||
;;; Taken from http://gambitscheme.org/wiki/index.php/Lalr_example
|
||||
;;; LGPL 2.1 / Apache 2.0
|
||||
|
||||
;;; Read C source code, breaking it into the following types of tokens:
|
||||
;;; the identifier ___P, other identifiers, left and right parentheses,
|
||||
;;; and any other non-spacing character. White space (space, tab, and
|
||||
|
@ -134,5 +187,3 @@
|
|||
(newline))))
|
||||
(lambda ()
|
||||
(paren-depth-parser (paren-depth-lexer errorp) errorp))))
|
||||
|
||||
(paren-depth)
|
|
@ -3,7 +3,7 @@
|
|||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; base.mes: This file is part of Mes.
|
||||
;;; base-0.mes: 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
|
||||
|
@ -18,6 +18,33 @@
|
|||
;;; 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 eval eval-env)
|
||||
(define (apply f x) (apply-env f x (current-module)))
|
||||
(define (primitive-eval e) (eval-env e (current-module)))
|
||||
(define (expand-macro e) (expand-macro-env e (current-module)))
|
||||
|
||||
(define quotient /)
|
||||
|
||||
(define-macro (defined? x)
|
||||
(list 'assq x '(cddr (current-module))))
|
||||
|
||||
(define (current-input-port) 0)
|
||||
(define (current-output-port) 1)
|
||||
(define (current-error-port) 2)
|
||||
(define (port-filename port) "<stdin>")
|
||||
(define (port-line port) 0)
|
||||
(define (port-column port) 0)
|
||||
(define (ftell port) 0)
|
||||
(define (false-if-exception x) x)
|
||||
|
||||
(define (cons* x . rest)
|
||||
(define (loop rest)
|
||||
(if (null? (cdr rest)) (car rest)
|
||||
|
@ -38,3 +65,12 @@
|
|||
(list 'if (car (car clauses))
|
||||
(cons* 'begin (car (car clauses)) (cdr (car clauses)))
|
||||
(cons* 'cond (cdr clauses))))))))
|
||||
|
||||
(define else #t)
|
||||
|
||||
(define-macro (simple-let bindings . rest)
|
||||
(cons (cons 'lambda (cons (map car bindings) rest))
|
||||
(map cadr bindings)))
|
||||
|
||||
(define-macro (let bindings . rest)
|
||||
(cons* 'simple-let bindings rest))
|
|
@ -18,56 +18,58 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define (identity x) x)
|
||||
(define else #t)
|
||||
|
||||
;; IF based
|
||||
;;; Commentary:
|
||||
|
||||
;;; base.mes is being loaded after base0.mes. It provides the minimal
|
||||
;;; set of scheme primitives to run lib/test.mes. It is safe to be
|
||||
;;; run by Guile.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-macro (mes-use-module . rest) #t)
|
||||
|
||||
(define (identity x) x)
|
||||
|
||||
(define-macro (or . x)
|
||||
(if (null? x) #f ;; IF
|
||||
(if (null? (cdr x)) (car x) ;; IF
|
||||
(if (null? x) #f
|
||||
(if (null? (cdr x)) (car x)
|
||||
(list 'if (car x) (car x)
|
||||
(cons* 'or (cdr x))))))
|
||||
|
||||
(define-macro (and . x)
|
||||
(if (null? x) #t ;; IF
|
||||
(if (null? (cdr x)) (car x) ;; IF
|
||||
(list 'if (car x) (cons 'and (cdr x)) ;; IF
|
||||
(if (null? x) #t
|
||||
(if (null? (cdr x)) (car x)
|
||||
(list 'if (car x) (cons 'and (cdr x))
|
||||
#f))))
|
||||
|
||||
(define (not x)
|
||||
(if x #f #t))
|
||||
|
||||
(define (equal? a b) ;; FIXME: only 2 arg
|
||||
(if (and (null? a) (null? b)) #t ;; IF
|
||||
(if (and (null? a) (null? b)) #t
|
||||
(if (and (pair? a) (pair? b))
|
||||
(and (equal? (car a) (car b))
|
||||
(equal? (cdr a) (cdr b)))
|
||||
(if (and (string? a) (string? b)) ;; IF
|
||||
(if (and (string? a) (string? b))
|
||||
(eq? (string->symbol a) (string->symbol b))
|
||||
(if (and (vector? a) (vector? b)) ;; IF
|
||||
(if (and (vector? a) (vector? b))
|
||||
(equal? (vector->list a) (vector->list b))
|
||||
(eq? a b))))))
|
||||
|
||||
(define (memq x lst)
|
||||
(if (null? lst) #f ;; IF
|
||||
(if (eq? x (car lst)) lst ;; IF
|
||||
(if (null? lst) #f
|
||||
(if (eq? x (car lst)) lst
|
||||
(memq x (cdr lst)))))
|
||||
|
||||
(define guile? (not (pair? (current-module))))
|
||||
|
||||
(define (map f l . r)
|
||||
(if (null? l) '() ;; IF
|
||||
(if (null? r) (cons (f (car l)) (map f (cdr l))) ;; IF
|
||||
(if (null? (cdr r)) ;; IF
|
||||
(if (null? l) '()
|
||||
(if (null? r) (cons (f (car l)) (map f (cdr l)))
|
||||
(if (null? (cdr r))
|
||||
(cons (f (car l) (caar r)) (map f (cdr l) (cdar r)))))))
|
||||
|
||||
(define-macro (simple-let bindings . rest)
|
||||
(cons (cons 'lambda (cons (map car bindings) rest))
|
||||
(map cadr bindings)))
|
||||
|
||||
(define-macro (let bindings . rest)
|
||||
(cons* 'simple-let bindings rest))
|
||||
|
||||
(define (list? x)
|
||||
(or (null? x)
|
||||
(and (pair? x) (list? (cdr x)))))
|
|
@ -3,7 +3,7 @@
|
|||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; scm.mes: This file is part of Mes.
|
||||
;;; elf.mes: 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
|
||||
|
@ -18,6 +18,12 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; elf.mes - produce a i386 elf executable.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (int->bv32 value)
|
||||
(let ((bv (make-bytevector 4)))
|
||||
(bytevector-u32-native-set! bv 0 value)
|
33
module/mes/lalr-0.mes
Normal file
33
module/mes/lalr-0.mes
Normal file
|
@ -0,0 +1,33 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; lalr-0.mes: 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:
|
||||
|
||||
;;; lalr-0.mes has mes-specific definitions needed for lalr.mes
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define pprint display)
|
||||
(define lalr-keyword? symbol?)
|
||||
(define-macro (BITS-PER-WORD) 30)
|
||||
(define-macro (logical-or x . y) `(logior ,x ,@y))
|
||||
(define-macro (lalr-error msg obj) `(error ,msg ,obj))
|
||||
(define (note-source-location lvalue tok) lvalue)
|
||||
(define *eoi* -1)
|
|
@ -1783,6 +1783,7 @@
|
|||
(usual-integrations)
|
||||
(fixnum)
|
||||
(not safe)))
|
||||
(guile)
|
||||
(else))
|
||||
|
||||
|
|
@ -18,6 +18,13 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; let-syntax.mes is loaded after syntax.mes. It provides the R5RS
|
||||
;;; hygienic macro let-syntax.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-macro (let-syntax bindings . rest)
|
||||
`((lambda ()
|
||||
,@(map (lambda (binding)
|
|
@ -3,7 +3,7 @@
|
|||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; scm.mes: This file is part of Mes.
|
||||
;;; libc-i386.mes: 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
|
||||
|
@ -18,6 +18,12 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; libc-i386.mes defines C library routines
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (i386:puts data length)
|
||||
`(
|
||||
#xba ,@(int->bv32 length) ;; mov $0xe,%edx
|
||||
|
@ -67,16 +73,3 @@
|
|||
;;;#x7e ,(- 0 (length statement) 18) ;;#xe6 ;; jle 2a <main+0x2a>
|
||||
#x75 ,(- 0 (length statement) 18) ;;#xe6 ;; jne 2a <main+0x2a>
|
||||
))
|
||||
|
||||
(define data
|
||||
(string->list "Hello, world!\n"))
|
||||
|
||||
(define (text d)
|
||||
(append
|
||||
(i386:puts d (length data))
|
||||
(i386:for 0 3 1 (i386:puts (+ d 6) (- (length data) 6)))
|
||||
(i386:exit 0)
|
||||
))
|
||||
|
||||
(define (write-any x) (write-char (if (char? x) x (integer->char x))))
|
||||
(map write-any (make-elf text data))
|
|
@ -1,4 +1,4 @@
|
|||
;;;; match.scm -- portable hygienic pattern matcher -*- coding: utf-8 -*-
|
||||
;;; match.scm -- portable hygienic pattern matcher -*- coding: utf-8; mode: scheme -*-
|
||||
;;
|
||||
;; This code is written by Alex Shinn and placed in the
|
||||
;; Public Domain. All warranties are disclaimed.
|
|
@ -18,7 +18,7 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-macro (works-but-sloooooow-quasiquote x)
|
||||
(define-macro (slow...quasiquote x)
|
||||
(define (check x)
|
||||
(cond ((pair? (cdr x)) (cond ((null? (cddr x)))
|
||||
(#t (error (car x) "invalid form ~s" x))))))
|
|
@ -3,7 +3,7 @@
|
|||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; base0.mes: This file is part of Mes.
|
||||
;;; record-0.mes: 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
|
||||
|
@ -18,9 +18,15 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-macro (defined? x)
|
||||
(list 'assq x '(cddr (current-module))))
|
||||
;;; Commentary:
|
||||
|
||||
(define (current-input-port) 0)
|
||||
(define (current-output-port) 1)
|
||||
(define (current-error-port) 2)
|
||||
;;; record-0.mes mes-specific definitions needed for record.mes
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (unspecific) (if #f #f))
|
||||
(define make-record make-vector)
|
||||
(define record-set! vector-set!)
|
||||
(define record? vector?)
|
||||
(define (record-type x) (vector-ref x 0))
|
||||
(define record-ref vector-ref)
|
|
@ -1,4 +1,60 @@
|
|||
; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees.
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; syntax.mes: 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:
|
||||
|
||||
;;; record.mes is loaded after record-0.mes. It provides a
|
||||
;;; nonstandard record type that SRFI-9 can be trivially implemented
|
||||
;;; on. Adapted from scheme48-1.1/scheme/rts/record.scm
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
|
||||
;;; scheme48-1.1/COPYING
|
||||
|
||||
;; Copyright (c) 1993-2004 Richard Kelsey and Jonathan Rees
|
||||
;; All rights reserved.
|
||||
|
||||
;; Redistribution and use in source and binary forms, with or without
|
||||
;; modification, are permitted provided that the following conditions
|
||||
;; are met:
|
||||
;; 1. Redistributions of source code must retain the above copyright
|
||||
;; notice, this list of conditions and the following disclaimer.
|
||||
;; 2. Redistributions in binary form must reproduce the above copyright
|
||||
;; notice, this list of conditions and the following disclaimer in the
|
||||
;; documentation and/or other materials provided with the distribution.
|
||||
;; 3. The name of the authors may not be used to endorse or promote products
|
||||
;; derived from this software without specific prior written permission.
|
||||
|
||||
;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
;;;; Records
|
||||
|
||||
|
@ -200,4 +256,3 @@
|
|||
(list 'record-type
|
||||
(record-type-uid rt)
|
||||
(record-type-name rt))))
|
||||
|
|
@ -1,5 +1,29 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; repl.mes: 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:
|
||||
|
||||
;;; repl.mes defines repl, a repl for Mes.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define welcome
|
||||
"Mes 0.0
|
||||
Copyright (C) 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
|
@ -124,9 +148,6 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|||
(meta (cadr sexp))
|
||||
(loop a))
|
||||
(let ((e (eval-env sexp a)))
|
||||
(display "NOT UNQUOTE")
|
||||
(display (car sexp))
|
||||
(newline)
|
||||
(if (eq? e *unspecified*) (loop a)
|
||||
(let ((id (string->symbol (string-append "$" (number->string count)))))
|
||||
(set! count (+ count 1))
|
||||
|
@ -135,5 +156,3 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|||
(display e)
|
||||
(newline)
|
||||
(loop (acons id e a)))))))))))
|
||||
(repl)
|
||||
()
|
23
scm.mes → module/mes/scm.mes
Executable file → Normal file
23
scm.mes → module/mes/scm.mes
Executable file → Normal file
|
@ -18,13 +18,17 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; scm.mes is loaded after base, quasiquote and let. It provides
|
||||
;;; basic Scheme functions bringing Mes close to basic RRS Scheme (no
|
||||
;;; labels, processes, fluids or throw/catch).
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (cadddr x) (car (cdddr x)))
|
||||
|
||||
(define (list . rest) rest)
|
||||
(define eval eval-env)
|
||||
(define (apply f x) (apply-env f x (current-module)))
|
||||
(define (primitive-eval e) (eval-env e (current-module)))
|
||||
(define (expand-macro e) (expand-macro-env e (current-module)))
|
||||
|
||||
(define-macro (case val . args)
|
||||
(if (null? args)
|
||||
|
@ -125,10 +129,8 @@
|
|||
;; (if (apply = rest) #t
|
||||
;; #f)))
|
||||
|
||||
(define quotient /)
|
||||
|
||||
(define (remainder x y)
|
||||
(- x (* (/ x y) y)))
|
||||
(- x (* (quotient x y) y)))
|
||||
|
||||
(define (expt x y)
|
||||
(let loop ((s 1) (count y))
|
||||
|
@ -203,10 +205,3 @@
|
|||
(and (char? x)
|
||||
(let ((i (char->integer x)))
|
||||
(and (>= i (char->integer #\0)) (<= i (char->integer #\9))))))
|
||||
|
||||
(define (current-input-port) #f)
|
||||
(define (port-filename port) "<stdin>")
|
||||
(define (port-line port) 0)
|
||||
(define (port-column port) 0)
|
||||
(define (ftell port) 0)
|
||||
(define (false-if-exception x) x)
|
|
@ -1,5 +1,32 @@
|
|||
;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees.
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; syntax.mes: 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:
|
||||
|
||||
;;; syntax.mes is loaded after scm.mes. It provides the R5RS hygienic
|
||||
;;; macros define-syntax, syntax-rules and define-syntax-rule.
|
||||
;;; syntax-rules is adapted from scheme48-1.1/scheme/alt/syntax.scm
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (syntax-error message thing)
|
||||
(display "syntax-error:" (current-error-port))
|
||||
(display message (current-error-port))
|
||||
|
@ -10,8 +37,6 @@
|
|||
(define (silent-syntax-error message thing)
|
||||
*unspecified*)
|
||||
|
||||
;;; Adapted from scheme48-1.1/scheme/alt/syntax.scm
|
||||
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
|
||||
;;; scheme48-1.1/COPYING
|
|
@ -18,6 +18,13 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; test.mes can be loaded after base.mes. It provides a minimalistic
|
||||
;;; test framework: pass-if, pass-if-not, seq?, sequal? and result.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define guile? (not (pair? (current-module))))
|
||||
|
||||
(define result
|
48
module/rnrs/bytevectors.mes
Normal file
48
module/rnrs/bytevectors.mes
Normal file
|
@ -0,0 +1,48 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; bytevectors.mes: 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:
|
||||
|
||||
;;; bytevectors.mes
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; rnrs compatibility
|
||||
(define (bytevector-u32-native-set! bv index value)
|
||||
(when (not (= 0 index)) (error "bytevector-u32-native-set! index not zero: " index " value: " value))
|
||||
(let ((x (list
|
||||
(modulo value #x100)
|
||||
(quotient (modulo value #x10000) #x100)
|
||||
(quotient (modulo value #x1000000) #x10000)
|
||||
(quotient value #x1000000))))
|
||||
(set-car! bv (car x))
|
||||
(set-cdr! bv (cdr x))
|
||||
x))
|
||||
|
||||
(define (bytevector-u16-native-set! bv index value)
|
||||
(when (not (= 0 index)) (error "bytevector-u16-native-set! index not zero: " index " value: " value))
|
||||
(let ((x (list (modulo value #x100)
|
||||
(quotient (modulo value #x10000) #x100))))
|
||||
(set-car! bv (car x))
|
||||
(set-cdr! bv (cdr x))
|
||||
x))
|
||||
|
||||
(define (make-bytevector length)
|
||||
(make-list length 0))
|
36
module/srfi/srfi-0.mes
Normal file
36
module/srfi/srfi-0.mes
Normal file
|
@ -0,0 +1,36 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; srfi-0.mes: 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:
|
||||
|
||||
;;; srfi-0.mes - cond-expand
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define mes '(0 1))
|
||||
|
||||
(define (cond-expand-expander clauses)
|
||||
(let loop ((clauses clauses))
|
||||
(if (defined? (caar clauses))
|
||||
(eval (cons 'begin (cdar clauses)) (current-module))
|
||||
(loop (cdr clauses)))))
|
||||
|
||||
(define-macro (cond-expand . clauses)
|
||||
`(cond-expand-expander (quote ,clauses)))
|
41
module/srfi/srfi-1.mes
Normal file
41
module/srfi/srfi-1.mes
Normal file
|
@ -0,0 +1,41 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; srfi-1.mes: 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:
|
||||
|
||||
;;; srfi-1.mes is the miminimal srfi-1 needed to run mescc.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define (find pred lst)
|
||||
(let loop ((lst lst))
|
||||
(if (null? lst) #f
|
||||
(if (pred (car lst)) (car lst)
|
||||
(loop (cdr lst))))))
|
||||
|
||||
(define (filter pred lst)
|
||||
(let loop ((lst lst))
|
||||
(if (null? lst) '()
|
||||
(if (pred (car lst))
|
||||
(cons (car lst) (loop (cdr lst)))
|
||||
(loop (cdr lst))))))
|
||||
|
||||
(define (append-map f lst)
|
||||
(apply append (map f lst)))
|
100
module/srfi/srfi-9.mes
Normal file
100
module/srfi/srfi-9.mes
Normal file
|
@ -0,0 +1,100 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees.
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; base-0.mes: 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:
|
||||
|
||||
;;; srfi-9.mes - records. Assumes record-0.mes and record.mes are
|
||||
;;; available. Modified from
|
||||
;;; scheme48-1.1/scheme/alt/jar-defrecord.scm to implement SRFI-9.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Copyright (c) 1993-2004 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
||||
|
||||
;;; scheme48-1.1/COPYING
|
||||
|
||||
;; Copyright (c) 1993-2004 Richard Kelsey and Jonathan Rees
|
||||
;; All rights reserved.
|
||||
|
||||
;; Redistribution and use in source and binary forms, with or without
|
||||
;; modification, are permitted provided that the following conditions
|
||||
;; are met:
|
||||
;; 1. Redistributions of source code must retain the above copyright
|
||||
;; notice, this list of conditions and the following disclaimer.
|
||||
;; 2. Redistributions in binary form must reproduce the above copyright
|
||||
;; notice, this list of conditions and the following disclaimer in the
|
||||
;; documentation and/or other materials provided with the distribution.
|
||||
;; 3. The name of the authors may not be used to endorse or promote products
|
||||
;; derived from this software without specific prior written permission.
|
||||
|
||||
;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
; This is JAR's define-record-type, which doesn't resemble Richard's.
|
||||
|
||||
; There's no implicit name concatenation, so it can be defined
|
||||
; entirely using syntax-rules. Example:
|
||||
; (define-record-type foo :foo
|
||||
; (make-foo x y)
|
||||
; foo? - predicate name is optional
|
||||
; (x foo-x)
|
||||
; (y foo-y)
|
||||
; (z foo-z set-foo-z!))
|
||||
|
||||
(define-syntax define-record-type
|
||||
(syntax-rules ()
|
||||
((define-record-type type
|
||||
(constructor arg ...)
|
||||
(field . field-stuff)
|
||||
...)
|
||||
(begin (define type (make-record-type 'type '(field ...)))
|
||||
(define constructor (record-constructor type '(arg ...)))
|
||||
(define-accessors type (field . field-stuff) ...)))
|
||||
((define-record-type type
|
||||
(constructor arg ...)
|
||||
pred
|
||||
more ...)
|
||||
(begin (define-record-type type
|
||||
(constructor arg ...)
|
||||
more ...)
|
||||
(define pred (record-predicate type))))))
|
||||
|
||||
;; Straightforward version
|
||||
(define-syntax define-accessors
|
||||
(syntax-rules ()
|
||||
((define-accessors type field-spec ...)
|
||||
(begin (define-accessor type . field-spec) ...))))
|
||||
|
||||
(define-syntax define-accessor
|
||||
(syntax-rules ()
|
||||
((define-accessor type field accessor)
|
||||
(define accessor (record-accessor type 'field)))
|
||||
((define-accessor type field accessor modifier)
|
||||
(begin (define accessor (record-accessor type 'field))
|
||||
(define modifier (record-modifier type 'field))))))
|
49
scripts/elf.mes
Executable file
49
scripts/elf.mes
Executable file
|
@ -0,0 +1,49 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
cat $($(dirname $0)/include.mes $0) $0 /dev/stdin | ./mes > a.out
|
||||
chmod +x a.out
|
||||
exit $?
|
||||
!#
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; elf.mes: 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/>.
|
||||
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (rnrs bytevectors))
|
||||
(mes-use-module (mes elf))
|
||||
(mes-use-module (mes libc-i386))
|
||||
|
||||
(define data
|
||||
(string->list "Hello, world!\n"))
|
||||
|
||||
(define (text d)
|
||||
(append
|
||||
(i386:puts d (length data))
|
||||
(i386:for 0 3 1 (i386:puts (+ d 6) (- (length data) 6)))
|
||||
(i386:exit 0)
|
||||
))
|
||||
|
||||
(define (write-any x) (write-char (if (char? x) x (integer->char x))))
|
||||
|
||||
(display "dumping to a.out:\n" (current-error-port))
|
||||
(map write-any (make-elf text data))
|
||||
()
|
6
scripts/include.mes
Executable file
6
scripts/include.mes
Executable file
|
@ -0,0 +1,6 @@
|
|||
#! /bin/sh
|
||||
|
||||
cat $1 \
|
||||
| grep -Eo '(mes-use-module \([^()]+ [^()]+))' \
|
||||
| grep -Eo ' \([^)]+\)' \
|
||||
| sed -e 's@^ *(@module/@' -e 's@ @/@g' -e 's@)@.mes@'
|
58
scripts/mescc.mes
Executable file
58
scripts/mescc.mes
Executable file
|
@ -0,0 +1,58 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
cat cc/main.c | cat $($(dirname $0)/include.mes $0) cc/c-lexer.mes cc/mescc.mes $0 /dev/stdin | ./mes > a.out
|
||||
chmod +x a.out
|
||||
exit $?
|
||||
!#
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; mescc.mes: 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:
|
||||
|
||||
;;; mescc.mes is a proof-of-concept simplistic C compiler and linker
|
||||
;;;
|
||||
;;; Run with Guile:
|
||||
;;; make guile-mescc
|
||||
;;; BROKEN? cat cc/main.c | guile -s <(echo '(compile)' | cat guile/mes-0.scm module/mes/lalr.mes module/rnrs/bytevectors.mes module/srfi/srfi-1.mes module/mes/elf.mes module/mes/libc-i386.mes cc/c-lexer.mes cc/mescc.mes -)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes lalr-0))
|
||||
(mes-use-module (mes lalr))
|
||||
|
||||
(mes-use-module (mes let-syntax))
|
||||
(mes-use-module (srfi srfi-1))
|
||||
(mes-use-module (mes match))
|
||||
|
||||
(mes-use-module (rnrs bytevectors))
|
||||
(mes-use-module (mes elf))
|
||||
(mes-use-module (mes libc-i386))
|
||||
|
||||
(compile)
|
||||
()
|
51
scripts/paren.mes
Executable file
51
scripts/paren.mes
Executable file
|
@ -0,0 +1,51 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
echo -e 'EOF\n___P((()))' | cat $($(dirname $0)/include.mes $0) cc/paren.mes $0 /dev/stdin | ./mes
|
||||
chmod +x a.out
|
||||
exit $?
|
||||
!#
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2008 Derek Peschel
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; paren.mes: 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:
|
||||
|
||||
;;; paren.mes is a simple yet full lalr test for Mes taken from the
|
||||
;;; Gambit wiki.
|
||||
;;;
|
||||
;;; Run with Guile:
|
||||
;;; echo '___P((()))' | guile -s <(echo '(paren-depth)' | cat cc/paren.mes -)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes lalr-0))
|
||||
(mes-use-module (mes lalr))
|
||||
|
||||
(paren-depth)
|
||||
()
|
37
scripts/repl.mes
Executable file
37
scripts/repl.mes
Executable file
|
@ -0,0 +1,37 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
cat $($(dirname $0)/include.mes $0) $0 /dev/stdin | ./mes
|
||||
exit $?
|
||||
!#
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; repl.mes: 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/>.
|
||||
|
||||
(mes-use-module (mes base-0))
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (mes let-syntax))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes match))
|
||||
(mes-use-module (mes repl))
|
||||
|
||||
(repl)
|
||||
()
|
|
@ -1,6 +0,0 @@
|
|||
(display (let () 0))
|
||||
(newline)
|
||||
(display (let ((x 0)) x))
|
||||
(newline)
|
||||
(display (let loop ((x 0)) 0))
|
||||
(newline)
|
|
@ -18,6 +18,9 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
||||
|
|
@ -1,3 +1,29 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; closure.test: 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/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
||||
|
||||
(define b 0)
|
||||
(define x (lambda () b))
|
||||
(define (x) b)
|
|
@ -18,6 +18,14 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (mes let-syntax))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
||||
|
|
@ -18,6 +18,11 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
||||
|
|
@ -18,6 +18,19 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes let-syntax))
|
||||
(mes-use-module (mes match))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(when guile?
|
||||
(use-modules (ice-9 match))
|
||||
)
|
||||
|
@ -54,11 +67,16 @@
|
|||
'(0)))
|
||||
|
||||
(pass-if "match list 2"
|
||||
(sequal?
|
||||
(match (list 1 2 3) ((1 b c) (list b c)))
|
||||
'(2 3)))
|
||||
|
||||
(pass-if "match unquote"
|
||||
(sequal?
|
||||
(match (list 1 2 3) (`(1 ,b ,c) (list b c)))
|
||||
'(2 3)))
|
||||
|
||||
(pass-if "match list 3"
|
||||
(pass-if "match x-hygiene"
|
||||
(seq?
|
||||
(match '(0 1 2)
|
||||
((0 x y) (+ x y))
|
|
@ -18,6 +18,10 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
||||
|
|
@ -18,9 +18,19 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes syntax))
|
||||
(mes-use-module (mes record-0))
|
||||
(mes-use-module (mes record))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(when guile?
|
||||
(use-modules (srfi srfi-9))
|
||||
)
|
||||
(use-modules (srfi srfi-9)))
|
||||
|
||||
(pass-if "first dummy" #t)
|
||||
(pass-if-not "second dummy" #f)
|
|
@ -18,6 +18,13 @@
|
|||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (mes quasiquote))
|
||||
(mes-use-module (mes let))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
(mes-use-module (mes scm))
|
||||
(mes-use-module (mes test))
|
||||
|
||||
(when guile?
|
||||
(module-define! (current-module) 'builtin? (lambda (. x) #t))
|
||||
(use-modules (srfi srfi-1))
|
Loading…
Reference in a new issue