Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
9b984891
Commit
9b984891
authored
1 year ago
by
Elizabeth Figura
Committed by
Alexandre Julliard
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/preproc: Parse hash marks as two separate tokens when not in stringification contexts.
parent
9a80ff28
No related branches found
No related tags found
1 merge request
!291
vkd3d-shader/preproc: Various fixes.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/vkd3d-shader/preproc.l
+22
-15
22 additions, 15 deletions
libs/vkd3d-shader/preproc.l
tests/preproc-macro.shader_test
+4
-0
4 additions, 0 deletions
tests/preproc-macro.shader_test
with
26 additions
and
15 deletions
libs/vkd3d-shader/preproc.l
+
22
−
15
View file @
9b984891
...
...
@@ -29,6 +29,13 @@
#define YY_DECL static int preproc_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
static struct preproc_macro *preproc_get_top_macro(struct preproc_ctx *ctx)
{
if (!ctx->expansion_count)
return NULL;
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
}
static void update_location(struct preproc_ctx *ctx);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner));
...
...
@@ -124,7 +131,20 @@ INT_SUFFIX [uUlL]{0,2}
const char *p;
if (!ctx->last_was_newline)
return T_HASHSTRING;
{
struct preproc_macro *macro;
/* Stringification is only done for function-like macro bodies.
* Anywhere else, we need to parse it as two separate tokens.
* We could use a state for this, but yyless() is easier and cheap.
*/
if ((macro = preproc_get_top_macro(ctx)) && macro->arg_count)
return T_HASHSTRING;
yyless(1);
return T_TEXT;
}
for (p = yytext + 1; strchr(" \t", *p); ++p)
;
...
...
@@ -218,13 +238,6 @@ static bool preproc_is_writing(struct preproc_ctx *ctx)
return file->if_stack[file->if_count - 1].current_true;
}
static struct preproc_macro *preproc_get_top_macro(struct preproc_ctx *ctx)
{
if (!ctx->expansion_count)
return NULL;
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
}
/* Concatenation is not done for object-like macros, but is done for both
* function-like macro bodies and their arguments. */
static bool should_concat(struct preproc_ctx *ctx)
...
...
@@ -440,9 +453,6 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
switch (func_state->state)
{
case STATE_NONE:
{
struct preproc_macro *macro;
if (token == T_CONCAT && should_concat(ctx))
{
while (ctx->buffer.content_size
...
...
@@ -451,9 +461,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
break;
}
/* Stringification, however, is only done for function-like
* macro bodies. */
if (token == T_HASHSTRING && (macro = preproc_get_top_macro(ctx)) && macro->arg_count)
if (token == T_HASHSTRING)
{
const struct preproc_text *expansion;
const char *p = text + 1;
...
...
@@ -585,7 +593,6 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
else
vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
break;
}
case STATE_IDENTIFIER:
if (token == '(')
...
...
This diff is collapsed.
Click to expand it.
tests/preproc-macro.shader_test
+
4
−
0
View file @
9b984891
...
...
@@ -301,3 +301,7 @@ fail
[preproc]
#define __LINE__ pass
__LINE__
[preproc]
#define KEY pass
apple # KEY
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment