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, 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, 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"
50 #define YYPRINT(file, type, value) print_token (file, type, value)
51 #define YYERROR_VERBOSE YES
53 /* My yylex routine used to intercept calls to flex generated code, to
56 static inline
int my_yylex
(void);
58 /* Call lex, but ensure time is charged to TV_LEX. */
63 timevar_push
(TV_LEX
);
68 #define yylex my_yylex
70 extern
int option_parser_trace
;
72 /* Local prototypes. */
73 static void yyerror (const char *error_message
);
75 void print_token
(FILE *file
, unsigned int type ATTRIBUTE_UNUSED
,
77 static struct prod_token_parm_item
*reverse_prod_list
78 (struct prod_token_parm_item
*old_first
);
79 static void ensure_not_void
(unsigned int type
,
80 struct prod_token_parm_item
*name
);
81 static int check_type_match
(int type_num
, struct prod_token_parm_item
*exp
);
82 static int get_common_type
(struct prod_token_parm_item
*type1
,
83 struct prod_token_parm_item
*type2
);
84 static struct prod_token_parm_item
*make_integer_constant
85 (struct prod_token_parm_item
*value
);
86 static struct prod_token_parm_item
*make_plus_expression
87 (struct prod_token_parm_item
*tok
, struct prod_token_parm_item
*op1
,
88 struct prod_token_parm_item
*op2
, int type_code
, int prod_code
);
89 static void set_storage
(struct prod_token_parm_item
*prod
);
91 /* File global variables. */
92 static struct prod_token_parm_item
*current_function
= NULL
;
95 /* Not %raw - seems to have bugs. */
101 %token RIGHT_SQUARE_BRACKET
102 %token LEFT_SQUARE_BRACKET
103 %token RIGHT_PARENTHESIS
104 %token LEFT_PARENTHESIS
128 %token EXTERNAL_DEFINITION
129 %token EXTERNAL_REFERENCE
131 /* Tokens not passed to parser. */
135 /* Pseudo tokens - productions. */
136 %token PROD_VARIABLE_NAME
137 %token PROD_TYPE_NAME
138 %token PROD_FUNCTION_NAME
139 %token PROD_INTEGER_CONSTANT
140 %token PROD_PLUS_EXPRESSION
141 %token PROD_MINUS_EXPRESSION
142 %token PROD_ASSIGN_EXPRESSION
143 %token PROD_VARIABLE_REFERENCE_EXPRESSION
144 %token PROD_PARAMETER
145 %token PROD_FUNCTION_INVOCATION
163 | declarations declaration
{
172 |function_prototype
{
181 storage typename NAME init_opt SEMICOLON
{
182 struct prod_token_parm_item
*tok
;
183 struct prod_token_parm_item
*prod
;
185 prod
= make_production
(PROD_VARIABLE_NAME
, tok
);
186 SYMBOL_TABLE_NAME
(prod
) = tok
;
187 EXPRESSION_TYPE
(prod
) = $2;
188 VAR_INIT
(prod
) = $4;
189 NUMERIC_TYPE
(prod
) =
190 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
191 ensure_not_void
(NUMERIC_TYPE
(prod
), tok
);
192 if
(insert_tree_name
(prod
))
196 STORAGE_CLASS_TOKEN
(prod
) = $1;
201 gcc_assert
(((struct prod_token_parm_item
*)
202 VAR_INIT
(prod
))->tp.pro.code
);
203 if
(STORAGE_CLASS
(prod
) == EXTERNAL_REFERENCE_STORAGE
)
205 error("%Hexternal reference variable %q.*s has an initial value",
206 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
208 VAR_INIT
(prod
) = NULL
;
213 prod
->tp.pro.code
= tree_code_create_variable
214 (STORAGE_CLASS
(prod
),
215 ((struct prod_token_parm_item
*)SYMBOL_TABLE_NAME
(prod
))->tp.tok.chars
,
216 ((struct prod_token_parm_item
*)SYMBOL_TABLE_NAME
(prod
))->tp.tok.length
,
219 ((struct prod_token_parm_item
*)VAR_INIT
(prod
))->tp.pro.code
: NULL
,
220 tok
->tp.tok.location
);
221 gcc_assert
(prod
->tp.pro.code
);
234 struct prod_token_parm_item
*tok
;
235 struct prod_token_parm_item
*prod
;
236 struct prod_token_parm_item
*prod2
;
238 prod
= make_production
(PROD_VARIABLE_NAME
, tok
);
239 SYMBOL_TABLE_NAME
(prod
) = $2;
240 EXPRESSION_TYPE
(prod
) = $1;
241 NUMERIC_TYPE
(prod
) =
242 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
243 ensure_not_void
(NUMERIC_TYPE
(prod
), tok
);
244 if
(insert_tree_name
(prod
))
248 prod2
= make_production
(PROD_PARAMETER
, tok
);
249 VARIABLE
(prod2
) = prod
;
255 storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLON
{
256 struct prod_token_parm_item
*tok
;
257 struct prod_token_parm_item
*prod
;
258 struct prod_token_parm_item
*type
;
259 struct prod_token_parm_item
*first_parms
;
260 struct prod_token_parm_item
*last_parms
;
261 struct prod_token_parm_item
*this_parms
;
262 struct prod_token_parm_item
*this_parm
;
263 struct prod_token_parm_item
*this_parm_var
;
265 prod
= make_production
(PROD_FUNCTION_NAME
, $3);
266 SYMBOL_TABLE_NAME
(prod
) = $3;
267 EXPRESSION_TYPE
(prod
) = $2;
268 NUMERIC_TYPE
(prod
) =
269 NUMERIC_TYPE
(( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(prod
)));
270 PARAMETERS
(prod
) = reverse_prod_list
($5);
271 insert_tree_name
(prod
);
272 STORAGE_CLASS_TOKEN
(prod
) = $1;
274 switch
(STORAGE_CLASS
(prod
))
277 case EXTERNAL_DEFINITION_STORAGE
:
278 case EXTERNAL_REFERENCE_STORAGE
:
281 case AUTOMATIC_STORAGE
:
282 error ("%Hfunction %q.*s cannot be automatic",
283 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
290 type
= EXPRESSION_TYPE
(prod
);
291 /* Create a parameter list in a non-front end specific format. */
292 for
(first_parms
= NULL
, last_parms
= NULL
, this_parm
= PARAMETERS
(prod
);
294 this_parm
= this_parm
->tp.pro.next
)
296 gcc_assert
(this_parm
->category
== production_category
);
297 this_parm_var
= VARIABLE
(this_parm
);
299 gcc_assert
(this_parm_var
);
300 gcc_assert
(this_parm_var
->category
== production_category
);
301 gcc_assert
(this_parm_var
->tp.pro.main_token
);
303 this_parms
= my_malloc
(sizeof
(struct prod_token_parm_item
));
305 this_parms
->tp.par.variable_name
=
306 this_parm_var
->tp.pro.main_token
->tp.tok.chars
;
307 this_parms
->category
= parameter_category
;
308 this_parms
->type
= NUMERIC_TYPE
309 (( (struct prod_token_parm_item
*)EXPRESSION_TYPE
(this_parm_var
)));
312 last_parms
->tp.par.next
= this_parms
;
313 last_parms
= this_parms
;
317 first_parms
= this_parms
;
318 last_parms
= this_parms
;
320 this_parms
->tp.par.where_to_put_var_tree
=
321 & (((struct prod_token_parm_item
*)VARIABLE
(this_parm
))->tp.pro.code
);
323 FIRST_PARMS
(prod
) = first_parms
;
326 tree_code_create_function_prototype
(tok
->tp.tok.chars
,
327 STORAGE_CLASS
(prod
),
329 first_parms
, tok
->tp.tok.location
);
331 #ifdef ENABLE_CHECKING
332 /* Check all the parameters have code. */
333 for
(this_parm
= PARAMETERS
(prod
);
335 this_parm
= this_parm
->tp.pro.next
)
337 gcc_assert
((struct prod_token_parm_item
*)VARIABLE
(this_parm
));
338 gcc_assert
(((struct prod_token_parm_item
*)
339 VARIABLE
(this_parm
))->tp.pro.code
);
347 struct prod_token_parm_item
*proto
;
348 struct prod_token_parm_item search_prod
;
349 struct prod_token_parm_item
*tok
;
351 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
352 search_prod.category
= token_category
;
353 current_function
= proto
= lookup_tree_name
(&search_prod
);
356 error ("%Hno prototype found for %q.*s", &tok
->tp.tok.location
,
357 tok
->tp.tok.length
, tok
->tp.tok.chars
);
361 gcc_assert
(proto
->tp.pro.code
);
363 tree_code_create_function_initial
(proto
->tp.pro.code
, tok
->tp.tok.location
);
366 variable_defs_opt statements_opt RIGHT_BRACE
{
367 struct prod_token_parm_item
*tok
;
369 tree_code_create_function_wrapup
(tok
->tp.tok.location
);
370 current_function
= NULL
;
396 |variable_defs variable_def
{
403 struct prod_token_parm_item
*tok
;
404 struct prod_token_parm_item
*prod
;
406 prod
= make_production
(PROD_TYPE_NAME
, tok
);
407 NUMERIC_TYPE
(prod
) = SIGNED_INT
;
408 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
412 struct prod_token_parm_item
*tok
;
413 struct prod_token_parm_item
*prod
;
415 prod
= make_production
(PROD_TYPE_NAME
, tok
);
416 NUMERIC_TYPE
(prod
) = UNSIGNED_INT
;
417 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
421 struct prod_token_parm_item
*tok
;
422 struct prod_token_parm_item
*prod
;
424 prod
= make_production
(PROD_TYPE_NAME
, tok
);
425 NUMERIC_TYPE
(prod
) = SIGNED_CHAR
;
426 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
430 struct prod_token_parm_item
*tok
;
431 struct prod_token_parm_item
*prod
;
433 prod
= make_production
(PROD_TYPE_NAME
, tok
);
434 NUMERIC_TYPE
(prod
) = UNSIGNED_CHAR
;
435 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
439 struct prod_token_parm_item
*tok
;
440 struct prod_token_parm_item
*prod
;
442 prod
= make_production
(PROD_TYPE_NAME
, tok
);
443 NUMERIC_TYPE
(prod
) = VOID_TYPE
;
444 prod
->tp.pro.code
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
450 /* Nothing to do. */ {
463 |parameters COMMA parameter
{
464 struct prod_token_parm_item
*prod1
;
466 prod1
->tp.pro.next
= $1; /* Insert in reverse order. */
475 |statements statement
{
481 expression SEMICOLON
{
482 struct prod_token_parm_item
*exp
;
484 tree_code_output_expression_statement
(exp
->tp.pro.code
,
485 exp
->tp.pro.main_token
->tp.tok.location
);
496 IF LEFT_PARENTHESIS expression RIGHT_PARENTHESIS
{
497 struct prod_token_parm_item
*tok
;
498 struct prod_token_parm_item
*exp
;
501 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
502 tree_code_if_start
(exp
->tp.pro.code
, tok
->tp.tok.location
);
504 LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE
{
505 /* Just let the statements flow. */
508 struct prod_token_parm_item
*tok
;
510 tree_code_if_else
(tok
->tp.tok.location
);
512 LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE
{
513 struct prod_token_parm_item
*tok
;
515 tree_code_if_end
(tok
->tp.tok.location
);
521 tl_RETURN expression_opt
{
522 struct prod_token_parm_item
*type_prod
;
523 struct prod_token_parm_item
*ret_tok
= $1;
524 struct prod_token_parm_item
*exp
= $2;
526 type_prod
= EXPRESSION_TYPE
(current_function
);
527 if
(NUMERIC_TYPE
(type_prod
) == VOID_TYPE
)
529 tree_code_generate_return
(type_prod
->tp.pro.code
, NULL
);
532 warning
(0, "%Hredundant expression in return",
533 &ret_tok
->tp.tok.location
);
534 tree_code_generate_return
(type_prod
->tp.pro.code
, NULL
);
538 error ("%Hexpression missing in return", &ret_tok
->tp.tok.location
);
541 /* Check same type. */
542 if
(check_type_match
(NUMERIC_TYPE
(type_prod
), exp
))
544 gcc_assert
(type_prod
->tp.pro.code
);
545 gcc_assert
(exp
->tp.pro.code
);
547 /* Generate the code. */
548 tree_code_generate_return
(type_prod
->tp.pro.code
,
560 struct prod_token_parm_item
*exp
;
562 gcc_assert
(exp
->tp.pro.code
);
570 $$
= make_integer_constant
($1);
575 |expression tl_PLUS expression
{
576 struct prod_token_parm_item
*tok
= $2;
577 struct prod_token_parm_item
*op1
= $1;
578 struct prod_token_parm_item
*op2
= $3;
579 int type_code
= get_common_type
(op1
, op2
);
582 $$
= make_plus_expression
(tok
, op1
, op2
, type_code
, EXP_PLUS
);
584 |expression tl_MINUS expression %prec tl_PLUS
{
585 struct prod_token_parm_item
*tok
= $2;
586 struct prod_token_parm_item
*op1
= $1;
587 struct prod_token_parm_item
*op2
= $3;
588 int type_code
= get_common_type
(op1
, op2
);
591 $$
= make_plus_expression
(tok
, op1
, op2
, type_code
, EXP_MINUS
);
593 |expression EQUALS expression
{
594 struct prod_token_parm_item
*tok
= $2;
595 struct prod_token_parm_item
*op1
= $1;
596 struct prod_token_parm_item
*op2
= $3;
597 int type_code
= NUMERIC_TYPE
(op1
);
600 $$
= make_plus_expression
601 (tok
, op1
, op2
, type_code
, EXP_EQUALS
);
603 |variable_ref ASSIGN expression
{
604 struct prod_token_parm_item
*tok
= $2;
605 struct prod_token_parm_item
*op1
= $1;
606 struct prod_token_parm_item
*op2
= $3;
607 int type_code
= NUMERIC_TYPE
(op1
);
610 $$
= make_plus_expression
611 (tok
, op1
, op2
, type_code
, EXP_ASSIGN
);
613 |function_invocation
{
619 NAME LEFT_PARENTHESIS expressions_with_commas_opt RIGHT_PARENTHESIS
{
620 struct prod_token_parm_item
*prod
;
621 struct prod_token_parm_item
*tok
;
622 struct prod_token_parm_item search_prod
;
623 struct prod_token_parm_item
*proto
;
624 struct prod_token_parm_item
*exp
;
625 struct prod_token_parm_item
*exp_proto
;
626 struct prod_token_parm_item
*var
;
633 prod
= make_production
(PROD_FUNCTION_INVOCATION
, tok
);
634 SYMBOL_TABLE_NAME
(prod
) = tok
;
635 PARAMETERS
(prod
) = reverse_prod_list
($3);
636 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
637 search_prod.category
= token_category
;
638 proto
= lookup_tree_name
(&search_prod
);
641 error ("%Hfunction prototype not found for %q.*s",
642 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
645 EXPRESSION_TYPE
(prod
) = EXPRESSION_TYPE
(proto
);
646 NUMERIC_TYPE
(prod
) = NUMERIC_TYPE
(proto
);
647 /* Count the expressions and ensure they match the prototype. */
648 for
(exp_proto_count
= 0, exp_proto
= PARAMETERS
(proto
);
649 exp_proto
; exp_proto
= exp_proto
->tp.pro.next
)
652 for
(exp_count
= 0, exp
= PARAMETERS
(prod
); exp
; exp
= exp
->tp.pro.next
)
655 if
(exp_count
!= exp_proto_count
)
657 error ("%Hexpression count mismatch %q.*s with prototype",
658 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
661 parms
= tree_code_init_parameters
();
662 for
(exp_proto
= PARAMETERS
(proto
), exp
= PARAMETERS
(prod
);
664 exp
= exp
->tp.pro.next
, exp_proto
= exp_proto
->tp.pro.next
)
667 gcc_assert
(exp_proto
);
668 gcc_assert
(exp
->tp.pro.code
);
670 var
= VARIABLE
(exp_proto
);
673 gcc_assert
(var
->tp.pro.code
);
675 parms
= tree_code_add_parameter
(parms
, var
->tp.pro.code
,
678 type
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
679 prod
->tp.pro.code
= tree_code_get_expression
(EXP_FUNCTION_INVOCATION
, type
,
682 NULL
, tok
->tp.tok.location
);
687 expressions_with_commas_opt:
691 |expressions_with_commas
{ $$
= $1 }
694 expressions_with_commas:
696 struct prod_token_parm_item
*exp
;
698 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
701 |expressions_with_commas COMMA expression
{
702 struct prod_token_parm_item
*exp
;
704 ensure_not_void
(NUMERIC_TYPE
(exp
), exp
->tp.pro.main_token
);
705 exp
->tp.pro.next
= $1; /* Reverse order. */
712 struct prod_token_parm_item search_prod
;
713 struct prod_token_parm_item
*prod
;
714 struct prod_token_parm_item
*symbol_table_entry
;
715 struct prod_token_parm_item
*tok
;
719 SYMBOL_TABLE_NAME
((&search_prod
)) = tok
;
720 search_prod.category
= token_category
;
721 symbol_table_entry
= lookup_tree_name
(&search_prod
);
722 if
(!symbol_table_entry
)
724 error ("%Hvariable %q.*s not defined",
725 &tok
->tp.tok.location
, tok
->tp.tok.length
, tok
->tp.tok.chars
);
729 prod
= make_production
(PROD_VARIABLE_REFERENCE_EXPRESSION
, tok
);
730 NUMERIC_TYPE
(prod
) = NUMERIC_TYPE
(symbol_table_entry
);
731 type
= tree_code_get_type
(NUMERIC_TYPE
(prod
));
732 if
(!NUMERIC_TYPE
(prod
))
737 tree_code_get_expression
(EXP_REFERENCE
, type
,
738 symbol_table_entry
->tp.pro.code
, NULL
, NULL
,
739 tok
->tp.tok.location
);
749 /* Pass the initialization value up. */
754 ASSIGN init_element
{
761 $$
= make_integer_constant
($1);
767 /* Print a token VALUE to file FILE. Ignore TYPE which is the token
771 print_token
(FILE *file
, unsigned int type ATTRIBUTE_UNUSED
, YYSTYPE value
)
773 struct prod_token_parm_item
*tok
;
777 fprintf
(file
, "%d \"", LOCATION_LINE
(tok
->tp.tok.location
));
778 for
(ix
= 0; ix
< tok
->tp.tok.length
; ix
++)
779 fprintf
(file
, "%c", tok
->tp.tok.chars
[ix
]);
781 fprintf
(file
, "\"");
784 /* Output a message ERROR_MESSAGE from the parser. */
786 yyerror (const char *error_message
)
788 struct prod_token_parm_item
*tok
;
792 error ("%H%s", &tok
->tp.tok.location
, error_message
);
794 error ("%s", error_message
);
797 /* Reverse the order of a token list, linked by parse_next, old first
798 token is OLD_FIRST. */
800 static struct prod_token_parm_item
*
801 reverse_prod_list
(struct prod_token_parm_item
*old_first
)
803 struct prod_token_parm_item
*current
;
804 struct prod_token_parm_item
*next
;
805 struct prod_token_parm_item
*prev
= NULL
;
812 gcc_assert
(current
->category
== production_category
);
814 next
= current
->tp.pro.next
;
815 current
->tp.pro.next
= prev
;
822 /* Ensure TYPE is not VOID. Use NAME as the token for the error location. */
825 ensure_not_void
(unsigned int type
, struct prod_token_parm_item
* name
)
827 if
(type
== VOID_TYPE
)
828 error ("%Htype must not be void in this context",
829 &name
->tp.tok.location
);
832 /* Check TYPE1 and TYPE2 which are integral types. Return the lowest
833 common type (min is signed int). */
836 get_common_type
(struct prod_token_parm_item
*type1
,
837 struct prod_token_parm_item
*type2
)
839 if
(NUMERIC_TYPE
(type1
) == UNSIGNED_INT
)
841 if
(NUMERIC_TYPE
(type2
) == UNSIGNED_INT
)
847 /* Check type (TYPE_NUM) and expression (EXP) match. Return the 1 if
848 OK else 0. Must be exact match - same name unless it is an
852 check_type_match
(int type_num
, struct prod_token_parm_item
*exp
)
860 switch
(NUMERIC_TYPE
(exp
))
881 /* Make a production for an integer constant VALUE. */
883 static struct prod_token_parm_item
*
884 make_integer_constant
(struct prod_token_parm_item
* value
)
886 struct prod_token_parm_item
*tok
;
887 struct prod_token_parm_item
*prod
;
889 prod
= make_production
(PROD_INTEGER_CONSTANT
, tok
);
890 if
((tok
->tp.tok.chars
[0] == (unsigned char)'-')
891 ||
(tok
->tp.tok.chars
[0] == (unsigned char)'+'))
892 NUMERIC_TYPE
(prod
) = SIGNED_INT
;
894 NUMERIC_TYPE
(prod
) = UNSIGNED_INT
;
895 prod
->tp.pro.code
= tree_code_get_integer_value
(tok
->tp.tok.chars
,
901 /* Build a PROD_PLUS_EXPRESSION. This is uses for PLUS, MINUS, ASSIGN
902 and EQUALS expressions. */
904 static struct prod_token_parm_item
*
905 make_plus_expression
(struct prod_token_parm_item
*tok
,
906 struct prod_token_parm_item
*op1
,
907 struct prod_token_parm_item
*op2
,
908 int type_code
, int prod_code
)
910 struct prod_token_parm_item
*prod
;
913 ensure_not_void
(NUMERIC_TYPE
(op1
), op1
->tp.pro.main_token
);
914 ensure_not_void
(NUMERIC_TYPE
(op2
), op2
->tp.pro.main_token
);
916 prod
= make_production
(PROD_PLUS_EXPRESSION
, tok
);
918 NUMERIC_TYPE
(prod
) = type_code
;
919 type
= tree_code_get_type
(type_code
);
926 prod
->tp.pro.code
= tree_code_get_expression
(prod_code
, type
,
928 op2
->tp.pro.code
, NULL
,
929 tok
->tp.tok.location
);
935 /* Set STORAGE_CLASS in PROD according to CLASS_TOKEN. */
938 set_storage
(struct prod_token_parm_item
*prod
)
940 struct prod_token_parm_item
*stg_class
;
941 stg_class
= STORAGE_CLASS_TOKEN
(prod
);
942 switch
(stg_class
->type
)
945 STORAGE_CLASS
(prod
) = STATIC_STORAGE
;
949 STORAGE_CLASS
(prod
) = AUTOMATIC_STORAGE
;
952 case EXTERNAL_DEFINITION
:
953 STORAGE_CLASS
(prod
) = EXTERNAL_DEFINITION_STORAGE
;
956 case EXTERNAL_REFERENCE
:
957 STORAGE_CLASS
(prod
) = EXTERNAL_REFERENCE_STORAGE
;
965 /* Set parse trace. */
968 treelang_debug
(void)
970 if
(option_parser_trace
)
975 /* Depending on the version of Bison used to compile this grammar,
976 it may issue generic diagnostics spelled "syntax error" or
977 "parse error". To prevent this from changing the translation
978 template randomly, we list all the variants of this particular
979 diagnostic here. Translators: there is no fine distinction
980 between diagnostics with "syntax error" in them, and diagnostics
981 with "parse error" in them. It's okay to give them both the same
983 const char d1
[] = N_
("syntax error");
984 const char d2
[] = N_
("parse error");
985 const char d3
[] = N_
("syntax error; also virtual memory exhausted");
986 const char d4
[] = N_
("parse error; also virtual memory exhausted");
987 const char d5
[] = N_
("syntax error: cannot back up");
988 const char d6
[] = N_
("parse error: cannot back up");