Zebediah Figura : vkd3d-shader: Parse #line directives.
Alexandre Julliard
julliard at winehq.org
Tue Jan 26 15:53:16 CST 2021
Module: vkd3d
Branch: master
Commit: 160db8306f2a2cb86c3df973cfdb5c4b5c4751df
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=160db8306f2a2cb86c3df973cfdb5c4b5c4751df
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Mon Jan 25 11:23:56 2021 -0600
vkd3d-shader: Parse #line directives.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/preproc.l | 20 ++++++++++++++------
libs/vkd3d-shader/preproc.y | 12 ++++++++++++
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 1bf14ff..0ce75f0 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -52,6 +52,7 @@ static void update_location(struct preproc_ctx *ctx);
%s ERROR
%s INCLUDE
+%s LINE
NEWLINE \r?\n
WS [ \t]
@@ -91,9 +92,9 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>[0-9]+\.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
<INITIAL>[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;}
<INITIAL>[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;}
-<INITIAL>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_INTEGER;}
-<INITIAL>0[0-7]*[ul]{0,2} {return T_INTEGER;}
-<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
+<INITIAL,LINE>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_INTEGER;}
+<INITIAL,LINE>0[0-7]*[ul]{0,2} {return T_INTEGER;}
+<INITIAL,LINE>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
<INITIAL>## {return T_CONCAT;}
@@ -103,7 +104,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>">>"=? {return T_TEXT;}
<INITIAL>[-+*/%&|^]= {return T_TEXT;}
-<INCLUDE>\"[^"]*\" {return T_STRING;}
+<INCLUDE,LINE>\"[^"]*\" {return T_STRING;}
<INCLUDE>\<[^>]*\> {return T_STRING;}
/* C strings (including escaped quotes). */
@@ -131,6 +132,12 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
return T_INCLUDE;
}
+ if (!strcmp(p, "line"))
+ {
+ BEGIN(LINE);
+ return T_LINE;
+ }
+
if (!strcmp(p, "define"))
return T_DEFINE;
if (!strcmp(p, "elif"))
@@ -155,8 +162,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
return T_TEXT;
}
-<INITIAL,INCLUDE>\\{NEWLINE} {}
-<INITIAL,INCLUDE,ERROR>{NEWLINE} {
+<INITIAL,INCLUDE,LINE>\\{NEWLINE} {}
+<INITIAL,INCLUDE,ERROR,LINE>{NEWLINE} {
BEGIN(INITIAL);
return T_NEWLINE;
}
@@ -371,6 +378,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
case T_IFDEF:
case T_IFNDEF:
case T_INCLUDE:
+ case T_LINE:
case T_PRAGMA:
case T_UNDEF:
ctx->current_directive = token;
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index 7a99543..01437b2 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -327,6 +327,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%token T_IFDEF "#ifdef"
%token T_IFNDEF "#ifndef"
%token T_INCLUDE "#include"
+%token T_LINE "#line"
%token T_PRAGMA "#pragma"
%token T_UNDEF "#undef"
@@ -671,6 +672,17 @@ directive
}
vkd3d_free($2);
}
+ | T_LINE T_INTEGER T_NEWLINE
+ {
+ FIXME("#line directive.\n");
+ vkd3d_free($2);
+ }
+ | T_LINE T_INTEGER T_STRING T_NEWLINE
+ {
+ FIXME("#line directive.\n");
+ vkd3d_free($2);
+ vkd3d_free($3);
+ }
primary_expr
: T_INTEGER
More information about the wine-cvs
mailing list