aboutsummaryrefslogtreecommitdiffstats
path: root/src/simplify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplify.cpp')
-rw-r--r--src/simplify.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/simplify.cpp b/src/simplify.cpp
index 397c2b7..63b5fd6 100644
--- a/src/simplify.cpp
+++ b/src/simplify.cpp
@@ -145,6 +145,20 @@ simplify_let(CEnv& cenv, const ATuple* call) throw()
return copy;
}
+static const AST*
+simplify_quote(CEnv& cenv, const ATuple* call) throw()
+{
+ switch (call->list_ref(1)->tag()) {
+ case T_SYMBOL: case T_TUPLE:
+ // Symbols and lists remain quoted (because semantics differ)
+ return call;
+ default:
+ // Other literals (e.g. numbers, strings) are self-evaluating, so the
+ // quote can be removed, e.g. (quote 3) => 3
+ return call->list_ref(1);
+ }
+}
+
const AST*
resp_simplify(CEnv& cenv, const AST* ast) throw()
{
@@ -161,6 +175,8 @@ resp_simplify(CEnv& cenv, const AST* ast) throw()
return simplify_if(cenv, list);
else if (form == "let")
return simplify_let(cenv, list);
+ else if (form == "quote")
+ return simplify_quote(cenv, list);
else
return simplify_list(cenv, list);
}