Improved error reports about leading whitespace
This commit is contained in:
parent
dc91d4f1e6
commit
20c076dff9
5 changed files with 51 additions and 1178 deletions
|
|
@ -133,7 +133,7 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
void read_next_directive();
|
||||
void read_next_directive(bool& error_flag);
|
||||
|
||||
#if defined(TIMELOG_SUPPORT)
|
||||
void clock_in_directive(char * line, bool capitalized);
|
||||
|
|
@ -251,11 +251,15 @@ void instance_t::parse()
|
|||
context.linenum = 0;
|
||||
context.curr_pos = in.tellg();
|
||||
|
||||
bool error_flag = false;
|
||||
|
||||
while (in.good() && ! in.eof()) {
|
||||
try {
|
||||
read_next_directive();
|
||||
read_next_directive(error_flag);
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
error_flag = true;
|
||||
|
||||
string current_context = error_context();
|
||||
|
||||
if (parent) {
|
||||
|
|
@ -324,13 +328,16 @@ std::streamsize instance_t::read_line(char *& line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void instance_t::read_next_directive()
|
||||
void instance_t::read_next_directive(bool& error_flag)
|
||||
{
|
||||
char * line;
|
||||
std::streamsize len = read_line(line);
|
||||
if (len == 0 || line == NULL)
|
||||
return;
|
||||
|
||||
if (! std::isspace(line[0]))
|
||||
error_flag = false;
|
||||
|
||||
switch (line[0]) {
|
||||
case '\0':
|
||||
assert(false); // shouldn't ever reach here
|
||||
|
|
@ -338,7 +345,9 @@ void instance_t::read_next_directive()
|
|||
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (! error_flag)
|
||||
throw parse_error(_("Unexpected whitespace at beginning of line"));
|
||||
break;
|
||||
|
||||
case ';': // comments
|
||||
case '#':
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -10,12 +10,8 @@
|
|||
Asset:Bank:Boi:Savings:Dk -3016.24
|
||||
Income:NetSalary:Dk
|
||||
|
||||
test reg -> 3
|
||||
test reg -> 1
|
||||
__ERROR__
|
||||
While parsing file "$sourcepath/test/regress/8EAF77C0.test", line 5:
|
||||
Error: Unexpected whitespace at beginning of line
|
||||
While parsing file "$sourcepath/test/regress/8EAF77C0.test", line 6:
|
||||
Error: Unexpected whitespace at beginning of line
|
||||
While parsing file "$sourcepath/test/regress/8EAF77C0.test", line 7:
|
||||
Error: Unexpected whitespace at beginning of line
|
||||
end test
|
||||
|
|
|
|||
12
test/regress/AEDE9734.test
Normal file
12
test/regress/AEDE9734.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
2011-02-23 Rocket Fuel
|
||||
Expense:Travel $100000000.00 ; trip: Moon
|
||||
Asset:NASA
|
||||
|
||||
2011-02-23 Liquid Oxygen
|
||||
Expense:Travel $232233223.00 ; trip: Moon
|
||||
Asset:NASA
|
||||
|
||||
test bal --group-by "tag('trip')"
|
||||
Moon
|
||||
$332233223.00 Expense:Travel
|
||||
end test
|
||||
24
test/regress/D51BFF74.test
Normal file
24
test/regress/D51BFF74.test
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
2012-03-16 KFC
|
||||
Expenses:Food $-20
|
||||
Assets:Cash
|
||||
|
||||
2012-03-16 KFC
|
||||
Expenses:Food $- 20
|
||||
Assets:Cash
|
||||
|
||||
2012-03-16 KFC
|
||||
Expenses:Food -$20
|
||||
Assets:Cash
|
||||
|
||||
2012-03-16 KFC
|
||||
Expenses:Food - $20
|
||||
Assets:Cash
|
||||
|
||||
test reg -> 1
|
||||
__ERROR__
|
||||
While parsing file "$sourcepath/test/regress/D51BFF74.test", line 6:
|
||||
While parsing posting:
|
||||
Expenses:Food $- 20
|
||||
^^^^^
|
||||
Error: No quantity specified for amount
|
||||
end test
|
||||
Loading…
Add table
Reference in a new issue