Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
194c002c
Commit
194c002c
authored
Mar 17, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Simplify string literals lexing.
parent
baa3680f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
51 deletions
+24
-51
parser.l
tools/widl/parser.l
+24
-51
No files found.
tools/widl/parser.l
View file @
194c002c
...
...
@@ -35,12 +35,9 @@ hex 0(x|X){hexd}+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
%x QUOTE
%x WSTRQUOTE
%x ATTR
%x PP_LINE
%x PP_PRAGMA
%x SQUOTE
%{
...
...
@@ -67,13 +64,6 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
#include "parser.tab.h"
static void addcchar(char c);
static char *get_buffered_cstring(void);
static char *cbuffer;
static int cbufidx;
static int cbufalloc = 0;
static int kw_token(const char *kw, YYSTYPE *yylval);
static int attr_token(const char *kw, YYSTYPE *yylval);
...
...
@@ -131,6 +121,26 @@ struct uuid *parse_uuid(const char *u)
return uuid;
}
static int token_str( int token, const char *str, YYSTYPE *yylval )
{
char *tmp = xstrdup( str );
if (token == aWSTRING || token == aSTRING || token == aSQSTRING)
{
char *src, *dst;
src = dst = ++tmp; /* skip first quote */
while (*src)
{
if (*src == '\\') src++;
*dst++ = *src++;
}
dst[-1] = 0; /* strip last quote */
}
yylval->str = tmp;
return token;
}
static int token_num( int token, const char *yytext, YYSTYPE *yylval )
{
yylval->num = xstrtoul( yytext, NULL, 0 );
...
...
@@ -182,29 +192,6 @@ static int token_num( int token, const char *yytext, YYSTYPE *yylval )
yy_pop_state();
}
<PP_PRAGMA>[^\n]* yylval->str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
<QUOTE>\" {
yy_pop_state();
yylval->str = get_buffered_cstring();
return aSTRING;
}
<INITIAL,ATTR>L\" yy_push_state(WSTRQUOTE); cbufidx = 0;
<WSTRQUOTE>\" {
yy_pop_state();
yylval->str = get_buffered_cstring();
return aWSTRING;
}
<INITIAL,ATTR>\' yy_push_state(SQUOTE); cbufidx = 0;
<SQUOTE>\' {
yy_pop_state();
yylval->str = get_buffered_cstring();
return aSQSTRING;
}
<QUOTE,WSTRQUOTE,SQUOTE>\\\\ |
<QUOTE,WSTRQUOTE>\\\" addcchar(yytext[1]);
<SQUOTE>\\\' addcchar(yytext[1]);
<QUOTE,WSTRQUOTE,SQUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
<QUOTE,WSTRQUOTE,SQUOTE>. addcchar(yytext[0]);
<ATTR>{
\] { yy_pop_state(); return ']'; }
...
...
@@ -236,6 +223,10 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
{hex} { return token_num( aHEXNUM, yytext, yylval ); }
{int} { return token_num( aNUM, yytext, yylval ); }
L\"(\\.|[^"\\])*\" { return token_str( aWSTRING, yytext + 1, yylval ); }
\"(\\.|[^"\\])*\" { return token_str( aSTRING, yytext, yylval ); }
\'(\\.|[^'\\])*\' { return token_str( aSQSTRING, yytext, yylval ); }
\n { line_number++; }
{ws} {}
\<\< { return SHL; }
...
...
@@ -508,24 +499,6 @@ static int attr_token(const char *kw, YYSTYPE *yylval)
return kw_token(kw, yylval);
}
static void addcchar(char c)
{
if(cbufidx >= cbufalloc)
{
cbufalloc += 1024;
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
if(cbufalloc > 65536)
parser_warning("Reallocating string buffer larger than 64kB\n");
}
cbuffer[cbufidx++] = c;
}
static char *get_buffered_cstring(void)
{
addcchar(0);
return xstrdup(cbuffer);
}
void pop_import(void)
{
struct list *entry = list_head( &import_stack );
...
...
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