Mesa (master): glsl/glcpp: Allow single-line comments immediately after #define

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 7 23:08:46 UTC 2014


Module: Mesa
Branch: master
Commit: b4b2a5c3f31f0f66d3ddf1e994c099304d99ed4b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4b2a5c3f31f0f66d3ddf1e994c099304d99ed4b

Author: Carl Worth <cworth at cworth.org>
Date:   Tue Jul  1 17:47:29 2014 -0700

glsl/glcpp: Allow single-line comments immediately after #define

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.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 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 6e197d1..2cfe203 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -250,7 +250,7 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	}
 
 	/* Single-line comments */
-"//"[^\r\n]* {
+<INITIAL,DEFINE>"//"[^\r\n]* {
 }
 
 	/* Multi-line comments */




More information about the mesa-commit mailing list