1 /* -*- c -*- emacs mode c */
2 /* TREELANG Compiler parser.
4 ---------------------------------------------------------------------
6 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
7 Free Software Foundation, Inc.
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2, or (at your option) any
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
24 In other words, you are welcome to use, share and improve this program.
25 You are forbidden to forbid anyone else to use, share and improve
26 what you give them. Help stamp out software-hoarding!
28 ---------------------------------------------------------------------
30 Written by Tim Josling 1999-2001, based in part on other parts of
35 There are no conflicts in this grammar. Please keep it that way. */
40 #include "coretypes.h"
49 #define YYPRINT(file, type, value) print_token (file, type, value)
50 #define YYERROR_VERBOSE YES
52 /* My yylex routine used to intercept calls to flex generated code, to
55 static inline
int my_yylex
(void);
57 /* Call lex, but ensure time is charged to TV_LEX. */
62 timevar_push
(TV_LEX
);
67 #define yylex my_yylex
69 extern
int option_parser_trace
;
71 /* Local prototypes. */
72 static void yyerror (const char *error_message
);
74 void print_token
(FILE * file
, unsigned int type ATTRIBUTE_UNUSED
,
76 static struct prod_token_parm_item
*reverse_prod_list
77 (struct prod_token_parm_item
*old_first
);
78 static void ensure_not_void
(unsigned int type
,
79 struct prod_token_parm_item
* name
);
80 static int check_type_match
(int type_num
, struct prod_token_parm_item
*exp
);
81 static int get_common_type
(struct prod_token_parm_item
*type1
,
82 struct prod_token_parm_item
*type2
);
83 static struct prod_token_parm_item
*make_integer_constant
84 (struct prod_token_parm_item
* value
);
85 static struct prod_token_parm_item
*make_plus_expression
86 (struct prod_token_parm_item
* tok
, struct prod_token_parm_item
* op1
,
87 struct prod_token_parm_item
* op2
, int type_code
, int prod_code
);
88 static void set_storage
(struct prod_token_parm_item
*prod
);
90 /* File global variables. */
91 static struct prod_token_parm_item
*current_function
= NULL
;
94 /* Not %raw - seems to have bugs. */
100 %token RIGHT_SQUARE_BRACKET
101 %token LEFT_SQUARE_BRACKET
102 %token RIGHT_PARENTHESIS
103 %token LEFT_PARENTHESIS
127 %token EXTERNAL_DEFINITION
128 %token EXTERNAL_REFERENCE
130 /* Tokens not passed to parser. */
134 /* Pseudo tokens - productions. */
135 %token PROD_VARIABLE_NAME
136 %token PROD_TYPE_NAME
137 %token PROD_FUNCTION_NAME
138 %token PROD_INTEGER_CONSTANT
139 %token PROD_PLUS_EXPRESSION
140 %token PROD_MINUS_EXPRESSION
141 %token PROD_ASSIGN_EXPRESSION
142 %token PROD_VARIABLE_REFERENCE_EXPRESSION
143 %token PROD_PARAMETER
144 %token PROD_FUNCTION_INVOCATION
162 | declarations declaration
{
171 |function_prototype
{
180 storage typename NAME init_opt SEMICOLON
{
181 struct prod_token_parm_item
* tok
;
182 struct prod_token_parm_item
*prod
;
184 prod
= make_production
(PROD_VARIABLE_NAME
, tok
);
185 SYMBOL_TABLE_NAME
(prod
) = tok
;
186 EXPRESSION_TYPE
(prod
) = $2;
187 VAR_INIT
(prod
) = $4;
188 NUMERIC_TYPE
(prod
) =
189 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
190 ensure_not_void
(NUMERIC_TYPE
(prod
), tok
);
191 if
(insert_tree_name
(prod
))
195 STORAGE_CLASS_TOKEN
(prod
) = $1;
200 gcc_assert
(((struct prod_token_parm_item
*)VAR_INIT
(prod
))->tp.pro.code
);
201 if
(STORAGE_CLASS
(prod
) == EXTERNAL_REFERENCE_STORAGE
)
203 error("%HExternal reference variable %q.*s has an initial value.",
204 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
206 VAR_INIT
(prod
) = NULL
;
211 prod
->tp.pro.code
= tree_code_create_variable
212 (STORAGE_CLASS
(prod
),
213 ((struct prod_token_parm_item
*)SYMBOL_TABLE_NAME
(prod
))->tp.tok.chars
,
214 ((struct prod_token_parm_item
*)SYMBOL_TABLE_NAME
(prod
))->tp.tok.length
,
217 ((struct prod_token_parm_item
*)VAR_INIT
(prod
))->tp.pro.code
: NULL
,
218 tok
->tp.tok.location
);
219 gcc_assert
(prod
->tp.pro.code
);
232 struct prod_token_parm_item
* tok
;
233 struct prod_token_parm_item
*prod
;
234 struct prod_token_parm_item
*prod2
;
236 prod
= make_production
(PROD_VARIABLE_NAME
, tok
);
237 SYMBOL_TABLE_NAME
(prod
) = $2;
238 EXPRESSION_TYPE
(prod
) = $1;
239 NUMERIC_TYPE
(prod
) =
240 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
241 ensure_not_void
(NUMERIC_TYPE
(prod
), tok
);
242 if
(insert_tree_name
(prod
))
246 prod2
= make_production
(PROD_PARAMETER
, tok
);
247 VARIABLE
(prod2
) = prod
;
253 storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLON
{
254 struct prod_token_parm_item
* tok
;
255 struct prod_token_parm_item
*prod
;
256 struct prod_token_parm_item
*type
;
257 struct prod_token_parm_item
* first_parms
;
258 struct prod_token_parm_item
* last_parms
;
259 struct prod_token_parm_item
* this_parms
;
260 struct prod_token_parm_item
*this_parm
;
261 struct prod_token_parm_item
*this_parm_var
;
263 prod
= make_production
(PROD_FUNCTION_NAME
, $3);
264 SYMBOL_TABLE_NAME
(prod
) = $3;
265 EXPRESSION_TYPE
(prod
) = $2;
266 NUMERIC_TYPE
(prod
) =
267 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
268 PARAMETERS
(prod
) = reverse_prod_list
($5);
269 insert_tree_name
(prod
);
270 STORAGE_CLASS_TOKEN
(prod
) = $1;
272 switch
(STORAGE_CLASS
(prod
))
275 case EXTERNAL_DEFINITION_STORAGE
:
276 case EXTERNAL_REFERENCE_STORAGE
:
279 case AUTOMATIC_STORAGE
:
280 error ("%HFunction %q.*s cannot be automatic.",
281 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
288 type
= EXPRESSION_TYPE
(prod
);
289 /* Create a parameter list in a non-front end specific format. */
290 for
(first_parms
= NULL
, last_parms
= NULL
, this_parm
= PARAMETERS
(prod
);
292 this_parm
= this_parm
->tp.pro.next
)
294 gcc_assert
(this_parm
->category
== production_category
);
295 this_parm_var
= VARIABLE
(this_parm
);
297 gcc_assert
(this_parm_var
);
298 gcc_assert
(this_parm_var
->category
== production_category
);
299 gcc_assert
(this_parm_var
->tp.pro.main_token
);
301 this_parms
= my_malloc
(sizeof
(struct prod_token_parm_item
));
303 this_parms
->tp.par.variable_name
=
304 this_parm_var
->tp.pro.main_token
->tp.tok.chars
;
305 this_parms
->category
= parameter_category
;
306 this_parms
->type
= NUMERIC_TYPE
307 (( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(this_parm_var
)));
310 last_parms
->tp.par.next
= this_parms
;
311 last_parms
= this_parms
;
315 first_parms
= this_parms
;
316 last_parms
= this_parms
;
318 this_parms
->tp.par.where_to_put_var_tree
=
319 & (( (struct prod_token_parm_item
*)VARIABLE
(this_parm
))->tp.pro.code
);
321 FIRST_PARMS
(prod
) = first_parms
;
324 tree_code_create_function_prototype
(tok
->tp.tok.chars
,
325 STORAGE_CLASS
(prod
),
327 first_parms
, tok
->tp.tok.location
);
329 #ifdef ENABLE_CHECKING
330 /* Check all the parameters have code. */
331 for
(this_parm
= PARAMETERS
(prod
);
333 this_parm
= this_parm
->tp.pro.next
)
335 gcc_assert
((struct prod_token_parm_item
*)VARIABLE
(this_parm
));
336 gcc_assert
(((struct prod_token_parm_item
*)VARIABLE
(this_parm
))->tp.pro.code
);
344 struct prod_token_parm_item
*proto
;
345 struct prod_token_parm_item search_prod
;
346 struct prod_token_parm_item
* tok
;
348 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
349 search_prod.category
= token_category
;
350 current_function
= proto
= lookup_tree_name
(&search_prod
);
353 error ("%HNo prototype found for %q.*s", &tok
->tp.tok.location
,
354 tok
->tp.tok.length
, tok
->tp.tok.chars
);
358 gcc_assert
(proto
->tp.pro.code
);
360 tree_code_create_function_initial
(proto
->tp.pro.code
, tok
->tp.tok.location
);
363 variable_defs_opt statements_opt RIGHT_BRACE
{
364 struct prod_token_parm_item
* tok
;
366 tree_code_create_function_wrapup
(tok
->tp.tok.location
);
367 current_function
= NULL
;
393 |variable_defs variable_def
{
400 struct prod_token_parm_item
* tok
;
401 struct prod_token_parm_item
*prod
;
403 prod
= make_production
(PROD_TYPE_NAME
, tok
);
404 NUMERIC_TYPE
(prod
) = SIGNED_INT
;
405 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
409 struct prod_token_parm_item
* tok
;
410 struct prod_token_parm_item
*prod
;
412 prod
= make_production
(PROD_TYPE_NAME
, tok
);
413 NUMERIC_TYPE
(prod
) = UNSIGNED_INT
;
414 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
418 struct prod_token_parm_item
* tok
;
419 struct prod_token_parm_item
*prod
;
421 prod
= make_production
(PROD_TYPE_NAME
, tok
);
422 NUMERIC_TYPE
(prod
) = SIGNED_CHAR
;
423 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
427 struct prod_token_parm_item
* tok
;
428 struct prod_token_parm_item
*prod
;
430 prod
= make_production
(PROD_TYPE_NAME
, tok
);
431 NUMERIC_TYPE
(prod
) = UNSIGNED_CHAR
;
432 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
436 struct prod_token_parm_item
* tok
;
437 struct prod_token_parm_item
*prod
;
439 prod
= make_production
(PROD_TYPE_NAME
, tok
);
440 NUMERIC_TYPE
(prod
) = VOID_TYPE
;
441 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
447 /* Nothing to do. */ {
459 |parameters COMMA parameter
{
460 struct prod_token_parm_item
*prod1
;
462 prod1
->tp.pro.next
= $1; /* Insert in reverse order. */
471 |statements statement
{
477 expression SEMICOLON
{
478 struct prod_token_parm_item
*exp
;
480 tree_code_output_expression_statement
(exp
->tp.pro.code
,
481 exp
->tp.pro.main_token
->tp.tok.location
);
492 IF LEFT_PARENTHESIS expression RIGHT_PARENTHESIS
{
493 struct prod_token_parm_item
* tok
;
494 struct prod_token_parm_item
*exp
;
497 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
498 tree_code_if_start
(exp
->tp.pro.code
, tok
->tp.tok.location
);
500 LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE
{
501 /* Just let the statements flow. */
504 struct prod_token_parm_item
* tok
;
506 tree_code_if_else
(tok
->tp.tok.location
);
508 LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE
{
509 struct prod_token_parm_item
* tok
;
511 tree_code_if_end
(tok
->tp.tok.location
);
517 tl_RETURN expression_opt
{
518 struct prod_token_parm_item
*type_prod
;
519 struct prod_token_parm_item
*ret_tok
= $1;
520 struct prod_token_parm_item
*exp
= $2;
522 type_prod
= EXPRESSION_TYPE
(current_function
);
523 if
(NUMERIC_TYPE
(type_prod
) == VOID_TYPE
)
525 tree_code_generate_return
(type_prod
->tp.pro.code
, NULL
);
528 warning
("%HRedundant expression in return.",
529 &ret_tok
->tp.tok.location
, ret_tok
->tp.tok.length
,
530 ret_tok
->tp.tok.chars
);
531 tree_code_generate_return
(type_prod
->tp.pro.code
, NULL
);
535 error ("%HExpression missing in return.", &ret_tok
->tp.tok.location
);
538 /* Check same type. */
539 if
(check_type_match
(NUMERIC_TYPE
(type_prod
), exp
))
541 gcc_assert
(type_prod
->tp.pro.code
);
542 gcc_assert
(exp
->tp.pro.code
);
544 /* Generate the code. */
545 tree_code_generate_return
(type_prod
->tp.pro.code
,
557 struct prod_token_parm_item
*exp
;
559 gcc_assert
(exp
->tp.pro.code
);
567 $$
= make_integer_constant
($1);
572 |expression tl_PLUS expression
{
573 struct prod_token_parm_item
*tok
= $2;
574 struct prod_token_parm_item
*op1
= $1;
575 struct prod_token_parm_item
*op2
= $3;
576 int type_code
= get_common_type
(op1
, op2
);
579 $$
= make_plus_expression
(tok
, op1
, op2
, type_code
, EXP_PLUS
);
581 |expression tl_MINUS expression %prec tl_PLUS
{
582 struct prod_token_parm_item
*tok
= $2;
583 struct prod_token_parm_item
*op1
= $1;
584 struct prod_token_parm_item
*op2
= $3;
585 int type_code
= get_common_type
(op1
, op2
);
588 $$
= make_plus_expression
(tok
, op1
, op2
, type_code
, EXP_MINUS
);
590 |expression EQUALS expression
{
591 struct prod_token_parm_item
*tok
= $2;
592 struct prod_token_parm_item
*op1
= $1;
593 struct prod_token_parm_item
*op2
= $3;
594 int type_code
= NUMERIC_TYPE
(op1
);
597 $$
= make_plus_expression
598 (tok
, op1
, op2
, type_code
, EXP_EQUALS
);
600 |variable_ref ASSIGN expression
{
601 struct prod_token_parm_item
*tok
= $2;
602 struct prod_token_parm_item
*op1
= $1;
603 struct prod_token_parm_item
*op2
= $3;
604 int type_code
= NUMERIC_TYPE
(op1
);
607 $$
= make_plus_expression
608 (tok
, op1
, op2
, type_code
, EXP_ASSIGN
);
610 |function_invocation
{
616 NAME LEFT_PARENTHESIS expressions_with_commas_opt RIGHT_PARENTHESIS
{
617 struct prod_token_parm_item
*prod
;
618 struct prod_token_parm_item
* tok
;
619 struct prod_token_parm_item search_prod
;
620 struct prod_token_parm_item
*proto
;
621 struct prod_token_parm_item
*exp
;
622 struct prod_token_parm_item
*exp_proto
;
623 struct prod_token_parm_item
*var
;
630 prod
= make_production
(PROD_FUNCTION_INVOCATION
, tok
);
631 SYMBOL_TABLE_NAME
(prod
) = tok
;
632 PARAMETERS
(prod
) = reverse_prod_list
($3);
633 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
634 search_prod.category
= token_category
;
635 proto
= lookup_tree_name
(&search_prod
);
638 error ("%HFunction prototype not found for %q.*%s.",
639 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
642 EXPRESSION_TYPE
(prod
) = EXPRESSION_TYPE
(proto
);
643 NUMERIC_TYPE
(prod
) = NUMERIC_TYPE
(proto
);
644 /* Count the expressions and ensure they match the prototype. */
645 for
(exp_proto_count
= 0, exp_proto
= PARAMETERS
(proto
);
646 exp_proto
; exp_proto
= exp_proto
->tp.pro.next
)
649 for
(exp_count
= 0, exp
= PARAMETERS
(prod
); exp
; exp
= exp
->tp.pro.next
)
652 if
(exp_count
!= exp_proto_count
)
654 error ("%HExpression count mismatch %q.*s with prototype.",
655 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
658 parms
= tree_code_init_parameters
();
659 for
(exp_proto
= PARAMETERS
(proto
), exp
= PARAMETERS
(prod
);
661 exp
= exp
->tp.pro.next
, exp_proto
= exp_proto
->tp.pro.next
)
664 gcc_assert
(exp_proto
);
665 gcc_assert
(exp
->tp.pro.code
);
667 var
= VARIABLE
(exp_proto
);
670 gcc_assert
(var
->tp.pro.code
);
672 parms
= tree_code_add_parameter
(parms
, var
->tp.pro.code
,
675 type
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
676 prod
->tp.pro.code
= tree_code_get_expression
(EXP_FUNCTION_INVOCATION
, type
,
677 proto
->tp.pro.code
, parms
,
678 NULL
, tok
->tp.tok.location
);
683 expressions_with_commas_opt:
687 |expressions_with_commas
{ $$
= $1 }
690 expressions_with_commas:
692 struct prod_token_parm_item
*exp
;
694 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
697 |expressions_with_commas COMMA expression
{
698 struct prod_token_parm_item
*exp
;
700 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
701 exp
->tp.pro.next
= $1; /* Reverse order. */
708 struct prod_token_parm_item search_prod
;
709 struct prod_token_parm_item
*prod
;
710 struct prod_token_parm_item
*symbol_table_entry
;
711 struct prod_token_parm_item
* tok
;
715 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
716 search_prod.category
= token_category
;
717 symbol_table_entry
= lookup_tree_name
(&search_prod
);
718 if
(!symbol_table_entry
)
720 error ("%HVariable %q.*s not defined.",
721 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
725 prod
= make_production
(PROD_VARIABLE_REFERENCE_EXPRESSION
, tok
);
726 NUMERIC_TYPE
(prod
) = NUMERIC_TYPE
(symbol_table_entry
);
727 type
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
728 if
(!NUMERIC_TYPE
(prod
))
733 tree_code_get_expression
(EXP_REFERENCE
, type
,
734 symbol_table_entry
->tp.pro.code
, NULL
, NULL
,
735 tok
->tp.tok.location
);
745 /* Pass the initialization value up. */
750 ASSIGN init_element
{
757 $$
= make_integer_constant
($1);
763 /* Print a token VALUE to file FILE. Ignore TYPE which is the token
767 print_token
(FILE * file
, unsigned int type ATTRIBUTE_UNUSED
, YYSTYPE value
)
769 struct prod_token_parm_item
*tok
;
773 fprintf
(file
, "%d \"", LOCATION_LINE
(tok
->tp.tok.location
));
774 for
(ix
= 0; ix
< tok
->tp.tok.length
; ix
++)
775 fprintf
(file
, "%c", tok
->tp.tok.chars
[ix
]);
777 fprintf
(file
, "\"");
780 /* Output a message ERROR_MESSAGE from the parser. */
782 yyerror (const char *error_message
)
784 struct prod_token_parm_item
*tok
;
788 error ("%H%s", &tok
->tp.tok.location
, error_message
);
790 error ("%s", error_message
);
793 /* Reverse the order of a token list, linked by parse_next, old first
794 token is OLD_FIRST. */
796 static struct prod_token_parm_item
*
797 reverse_prod_list
(struct prod_token_parm_item
*old_first
)
799 struct prod_token_parm_item
*current
;
800 struct prod_token_parm_item
*next
;
801 struct prod_token_parm_item
*prev
= NULL
;
808 gcc_assert
(current
->category
== production_category
);
810 next
= current
->tp.pro.next
;
811 current
->tp.pro.next
= prev
;
818 /* Ensure TYPE is not VOID. Use NAME as the token for the error location. */
821 ensure_not_void
(unsigned int type
, struct prod_token_parm_item
* name
)
823 if
(type
== VOID_TYPE
)
824 error ("%HType must not be void in this context.",
825 &name
->tp.tok.location
);
828 /* Check TYPE1 and TYPE2 which are integral types. Return the lowest
829 common type (min is signed int). */
832 get_common_type
(struct prod_token_parm_item
*type1
,
833 struct prod_token_parm_item
*type2
)
835 if
(NUMERIC_TYPE
(type1
) == UNSIGNED_INT
)
837 if
(NUMERIC_TYPE
(type2
) == UNSIGNED_INT
)
843 /* Check type (TYPE_NUM) and expression (EXP) match. Return the 1 if
844 OK else 0. Must be exact match - same name unless it is an
848 check_type_match
(int type_num
, struct prod_token_parm_item
*exp
)
856 switch
(NUMERIC_TYPE
(exp
))
877 /* Make a production for an integer constant VALUE. */
879 static struct prod_token_parm_item
*
880 make_integer_constant
(struct prod_token_parm_item
* value
)
882 struct prod_token_parm_item
* tok
;
883 struct prod_token_parm_item
*prod
;
885 prod
= make_production
(PROD_INTEGER_CONSTANT
, tok
);
886 if
((tok
->tp.tok.chars
[0] == (unsigned char)'-')
887 ||
(tok
->tp.tok.chars
[0] == (unsigned char)'+'))
888 NUMERIC_TYPE
(prod
) = SIGNED_INT
;
890 NUMERIC_TYPE
(prod
) = UNSIGNED_INT
;
891 prod
->tp.pro.code
= tree_code_get_integer_value
(tok
->tp.tok.chars
,
897 /* Build a PROD_PLUS_EXPRESSION. This is uses for PLUS, MINUS, ASSIGN
898 and EQUALS expressions. */
900 static struct prod_token_parm_item
*
901 make_plus_expression
(struct prod_token_parm_item
* tok
,
902 struct prod_token_parm_item
* op1
,
903 struct prod_token_parm_item
* op2
,
904 int type_code
, int prod_code
)
906 struct prod_token_parm_item
*prod
;
909 ensure_not_void
(NUMERIC_TYPE
(op1
), op1
->tp.pro.main_token
);
910 ensure_not_void
(NUMERIC_TYPE
(op2
), op2
->tp.pro.main_token
);
912 prod
= make_production
(PROD_PLUS_EXPRESSION
, tok
);
914 NUMERIC_TYPE
(prod
) = type_code
;
915 type
= tree_code_get_type
(type_code
);
922 prod
->tp.pro.code
= tree_code_get_expression
(prod_code
, type
,
924 op2
->tp.pro.code
, NULL
,
925 tok
->tp.tok.location
);
931 /* Set STORAGE_CLASS in PROD according to CLASS_TOKEN. */
934 set_storage
(struct prod_token_parm_item
*prod
)
936 struct prod_token_parm_item
* stg_class
;
937 stg_class
= STORAGE_CLASS_TOKEN
(prod
);
938 switch
(stg_class
->type
)
941 STORAGE_CLASS
(prod
) = STATIC_STORAGE
;
945 STORAGE_CLASS
(prod
) = AUTOMATIC_STORAGE
;
948 case EXTERNAL_DEFINITION
:
949 STORAGE_CLASS
(prod
) = EXTERNAL_DEFINITION_STORAGE
;
952 case EXTERNAL_REFERENCE
:
953 STORAGE_CLASS
(prod
) = EXTERNAL_REFERENCE_STORAGE
;
961 /* Set parse trace. */
964 treelang_debug
(void)
966 if
(option_parser_trace
)
971 /* Depending on the version of Bison used to compile this grammar,
972 it may issue generic diagnostics spelled "syntax error" or
973 "parse error". To prevent this from changing the translation
974 template randomly, we list all the variants of this particular
975 diagnostic here. Translators: there is no fine distinction
976 between diagnostics with "syntax error" in them, and diagnostics
977 with "parse error" in them. It's okay to give them both the same
979 const char d1
[] = N_
("syntax error");
980 const char d2
[] = N_
("parse error");
981 const char d3
[] = N_
("syntax error; also virtual memory exhausted");
982 const char d4
[] = N_
("parse error; also virtual memory exhausted");
983 const char d5
[] = N_
("syntax error: cannot back up");
984 const char d6
[] = N_
("parse error: cannot back up");