2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
30 #include "main/mtypes.h"
32 #include "../ralloc.h"
34 #include "program/hash_table.h"
36 #define yyscan_t void*
38 /* Some data types used for parser values. */
40 typedef struct string_node
{
42 struct string_node
*next
;
45 typedef struct string_list
{
50 typedef struct token token_t
;
51 typedef struct token_list token_list_t
;
57 string_list_t
*string_list
;
59 token_list_t
*token_list
;
62 # define YYSTYPE_IS_TRIVIAL 1
63 # define YYSTYPE_IS_DECLARED 1
65 typedef struct YYLTYPE
{
72 # define YYLTYPE_IS_DECLARED 1
73 # define YYLTYPE_IS_TRIVIAL 1
75 # define YYLLOC_DEFAULT(Current, Rhs, N) \
79 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
80 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
81 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
82 (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
86 (Current).first_line = (Current).last_line = \
87 YYRHSLOC(Rhs, 0).last_line; \
88 (Current).first_column = (Current).last_column = \
89 YYRHSLOC(Rhs, 0).last_column; \
91 (Current).source = 0; \
100 typedef struct token_node
{
102 struct token_node
*next
;
108 token_node_t
*non_space_tail
;
111 typedef struct argument_node
{
112 token_list_t
*argument
;
113 struct argument_node
*next
;
116 typedef struct argument_list
{
117 argument_node_t
*head
;
118 argument_node_t
*tail
;
121 typedef struct glcpp_parser glcpp_parser_t
;
124 TOKEN_CLASS_IDENTIFIER
,
125 TOKEN_CLASS_IDENTIFIER_FINALIZED
,
126 TOKEN_CLASS_FUNC_MACRO
,
127 TOKEN_CLASS_OBJ_MACRO
131 glcpp_parser_classify_token (glcpp_parser_t
*parser
,
132 const char *identifier
,
133 int *parameter_index
);
137 string_list_t
*parameters
;
138 const char *identifier
;
139 token_list_t
*replacements
;
142 typedef struct expansion_node
{
144 token_node_t
*replacements
;
145 struct expansion_node
*next
;
148 typedef enum skip_type
{
154 typedef struct skip_node
{
156 YYLTYPE loc
; /* location of the initial #if/#elif/... */
157 struct skip_node
*next
;
160 typedef struct active_list
{
161 const char *identifier
;
162 token_node_t
*marker
;
163 struct active_list
*next
;
166 struct glcpp_parser
{
168 struct hash_table
*defines
;
169 active_list_t
*active
;
172 int newline_as_space
;
175 skip_node_t
*skip_stack
;
176 token_list_t
*lex_from_list
;
177 token_node_t
*lex_from_node
;
180 size_t output_length
;
181 size_t info_log_length
;
183 bool has_new_line_number
;
185 bool has_new_source_number
;
186 int new_source_number
;
190 struct gl_extensions
;
193 glcpp_parser_create (const struct gl_extensions
*extensions
, int api
);
196 glcpp_parser_parse (glcpp_parser_t
*parser
);
199 glcpp_parser_destroy (glcpp_parser_t
*parser
);
202 glcpp_preprocess(void *ralloc_ctx
, const char **shader
, char **info_log
,
203 const struct gl_extensions
*extensions
, struct gl_context
*g_ctx
);
205 /* Functions for writing to the info log */
208 glcpp_error (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *fmt
, ...);
211 glcpp_warning (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *fmt
, ...);
213 /* Generated by glcpp-lex.l to glcpp-lex.c */
216 glcpp_lex_init_extra (glcpp_parser_t
*parser
, yyscan_t
* scanner
);
219 glcpp_lex_set_source_string(glcpp_parser_t
*parser
, const char *shader
);
222 glcpp_lex (YYSTYPE
*lvalp
, YYLTYPE
*llocp
, yyscan_t scanner
);
225 glcpp_lex_destroy (yyscan_t scanner
);
227 /* Generated by glcpp-parse.y to glcpp-parse.c */
230 yyparse (glcpp_parser_t
*parser
);