diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-22 21:16:43 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-22 21:16:43 -0400 |
commit | 812d38c176b76b0fda5228338f5c5d70b3c6edf1 (patch) | |
tree | 75b50d517d948fe6808dcc1fc3b9e6594fb573fb /src/parser.cc | |
parent | d9e97cfede4afcda55eaa8defaaa63c0c18065b1 (diff) | |
download | fork-ledger-812d38c176b76b0fda5228338f5c5d70b3c6edf1.tar.gz fork-ledger-812d38c176b76b0fda5228338f5c5d70b3c6edf1.tar.bz2 fork-ledger-812d38c176b76b0fda5228338f5c5d70b3c6edf1.zip |
Correctly report the line context when there is a valexpr parsing error.
Diffstat (limited to 'src/parser.cc')
-rw-r--r-- | src/parser.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/parser.cc b/src/parser.cc index 82bc771d..4881f7bc 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -399,11 +399,21 @@ expr_t::parser_t::parse(std::istream& in, const flags_t flags, return top_node; } catch (const std::exception& err) { - add_error_context("While parsing value expression:"); if (original_string) { - istream_pos_type pos = in.tellg(); - pos -= 1; - add_error_context(line_context(*original_string, pos)); + add_error_context("While parsing value expression:"); + + istream_pos_type end_pos = in.tellg(); + istream_pos_type pos = end_pos; + + pos -= lookahead.length; + + DEBUG("parser.error", "original_string = '" << *original_string << "'"); + DEBUG("parser.error", " pos = " << pos); + DEBUG("parser.error", " end_pos = " << end_pos); + DEBUG("parser.error", " token kind = " << int(lookahead.kind)); + DEBUG("parser.error", " token length = " << lookahead.length); + + add_error_context(line_context(*original_string, pos, end_pos)); } throw; } |