stage1_2/iec_bison.yy
changeset 958 7474d2cd1d6e
parent 956 513809fbfaf9
child 961 b05f63d9d0fa
equal deleted inserted replaced
957:4489afa5b1c5 958:7474d2cd1d6e
   222 /* forward declarations */
   222 /* forward declarations */
   223 /************************/
   223 /************************/
   224 /* The functions declared here are defined at the end of this file... */
   224 /* The functions declared here are defined at the end of this file... */
   225 
   225 
   226 /* Convert an il_operator_c into an identifier_c */
   226 /* Convert an il_operator_c into an identifier_c */
   227 symbol_c *il_operator_c_2_identifier_c(symbol_c *il_operator);
   227 identifier_c         *il_operator_c_2_identifier_c        (symbol_c *il_operator);
       
   228 /* Convert an il_operator_c into an poutype_identifier_c */
       
   229 poutype_identifier_c *il_operator_c_2_poutype_identifier_c(symbol_c *il_operator);
       
   230 
   228 
   231 
   229 /* return if current token is a syntax element */
   232 /* return if current token is a syntax element */
   230 /* ERROR_CHECK_BEGIN */
   233 /* ERROR_CHECK_BEGIN */
   231 bool is_current_syntax_token();
   234 bool is_current_syntax_token();
   232 /* ERROR_CHECK_END */
   235 /* ERROR_CHECK_END */
  1595 | prev_declared_subrange_type_name          {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1598 | prev_declared_subrange_type_name          {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1596 | prev_declared_enumerated_type_name        {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1599 | prev_declared_enumerated_type_name        {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1597 | prev_declared_array_type_name             {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1600 | prev_declared_array_type_name             {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1598 | prev_declared_structure_type_name         {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1601 | prev_declared_structure_type_name         {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1599 | prev_declared_string_type_name            {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1602 | prev_declared_string_type_name            {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1600 | prev_declared_derived_function_name
  1603 | prev_declared_derived_function_name       {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1601 | prev_declared_derived_function_block_name
  1604 | prev_declared_derived_function_block_name {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1602 | prev_declared_program_type_name
  1605 | prev_declared_program_type_name           {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
  1603 /**/
  1606 /**/
  1604 | prev_declared_resource_name
  1607 | prev_declared_resource_name
  1605 | prev_declared_program_name
  1608 | prev_declared_program_name
  1606 | prev_declared_global_var_name
  1609 | prev_declared_global_var_name
  1607 ;
  1610 ;
  1608 
  1611 
  1609 
  1612 /* NOTE: Notice that the symbol classes:
       
  1613  *            - derived_datatype_identifier_c
       
  1614  *            - poutype_identifier_c
       
  1615  *       are only inserted into the AST when referencing a derived dataype or a POU
       
  1616  *       (e.g. when declaring a variable, making a function call, instantiating a program in a resource,
       
  1617  *        or delaring a derived datatype that derives from another previously delcared datatype).
       
  1618  *
       
  1619  *       In the declaration of the datatype or POU itself, the name of the datatype or POU will be stored
       
  1620  *       inside an identifier_c instead!!
       
  1621  */
  1610 prev_declared_variable_name:        prev_declared_variable_name_token        {$$ = new identifier_c($1, locloc(@$));};
  1622 prev_declared_variable_name:        prev_declared_variable_name_token        {$$ = new identifier_c($1, locloc(@$));};
  1611 prev_declared_fb_name:              prev_declared_fb_name_token              {$$ = new identifier_c($1, locloc(@$));};
  1623 prev_declared_fb_name:              prev_declared_fb_name_token              {$$ = new identifier_c($1, locloc(@$));};
  1612 
  1624 
  1613 prev_declared_simple_type_name:     prev_declared_simple_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1625 prev_declared_simple_type_name:     prev_declared_simple_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1614 prev_declared_subrange_type_name:   prev_declared_subrange_type_name_token   {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1626 prev_declared_subrange_type_name:   prev_declared_subrange_type_name_token   {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1616 prev_declared_array_type_name:      prev_declared_array_type_name_token      {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1628 prev_declared_array_type_name:      prev_declared_array_type_name_token      {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1617 prev_declared_structure_type_name:  prev_declared_structure_type_name_token  {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1629 prev_declared_structure_type_name:  prev_declared_structure_type_name_token  {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1618 prev_declared_string_type_name:     prev_declared_string_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1630 prev_declared_string_type_name:     prev_declared_string_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
  1619 prev_declared_ref_type_name:        prev_declared_ref_type_name_token        {$$ = new derived_datatype_identifier_c($1, locloc(@$));};  /* defined in IEC 61131-3 v3 */
  1631 prev_declared_ref_type_name:        prev_declared_ref_type_name_token        {$$ = new derived_datatype_identifier_c($1, locloc(@$));};  /* defined in IEC 61131-3 v3 */
  1620 
  1632 
  1621 prev_declared_derived_function_name:       prev_declared_derived_function_name_token       {$$ = new identifier_c($1, locloc(@$));};
  1633 prev_declared_derived_function_name:       prev_declared_derived_function_name_token       {$$ = new poutype_identifier_c($1, locloc(@$));};
  1622 prev_declared_derived_function_block_name: prev_declared_derived_function_block_name_token {$$ = new identifier_c($1, locloc(@$));};
  1634 prev_declared_derived_function_block_name: prev_declared_derived_function_block_name_token {$$ = new poutype_identifier_c($1, locloc(@$));};
  1623 prev_declared_program_type_name:           prev_declared_program_type_name_token           {$$ = new identifier_c($1, locloc(@$));};
  1635 prev_declared_program_type_name:           prev_declared_program_type_name_token           {$$ = new poutype_identifier_c($1, locloc(@$));};
       
  1636 /* NOTE: The poutype_identifier_c was introduced to allow the implementation of remove_forward_dependencies_c */
       
  1637 
  1624 
  1638 
  1625 
  1639 
  1626 
  1640 
  1627 /***************************/
  1641 /***************************/
  1628 /* B 0 - Programming Model */
  1642 /* B 0 - Programming Model */
  4823   standard_function_name_no_clashes
  4837   standard_function_name_no_clashes
  4824 | standard_function_name_expression_clashes
  4838 | standard_function_name_expression_clashes
  4825 //| standard_function_name_simpleop_only_clashes
  4839 //| standard_function_name_simpleop_only_clashes
  4826 ;
  4840 ;
  4827 
  4841 
       
  4842 /* standard_function_name_no_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
  4828 standard_function_name_no_clashes:
  4843 standard_function_name_no_clashes:
  4829   standard_function_name_token
  4844   standard_function_name_token
  4830 	{$$ = new identifier_c($1, locloc(@$));}
  4845 	{$$ = new poutype_identifier_c($1, locloc(@$));}
  4831 ;
  4846 ;
  4832 
  4847 
  4833 
  4848 
  4834 standard_function_name_simpleop_clashes:
  4849 standard_function_name_simpleop_clashes:
  4835   standard_function_name_NOT_clashes
  4850   standard_function_name_NOT_clashes
  4836 //| standard_function_name_simpleop_only_clashes
  4851 //| standard_function_name_simpleop_only_clashes
  4837 ;
  4852 ;
  4838 
  4853 
       
  4854 /* standard_function_name_NOT_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
  4839 standard_function_name_NOT_clashes:
  4855 standard_function_name_NOT_clashes:
  4840   NOT
  4856   NOT
  4841 	{$$ = new identifier_c(strdup("NOT"), locloc(@$));}
  4857 	{$$ = new poutype_identifier_c(strdup("NOT"), locloc(@$));}
  4842 ;
  4858 ;
  4843 
  4859 
  4844 /* Add here any other IL simple operators that collide
  4860 /* Add here any other IL simple operators that collide
  4845  * with standard function names!
  4861  * with standard function names!
  4846  * Don't forget to uncomment the equivalent lines in
  4862  * Don't forget to uncomment the equivalent lines in
  4851 /*
  4867 /*
  4852 standard_function_name_simpleop_only_clashes:
  4868 standard_function_name_simpleop_only_clashes:
  4853 ;
  4869 ;
  4854 */
  4870 */
  4855 
  4871 
       
  4872 /* standard_function_name_expression_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
  4856 standard_function_name_expression_clashes:
  4873 standard_function_name_expression_clashes:
  4857   AND	{$$ = new identifier_c(strdup("AND"), locloc(@$));}
  4874   AND	{$$ = new poutype_identifier_c(strdup("AND"), locloc(@$));}
  4858 | OR	{$$ = new identifier_c(strdup("OR"), locloc(@$));}
  4875 | OR	{$$ = new poutype_identifier_c(strdup("OR"), locloc(@$));}
  4859 | XOR	{$$ = new identifier_c(strdup("XOR"), locloc(@$));}
  4876 | XOR	{$$ = new poutype_identifier_c(strdup("XOR"), locloc(@$));}
  4860 | ADD	{$$ = new identifier_c(strdup("ADD"), locloc(@$));}
  4877 | ADD	{$$ = new poutype_identifier_c(strdup("ADD"), locloc(@$));}
  4861 | SUB	{$$ = new identifier_c(strdup("SUB"), locloc(@$));}
  4878 | SUB	{$$ = new poutype_identifier_c(strdup("SUB"), locloc(@$));}
  4862 | MUL	{$$ = new identifier_c(strdup("MUL"), locloc(@$));}
  4879 | MUL	{$$ = new poutype_identifier_c(strdup("MUL"), locloc(@$));}
  4863 | DIV	{$$ = new identifier_c(strdup("DIV"), locloc(@$));}
  4880 | DIV	{$$ = new poutype_identifier_c(strdup("DIV"), locloc(@$));}
  4864 | MOD	{$$ = new identifier_c(strdup("MOD"), locloc(@$));}
  4881 | MOD	{$$ = new poutype_identifier_c(strdup("MOD"), locloc(@$));}
  4865 | GT	{$$ = new identifier_c(strdup("GT"), locloc(@$));}
  4882 | GT	{$$ = new poutype_identifier_c(strdup("GT"), locloc(@$));}
  4866 | GE	{$$ = new identifier_c(strdup("GE"), locloc(@$));}
  4883 | GE	{$$ = new poutype_identifier_c(strdup("GE"), locloc(@$));}
  4867 | EQ	{$$ = new identifier_c(strdup("EQ"), locloc(@$));}
  4884 | EQ	{$$ = new poutype_identifier_c(strdup("EQ"), locloc(@$));}
  4868 | LT	{$$ = new identifier_c(strdup("LT"), locloc(@$));}
  4885 | LT	{$$ = new poutype_identifier_c(strdup("LT"), locloc(@$));}
  4869 | LE	{$$ = new identifier_c(strdup("LE"), locloc(@$));}
  4886 | LE	{$$ = new poutype_identifier_c(strdup("LE"), locloc(@$));}
  4870 | NE	{$$ = new identifier_c(strdup("NE"), locloc(@$));}
  4887 | NE	{$$ = new poutype_identifier_c(strdup("NE"), locloc(@$));}
  4871 /*
  4888 /*
  4872   AND_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4889   AND_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4873 //NOTE: AND2 (corresponding to the source code string '&') does not clash
  4890 //NOTE: AND2 (corresponding to the source code string '&') does not clash
  4874 //      with a standard function name, so should be commented out!
  4891 //      with a standard function name, so should be commented out!
  4875 //| AND2_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4892 //| AND2_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4876 | OR_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4893 | OR_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4877 | XOR_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4894 | XOR_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4878 | ADD_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4895 | ADD_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4879 | SUB_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4896 | SUB_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4880 | MUL_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4897 | MUL_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4881 | DIV_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4898 | DIV_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4882 | MOD_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4899 | MOD_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4883 | GT_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4900 | GT_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4884 | GE_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4901 | GE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4885 | EQ_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4902 | EQ_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4886 | LT_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4903 | LT_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4887 | LE_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4904 | LE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4888 | NE_operator	{$$ = il_operator_c_2_identifier_c($1);}
  4905 | NE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
  4889 */
  4906 */
  4890 ;
  4907 ;
  4891 
  4908 
  4892 
  4909 
  4893 derived_function_name:
  4910 derived_function_name:
  4894   identifier  /* will never occur during normal parsing, only needed for preparsing to change it to a prev_declared_derived_function_name! */
  4911   identifier  /* will never occur during normal parsing, only needed for preparsing to change it to a prev_declared_derived_function_name! */
  4895 | prev_declared_derived_function_name
  4912 | prev_declared_derived_function_name
  4896 	{$$ = $1;
  4913 	{$$ = new identifier_c(((token_c *)$1)->value, locloc(@$)); // transform the poutype_identifier_c into an identifier_c
  4897 	 if (get_preparse_state() && !allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
  4914 	 if (get_preparse_state() && !allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
  4898 	}
  4915 	}
  4899 | AND
  4916 | AND
  4900 	{$$ = new identifier_c("AND", locloc(@$));
  4917 	{$$ = new identifier_c("AND", locloc(@$));
  4901 	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
  4918 	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
  4925   FUNCTION derived_function_name END_FUNCTION   /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */
  4942   FUNCTION derived_function_name END_FUNCTION   /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */
  4926 	{$$ = NULL; 
  4943 	{$$ = NULL; 
  4927 	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_derived_function_name_token);}
  4944 	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_derived_function_name_token);}
  4928 	 else                         {print_err_msg(locl(@1), locf(@3), "FUNCTION with no variable declarations and no body."); yynerrs++;}
  4945 	 else                         {print_err_msg(locl(@1), locf(@3), "FUNCTION with no variable declarations and no body."); yynerrs++;}
  4929 	 }
  4946 	 }
  4930 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */
  4947 /* POST_PARSING and STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */
  4931 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
  4948 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
  4932 	{$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$));
  4949 	{$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$));
  4933 	 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
  4950 	 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
  4934 	 variable_name_symtable.pop();
  4951 	 variable_name_symtable.pop();
  4935 	 direct_variable_symtable.pop();
  4952 	 direct_variable_symtable.pop();
  6690  *         | function_name_no_clashes
  6707  *         | function_name_no_clashes
  6691  *       in order to include all possible function names except
  6708  *       in order to include all possible function names except
  6692  *       those whose names coincide with operators !!
  6709  *       those whose names coincide with operators !!
  6693  */
  6710  */
  6694 | function_name_no_clashes
  6711 | function_name_no_clashes
  6695 	{$$ = new il_function_call_c($1, NULL, locloc(@$));}
  6712 	{$$ = new il_function_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6696 /* NOTE: the line
  6713 /* NOTE: the line
  6697  *         | il_simple_operator il_operand
  6714  *         | il_simple_operator il_operand
  6698  *       already contains the 'NOT', 'MOD', etc. operators, followed by a single il_operand.
  6715  *       already contains the 'NOT', 'MOD', etc. operators, followed by a single il_operand.
  6699  *       However, this same code (MOD x) may also be reduced to a function call to the MOD
  6716  *       However, this same code (MOD x) may also be reduced to a function call to the MOD
  6700  *       function. This means that (MOD, AND,...) could be interpret as a function name
  6717  *       function. This means that (MOD, AND,...) could be interpret as a function name
  6718  *       We therefore need to include an extra rule where the
  6735  *       We therefore need to include an extra rule where the
  6719  *       function_name_expression_clashes and function_name_simpleop_clashes
  6736  *       function_name_expression_clashes and function_name_simpleop_clashes
  6720  *       are followed by a il_operand_list with __two__ or more il_operands!!
  6737  *       are followed by a il_operand_list with __two__ or more il_operands!!
  6721  */
  6738  */
  6722 | function_name_no_clashes il_operand_list
  6739 | function_name_no_clashes il_operand_list
  6723 	{$$ = new il_function_call_c($1, $2, locloc(@$));}
  6740 	{$$ = new il_function_call_c($1, $2, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6724 | il_simple_operator_clash il_operand_list2
  6741 | il_simple_operator_clash il_operand_list2
  6725 	{$$ = new il_function_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));}
  6742 	{$$ = new il_function_call_c(il_operator_c_2_poutype_identifier_c($1), $2, locloc(@$));}
  6726 ;
  6743 ;
  6727 
  6744 
  6728 
  6745 
  6729 
  6746 
  6730 il_expression:
  6747 il_expression:
  6879  *       two different routes. I (Mario) chose to interpret them
  6896  *       two different routes. I (Mario) chose to interpret them
  6880  *       as operators, rather than as function calls!
  6897  *       as operators, rather than as function calls!
  6881  *       (AND MOD OR XOR ADD DIV EQ GT GE LT LE MUL NE SUB)
  6898  *       (AND MOD OR XOR ADD DIV EQ GT GE LT LE MUL NE SUB)
  6882  */
  6899  */
  6883   function_name_no_clashes '(' eol_list ')'
  6900   function_name_no_clashes '(' eol_list ')'
  6884 	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$));}
  6901 	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6885 | function_name_simpleop_clashes '(' eol_list ')'
  6902 | function_name_simpleop_clashes '(' eol_list ')'
  6886 	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$));}
  6903 	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6887 /* | function_name '(' eol_list il_param_list ')' */
  6904 /* | function_name '(' eol_list il_param_list ')' */
  6888 /* For the above syntax, we no longer have two ways of interpreting the
  6905 /* For the above syntax, we no longer have two ways of interpreting the
  6889  * same syntax. The above is always a function call!
  6906  * same syntax. The above is always a function call!
  6890  * However, some of the functions that we may be calling
  6907  * However, some of the functions that we may be calling
  6891  * may have the same name as an IL operator. This means that
  6908  * may have the same name as an IL operator. This means that
  6896  * name also coincides with an operator used in ST -> XOR, OR, MOD, AND, NOT)
  6913  * name also coincides with an operator used in ST -> XOR, OR, MOD, AND, NOT)
  6897  *
  6914  *
  6898  * We must therefore interpret the IL operators as function names!
  6915  * We must therefore interpret the IL operators as function names!
  6899  */
  6916  */
  6900 | function_name_no_clashes '(' eol_list il_param_list ')'
  6917 | function_name_no_clashes '(' eol_list il_param_list ')'
  6901 	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$));}
  6918 	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6902 | function_name_simpleop_clashes '(' eol_list il_param_list ')'
  6919 | function_name_simpleop_clashes '(' eol_list il_param_list ')'
  6903 	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$));}
  6920 	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  6904 /* The following line should read:
  6921 /* The following line should read:
  6905  *
  6922  *
  6906  * | function_name_expression_clashes '(' eol_list il_param_list ')'
  6923  * | function_name_expression_clashes '(' eol_list il_param_list ')'
  6907  *
  6924  *
  6908  * but the function_name_expression_clashes had to be first reduced to
  6925  * but the function_name_expression_clashes had to be first reduced to
  6918  * Unfortunately, this work around results in the wrong symbol
  6935  * Unfortunately, this work around results in the wrong symbol
  6919  * being created for the abstract syntax tree.
  6936  * being created for the abstract syntax tree.
  6920  * We need to figure out which symbol was created, destroy it,
  6937  * We need to figure out which symbol was created, destroy it,
  6921  * and create the correct symbol for our case.
  6938  * and create the correct symbol for our case.
  6922  * This is a lot of work, so I put it in a function
  6939  * This is a lot of work, so I put it in a function
  6923  * at the end of this file... il_operator_c_2_identifier_c()
  6940  * at the end of this file... il_operator_c_2_poutype_identifier_c()
  6924  */
  6941  */
  6925 | il_expr_operator_clash_eol_list il_param_list ')'
  6942 | il_expr_operator_clash_eol_list il_param_list ')'
  6926 	{$$ = new il_formal_funct_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));}
  6943 	{$$ = new il_formal_funct_call_c(il_operator_c_2_poutype_identifier_c($1), $2, locloc(@$));}
  6927 /* ERROR_CHECK_BEGIN */
  6944 /* ERROR_CHECK_BEGIN */
  6928 | function_name_no_clashes '(' eol_list error ')'
  6945 | function_name_no_clashes '(' eol_list error ')'
  6929   {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
  6946   {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
  6930 | function_name_simpleop_clashes '(' eol_list error ')'
  6947 | function_name_simpleop_clashes '(' eol_list error ')'
  6931   {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
  6948   {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
  7736  *       letting names clash!
  7753  *       letting names clash!
  7737  */
  7754  */
  7738 function_invocation:
  7755 function_invocation:
  7739 /*  function_name '(' [param_assignment_list] ')' */
  7756 /*  function_name '(' [param_assignment_list] ')' */
  7740   function_name_no_NOT_clashes '(' param_assignment_formal_list ')'
  7757   function_name_no_NOT_clashes '(' param_assignment_formal_list ')'
  7741 	{$$ = new function_invocation_c($1, $3, NULL, locloc(@$));}
  7758 	{$$ = new function_invocation_c($1, $3, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  7742 | function_name_no_NOT_clashes '(' param_assignment_nonformal_list ')'
  7759 | function_name_no_NOT_clashes '(' param_assignment_nonformal_list ')'
  7743 	{$$ = new function_invocation_c($1, NULL, $3, locloc(@$));}
  7760 	{$$ = new function_invocation_c($1, NULL, $3, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
  7744 /* ERROR_CHECK_BEGIN */ 
  7761 /* ERROR_CHECK_BEGIN */ 
  7745 | function_name_no_NOT_clashes param_assignment_formal_list ')'
  7762 | function_name_no_NOT_clashes param_assignment_formal_list ')'
  7746   {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'(' missing after function name in ST expression."); yynerrs++;}
  7763   {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'(' missing after function name in ST expression."); yynerrs++;}
  7747 | function_name_no_NOT_clashes '(' ')'
  7764 | function_name_no_NOT_clashes '(' ')'
  7748   {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no parameter defined in function invocation of ST expression."); yynerrs++;}
  7765   {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no parameter defined in function invocation of ST expression."); yynerrs++;}
  8492 }
  8509 }
  8493 
  8510 
  8494 /* NOTE: this code is very ugly and un-eficient, but I (Mario) have many
  8511 /* NOTE: this code is very ugly and un-eficient, but I (Mario) have many
  8495  *       more things to worry about right now, so just let it be...
  8512  *       more things to worry about right now, so just let it be...
  8496  */
  8513  */
  8497 symbol_c *il_operator_c_2_identifier_c(symbol_c *il_operator) {
  8514 poutype_identifier_c *il_operator_c_2_poutype_identifier_c(symbol_c *il_operator) {
       
  8515   identifier_c         *    id = il_operator_c_2_identifier_c(il_operator);
       
  8516   poutype_identifier_c *pou_id = new poutype_identifier_c(strdup(id->value));
       
  8517 
       
  8518   *(symbol_c *)pou_id = *(symbol_c *)id;
       
  8519   delete id;
       
  8520   return pou_id;
       
  8521 }
       
  8522   
       
  8523 
       
  8524 identifier_c *il_operator_c_2_identifier_c(symbol_c *il_operator) {
  8498   const char *name = NULL;
  8525   const char *name = NULL;
  8499   identifier_c *res;
  8526   identifier_c *res;
  8500 
  8527 
  8501   op_2_str(NOT,   "NOT");
  8528   op_2_str(NOT,   "NOT");
  8502 
  8529 
  8558   op_2_str(JMPC,  "JMPC");
  8585   op_2_str(JMPC,  "JMPC");
  8559   op_2_str(JMPCN, "JMPCN");
  8586   op_2_str(JMPCN, "JMPCN");
  8560 
  8587 
  8561   if (name == NULL)
  8588   if (name == NULL)
  8562     ERROR;
  8589     ERROR;
  8563 
  8590 /*
  8564   res = new identifier_c(strdup(name), 
  8591   res = new identifier_c(strdup(name), 
  8565                          il_operator->first_line,
  8592                          il_operator->first_line,
  8566                          il_operator->first_column,
  8593                          il_operator->first_column,
  8567                          il_operator->first_file,
  8594                          il_operator->first_file,
  8568                          il_operator->first_order,
  8595                          il_operator->first_order,
  8570                          il_operator->last_column,
  8597                          il_operator->last_column,
  8571                          il_operator->last_file,
  8598                          il_operator->last_file,
  8572                          il_operator->last_order
  8599                          il_operator->last_order
  8573                         );
  8600                         );
  8574   free(il_operator);
  8601   free(il_operator);
       
  8602 */
       
  8603   res = new identifier_c(strdup(name));
       
  8604   *(symbol_c *)res = *(symbol_c *)il_operator;
       
  8605   delete il_operator;
       
  8606   
  8575   return res;
  8607   return res;
  8576 }
  8608 }
  8577 
  8609 
  8578 
  8610 
  8579 #include "standard_function_names.c"
  8611 #include "standard_function_names.c"