Module: wine Branch: master Commit: 071b0a5532fa2e69ea7a547ac0d8f106789d78a1 URL: https://gitlab.winehq.org/wine/wine/-/commit/071b0a5532fa2e69ea7a547ac0d8f10...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Mar 23 09:23:43 2023 +0100
widl: Enable bison locations option.
---
tools/widl/parser.h | 2 +- tools/widl/parser.l | 11 ++++++++--- tools/widl/parser.y | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/widl/parser.h b/tools/widl/parser.h index 6111193561f..2d35a2dd279 100644 --- a/tools/widl/parser.h +++ b/tools/widl/parser.h @@ -26,7 +26,7 @@ int parser_parse(void);
extern void generic_msg( const struct location *where, const char *s, const char *t, va_list ap ); -extern void parser_error( const char *message ); +extern void parser_error( const struct location *where, const char *message ); extern void init_location( struct location *where );
extern FILE *parser_in; diff --git a/tools/widl/parser.l b/tools/widl/parser.l index a89e9cc00b9..5437e6c5c5b 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -19,6 +19,7 @@ */
%option bison-bridge +%option bison-locations %option stack %option noinput nounput noyy_top_state %option noyywrap @@ -53,6 +54,7 @@ uuid {hd}{8}-{hd}{4}-{hd}{4}-{hd}{4}-{hd}{12}
#define YYerror PARSER_error #define YYSTYPE PARSER_STYPE +#define YYLTYPE PARSER_LTYPE #define YYUNDEF PARSER_UNDEF #define yyerror parser_error
@@ -197,13 +199,16 @@ static void winrt_enable( int ns_prefix ) } } <PP_LINE>[0-9]+{ws}* { - line_number = strtoul( yytext, NULL, 10 ) - 1; /* We didn't read the newline */ + yylloc->first_line = strtoul( yytext, NULL, 10 ) - 1; + yylloc->last_line = yylloc->first_line; + line_number = yylloc->first_line; yy_pop_state(); yy_push_state(PP_FILE); } <PP_FILE>"(\[^n]|[^"\\n])*"{ws}* { input_name = xstrdup( yytext + 1 ); *strchr( input_name, '"' ) = 0; + yylloc->input_name = input_name; } <PP_FILE>[^"][^\n]* { yy_pop_state(); }
@@ -557,9 +562,9 @@ void generic_msg( const struct location *where, const char *s, const char *t, va }
/* yyerror: yacc assumes this is not newline terminated. */ -void parser_error( const char *message ) +void parser_error( const struct location *where, const char *message ) { - error_loc( "%s\n", message ); + error_at( where, "%s\n", message ); }
static void warning_disable(int warning) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 97ee48cbfa7..35a392601e4 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -124,15 +124,17 @@ static typelib_t *current_typelib; %code provides {
-int parser_lex( PARSER_STYPE *yylval ); +int parser_lex( PARSER_STYPE *yylval, PARSER_LTYPE *yylloc ); void push_import( char *input_name ); void pop_import(void);
}
+%define api.location.type {struct location} %define api.prefix {parser_} %define api.pure full %define parse.error verbose +%locations
%union { attr_t *attr;