From eb0c48b789bbf41745287adb6b2949f84e7e9171 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 29 Mar 2012 03:19:50 +0200 Subject: Config parse: add location tracking for nice error messages --- src/config.y | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/config.y') diff --git a/src/config.y b/src/config.y index 78c0833..1e75da8 100644 --- a/src/config.y +++ b/src/config.y @@ -27,8 +27,10 @@ %define api.pure %define api.push-pull push %name-prefix "fastd_config_" +%locations %parse-param {fastd_context *ctx} %parse-param {fastd_config *conf} +%parse-param {const char *filename} %parse-param {int depth} %code requires { @@ -78,7 +80,7 @@ #include #include - void fastd_config_error(fastd_context *ctx, fastd_config *conf, int depth, char *s); + void fastd_config_error(YYLTYPE *loc, fastd_context *ctx, fastd_config *conf, const char *filename, int depth, char *s); extern fastd_protocol fastd_protocol_null; @@ -237,6 +239,6 @@ port: TOK_INTEGER { } ; %% -void fastd_config_error(fastd_context *ctx, fastd_config *conf, int depth, char *s) { - exit_error(ctx, "config error: %s", s); +void fastd_config_error(YYLTYPE *loc, fastd_context *ctx, fastd_config *conf, const char *filename, int depth, char *s) { + exit_error(ctx, "config error: %s at %s:%i:%i", s, filename, loc->first_line, loc->first_column); } -- cgit v1.2.3