stage1_2/iec.y
changeset 3 38850ee685e6
parent 1 5d893a68be6e
child 5 8860f9917bbc
equal deleted inserted replaced
2:cecf2a950ec8 3:38850ee685e6
   166 /************************/
   166 /************************/
   167 /* forward declarations */
   167 /* forward declarations */
   168 /************************/
   168 /************************/
   169 /* The functions declared here are defined in iec.flex... */
   169 /* The functions declared here are defined in iec.flex... */
   170 void print_include_stack(void);
   170 void print_include_stack(void);
   171 
   171 void cmd_goto_body_state(void);
       
   172 int  get_goto_body_state(void);
       
   173 void rst_goto_body_state(void);
   172 
   174 
   173 %}
   175 %}
   174 
   176 
   175 
   177 
   176 
   178 
   179     list_c	*list;
   181     list_c	*list;
   180     char 	*ID;	/* token value */
   182     char 	*ID;	/* token value */
   181     struct {
   183     struct {
   182       symbol_c	*first;
   184       symbol_c	*first;
   183       symbol_c	*second;
   185       symbol_c	*second;
   184     } double_symbol; /* used by il_simple_operator_clash_il_operand */
   186       symbol_c	*third;
       
   187       symbol_c	*fourth;
       
   188     } tmp_symbol; /* used as a temorary reference to symbols by:
       
   189                                      il_simple_operator_clash_il_operand
       
   190                                      transaction_tmp
       
   191                                      action_tmp
       
   192                              */
   185 }
   193 }
   186 
   194 
   187 
   195 
   188 
   196 
   189 
   197 
   807 %type  <leaf>	action_time
   815 %type  <leaf>	action_time
   808 %type  <leaf>	indicator_name
   816 %type  <leaf>	indicator_name
   809 %type  <leaf>	transition
   817 %type  <leaf>	transition
   810 %type  <leaf>	steps
   818 %type  <leaf>	steps
   811 %type  <list>	step_name_list
   819 %type  <list>	step_name_list
   812 %type  <leaf>	transition_condition
   820 %type  <tmp_symbol> transition_header
       
   821 %type  <leaf>	transition_condition_il
       
   822 %type  <leaf>	transition_condition_st
       
   823 %type  <tmp_symbol> action_header
   813 %type  <leaf>	action
   824 %type  <leaf>	action
   814 %type  <leaf>	transition_name
   825 %type  <leaf>	transition_name
   815 
   826 
   816 
   827 
   817 %token ASSIGN
   828 %token ASSIGN
   944 %type  <leaf>	il_instruction
   955 %type  <leaf>	il_instruction
   945 %type  <leaf>	il_incomplete_instruction
   956 %type  <leaf>	il_incomplete_instruction
   946 %type  <leaf>	label
   957 %type  <leaf>	label
   947 %type  <leaf>	il_simple_operation
   958 %type  <leaf>	il_simple_operation
   948 // helper symbol for il_simple_operation
   959 // helper symbol for il_simple_operation
   949 %type <double_symbol> il_simple_operator_clash_il_operand
   960 %type <tmp_symbol> il_simple_operator_clash_il_operand
   950 %type  <leaf>	il_expression
   961 %type  <leaf>	il_expression
   951 %type  <leaf>	il_jump_operation
   962 %type  <leaf>	il_jump_operation
   952 %type  <leaf>	il_fb_call
   963 %type  <leaf>	il_fb_call
   953 %type  <leaf>	il_formal_funct_call
   964 %type  <leaf>	il_formal_funct_call
   954 // helper symbol for il_formal_funct_call
   965 // helper symbol for il_formal_funct_call
  3627 
  3638 
  3628 
  3639 
  3629 
  3640 
  3630 /********************************************/
  3641 /********************************************/
  3631 /* B 1.6 Sequential Function Chart elements *
  3642 /* B 1.6 Sequential Function Chart elements *
  3632 /********************************************/////////////////////////////////////////////////////////////////////////////////////////////
  3643 /********************************************/
  3633 /* TODO ... */
  3644 /* TODO ... */
  3634 
  3645 
  3635 sequential_function_chart:
  3646 sequential_function_chart:
  3636   sfc_network
  3647   sfc_network
  3637 	{$$ = new sequential_function_chart_c(); $$->add_element($1);}
  3648 	{$$ = new sequential_function_chart_c(); $$->add_element($1);}
  3726 | transition_name
  3737 | transition_name
  3727 ;
  3738 ;
  3728 
  3739 
  3729 indicator_name: variable_name;
  3740 indicator_name: variable_name;
  3730 
  3741 
  3731 transition:
       
  3732   TRANSITION FROM steps TO steps transition_condition END_TRANSITION
       
  3733 	{$$ = new transition_c(NULL, NULL, $3, $5, $6, NULL);}
       
  3734 | TRANSITION transition_name FROM steps TO steps transition_condition END_TRANSITION
       
  3735 	{$$ = new transition_c($2, NULL, $4, $6, $7, NULL);}
       
  3736 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps transition_condition END_TRANSITION
       
  3737 	{$$ = new transition_c(NULL, $5, $8, $10, $11, NULL);}
       
  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);}
       
  3740 ;
       
  3741 
       
  3742 transition_name: identifier;
  3742 transition_name: identifier;
  3743 
  3743 
  3744 steps:
  3744 steps:
  3745   step_name
  3745   step_name
  3746 	{$$ = new steps_c($1, NULL);}
  3746 	{$$ = new steps_c($1, NULL);}
  3753 	{$$ = new step_name_list_c(); $$->add_element($1); $$->add_element($3);}
  3753 	{$$ = new step_name_list_c(); $$->add_element($1); $$->add_element($3);}
  3754 | step_name_list ',' step_name
  3754 | step_name_list ',' step_name
  3755 	{$$ = $1; $$->add_element($3);}
  3755 	{$$ = $1; $$->add_element($3);}
  3756 ;
  3756 ;
  3757 
  3757 
  3758 transition_condition:
  3758 transition_header:
       
  3759   TRANSITION FROM steps TO steps
       
  3760 	{$$.first = NULL; $$.second = NULL; $$.third = $3; $$.fourth = $5; cmd_goto_body_state();}
       
  3761 | TRANSITION transition_name FROM steps TO steps 
       
  3762 	{$$.first = $2; $$.second = NULL; $$.third = $4; $$.fourth = $6; cmd_goto_body_state();}
       
  3763 | TRANSITION '(' PRIORITY ASSIGN integer ')' FROM steps TO steps
       
  3764 	{$$.first = NULL; $$.second = $5; $$.third = $8; $$.fourth = $10; cmd_goto_body_state();}
       
  3765 | TRANSITION transition_name '(' PRIORITY ASSIGN integer ')' FROM steps TO steps
       
  3766 	{$$.first = $2; $$.second = $6; $$.third = $9; $$.fourth = $11; cmd_goto_body_state();}
       
  3767 ;
       
  3768 
       
  3769 transition_condition_il:
  3759   ':' simple_instr_list
  3770   ':' simple_instr_list
  3760 	{$$ = new transition_condition_c($2, NULL);} 
  3771 	{$$ = new transition_condition_c($2, NULL);} ;
  3761 | ASSIGN expression ';'
  3772 
  3762 	{$$ = new transition_condition_c(NULL, $2);} 
  3773 transition_condition_st:
  3763 ;
  3774   ASSIGN expression ';'
       
  3775 	{$$ = new transition_condition_c(NULL, $2);};
       
  3776 
       
  3777 transition:
       
  3778   transition_header transition_condition_il END_TRANSITION
       
  3779         {$$ = new transition_c($1.first, $1.second, $1.third, $1.fourth, $2, 
       
  3780 NULL);}
       
  3781 |  transition_header transition_condition_st END_TRANSITION
       
  3782         {$$ = new transition_c($1.first, $1.second, $1.third, $1.fourth, NULL, 
       
  3783 $2);}
       
  3784 ;
       
  3785 
       
  3786 action_header:
       
  3787   ACTION action_name ':' 
       
  3788 	{$$.first = $2; cmd_goto_body_state();}
       
  3789 ;
       
  3790 
  3764 
  3791 
  3765 action:
  3792 action:
  3766   ACTION action_name ':' function_block_body END_ACTION
  3793   action_header function_block_body END_ACTION
  3767 	{$$ = new action_c($2, $4);}
  3794 	{$$ = new action_c($1.first, $2);}
  3768 ;
  3795 ;
  3769 
  3796 
  3770 
  3797 
  3771 /********************************/
  3798 /********************************/
  3772 /* B 1.7 Configuration elements */
  3799 /* B 1.7 Configuration elements */