stage1_2/iec.y
changeset 1 5d893a68be6e
parent 0 fb772792efd1
child 3 38850ee685e6
equal deleted inserted replaced
0:fb772792efd1 1:5d893a68be6e
   788 
   788 
   789 /********************************************/
   789 /********************************************/
   790 /* B 1.6 Sequential Function Chart elements */
   790 /* B 1.6 Sequential Function Chart elements */
   791 /********************************************/
   791 /********************************************/
   792 /* TODO */
   792 /* TODO */
   793 /*
   793 
   794 %type  <list>	sequential_function_chart
   794 %type  <list>	sequential_function_chart
   795 %type  <leaf>	sfc_network
   795 %type  <list>	sfc_network
   796 %type  <leaf>	initial_step
   796 %type  <leaf>	initial_step
   797 %type  <leaf>	step
   797 %type  <leaf>	step
   798 %type  <leaf>	action_association_list
   798 %type  <list>	action_association_list
   799 %type  <leaf>	step_name
   799 %type  <leaf>	step_name
   800 %type  <leaf>	action_association
   800 %type  <leaf>	action_association
   801 /* helper symbol for action_association *
   801 /* helper symbol for action_association */
   802 %type  <list>	indicator_name_list
   802 %type  <list>	indicator_name_list
   803 %type  <leaf>	action_name
   803 %type  <leaf>	action_name
   804 %type  <leaf>	action_qualifier
   804 %type  <leaf>	action_qualifier
       
   805 %type  <leaf>	qualifier
   805 %type  <leaf>	timed_qualifier
   806 %type  <leaf>	timed_qualifier
   806 %type  <leaf>	action_time
   807 %type  <leaf>	action_time
   807 %type  <leaf>	indicator_name
   808 %type  <leaf>	indicator_name
   808 %type  <leaf>	transition
   809 %type  <leaf>	transition
   809 %type  <leaf>	steps
   810 %type  <leaf>	steps
   810 %type  <list>	step_name_list
   811 %type  <list>	step_name_list
   811 %type  <leaf>	transition_condition
   812 %type  <leaf>	transition_condition
   812 %type  <leaf>	action
   813 %type  <leaf>	action
   813 */
   814 %type  <leaf>	transition_name
       
   815 
   814 
   816 
   815 %token ASSIGN
   817 %token ASSIGN
   816 %token ACTION
   818 %token ACTION
   817 %token END_ACTION
   819 %token END_ACTION
   818 
   820 
  1540 | RETC_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1542 | RETC_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1541 | RETCN_operator	{$$ = il_operator_c_2_identifier_c($1);}
  1543 | RETCN_operator	{$$ = il_operator_c_2_identifier_c($1);}
  1542 | JMP_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1544 | JMP_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1543 | JMPC_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1545 | JMPC_operator		{$$ = il_operator_c_2_identifier_c($1);}
  1544 | JMPCN_operator	{$$ = il_operator_c_2_identifier_c($1);}
  1546 | JMPCN_operator	{$$ = il_operator_c_2_identifier_c($1);}
  1545 /**/
       
  1546 | L		{$$ = new identifier_c(strdup("L"));}
       
  1547 | D		{$$ = new identifier_c(strdup("D"));}
       
  1548 | SD		{$$ = new identifier_c(strdup("SD"));}
       
  1549 | DS		{$$ = new identifier_c(strdup("DS"));}
       
  1550 | SL		{$$ = new identifier_c(strdup("SL"));}
       
  1551 | N		{$$ = new identifier_c(strdup("N"));}
       
  1552 /* NOTE: the following two clash with the R and S IL operators.
       
  1553  * It will have to be handled when we include parsing of SFC...
       
  1554  */
       
  1555 /*
       
  1556 | R		{$$ = new identifier_c(strdup("R"));}
       
  1557 | S		{$$ = new identifier_c(strdup("S"));}
       
  1558 */
       
  1559 | P		{$$ = new identifier_c(strdup("P"));}
       
  1560 
       
  1561 ;
  1547 ;
  1562 
  1548 
  1563 /*********************/
  1549 /*********************/
  1564 /* B 1.2 - Constants */
  1550 /* B 1.2 - Constants */
  1565 /*********************/
  1551 /*********************/
  3564 
  3550 
  3565 
  3551 
  3566 function_block_body:
  3552 function_block_body:
  3567   statement_list	{$$ = $1;}
  3553   statement_list	{$$ = $1;}
  3568 | instruction_list	{$$ = $1;}
  3554 | instruction_list	{$$ = $1;}
       
  3555 | sequential_function_chart	{$$ = $1;}
  3569 /*
  3556 /*
  3570 | sequential_function_chart
       
  3571 | ladder_diagram
  3557 | ladder_diagram
  3572 | function_block_diagram
  3558 | function_block_diagram
  3573 | <other languages>
  3559 | <other languages>
  3574 */
  3560 */
  3575 ;
  3561 ;
  3640 */
  3626 */
  3641 
  3627 
  3642 
  3628 
  3643 
  3629 
  3644 /********************************************/
  3630 /********************************************/
  3645 /* B 1.6 Sequential Function Chart elements */
  3631 /* B 1.6 Sequential Function Chart elements *
  3646 /********************************************/
  3632 /********************************************/////////////////////////////////////////////////////////////////////////////////////////////
  3647 /* TODO ... */
  3633 /* TODO ... */
  3648 
  3634 
  3649 /*
       
  3650 sequential_function_chart:
  3635 sequential_function_chart:
  3651   sfc_network
  3636   sfc_network
       
  3637 	{$$ = new sequential_function_chart_c(); $$->add_element($1);}
  3652 | sequential_function_chart sfc_network
  3638 | sequential_function_chart sfc_network
       
  3639 	{$$ = $1; $$->add_element($2);}
  3653 ;
  3640 ;
  3654 
  3641 
  3655 sfc_network:
  3642 sfc_network:
  3656   initial_step
  3643   initial_step
       
  3644 	{$$ = new sfc_network_c(); $$->add_element($1);}
  3657 | sfc_network step
  3645 | sfc_network step
       
  3646 	{$$ = $1; $$->add_element($2);}
  3658 | sfc_network transition
  3647 | sfc_network transition
       
  3648 	{$$ = $1; $$->add_element($2);}
  3659 | sfc_network action
  3649 | sfc_network action
       
  3650 	{$$ = $1; $$->add_element($2);}
  3660 ;
  3651 ;
  3661 
  3652 
  3662 initial_step:
  3653 initial_step:
  3663   INITIAL_STEP step_name ':' action_association_list END_STEP
  3654   INITIAL_STEP step_name ':' action_association_list END_STEP
       
  3655 	{$$ = new initial_step_c($2, $4);}
  3664 ;
  3656 ;
  3665 
  3657 
  3666 step:
  3658 step:
  3667   STEP step_name ':' action_association_list END_STEP
  3659   STEP step_name ':' action_association_list END_STEP
       
  3660 	{$$ = new step_c($2, $4);}
  3668 ;
  3661 ;
  3669 
  3662 
  3670 /* helper symbol for:
  3663 /* helper symbol for:
  3671  *  - initial_step
  3664  *  - initial_step
  3672  *  - step
  3665  *  - step
  3673  *
  3666  */
  3674 action_association_list:
  3667 action_association_list:
  3675   /* empty *
  3668   /* empty */
       
  3669 	{$$ = new action_association_list_c();}
  3676 | action_association_list action_association ';'
  3670 | action_association_list action_association ';'
  3677 ;
  3671 	{$$ = $1; $$->add_element($2);}
       
  3672 ;
       
  3673 
  3678 
  3674 
  3679 step_name: identifier;
  3675 step_name: identifier;
  3680 
  3676 
  3681 action_association:
  3677 action_association:
  3682   action_name '(' action_qualifier indicator_name_list ')'
  3678   action_name '(' action_qualifier indicator_name_list ')'
  3683 ;
  3679 	{$$ = new action_association_c($1, $3, $4, NULL);}
  3684 
  3680 ;
  3685 /* helper symbol for action_association *
  3681 
       
  3682 /* helper symbol for action_association */
  3686 indicator_name_list:
  3683 indicator_name_list:
  3687   /* empty *
  3684   /* empty */
       
  3685 	{$$ = new indicator_name_list_c();}
  3688 | indicator_name_list ',' indicator_name
  3686 | indicator_name_list ',' indicator_name
       
  3687 	{$$ = $1; $$->add_element($3);}
  3689 ;
  3688 ;
  3690 
  3689 
  3691 action_name: identifier;
  3690 action_name: identifier;
  3692 
  3691 
  3693 action_qualifier:
  3692 action_qualifier:
  3694   /* empty *
  3693   /* empty */
  3695 | N
  3694 	{$$ = NULL;}
  3696 | R
  3695 | qualifier
  3697 | S
  3696 	{$$ = new action_qualifier_c($1, NULL);}
  3698 | P
       
  3699 | timed_qualifier ',' action_time
  3697 | timed_qualifier ',' action_time
       
  3698 	{$$ = new action_qualifier_c($1, $3);}
       
  3699 ;
       
  3700 
       
  3701 //N_token: N 	{$$ = new N_token_c();};
       
  3702 
       
  3703 qualifier:
       
  3704 N		{$$ = new qualifier_c(strdup("N"));}
       
  3705 /* NOTE: the following two clash with the R and S IL operators.
       
  3706  * It will have to be handled when we include parsing of SFC...
       
  3707  */
       
  3708 /*
       
  3709 | R		{$$ = new identifier_c(strdup("R"));}
       
  3710 | S		{$$ = new identifier_c(strdup("S"));}
       
  3711 */
       
  3712 | P		{$$ = new qualifier_c(strdup("P"));}
  3700 ;
  3713 ;
  3701 
  3714 
  3702 timed_qualifier:
  3715 timed_qualifier:
  3703   L
  3716 L		{$$ = new timed_qualifier_c(strdup("L"));}
  3704 | D
  3717 | D		{$$ = new timed_qualifier_c(strdup("D"));}
  3705 | SD
  3718 | SD		{$$ = new timed_qualifier_c(strdup("SD"));}
  3706 | DS
  3719 | DS		{$$ = new timed_qualifier_c(strdup("DS"));}
  3707 | SL
  3720 | SL		{$$ = new timed_qualifier_c(strdup("SL"));}
  3708 ;
  3721 ;
  3709 
  3722 
  3710 action_time:
  3723 action_time:
  3711   duration
  3724   duration
  3712 | variable_name
  3725 | variable_name
       
  3726 | transition_name
  3713 ;
  3727 ;
  3714 
  3728 
  3715 indicator_name: variable_name;
  3729 indicator_name: variable_name;
  3716 
  3730 
  3717 transition:
  3731 transition:
  3718   TRANSITION FROM steps TO steps transition_condition END_TRANSITION
  3732   TRANSITION FROM steps TO steps transition_condition END_TRANSITION
       
  3733 	{$$ = new transition_c(NULL, NULL, $3, $5, $6, NULL);}
  3719 | TRANSITION transition_name FROM steps TO steps transition_condition END_TRANSITION
  3734 | TRANSITION transition_name FROM steps TO steps transition_condition END_TRANSITION
       
  3735 	{$$ = new transition_c($2, NULL, $4, $6, $7, NULL);}
  3720 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps transition_condition END_TRANSITION
  3736 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps transition_condition END_TRANSITION
       
  3737 	{$$ = new transition_c(NULL, $5, $8, $10, $11, NULL);}
  3721 | TRANSITION transition_name '(' PRIORITY ASSIGN integer ')' FROM steps TO steps transition_condition END_TRANSITION
  3738 | TRANSITION transition_name '(' PRIORITY ASSIGN integer ')' FROM steps TO steps transition_condition END_TRANSITION
       
  3739 	{$$ = new transition_c($2, $6, $9, $11, $12, NULL);}
  3722 ;
  3740 ;
  3723 
  3741 
  3724 transition_name: identifier;
  3742 transition_name: identifier;
  3725 
  3743 
  3726 steps:
  3744 steps:
  3727   step_name
  3745   step_name
       
  3746 	{$$ = new steps_c($1, NULL);}
  3728 | '(' step_name_list ')'
  3747 | '(' step_name_list ')'
  3729 ;
  3748 	{$$ = new steps_c(NULL, $2);}
  3730 
  3749 ;
  3731 
  3750 
  3732 step_name_list:
  3751 step_name_list:
  3733   step_name ',' step_name
  3752   step_name ',' step_name
       
  3753 	{$$ = new step_name_list_c(); $$->add_element($1); $$->add_element($3);}
  3734 | step_name_list ',' step_name
  3754 | step_name_list ',' step_name
  3735 ;
  3755 	{$$ = $1; $$->add_element($3);}
  3736 
  3756 ;
  3737 
  3757 
  3738 transition_condition:
  3758 transition_condition:
  3739   ':' simple_instruction_list
  3759   ':' simple_instr_list
       
  3760 	{$$ = new transition_condition_c($2, NULL);} 
  3740 | ASSIGN expression ';'
  3761 | ASSIGN expression ';'
  3741 | ':' fbd_network
  3762 	{$$ = new transition_condition_c(NULL, $2);} 
  3742 | ':' rung
       
  3743 ;
  3763 ;
  3744 
  3764 
  3745 action:
  3765 action:
  3746   ACTION action_name ':' function_block_body END_ACTION
  3766   ACTION action_name ':' function_block_body END_ACTION
  3747 ;
  3767 	{$$ = new action_c($2, $4);}
  3748 */
  3768 ;
       
  3769 
  3749 
  3770 
  3750 /********************************/
  3771 /********************************/
  3751 /* B 1.7 Configuration elements */
  3772 /* B 1.7 Configuration elements */
  3752 /********************************/
  3773 /********************************/
  3753 /* NOTE:
  3774 /* NOTE: