-
-int yydebug = 1;
-
-void yyerror(const char *str) {
- fprintf(stderr,"error: %s\n",str);
+static struct context *context;
+
+/* We don’t need yydebug for now, as we got decent error messages using
+ * yyerror(). Should you ever want to extend the parser, it might be handy
+ * to just comment it in again, so it stays here. */
+//int yydebug = 1;
+
+void yyerror(const char *error_message) {
+ ELOG("\n");
+ ELOG("CONFIG: %s\n", error_message);
+ ELOG("CONFIG: in file \"%s\", line %d:\n",
+ context->filename, context->line_number);
+ ELOG("CONFIG: %s\n", context->line_copy);
+ ELOG("CONFIG: ");
+ for (int c = 1; c <= context->last_column; c++)
+ if (c >= context->first_column)
+ printf("^");
+ else printf(" ");
+ printf("\n");
+ ELOG("\n");