aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-23 05:31:15 +0000
committerDavid Robillard <d@drobilla.net>2012-12-23 05:31:15 +0000
commit67319bf0410196787c753225f46057bc7c94beec (patch)
tree572e8f8989a903fde8be784de5dddbaa1938ecfe /src
parent0375a20786f1e6eba9d128889f700b22d447021c (diff)
downloadresp-67319bf0410196787c753225f46057bc7c94beec.tar.gz
resp-67319bf0410196787c753225f46057bc7c94beec.tar.bz2
resp-67319bf0410196787c753225f46057bc7c94beec.zip
Move towards standard Scheme syntax.
git-svn-id: http://svn.drobilla.net/resp/trunk@442 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r--src/compile.cpp2
-rw-r--r--src/constrain.cpp6
-rw-r--r--src/cps.cpp10
-rw-r--r--src/depoly.cpp2
-rw-r--r--src/expand.cpp8
-rw-r--r--src/flatten.cpp16
-rw-r--r--src/lift.cpp14
-rw-r--r--src/pprint.cpp10
-rw-r--r--src/repl.cpp4
-rw-r--r--src/simplify.cpp8
10 files changed, 40 insertions, 40 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 64dee08..69cce6d 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -230,7 +230,7 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return compile_cons(cenv, call);
else if (form == ".")
return compile_dot(cenv, call);
- else if (form == "def")
+ else if (form == "define")
return compile_def(cenv, call);
else if (form == "def-type")
return compile_def_type(cenv, call);
diff --git a/src/constrain.cpp b/src/constrain.cpp
index e6e81a3..baa4ca8 100644
--- a/src/constrain.cpp
+++ b/src/constrain.cpp
@@ -173,7 +173,7 @@ constrain_fn(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error)
for (++i; i != call->end(); ++i) {
const AST* exp = *i;
const ATuple* call = exp->to_tuple();
- if (call && is_form(call, "def")) {
+ if (call && is_form(call, "define")) {
const ASymbol* sym = call->list_ref(1)->as_symbol();
THROW_IF(defs.count(sym) != 0, call->loc,
(format("`%1%' defined twice") % sym->str()).str());
@@ -429,11 +429,11 @@ constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) throw(Error)
constrain_cons(tenv, c, tup);
else if (form == ".")
constrain_dot(tenv, c, tup);
- else if (form == "def")
+ else if (form == "define")
constrain_def(tenv, c, tup);
else if (form == "def-type")
constrain_def_type(tenv, c, tup);
- else if (form == "fn")
+ else if (form == "lambda")
constrain_fn(tenv, c, tup);
else if (form == "if")
constrain_if(tenv, c, tup);
diff --git a/src/cps.cpp b/src/cps.cpp
index c55f728..bb375a8 100644
--- a/src/cps.cpp
+++ b/src/cps.cpp
@@ -63,7 +63,7 @@ cps_fn(CEnv& cenv, const ATuple* fn, const AST* cont)
assert(fn->fst());
assert(copyProt.head);
List copy;
- copy.push_back(cenv.penv.sym("fn"));
+ copy.push_back(cenv.penv.sym("lambda"));
copy.push_back(copyProt);
for (ATuple::const_iterator i = fn->iter_at(2); i != fn->end(); ++i)
@@ -105,7 +105,7 @@ cps_call(CEnv& cenv, const ATuple* call, const AST* k)
std::vector<const AST*>::const_reverse_iterator a = args.rbegin();
for (ExpVec::const_reverse_iterator e = exprs.rbegin(); e != exprs.rend(); ++e, ++a) {
if (!is_value(cenv, *e)) {
- cont = resp_cps(cenv, *e, tup(Cursor(), cenv.penv.sym("fn"),
+ cont = resp_cps(cenv, *e, tup(Cursor(), cenv.penv.sym("lambda"),
tup(Cursor(), *a, 0),
cont,
0));
@@ -145,7 +145,7 @@ cps_if(CEnv& cenv, const ATuple* aif, const AST* k)
} else {
/*
const ASymbol* const condSym = cenv.penv.gensym("c");
- const ATuple* contFn = tup(loc, tenv.penv.sym("fn"),
+ const ATuple* contFn = tup(loc, tenv.penv.sym("lambda"),
tup(cond->loc, argSym, tenv.penv.gensym("_k"), 0),
tup(loc, tenv.penv.sym("if"), argSym,
exp->(tenv, cont),
@@ -166,9 +166,9 @@ resp_cps(CEnv& cenv, const AST* ast, const AST* k) throw()
if (call) {
const ASymbol* const sym = call->fst()->to_symbol();
const std::string form = sym ? sym->sym() : "";
- if (form == "def")
+ if (form == "define")
return cps_def(cenv, call, k);
- else if (form == "fn")
+ else if (form == "lambda")
return cps_fn(cenv, call, k);
else if (form == "if")
return cps_if(cenv, call, k);
diff --git a/src/depoly.cpp b/src/depoly.cpp
index c6de0c1..0ee89c1 100644
--- a/src/depoly.cpp
+++ b/src/depoly.cpp
@@ -112,7 +112,7 @@ resp_depoly(CEnv& cenv, Code& code, const AST* ast) throw()
const ATuple* const call = ast->as_tuple();
const ASymbol* const sym = call->fst()->to_symbol();
const std::string form = sym ? sym->sym() : "";
- assert(form != "fn");
+ assert(form != "lambda");
if (form == "quote")
return ast;
else if (form == "def-type")
diff --git a/src/expand.cpp b/src/expand.cpp
index b50d627..0cbe118 100644
--- a/src/expand.cpp
+++ b/src/expand.cpp
@@ -41,7 +41,7 @@ expand_fn(PEnv& penv, const AST* exp, void* arg)
THROW_IF(++a == tup->end(), exp->loc, "Unexpected end of `fn' form");
THROW_IF(!(*a)->to_tuple(), (*a)->loc, "First argument of `fn' is not a list");
const ATuple* prot = (*a++)->to_tuple();
- List ret(new ATuple(penv.sym("fn"), NULL, exp->loc));
+ List ret(new ATuple(penv.sym("lambda"), NULL, exp->loc));
ret.push_back(prot);
while (a != tup->end())
ret.push_back(penv.expand(*a++));
@@ -67,7 +67,7 @@ expand_def(PEnv& penv, const AST* exp, void* arg)
argsExp.head->loc = exp->loc;
List fnExp;
- fnExp.push_back(penv.sym("fn"));
+ fnExp.push_back(penv.sym("lambda"));
fnExp.push_back(argsExp.head);
for (++i; i != tup->end(); ++i)
fnExp.push_back(*i);
@@ -94,9 +94,9 @@ PEnv::expand(const AST* exp)
THROW_IF(tup->empty(), exp->loc, "Call to empty list");
- if (is_form(tup, "def"))
+ if (is_form(tup, "define"))
return expand_def(*this, exp, NULL);
- else if (is_form(tup, "fn"))
+ else if (is_form(tup, "lambda"))
return expand_fn(*this, exp, NULL);
else
return expand_list(*this, tup);
diff --git a/src/flatten.cpp b/src/flatten.cpp
index 424e5a6..ca849fa 100644
--- a/src/flatten.cpp
+++ b/src/flatten.cpp
@@ -32,7 +32,7 @@ flatten_def(CEnv& cenv, Code& code, const ATuple* def) throw()
const ASymbol* const sym = def->list_ref(1)->as_symbol();
const AST* const body = def->list_ref(2);
- if (!is_form(body, "fn")) {
+ if (!is_form(body, "lambda")) {
code.push_back(def);
return NULL;
}
@@ -89,7 +89,7 @@ flatten_do(CEnv& cenv, Code& code, const ATuple* ado) throw()
code.push_back(ret);
}
const ASymbol* sym = cenv.penv.gensym("doval");
- List def(Cursor(), cenv.penv.sym("def"), sym, ret, NULL);
+ List def(Cursor(), cenv.penv.sym("define"), sym, ret, NULL);
code.push_back(def);
cenv.setTypeSameAs(sym, ado);
return sym;
@@ -103,7 +103,7 @@ flatten_if(CEnv& cenv, Code& code, const ATuple* aif) throw()
cond = aif->frst()->as_symbol();
} else {
cond = cenv.penv.gensym("ifcond");
- List def(Cursor(), cenv.penv.sym("def"), cond,
+ List def(Cursor(), cenv.penv.sym("define"), cond,
resp_flatten(cenv, code, aif->frst()), 0);
cenv.setTypeSameAs(cond, aif->frst());
code.push_back(def);
@@ -131,7 +131,7 @@ flatten_if(CEnv& cenv, Code& code, const ATuple* aif) throw()
code.push_back(else_goto);
List end(Cursor(), cenv.penv.sym("if-end"), if_lab, NULL);
- List def(Cursor(), cenv.penv.sym("def"), result, end.head, NULL);
+ List def(Cursor(), cenv.penv.sym("define"), result, end.head, NULL);
code.push_back(def);
cenv.setTypeSameAs(end, aif);
@@ -150,7 +150,7 @@ flatten_call(CEnv& cenv, Code& code, const ATuple* call) throw()
arg = flat_i;
} else {
const ASymbol* sym = cenv.penv.gensym();
- List def(Cursor(), cenv.penv.sym("def"), sym, flat_i, NULL);
+ List def(Cursor(), cenv.penv.sym("define"), sym, flat_i, NULL);
code.push_back(def);
arg = sym;
cenv.setTypeSameAs(sym, *i);
@@ -159,7 +159,7 @@ flatten_call(CEnv& cenv, Code& code, const ATuple* call) throw()
copy.push_back(arg);
}
const ASymbol* sym = cenv.penv.gensym();
- List def(Cursor(), cenv.penv.sym("def"), sym, copy.head, NULL);
+ List def(Cursor(), cenv.penv.sym("define"), sym, copy.head, NULL);
code.push_back(def);
cenv.setTypeSameAs(copy, call);
@@ -175,10 +175,10 @@ resp_flatten(CEnv& cenv, Code& code, const AST* ast) throw()
const ATuple* const call = ast->as_tuple();
const ASymbol* const sym = call->fst()->to_symbol();
const std::string form = sym ? sym->sym() : "";
- assert(form != "fn");
+ assert(form != "lambda");
if (form == "quote")
return ast;
- else if (form == "def")
+ else if (form == "define")
return flatten_def(cenv, code, call);
else if (form == "def-type")
return flatten_def_type(cenv, code, call);
diff --git a/src/lift.cpp b/src/lift.cpp
index 7f236d1..7fa834f 100644
--- a/src/lift.cpp
+++ b/src/lift.cpp
@@ -76,7 +76,7 @@ lift_def(CEnv& cenv, Code& code, const ATuple* def) throw()
const ASymbol* const sym = def->list_ref(1)->as_symbol();
const AST* const body = def->list_ref(2);
cenv.def(sym, body, cenv.type(body), NULL);
- if (is_form(body, "fn"))
+ if (is_form(body, "lambda"))
cenv.setName(body->as_tuple(), sym->str());
assert(def->list_ref(1)->to_symbol());
@@ -126,7 +126,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw()
for (ATuple::const_iterator p = fn->prot()->begin(); p != fn->prot()->end(); ++p) {
const AST* paramType = (*tp++);
- if (is_form(paramType, "Fn")) {
+ if (is_form(paramType, "lambda")) {
const ATuple* fnType = new ATuple(cenv.tenv.var(), paramType->as_tuple(), paramType->loc);
paramType = tup((*p)->loc, cenv.tenv.Tup, fnType, NULL);
}
@@ -136,7 +136,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw()
}
// Write function prototype first for mutual and/or nested recursion
- List declProt(fn->loc, cenv.penv.sym("fn"), 0);
+ List declProt(fn->loc, cenv.penv.sym("lambda"), 0);
declProt.push_back(implProt);
List decl(fn->loc, cenv.penv.sym("prot"), cenv.penv.sym(implNameStr), 0);
decl.push_back(declProt);
@@ -157,7 +157,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw()
// Create definition for implementation fn
const ASymbol* implName = cenv.penv.sym(implNameStr);
- const ATuple* def = tup(fn->loc, cenv.penv.sym("def"), implName, impl.head, NULL);
+ const ATuple* def = tup(fn->loc, cenv.penv.sym("define"), implName, impl.head, NULL);
// Define types before lifting body with return type as a variable
List implT(Cursor(), type->fst(), implProtT.head, retTVar, 0);
@@ -244,7 +244,7 @@ lift_call(CEnv& cenv, Code& code, const ATuple* call) throw()
copy.push_front(cenv.penv.sym(cenv.liftStack.top().implName));
copy.push_front(cenv.penv.sym("call"));
cenv.setTypeSameAs(copy, call);
- } else if (is_form(call->fst(), "fn")) {
+ } else if (is_form(call->fst(), "lambda")) {
/* Special case: ((fn ...) ...)
* Lifting (fn ...) yields: (Closure _impl ...).
* We don't want (call (. (Closure _impl ...) 1) (Closure _impl ...) ...),
@@ -307,13 +307,13 @@ resp_lift(CEnv& cenv, Code& code, const AST* ast) throw()
return lift_args(cenv, code, call);
else if (form == ".")
return lift_dot(cenv, code, call);
- else if (form == "def")
+ else if (form == "define")
return lift_def(cenv, code, call);
else if (form == "def-type")
return call;
else if (form == "do")
return lift_args(cenv, code, call);
- else if (form == "fn")
+ else if (form == "lambda")
return lift_fn(cenv, code, call);
else if (form == "if")
return lift_args(cenv, code, call);
diff --git a/src/pprint.cpp b/src/pprint.cpp
index bbb4904..ff19331 100644
--- a/src/pprint.cpp
+++ b/src/pprint.cpp
@@ -37,7 +37,7 @@ newline(ostream& out, unsigned indent)
static inline void
print_annotation(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool print)
{
- if (is_form(ast, "def"))
+ if (is_form(ast, "define"))
return;
if (print) {
@@ -143,8 +143,8 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
out << " ";
}
- if (form == "def") {
- if (tup->rrst() && is_form(tup->frrst(), "fn")) {
+ if (form == "define") {
+ if (tup->rrst() && is_form(tup->frrst(), "lambda")) {
// Abreviate (def (fn (...) ...))
out << "(" << (*i++) << " ";
const ATuple* const fn = tup->frrst()->as_tuple();
@@ -179,7 +179,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
newline(out, indent + 2);
print_list(out, tup, i, indent + 2, cenv, types, false);
- } else if (form == "fn") {
+ } else if (form == "lambda") {
// Print prototype (possibly with parameter type annotations)
const ATuple* pat = (*i++)->as_tuple();
out << "(";
@@ -266,7 +266,7 @@ pprint(ostream& out, const AST* ast, CEnv* cenv, bool types)
print_to(out, ast, 0, cenv, types);
print_annotation(out, ast, 0, cenv, types);
out << endl;
- if ((is_form(ast, "def") && is_form(ast->as_tuple()->frrst(), "fn"))
+ if ((is_form(ast, "define") && is_form(ast->as_tuple()->frrst(), "lambda"))
|| is_form(ast, "fn-end")
|| is_form(ast, "def-type"))
out << endl;
diff --git a/src/repl.cpp b/src/repl.cpp
index 25da08a..9709656 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -134,7 +134,7 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
for (Code::const_iterator i = stages.back().begin(); i != stages.back().end(); ++i) {
const ATuple* call = (*i)->to_tuple();
if (call && (is_form(*i, "def-type")
- || (is_form(*i, "def") && is_form(call->frrst(), "fn")))) {
+ || (is_form(*i, "define") && is_form(call->frrst(), "lambda")))) {
resp_flatten(cenv, defs, call);
} else if (call && is_form(*i, "prot")) {
defs.push_back(*i);
@@ -151,7 +151,7 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
if (!exprs.empty()) {
const ASymbol* main = cenv.penv.sym(mainName);
- List mainT(Cursor(), cenv.penv.sym("Fn"), new ATuple(Cursor()), retT, NULL);
+ List mainT(Cursor(), cenv.penv.sym("lambda"), new ATuple(Cursor()), retT, NULL);
cenv.def(main, NULL, mainT, NULL);
defs.push_back(
diff --git a/src/simplify.cpp b/src/simplify.cpp
index d8d23f2..f1b1bec 100644
--- a/src/simplify.cpp
+++ b/src/simplify.cpp
@@ -65,7 +65,7 @@ simplify_match(CEnv& cenv, Code& code, const ATuple* match) throw()
const ASymbol* tsym = cenv.penv.gensym("__tag");
- List def(match->loc, cenv.penv.sym("def"), tsym, tval.head, NULL);
+ List def(match->loc, cenv.penv.sym("define"), tsym, tval.head, NULL);
cenv.setType(tval.head, cenv.tenv.named("Symbol"));
List copyIf;
@@ -98,13 +98,13 @@ simplify_match(CEnv& cenv, Code& code, const ATuple* match) throw()
const ATuple* prot = new ATuple(osym, 0, Cursor());
const ATuple* protT = new ATuple(texp, 0, Cursor());
- List fn(Cursor(), cenv.penv.sym("fn"), prot, 0);
+ List fn(Cursor(), cenv.penv.sym("lambda"), prot, 0);
int idx = 0;
ATuple::const_iterator ti = texp->iter_at(1);
for (ATuple::const_iterator j = pat->iter_at(1); j != pat->end(); ++j, ++ti, ++idx) {
const AST* index = new ALiteral<int32_t>(T_INT32, idx, Cursor());
const AST* dot = tup(Cursor(), cenv.penv.sym("."), osym, index, 0);
- const AST* def = tup(Cursor(), cenv.penv.sym("def"), *j, dot, 0);
+ const AST* def = tup(Cursor(), cenv.penv.sym("define"), *j, dot, 0);
fn.push_back(def);
}
@@ -144,7 +144,7 @@ simplify_let(CEnv& cenv, Code& code, const ATuple* call) throw()
{
const ATuple* vars = call->list_ref(1)->to_tuple();
- List fn(Cursor(), cenv.penv.sym("fn"), NULL);
+ List fn(Cursor(), cenv.penv.sym("lambda"), NULL);
List fnProt;
List fnArgs;