blob: 455bf0c7a4a63e3648622b412324558bc9893577 [file] [log] [blame]
Ian Romanicka87ac252010-02-22 13:19:34 -08001/*
2 * Copyright © 2008, 2009 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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.
22 */
23#include <stdio.h>
24#include <stdarg.h>
25#include <stdlib.h>
26#include <string.h>
27#include <assert.h>
28
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <fcntl.h>
32#include <unistd.h>
33
34#include "ast.h"
35#include "glsl_parser_extras.h"
Ian Romanickd59673c2010-02-25 17:17:23 -080036#include "glsl_parser.h"
Eric Anholt62735692010-04-05 15:24:28 -070037#include "ir_constant_folding.h"
Eric Anholtcad97662010-04-07 11:46:26 -070038#include "ir_function_inlining.h"
Eric Anholt5ba94202010-04-14 17:03:03 -070039#include "ir_if_simplification.h"
Ian Romanick1c4156f2010-03-10 09:27:03 -080040#include "ir_print_visitor.h"
Ian Romanicka87ac252010-02-22 13:19:34 -080041
Ian Romanick5bfe30a2010-04-07 16:44:30 -070042const char *
43_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
44{
45 switch (target) {
46 case vertex_shader: return "vertex";
47 case fragment_shader: return "fragment";
48 case geometry_shader: return "geometry";
49 }
50
51 assert(!"Should not get here.");
52}
53
54
Ian Romanicka87ac252010-02-22 13:19:34 -080055void
Ian Romanick1f585182010-03-11 14:08:33 -080056_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
57 const char *fmt, ...)
Ian Romanicka87ac252010-02-22 13:19:34 -080058{
59 char buf[1024];
60 int len;
61 va_list ap;
62
Ian Romanick71d0bbf2010-03-23 13:21:19 -070063 state->error = true;
Ian Romanick1f585182010-03-11 14:08:33 -080064
Ian Romanicka87ac252010-02-22 13:19:34 -080065 len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ",
66 locp->source, locp->first_line, locp->first_column);
67
68 va_start(ap, fmt);
69 vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
70 va_end(ap);
71
72 printf("%s\n", buf);
73}
74
75
Ian Romanick56b8b212010-04-07 14:47:46 -070076void
77_mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state,
78 const char *fmt, ...)
79{
80 char buf[1024];
81 int len;
82 va_list ap;
83
84 len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ",
85 locp->source, locp->first_line, locp->first_column);
86
87 va_start(ap, fmt);
88 vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
89 va_end(ap);
90
91 printf("%s\n", buf);
92}
93
94
Ian Romanicke7017612010-04-07 16:46:25 -070095bool
96_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
97 const char *behavior, YYLTYPE *behavior_locp,
98 _mesa_glsl_parse_state *state)
99{
100 enum {
101 extension_disable,
102 extension_enable,
103 extension_require,
104 extension_warn
105 } ext_mode;
Ian Romanicke7017612010-04-07 16:46:25 -0700106
107 if (strcmp(behavior, "warn") == 0) {
108 ext_mode = extension_warn;
109 } else if (strcmp(behavior, "require") == 0) {
110 ext_mode = extension_require;
111 } else if (strcmp(behavior, "enable") == 0) {
112 ext_mode = extension_enable;
113 } else if (strcmp(behavior, "disable") == 0) {
114 ext_mode = extension_disable;
115 } else {
116 _mesa_glsl_error(behavior_locp, state,
117 "Unknown extension behavior `%s'",
118 behavior);
119 return false;
120 }
121
Ian Romanick887a8b02010-04-07 16:57:56 -0700122 bool unsupported = false;
123
Ian Romanicke7017612010-04-07 16:46:25 -0700124 if (strcmp(name, "all") == 0) {
125 if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
126 _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
127 (ext_mode == extension_enable)
128 ? "enable" : "require");
129 return false;
130 }
Ian Romanickc77b2572010-04-07 16:59:46 -0700131 } if (strcmp(name, "GL_ARB_draw_buffers") == 0) {
132 /* This extension is only supported in fragment shaders.
133 */
134 if (state->target != fragment_shader) {
135 unsupported = true;
136 } else {
137 state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
138 state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
139 }
Ian Romanick0c824652010-04-07 17:13:44 -0700140 } if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
141 state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
142 state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
Ian Romanicke7017612010-04-07 16:46:25 -0700143 } else {
Ian Romanick887a8b02010-04-07 16:57:56 -0700144 unsupported = true;
145 }
146
147 if (unsupported) {
148 static const char *const fmt = "extension `%s' unsupported in %s shader";
149
Ian Romanicke7017612010-04-07 16:46:25 -0700150 if (ext_mode == extension_require) {
Ian Romanick887a8b02010-04-07 16:57:56 -0700151 _mesa_glsl_error(name_locp, state, fmt,
152 name, _mesa_glsl_shader_target_name(state->target));
Ian Romanicke7017612010-04-07 16:46:25 -0700153 return false;
Ian Romanick1799a0c2010-04-07 14:50:36 -0700154 } else {
Ian Romanick887a8b02010-04-07 16:57:56 -0700155 _mesa_glsl_warning(name_locp, state, fmt,
156 name, _mesa_glsl_shader_target_name(state->target));
Ian Romanicke7017612010-04-07 16:46:25 -0700157 }
158 }
159
160 return true;
161}
162
163
Ian Romanicka87ac252010-02-22 13:19:34 -0800164ast_node::~ast_node()
165{
166 /* empty */
167}
168
169
170void
171_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q)
172{
173 if (q->constant)
174 printf("const ");
175
176 if (q->invariant)
177 printf("invariant ");
178
179 if (q->attribute)
180 printf("attribute ");
181
182 if (q->varying)
183 printf("varying ");
184
185 if (q->in && q->out)
186 printf("inout ");
187 else {
188 if (q->in)
189 printf("in ");
190
191 if (q->out)
192 printf("out ");
193 }
194
195 if (q->centroid)
196 printf("centroid ");
197 if (q->uniform)
198 printf("uniform ");
199 if (q->smooth)
200 printf("smooth ");
201 if (q->flat)
202 printf("flat ");
203 if (q->noperspective)
204 printf("noperspective ");
205}
206
207
208void
209ast_node::print(void) const
210{
Ian Romanick03d3f3a2010-04-02 11:03:47 -0700211 printf("unhandled node ");
Ian Romanicka87ac252010-02-22 13:19:34 -0800212}
213
214
215ast_node::ast_node(void)
216{
Ian Romanick53d27742010-02-22 13:22:10 -0800217 make_empty_list(this);
Ian Romanicka87ac252010-02-22 13:19:34 -0800218}
219
Ian Romanicka87ac252010-02-22 13:19:34 -0800220
221static void
222ast_opt_array_size_print(bool is_array, const ast_expression *array_size)
223{
224 if (is_array) {
225 printf("[ ");
226
227 if (array_size)
228 array_size->print();
229
230 printf("] ");
231 }
232}
233
234
Ian Romanicka87ac252010-02-22 13:19:34 -0800235void
236ast_compound_statement::print(void) const
237{
238 const struct simple_node *ptr;
239
240 printf("{\n");
241
242 foreach(ptr, & statements) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800243 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800244 }
245
246 printf("}\n");
247}
248
249
250ast_compound_statement::ast_compound_statement(int new_scope,
251 ast_node *statements)
252{
253 this->new_scope = new_scope;
254 make_empty_list(& this->statements);
255
256 if (statements != NULL) {
257 /* This seems odd, but it works. The simple_list is,
258 * basically, a circular list. insert_at_tail adds
259 * the specified node to the list before the current
260 * head.
261 */
262 insert_at_tail((struct simple_node *) statements,
263 & this->statements);
264 }
265}
266
267
268void
269ast_expression::print(void) const
270{
Ian Romanicka87ac252010-02-22 13:19:34 -0800271 switch (oper) {
272 case ast_assign:
Ian Romanicka87ac252010-02-22 13:19:34 -0800273 case ast_mul_assign:
274 case ast_div_assign:
275 case ast_mod_assign:
276 case ast_add_assign:
277 case ast_sub_assign:
278 case ast_ls_assign:
279 case ast_rs_assign:
280 case ast_and_assign:
281 case ast_xor_assign:
282 case ast_or_assign:
283 subexpressions[0]->print();
Ian Romanick88349b22010-02-22 19:10:25 -0800284 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800285 subexpressions[1]->print();
286 break;
287
288 case ast_field_selection:
289 subexpressions[0]->print();
290 printf(". %s ", primary_expression.identifier);
291 break;
292
293 case ast_plus:
294 case ast_neg:
295 case ast_bit_not:
296 case ast_logic_not:
297 case ast_pre_inc:
298 case ast_pre_dec:
Ian Romanick88349b22010-02-22 19:10:25 -0800299 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800300 subexpressions[0]->print();
301 break;
302
303 case ast_post_inc:
304 case ast_post_dec:
305 subexpressions[0]->print();
Ian Romanick88349b22010-02-22 19:10:25 -0800306 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800307 break;
308
309 case ast_conditional:
310 subexpressions[0]->print();
311 printf("? ");
312 subexpressions[1]->print();
313 printf(": ");
314 subexpressions[1]->print();
315 break;
316
317 case ast_array_index:
318 subexpressions[0]->print();
319 printf("[ ");
320 subexpressions[1]->print();
321 printf("] ");
322 break;
323
324 case ast_function_call: {
325 ast_expression *parameters = subexpressions[1];
326
327 subexpressions[0]->print();
328 printf("( ");
329
330 if (parameters != NULL) {
331 struct simple_node *ptr;
332
333 parameters->print();
334 foreach (ptr, (struct simple_node *) parameters) {
335 printf(", ");
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800336 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800337 }
338 }
339
340 printf(") ");
341 break;
342 }
343
344 case ast_identifier:
345 printf("%s ", primary_expression.identifier);
346 break;
347
348 case ast_int_constant:
349 printf("%d ", primary_expression.int_constant);
350 break;
351
352 case ast_uint_constant:
353 printf("%u ", primary_expression.uint_constant);
354 break;
355
356 case ast_float_constant:
357 printf("%f ", primary_expression.float_constant);
358 break;
359
360 case ast_bool_constant:
361 printf("%s ",
362 primary_expression.bool_constant
363 ? "true" : "false");
364 break;
365
366 case ast_sequence: {
367 struct simple_node *ptr;
368 struct simple_node *const head = first_elem(& expressions);
369
370 printf("( ");
371 foreach (ptr, & expressions) {
372 if (ptr != head)
373 printf(", ");
374
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800375 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800376 }
377 printf(") ");
378 break;
379 }
Ian Romanick88349b22010-02-22 19:10:25 -0800380
381 default:
382 assert(0);
383 break;
Ian Romanicka87ac252010-02-22 13:19:34 -0800384 }
385}
386
387ast_expression::ast_expression(int oper,
388 ast_expression *ex0,
389 ast_expression *ex1,
390 ast_expression *ex2)
391{
392 this->oper = ast_operators(oper);
393 this->subexpressions[0] = ex0;
394 this->subexpressions[1] = ex1;
395 this->subexpressions[2] = ex2;
396 make_empty_list(& expressions);
397}
398
399
400void
401ast_expression_statement::print(void) const
402{
403 if (expression)
404 expression->print();
405
406 printf("; ");
407}
408
409
410ast_expression_statement::ast_expression_statement(ast_expression *ex) :
411 expression(ex)
412{
413 /* empty */
414}
415
416
417void
418ast_function::print(void) const
419{
420 struct simple_node *ptr;
421
422 return_type->print();
423 printf(" %s (", identifier);
424
425 foreach(ptr, & parameters) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800426 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800427 }
428
429 printf(")");
430}
431
432
433ast_function::ast_function(void)
Ian Romanick92318a92010-03-31 18:23:21 -0700434 : is_definition(false), signature(NULL)
Ian Romanicka87ac252010-02-22 13:19:34 -0800435{
436 make_empty_list(& parameters);
437}
438
439
440void
441ast_fully_specified_type::print(void) const
442{
443 _mesa_ast_type_qualifier_print(& qualifier);
444 specifier->print();
445}
446
447
448void
449ast_parameter_declarator::print(void) const
450{
451 type->print();
452 if (identifier)
453 printf("%s ", identifier);
454 ast_opt_array_size_print(is_array, array_size);
455}
456
457
458void
459ast_function_definition::print(void) const
460{
461 prototype->print();
462 body->print();
463}
464
465
466void
467ast_declaration::print(void) const
468{
469 printf("%s ", identifier);
470 ast_opt_array_size_print(is_array, array_size);
471
472 if (initializer) {
473 printf("= ");
474 initializer->print();
475 }
476}
477
478
479ast_declaration::ast_declaration(char *identifier, int is_array,
480 ast_expression *array_size,
481 ast_expression *initializer)
482{
483 this->identifier = identifier;
484 this->is_array = is_array;
485 this->array_size = array_size;
486 this->initializer = initializer;
487}
488
489
490void
491ast_declarator_list::print(void) const
492{
493 struct simple_node *head;
494 struct simple_node *ptr;
495
496 assert(type || invariant);
497
498 if (type)
499 type->print();
500 else
501 printf("invariant ");
502
503 head = first_elem(& declarations);
504 foreach (ptr, & declarations) {
505 if (ptr != head)
506 printf(", ");
507
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800508 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800509 }
510
511 printf("; ");
512}
513
514
515ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type)
516{
517 this->type = type;
518 make_empty_list(& this->declarations);
519}
520
521void
522ast_jump_statement::print(void) const
523{
524 switch (mode) {
525 case ast_continue:
526 printf("continue; ");
527 break;
528 case ast_break:
529 printf("break; ");
530 break;
531 case ast_return:
532 printf("return ");
533 if (opt_return_value)
534 opt_return_value->print();
535
536 printf("; ");
537 break;
538 case ast_discard:
539 printf("discard; ");
540 break;
541 }
542}
543
544
545ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value)
546{
547 this->mode = ast_jump_modes(mode);
548
549 if (mode == ast_return)
550 opt_return_value = return_value;
551}
552
553
554void
555ast_selection_statement::print(void) const
556{
557 printf("if ( ");
558 condition->print();
559 printf(") ");
560
561 then_statement->print();
562
563 if (else_statement) {
564 printf("else ");
565 else_statement->print();
566 }
567
568}
569
570
571ast_selection_statement::ast_selection_statement(ast_expression *condition,
572 ast_node *then_statement,
573 ast_node *else_statement)
574{
575 this->condition = condition;
576 this->then_statement = then_statement;
577 this->else_statement = else_statement;
578}
579
580
581void
582ast_iteration_statement::print(void) const
583{
584 switch (mode) {
585 case ast_for:
586 printf("for( ");
587 if (init_statement)
588 init_statement->print();
589 printf("; ");
590
591 if (condition)
592 condition->print();
593 printf("; ");
594
595 if (rest_expression)
596 rest_expression->print();
597 printf(") ");
598
599 body->print();
600 break;
601
602 case ast_while:
603 printf("while ( ");
604 if (condition)
605 condition->print();
606 printf(") ");
607 body->print();
608 break;
609
610 case ast_do_while:
611 printf("do ");
612 body->print();
613 printf("while ( ");
614 if (condition)
615 condition->print();
616 printf("); ");
617 break;
618 }
619}
620
621
622ast_iteration_statement::ast_iteration_statement(int mode,
623 ast_node *init,
624 ast_node *condition,
625 ast_expression *rest_expression,
626 ast_node *body)
627{
628 this->mode = ast_iteration_modes(mode);
629 this->init_statement = init;
630 this->condition = condition;
631 this->rest_expression = rest_expression;
632 this->body = body;
633}
634
635
636void
637ast_struct_specifier::print(void) const
638{
639 struct simple_node *ptr;
640
641 printf("struct %s { ", name);
642 foreach (ptr, & declarations) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800643 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800644 }
645 printf("} ");
646}
647
648
649ast_struct_specifier::ast_struct_specifier(char *identifier,
650 ast_node *declarator_list)
651{
652 name = identifier;
653
654 /* This seems odd, but it works. The simple_list is,
655 * basically, a circular list. insert_at_tail adds
656 * the specified node to the list before the current
657 * head.
658 */
659 insert_at_tail((struct simple_node *) declarator_list,
660 & declarations);
661}
662
663
664static char *
665load_text_file(const char *file_name, size_t *size)
666{
667 char *text = NULL;
668 struct stat st;
669 ssize_t total_read = 0;
670 int fd = open(file_name, O_RDONLY);
671
672 *size = 0;
673 if (fd < 0) {
674 return NULL;
675 }
676
677 if (fstat(fd, & st) == 0) {
678 text = (char *) malloc(st.st_size + 1);
679 if (text != NULL) {
680 do {
681 ssize_t bytes = read(fd, text + total_read,
682 st.st_size - total_read);
683 if (bytes < 0) {
684 free(text);
685 text = NULL;
686 break;
687 }
688
689 if (bytes == 0) {
690 break;
691 }
692
693 total_read += bytes;
694 } while (total_read < st.st_size);
695
696 text[total_read] = '\0';
697 *size = total_read;
698 }
699 }
700
701 close(fd);
702
703 return text;
704}
705
706
707int
708main(int argc, char **argv)
709{
710 struct _mesa_glsl_parse_state state;
711 char *shader;
712 size_t shader_len;
713 struct simple_node *ptr;
Ian Romanick0044e7e2010-03-08 23:44:00 -0800714 exec_list instructions;
Ian Romanicka87ac252010-02-22 13:19:34 -0800715
Ian Romanick8e6cd3b2010-03-10 09:31:30 -0800716 if (argc < 3) {
717 printf("Usage: %s [v|g|f] <shader_file>\n", argv[0]);
718 return EXIT_FAILURE;
719 }
720
721 switch (argv[1][0]) {
722 case 'v':
723 state.target = vertex_shader;
724 break;
725 case 'g':
726 state.target = geometry_shader;
727 break;
728 case 'f':
729 state.target = fragment_shader;
730 break;
731 default:
732 printf("Usage: %s [v|g|f] <shader_file>\n", argv[0]);
733 return EXIT_FAILURE;
734 }
735
736 shader = load_text_file(argv[2], & shader_len);
Ian Romanicka87ac252010-02-22 13:19:34 -0800737
738 state.scanner = NULL;
739 make_empty_list(& state.translation_unit);
Ian Romanick8bde4ce2010-03-19 11:57:24 -0700740 state.symbols = new glsl_symbol_table;
Ian Romanick1f585182010-03-11 14:08:33 -0800741 state.error = false;
Ian Romanick5185a5f2010-03-29 15:20:42 -0700742 state.temp_index = 0;
Ian Romanicke9d0f262010-04-05 17:01:53 -0700743 state.loop_or_switch_nesting = NULL;
Ian Romanick0c824652010-04-07 17:13:44 -0700744 state.ARB_texture_rectangle_enable = true;
Ian Romanicka87ac252010-02-22 13:19:34 -0800745
746 _mesa_glsl_lexer_ctor(& state, shader, shader_len);
747 _mesa_glsl_parse(& state);
748 _mesa_glsl_lexer_dtor(& state);
749
750 foreach (ptr, & state.translation_unit) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800751 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800752 }
753
Ian Romanickd949a9a2010-03-10 09:55:22 -0800754 _mesa_ast_to_hir(&instructions, &state);
Ian Romanicka87ac252010-02-22 13:19:34 -0800755
Eric Anholt62735692010-04-05 15:24:28 -0700756 /* Optimization passes */
757 if (!state.error) {
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700758 bool progress;
759 do {
760 progress = false;
Eric Anholtcad97662010-04-07 11:46:26 -0700761
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700762 progress = do_function_inlining(&instructions) || progress;
Eric Anholt5ba94202010-04-14 17:03:03 -0700763 progress = do_if_simplification(&instructions) || progress;
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700764
765 /* Constant folding */
766 ir_constant_folding_visitor constant_folding;
767 visit_exec_list(&instructions, &constant_folding);
768 } while (progress);
Eric Anholt62735692010-04-05 15:24:28 -0700769 }
770
771 /* Print out the resulting IR */
Ian Romanick1c4156f2010-03-10 09:27:03 -0800772 printf("\n\n");
Ian Romanick1c4156f2010-03-10 09:27:03 -0800773
Ian Romanick1f585182010-03-11 14:08:33 -0800774 if (!state.error) {
775 foreach_iter(exec_list_iterator, iter, instructions) {
776 ir_print_visitor v;
777
778 ((ir_instruction *)iter.get())->accept(& v);
Ian Romanickd1464272010-03-25 18:29:25 -0700779 printf("\n");
Ian Romanick1f585182010-03-11 14:08:33 -0800780 }
Ian Romanick1c4156f2010-03-10 09:27:03 -0800781 }
782
Ian Romanick8bde4ce2010-03-19 11:57:24 -0700783 delete state.symbols;
Ian Romanicka87ac252010-02-22 13:19:34 -0800784
Eric Anholt7c15bb22010-03-25 14:37:25 -0700785 return state.error != 0;
Ian Romanicka87ac252010-02-22 13:19:34 -0800786}