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
858ec42a
Commit
858ec42a
authored
Jan 24, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Simplify preprocessor directive lexing.
parent
83f9f2cd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
parser.l
tools/widl/parser.l
+32
-32
No files found.
tools/widl/parser.l
View file @
858ec42a
...
...
@@ -31,6 +31,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
%x ATTR
%x PP_LINE
%x PP_FILE
%x PP_PRAGMA
%{
...
...
@@ -153,6 +154,14 @@ static int token_num( int token, const char *yytext, YYSTYPE *yylval )
return token;
}
static void winrt_enable( int ns_prefix )
{
if (!list_empty( &import_stack ) && !winrt_mode) error_loc( "WinRT IDL file imported in non-winrt mode." );
use_abi_namespace = ns_prefix;
winrt_mode = TRUE;
}
%}
/*
...
...
@@ -161,43 +170,34 @@ static int token_num( int token, const char *yytext, YYSTYPE *yylval )
**************************************************************************
*/
%%
<PP_LINE>[^\n]* {
int lineno;
char *cptr, *fname;
<PP_PRAGMA>{
midl_echo/"(" {
yy_pop_state();
lineno = (int)strtol(yytext, &cptr, 10);
if(!lineno)
error_loc("Malformed '#...' line-directive; invalid linenumber\n");
fname = strchr(cptr, '"');
if(!fname)
error_loc("Malformed '#...' line-directive; missing filename\n");
fname++;
cptr = strchr(fname, '"');
if(!cptr)
error_loc("Malformed '#...' line-directive; missing terminating \"\n");
*cptr = '\0';
line_number = lineno - 1; /* We didn't read the newline */
input_name = xstrdup(fname);
return tCPPQUOTE;
}
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
<PP_PRAGMA>winrt[^\n]* {
if (!list_empty( &import_stack ))
{
if(!winrt_mode)
error_loc("winrt IDL file imported in non-winrt mode\n");
}else {
const char *ptr = yytext+5;
winrt_mode = TRUE;
while(isspace(*ptr))
ptr++;
if(!strncmp(ptr, "ns_prefix", 9) && (!*(ptr += 9) || isspace(*ptr)))
use_abi_namespace = TRUE;
winrt{ws}+ns_prefix[^\n]* {
yy_pop_state();
winrt_enable( TRUE );
}
winrt[^\n]* {
yy_pop_state();
winrt_enable( FALSE );
}
[^\n]* {
yy_pop_state();
return token_str( aPRAGMA, yytext, yylval );
}
}
<PP_LINE>[0-9]+{ws}* {
line_number = strtoul( yytext, NULL, 10 ) - 1; /* We didn't read the newline */
yy_pop_state();
yy_push_state(PP_FILE);
}
<PP_FILE>\"(\\[^n]|[^"\\\n])*\"{ws}* {
input_name = xstrdup( yytext + 1 );
*strchr( input_name, '"' ) = 0;
}
<PP_
PRAGMA>[^\n]* yylval->str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
<PP_
FILE>[^"][^\n]* { yy_pop_state(); }
<ATTR>{
\] { yy_pop_state(); return ']'; }
...
...
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