glcpp: Add plumbing to support line locations.
diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l
index a04e0fa..f173369 100644
--- a/glcpp/glcpp-lex.l
+++ b/glcpp/glcpp-lex.l
@@ -29,7 +29,7 @@
 #include "glcpp-parse.h"
 %}
 
-%option bison-bridge reentrant noyywrap
+%option bison-bridge bison-locations reentrant noyywrap
 %option extra-type="glcpp_parser_t *"
 %option prefix="glcpp_"
 
diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y
index c5c03b6..52927d8 100644
--- a/glcpp/glcpp-parse.y
+++ b/glcpp/glcpp-parse.y
@@ -34,7 +34,7 @@
 	stream = talloc_asprintf_append(stream, fmt, args)
 
 static void
-yyerror (glcpp_parser_t *parser, const char *error);
+yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
 
 static void
 _define_object_macro (glcpp_parser_t *parser,
@@ -133,7 +133,7 @@
 #define yylex glcpp_parser_lex
 
 static int
-glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser);
+glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
 
 static void
 glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
@@ -142,6 +142,7 @@
 
 %pure-parser
 %error-verbose
+%locations
 
 %parse-param {glcpp_parser_t *parser}
 %lex-param {glcpp_parser_t *parser}
@@ -364,7 +365,7 @@
 
 non_directive:
 	pp_tokens NEWLINE {
-		yyerror (parser, "Invalid tokens after #");
+		yyerror (& @1, parser, "Invalid tokens after #");
 	}
 ;
 
@@ -861,9 +862,10 @@
 }
 
 void
-yyerror (glcpp_parser_t *parser, const char *error)
+yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
 {
-	glcpp_printf(parser->errors, "Parse error: %s\n", error);
+	glcpp_printf(parser->errors, "%u:%u(%u): preprocessor error: %s\n",
+		     locp->source, locp->first_line, locp->first_column, error);
 }
 
 glcpp_parser_t *
@@ -1452,13 +1454,13 @@
 }
 
 static int
-glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser)
+glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
 {
 	token_node_t *node;
 	int ret;
 
 	if (parser->lex_from_list == NULL) {
-		ret = glcpp_lex (yylval, parser->scanner);
+		ret = glcpp_lex (yylval, yylloc, parser->scanner);
 
 		/* XXX: This ugly block of code exists for the sole
 		 * purpose of converting a NEWLINE token into a SPACE
diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h
index 3441ab8..1d139af 100644
--- a/glcpp/glcpp.h
+++ b/glcpp/glcpp.h
@@ -59,6 +59,16 @@
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 
+typedef struct YYLTYPE {
+   int first_line;
+   int first_column;
+   int last_line;
+   int last_column;
+   unsigned source;
+} YYLTYPE;
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+
 struct token {
 	int type;
 	YYSTYPE value;
@@ -163,7 +173,7 @@
 glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader);
 
 int
-glcpp_lex (YYSTYPE *lvalp, yyscan_t scanner);
+glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner);
 
 int
 glcpp_lex_destroy (yyscan_t scanner);