diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-12 15:42:02 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-12 15:43:00 -0400 |
commit | b1b4e2aadff5983d443d70c09ea86a41b015873f (patch) | |
tree | 2c40305c9f9841a4c3d453a4a5c49ec69056b4b2 /src/textual.cc | |
parent | 0555e7f61ef14ec667f8ba611e60fd96133a9676 (diff) | |
download | fork-ledger-b1b4e2aadff5983d443d70c09ea86a41b015873f.tar.gz fork-ledger-b1b4e2aadff5983d443d70c09ea86a41b015873f.tar.bz2 fork-ledger-b1b4e2aadff5983d443d70c09ea86a41b015873f.zip |
Add support for typed metadata
The metadata construct 'Key: Value' is now just a special case for
'Key:: "Value"'. Another after a :: in metadata setting is parsed as a
full value expression and typed as such. For example:
; Key:: $400 + $500
ledger -l 'tag("Key") < $1000'
Diffstat (limited to 'src/textual.cc')
-rw-r--r-- | src/textual.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/textual.cc b/src/textual.cc index 5308fa18..9a4fee8e 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -67,7 +67,7 @@ namespace { std::size_t sequence; parse_context_t(journal_t& _journal, scope_t& _scope) - : journal(_journal), scope(_scope), timelog(journal), + : journal(_journal), scope(_scope), timelog(journal, scope), strict(false), count(0), errors(0), sequence(1) {} bool front_is_account() { @@ -1236,7 +1236,7 @@ post_t * instance_t::parse_post(char * line, // Parse the optional note if (next && *next == ';') { - post->append_note(++next, true, current_year); + post->append_note(++next, context.scope, true, current_year); next = line + len; DEBUG("textual.parse", "line " << linenum << ": " << "Parsed a posting note"); @@ -1255,7 +1255,8 @@ post_t * instance_t::parse_post(char * line, if (! context.state_stack.empty()) { foreach (const state_t& state, context.state_stack) if (state.type() == typeid(string)) - post->parse_tags(boost::get<string>(state).c_str(), true); + post->parse_tags(boost::get<string>(state).c_str(), context.scope, + true); } TRACE_STOP(post_details, 1); @@ -1367,7 +1368,7 @@ xact_t * instance_t::parse_xact(char * line, // Parse the xact note if (next && *next == ';') - xact->append_note(++next, current_year); + xact->append_note(++next, context.scope, false, current_year); TRACE_STOP(xact_text, 1); @@ -1392,7 +1393,7 @@ xact_t * instance_t::parse_xact(char * line, item = xact.get(); // This is a trailing note, and possibly a metadata info tag - item->append_note(p + 1, true, current_year); + item->append_note(p + 1, context.scope, true, current_year); item->pos->end_pos = curr_pos; item->pos->end_line++; } else { @@ -1426,7 +1427,8 @@ xact_t * instance_t::parse_xact(char * line, if (! context.state_stack.empty()) { foreach (const state_t& state, context.state_stack) if (state.type() == typeid(string)) - xact->parse_tags(boost::get<string>(state).c_str(), false); + xact->parse_tags(boost::get<string>(state).c_str(), context.scope, + false); } TRACE_STOP(xact_details, 1); |