541 %type <leaf> enumerated_spec_init |
547 %type <leaf> enumerated_spec_init |
542 %type <leaf> enumerated_specification |
548 %type <leaf> enumerated_specification |
543 /* helper symbol for enumerated_value */ |
549 /* helper symbol for enumerated_value */ |
544 %type <list> enumerated_value_list |
550 %type <list> enumerated_value_list |
545 %type <leaf> enumerated_value |
551 %type <leaf> enumerated_value |
|
552 %type <leaf> enumerated_value_without_identifier |
546 |
553 |
547 %type <leaf> array_type_declaration |
554 %type <leaf> array_type_declaration |
548 %type <leaf> array_spec_init |
555 %type <leaf> array_spec_init |
549 %type <leaf> array_specification |
556 %type <leaf> array_specification |
550 /* helper symbol for array_specification */ |
557 /* helper symbol for array_specification */ |
795 |
802 |
796 |
803 |
797 /********************************************/ |
804 /********************************************/ |
798 /* B 1.6 Sequential Function Chart elements */ |
805 /* B 1.6 Sequential Function Chart elements */ |
799 /********************************************/ |
806 /********************************************/ |
800 /* TODO */ |
|
801 |
807 |
802 %type <list> sequential_function_chart |
808 %type <list> sequential_function_chart |
803 %type <list> sfc_network |
809 %type <list> sfc_network |
804 %type <leaf> initial_step |
810 %type <leaf> initial_step |
805 %type <leaf> step |
811 %type <leaf> step |
2313 | prev_declared_enumerated_type_name '#' any_identifier |
2319 | prev_declared_enumerated_type_name '#' any_identifier |
2314 {$$ = new enumerated_value_c($1, $3);} |
2320 {$$ = new enumerated_value_c($1, $3);} |
2315 ; |
2321 ; |
2316 |
2322 |
2317 |
2323 |
|
2324 enumerated_value_without_identifier: |
|
2325 prev_declared_enumerated_type_name '#' any_identifier |
|
2326 {$$ = new enumerated_value_c($1, $3);} |
|
2327 ; |
|
2328 |
2318 |
2329 |
2319 array_type_declaration: |
2330 array_type_declaration: |
2320 /* array_type_name ':' array_spec_init */ |
2331 /* array_type_name ':' array_spec_init */ |
2321 identifier ':' array_spec_init |
2332 identifier ':' array_spec_init |
2322 {$$ = new array_type_declaration_c($1, $3); |
2333 {$$ = new array_type_declaration_c($1, $3); |
2522 |
2533 |
2523 symbolic_variable: |
2534 symbolic_variable: |
2524 /* NOTE: To be entirely correct, variable_name should be replacemed by |
2535 /* NOTE: To be entirely correct, variable_name should be replacemed by |
2525 * prev_declared_variable_name | prev_declared_fb_name | prev_declared_global_var_name |
2536 * prev_declared_variable_name | prev_declared_fb_name | prev_declared_global_var_name |
2526 */ |
2537 */ |
2527 prev_declared_variable_name |
2538 identifier |
2528 {$$ = new symbolic_variable_c($1);} |
2539 {$$ = new symbolic_variable_c($1);} |
2529 | prev_declared_fb_name |
2540 | prev_declared_fb_name |
2530 {$$ = new symbolic_variable_c($1);} |
2541 {$$ = new symbolic_variable_c($1);} |
2531 | prev_declared_global_var_name |
2542 | prev_declared_global_var_name |
|
2543 {$$ = new symbolic_variable_c($1);} |
|
2544 | prev_declared_variable_name |
2532 {$$ = new symbolic_variable_c($1);} |
2545 {$$ = new symbolic_variable_c($1);} |
2533 | multi_element_variable |
2546 | multi_element_variable |
2534 ; |
2547 ; |
2535 |
2548 |
2536 |
2549 |
3660 {$$ = $1; $$->add_element($2);} |
3673 {$$ = $1; $$->add_element($2);} |
3661 ; |
3674 ; |
3662 |
3675 |
3663 initial_step: |
3676 initial_step: |
3664 INITIAL_STEP step_name ':' action_association_list END_STEP |
3677 INITIAL_STEP step_name ':' action_association_list END_STEP |
|
3678 // INITIAL_STEP identifier ':' action_association_list END_STEP |
3665 {$$ = new initial_step_c($2, $4);} |
3679 {$$ = new initial_step_c($2, $4);} |
3666 ; |
3680 ; |
3667 |
3681 |
3668 step: |
3682 step: |
3669 STEP step_name ':' action_association_list END_STEP |
3683 STEP step_name ':' action_association_list END_STEP |
|
3684 // STEP identifier ':' action_association_list END_STEP |
3670 {$$ = new step_c($2, $4);} |
3685 {$$ = new step_c($2, $4);} |
3671 ; |
3686 ; |
3672 |
3687 |
3673 /* helper symbol for: |
3688 /* helper symbol for: |
3674 * - initial_step |
3689 * - initial_step |
3680 | action_association_list action_association ';' |
3695 | action_association_list action_association ';' |
3681 {$$ = $1; $$->add_element($2);} |
3696 {$$ = $1; $$->add_element($2);} |
3682 ; |
3697 ; |
3683 |
3698 |
3684 |
3699 |
3685 step_name: identifier; |
3700 // step_name: identifier; |
|
3701 step_name: any_identifier; |
3686 |
3702 |
3687 action_association: |
3703 action_association: |
3688 action_name '(' action_qualifier indicator_name_list ')' |
3704 action_name '(' action_qualifier indicator_name_list ')' |
3689 {$$ = new action_association_c($1, $3, $4, NULL);} |
3705 {$$ = new action_association_c($1, $3, $4, NULL);} |
3690 ; |
3706 ; |
3749 {$$ = new step_name_list_c(); $$->add_element($1); $$->add_element($3);} |
3768 {$$ = new step_name_list_c(); $$->add_element($1); $$->add_element($3);} |
3750 | step_name_list ',' step_name |
3769 | step_name_list ',' step_name |
3751 {$$ = $1; $$->add_element($3);} |
3770 {$$ = $1; $$->add_element($3);} |
3752 ; |
3771 ; |
3753 |
3772 |
|
3773 |
3754 transition_header: |
3774 transition_header: |
3755 TRANSITION FROM steps TO steps |
3775 TRANSITION FROM steps TO steps |
3756 {$$.first = NULL; $$.second = NULL; $$.third = $3; $$.fourth = $5; cmd_goto_body_state();} |
3776 {$$.first = NULL; $$.second = NULL; $$.third = $3; $$.fourth = $5; cmd_goto_body_state();} |
3757 | TRANSITION transition_name FROM steps TO steps |
3777 | TRANSITION transition_name FROM steps TO steps |
|
3778 //| TRANSITION identifier FROM steps TO steps |
3758 {$$.first = $2; $$.second = NULL; $$.third = $4; $$.fourth = $6; cmd_goto_body_state();} |
3779 {$$.first = $2; $$.second = NULL; $$.third = $4; $$.fourth = $6; cmd_goto_body_state();} |
3759 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps |
3780 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps |
3760 {$$.first = NULL; $$.second = $5; $$.third = $8; $$.fourth = $10; cmd_goto_body_state();} |
3781 {$$.first = NULL; $$.second = $5; $$.third = $8; $$.fourth = $10; cmd_goto_body_state();} |
3761 | TRANSITION transition_name '(' PRIORITY ASSIGN integer ')' FROM steps TO steps |
3782 | TRANSITION transition_name '(' PRIORITY ASSIGN integer ')' FROM steps TO steps |
|
3783 //| TRANSITION identifier '(' PRIORITY ASSIGN integer ')' FROM steps TO steps |
3762 {$$.first = $2; $$.second = $6; $$.third = $9; $$.fourth = $11; cmd_goto_body_state();} |
3784 {$$.first = $2; $$.second = $6; $$.third = $9; $$.fourth = $11; cmd_goto_body_state();} |
3763 ; |
3785 ; |
3764 |
3786 |
3765 transition_condition_il: |
3787 transition_condition_il: |
3766 ':' eol_list simple_instr_list |
3788 ':' eol_list simple_instr_list |
3779 {$$ = new transition_c($1.first, $1.second, $1.third, $1.fourth, NULL, $2);} |
3801 {$$ = new transition_c($1.first, $1.second, $1.third, $1.fourth, NULL, $2);} |
3780 ; |
3802 ; |
3781 |
3803 |
3782 action_header: |
3804 action_header: |
3783 ACTION action_name ':' |
3805 ACTION action_name ':' |
|
3806 // ACTION identifier ':' |
3784 {$$.first = $2; cmd_goto_body_state();} |
3807 {$$.first = $2; cmd_goto_body_state();} |
3785 ; |
3808 ; |
3786 |
3809 |
3787 |
3810 |
3788 action: |
3811 action: |
3923 RESOURCE {variable_name_symtable.push();} resource_name ON resource_type_name |
3946 RESOURCE {variable_name_symtable.push();} resource_name ON resource_type_name |
3924 optional_global_var_declarations |
3947 optional_global_var_declarations |
3925 single_resource_declaration |
3948 single_resource_declaration |
3926 END_RESOURCE |
3949 END_RESOURCE |
3927 {$$ = new resource_declaration_c($3, $5, $6, $7); |
3950 {$$ = new resource_declaration_c($3, $5, $6, $7); |
3928 variable_name_symtable.pop(); |
3951 variable_name_symtable.pop(); |
3929 variable_name_symtable.insert($3, prev_declared_resource_name_token); |
3952 variable_name_symtable.insert($3, prev_declared_resource_name_token); |
3930 } |
3953 } |
3931 ; |
3954 ; |
3932 |
3955 |
3933 |
3956 |
4255 ; |
4278 ; |
4256 */ |
4279 */ |
4257 |
4280 |
4258 instruction_list: |
4281 instruction_list: |
4259 il_instruction |
4282 il_instruction |
|
4283 {$$ = new instruction_list_c(); $$->add_element($1);} |
|
4284 | pragma eol_list |
4260 {$$ = new instruction_list_c(); $$->add_element($1);} |
4285 {$$ = new instruction_list_c(); $$->add_element($1);} |
4261 | instruction_list il_instruction |
4286 | instruction_list il_instruction |
4262 {$$ = $1; $$->add_element($2);} |
4287 {$$ = $1; $$->add_element($2);} |
4263 | instruction_list pragma |
4288 | instruction_list pragma |
4264 {$$ = $1; $$->add_element($2);} |
4289 {$$ = $1; $$->add_element($2);} |
4853 * (i.e. the constant 9, preceded by a unary negation) |
4882 * (i.e. the constant 9, preceded by a unary negation) |
4854 * |
4883 * |
4855 * To remove the conlfict, we only allow constants without |
4884 * To remove the conlfict, we only allow constants without |
4856 * a preceding '-' to be used in primary_expression |
4885 * a preceding '-' to be used in primary_expression |
4857 */ |
4886 */ |
|
4887 /* NOTE: We use enumerated_value_without_identifier instead of enumerated_value |
|
4888 * in order to remove a reduce/reduce conflict between reducing an |
|
4889 * identifier to a variable or an enumerated_value. |
|
4890 */ |
4858 primary_expression: |
4891 primary_expression: |
4859 /* constant */ |
4892 /* constant */ |
4860 non_negative_constant |
4893 non_negative_constant |
4861 | enumerated_value |
4894 | enumerated_value_without_identifier |
4862 | variable |
4895 | variable |
4863 | '(' expression ')' |
4896 | '(' expression ')' |
4864 {$$ = $2;} |
4897 {$$ = $2;} |
4865 | function_invocation |
4898 | function_invocation |
4866 ; |
4899 ; |
4901 |
4934 |
4902 /********************/ |
4935 /********************/ |
4903 /* B 3.2 Statements */ |
4936 /* B 3.2 Statements */ |
4904 /********************/ |
4937 /********************/ |
4905 statement_list: |
4938 statement_list: |
4906 /* empty */ |
4939 statement ';' |
4907 {$$ = new statement_list_c();} |
4940 {$$ = new statement_list_c(); $$->add_element($1);} |
|
4941 | pragma |
|
4942 {$$ = new statement_list_c(); $$->add_element($1);} |
4908 | statement_list statement ';' |
4943 | statement_list statement ';' |
4909 {$$ = $1; $$->add_element($2);} |
4944 {$$ = $1; $$->add_element($2);} |
4910 | statement_list pragma |
4945 | statement_list pragma |
4911 {$$ = $1; $$->add_element($2);} |
4946 {$$ = $1; $$->add_element($2);} |
4912 | statement_list error ';' |
4947 | statement_list error ';' |
5088 * (Section 3.3.2.4) as being of an integer type |
5129 * (Section 3.3.2.4) as being of an integer type |
5089 * (e.g., SINT, INT, or DINT). |
5130 * (e.g., SINT, INT, or DINT). |
5090 * |
5131 * |
5091 * Obviously this presuposes that the control_variable |
5132 * Obviously this presuposes that the control_variable |
5092 * must have been declared in some VAR .. END_VAR |
5133 * must have been declared in some VAR .. END_VAR |
5093 * construct, so I (Mario) changed the syntax to read |
5134 * We could therefore change the syntax to read |
5094 * control_variable: prev_declared_variable_name; |
5135 * control_variable: prev_declared_variable_name; |
|
5136 * |
|
5137 * However, it is probaly best if we leave the semantic checks |
|
5138 * to the semantic analyser of pass 2. |
5095 */ |
5139 */ |
5096 control_variable: prev_declared_variable_name {$$ = $1;}; |
5140 // control_variable: prev_declared_variable_name {$$ = $1;}; |
|
5141 control_variable: identifier {$$ = $1;}; |
5097 |
5142 |
5098 /* Integrated directly into for_statement */ |
5143 /* Integrated directly into for_statement */ |
5099 /* |
5144 /* |
5100 for_list: |
5145 for_list: |
5101 expression TO expression [BY expression] |
5146 expression TO expression [BY expression] |