diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-10 16:06:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-10 16:06:17 +0200 |
commit | 4d134880196e85e06d5ff4e83a26a3b15027706a (patch) | |
tree | 5db9e055361e7573874433d8367c2dd2cf27e508 | |
parent | a7e3df85fd7180aa0daf0947e50b08d51b7e2380 (diff) |
Keep track of {}-balance in addition to ()-balance in expressions
This allows us, for example, to use brace-initializer syntax.
-rw-r--r-- | odb/pragma.cxx | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 11e1d4e..9bf38c5 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -163,9 +163,9 @@ parse_expression (cxx_lexer& l, string const& prag) { // Keep reading tokens until we see a mis-matching ')' or ',' while - // keeping track of the '()' balance. + // keeping track of the '()' and '{}' balance. // - size_t balance (0); + size_t p_balance (0), b_balance (0); for (; tt != CPP_EOF; tt = l.next (tl, &tn)) { @@ -174,22 +174,32 @@ parse_expression (cxx_lexer& l, switch (tt) { + case CPP_OPEN_BRACE: + { + b_balance++; + break; + } + case CPP_CLOSE_BRACE: + { + b_balance--; + break; + } case CPP_OPEN_PAREN: { - balance++; + p_balance++; break; } case CPP_CLOSE_PAREN: { - if (balance == 0) + if (p_balance == 0 && b_balance == 0) done = true; else - balance--; + p_balance--; break; } case CPP_COMMA: { - if (balance == 0) + if (p_balance == 0 && b_balance == 0) done = true; else break; |