aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-03 03:08:08 +0000
committerDavid Robillard <d@drobilla.net>2010-12-03 03:08:08 +0000
commitad056bdf71c8bf780e22f983c83fac0e3a2f41f3 (patch)
tree0d70ea6eb4188f40034e8e011adc5be6e0956fc7 /src/parse.cpp
parent074edbce57e850fc3293eef47861e0ed7707c7e9 (diff)
downloadresp-ad056bdf71c8bf780e22f983c83fac0e3a2f41f3.tar.gz
resp-ad056bdf71c8bf780e22f983c83fac0e3a2f41f3.tar.bz2
resp-ad056bdf71c8bf780e22f983c83fac0e3a2f41f3.zip
Remove use of RTTI for AST.
git-svn-id: http://svn.drobilla.net/resp/resp@290 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/parse.cpp')
-rw-r--r--src/parse.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/parse.cpp b/src/parse.cpp
index a9527ea..7f107aa 100644
--- a/src/parse.cpp
+++ b/src/parse.cpp
@@ -35,22 +35,22 @@ parseTuple(PEnv& penv, const ATuple* e)
AST*
PEnv::parse(const AST* exp)
{
- const ATuple* tup = exp->to<const ATuple*>();
+ const ATuple* tup = exp->to_tuple();
if (tup) {
THROW_IF(tup->empty(), exp->loc, "Call to empty list");
- const ALexeme* form = tup->head()->to<const ALexeme*>();
+ const ALexeme* form = tup->head()->to_lexeme();
if (form) {
MF mf = mac(*form);
if (mf) {
- exp = mf(*this, exp)->as<ATuple*>(); // Apply macro
- tup = exp->to<const ATuple*>();
+ exp = mf(*this, exp)->as_tuple(); // Apply macro
+ tup = exp->to_tuple();
}
}
}
if (tup) {
THROW_IF(tup->empty(), exp->loc, "Call to empty list");
- const ALexeme* form = tup->head()->to<const ALexeme*>();
+ const ALexeme* form = tup->head()->to_lexeme();
if (form) {
const PEnv::Handler* h = handler(true, form->cppstr);
if (h)
@@ -63,7 +63,7 @@ PEnv::parse(const AST* exp)
return parseTuple(*this, tup); // Parse regular call
}
- const ALexeme* lex = exp->to<const ALexeme*>();
+ const ALexeme* lex = exp->to_lexeme();
assert(lex);
if (isdigit(lex->cppstr[0])) {
const std::string& s = lex->cppstr;
@@ -89,16 +89,16 @@ PEnv::parse(const AST* exp)
inline AST*
macDef(PEnv& penv, const AST* exp)
{
- const ATuple* tup = exp->to<const ATuple*>();
+ const ATuple* tup = exp->to_tuple();
ATuple::const_iterator i = tup->begin();
THROW_IF(i == tup->end(), tup->loc, "Unexpected end of `def' macro call");
const AST* arg1 = *(++i);
THROW_IF(i == tup->end(), arg1->loc, "Unexpected end of `def' macro call");
- if (arg1->to<const ALexeme*>()) {
+ if (arg1->to_lexeme()) {
return const_cast<AST*>(exp);
} else {
// (def (f x) y) => (def f (fn (x) y))
- const ATuple* pat = arg1->to<const ATuple*>();
+ const ATuple* pat = arg1->to_tuple();
List<ATuple, AST> argsExp;
ATuple::const_iterator j = pat->begin();
@@ -131,7 +131,7 @@ macDef(PEnv& penv, const AST* exp)
inline AST*
parseCall(PEnv& penv, const AST* exp, void* arg)
{
- return parseTuple(penv, exp->to<const ATuple*>());
+ return parseTuple(penv, exp->to_tuple());
}
inline AST*
@@ -143,10 +143,10 @@ parseBool(PEnv& penv, const AST* exp, void* arg)
inline AST*
parseFn(PEnv& penv, const AST* exp, void* arg)
{
- const ATuple* texp = exp->to<const ATuple*>();
+ const ATuple* texp = exp->to_tuple();
ATuple::const_iterator a = texp->begin();
THROW_IF(++a == texp->end(), exp->loc, "Unexpected end of `fn' form");
- ATuple* prot = parseTuple(penv, (*a++)->to<const ATuple*>());
+ ATuple* prot = parseTuple(penv, (*a++)->to_tuple());
List<ATuple, AST> ret(new ATuple(penv.sym("fn"), NULL, Cursor()));
ret.push_back(prot);
while (a != texp->end())
@@ -158,9 +158,9 @@ parseFn(PEnv& penv, const AST* exp, void* arg)
inline AST*
parseQuote(PEnv& penv, const AST* exp, void* arg)
{
- const ATuple* texp = exp->to<const ATuple*>();
+ const ATuple* texp = exp->to_tuple();
THROW_IF(texp->list_len() != 2, exp->loc, "`quote' requires exactly 1 argument");
- const ALexeme* quotee = texp->list_ref(1)->to<const ALexeme*>();
+ const ALexeme* quotee = texp->list_ref(1)->to_lexeme();
THROW_IF(!quotee, exp->loc, "`quote' argument is not a lexeme");
ATuple* ret = tup<ATuple>(texp->loc, penv.sym("quote"), quotee, NULL);
return ret;