diff options
| author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-03 20:23:22 +0200 | 
|---|---|---|
| committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-03 20:23:22 +0200 | 
| commit | 3b94099c717020be8c29588551f61bc67e610d9d (patch) | |
| tree | f368e672ba3de6ec0f4d20f2c175d6039ca7e1f1 | |
| parent | cfd165366900e6719fbb094c2a70eb8c8009a0dd (diff) | |
Implement COND, LET*, and LIST*.
| -rw-r--r-- | MLKReadEvalPrintLoop.m | 15 | ||||
| -rw-r--r-- | cond.lisp | 30 | ||||
| -rw-r--r-- | init.lisp | 1 | 
3 files changed, 46 insertions, 0 deletions
diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m index e9e90db..8c06496 100644 --- a/MLKReadEvalPrintLoop.m +++ b/MLKReadEvalPrintLoop.m @@ -67,6 +67,10 @@ static const char *prompt (EditLine *e) {    History *commands;    HistEvent event; +  NSInputStream *input; +  MLKStream *stream; +  BOOL success; +    editline = el_init (_argv[0], stdin, stdout, stderr);    el_set (editline, EL_PROMPT, &prompt);    el_set (editline, EL_EDITOR, "emacs"); @@ -75,6 +79,17 @@ static const char *prompt (EditLine *e) {    history (commands, &event, H_SETSIZE, 1000);    el_set (editline, EL_HIST, history, commands); +  printf ("Loading init.lisp.\n"); +  input = [NSInputStream inputStreamWithFileAtPath:@"init.lisp"]; +  stream = AUTORELEASE ([[MLKStream alloc] initWithInputStream:input]); + +  [input open]; +  [MLKInterpreter load:stream verbose:YES print:YES]; +  success = [MLKInterpreter load:stream verbose:YES print:YES]; +  [input close]; + +  printf ("Done.\n\n"); +    printf ("This is Toilet Lisp, version 0.0.1.\n");    printf ("Please make yourself at home.\n"); diff --git a/cond.lisp b/cond.lisp new file mode 100644 index 0000000..e5aed02 --- /dev/null +++ b/cond.lisp @@ -0,0 +1,30 @@ +(%fset 'list* +  (%lambda args +    (if (null (cdr args)) +        (car args) +        (cons (car args) +              (apply 'list* (cdr args)))))) + +(%defmacro let* args +  (let ((form (car args))) +    (let ((bindings (car (cdr form))) +          (body (cdr (cdr form)))) +      (if (null bindings) +          (list* 'let nil body) +          (let ((first-binding (car bindings)) +                (rest (cdr bindings))) +            (list 'let +                  (list first-binding) +                  (list* 'let* rest body))))))) + +(%defmacro cond args +  (let* ((form (car args)) +         (clauses (cdr form)) +         (clause (car clauses)) +         (rest (cdr clauses))) +    (if (null clauses) +        nil +        (list 'if +              (car clause) +              (cons 'progn (cdr clause)) +              (cons 'cond rest))))) diff --git a/init.lisp b/init.lisp new file mode 100644 index 0000000..57652b6 --- /dev/null +++ b/init.lisp @@ -0,0 +1 @@ +(load "cond.lisp")  | 
