aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compile.cpp4
-rw-r--r--src/parse.cpp16
-rw-r--r--src/pprint.cpp6
-rw-r--r--src/resp.hpp12
4 files changed, 20 insertions, 18 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 88accf4..ebd6083 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -145,11 +145,11 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
const AString* str = ast->to<const AString*>();
if (str)
- return cenv.engine()->compileString(cenv, str->c_str());
+ return cenv.engine()->compileString(cenv, str->cppstr.c_str());
const ALexeme* lexeme = ast->to<const ALexeme*>();
if (lexeme)
- return cenv.engine()->compileString(cenv, lexeme->c_str());
+ return cenv.engine()->compileString(cenv, lexeme->cppstr.c_str());
const ASymbol* sym = ast->to<const ASymbol*>();
if (sym)
diff --git a/src/parse.cpp b/src/parse.cpp
index 78aae69..a9527ea 100644
--- a/src/parse.cpp
+++ b/src/parse.cpp
@@ -52,11 +52,11 @@ PEnv::parse(const AST* exp)
THROW_IF(tup->empty(), exp->loc, "Call to empty list");
const ALexeme* form = tup->head()->to<const ALexeme*>();
if (form) {
- const PEnv::Handler* h = handler(true, *form);
+ const PEnv::Handler* h = handler(true, form->cppstr);
if (h)
return h->func(*this, exp, h->arg); // Parse special form
- if (isupper(form->c_str()[0])) // Call constructor (any uppercase symbol)
+ if (isupper(form->cppstr.c_str()[0])) // Call constructor (any uppercase symbol)
return parseTuple(*this, tup);
}
@@ -65,20 +65,20 @@ PEnv::parse(const AST* exp)
const ALexeme* lex = exp->to<const ALexeme*>();
assert(lex);
- if (isdigit((*lex)[0])) {
- const std::string& s = *lex;
+ if (isdigit(lex->cppstr[0])) {
+ const std::string& s = lex->cppstr;
if (s.find('.') == string::npos)
return new ALiteral<int32_t>(T_INT32, strtol(s.c_str(), NULL, 10), exp->loc);
else
return new ALiteral<float>(T_FLOAT, strtod(s.c_str(), NULL), exp->loc);
- } else if ((*lex)[0] == '\"') {
- return new AString(exp->loc, lex->substr(1, lex->length() - 2));
+ } else if (lex->cppstr[0] == '\"') {
+ return new AString(exp->loc, lex->cppstr.substr(1, lex->cppstr.length() - 2));
} else {
- const PEnv::Handler* h = handler(false, *lex);
+ const PEnv::Handler* h = handler(false, lex->cppstr);
if (h)
return h->func(*this, exp, h->arg);
}
- return sym(*lex, exp->loc);
+ return sym(lex->cppstr, exp->loc);
}
diff --git a/src/pprint.cpp b/src/pprint.cpp
index 003d447..2f4180b 100644
--- a/src/pprint.cpp
+++ b/src/pprint.cpp
@@ -62,7 +62,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
{
const ALexeme* lexeme = ast->to<const ALexeme*>();
if (lexeme)
- return out << *lexeme;
+ return out << lexeme->cppstr;
const ALiteral<float>* flit = ast->to<const ALiteral<float>*>();
if (flit)
@@ -78,7 +78,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
const AString* str = ast->to<const AString*>();
if (str)
- return out << '"' << *str << '"';
+ return out << '"' << str->cppstr << '"';
const ASymbol* sym = ast->to<const ASymbol*>();
if (sym)
@@ -108,7 +108,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
} else {
const ALexeme* lexeme = (*i)->to<const ALexeme*>();
if (lexeme)
- form = *lexeme;
+ form = lexeme->cppstr;
}
}
diff --git a/src/resp.hpp b/src/resp.hpp
index 7383cdd..f2f27f5 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -246,15 +246,17 @@ struct ALiteral : public AST {
};
/// Lexeme (any atom in the CST, e.g. "a", "3.4", ""hello"", etc.)
-struct ALexeme : public AST, public std::string {
- ALexeme(Cursor c, const string& s) : AST(T_LEXEME, c), std::string(s) {}
+struct ALexeme : public AST {
+ ALexeme(Cursor c, const string& s) : AST(T_LEXEME, c), cppstr(s) {}
bool operator==(const AST& rhs) const { return this == &rhs; }
+ const string cppstr;
};
/// String, e.g. ""a""
-struct AString : public AST, public std::string {
- AString(Cursor c, const string& s) : AST(T_STRING, c), std::string(s) {}
+struct AString : public AST {
+ AString(Cursor c, const string& s) : AST(T_STRING, c), cppstr(s) {}
bool operator==(const AST& rhs) const { return this == &rhs; }
+ const string cppstr;
};
/// Symbol, e.g. "a"
@@ -553,7 +555,7 @@ struct PEnv : private map<const string, ASymbol*> {
macros.insert(make_pair(s, f));
}
MF mac(const ALexeme& s) const {
- map<string, MF>::const_iterator i = macros.find(s);
+ map<string, MF>::const_iterator i = macros.find(s.cppstr);
return (i != macros.end()) ? i->second : NULL;
}
string gensymstr(const char* s="_") { return (format("%s_%d") % s % symID++).str(); }