Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
472b2eca
Commit
472b2eca
authored
Mar 23, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Improve accuracy of error messages location.
parent
071b0a55
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
27 deletions
+70
-27
parser.h
tools/widl/parser.h
+1
-1
parser.l
tools/widl/parser.l
+58
-19
parser.y
tools/widl/parser.y
+9
-5
typetree.c
tools/widl/typetree.c
+2
-2
No files found.
tools/widl/parser.h
View file @
472b2eca
...
...
@@ -27,7 +27,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
struct
location
*
where
,
const
char
*
message
);
extern
void
init_location
(
struct
location
*
where
);
extern
void
init_location
(
struct
location
*
copy
,
const
struct
location
*
begin
,
const
struct
location
*
end
);
extern
FILE
*
parser_in
;
extern
int
parser_debug
;
...
...
tools/widl/parser.l
View file @
472b2eca
...
...
@@ -60,6 +60,13 @@ uuid {hd}{8}-{hd}{4}-{hd}{4}-{hd}{4}-{hd}{12}
#include "parser.tab.h"
static void reset_location( struct location *where, const char *input_name );
static void update_location( struct location *where, const char *yytext );
static void end_of_line( struct location *where );
#define YY_USER_INIT reset_location( yylloc, input_name )
#define YY_USER_ACTION update_location( yylloc, yytext );
static void switch_to_acf(void);
static warning_list_t *disabled_warnings = NULL;
...
...
@@ -68,7 +75,7 @@ struct import_state
{
YY_BUFFER_STATE buffer;
char *input_name;
int line_number
;
struct location where
;
struct list entry;
};
static struct list import_stack = LIST_INIT( import_stack );
...
...
@@ -80,7 +87,7 @@ struct import
struct list entry;
};
static struct list imports = LIST_INIT( imports );
static
int line_number = 1
;
static
struct location previous_location
;
/* converts an integer in string form to an unsigned long and prints an error
* on overflow */
...
...
@@ -183,25 +190,28 @@ static void winrt_enable( int ns_prefix )
<PP_PRAGMA>{
midl_echo/"(" {
yy_pop_state();
yylloc->first_line -= 1;
return tCPPQUOTE;
}
winrt{ws}+ns_prefix[^\n]* {
yy_pop_state();
yylloc->first_line -= 1;
winrt_enable( TRUE );
}
winrt[^\n]* {
yy_pop_state();
yylloc->first_line -= 1;
winrt_enable( FALSE );
}
[^\n]* {
yy_pop_state();
yylloc->first_line -= 1;
return token_str( aPRAGMA, yytext, yylval );
}
}
<PP_LINE>[0-9]+{ws}* {
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);
}
...
...
@@ -424,7 +434,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
\"(\\.|[^"\\])*\" { return token_str( aSTRING, yytext, yylval ); }
\'(\\.|[^'\\])*\' { return token_str( aSQSTRING, yytext, yylval ); }
\n {
line_number++
; }
\n {
end_of_line( yylloc )
; }
{ws} {}
\<\< { return SHL; }
\>\> { return SHR; }
...
...
@@ -451,7 +461,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
}
%%
void pop_import(
void
)
void pop_import(
struct location *where
)
{
struct list *entry = list_head( &import_stack );
struct import_state *state;
...
...
@@ -466,11 +476,11 @@ void pop_import(void)
yy_switch_to_buffer( state->buffer );
input_name = state->input_name;
line_number = state->line_number
;
*where = state->where
;
free( state );
}
void push_import( c
har *import_nam
e )
void push_import( c
onst char *import_name, struct location *wher
e )
{
struct import_state *state;
struct import *import;
...
...
@@ -482,7 +492,7 @@ void push_import( char *import_name )
state->buffer = YY_CURRENT_BUFFER;
state->input_name = input_name;
state->
line_number = line_number
;
state->
where = *where
;
input_name = NULL;
/* reset buffer for <<EOF>>, in case import fails or already imported */
...
...
@@ -497,7 +507,7 @@ void push_import( char *import_name )
input_name = find_input_file( import_name, state->input_name );
file = open_input_file( input_name );
line_number = 1
;
reset_location( where, input_name )
;
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
}
...
...
@@ -511,13 +521,35 @@ static void switch_to_acf(void)
input_name = xstrdup( acf_name );
file = open_input_file( input_name );
line_number = 1;
acf_name = NULL;
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
}
#define CURRENT_LOCATION { input_name ? input_name : "stdin", parser_text, line_number, 0, line_number, 0 }
static void reset_location( struct location *where, const char *input_name )
{
where->first_line = 1;
where->last_line = 1;
where->first_column = 1;
where->last_column = 1;
where->input_name = xstrdup( input_name );
}
static void update_location( struct location *where, const char *yytext )
{
int len = strlen( yytext );
previous_location = *where;
where->first_column = where->last_column;
where->last_column += len;
}
static void end_of_line( struct location *where )
{
where->first_line++;
where->last_line++;
where->first_column = 1;
where->last_column = 1;
}
static const int want_near_indication = 0;
...
...
@@ -531,19 +563,26 @@ static void make_print(char *str)
}
}
void init_location( struct location *where )
void init_location( struct location *where
, const struct location *begin, const struct location *end
)
{
where->input_name = input_name ? input_name : "stdin";
where->near_text = parser_text;
where->first_line = line_number;
where->last_line = line_number;
if (!begin) begin = &previous_location;
*where = *begin;
if (end)
{
where->last_line = end->last_line;
where->last_column = end->last_column;
}
else
{
where->first_line = begin->last_line;
where->first_column = begin->last_column;
}
}
void generic_msg( const struct location *where, const char *s, const char *t, va_list ap )
{
struct location cur_loc = CURRENT_LOCATION;
if (!where) where = &cur_loc;
if (!where) where = &previous_location;
fprintf( stderr, "%s:%d: %s: ", where->input_name, where->first_line, t );
vfprintf( stderr, s, ap );
...
...
tools/widl/parser.y
View file @
472b2eca
...
...
@@ -125,8 +125,12 @@ static typelib_t *current_typelib;
{
int parser_lex( PARSER_STYPE *yylval, PARSER_LTYPE *yylloc );
void push_import( char *input_name );
void pop_import(void);
void push_import( const char *fname, PARSER_LTYPE *yylloc );
void pop_import( PARSER_LTYPE *yylloc );
# define YYLLOC_DEFAULT( cur, rhs, n ) \
do { if (n) init_location( &(cur), &YYRHSLOC( rhs, 1 ), &YYRHSLOC( rhs, n ) ); \
else init_location( &(cur), &YYRHSLOC( rhs, 0 ), NULL ); } while(0)
}
...
...
@@ -511,9 +515,9 @@ typedecl:
cppquote: tCPPQUOTE '(' aSTRING ')' { $$ = $3; }
;
import_start: tIMPORT aSTRING ';' { $$ = $2; push_import(
$2
); }
import_start: tIMPORT aSTRING ';' { $$ = $2; push_import(
$2, &yylloc
); }
;
import: import_start imp_statements aEOF { pop_import(); }
import: import_start imp_statements aEOF { pop_import(
&yylloc
); }
;
importlib: tIMPORTLIB '(' aSTRING ')'
...
...
@@ -1974,7 +1978,7 @@ var_t *make_var(char *name)
init_declspec(&v->declspec, NULL);
v->attrs = NULL;
v->eval = NULL;
init_location( &v->where );
init_location( &v->where
, NULL, NULL
);
v->declonly = FALSE;
return v;
}
...
...
tools/widl/typetree.c
View file @
472b2eca
...
...
@@ -65,7 +65,7 @@ type_t *make_type(enum type_type type)
t
->
tfswrite
=
FALSE
;
t
->
checked
=
FALSE
;
t
->
typelib_idx
=
-
1
;
init_location
(
&
t
->
where
);
init_location
(
&
t
->
where
,
NULL
,
NULL
);
return
t
;
}
...
...
@@ -478,7 +478,7 @@ type_t *type_new_alias(const decl_spec_t *t, const char *name)
a
->
name
=
xstrdup
(
name
);
a
->
attrs
=
NULL
;
a
->
details
.
alias
.
aliasee
=
*
t
;
init_location
(
&
a
->
where
);
init_location
(
&
a
->
where
,
NULL
,
NULL
);
return
a
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment