Mesa (master): glcpp: Add basic #line support ( adapted from the main compiler).

Kenneth Graunke kwg at kemper.freedesktop.org
Thu Aug 19 00:35:48 UTC 2010


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Aug 18 17:38:05 2010 -0700

glcpp: Add basic #line support (adapted from the main compiler).

---

 src/glsl/glcpp/glcpp-lex.l |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index a14e580..c81bd04 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -100,6 +100,37 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	return OTHER;
 }
 
+{HASH}line{HSPACE}+{DECIMAL_INTEGER}{HSPACE}+{DECIMAL_INTEGER}{HSPACE}*$ {
+	/* Eat characters until the first digit is
+	 * encountered
+	 */
+	char *ptr = yytext;
+	while (!isdigit(*ptr))
+		ptr++;
+
+	/* Subtract one from the line number because
+	 * yylineno is zero-based instead of
+	 * one-based.
+	 */
+	yylineno = strtol(ptr, &ptr, 0) - 1;
+	yylloc->source = strtol(ptr, NULL, 0);
+}
+
+{HASH}line{HSPACE}+{DECIMAL_INTEGER}{HSPACE}*$ {
+	/* Eat characters until the first digit is
+	 * encountered
+	 */
+	char *ptr = yytext;
+	while (!isdigit(*ptr))
+		ptr++;
+
+	/* Subtract one from the line number because
+	 * yylineno is zero-based instead of
+	 * one-based.
+	 */
+	yylineno = strtol(ptr, &ptr, 0) - 1;
+}
+
 {HASH}ifdef/.*\n {
 	yyextra->lexing_if = 1;
 	yyextra->space_tokens = 0;




More information about the mesa-commit mailing list