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,
#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);
%pure-parser
%error-verbose
+%locations
%parse-param {glcpp_parser_t *parser}
%lex-param {glcpp_parser_t *parser}
non_directive:
pp_tokens NEWLINE {
- yyerror (parser, "Invalid tokens after #");
+ yyerror (& @1, parser, "Invalid tokens after #");
}
;
}
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 *
}
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
# 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;
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);