Add backquote/quasiquote (`).
diff --git a/doc/lisp_reference/lisp_reference.tex b/doc/lisp_reference/lisp_reference.tex
index 52e9e4b..a758d51 100644
--- a/doc/lisp_reference/lisp_reference.tex
+++ b/doc/lisp_reference/lisp_reference.tex
@@ -166,7 +166,7 @@
\section{Function Manipulation}
\definition{
- (\mac{funcall} \param{function} \param{args}\more)\index{funcall} \\
+ (\func{funcall} \param{function} \param{args}\more)\index{funcall} \\
(\func{apply} \param{function} \param{args})\index{apply}
}{
Call the \type{closure} or \type{function-object} \param{function} with \param{args} and evaluate to \ret{its result}. An error occurs if \param{args} are not acceptable.
diff --git a/lib/lisp/std/std.lisp b/lib/lisp/std/std.lisp
index e7ed14c..774d805 100644
--- a/lib/lisp/std/std.lisp
+++ b/lib/lisp/std/std.lisp
@@ -19,8 +19,6 @@
;; /Boring utilitites
-
-
(defun not (val)
(nilp val))
diff --git a/src/lisp/compiler.dasc b/src/lisp/compiler.dasc
index bf78a20..f176b7d 100644
--- a/src/lisp/compiler.dasc
+++ b/src/lisp/compiler.dasc
@@ -370,9 +370,34 @@
else
{
value_t fsym = car(val), args = cdr(val);
- int nargs = length(args);
+ int nargs = length(args),
+ n = length(val);
- // TODO
+ if (symstreq(fsym, "unquote"))
+ {
+ if (nargs != 1)
+ {
+ err_at(val, "unquote (or ,) takes exactly 1 argument");
+ }
+
+ compile_expression(env, local, car(args), false, Dst);
+ }
+ else
+ {
+ | push nil;
+
+ for (int i = n - 1; i >= 0; i--)
+ {
+ compile_backquote(env, local, elt(val, i), Dst);
+ | push eax;
+ | call_extern cons;
+ | add esp, 8;
+
+ // Remove unnecessary pop
+ | push eax;
+ }
+ | pop eax;
+ }
}
}
@@ -552,17 +577,12 @@
{
compile_expression(env, local, elt(args, i), false, Dst);
- // push the ith item
| push eax;
- // cons the top two stack items
| call_extern cons;
- // remove the stack items from use
| add esp, (2 * value_size);
- // put the new thing on the stack
| push eax;
}
-
- | pop eax;
+ | pop eax;
}
else if (symstreq(fsym, "lambda"))
{