summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/expr.cc5
-rw-r--r--src/expr.h7
-rw-r--r--src/op.cc3
-rw-r--r--src/op.h3
4 files changed, 12 insertions, 6 deletions
diff --git a/src/expr.cc b/src/expr.cc
index ee06187a..69319105 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -190,4 +190,9 @@ std::ostream& operator<<(std::ostream& out, const expr_t& expr) {
return out;
}
+string expr_context(const expr_t& expr)
+{
+ return expr ? op_context(expr.ptr) : "<empty expression>";
+}
+
} // namespace ledger
diff --git a/src/expr.h b/src/expr.h
index d5ff276e..6805e6d5 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -70,6 +70,8 @@ class expr_t
struct token_t;
class parser_t;
+ friend string expr_context(const expr_t& expr);
+
public:
class op_t;
typedef intrusive_ptr<op_t> ptr_op_t;
@@ -141,10 +143,7 @@ public:
std::ostream& operator<<(std::ostream& out, const expr_t& expr);
-inline string expr_context(const expr_t& expr) {
- // jww (2009-02-01): NYI
- return "EXPR";
-}
+string expr_context(const expr_t& expr);
} // namespace ledger
diff --git a/src/op.cc b/src/op.cc
index 7f44ac16..53f5b9e6 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -490,7 +490,8 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const
}
}
-string op_context(const expr_t::ptr_op_t op, const expr_t::ptr_op_t goal)
+string op_context(const expr_t::ptr_op_t op,
+ const expr_t::ptr_op_t goal)
{
ostream_pos_type start_pos, end_pos;
expr_t::op_t::context_t context(op, goal, &start_pos, &end_pos);
diff --git a/src/op.h b/src/op.h
index b7ae9430..ad900cc5 100644
--- a/src/op.h
+++ b/src/op.h
@@ -328,7 +328,8 @@ inline expr_t::ptr_op_t expr_t::op_t::wrap_functor(const function_t& fobj) {
#define MAKE_FUNCTOR(x) expr_t::op_t::wrap_functor(bind(&x, this, _1))
#define WRAP_FUNCTOR(x) expr_t::op_t::wrap_functor(x)
-string op_context(const expr_t::ptr_op_t op, const expr_t::ptr_op_t goal);
+string op_context(const expr_t::ptr_op_t op,
+ const expr_t::ptr_op_t goal = NULL);
} // namespace ledger