summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-08-18 17:38:05 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-08-18 17:38:47 -0700
commit9cf62bdfeb3982405b9360500d7e0fa52036f38f (patch)
tree633a8420f00754f1b8e52dd8aac530b8378d5b66
parent49dfa89873403967d9f99d08d2e25042dea544e0 (diff)
glcpp: Add basic #line support (adapted from the main compiler).
-rw-r--r--src/glsl/glcpp/glcpp-lex.l31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index a14e580ab1..c81bd044a2 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;