[PATCH vkd3d v2 2/5] vkd3d-shader: Parse comments in the preprocessor.
Zebediah Figura
zfigura at codeweavers.com
Fri Dec 4 01:03:45 CST 2020
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
libs/vkd3d-shader/preproc.l | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 1ae43a8d..966c11b0 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -36,16 +36,33 @@
%option never-interactive
%option noinput
%option nounput
+%option noyy_top_state
%option noyywrap
%option prefix="preproc_yy"
%option reentrant
+%option stack
+
+ /* Because these can both be terminated by EOF, we need states for them. */
+%s C_COMMENT
+%s CXX_COMMENT
WS [ \t]
%%
-{WS}+ {}
-. {return T_TEXT;}
+<INITIAL>"//" {yy_push_state(CXX_COMMENT, yyscanner);}
+<INITIAL>"/*" {yy_push_state(C_COMMENT, yyscanner);}
+<CXX_COMMENT>\\\r?\n {}
+<CXX_COMMENT>\n {
+ yy_pop_state(yyscanner);
+ return T_TEXT;
+ }
+<C_COMMENT>"*/" {yy_pop_state(yyscanner);}
+<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
+<C_COMMENT,CXX_COMMENT>. {}
+
+<INITIAL>{WS}+ {}
+<INITIAL>. {return T_TEXT;}
%%
--
2.29.2
More information about the wine-devel
mailing list