Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
fbp-parser: print wrong statement on error
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Dilly <bruno.dilly@intel.com>
  • Loading branch information
bdilly committed Sep 16, 2015
1 parent 7e2efb3 commit d1aacf0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/shared/sol-fbp-internal-scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ struct sol_fbp_token {
unsigned int column;
};

/* To be used together with "%.*s" formatting in printf family of functions. */
#define SOL_FBP_TOKEN_PRINT(_s) (int)((_s).end - (_s).start + 1), (_s).start

struct sol_fbp_scanner {
const char *input_end;
struct sol_fbp_token token;
Expand Down
3 changes: 2 additions & 1 deletion src/shared/sol-fbp-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ parse_stmt(struct sol_fbp_parser *p)
default:
/* Ensure error is at the token that couldn't be parsed. */
next_token(p);
return set_parse_error(p, "Couldn't parse statement.");
return set_parse_error(p, "Couldn't parse statement '%.*s'.",
SOL_FBP_TOKEN_PRINT(p->current_token));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test-fbp/parser-errors/brackets-instead-of-parens.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
## TEST-EXPECTS-ERROR

## TEST-OUTPUT
# brackets-instead-of-parens.fbp:31:1 Couldn't parse statement.
# brackets-instead-of-parens.fbp:31:1 Couldn't parse statement '[F'.
## TEST-SKIP-COMPILE This test should not be generated + compiled, test parser errors is its sole purpose

2 changes: 1 addition & 1 deletion src/test-fbp/parser-errors/component-without-node.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
## TEST-EXPECTS-ERROR

## TEST-OUTPUT
# component-without-node.fbp:31:1 Couldn't parse statement.
# component-without-node.fbp:31:1 Couldn't parse statement '(F'.
## TEST-SKIP-COMPILE This test should not be generated + compiled, test parser errors is its sole purpose

0 comments on commit d1aacf0

Please sign in to comment.