diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-22 16:27:24 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-22 16:27:24 -0400 |
commit | 0b9f22b4d24e8fa545af2d7d448ddfe9fb3736ba (patch) | |
tree | 61bb92dac4a3adc07e6b61a4b7516252fc6abbe1 /src/parser.cc | |
parent | ccedf7d57f6cc42553f1d80189bf1491df6680e2 (diff) | |
download | fork-ledger-0b9f22b4d24e8fa545af2d7d448ddfe9fb3736ba.tar.gz fork-ledger-0b9f22b4d24e8fa545af2d7d448ddfe9fb3736ba.tar.bz2 fork-ledger-0b9f22b4d24e8fa545af2d7d448ddfe9fb3736ba.zip |
Redid the way command-line arguments are processed. Before, Ledger used - and
-- to mean special things after the command verb was seen. But now, what used
to be specified as this:
ledger -n reg cash -payable -- shell
Is now specified as this:
ledger reg -n cash not payable @shell
It could also be specified as:
ledger -n reg \(cash and not payable\) and @shell
Diffstat (limited to 'src/parser.cc')
-rw-r--r-- | src/parser.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/parser.cc b/src/parser.cc index d74421f0..d54d78cd 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -215,8 +215,9 @@ expr_t::parser_t::parse_logic_expr(std::istream& in, if (node && ! (tflags & EXPR_PARSE_SINGLE)) { op_t::kind_t kind = op_t::LAST; - flags_t _flags = tflags; + flags_t _flags = tflags; token_t& tok = next_token(in, tflags); + bool negate = false; switch (tok.kind) { case token_t::EQUAL: @@ -226,11 +227,16 @@ expr_t::parser_t::parse_logic_expr(std::istream& in, kind = op_t::O_EQ; break; case token_t::NEQUAL: - kind = op_t::O_NEQ; + kind = op_t::O_EQ; + negate = true; break; case token_t::MATCH: kind = op_t::O_MATCH; break; + case token_t::NMATCH: + kind = op_t::O_MATCH; + negate = true; + break; case token_t::LESS: kind = op_t::O_LT; break; @@ -257,6 +263,12 @@ expr_t::parser_t::parse_logic_expr(std::istream& in, if (! node->right()) throw_(parse_error, tok.symbol << " operator not followed by argument"); + + if (negate) { + prev = node; + node = new op_t(op_t::O_NOT); + node->set_left(prev); + } } } |