69template <
typename ResultType>
111 virtual operator bool()
const throw() {
112 return !
str.empty();
115 virtual string text()
const throw() {
125 std::istringstream stream(expr_str);
130 const optional<string>& original_string = none) {
131 set_text(original_string ? *original_string :
"<stream>");
160 DEBUG(
"expr.compile",
"Before compilation:");
165 DEBUG(
"expr.compile",
"Compiling: " <<
str);
170 DEBUG(
"expr.compile",
"After compilation:");
176 DEBUG(
"expr.calc",
"Calculating: " <<
str);
197 std::ostringstream out;
202 std::ostringstream out;
207 std::ostringstream out;
212 virtual void print(std::ostream&)
const {}
213 virtual void dump(std::ostream&)
const {}
216 out << _(
"--- Input expression ---") << std::endl;
217 out <<
text() << std::endl;
219 out << std::endl << _(
"--- Text as parsed ---") << std::endl;
223 out << std::endl << _(
"--- Expression tree ---") << std::endl;
226 out << std::endl << _(
"--- Compiled tree ---") << std::endl;
230 out << std::endl << _(
"--- Result value ---") << std::endl;
235template <
typename ResultType>
#define DECLARE_EXCEPTION(name, kind)
Basic type for handling commoditized math: amount_t.
General utility facilities used by Ledger.
#define TRACE_CTOR(cls, args)
flags::basic_t< parse_flags_enum_t, uint_least8_t > parse_flags_t
std::ostream * _log_stream
std::ostream & operator<<(std::ostream &out, const account_t &account)
parse_error(const string &why)
compile_error(const string &why)
calc_error(const string &why)
usage_error(const string &why)
string preview_to_str(scope_t &) const
virtual void parse(std::istream &, const parse_flags_t &=PARSE_DEFAULT, const optional< string > &original_string=none)
void recompile(scope_t &scope)
void set_context(scope_t *scope)
result_type calc(scope_t &scope)
expr_base_t & operator=(const expr_base_t &_expr)
expr_base_t(scope_t *_context=NULL)
virtual void dump(std::ostream &) const
virtual result_type real_calc(scope_t &scope)=0
virtual string context_to_str() const
virtual void mark_uncompiled()
string print_to_str() const
function< result_type(call_scope_t &)> func_t
result_type operator()(scope_t &scope)
result_type preview(std::ostream &out, scope_t &scope) const
virtual string text() const
string dump_to_str() const
expr_base_t(const expr_base_t &other)
virtual void print(std::ostream &) const
void set_text(const string &txt)
virtual void compile(scope_t &scope)
expr_base_t & operator=(const string &_expr)
void parse(const string &expr_str, const parse_flags_t &flags=PARSE_DEFAULT)