Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GLSL and HLSL preprocessor directive start #2357

Merged
merged 1 commit into from Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygments/lexers/graphics.py
Expand Up @@ -30,7 +30,7 @@ class GLShaderLexer(RegexLexer):

tokens = {
'root': [
(r'^#(?:.*\\\n)*.*$', Comment.Preproc),
(r'#(?:.*\\\n)*.*$', Comment.Preproc),
(r'//.*$', Comment.Single),
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
(r'\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?',
Expand Down Expand Up @@ -161,7 +161,7 @@ class HLSLShaderLexer(RegexLexer):

tokens = {
'root': [
(r'^#(?:.*\\\n)*.*$', Comment.Preproc),
(r'#(?:.*\\\n)*.*$', Comment.Preproc),
(r'//.*$', Comment.Single),
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
(r'\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?',
Expand Down
6 changes: 6 additions & 0 deletions tests/examplefiles/glsl/glsl.frag
@@ -1,5 +1,11 @@
/* Fragment shader */

// Macro inside a single-line comment: #define COMMENT_MACRO 1

/* Macro inside a block comment: #define COMMENT_MACRO 2 */

# define INDENTED_MACRO 5.0

#define SINGLELINE_MACRO 10.0

#define MULTILINE_MACRO(a, b) vec2( \
Expand Down
8 changes: 8 additions & 0 deletions tests/examplefiles/glsl/glsl.frag.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/examplefiles/glsl/glsl.vert
@@ -1,5 +1,11 @@
/* Vertex shader */

// Macro inside a single-line comment: #define COMMENT_MACRO 1

/* Macro inside a block comment: #define COMMENT_MACRO 2 */

# define INDENTED_MACRO 5.0

#define SINGLELINE_MACRO 10.0

#define MULTILINE_MACRO(a, b) vec2( \
Expand Down
8 changes: 8 additions & 0 deletions tests/examplefiles/glsl/glsl.vert.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/examplefiles/hlsl/example.hlsl
@@ -1,5 +1,11 @@
// A few random snippets of HLSL shader code I gathered...

// Macro inside a single-line comment: #define COMMENT_MACRO 1

/* Macro inside a block comment: #define COMMENT_MACRO 2 */

# define INDENTED_MACRO 5.0

#define SINGLELINE_MACRO 10.0

#define MULTILINE_MACRO(a, b) float2( \
Expand Down
8 changes: 8 additions & 0 deletions tests/examplefiles/hlsl/example.hlsl.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.