summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/glcpp')
-rw-r--r--src/glsl/glcpp/.gitignore3
-rw-r--r--src/glsl/glcpp/Makefile.am44
-rw-r--r--src/glsl/glcpp/glcpp-lex.c556
-rw-r--r--src/glsl/glcpp/glcpp-lex.l67
-rw-r--r--src/glsl/glcpp/glcpp-parse.c640
-rw-r--r--src/glsl/glcpp/glcpp-parse.h7
-rw-r--r--src/glsl/glcpp/glcpp-parse.y202
-rw-r--r--src/glsl/glcpp/glcpp.c48
-rw-r--r--src/glsl/glcpp/glcpp.h4
-rw-r--r--src/glsl/glcpp/pp.c30
-rw-r--r--src/glsl/glcpp/tests/063-comments.c.expected7
-rw-r--r--src/glsl/glcpp/tests/092-redefine-macro-error-2.c5
-rw-r--r--src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected10
-rw-r--r--src/glsl/glcpp/tests/093-divide-by-zero.c2
-rw-r--r--src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c2
-rw-r--r--src/glsl/glcpp/tests/095-recursive-define.c3
16 files changed, 802 insertions, 828 deletions
diff --git a/src/glsl/glcpp/.gitignore b/src/glsl/glcpp/.gitignore
index dbc37e1926d..fb0be2065b4 100644
--- a/src/glsl/glcpp/.gitignore
+++ b/src/glsl/glcpp/.gitignore
@@ -1,5 +1,8 @@
glcpp
+glcpp-lex.c
glcpp-parse.output
+glcpp-parse.c
+glcpp-parse.h
*.o
*.lo
*.la
diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am
deleted file mode 100644
index 81147e6e12c..00000000000
--- a/src/glsl/glcpp/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright © 2010 Intel Corporation
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, and/or sell copies of the Software, and to permit persons to whom
-# the Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-# USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-noinst_LTLIBRARIES = libglcpp.la
-libglcpp_la_SOURCES = \
- glcpp-lex.l \
- glcpp-parse.y \
- glcpp.h \
- pp.c
-
-BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c
-CLEANFILES = $(BUILT_SOURCES)
-
-glcpp-parse.h: glcpp-parse.c
-
-bin_PROGRAMS = glcpp
-glcpp_LDADD = libglcpp.la
-glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
-glcpp_SOURCES = glcpp.c
-
-.l.c:
- $(LEXCOMPILE) --outfile="$@" $<
-
-test: glcpp
- @(cd tests; ./glcpp-test)
diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c
index 156af3008c0..34605598822 100644
--- a/src/glsl/glcpp/glcpp-lex.c
+++ b/src/glsl/glcpp/glcpp-lex.c
@@ -54,7 +54,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@@ -158,7 +159,15 @@ typedef void* yyscan_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -358,45 +367,43 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_acclist[137] =
+static yyconst flex_int16_t yy_acclist[125] =
{ 0,
3, 3, 44, 39, 43, 40, 43, 41, 43, 43,
38, 43, 43, 38, 43, 38, 43, 38, 43, 25,
39, 43, 24, 39, 43, 38, 43, 38, 43, 38,
43, 37, 39, 43, 37, 39, 43, 38, 43, 40,
- 43, 23, 43, 43, 3, 43, 4, 43, 5, 43,
- 42, 43, 39, 18, 40, 32, 35, 33, 2, 1,
- 25, 39, 25, 39, 39, 24, 39, 24, 39, 27,
- 29, 31, 30, 28, 37, 39, 37, 39, 34, 40,
- 23, 23, 3, 4, 5, 6, 5, 7, 1, 26,
- 39, 37, 39,16398, 26, 39, 37, 39, 18, 37,
-
- 39,16399,16400, 8206, 18, 8206, 37, 39, 8207, 18,
- 8208, 18,16401, 19,16396, 22, 36, 37, 39, 21,
- 8209, 18, 19, 8204, 18,16397,16404, 8205, 18, 11,
- 18, 9, 8, 8212, 10, 18
+ 43, 23, 43, 3, 43, 4, 43, 5, 43, 42,
+ 43, 18, 43, 18, 43, 18, 43, 39, 40, 32,
+ 35, 33, 2, 1, 25, 39, 25, 39, 39, 24,
+ 39, 24, 39, 27, 29, 31, 30, 28, 37, 39,
+ 37, 39, 34, 40, 23, 23, 3, 4, 5, 6,
+ 5, 7, 1, 26, 39, 37, 39, 26, 39, 37,
+
+ 39, 14, 37, 39, 15, 16, 37, 39, 17, 19,
+ 12, 22, 36, 37, 39, 21, 19, 13,16404, 11,
+ 9, 8, 8212, 10
} ;
-static yyconst flex_int16_t yy_accept[164] =
+static yyconst flex_int16_t yy_accept[155] =
{ 0,
- 1, 1, 1, 1, 1, 2, 3, 3, 3, 4,
- 6, 8, 10, 11, 13, 14, 16, 18, 20, 23,
- 26, 28, 30, 32, 35, 38, 40, 42, 44, 45,
- 47, 49, 51, 53, 54, 54, 55, 56, 57, 58,
- 59, 60, 61, 63, 65, 66, 68, 70, 71, 72,
- 73, 74, 75, 77, 79, 80, 81, 82, 83, 83,
- 83, 83, 83, 83, 83, 83, 84, 85, 86, 87,
- 88, 89, 90, 92, 94, 94, 94, 94, 94, 94,
- 95, 95, 95, 95, 95, 97, 99, 99, 99, 99,
- 99, 99, 99, 99, 100, 100, 100, 100, 100, 100,
-
- 100, 102, 102, 103, 104, 104, 104, 104, 104, 106,
- 106, 107, 107, 107, 107, 107, 107, 107, 109, 109,
- 109, 111, 111, 113, 114, 115, 115, 116, 116, 116,
- 116, 117, 117, 120, 121, 121, 123, 124, 124, 124,
- 126, 127, 127, 127, 127, 128, 128, 128, 130, 130,
- 132, 132, 133, 134, 134, 134, 134, 135, 135, 135,
- 137, 137, 137
+ 1, 1, 1, 1, 1, 2, 3, 3, 3, 3,
+ 3, 4, 6, 8, 10, 11, 13, 14, 16, 18,
+ 20, 23, 26, 28, 30, 32, 35, 38, 40, 42,
+ 44, 46, 48, 50, 52, 54, 56, 58, 59, 60,
+ 61, 62, 63, 64, 65, 67, 69, 70, 72, 74,
+ 75, 76, 77, 78, 79, 81, 83, 84, 85, 86,
+ 87, 87, 87, 87, 87, 87, 87, 87, 88, 89,
+ 90, 91, 92, 93, 93, 93, 93, 93, 94, 96,
+ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
+ 98, 100, 102, 102, 102, 102, 102, 102, 102, 103,
+
+ 103, 103, 103, 103, 103, 103, 105, 105, 106, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 109,
+ 109, 110, 111, 111, 112, 112, 112, 112, 113, 113,
+ 116, 117, 118, 118, 119, 119, 119, 119, 120, 120,
+ 120, 121, 121, 122, 123, 123, 123, 123, 124, 124,
+ 124, 125, 125, 125
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -433,198 +440,144 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[40] =
{ 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1
+ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6,
+ 4, 7, 7, 7, 4, 4, 4, 8, 8, 8,
+ 8, 8, 9, 8, 8, 8, 8, 8, 8, 9,
+ 8, 8, 8, 8, 8, 8, 8, 8, 4
} ;
-static yyconst flex_int16_t yy_base[182] =
+static yyconst flex_int16_t yy_base[168] =
{ 0,
- 0, 38, 0, 0, 38, 39, 499, 498, 500, 48,
- 43, 552, 496, 44, 63, 495, 59, 65, 87, 125,
- 58, 67, 68, 164, 203, 40, 75, 241, 552, 494,
- 552, 140, 552, 140, 493, 552, 144, 492, 491, 487,
- 486, 485, 156, 179, 267, 0, 209, 472, 471, 470,
- 469, 468, 446, 124, 466, 153, 462, 458, 154, 198,
- 159, 155, 183, 160, 193, 460, 552, 222, 552, 227,
- 552, 459, 204, 161, 231, 232, 238, 243, 236, 303,
- 245, 180, 247, 249, 281, 56, 257, 271, 248, 259,
- 252, 264, 455, 454, 297, 299, 312, 313, 320, 294,
-
- 407, 295, 427, 426, 321, 296, 324, 425, 552, 424,
- 552, 327, 329, 195, 328, 331, 332, 230, 334, 378,
- 552, 377, 552, 371, 370, 335, 365, 337, 358, 342,
- 360, 344, 326, 255, 340, 552, 260, 338, 246, 552,
- 197, 364, 192, 352, 382, 348, 186, 552, 420, 552,
- 423, 184, 141, 437, 421, 447, 79, 476, 346, 552,
- 453, 552, 515, 517, 519, 521, 523, 525, 71, 527,
- 529, 531, 533, 535, 537, 539, 541, 543, 545, 547,
- 549
+ 0, 38, 0, 0, 38, 39, 328, 327, 326, 44,
+ 328, 0, 325, 332, 332, 310, 319, 332, 316, 41,
+ 41, 44, 44, 307, 49, 321, 44, 282, 61, 79,
+ 317, 332, 72, 332, 332, 67, 68, 0, 317, 332,
+ 332, 332, 332, 0, 34, 0, 105, 0, 0, 332,
+ 332, 332, 332, 332, 317, 73, 332, 82, 311, 310,
+ 291, 61, 289, 286, 279, 281, 286, 306, 332, 90,
+ 332, 94, 332, 84, 85, 108, 48, 0, 88, 95,
+ 283, 86, 284, 273, 270, 91, 274, 281, 279, 268,
+ 0, 124, 273, 274, 274, 270, 265, 271, 332, 267,
+
+ 264, 262, 259, 260, 249, 125, 245, 332, 332, 241,
+ 229, 231, 223, 209, 222, 194, 197, 194, 130, 196,
+ 332, 0, 181, 332, 189, 131, 191, 332, 181, 210,
+ 162, 0, 136, 332, 134, 0, 130, 155, 111, 138,
+ 332, 153, 0, 332, 125, 41, 156, 332, 34, 136,
+ 332, 159, 332, 173, 182, 191, 200, 209, 218, 227,
+ 236, 245, 254, 263, 272, 280, 285
} ;
-static yyconst flex_int16_t yy_def[182] =
+static yyconst flex_int16_t yy_def[168] =
{ 0,
- 162, 1, 163, 163, 164, 164, 165, 165, 162, 166,
- 167, 162, 167, 167, 167, 167, 167, 167, 162, 166,
- 167, 167, 167, 168, 168, 167, 167, 167, 162, 169,
- 162, 170, 162, 20, 167, 162, 167, 167, 167, 167,
- 167, 171, 19, 20, 20, 20, 20, 167, 167, 167,
- 167, 167, 25, 25, 167, 167, 28, 28, 167, 167,
- 167, 167, 167, 167, 167, 169, 162, 170, 162, 170,
- 162, 171, 45, 25, 167, 167, 167, 167, 167, 167,
- 167, 167, 167, 167, 20, 25, 167, 167, 167, 167,
- 167, 167, 172, 173, 167, 167, 167, 167, 167, 167,
-
- 25, 167, 174, 175, 167, 167, 167, 172, 162, 173,
- 162, 167, 167, 167, 167, 167, 167, 25, 167, 174,
- 162, 175, 162, 176, 177, 167, 178, 167, 167, 167,
- 167, 167, 25, 167, 176, 162, 177, 167, 178, 162,
- 179, 167, 180, 167, 162, 167, 179, 162, 167, 162,
- 167, 180, 167, 181, 167, 167, 167, 181, 167, 162,
- 167, 0, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162
+ 153, 1, 154, 154, 155, 155, 156, 156, 157, 157,
+ 153, 158, 153, 153, 153, 153, 153, 153, 153, 153,
+ 158, 158, 153, 153, 153, 159, 159, 153, 153, 153,
+ 160, 153, 161, 153, 153, 153, 153, 158, 153, 153,
+ 153, 153, 153, 162, 21, 158, 158, 22, 158, 153,
+ 153, 153, 153, 153, 159, 159, 153, 153, 30, 30,
+ 153, 153, 153, 153, 153, 153, 153, 160, 153, 161,
+ 153, 161, 153, 153, 153, 153, 153, 162, 47, 159,
+ 153, 153, 153, 153, 153, 163, 153, 153, 153, 153,
+ 158, 159, 153, 153, 153, 153, 153, 153, 153, 153,
+
+ 153, 153, 153, 153, 153, 159, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 159, 153,
+ 153, 164, 153, 153, 153, 153, 153, 153, 153, 159,
+ 153, 164, 153, 153, 153, 165, 153, 166, 153, 153,
+ 153, 153, 165, 153, 167, 153, 153, 153, 167, 153,
+ 153, 153, 0, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153
} ;
-static yyconst flex_int16_t yy_nxt[592] =
+static yyconst flex_int16_t yy_nxt[372] =
{ 0,
- 10, 11, 12, 13, 14, 15, 16, 17, 16, 16,
- 18, 19, 20, 20, 21, 22, 23, 24, 24, 24,
- 24, 24, 25, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 26, 27,
- 31, 31, 36, 28, 37, 36, 36, 32, 32, 35,
- 36, 35, 35, 35, 35, 35, 35, 35, 35, 38,
- 36, 36, 35, 35, 35, 36, 40, 36, 39, 36,
- 36, 66, 48, 49, 41, 42, 56, 36, 55, 53,
- 57, 36, 50, 51, 52, 101, 35, 34, 35, 36,
- 35, 35, 35, 35, 35, 35, 35, 35, 43, 43,
-
- 34, 35, 35, 35, 34, 34, 44, 45, 34, 34,
- 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
- 34, 34, 44, 34, 45, 35, 35, 36, 35, 35,
- 35, 35, 35, 35, 35, 35, 46, 46, 46, 35,
- 35, 35, 69, 36, 47, 37, 36, 53, 74, 70,
- 71, 34, 34, 34, 56, 36, 36, 36, 57, 34,
- 47, 36, 36, 35, 34, 35, 36, 35, 35, 35,
- 35, 35, 35, 35, 35, 34, 34, 75, 35, 35,
- 35, 81, 36, 80, 53, 36, 36, 86, 148, 83,
- 34, 34, 34, 34, 36, 36, 129, 36, 34, 148,
-
- 36, 98, 35, 34, 35, 36, 35, 35, 35, 35,
- 35, 35, 35, 35, 34, 82, 84, 35, 35, 35,
- 34, 34, 34, 85, 69, 76, 54, 77, 34, 69,
- 78, 162, 162, 36, 36, 79, 70, 71, 36, 85,
- 36, 35, 58, 36, 34, 36, 39, 36, 140, 36,
- 36, 36, 133, 53, 36, 87, 145, 36, 88, 36,
- 90, 36, 36, 59, 60, 89, 36, 61, 62, 99,
- 92, 104, 63, 36, 97, 91, 64, 65, 73, 73,
- 73, 100, 106, 102, 73, 105, 34, 107, 73, 73,
- 73, 73, 34, 34, 34, 103, 36, 36, 36, 36,
-
- 34, 36, 34, 93, 93, 94, 93, 93, 93, 93,
- 93, 93, 93, 93, 36, 36, 34, 93, 93, 93,
- 112, 113, 36, 36, 119, 95, 36, 117, 125, 36,
- 36, 36, 96, 36, 36, 114, 36, 36, 115, 36,
- 36, 93, 136, 116, 36, 124, 36, 159, 160, 53,
- 36, 127, 128, 126, 36, 131, 130, 134, 132, 129,
- 36, 141, 36, 143, 146, 149, 150, 140, 138, 142,
- 142, 142, 36, 136, 144, 151, 151, 151, 155, 123,
- 121, 153, 35, 145, 36, 35, 35, 35, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 154,
-
- 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
- 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
- 35, 149, 150, 36, 149, 150, 111, 109, 123, 121,
- 118, 156, 156, 156, 151, 151, 151, 35, 35, 36,
- 35, 35, 35, 35, 35, 157, 35, 35, 159, 160,
- 143, 35, 35, 35, 159, 160, 111, 109, 161, 161,
- 161, 36, 67, 35, 161, 161, 161, 35, 36, 53,
- 36, 36, 36, 36, 36, 35, 35, 35, 36, 35,
- 35, 35, 35, 35, 157, 35, 35, 36, 36, 36,
- 35, 35, 35, 36, 36, 36, 67, 36, 36, 162,
-
- 29, 29, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 35, 29, 29, 30, 30, 33,
- 33, 34, 34, 35, 35, 53, 53, 68, 68, 72,
- 72, 108, 108, 110, 110, 120, 120, 122, 122, 135,
- 135, 137, 137, 139, 139, 147, 147, 152, 152, 158,
- 158, 9, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162
-
+ 12, 13, 14, 15, 16, 17, 18, 19, 18, 18,
+ 20, 21, 22, 22, 23, 24, 25, 26, 26, 26,
+ 26, 26, 27, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 28, 29,
+ 32, 32, 148, 30, 38, 36, 14, 33, 33, 37,
+ 43, 44, 45, 45, 38, 48, 48, 48, 50, 51,
+ 46, 47, 58, 49, 53, 54, 59, 56, 74, 76,
+ 136, 38, 75, 38, 71, 82, 46, 83, 47, 49,
+ 60, 72, 73, 58, 41, 74, 76, 59, 82, 75,
+ 83, 77, 71, 84, 63, 38, 71, 80, 85, 153,
+
+ 153, 61, 62, 72, 73, 63, 64, 91, 77, 76,
+ 65, 63, 94, 100, 66, 67, 79, 79, 79, 95,
+ 101, 92, 79, 91, 38, 38, 79, 79, 79, 79,
+ 38, 77, 126, 148, 63, 140, 141, 150, 151, 140,
+ 141, 146, 135, 135, 135, 142, 142, 142, 119, 147,
+ 147, 147, 130, 106, 140, 141, 138, 150, 151, 144,
+ 150, 151, 139, 138, 142, 142, 142, 152, 152, 152,
+ 152, 152, 152, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 34, 34, 34, 34, 34, 34, 34, 34, 34,
+
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 38,
+ 38, 137, 136, 134, 133, 38, 38, 38, 55, 131,
+ 129, 128, 127, 126, 55, 55, 55, 68, 68, 68,
+ 68, 68, 125, 68, 68, 68, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 78, 78, 124, 78, 78,
+ 78, 78, 78, 78, 99, 99, 99, 99, 99, 99,
+ 123, 122, 99, 132, 132, 121, 132, 132, 132, 132,
+ 132, 132, 143, 143, 120, 143, 143, 143, 143, 143,
+ 143, 145, 118, 117, 116, 115, 114, 145, 145, 149,
+ 113, 149, 149, 149, 112, 111, 110, 109, 108, 107,
+
+ 105, 104, 103, 102, 98, 97, 96, 93, 69, 90,
+ 89, 88, 87, 86, 81, 153, 153, 38, 39, 69,
+ 57, 38, 52, 42, 41, 40, 39, 153, 14, 15,
+ 15, 11, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153
} ;
-static yyconst flex_int16_t yy_chk[592] =
+static yyconst flex_int16_t yy_chk[372] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 5, 6, 26, 2, 11, 11, 14, 5, 6, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 14,
- 21, 17, 10, 10, 10, 15, 17, 18, 15, 22,
- 23, 169, 21, 21, 18, 18, 27, 27, 26, 86,
- 27, 157, 22, 23, 23, 86, 10, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 32, 153, 20, 37, 37, 54, 54, 32,
- 32, 34, 34, 34, 56, 56, 59, 62, 56, 34,
- 20, 61, 64, 20, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 34, 43, 59, 24, 24,
- 24, 62, 82, 61, 74, 63, 152, 74, 147, 64,
- 44, 44, 44, 43, 143, 65, 114, 114, 44, 141,
-
- 60, 82, 24, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 44, 63, 65, 25, 25, 25,
- 47, 47, 47, 73, 68, 60, 25, 60, 47, 70,
- 60, 68, 68, 75, 76, 60, 70, 70, 79, 73,
- 77, 25, 28, 28, 47, 78, 28, 81, 139, 83,
- 89, 84, 118, 118, 91, 75, 134, 134, 76, 87,
- 77, 90, 137, 28, 28, 76, 92, 28, 28, 83,
- 79, 89, 28, 88, 81, 78, 28, 28, 45, 45,
- 45, 84, 91, 87, 45, 90, 45, 92, 45, 45,
- 45, 45, 85, 85, 85, 88, 100, 102, 106, 95,
-
- 85, 96, 45, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 97, 98, 85, 80, 80, 80,
- 95, 96, 99, 105, 102, 80, 107, 100, 106, 112,
- 115, 113, 80, 116, 117, 97, 119, 126, 98, 128,
- 138, 80, 135, 99, 130, 105, 132, 159, 159, 133,
- 146, 112, 113, 107, 144, 116, 115, 119, 117, 129,
- 129, 128, 131, 130, 138, 142, 142, 127, 126, 129,
- 129, 129, 125, 124, 132, 142, 142, 142, 146, 122,
- 120, 144, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 149, 149, 155, 151, 151, 110, 108, 104, 103,
- 101, 149, 149, 149, 151, 151, 151, 154, 154, 154,
- 154, 154, 154, 154, 154, 154, 154, 154, 156, 156,
- 155, 154, 154, 154, 161, 161, 94, 93, 156, 156,
- 156, 72, 66, 58, 161, 161, 161, 57, 55, 53,
- 52, 51, 50, 49, 48, 154, 158, 158, 158, 158,
- 158, 158, 158, 158, 158, 158, 158, 42, 41, 40,
- 158, 158, 158, 39, 38, 35, 30, 16, 13, 9,
-
- 8, 7, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 158, 163, 163, 164, 164, 165,
- 165, 166, 166, 167, 167, 168, 168, 170, 170, 171,
- 171, 172, 172, 173, 173, 174, 174, 175, 175, 176,
- 176, 177, 177, 178, 178, 179, 179, 180, 180, 181,
- 181, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
- 162
-
+ 5, 6, 149, 2, 27, 10, 10, 5, 6, 10,
+ 20, 20, 21, 21, 45, 22, 22, 22, 23, 23,
+ 21, 21, 29, 22, 25, 25, 29, 27, 36, 37,
+ 146, 45, 36, 56, 33, 77, 21, 77, 21, 22,
+ 30, 33, 33, 58, 30, 74, 75, 58, 62, 74,
+ 62, 37, 70, 62, 37, 80, 72, 56, 62, 70,
+
+ 70, 30, 30, 72, 72, 30, 30, 79, 75, 76,
+ 30, 75, 82, 86, 30, 30, 47, 47, 47, 82,
+ 86, 80, 47, 79, 92, 106, 47, 47, 47, 47,
+ 119, 76, 126, 145, 76, 135, 135, 150, 150, 140,
+ 140, 139, 126, 126, 126, 135, 135, 135, 106, 140,
+ 140, 140, 119, 92, 142, 142, 138, 147, 147, 137,
+ 152, 152, 133, 131, 142, 142, 142, 147, 147, 147,
+ 152, 152, 152, 154, 154, 154, 154, 154, 154, 154,
+ 154, 154, 155, 155, 155, 155, 155, 155, 155, 155,
+ 155, 156, 156, 156, 156, 156, 156, 156, 156, 156,
+
+ 157, 157, 157, 157, 157, 157, 157, 157, 157, 158,
+ 130, 129, 127, 125, 123, 158, 158, 158, 159, 120,
+ 118, 117, 116, 115, 159, 159, 159, 160, 160, 160,
+ 160, 160, 114, 160, 160, 160, 161, 161, 161, 161,
+ 161, 161, 161, 161, 161, 162, 162, 113, 162, 162,
+ 162, 162, 162, 162, 163, 163, 163, 163, 163, 163,
+ 112, 111, 163, 164, 164, 110, 164, 164, 164, 164,
+ 164, 164, 165, 165, 107, 165, 165, 165, 165, 165,
+ 165, 166, 105, 104, 103, 102, 101, 166, 166, 167,
+ 100, 167, 167, 167, 98, 97, 96, 95, 94, 93,
+
+ 90, 89, 88, 87, 85, 84, 83, 81, 68, 67,
+ 66, 65, 64, 63, 61, 60, 59, 55, 39, 31,
+ 28, 26, 24, 19, 17, 16, 13, 11, 9, 8,
+ 7, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153
} ;
#define YY_TRAILING_MASK 0x2000
@@ -680,6 +633,10 @@ goto find_rule; \
int glcpp_get_column (yyscan_t yyscanner);
void glcpp_set_column (int column_no , yyscan_t yyscanner);
+#ifdef _MSC_VER
+#define YY_NO_UNISTD_H
+#endif
+
#define YY_NO_INPUT
#define YY_USER_ACTION \
@@ -696,12 +653,13 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner);
yylloc->source = 0; \
} while(0)
-#line 700 "glcpp/glcpp-lex.c"
+#line 657 "glcpp/glcpp-lex.c"
#define INITIAL 0
#define DONE 1
#define COMMENT 2
#define UNREACHABLE 3
+#define SKIP 4
#define YY_EXTRA_TYPE glcpp_parser_t *
@@ -843,7 +801,12 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -862,7 +825,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- unsigned n; \
+ size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -950,11 +913,22 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 76 "glcpp/glcpp-lex.l"
+#line 80 "glcpp/glcpp-lex.l"
+ /* Implicitly switch between SKIP and INITIAL (non-skipping);
+ * don't switch if some other state was explicitly set.
+ */
+ glcpp_parser_t *parser = yyextra;
+ if (YY_START == 0 || YY_START == SKIP) {
+ if (parser->lexing_if || parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) {
+ BEGIN 0;
+ } else {
+ BEGIN SKIP;
+ }
+ }
/* Single-line comments */
-#line 958 "glcpp/glcpp-lex.c"
+#line 932 "glcpp/glcpp-lex.c"
yylval = yylval_param;
@@ -1017,14 +991,14 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 163 )
+ if ( yy_current_state >= 154 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
*yyg->yy_state_ptr++ = yy_current_state;
++yy_cp;
}
- while ( yy_current_state != 162 );
+ while ( yy_current_state != 153 );
yy_find_action:
yy_current_state = *--yyg->yy_state_ptr;
@@ -1049,9 +1023,6 @@ find_rule: /* we branch to this label when backing up */
{
yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;
yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;
- yyg->yy_full_match = yy_cp;
- yyg->yy_full_state = yyg->yy_state_ptr;
- yyg->yy_full_lp = yyg->yy_lp;
}
else
{
@@ -1076,41 +1047,41 @@ do_action: /* This label is used only to access EOF actions. */
{ /* beginning of action switch */
case 1:
YY_RULE_SETUP
-#line 79 "glcpp/glcpp-lex.l"
+#line 94 "glcpp/glcpp-lex.l"
{
}
YY_BREAK
/* Multi-line comments */
case 2:
YY_RULE_SETUP
-#line 83 "glcpp/glcpp-lex.l"
+#line 98 "glcpp/glcpp-lex.l"
{ yy_push_state(COMMENT, yyscanner); }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 84 "glcpp/glcpp-lex.l"
+#line 99 "glcpp/glcpp-lex.l"
YY_BREAK
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
-#line 85 "glcpp/glcpp-lex.l"
+#line 100 "glcpp/glcpp-lex.l"
{ yylineno++; yycolumn = 0; return NEWLINE; }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 86 "glcpp/glcpp-lex.l"
+#line 101 "glcpp/glcpp-lex.l"
YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
-#line 87 "glcpp/glcpp-lex.l"
+#line 102 "glcpp/glcpp-lex.l"
{ yylineno++; yycolumn = 0; return NEWLINE; }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 88 "glcpp/glcpp-lex.l"
+#line 103 "glcpp/glcpp-lex.l"
{
yy_pop_state(yyscanner);
if (yyextra->space_tokens)
@@ -1119,9 +1090,9 @@ YY_RULE_SETUP
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 94 "glcpp/glcpp-lex.l"
+#line 109 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
return HASH_VERSION;
}
@@ -1130,9 +1101,9 @@ YY_RULE_SETUP
* Simply pass them through to the main compiler's lexer/parser. */
case 9:
YY_RULE_SETUP
-#line 102 "glcpp/glcpp-lex.l"
+#line 117 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
@@ -1143,7 +1114,7 @@ case 10:
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 109 "glcpp/glcpp-lex.l"
+#line 124 "glcpp/glcpp-lex.l"
{
/* Eat characters until the first digit is
* encountered
@@ -1165,7 +1136,7 @@ case 11:
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 125 "glcpp/glcpp-lex.l"
+#line 140 "glcpp/glcpp-lex.l"
{
/* Eat characters until the first digit is
* encountered
@@ -1181,10 +1152,10 @@ YY_RULE_SETUP
yylineno = strtol(ptr, &ptr, 0) - 1;
}
YY_BREAK
+
case 12:
-/* rule 12 can match eol */
YY_RULE_SETUP
-#line 140 "glcpp/glcpp-lex.l"
+#line 156 "glcpp/glcpp-lex.l"
{
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
@@ -1192,9 +1163,8 @@ YY_RULE_SETUP
}
YY_BREAK
case 13:
-/* rule 13 can match eol */
YY_RULE_SETUP
-#line 146 "glcpp/glcpp-lex.l"
+#line 162 "glcpp/glcpp-lex.l"
{
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
@@ -1203,8 +1173,11 @@ YY_RULE_SETUP
YY_BREAK
case 14:
/* rule 14 can match eol */
+*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
+yyg->yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 152 "glcpp/glcpp-lex.l"
+#line 168 "glcpp/glcpp-lex.l"
{
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
@@ -1212,9 +1185,8 @@ YY_RULE_SETUP
}
YY_BREAK
case 15:
-/* rule 15 can match eol */
YY_RULE_SETUP
-#line 158 "glcpp/glcpp-lex.l"
+#line 174 "glcpp/glcpp-lex.l"
{
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
@@ -1222,53 +1194,30 @@ YY_RULE_SETUP
}
YY_BREAK
case 16:
-/* rule 16 can match eol */
YY_RULE_SETUP
-#line 164 "glcpp/glcpp-lex.l"
+#line 180 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH_ELSE;
}
YY_BREAK
case 17:
-/* rule 17 can match eol */
YY_RULE_SETUP
-#line 169 "glcpp/glcpp-lex.l"
+#line 185 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH_ENDIF;
}
YY_BREAK
-/* When skipping (due to an #if 0 or similar) consume anything
- * up to a newline. We do this with less priority than any
- * #if-related directive (#if, #elif, #else, #endif), but with
- * more priority than any other directive or token to avoid
- * any side-effects from skipped content.
- *
- * We use the lexing_if flag to avoid skipping any part of an
- * if conditional expression. */
+
case 18:
-/* rule 18 can match eol */
-*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
-yyg->yy_c_buf_p = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 182 "glcpp/glcpp-lex.l"
-{
- /* Since this rule always matches, YY_USER_ACTION gets called for it,
- * wrongly incrementing yycolumn. We undo that effect here. */
- yycolumn -= yyleng;
- if (yyextra->lexing_if ||
- yyextra->skip_stack == NULL ||
- yyextra->skip_stack->type == SKIP_NO_SKIP)
- {
- REJECT;
- }
-}
+#line 191 "glcpp/glcpp-lex.l"
+;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 194 "glcpp/glcpp-lex.l"
+#line 193 "glcpp/glcpp-lex.l"
{
char *p;
for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */
@@ -1278,7 +1227,7 @@ YY_RULE_SETUP
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 201 "glcpp/glcpp-lex.l"
+#line 200 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH_DEFINE_FUNC;
@@ -1286,7 +1235,7 @@ YY_RULE_SETUP
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 206 "glcpp/glcpp-lex.l"
+#line 205 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH_DEFINE_OBJ;
@@ -1294,7 +1243,7 @@ YY_RULE_SETUP
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 211 "glcpp/glcpp-lex.l"
+#line 210 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH_UNDEF;
@@ -1302,7 +1251,7 @@ YY_RULE_SETUP
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 216 "glcpp/glcpp-lex.l"
+#line 215 "glcpp/glcpp-lex.l"
{
yyextra->space_tokens = 0;
return HASH;
@@ -1310,124 +1259,124 @@ YY_RULE_SETUP
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 221 "glcpp/glcpp-lex.l"
+#line 220 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 226 "glcpp/glcpp-lex.l"
+#line 225 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 231 "glcpp/glcpp-lex.l"
+#line 230 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 236 "glcpp/glcpp-lex.l"
+#line 235 "glcpp/glcpp-lex.l"
{
return LEFT_SHIFT;
}
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 240 "glcpp/glcpp-lex.l"
+#line 239 "glcpp/glcpp-lex.l"
{
return RIGHT_SHIFT;
}
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 244 "glcpp/glcpp-lex.l"
+#line 243 "glcpp/glcpp-lex.l"
{
return LESS_OR_EQUAL;
}
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 248 "glcpp/glcpp-lex.l"
+#line 247 "glcpp/glcpp-lex.l"
{
return GREATER_OR_EQUAL;
}
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 252 "glcpp/glcpp-lex.l"
+#line 251 "glcpp/glcpp-lex.l"
{
return EQUAL;
}
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 256 "glcpp/glcpp-lex.l"
+#line 255 "glcpp/glcpp-lex.l"
{
return NOT_EQUAL;
}
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 260 "glcpp/glcpp-lex.l"
+#line 259 "glcpp/glcpp-lex.l"
{
return AND;
}
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 264 "glcpp/glcpp-lex.l"
+#line 263 "glcpp/glcpp-lex.l"
{
return OR;
}
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 268 "glcpp/glcpp-lex.l"
+#line 267 "glcpp/glcpp-lex.l"
{
return PASTE;
}
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 272 "glcpp/glcpp-lex.l"
+#line 271 "glcpp/glcpp-lex.l"
{
return DEFINED;
}
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 276 "glcpp/glcpp-lex.l"
+#line 275 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return IDENTIFIER;
}
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 281 "glcpp/glcpp-lex.l"
+#line 280 "glcpp/glcpp-lex.l"
{
return yytext[0];
}
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 285 "glcpp/glcpp-lex.l"
+#line 284 "glcpp/glcpp-lex.l"
{
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return OTHER;
}
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 290 "glcpp/glcpp-lex.l"
+#line 289 "glcpp/glcpp-lex.l"
{
if (yyextra->space_tokens) {
return SPACE;
@@ -1437,7 +1386,7 @@ YY_RULE_SETUP
case 41:
/* rule 41 can match eol */
YY_RULE_SETUP
-#line 296 "glcpp/glcpp-lex.l"
+#line 295 "glcpp/glcpp-lex.l"
{
yyextra->lexing_if = 0;
yylineno++;
@@ -1447,7 +1396,7 @@ YY_RULE_SETUP
YY_BREAK
/* Handle missing newline at EOF. */
case YY_STATE_EOF(INITIAL):
-#line 304 "glcpp/glcpp-lex.l"
+#line 303 "glcpp/glcpp-lex.l"
{
BEGIN DONE; /* Don't keep matching this rule forever. */
yyextra->lexing_if = 0;
@@ -1460,7 +1409,7 @@ case YY_STATE_EOF(INITIAL):
warnings. */
case 42:
YY_RULE_SETUP
-#line 314 "glcpp/glcpp-lex.l"
+#line 313 "glcpp/glcpp-lex.l"
{
unput('.');
yy_top_state(yyextra);
@@ -1468,13 +1417,14 @@ YY_RULE_SETUP
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 319 "glcpp/glcpp-lex.l"
+#line 318 "glcpp/glcpp-lex.l"
ECHO;
YY_BREAK
-#line 1475 "glcpp/glcpp-lex.c"
+#line 1424 "glcpp/glcpp-lex.c"
case YY_STATE_EOF(DONE):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(UNREACHABLE):
+ case YY_STATE_EOF(SKIP):
yyterminate();
case YY_END_OF_BUFFER:
@@ -1737,7 +1687,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 163 )
+ if ( yy_current_state >= 154 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1761,11 +1711,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 163 )
+ if ( yy_current_state >= 154 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 162);
+ yy_is_jam = (yy_current_state == 153);
if ( ! yy_is_jam )
*yyg->yy_state_ptr++ = yy_current_state;
@@ -2210,8 +2160,8 @@ YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner)
/** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
@@ -2665,7 +2615,7 @@ void glcpp_free (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#line 319 "glcpp/glcpp-lex.l"
+#line 318 "glcpp/glcpp-lex.l"
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index e936854cf2c..86618870885 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -34,6 +34,10 @@
int glcpp_get_column (yyscan_t yyscanner);
void glcpp_set_column (int column_no , yyscan_t yyscanner);
+#ifdef _MSC_VER
+#define YY_NO_UNISTD_H
+#endif
+
#define YY_NO_INPUT
#define YY_USER_ACTION \
@@ -57,7 +61,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner);
%option stack
%option never-interactive
-%x DONE COMMENT UNREACHABLE
+%x DONE COMMENT UNREACHABLE SKIP
SPACE [[:space:]]
NONSPACE [^[:space:]]
@@ -74,6 +78,17 @@ OCTAL_INTEGER 0[0-7]*[uU]?
HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
%%
+ /* Implicitly switch between SKIP and INITIAL (non-skipping);
+ * don't switch if some other state was explicitly set.
+ */
+ glcpp_parser_t *parser = yyextra;
+ if (YY_START == 0 || YY_START == SKIP) {
+ if (parser->lexing_if || parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) {
+ BEGIN 0;
+ } else {
+ BEGIN SKIP;
+ }
+ }
/* Single-line comments */
"//"[^\n]* {
@@ -92,7 +107,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
{HASH}version {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
return HASH_VERSION;
}
@@ -100,7 +115,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
/* glcpp doesn't handle #extension, #version, or #pragma directives.
* Simply pass them through to the main compiler's lexer/parser. */
{HASH}(extension|pragma)[^\n]+ {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
@@ -137,60 +152,44 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
yylineno = strtol(ptr, &ptr, 0) - 1;
}
-{HASH}ifdef/.*\n {
+<SKIP,INITIAL>{
+{HASH}ifdef {
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
return HASH_IFDEF;
}
-{HASH}ifndef/.*\n {
+{HASH}ifndef {
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
return HASH_IFNDEF;
}
-{HASH}if/[^_a-zA-Z0-9].*\n {
+{HASH}if/[^_a-zA-Z0-9] {
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
return HASH_IF;
}
-{HASH}elif/.*\n {
+{HASH}elif {
yyextra->lexing_if = 1;
yyextra->space_tokens = 0;
return HASH_ELIF;
}
-{HASH}else/.*\n {
+{HASH}else {
yyextra->space_tokens = 0;
return HASH_ELSE;
}
-{HASH}endif/.*\n {
+{HASH}endif {
yyextra->space_tokens = 0;
return HASH_ENDIF;
}
-
- /* When skipping (due to an #if 0 or similar) consume anything
- * up to a newline. We do this with less priority than any
- * #if-related directive (#if, #elif, #else, #endif), but with
- * more priority than any other directive or token to avoid
- * any side-effects from skipped content.
- *
- * We use the lexing_if flag to avoid skipping any part of an
- * if conditional expression. */
-[^\n]+/\n {
- /* Since this rule always matches, YY_USER_ACTION gets called for it,
- * wrongly incrementing yycolumn. We undo that effect here. */
- yycolumn -= yyleng;
- if (yyextra->lexing_if ||
- yyextra->skip_stack == NULL ||
- yyextra->skip_stack->type == SKIP_NO_SKIP)
- {
- REJECT;
- }
}
+<SKIP>[^\n] ;
+
{HASH}error.* {
char *p;
for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */
@@ -219,17 +218,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
{DECIMAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{OCTAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{HEXADECIMAL_INTEGER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
@@ -274,7 +273,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
{IDENTIFIER} {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return IDENTIFIER;
}
@@ -283,7 +282,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
{OTHER}+ {
- yylval->str = talloc_strdup (yyextra, yytext);
+ yylval->str = ralloc_strdup (yyextra, yytext);
return OTHER;
}
@@ -293,7 +292,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
}
-\n {
+<SKIP,INITIAL>\n {
yyextra->lexing_if = 0;
yylineno++;
yycolumn = 0;
diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c
index ab7c30ed78a..29c45c7f30b 100644
--- a/src/glsl/glcpp/glcpp-parse.c
+++ b/src/glsl/glcpp/glcpp-parse.c
@@ -1,9 +1,10 @@
-/* A Bison parser, made by GNU Bison 2.4.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,7 +46,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.4.3"
+#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -102,10 +103,6 @@
#include "main/core.h" /* for struct gl_extensions */
#include "main/mtypes.h" /* for gl_api enum */
-#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
-#define glcpp_printf(stream, fmt, args, ...) \
- stream = talloc_asprintf_append(stream, fmt, args)
-
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
@@ -149,7 +146,7 @@ _argument_list_length (argument_list_t *list);
static token_list_t *
_argument_list_member_at (argument_list_t *list, int index);
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
static token_t *
_token_create_str (void *ctx, int type, char *str);
@@ -159,10 +156,7 @@ _token_create_ival (void *ctx, int type, int ival);
static token_list_t *
_token_list_create (void *ctx);
-/* Note: This function adds a talloc_reference() to token.
- *
- * You may want to talloc_unlink any current reference if you no
- * longer need it. */
+/* Note: This function calls ralloc_steal on token. */
static void
_token_list_append (token_list_t *list, token_t *token);
@@ -219,7 +213,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
/* Line 189 of yacc.c */
-#line 223 "glcpp/glcpp-parse.c"
+#line 217 "glcpp/glcpp-parse.c"
/* Enabling traces. */
#ifndef YYDEBUG
@@ -307,7 +301,7 @@ typedef struct YYLTYPE
/* Line 264 of yacc.c */
-#line 311 "glcpp/glcpp-parse.c"
+#line 305 "glcpp/glcpp-parse.c"
#ifdef short
# undef short
@@ -357,7 +351,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
+# if YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -632,17 +626,17 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 188, 188, 190, 194, 197, 202, 203, 207, 210,
- 216, 219, 222, 225, 233, 252, 262, 267, 272, 291,
- 306, 309, 312, 333, 337, 346, 351, 352, 355, 358,
- 361, 364, 367, 370, 373, 376, 379, 382, 385, 388,
- 391, 394, 397, 400, 403, 406, 409, 412, 415, 418,
- 424, 429, 437, 438, 442, 448, 449, 452, 454, 461,
- 465, 469, 474, 479, 487, 493, 501, 505, 509, 513,
- 517, 524, 525, 526, 527, 528, 529, 530, 531, 532,
- 533, 534, 535, 536, 537, 538, 539, 540, 541, 542,
- 543, 544, 545, 546, 547, 548, 549, 550, 551, 552,
- 553, 554
+ 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
+ 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
+ 299, 302, 305, 326, 330, 339, 344, 345, 348, 351,
+ 354, 357, 360, 363, 366, 369, 372, 375, 378, 381,
+ 384, 387, 390, 398, 406, 409, 412, 415, 418, 421,
+ 427, 432, 440, 441, 445, 451, 452, 455, 457, 464,
+ 468, 472, 477, 481, 488, 493, 500, 504, 508, 512,
+ 516, 523, 524, 525, 526, 527, 528, 529, 530, 531,
+ 532, 533, 534, 535, 536, 537, 538, 539, 540, 541,
+ 542, 543, 544, 545, 546, 547, 548, 549, 550, 551,
+ 552, 553
};
#endif
@@ -945,18 +939,9 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. However,
- YYFAIL appears to be in use. Nevertheless, it is formally deprecated
- in Bison 2.4.2's NEWS entry, where a plan to phase it out is
- discussed. */
+ Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
-#if defined YYFAIL
- /* This is here to suppress warnings from the GCC cpp's
- -Wunused-macros. Normally we don't worry about that warning, but
- some users do, and we want to make it easy for users to remove
- YYFAIL uses, which will produce warnings from Bison 2.5. */
-#endif
#define YYRECOVERING() (!!yyerrstatus)
@@ -1013,7 +998,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+# if YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -1555,7 +1540,7 @@ YYLTYPE yylloc;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
- YYLTYPE yyerror_range[3];
+ YYLTYPE yyerror_range[2];
YYSIZE_T yystacksize;
@@ -1602,7 +1587,7 @@ YYLTYPE yylloc;
yyvsp = yyvs;
yylsp = yyls;
-#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 1;
@@ -1610,8 +1595,8 @@ YYLTYPE yylloc;
/* User initialization code. */
-/* Line 1251 of yacc.c */
-#line 155 "glcpp/glcpp-parse.y"
+/* Line 1242 of yacc.c */
+#line 148 "glcpp/glcpp-parse.y"
{
yylloc.first_line = 1;
yylloc.first_column = 1;
@@ -1620,8 +1605,8 @@ YYLTYPE yylloc;
yylloc.source = 0;
}
-/* Line 1251 of yacc.c */
-#line 1625 "glcpp/glcpp-parse.c"
+/* Line 1242 of yacc.c */
+#line 1610 "glcpp/glcpp-parse.c"
yylsp[0] = yylloc;
goto yysetstate;
@@ -1808,28 +1793,28 @@ yyreduce:
{
case 4:
-/* Line 1464 of yacc.c */
-#line 194 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 187 "glcpp/glcpp-parse.y"
{
- glcpp_print(parser->output, "\n");
+ ralloc_strcat (&parser->output, "\n");
;}
break;
case 5:
-/* Line 1464 of yacc.c */
-#line 197 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 190 "glcpp/glcpp-parse.y"
{
_glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
- glcpp_print(parser->output, "\n");
- talloc_free ((yyvsp[(1) - (1)].token_list));
+ ralloc_strcat (&parser->output, "\n");
+ ralloc_free ((yyvsp[(1) - (1)].token_list));
;}
break;
case 8:
-/* Line 1464 of yacc.c */
-#line 207 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 200 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
;}
@@ -1837,8 +1822,8 @@ yyreduce:
case 9:
-/* Line 1464 of yacc.c */
-#line 210 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 203 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
;}
@@ -1846,8 +1831,8 @@ yyreduce:
case 10:
-/* Line 1464 of yacc.c */
-#line 216 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 209 "glcpp/glcpp-parse.y"
{
_define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
;}
@@ -1855,8 +1840,8 @@ yyreduce:
case 11:
-/* Line 1464 of yacc.c */
-#line 219 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 212 "glcpp/glcpp-parse.y"
{
_define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
;}
@@ -1864,8 +1849,8 @@ yyreduce:
case 12:
-/* Line 1464 of yacc.c */
-#line 222 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 215 "glcpp/glcpp-parse.y"
{
_define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
;}
@@ -1873,22 +1858,22 @@ yyreduce:
case 13:
-/* Line 1464 of yacc.c */
-#line 225 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 218 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
if (macro) {
hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
- talloc_free (macro);
+ ralloc_free (macro);
}
- talloc_free ((yyvsp[(2) - (3)].str));
+ ralloc_free ((yyvsp[(2) - (3)].str));
;}
break;
case 14:
-/* Line 1464 of yacc.c */
-#line 233 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 226 "glcpp/glcpp-parse.y"
{
/* Be careful to only evaluate the 'if' expression if
* we are not skipping. When we are skipping, we
@@ -1912,8 +1897,8 @@ yyreduce:
case 15:
-/* Line 1464 of yacc.c */
-#line 252 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 245 "glcpp/glcpp-parse.y"
{
/* #if without an expression is only an error if we
* are not skipping */
@@ -1928,30 +1913,30 @@ yyreduce:
case 16:
-/* Line 1464 of yacc.c */
-#line 262 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 255 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
- talloc_free ((yyvsp[(2) - (4)].str));
+ ralloc_free ((yyvsp[(2) - (4)].str));
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
;}
break;
case 17:
-/* Line 1464 of yacc.c */
-#line 267 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 260 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
- talloc_free ((yyvsp[(2) - (4)].str));
+ ralloc_free ((yyvsp[(2) - (4)].str));
_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
;}
break;
case 18:
-/* Line 1464 of yacc.c */
-#line 272 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 265 "glcpp/glcpp-parse.y"
{
/* Be careful to only evaluate the 'elif' expression
* if we are not skipping. When we are skipping, we
@@ -1975,8 +1960,8 @@ yyreduce:
case 19:
-/* Line 1464 of yacc.c */
-#line 291 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 284 "glcpp/glcpp-parse.y"
{
/* #elif without an expression is an error unless we
* are skipping. */
@@ -1996,8 +1981,8 @@ yyreduce:
case 20:
-/* Line 1464 of yacc.c */
-#line 306 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 299 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
;}
@@ -2005,8 +1990,8 @@ yyreduce:
case 21:
-/* Line 1464 of yacc.c */
-#line 309 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 302 "glcpp/glcpp-parse.y"
{
_glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
;}
@@ -2014,13 +1999,13 @@ yyreduce:
case 22:
-/* Line 1464 of yacc.c */
-#line 312 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 305 "glcpp/glcpp-parse.y"
{
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
if (macro) {
hash_table_remove (parser->defines, "__VERSION__");
- talloc_free (macro);
+ ralloc_free (macro);
}
add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
@@ -2035,14 +2020,14 @@ yyreduce:
if ((yyvsp[(2) - (3)].ival) >= 130 || (yyvsp[(2) - (3)].ival) == 100)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
- glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
+ ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
;}
break;
case 24:
-/* Line 1464 of yacc.c */
-#line 337 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 330 "glcpp/glcpp-parse.y"
{
if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
(yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
@@ -2056,8 +2041,8 @@ yyreduce:
case 25:
-/* Line 1464 of yacc.c */
-#line 346 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 339 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (1)].ival);
;}
@@ -2065,8 +2050,8 @@ yyreduce:
case 27:
-/* Line 1464 of yacc.c */
-#line 352 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 345 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
;}
@@ -2074,8 +2059,8 @@ yyreduce:
case 28:
-/* Line 1464 of yacc.c */
-#line 355 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 348 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
;}
@@ -2083,8 +2068,8 @@ yyreduce:
case 29:
-/* Line 1464 of yacc.c */
-#line 358 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 351 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
;}
@@ -2092,8 +2077,8 @@ yyreduce:
case 30:
-/* Line 1464 of yacc.c */
-#line 361 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 354 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
;}
@@ -2101,8 +2086,8 @@ yyreduce:
case 31:
-/* Line 1464 of yacc.c */
-#line 364 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 357 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
;}
@@ -2110,8 +2095,8 @@ yyreduce:
case 32:
-/* Line 1464 of yacc.c */
-#line 367 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 360 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
;}
@@ -2119,8 +2104,8 @@ yyreduce:
case 33:
-/* Line 1464 of yacc.c */
-#line 370 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 363 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
;}
@@ -2128,8 +2113,8 @@ yyreduce:
case 34:
-/* Line 1464 of yacc.c */
-#line 373 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 366 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
;}
@@ -2137,8 +2122,8 @@ yyreduce:
case 35:
-/* Line 1464 of yacc.c */
-#line 376 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 369 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
;}
@@ -2146,8 +2131,8 @@ yyreduce:
case 36:
-/* Line 1464 of yacc.c */
-#line 379 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 372 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
;}
@@ -2155,8 +2140,8 @@ yyreduce:
case 37:
-/* Line 1464 of yacc.c */
-#line 382 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 375 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
;}
@@ -2164,8 +2149,8 @@ yyreduce:
case 38:
-/* Line 1464 of yacc.c */
-#line 385 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 378 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
;}
@@ -2173,8 +2158,8 @@ yyreduce:
case 39:
-/* Line 1464 of yacc.c */
-#line 388 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 381 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
;}
@@ -2182,8 +2167,8 @@ yyreduce:
case 40:
-/* Line 1464 of yacc.c */
-#line 391 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 384 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
;}
@@ -2191,8 +2176,8 @@ yyreduce:
case 41:
-/* Line 1464 of yacc.c */
-#line 394 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 387 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
;}
@@ -2200,26 +2185,36 @@ yyreduce:
case 42:
-/* Line 1464 of yacc.c */
-#line 397 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 390 "glcpp/glcpp-parse.y"
{
- (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
+ if ((yyvsp[(3) - (3)].ival) == 0) {
+ yyerror (& (yylsp[(1) - (3)]), parser,
+ "zero modulus in preprocessor directive");
+ } else {
+ (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
+ }
;}
break;
case 43:
-/* Line 1464 of yacc.c */
-#line 400 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 398 "glcpp/glcpp-parse.y"
{
- (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
+ if ((yyvsp[(3) - (3)].ival) == 0) {
+ yyerror (& (yylsp[(1) - (3)]), parser,
+ "division by 0 in preprocessor directive");
+ } else {
+ (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
+ }
;}
break;
case 44:
-/* Line 1464 of yacc.c */
-#line 403 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 406 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
;}
@@ -2227,8 +2222,8 @@ yyreduce:
case 45:
-/* Line 1464 of yacc.c */
-#line 406 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 409 "glcpp/glcpp-parse.y"
{
(yyval.ival) = ! (yyvsp[(2) - (2)].ival);
;}
@@ -2236,8 +2231,8 @@ yyreduce:
case 46:
-/* Line 1464 of yacc.c */
-#line 409 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 412 "glcpp/glcpp-parse.y"
{
(yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
;}
@@ -2245,8 +2240,8 @@ yyreduce:
case 47:
-/* Line 1464 of yacc.c */
-#line 412 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 415 "glcpp/glcpp-parse.y"
{
(yyval.ival) = - (yyvsp[(2) - (2)].ival);
;}
@@ -2254,8 +2249,8 @@ yyreduce:
case 48:
-/* Line 1464 of yacc.c */
-#line 415 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 418 "glcpp/glcpp-parse.y"
{
(yyval.ival) = + (yyvsp[(2) - (2)].ival);
;}
@@ -2263,8 +2258,8 @@ yyreduce:
case 49:
-/* Line 1464 of yacc.c */
-#line 418 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 421 "glcpp/glcpp-parse.y"
{
(yyval.ival) = (yyvsp[(2) - (3)].ival);
;}
@@ -2272,37 +2267,37 @@ yyreduce:
case 50:
-/* Line 1464 of yacc.c */
-#line 424 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 427 "glcpp/glcpp-parse.y"
{
(yyval.string_list) = _string_list_create (parser);
_string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
- talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
+ ralloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
;}
break;
case 51:
-/* Line 1464 of yacc.c */
-#line 429 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 432 "glcpp/glcpp-parse.y"
{
(yyval.string_list) = (yyvsp[(1) - (3)].string_list);
_string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
- talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
+ ralloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
;}
break;
case 52:
-/* Line 1464 of yacc.c */
-#line 437 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 440 "glcpp/glcpp-parse.y"
{ (yyval.token_list) = NULL; ;}
break;
case 54:
-/* Line 1464 of yacc.c */
-#line 442 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 445 "glcpp/glcpp-parse.y"
{
yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
;}
@@ -2310,15 +2305,15 @@ yyreduce:
case 55:
-/* Line 1464 of yacc.c */
-#line 448 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 451 "glcpp/glcpp-parse.y"
{ (yyval.token_list) = NULL; ;}
break;
case 58:
-/* Line 1464 of yacc.c */
-#line 454 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 457 "glcpp/glcpp-parse.y"
{
glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
;}
@@ -2326,8 +2321,8 @@ yyreduce:
case 59:
-/* Line 1464 of yacc.c */
-#line 461 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 464 "glcpp/glcpp-parse.y"
{
int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
(yyval.token) = _token_create_ival (parser, INTEGER, v);
@@ -2336,8 +2331,8 @@ yyreduce:
case 60:
-/* Line 1464 of yacc.c */
-#line 465 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 468 "glcpp/glcpp-parse.y"
{
int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
(yyval.token) = _token_create_ival (parser, INTEGER, v);
@@ -2346,53 +2341,49 @@ yyreduce:
case 62:
-/* Line 1464 of yacc.c */
-#line 474 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 477 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = _token_list_create (parser);
_token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
- talloc_unlink (parser, (yyvsp[(1) - (1)].token));
;}
break;
case 63:
-/* Line 1464 of yacc.c */
-#line 479 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 481 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
- talloc_unlink (parser, (yyvsp[(2) - (2)].token));
;}
break;
case 64:
-/* Line 1464 of yacc.c */
-#line 487 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 488 "glcpp/glcpp-parse.y"
{
parser->space_tokens = 1;
(yyval.token_list) = _token_list_create (parser);
_token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
- talloc_unlink (parser, (yyvsp[(1) - (1)].token));
;}
break;
case 65:
-/* Line 1464 of yacc.c */
+/* Line 1455 of yacc.c */
#line 493 "glcpp/glcpp-parse.y"
{
(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
- talloc_unlink (parser, (yyvsp[(2) - (2)].token));
;}
break;
case 66:
-/* Line 1464 of yacc.c */
-#line 501 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 500 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
@@ -2401,8 +2392,8 @@ yyreduce:
case 67:
-/* Line 1464 of yacc.c */
-#line 505 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 504 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
@@ -2411,8 +2402,8 @@ yyreduce:
case 68:
-/* Line 1464 of yacc.c */
-#line 509 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 508 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
(yyval.token)->location = yylloc;
@@ -2421,8 +2412,8 @@ yyreduce:
case 69:
-/* Line 1464 of yacc.c */
-#line 513 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 512 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
(yyval.token)->location = yylloc;
@@ -2431,8 +2422,8 @@ yyreduce:
case 70:
-/* Line 1464 of yacc.c */
-#line 517 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 516 "glcpp/glcpp-parse.y"
{
(yyval.token) = _token_create_ival (parser, SPACE, SPACE);
(yyval.token)->location = yylloc;
@@ -2441,225 +2432,225 @@ yyreduce:
case 71:
-/* Line 1464 of yacc.c */
-#line 524 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 523 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '['; ;}
break;
case 72:
-/* Line 1464 of yacc.c */
-#line 525 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 524 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ']'; ;}
break;
case 73:
-/* Line 1464 of yacc.c */
-#line 526 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 525 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '('; ;}
break;
case 74:
-/* Line 1464 of yacc.c */
-#line 527 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 526 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ')'; ;}
break;
case 75:
-/* Line 1464 of yacc.c */
-#line 528 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 527 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '{'; ;}
break;
case 76:
-/* Line 1464 of yacc.c */
-#line 529 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 528 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '}'; ;}
break;
case 77:
-/* Line 1464 of yacc.c */
-#line 530 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 529 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '.'; ;}
break;
case 78:
-/* Line 1464 of yacc.c */
-#line 531 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 530 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '&'; ;}
break;
case 79:
-/* Line 1464 of yacc.c */
-#line 532 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 531 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '*'; ;}
break;
case 80:
-/* Line 1464 of yacc.c */
-#line 533 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 532 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '+'; ;}
break;
case 81:
-/* Line 1464 of yacc.c */
-#line 534 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 533 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '-'; ;}
break;
case 82:
-/* Line 1464 of yacc.c */
-#line 535 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 534 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '~'; ;}
break;
case 83:
-/* Line 1464 of yacc.c */
-#line 536 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 535 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '!'; ;}
break;
case 84:
-/* Line 1464 of yacc.c */
-#line 537 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 536 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '/'; ;}
break;
case 85:
-/* Line 1464 of yacc.c */
-#line 538 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 537 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '%'; ;}
break;
case 86:
-/* Line 1464 of yacc.c */
-#line 539 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 538 "glcpp/glcpp-parse.y"
{ (yyval.ival) = LEFT_SHIFT; ;}
break;
case 87:
-/* Line 1464 of yacc.c */
-#line 540 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 539 "glcpp/glcpp-parse.y"
{ (yyval.ival) = RIGHT_SHIFT; ;}
break;
case 88:
-/* Line 1464 of yacc.c */
-#line 541 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 540 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '<'; ;}
break;
case 89:
-/* Line 1464 of yacc.c */
-#line 542 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 541 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '>'; ;}
break;
case 90:
-/* Line 1464 of yacc.c */
-#line 543 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 542 "glcpp/glcpp-parse.y"
{ (yyval.ival) = LESS_OR_EQUAL; ;}
break;
case 91:
-/* Line 1464 of yacc.c */
-#line 544 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 543 "glcpp/glcpp-parse.y"
{ (yyval.ival) = GREATER_OR_EQUAL; ;}
break;
case 92:
-/* Line 1464 of yacc.c */
-#line 545 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 544 "glcpp/glcpp-parse.y"
{ (yyval.ival) = EQUAL; ;}
break;
case 93:
-/* Line 1464 of yacc.c */
-#line 546 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 545 "glcpp/glcpp-parse.y"
{ (yyval.ival) = NOT_EQUAL; ;}
break;
case 94:
-/* Line 1464 of yacc.c */
-#line 547 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 546 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '^'; ;}
break;
case 95:
-/* Line 1464 of yacc.c */
-#line 548 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 547 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '|'; ;}
break;
case 96:
-/* Line 1464 of yacc.c */
-#line 549 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 548 "glcpp/glcpp-parse.y"
{ (yyval.ival) = AND; ;}
break;
case 97:
-/* Line 1464 of yacc.c */
-#line 550 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 549 "glcpp/glcpp-parse.y"
{ (yyval.ival) = OR; ;}
break;
case 98:
-/* Line 1464 of yacc.c */
-#line 551 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 550 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ';'; ;}
break;
case 99:
-/* Line 1464 of yacc.c */
-#line 552 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 551 "glcpp/glcpp-parse.y"
{ (yyval.ival) = ','; ;}
break;
case 100:
-/* Line 1464 of yacc.c */
-#line 553 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 552 "glcpp/glcpp-parse.y"
{ (yyval.ival) = '='; ;}
break;
case 101:
-/* Line 1464 of yacc.c */
-#line 554 "glcpp/glcpp-parse.y"
+/* Line 1455 of yacc.c */
+#line 553 "glcpp/glcpp-parse.y"
{ (yyval.ival) = PASTE; ;}
break;
-/* Line 1464 of yacc.c */
-#line 2663 "glcpp/glcpp-parse.c"
+/* Line 1455 of yacc.c */
+#line 2654 "glcpp/glcpp-parse.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2731,7 +2722,7 @@ yyerrlab:
#endif
}
- yyerror_range[1] = yylloc;
+ yyerror_range[0] = yylloc;
if (yyerrstatus == 3)
{
@@ -2768,7 +2759,7 @@ yyerrorlab:
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
- yyerror_range[1] = yylsp[1-yylen];
+ yyerror_range[0] = yylsp[1-yylen];
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
@@ -2802,7 +2793,7 @@ yyerrlab1:
if (yyssp == yyss)
YYABORT;
- yyerror_range[1] = *yylsp;
+ yyerror_range[0] = *yylsp;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yylsp, parser);
YYPOPSTACK (1);
@@ -2812,10 +2803,10 @@ yyerrlab1:
*++yyvsp = yylval;
- yyerror_range[2] = yylloc;
+ yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
- YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
+ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
/* Shift the error token. */
@@ -2877,8 +2868,8 @@ yyreturn:
-/* Line 1684 of yacc.c */
-#line 557 "glcpp/glcpp-parse.y"
+/* Line 1675 of yacc.c */
+#line 556 "glcpp/glcpp-parse.y"
string_list_t *
@@ -2886,7 +2877,7 @@ _string_list_create (void *ctx)
{
string_list_t *list;
- list = talloc (ctx, string_list_t);
+ list = ralloc (ctx, string_list_t);
list->head = NULL;
list->tail = NULL;
@@ -2898,8 +2889,8 @@ _string_list_append_item (string_list_t *list, const char *str)
{
string_node_t *node;
- node = talloc (list, string_node_t);
- node->str = talloc_strdup (node, str);
+ node = ralloc (list, string_node_t);
+ node->str = ralloc_strdup (node, str);
node->next = NULL;
@@ -2977,7 +2968,7 @@ _argument_list_create (void *ctx)
{
argument_list_t *list;
- list = talloc (ctx, argument_list_t);
+ list = ralloc (ctx, argument_list_t);
list->head = NULL;
list->tail = NULL;
@@ -2989,7 +2980,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument)
{
argument_node_t *node;
- node = talloc (list, argument_node_t);
+ node = ralloc (list, argument_node_t);
node->argument = argument;
node->next = NULL;
@@ -3040,15 +3031,17 @@ _argument_list_member_at (argument_list_t *list, int index)
return NULL;
}
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
token_t *
_token_create_str (void *ctx, int type, char *str)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
- token->value.str = talloc_steal (token, str);
+ token->value.str = str;
+
+ ralloc_steal (token, str);
return token;
}
@@ -3058,7 +3051,7 @@ _token_create_ival (void *ctx, int type, int ival)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
token->value.ival = ival;
@@ -3070,7 +3063,7 @@ _token_list_create (void *ctx)
{
token_list_t *list;
- list = talloc (ctx, token_list_t);
+ list = ralloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
list->non_space_tail = NULL;
@@ -3083,11 +3076,12 @@ _token_list_append (token_list_t *list, token_t *token)
{
token_node_t *node;
- node = talloc (list, token_node_t);
- node->token = talloc_reference (list, token);
-
+ node = ralloc (list, token_node_t);
+ node->token = token;
node->next = NULL;
+ ralloc_steal (list, token);
+
if (list->head == NULL) {
list->head = node;
} else {
@@ -3125,8 +3119,11 @@ _token_list_copy (void *ctx, token_list_t *other)
return NULL;
copy = _token_list_create (ctx);
- for (node = other->head; node; node = node->next)
- _token_list_append (copy, node->token);
+ for (node = other->head; node; node = node->next) {
+ token_t *new_token = ralloc (copy, token_t);
+ *new_token = *node->token;
+ _token_list_append (copy, new_token);
+ }
return copy;
}
@@ -3143,17 +3140,38 @@ _token_list_trim_trailing_space (token_list_t *list)
while (tail) {
next = tail->next;
- talloc_free (tail);
+ ralloc_free (tail);
tail = next;
}
}
}
+static int
+_token_list_is_empty_ignoring_space (token_list_t *l)
+{
+ token_node_t *n;
+
+ if (l == NULL)
+ return 1;
+
+ n = l->head;
+ while (n != NULL && n->token->type == SPACE)
+ n = n->next;
+
+ return n == NULL;
+}
+
int
_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
{
token_node_t *node_a, *node_b;
+ if (a == NULL || b == NULL) {
+ int a_empty = _token_list_is_empty_ignoring_space(a);
+ int b_empty = _token_list_is_empty_ignoring_space(b);
+ return a_empty == b_empty;
+ }
+
node_a = a->head;
node_b = b->head;
@@ -3208,51 +3226,51 @@ static void
_token_print (char **out, token_t *token)
{
if (token->type < 256) {
- glcpp_printf (*out, "%c", token->type);
+ ralloc_asprintf_append (out, "%c", token->type);
return;
}
switch (token->type) {
case INTEGER:
- glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
+ ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
break;
case IDENTIFIER:
case INTEGER_STRING:
case OTHER:
- glcpp_print (*out, token->value.str);
+ ralloc_strcat (out, token->value.str);
break;
case SPACE:
- glcpp_print (*out, " ");
+ ralloc_strcat (out, " ");
break;
case LEFT_SHIFT:
- glcpp_print (*out, "<<");
+ ralloc_strcat (out, "<<");
break;
case RIGHT_SHIFT:
- glcpp_print (*out, ">>");
+ ralloc_strcat (out, ">>");
break;
case LESS_OR_EQUAL:
- glcpp_print (*out, "<=");
+ ralloc_strcat (out, "<=");
break;
case GREATER_OR_EQUAL:
- glcpp_print (*out, ">=");
+ ralloc_strcat (out, ">=");
break;
case EQUAL:
- glcpp_print (*out, "==");
+ ralloc_strcat (out, "==");
break;
case NOT_EQUAL:
- glcpp_print (*out, "!=");
+ ralloc_strcat (out, "!=");
break;
case AND:
- glcpp_print (*out, "&&");
+ ralloc_strcat (out, "&&");
break;
case OR:
- glcpp_print (*out, "||");
+ ralloc_strcat (out, "||");
break;
case PASTE:
- glcpp_print (*out, "##");
+ ralloc_strcat (out, "##");
break;
case COMMA_FINAL:
- glcpp_print (*out, ",");
+ ralloc_strcat (out, ",");
break;
case PLACEHOLDER:
/* Nothing to print. */
@@ -3263,7 +3281,7 @@ _token_print (char **out, token_t *token)
}
}
-/* Return a new token (talloc()ed off of 'token') formed by pasting
+/* Return a new token (ralloc()ed off of 'token') formed by pasting
* 'token' and 'other'. Note that this function may return 'token' or
* 'other' directly rather than allocating anything new.
*
@@ -3334,7 +3352,7 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
{
char *str;
- str = talloc_asprintf (token, "%s%s", token->value.str,
+ str = ralloc_asprintf (token, "%s%s", token->value.str,
other->value.str);
combined = _token_create_str (token, token->type, str);
combined->location = token->location;
@@ -3342,11 +3360,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
}
glcpp_error (&token->location, parser, "");
- glcpp_print (parser->info_log, "Pasting \"");
+ ralloc_strcat (&parser->info_log, "Pasting \"");
_token_print (&parser->info_log, token);
- glcpp_print (parser->info_log, "\" and \"");
+ ralloc_strcat (&parser->info_log, "\" and \"");
_token_print (&parser->info_log, other);
- glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
+ ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
return token;
}
@@ -3380,8 +3398,6 @@ static void add_builtin_define(glcpp_parser_t *parser,
list = _token_list_create(parser);
_token_list_append(list, tok);
_define_object_macro(parser, NULL, name, list);
-
- talloc_unlink(parser, tok);
}
glcpp_parser_t *
@@ -3390,7 +3406,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
glcpp_parser_t *parser;
int language_version;
- parser = talloc (NULL, glcpp_parser_t);
+ parser = ralloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = hash_table_ctor (32, hash_table_string_hash,
@@ -3407,8 +3423,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
parser->lex_from_list = NULL;
parser->lex_from_node = NULL;
- parser->output = talloc_strdup(parser, "");
- parser->info_log = talloc_strdup(parser, "");
+ parser->output = ralloc_strdup(parser, "");
+ parser->info_log = ralloc_strdup(parser, "");
parser->error = 0;
/* Add pre-defined macros. */
@@ -3429,6 +3445,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
if (extensions->ARB_explicit_attrib_location)
add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
+ if (extensions->AMD_conservative_depth)
+ add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
}
language_version = 110;
@@ -3448,7 +3466,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser)
{
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
- talloc_free (parser);
+ ralloc_free (parser);
}
typedef enum function_status
@@ -3619,7 +3637,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL) {
- talloc_free (arguments);
+ ralloc_free (arguments);
return _token_list_create_with_one_space (parser);
}
@@ -3775,7 +3793,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
token_list_t *expansion;
token_t *final;
- str = talloc_strdup (parser, token->value.str);
+ str = ralloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
@@ -3811,8 +3829,8 @@ _active_list_push (active_list_t *list,
{
active_list_t *node;
- node = talloc (list, active_list_t);
- node->identifier = talloc_strdup (node, identifier);
+ node = ralloc (list, active_list_t);
+ node->identifier = ralloc_strdup (node, identifier);
node->marker = marker;
node->next = list;
@@ -3828,7 +3846,7 @@ _active_list_pop (active_list_t *list)
return NULL;
node = list->next;
- talloc_free (list);
+ ralloc_free (list);
return node;
}
@@ -3977,17 +3995,18 @@ _define_object_macro (glcpp_parser_t *parser,
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
macro->is_function = 0;
macro->parameters = NULL;
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
+ ralloc_steal (macro, replacements);
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
@@ -4008,17 +4027,18 @@ _define_function_macro (glcpp_parser_t *parser,
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
+ ralloc_steal (macro, parameters);
+ ralloc_steal (macro, replacements);
macro->is_function = 1;
- macro->parameters = talloc_steal (macro, parameters);
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
-
+ macro->parameters = parameters;
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
@@ -4094,7 +4114,7 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
node = parser->lex_from_node;
if (node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
return NEWLINE;
}
@@ -4123,13 +4143,13 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
_token_list_append (parser->lex_from_list, node->token);
}
- talloc_free (list);
+ ralloc_free (list);
parser->lex_from_node = parser->lex_from_list->head;
/* It's possible the list consisted of nothing but whitespace. */
if (parser->lex_from_node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
}
}
@@ -4144,7 +4164,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
if (parser->skip_stack)
current = parser->skip_stack->type;
- node = talloc (parser, skip_node_t);
+ node = ralloc (parser, skip_node_t);
node->loc = *loc;
if (current == SKIP_NO_SKIP) {
@@ -4189,6 +4209,6 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
node = parser->skip_stack;
parser->skip_stack = node->next;
- talloc_free (node);
+ ralloc_free (node);
}
diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h
index 40556854f38..50758930e9c 100644
--- a/src/glsl/glcpp/glcpp-parse.h
+++ b/src/glsl/glcpp/glcpp-parse.h
@@ -1,9 +1,10 @@
-/* A Bison parser, made by GNU Bison 2.4.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 558ad0acacc..1f6e67fa062 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -32,10 +32,6 @@
#include "main/core.h" /* for struct gl_extensions */
#include "main/mtypes.h" /* for gl_api enum */
-#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
-#define glcpp_printf(stream, fmt, args, ...) \
- stream = talloc_asprintf_append(stream, fmt, args)
-
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
@@ -79,7 +75,7 @@ _argument_list_length (argument_list_t *list);
static token_list_t *
_argument_list_member_at (argument_list_t *list, int index);
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
static token_t *
_token_create_str (void *ctx, int type, char *str);
@@ -89,10 +85,7 @@ _token_create_ival (void *ctx, int type, int ival);
static token_list_t *
_token_list_create (void *ctx);
-/* Note: This function adds a talloc_reference() to token.
- *
- * You may want to talloc_unlink any current reference if you no
- * longer need it. */
+/* Note: This function calls ralloc_steal on token. */
static void
_token_list_append (token_list_t *list, token_t *token);
@@ -192,12 +185,12 @@ input:
line:
control_line {
- glcpp_print(parser->output, "\n");
+ ralloc_strcat (&parser->output, "\n");
}
| text_line {
_glcpp_parser_print_expanded_token_list (parser, $1);
- glcpp_print(parser->output, "\n");
- talloc_free ($1);
+ ralloc_strcat (&parser->output, "\n");
+ ralloc_free ($1);
}
| expanded_line
| HASH non_directive
@@ -226,9 +219,9 @@ control_line:
macro_t *macro = hash_table_find (parser->defines, $2);
if (macro) {
hash_table_remove (parser->defines, $2);
- talloc_free (macro);
+ ralloc_free (macro);
}
- talloc_free ($2);
+ ralloc_free ($2);
}
| HASH_IF conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'if' expression if
@@ -261,12 +254,12 @@ control_line:
}
| HASH_IFDEF IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
- talloc_free ($2);
+ ralloc_free ($2);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
| HASH_IFNDEF IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
- talloc_free ($2);
+ ralloc_free ($2);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
}
| HASH_ELIF conditional_tokens NEWLINE {
@@ -313,7 +306,7 @@ control_line:
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
if (macro) {
hash_table_remove (parser->defines, "__VERSION__");
- talloc_free (macro);
+ ralloc_free (macro);
}
add_builtin_define (parser, "__VERSION__", $2);
@@ -328,7 +321,7 @@ control_line:
if ($2 >= 130 || $2 == 100)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
- glcpp_printf(parser->output, "#version %" PRIiMAX, $2);
+ ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2);
}
| HASH NEWLINE
;
@@ -395,10 +388,20 @@ expression:
$$ = $1 + $3;
}
| expression '%' expression {
- $$ = $1 % $3;
+ if ($3 == 0) {
+ yyerror (& @1, parser,
+ "zero modulus in preprocessor directive");
+ } else {
+ $$ = $1 % $3;
+ }
}
| expression '/' expression {
- $$ = $1 / $3;
+ if ($3 == 0) {
+ yyerror (& @1, parser,
+ "division by 0 in preprocessor directive");
+ } else {
+ $$ = $1 / $3;
+ }
}
| expression '*' expression {
$$ = $1 * $3;
@@ -424,12 +427,12 @@ identifier_list:
IDENTIFIER {
$$ = _string_list_create (parser);
_string_list_append_item ($$, $1);
- talloc_steal ($$, $1);
+ ralloc_steal ($$, $1);
}
| identifier_list ',' IDENTIFIER {
$$ = $1;
_string_list_append_item ($$, $3);
- talloc_steal ($$, $3);
+ ralloc_steal ($$, $3);
}
;
@@ -474,12 +477,10 @@ conditional_tokens:
conditional_token {
$$ = _token_list_create (parser);
_token_list_append ($$, $1);
- talloc_unlink (parser, $1);
}
| conditional_tokens conditional_token {
$$ = $1;
_token_list_append ($$, $2);
- talloc_unlink (parser, $2);
}
;
@@ -488,12 +489,10 @@ pp_tokens:
parser->space_tokens = 1;
$$ = _token_list_create (parser);
_token_list_append ($$, $1);
- talloc_unlink (parser, $1);
}
| pp_tokens preprocessing_token {
$$ = $1;
_token_list_append ($$, $2);
- talloc_unlink (parser, $2);
}
;
@@ -561,7 +560,7 @@ _string_list_create (void *ctx)
{
string_list_t *list;
- list = talloc (ctx, string_list_t);
+ list = ralloc (ctx, string_list_t);
list->head = NULL;
list->tail = NULL;
@@ -573,8 +572,8 @@ _string_list_append_item (string_list_t *list, const char *str)
{
string_node_t *node;
- node = talloc (list, string_node_t);
- node->str = talloc_strdup (node, str);
+ node = ralloc (list, string_node_t);
+ node->str = ralloc_strdup (node, str);
node->next = NULL;
@@ -652,7 +651,7 @@ _argument_list_create (void *ctx)
{
argument_list_t *list;
- list = talloc (ctx, argument_list_t);
+ list = ralloc (ctx, argument_list_t);
list->head = NULL;
list->tail = NULL;
@@ -664,7 +663,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument)
{
argument_node_t *node;
- node = talloc (list, argument_node_t);
+ node = ralloc (list, argument_node_t);
node->argument = argument;
node->next = NULL;
@@ -715,15 +714,17 @@ _argument_list_member_at (argument_list_t *list, int index)
return NULL;
}
-/* Note: This function talloc_steal()s the str pointer. */
+/* Note: This function ralloc_steal()s the str pointer. */
token_t *
_token_create_str (void *ctx, int type, char *str)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
- token->value.str = talloc_steal (token, str);
+ token->value.str = str;
+
+ ralloc_steal (token, str);
return token;
}
@@ -733,7 +734,7 @@ _token_create_ival (void *ctx, int type, int ival)
{
token_t *token;
- token = talloc (ctx, token_t);
+ token = ralloc (ctx, token_t);
token->type = type;
token->value.ival = ival;
@@ -745,7 +746,7 @@ _token_list_create (void *ctx)
{
token_list_t *list;
- list = talloc (ctx, token_list_t);
+ list = ralloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
list->non_space_tail = NULL;
@@ -758,11 +759,12 @@ _token_list_append (token_list_t *list, token_t *token)
{
token_node_t *node;
- node = talloc (list, token_node_t);
- node->token = talloc_reference (list, token);
-
+ node = ralloc (list, token_node_t);
+ node->token = token;
node->next = NULL;
+ ralloc_steal (list, token);
+
if (list->head == NULL) {
list->head = node;
} else {
@@ -800,8 +802,11 @@ _token_list_copy (void *ctx, token_list_t *other)
return NULL;
copy = _token_list_create (ctx);
- for (node = other->head; node; node = node->next)
- _token_list_append (copy, node->token);
+ for (node = other->head; node; node = node->next) {
+ token_t *new_token = ralloc (copy, token_t);
+ *new_token = *node->token;
+ _token_list_append (copy, new_token);
+ }
return copy;
}
@@ -818,17 +823,38 @@ _token_list_trim_trailing_space (token_list_t *list)
while (tail) {
next = tail->next;
- talloc_free (tail);
+ ralloc_free (tail);
tail = next;
}
}
}
+static int
+_token_list_is_empty_ignoring_space (token_list_t *l)
+{
+ token_node_t *n;
+
+ if (l == NULL)
+ return 1;
+
+ n = l->head;
+ while (n != NULL && n->token->type == SPACE)
+ n = n->next;
+
+ return n == NULL;
+}
+
int
_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
{
token_node_t *node_a, *node_b;
+ if (a == NULL || b == NULL) {
+ int a_empty = _token_list_is_empty_ignoring_space(a);
+ int b_empty = _token_list_is_empty_ignoring_space(b);
+ return a_empty == b_empty;
+ }
+
node_a = a->head;
node_b = b->head;
@@ -883,51 +909,51 @@ static void
_token_print (char **out, token_t *token)
{
if (token->type < 256) {
- glcpp_printf (*out, "%c", token->type);
+ ralloc_asprintf_append (out, "%c", token->type);
return;
}
switch (token->type) {
case INTEGER:
- glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
+ ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
break;
case IDENTIFIER:
case INTEGER_STRING:
case OTHER:
- glcpp_print (*out, token->value.str);
+ ralloc_strcat (out, token->value.str);
break;
case SPACE:
- glcpp_print (*out, " ");
+ ralloc_strcat (out, " ");
break;
case LEFT_SHIFT:
- glcpp_print (*out, "<<");
+ ralloc_strcat (out, "<<");
break;
case RIGHT_SHIFT:
- glcpp_print (*out, ">>");
+ ralloc_strcat (out, ">>");
break;
case LESS_OR_EQUAL:
- glcpp_print (*out, "<=");
+ ralloc_strcat (out, "<=");
break;
case GREATER_OR_EQUAL:
- glcpp_print (*out, ">=");
+ ralloc_strcat (out, ">=");
break;
case EQUAL:
- glcpp_print (*out, "==");
+ ralloc_strcat (out, "==");
break;
case NOT_EQUAL:
- glcpp_print (*out, "!=");
+ ralloc_strcat (out, "!=");
break;
case AND:
- glcpp_print (*out, "&&");
+ ralloc_strcat (out, "&&");
break;
case OR:
- glcpp_print (*out, "||");
+ ralloc_strcat (out, "||");
break;
case PASTE:
- glcpp_print (*out, "##");
+ ralloc_strcat (out, "##");
break;
case COMMA_FINAL:
- glcpp_print (*out, ",");
+ ralloc_strcat (out, ",");
break;
case PLACEHOLDER:
/* Nothing to print. */
@@ -938,7 +964,7 @@ _token_print (char **out, token_t *token)
}
}
-/* Return a new token (talloc()ed off of 'token') formed by pasting
+/* Return a new token (ralloc()ed off of 'token') formed by pasting
* 'token' and 'other'. Note that this function may return 'token' or
* 'other' directly rather than allocating anything new.
*
@@ -1009,7 +1035,7 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
{
char *str;
- str = talloc_asprintf (token, "%s%s", token->value.str,
+ str = ralloc_asprintf (token, "%s%s", token->value.str,
other->value.str);
combined = _token_create_str (token, token->type, str);
combined->location = token->location;
@@ -1017,11 +1043,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
}
glcpp_error (&token->location, parser, "");
- glcpp_print (parser->info_log, "Pasting \"");
+ ralloc_strcat (&parser->info_log, "Pasting \"");
_token_print (&parser->info_log, token);
- glcpp_print (parser->info_log, "\" and \"");
+ ralloc_strcat (&parser->info_log, "\" and \"");
_token_print (&parser->info_log, other);
- glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
+ ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
return token;
}
@@ -1055,8 +1081,6 @@ static void add_builtin_define(glcpp_parser_t *parser,
list = _token_list_create(parser);
_token_list_append(list, tok);
_define_object_macro(parser, NULL, name, list);
-
- talloc_unlink(parser, tok);
}
glcpp_parser_t *
@@ -1065,7 +1089,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
glcpp_parser_t *parser;
int language_version;
- parser = talloc (NULL, glcpp_parser_t);
+ parser = ralloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = hash_table_ctor (32, hash_table_string_hash,
@@ -1082,8 +1106,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
parser->lex_from_list = NULL;
parser->lex_from_node = NULL;
- parser->output = talloc_strdup(parser, "");
- parser->info_log = talloc_strdup(parser, "");
+ parser->output = ralloc_strdup(parser, "");
+ parser->info_log = ralloc_strdup(parser, "");
parser->error = 0;
/* Add pre-defined macros. */
@@ -1104,6 +1128,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
if (extensions->ARB_explicit_attrib_location)
add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
+ if (extensions->AMD_conservative_depth)
+ add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
}
language_version = 110;
@@ -1123,7 +1149,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser)
{
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
- talloc_free (parser);
+ ralloc_free (parser);
}
typedef enum function_status
@@ -1294,7 +1320,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL) {
- talloc_free (arguments);
+ ralloc_free (arguments);
return _token_list_create_with_one_space (parser);
}
@@ -1450,7 +1476,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
token_list_t *expansion;
token_t *final;
- str = talloc_strdup (parser, token->value.str);
+ str = ralloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
@@ -1486,8 +1512,8 @@ _active_list_push (active_list_t *list,
{
active_list_t *node;
- node = talloc (list, active_list_t);
- node->identifier = talloc_strdup (node, identifier);
+ node = ralloc (list, active_list_t);
+ node->identifier = ralloc_strdup (node, identifier);
node->marker = marker;
node->next = list;
@@ -1503,7 +1529,7 @@ _active_list_pop (active_list_t *list)
return NULL;
node = list->next;
- talloc_free (list);
+ ralloc_free (list);
return node;
}
@@ -1652,17 +1678,18 @@ _define_object_macro (glcpp_parser_t *parser,
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
macro->is_function = 0;
macro->parameters = NULL;
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
+ ralloc_steal (macro, replacements);
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
@@ -1683,17 +1710,18 @@ _define_function_macro (glcpp_parser_t *parser,
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = talloc (parser, macro_t);
+ macro = ralloc (parser, macro_t);
+ ralloc_steal (macro, parameters);
+ ralloc_steal (macro, replacements);
macro->is_function = 1;
- macro->parameters = talloc_steal (macro, parameters);
- macro->identifier = talloc_strdup (macro, identifier);
- macro->replacements = talloc_steal (macro, replacements);
-
+ macro->parameters = parameters;
+ macro->identifier = ralloc_strdup (macro, identifier);
+ macro->replacements = replacements;
previous = hash_table_find (parser->defines, identifier);
if (previous) {
if (_macro_equal (macro, previous)) {
- talloc_free (macro);
+ ralloc_free (macro);
return;
}
glcpp_error (loc, parser, "Redefinition of macro %s\n",
@@ -1769,7 +1797,7 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
node = parser->lex_from_node;
if (node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
return NEWLINE;
}
@@ -1798,13 +1826,13 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
_token_list_append (parser->lex_from_list, node->token);
}
- talloc_free (list);
+ ralloc_free (list);
parser->lex_from_node = parser->lex_from_list->head;
/* It's possible the list consisted of nothing but whitespace. */
if (parser->lex_from_node == NULL) {
- talloc_free (parser->lex_from_list);
+ ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
}
}
@@ -1819,7 +1847,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
if (parser->skip_stack)
current = parser->skip_stack->type;
- node = talloc (parser, skip_node_t);
+ node = ralloc (parser, skip_node_t);
node->loc = *loc;
if (current == SKIP_NO_SKIP) {
@@ -1864,5 +1892,5 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
node = parser->skip_stack;
parser->skip_stack = node->next;
- talloc_free (node);
+ ralloc_free (node);
}
diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c
index 062eb6b72d4..325289129d5 100644
--- a/src/glsl/glcpp/glcpp.c
+++ b/src/glsl/glcpp/glcpp.c
@@ -21,10 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "glcpp.h"
@@ -40,39 +37,32 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
*ptr = sh;
}
-/* Read from fd until EOF and return a string of everything read.
+/* Read from fp until EOF and return a string of everything read.
*/
static char *
-load_text_fd (void *ctx, int fd)
+load_text_fp (void *ctx, FILE *fp)
{
#define CHUNK 4096
char *text = NULL;
- ssize_t text_size = 0;
- ssize_t total_read = 0;
- ssize_t bytes;
+ size_t text_size = 0;
+ size_t total_read = 0;
+ size_t bytes;
while (1) {
if (total_read + CHUNK + 1 > text_size) {
text_size = text_size ? text_size * 2 : CHUNK + 1;
- text = talloc_realloc_size (ctx, text, text_size);
+ text = reralloc_size (ctx, text, text_size);
if (text == NULL) {
fprintf (stderr, "Out of memory\n");
return NULL;
}
}
- bytes = read (fd, text + total_read, CHUNK);
- if (bytes < 0) {
- fprintf (stderr, "Error while reading: %s\n",
- strerror (errno));
- talloc_free (text);
- return NULL;
- }
+ bytes = fread (text + total_read, 1, CHUNK, fp);
+ total_read += bytes;
- if (bytes == 0) {
+ if (bytes < CHUNK) {
break;
}
-
- total_read += bytes;
}
text[total_read] = '\0';
@@ -84,21 +74,21 @@ static char *
load_text_file(void *ctx, const char *filename)
{
char *text;
- int fd;
+ FILE *fp;
if (filename == NULL || strcmp (filename, "-") == 0)
- return load_text_fd (ctx, STDIN_FILENO);
+ return load_text_fp (ctx, stdin);
- fd = open (filename, O_RDONLY);
- if (fd < 0) {
+ fp = fopen (filename, "r");
+ if (fp == NULL) {
fprintf (stderr, "Failed to open file %s: %s\n",
filename, strerror (errno));
return NULL;
}
- text = load_text_fd (ctx, fd);
+ text = load_text_fp (ctx, fp);
- close(fd);
+ fclose(fp);
return text;
}
@@ -107,8 +97,8 @@ int
main (int argc, char *argv[])
{
char *filename = NULL;
- void *ctx = talloc(NULL, void*);
- char *info_log = talloc_strdup(ctx, "");
+ void *ctx = ralloc(NULL, void*);
+ char *info_log = ralloc_strdup(ctx, "");
const char *shader;
int ret;
@@ -125,7 +115,7 @@ main (int argc, char *argv[])
printf("%s", shader);
fprintf(stderr, "%s", info_log);
- talloc_free(ctx);
+ ralloc_free(ctx);
return ret;
}
diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
index 7125d325dff..dc816e90ee7 100644
--- a/src/glsl/glcpp/glcpp.h
+++ b/src/glsl/glcpp/glcpp.h
@@ -26,7 +26,7 @@
#include <stdint.h>
-#include <talloc.h>
+#include "../ralloc.h"
#include "program/hash_table.h"
@@ -189,7 +189,7 @@ void
glcpp_parser_destroy (glcpp_parser_t *parser);
int
-preprocess(void *talloc_ctx, const char **shader, char **info_log,
+preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, int api);
/* Functions for writing to the info log */
diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index e1a3a88a3e5..3640896a2c2 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -33,16 +33,15 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
va_list ap;
parser->error = 1;
- parser->info_log = talloc_asprintf_append(parser->info_log,
- "%u:%u(%u): "
+ ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
"preprocessor error: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
+ ralloc_vasprintf_append(&parser->info_log, fmt, ap);
va_end(ap);
- parser->info_log = talloc_strdup_append(parser->info_log, "\n");
+ ralloc_strcat(&parser->info_log, "\n");
}
void
@@ -50,16 +49,15 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
{
va_list ap;
- parser->info_log = talloc_asprintf_append(parser->info_log,
- "%u:%u(%u): "
+ ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
"preprocessor warning: ",
locp->source,
locp->first_line,
locp->first_column);
va_start(ap, fmt);
- parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
+ ralloc_vasprintf_append(&parser->info_log, fmt, ap);
va_end(ap);
- parser->info_log = talloc_strdup_append(parser->info_log, "\n");
+ ralloc_strcat(&parser->info_log, "\n");
}
/* Searches backwards for '^ *#' from a given starting point. */
@@ -92,7 +90,7 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
{
int in_continued_line = 0;
int extra_newlines = 0;
- char *clean = talloc_strdup(ctx, "");
+ char *clean = ralloc_strdup(ctx, "");
const char *search_start = shader;
const char *newline;
while ((newline = strchr(search_start, '\n')) != NULL) {
@@ -122,27 +120,27 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
}
if (in_continued_line) {
/* Copy everything before the \ */
- clean = talloc_strndup_append(clean, shader, backslash - shader);
+ ralloc_strncat(&clean, shader, backslash - shader);
shader = newline + 1;
extra_newlines++;
}
} else if (in_continued_line) {
/* Copy everything up to and including the \n */
- clean = talloc_strndup_append(clean, shader, newline - shader + 1);
+ ralloc_strncat(&clean, shader, newline - shader + 1);
shader = newline + 1;
/* Output extra newlines to make line numbers match */
for (; extra_newlines > 0; extra_newlines--)
- clean = talloc_strdup_append(clean, "\n");
+ ralloc_strcat(&clean, "\n");
in_continued_line = 0;
}
search_start = newline + 1;
}
- clean = talloc_strdup_append(clean, shader);
+ ralloc_strcat(&clean, shader);
return clean;
}
int
-preprocess(void *talloc_ctx, const char **shader, char **info_log,
+preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, int api)
{
int errors;
@@ -156,9 +154,9 @@ preprocess(void *talloc_ctx, const char **shader, char **info_log,
if (parser->skip_stack)
glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
- *info_log = talloc_strdup_append(*info_log, parser->info_log);
+ ralloc_strcat(info_log, parser->info_log);
- talloc_steal(talloc_ctx, parser->output);
+ ralloc_steal(ralloc_ctx, parser->output);
*shader = parser->output;
errors = parser->error;
diff --git a/src/glsl/glcpp/tests/063-comments.c.expected b/src/glsl/glcpp/tests/063-comments.c.expected
index ed4feedd457..73ca7071faa 100644
--- a/src/glsl/glcpp/tests/063-comments.c.expected
+++ b/src/glsl/glcpp/tests/063-comments.c.expected
@@ -5,8 +5,15 @@ f = g /h;
l();
m = n
+ p;
+
+
+
+
+
+
more code here
+
are not treated like comments.
diff --git a/src/glsl/glcpp/tests/092-redefine-macro-error-2.c b/src/glsl/glcpp/tests/092-redefine-macro-error-2.c
new file mode 100644
index 00000000000..3c161a5c501
--- /dev/null
+++ b/src/glsl/glcpp/tests/092-redefine-macro-error-2.c
@@ -0,0 +1,5 @@
+#define A
+#define A 1
+
+#define B 1
+#define B
diff --git a/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected b/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected
new file mode 100644
index 00000000000..0026f91f32b
--- /dev/null
+++ b/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected
@@ -0,0 +1,10 @@
+0:2(9): preprocessor error: Redefinition of macro A
+
+0:5(9): preprocessor error: Redefinition of macro B
+
+
+
+
+
+
+
diff --git a/src/glsl/glcpp/tests/093-divide-by-zero.c b/src/glsl/glcpp/tests/093-divide-by-zero.c
new file mode 100644
index 00000000000..bf65d4f5271
--- /dev/null
+++ b/src/glsl/glcpp/tests/093-divide-by-zero.c
@@ -0,0 +1,2 @@
+#if (1 / 0)
+#endif
diff --git a/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c
new file mode 100644
index 00000000000..a9c6f36def8
--- /dev/null
+++ b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c
@@ -0,0 +1,2 @@
+#if 1 || (1 / 0)
+#endif
diff --git a/src/glsl/glcpp/tests/095-recursive-define.c b/src/glsl/glcpp/tests/095-recursive-define.c
new file mode 100644
index 00000000000..801d90ce2e3
--- /dev/null
+++ b/src/glsl/glcpp/tests/095-recursive-define.c
@@ -0,0 +1,3 @@
+#define A(a, b) B(a, b)
+#define C A(0, C)
+C