diff options
Diffstat (limited to 'src/query.cc')
-rw-r--r-- | src/query.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/query.cc b/src/query.cc index 705ba151..a157b4d1 100644 --- a/src/query.cc +++ b/src/query.cc @@ -36,6 +36,17 @@ namespace ledger { +// TODO: Extend this to handle all characters which define enclosures +bool query_t::lexer_t::unbalanced_braces(string str) { + int balance = 0; + for (char& c : str) { + if (c == '(') ++balance; + else if (c == ')') + if (--balance < 0) return true; + } + return balance != 0; +} + query_t::lexer_t::token_t query_t::lexer_t::next_token(query_t::lexer_t::token_t::kind_t tok_context) { @@ -157,6 +168,8 @@ query_t::lexer_t::next_token(query_t::lexer_t::token_t::kind_t tok_context) break; case ')': + if (unbalanced_braces(ident)) + consume_next = true; if (! consume_next && tok_context == token_t::TOK_EXPR) goto test_ident; // fall through... |