aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-07 23:25:14 +0000
committerDavid Robillard <d@drobilla.net>2010-12-07 23:25:14 +0000
commit375bed3c2e94f44fc3587f3b0cd036b97df8f72d (patch)
treee150e289ea4b832195b29116aa6d573ad16a1d77
parent7682c4ceab935d39aafac369c9b110b658b1e575 (diff)
downloadresp-375bed3c2e94f44fc3587f3b0cd036b97df8f72d.tar.gz
resp-375bed3c2e94f44fc3587f3b0cd036b97df8f72d.tar.bz2
resp-375bed3c2e94f44fc3587f3b0cd036b97df8f72d.zip
Rename 'parse' to the now more accurate 'expand'.
git-svn-id: http://svn.drobilla.net/resp/resp@307 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--Makefile2
-rw-r--r--src/expand.cpp (renamed from src/parse.cpp)29
-rw-r--r--src/repl.cpp2
-rw-r--r--src/resp.cpp2
-rw-r--r--src/resp.hpp2
5 files changed, 18 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index d76a7cc..b33dd9a 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ OBJECTS = \
build/gc.o \
build/lex.o \
build/lift.o \
- build/parse.o \
+ build/expand.o \
build/pprint.o \
build/repl.o \
build/resp.o \
diff --git a/src/parse.cpp b/src/expand.cpp
index 3fb8375..8e682dd 100644
--- a/src/parse.cpp
+++ b/src/expand.cpp
@@ -23,17 +23,17 @@
using namespace std;
-const ATuple*
-parseList(PEnv& penv, const ATuple* e)
+static inline const ATuple*
+expand_list(PEnv& penv, const ATuple* e)
{
List<ATuple, const AST> ret;
FOREACHP(ATuple::const_iterator, i, e)
- ret.push_back(penv.parse(*i));
+ ret.push_back(penv.expand(*i));
return ret.head;
}
-inline const AST*
-parseFn(PEnv& penv, const AST* exp, void* arg)
+static inline const AST*
+expand_fn(PEnv& penv, const AST* exp, void* arg)
{
const ATuple* tup = exp->to_tuple();
ATuple::const_iterator a = tup->begin();
@@ -43,12 +43,12 @@ parseFn(PEnv& penv, const AST* exp, void* arg)
List<ATuple, const AST> ret(new ATuple(penv.sym("fn"), NULL, exp->loc));
ret.push_back(prot);
while (a != tup->end())
- ret.push_back(penv.parse(*a++));
+ ret.push_back(penv.expand(*a++));
return ret.head;
}
-inline const AST*
-parseDef(PEnv& penv, const AST* exp, void* arg)
+static inline const AST*
+expand_def(PEnv& penv, const AST* exp, void* arg)
{
const ATuple* tup = exp->as_tuple();
@@ -57,7 +57,7 @@ parseDef(PEnv& penv, const AST* exp, void* arg)
const AST* arg1 = *(++i);
THROW_IF(i == tup->end(), arg1->loc, "Unexpected end of `def' form");
if (arg1->to_symbol()) {
- return parseList(penv, tup);
+ return expand_list(penv, tup);
} else {
// (def (f x) y) => (def f (fn (x) y))
const ATuple* pat = arg1->to_tuple();
@@ -82,12 +82,12 @@ parseDef(PEnv& penv, const AST* exp, void* arg)
ret.push_back(fnExp.head);
ret.head->loc = exp->loc;
- return parseList(penv, ret.head);
+ return expand_list(penv, ret.head);
}
}
const AST*
-PEnv::parse(const AST* exp)
+PEnv::expand(const AST* exp)
{
const ATuple* tup = exp->to_tuple();
if (!tup)
@@ -96,15 +96,14 @@ PEnv::parse(const AST* exp)
THROW_IF(tup->empty(), exp->loc, "Call to empty list");
if (is_form(tup, "def"))
- return parseDef(*this, exp, NULL);
+ return expand_def(*this, exp, NULL);
else if (is_form(tup, "fn"))
- return parseFn(*this, exp, NULL);
+ return expand_fn(*this, exp, NULL);
else
- return parseList(*this, tup);
+ return expand_list(*this, tup);
}
-
/***************************************************************************
* Language Definition *
***************************************************************************/
diff --git a/src/repl.cpp b/src/repl.cpp
index 8b4faab..965e202 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -39,7 +39,7 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, const AST*& as
if (!exp || (exp->to_tuple() && exp->to_tuple()->empty()))
return false;
- ast = cenv.penv.parse(exp); // Parse input
+ ast = cenv.penv.expand(exp); // Parse input
Constraints c(cenv.tsubst);
resp_constrain(cenv.tenv, c, ast); // Constrain types
diff --git a/src/resp.cpp b/src/resp.cpp
index 824acff..9e959f5 100644
--- a/src/resp.cpp
+++ b/src/resp.cpp
@@ -147,7 +147,7 @@ main(int argc, char** argv)
if (!exp || (exp->to_tuple() && exp->to_tuple()->tup_len() == 1))
break;
- const AST* ast = penv.parse(exp);
+ const AST* ast = penv.expand(exp);
pprint(os, ast, cenv, false);
is.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Skip newlines
}
diff --git a/src/resp.hpp b/src/resp.hpp
index 77f771c..ae7bc11 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -557,7 +557,7 @@ struct PEnv : private map<const string, ASymbol*> {
return sym;
}
}
- const AST* parse(const AST* exp);
+ const AST* expand(const AST* exp);
typedef std::set<std::string> Primitives;
Primitives primitives;