536 SYM_REF2(var1_init_decl_c, var1_list, spec_init) |
536 SYM_REF2(var1_init_decl_c, var1_list, spec_init) |
537 |
537 |
538 /* | var1_list ',' variable_name */ |
538 /* | var1_list ',' variable_name */ |
539 SYM_LIST(var1_list_c) |
539 SYM_LIST(var1_list_c) |
540 |
540 |
|
541 /* | [var1_list ','] variable_name integer '..' */ |
|
542 /* NOTE: This is an extension to the standard!!! */ |
|
543 /* In order to be able to handle extensible standard functions |
|
544 * (i.e. standard functions that may have a variable number of |
|
545 * input parameters, such as AND(word#33, word#44, word#55, word#66), |
|
546 * we have extended the acceptable syntax to allow var_name '..' |
|
547 * in an input variable declaration. |
|
548 * |
|
549 * This allows us to parse the declaration of standard |
|
550 * extensible functions and load their interface definition |
|
551 * into the abstract syntax tree just like we do to other |
|
552 * user defined functions. |
|
553 * This has the advantage that we can later do semantic |
|
554 * checking of calls to functions (be it a standard or user defined |
|
555 * function) in (almost) exactly the same way. |
|
556 * |
|
557 * The integer tells the compiler the number of the first parameter. |
|
558 * for example, for ADD(IN1 := 11, IN2:=22), the index for IN starts off at 1. |
|
559 * Some other standard library functions, such as MUX, has the extensible |
|
560 * variable starting off from 0 (IN0, IN1, IN2, ...). |
|
561 * |
|
562 * Of course, we have a flag that disables this syntax when parsing user |
|
563 * written code, so we only allow this extra syntax while parsing the |
|
564 * 'header' file that declares all the standard IEC 61131-3 functions. |
|
565 */ |
|
566 SYM_REF2(extensible_input_parameter_c, var_name, first_index) |
|
567 |
541 /* var1_list ':' array_spec_init */ |
568 /* var1_list ':' array_spec_init */ |
542 SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
569 SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
543 |
570 |
544 /* var1_list ':' initialized_structure */ |
571 /* var1_list ':' initialized_structure */ |
545 SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
572 SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
630 SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) |
657 SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) |
631 |
658 |
632 /* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
659 /* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
633 /* integer ->may be NULL ! */ |
660 /* integer ->may be NULL ! */ |
634 /* single_byte_character_string ->may be NULL ! */ |
661 /* single_byte_character_string ->may be NULL ! */ |
635 SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) |
662 SYM_REF2(single_byte_string_spec_c, string_spec, single_byte_character_string) |
|
663 |
|
664 /* STRING ['[' integer ']'] */ |
|
665 /* integer ->may be NULL ! */ |
|
666 SYM_REF2(single_byte_limited_len_string_spec_c, string_type_name, character_string_len) |
|
667 |
|
668 /* WSTRING ['[' integer ']'] */ |
|
669 /* integer ->may be NULL ! */ |
|
670 SYM_REF2(double_byte_limited_len_string_spec_c, string_type_name, character_string_len) |
636 |
671 |
637 /* var1_list ':' double_byte_string_spec */ |
672 /* var1_list ':' double_byte_string_spec */ |
638 SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) |
673 SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) |
639 |
674 |
640 /* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
675 /* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
641 /* integer ->may be NULL ! */ |
676 /* integer ->may be NULL ! */ |
642 /* double_byte_character_string ->may be NULL ! */ |
677 /* double_byte_character_string ->may be NULL ! */ |
643 SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) |
678 SYM_REF2(double_byte_string_spec_c, string_spec, double_byte_character_string) |
644 |
679 |
645 /*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ |
680 /*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ |
646 /* option ->may be NULL ! */ |
681 /* option ->may be NULL ! */ |
647 SYM_REF2(incompl_located_var_declarations_c, option, incompl_located_var_decl_list) |
682 SYM_REF2(incompl_located_var_declarations_c, option, incompl_located_var_decl_list) |
648 |
683 |
883 |
918 |
884 /* | il_simple_operator [il_operand] */ |
919 /* | il_simple_operator [il_operand] */ |
885 SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand) |
920 SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand) |
886 |
921 |
887 /* | function_name [il_operand_list] */ |
922 /* | function_name [il_operand_list] */ |
888 SYM_REF2(il_function_call_c, function_name, il_operand_list) |
923 /* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. |
|
924 * See the comment above function_invocation_c for more details |
|
925 */ |
|
926 SYM_REF2(il_function_call_c, function_name, il_operand_list, symbol_c *called_function_declaration; int extensible_param_count;) |
889 |
927 |
890 |
928 |
891 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ |
929 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ |
892 SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list) |
930 SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list) |
893 |
931 |
902 */ |
940 */ |
903 SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list) |
941 SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list) |
904 |
942 |
905 |
943 |
906 /* | function_name '(' eol_list [il_param_list] ')' */ |
944 /* | function_name '(' eol_list [il_param_list] ')' */ |
907 SYM_REF2(il_formal_funct_call_c, function_name, il_param_list) |
945 /* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. |
|
946 * See the comment above function_invocation_c for more details |
|
947 */ |
|
948 SYM_REF2(il_formal_funct_call_c, function_name, il_param_list, symbol_c *called_function_declaration; int extensible_param_count;) |
908 |
949 |
909 /* | il_operand_list ',' il_operand */ |
950 /* | il_operand_list ',' il_operand */ |
910 SYM_LIST(il_operand_list_c) |
951 SYM_LIST(il_operand_list_c) |
911 |
952 |
912 /* | simple_instr_list il_simple_instruction */ |
953 /* | simple_instr_list il_simple_instruction */ |
1002 SYM_REF1(neg_expression_c, exp) |
1043 SYM_REF1(neg_expression_c, exp) |
1003 SYM_REF1(not_expression_c, exp) |
1044 SYM_REF1(not_expression_c, exp) |
1004 |
1045 |
1005 /* formal_param_list -> may be NULL ! */ |
1046 /* formal_param_list -> may be NULL ! */ |
1006 /* nonformal_param_list -> may be NULL ! */ |
1047 /* nonformal_param_list -> may be NULL ! */ |
1007 SYM_REF3(function_invocation_c, function_name, formal_param_list, nonformal_param_list) |
1048 /* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. |
|
1049 * The IEC 61131-3 standard allows for overloaded standard functions. This means that some |
|
1050 * function calls are not compeletely defined by the name of the function being called, |
|
1051 * and need to be disambiguated with using the data types of the parameters being passed. |
|
1052 * Stage 3 does this to verify semantic correctnes. |
|
1053 * Stage 4 also needs to do this in order to determine which function to call. |
|
1054 * It does not make sense to determine the exact function being called twice (once in stage 3, |
|
1055 * and again in stage 4), so stage 3 will store this infor in the parameter called_function_declaration |
|
1056 * for stage 4 to use it later on. |
|
1057 */ |
|
1058 SYM_REF3(function_invocation_c, function_name, formal_param_list, nonformal_param_list, symbol_c *called_function_declaration; int extensible_param_count;) |
1008 |
1059 |
1009 |
1060 |
1010 /********************/ |
1061 /********************/ |
1011 /* B 3.2 Statements */ |
1062 /* B 3.2 Statements */ |
1012 /********************/ |
1063 /********************/ |