stage1_2/iec_bison.yy
changeset 813 0630cc31569f
parent 811 970c582885bf
child 822 a7d9e0b8636b
child 823 c95f42f28b69
equal deleted inserted replaced
804:7898ba56c7cf 813:0630cc31569f
  3456  *
  3456  *
  3457  *       Please read the comment above the definition of 'variable' in section B1.4 for details.
  3457  *       Please read the comment above the definition of 'variable' in section B1.4 for details.
  3458  */
  3458  */
  3459 en_param_declaration:
  3459 en_param_declaration:
  3460   en_identifier ':' BOOL ASSIGN boolean_literal
  3460   en_identifier ':' BOOL ASSIGN boolean_literal
  3461   {$$ = new en_param_declaration_c($1, new bool_type_name_c(locloc(@$)), $5, new explicit_definition_c(), locloc(@$));}
  3461   {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
  3462 | en_identifier ':' BOOL ASSIGN integer
  3462 | en_identifier ':' BOOL ASSIGN integer
  3463   {$$ = new en_param_declaration_c($1, new bool_type_name_c(locloc(@$)), $5, new explicit_definition_c(), locloc(@$));}
  3463   {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
  3464 /* ERROR_CHECK_BEGIN */
  3464 /* ERROR_CHECK_BEGIN */
  3465 | en_identifier BOOL ASSIGN boolean_literal
  3465 | en_identifier BOOL ASSIGN boolean_literal
  3466 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
  3466 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
  3467 | en_identifier BOOL ASSIGN integer
  3467 | en_identifier BOOL ASSIGN integer
  3468 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
  3468 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
  3596  *       the ':' was moved to var1_list and fb_name_list!
  3596  *       the ':' was moved to var1_list and fb_name_list!
  3597  */
  3597  */
  3598 fb_name_decl:
  3598 fb_name_decl:
  3599 /*  fb_name_list ':' function_block_type_name */
  3599 /*  fb_name_list ':' function_block_type_name */
  3600   fb_name_list_with_colon function_block_type_name
  3600   fb_name_list_with_colon function_block_type_name
  3601 	{$$ = new fb_name_decl_c($1, $2, NULL, locloc(@$));}
  3601 	{$$ = new fb_name_decl_c($1, new fb_spec_init_c($2, NULL,locloc(@2)), locloc(@$));}
  3602 /*| fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
  3602 /*| fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
  3603 | fb_name_list_with_colon function_block_type_name ASSIGN structure_initialization
  3603 | fb_name_list_with_colon function_block_type_name ASSIGN structure_initialization
  3604 	{$$ = new fb_name_decl_c($1, $2, $4, locloc(@$));}
  3604 	{$$ = new fb_name_decl_c($1, new fb_spec_init_c($2, $4, locf(@2), locl(@4)), locloc(@$));}
  3605 /* ERROR_CHECK_BEGIN */
  3605 /* ERROR_CHECK_BEGIN */
  3606 | fb_name_list_with_colon ASSIGN structure_initialization
  3606 | fb_name_list_with_colon ASSIGN structure_initialization
  3607 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block type name defined in function block declaration with initialization."); yynerrs++;}
  3607 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block type name defined in function block declaration with initialization."); yynerrs++;}
  3608 | fb_name_list_with_colon function_block_type_name structure_initialization
  3608 | fb_name_list_with_colon function_block_type_name structure_initialization
  3609 	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':=' missing in function block declaration with initialization."); yynerrs++;}
  3609 	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':=' missing in function block declaration with initialization."); yynerrs++;}
  4040 | global_var_name ':' prev_declared_structure_type_name
  4040 | global_var_name ':' prev_declared_structure_type_name
  4041 	{$$ = new external_declaration_c($1, $3, locloc(@$));
  4041 	{$$ = new external_declaration_c($1, $3, locloc(@$));
  4042 	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
  4042 	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
  4043 	}
  4043 	}
  4044 | global_var_name ':' function_block_type_name
  4044 | global_var_name ':' function_block_type_name
  4045 	{$$ = new external_declaration_c($1, $3, locloc(@$));
  4045 	{$$ = new external_declaration_c($1, new fb_spec_init_c($3, NULL, locloc(@3)), locloc(@$));
  4046 	 variable_name_symtable.insert($1, prev_declared_fb_name_token);
  4046 	 variable_name_symtable.insert($1, prev_declared_fb_name_token);
  4047 	}
  4047 	}
  4048 /* ERROR_CHECK_BEGIN */
  4048 /* ERROR_CHECK_BEGIN */
  4049 | global_var_name simple_specification
  4049 | global_var_name simple_specification
  4050 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and simple specification."); yynerrs++;}
  4050 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and simple specification."); yynerrs++;}
  4134 	{$$ = new global_var_decl_c($1, NULL, locloc(@$));}
  4134 	{$$ = new global_var_decl_c($1, NULL, locloc(@$));}
  4135 */
  4135 */
  4136   global_var_spec ':' located_var_spec_init
  4136   global_var_spec ':' located_var_spec_init
  4137 	{$$ = new global_var_decl_c($1, $3, locloc(@$));}
  4137 	{$$ = new global_var_decl_c($1, $3, locloc(@$));}
  4138 | global_var_spec ':' function_block_type_name
  4138 | global_var_spec ':' function_block_type_name
  4139 	{$$ = new global_var_decl_c($1, $3, locloc(@$));}
  4139 	{$$ = new global_var_decl_c($1, new fb_spec_init_c($3, NULL, locloc(@3)), locloc(@$));}
  4140 /* ERROR_CHECK_BEGIN */
  4140 /* ERROR_CHECK_BEGIN */
  4141 | global_var_list located_var_spec_init
  4141 | global_var_list located_var_spec_init
  4142 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable list and type specification."); yynerrs++;}
  4142 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable list and type specification."); yynerrs++;}
  4143 | global_var_name location located_var_spec_init
  4143 | global_var_name location located_var_spec_init
  4144 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable specification and type specification."); yynerrs++;}
  4144 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable specification and type specification."); yynerrs++;}
  5690 /* ERROR_CHECK_END */
  5690 /* ERROR_CHECK_END */
  5691 ;
  5691 ;
  5692 
  5692 
  5693 
  5693 
  5694 resource_declaration:
  5694 resource_declaration:
  5695   RESOURCE {variable_name_symtable.push();direct_variable_symtable.push();} resource_name ON resource_type_name
  5695   RESOURCE {variable_name_symtable.push();direct_variable_symtable.push();} resource_name {variable_name_symtable.insert($3, prev_declared_resource_name_token);} ON resource_type_name
  5696    optional_global_var_declarations
  5696    optional_global_var_declarations
  5697    single_resource_declaration
  5697    single_resource_declaration
  5698   END_RESOURCE
  5698   END_RESOURCE
  5699 	{$$ = new resource_declaration_c($3, $5, $6, $7, locloc(@$));
  5699 	{$$ = new resource_declaration_c($3, $6, $7, $8, locloc(@$));
  5700 	 variable_name_symtable.pop();
  5700 	 variable_name_symtable.pop();
  5701 	 direct_variable_symtable.pop();
  5701 	 direct_variable_symtable.pop();
  5702 	 variable_name_symtable.insert($3, prev_declared_resource_name_token);
  5702 	 variable_name_symtable.insert($3, prev_declared_resource_name_token);
  5703 	}
  5703 	}
  5704 /* ERROR_CHECK_BEGIN */
  5704 /* ERROR_CHECK_BEGIN */
  8244 int stage2__(const char *filename, 
  8244 int stage2__(const char *filename, 
  8245              const char *includedir,     /* Include directory, where included files will be searched for... */
  8245              const char *includedir,     /* Include directory, where included files will be searched for... */
  8246              symbol_c **tree_root_ref,
  8246              symbol_c **tree_root_ref,
  8247              bool full_token_loc_        /* error messages specify full token location */
  8247              bool full_token_loc_        /* error messages specify full token location */
  8248             ) {
  8248             ) {
  8249 
       
  8250   char *libfilename = NULL;
  8249   char *libfilename = NULL;
  8251 
  8250 
  8252   if (includedir != NULL) {
  8251   if (includedir != NULL) {
  8253     INCLUDE_DIRECTORIES[0] = includedir;
  8252     INCLUDE_DIRECTORIES[0] = includedir;
  8254   }
  8253   }
  8294   for(int i = 0; standard_function_block_names[i] != NULL; i++)
  8293   for(int i = 0; standard_function_block_names[i] != NULL; i++)
  8295     if (library_element_symtable.find_value(standard_function_block_names[i]) ==
  8294     if (library_element_symtable.find_value(standard_function_block_names[i]) ==
  8296         library_element_symtable.end_value())
  8295         library_element_symtable.end_value())
  8297       library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token);
  8296       library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token);
  8298 
  8297 
  8299 
       
  8300   /* now parse the input file... */
  8298   /* now parse the input file... */
  8301   #if YYDEBUG
  8299   #if YYDEBUG
  8302     yydebug = 1;
  8300     yydebug = 1;
  8303   #endif
  8301   #endif
  8304   FILE *mainfile = NULL;
  8302   FILE *mainfile = NULL;