mes.c: barf on unknown symbols.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-23 11:51:06 +02:00
parent b8a7bb4486
commit b63444d919
3 changed files with 15 additions and 24 deletions

7
mes.c
View file

@ -309,7 +309,7 @@ eval (scm *e, scm *a)
if (e->type == SYMBOL) {
scm *y = assq (e, a);
if (y == &scm_f) {
return e;
//return e;
printf ("eval: no such symbol: %s\n", e->name);
assert (!"unknown symbol");
}
@ -1108,6 +1108,11 @@ mes_environment ()
{
scm *a = &scm_nil;
a = cons (cons (&scm_f, &scm_f), a);
a = cons (cons (&scm_nil, &scm_nil), a);
a = cons (cons (&scm_t, &scm_t), a);
a = cons (cons (&scm_unspecified, &scm_unspecified), a);
#include "environment.i"
return a;

View file

@ -199,6 +199,8 @@
(set! counter (+ counter 1))
(string->symbol (string-append "g" value))))))
()
;; srfi-1
(define (last-pair lst)
(let loop ((lst lst))

View file

@ -41,7 +41,7 @@
(display "mes:define-syntax...")
(define-macro (mes:define-syntax macro-name transformer . stuff)
(define-macro (define-syntax macro-name transformer . stuff)
`(define-macro (,macro-name . args)
(,transformer (cons ',macro-name args)
(lambda (x) x)
@ -63,7 +63,7 @@
(display "mes:define-syntax syntax-rules...")
(newline)
(mes:define-syntax syntax-rules
(define-syntax syntax-rules
(let ()
(define name? symbol?)
@ -242,25 +242,9 @@
(make-transformer rules))))
(mes:define-syntax mes:or
(define-macro (define-syntax-rule id-pattern . template)
`(define-syntax ,(car id-pattern)
(syntax-rules ()
((mes:or) #f)
((mes:or e) e)
((mes:or e1 e ...) (let ((temp e1))
(cond (temp temp) (#t (or e ...)))))))
((,(car id-pattern) . ,(cdr id-pattern)) ,@template))))
(display "(mes:or #f (= 0 1) 'hello-syntax-world): ")
(display (mes:or #f (= 0 1) 'hello-syntax-world))
(display (mes:or #f '==>baaa))
(newline)
(mes:define-syntax mes:when
(syntax-rules ()
((when condition exp ...)
(if condition
(begin exp ...)))))
(display (mes:when #t "when:hello syntax world"))
(newline)
'syntax-dun
(define else #t)