[Mesa-dev] [PATCH 2/6] glsl/glcpp: Allow single-line comments immediately after #define

Carl Worth cworth at cworth.org
Tue Jul 1 18:03:37 PDT 2014


We were already correctly supporting single-line comments in case like:

	#define FOO bar // comment here...

The new support added here is simply for the none-too-useful:

	#define // comment instead of macro name

With this commit, this line will now give the expected "#define without
macro name" error message instead of the lexer just going off into the
weeds.
---
 src/glsl/glcpp/glcpp-lex.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 8b4be64..09dba35 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -251,7 +251,7 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	}
 
 	/* Single-line comments */
-"//"[^\r\n]* {
+<INITIAL,DEFINE>"//"[^\r\n]* {
 }
 
 	/* Multi-line comments */
-- 
2.0.0



More information about the mesa-dev mailing list