summaryrefslogtreecommitdiff
path: root/src/query.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-01 17:32:41 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-01 17:32:41 -0400
commitd19745afded63276449bb56b7d24c38c7e32d0a7 (patch)
treeb22dc43e1afc36bd8637499a2fffdd46443338ed /src/query.cc
parent651220129219d5581597d0c312ef9fee7b47a358 (diff)
downloadfork-ledger-d19745afded63276449bb56b7d24c38c7e32d0a7.tar.gz
fork-ledger-d19745afded63276449bb56b7d24c38c7e32d0a7.tar.bz2
fork-ledger-d19745afded63276449bb56b7d24c38c7e32d0a7.zip
Improve parsing of 'expr' query terms
Fixes #157 / 9DF85DF2-4BF5-4931-A30C-2592A10BB5C0
Diffstat (limited to 'src/query.cc')
-rw-r--r--src/query.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/query.cc b/src/query.cc
index 1f086df8..c79fe1c2 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -55,8 +55,9 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token()
if (consume_next_arg) {
consume_next_arg = false;
+ token_t tok(token_t::TERM, string(arg_i, arg_end));
arg_i = arg_end;
- return token_t(token_t::TERM, (*begin).as_string());
+ return tok;
}
resume:
@@ -70,23 +71,25 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token()
return next_token();
goto resume;
+ case '\'':
case '/': {
string pat;
- bool found_end_slash = false;
+ char closing = *arg_i;
+ bool found_closing = false;
for (++arg_i; arg_i != arg_end; ++arg_i) {
if (*arg_i == '\\') {
if (++arg_i == arg_end)
throw_(parse_error, _("Unexpected '\\' at end of pattern"));
}
- else if (*arg_i == '/') {
+ else if (*arg_i == closing) {
++arg_i;
- found_end_slash = true;
+ found_closing = true;
break;
}
pat.push_back(*arg_i);
}
- if (! found_end_slash)
- throw_(parse_error, _("Expected '/' at end of pattern"));
+ if (! found_closing)
+ throw_(parse_error, _("Expected '%1' at end of pattern") << closing);
if (pat.empty())
throw_(parse_error, _("Match pattern is empty"));