glcpp: Support #elif(expression) with no intervening space.
authorMatt Turner <mattst88@gmail.com>
Mon, 26 Nov 2012 19:53:45 +0000 (11:53 -0800)
committerMatt Turner <mattst88@gmail.com>
Wed, 28 Nov 2012 18:27:02 +0000 (10:27 -0800)
And add test cases to ensure that this works
- 110 verifies that glcpp rejects #elif<digits> which glcpp
  previously accepted.
- 111 verifies that glcpp accepts #if followed immediately by
  (, +, -, !, or ~.
- 112 does the same as 111 but for #elif.

See 17f9beb6 for #if change.
Reviewed-by: Carl Worth <cworth@cworth.org>
src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c [new file with mode: 0644]
src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected [new file with mode: 0644]
src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c [new file with mode: 0644]
src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected [new file with mode: 0644]
src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c [new file with mode: 0644]
src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected [new file with mode: 0644]

index 4f0dd34d30da59d9f60b5b6bcbbadea62546092e..fd28711d12cebec2665f8380cb0b013a3c96564e 100644 (file)
@@ -158,7 +158,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
        return HASH_IF;
 }
 
-{HASH}elif {
+{HASH}elif/[^_a-zA-Z0-9] {
        yyextra->lexing_if = 1;
        yyextra->space_tokens = 0;
        return HASH_ELIF;
diff --git a/src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c b/src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c
new file mode 100644 (file)
index 0000000..6d7d0f3
--- /dev/null
@@ -0,0 +1,3 @@
+#if 1
+#elif110
+#endif
diff --git a/src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected b/src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected
new file mode 100644 (file)
index 0000000..6d5e9d1
--- /dev/null
@@ -0,0 +1,4 @@
+0:2(2): preprocessor error: Invalid tokens after #
+
+
+
diff --git a/src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c b/src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c
new file mode 100644 (file)
index 0000000..b341337
--- /dev/null
@@ -0,0 +1,19 @@
+#if(1)
+success
+#endif
+
+#if+1
+success
+#endif
+
+#if-1
+success
+#endif
+
+#if!1
+success
+#endif
+
+#if~1
+success
+#endif
diff --git a/src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected b/src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected
new file mode 100644 (file)
index 0000000..e083008
--- /dev/null
@@ -0,0 +1,20 @@
+
+success
+
+
+
+success
+
+
+
+success
+
+
+
+
+
+
+
+success
+
+
diff --git a/src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c b/src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c
new file mode 100644 (file)
index 0000000..e8221bc
--- /dev/null
@@ -0,0 +1,24 @@
+#if 0
+#elif(1)
+success
+#endif
+
+#if 0
+#elif+1
+success
+#endif
+
+#if 0
+#elif-1
+success
+#endif
+
+#if 0
+#elif!1
+success
+#endif
+
+#if 0
+#elif~1
+success
+#endif
diff --git a/src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected b/src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected
new file mode 100644 (file)
index 0000000..3b5479a
--- /dev/null
@@ -0,0 +1,25 @@
+
+
+success
+
+
+
+
+success
+
+
+
+
+success
+
+
+
+
+
+
+
+
+
+success
+
+