stage1_2/iec.y
changeset 94 40288323acc0
parent 93 284ef59bb133
child 95 b119b1db0a7a
equal deleted inserted replaced
93:284ef59bb133 94:40288323acc0
  3737 | timed_qualifier ',' action_time
  3737 | timed_qualifier ',' action_time
  3738 	{$$ = new action_qualifier_c($1, $3, locloc(@$));}
  3738 	{$$ = new action_qualifier_c($1, $3, locloc(@$));}
  3739 ;
  3739 ;
  3740 
  3740 
  3741 qualifier:
  3741 qualifier:
  3742 N		{$$ = new qualifier_c(strdup("N"), locloc(@$));}
  3742   N		{$$ = new qualifier_c(strdup("N"), locloc(@$));}
  3743 /* NOTE: the following two clash with the R and S IL operators.
       
  3744  * It will have to be handled when we include parsing of SFC...
       
  3745  */
       
  3746 | R		{$$ = new qualifier_c(strdup("R"), locloc(@$));}
  3743 | R		{$$ = new qualifier_c(strdup("R"), locloc(@$));}
  3747 | S		{$$ = new qualifier_c(strdup("S"), locloc(@$));}
  3744 | S		{$$ = new qualifier_c(strdup("S"), locloc(@$));}
  3748 | P		{$$ = new qualifier_c(strdup("P"), locloc(@$));}
  3745 | P		{$$ = new qualifier_c(strdup("P"), locloc(@$));}
  3749 ;
  3746 ;
  3750 
  3747 
  3751 timed_qualifier:
  3748 timed_qualifier:
  3752 L		{$$ = new timed_qualifier_c(strdup("L"), locloc(@$));}
  3749   L		{$$ = new timed_qualifier_c(strdup("L"), locloc(@$));}
  3753 | D		{$$ = new timed_qualifier_c(strdup("D"), locloc(@$));}
  3750 | D		{$$ = new timed_qualifier_c(strdup("D"), locloc(@$));}
  3754 | SD		{$$ = new timed_qualifier_c(strdup("SD"), locloc(@$));}
  3751 | SD		{$$ = new timed_qualifier_c(strdup("SD"), locloc(@$));}
  3755 | DS		{$$ = new timed_qualifier_c(strdup("DS"), locloc(@$));}
  3752 | DS		{$$ = new timed_qualifier_c(strdup("DS"), locloc(@$));}
  3756 | SL		{$$ = new timed_qualifier_c(strdup("SL"), locloc(@$));}
  3753 | SL		{$$ = new timed_qualifier_c(strdup("SL"), locloc(@$));}
  3757 ;
  3754 ;
  3781 	{$$ = $1; $$->add_element($3);}
  3778 	{$$ = $1; $$->add_element($3);}
  3782 ;
  3779 ;
  3783 
  3780 
  3784 
  3781 
  3785 /* NOTE: flex will automatically pop() out of body_state to previous state.
  3782 /* NOTE: flex will automatically pop() out of body_state to previous state.
  3786  *       We do not need to give a command from bison to return to previous flex state!
  3783  *       We do not need to give a command from bison to return to previous flex state,
       
  3784  *       after forcing flex to go to body_state.
  3787  */
  3785  */
  3788 transition:
  3786 transition:
  3789   TRANSITION 
  3787   TRANSITION 
  3790     FROM steps TO steps 
  3788     FROM steps TO steps 
  3791     {cmd_goto_body_state();} transition_condition 
  3789     {cmd_goto_body_state();} transition_condition 
  4308 eol_list:
  4306 eol_list:
  4309   EOL
  4307   EOL
  4310 | eol_list EOL
  4308 | eol_list EOL
  4311 ;
  4309 ;
  4312 
  4310 
  4313 /*
  4311 
  4314 eol_list:
       
  4315   '\n'
       
  4316 | eol_list '\n'
       
  4317 ;
       
  4318 */
       
  4319 
  4312 
  4320 instruction_list:
  4313 instruction_list:
  4321   il_instruction
  4314   il_instruction
  4322 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  4315 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  4323 | pragma eol_list
  4316 | pragma eol_list
  4366 label: identifier;
  4359 label: identifier;
  4367 
  4360 
  4368 
  4361 
  4369 
  4362 
  4370 il_simple_operation:
  4363 il_simple_operation:
  4371 // il_simple_operation ::= (il_simple_operator [il_operand]) | (function_name [il_operand_list])
  4364 // (il_simple_operator [il_operand]) | (function_name [il_operand_list])
  4372   il_simple_operator
  4365   il_simple_operator
  4373 	{$$ = new il_simple_operation_c($1, NULL, locloc(@$));}
  4366 	{$$ = new il_simple_operation_c($1, NULL, locloc(@$));}
  4374 /*
  4367 /*
  4375  * Note: Bison is getting confused with the following rule,
  4368  * Note: Bison is getting confused with the following rule,
  4376  *       i.e. it is finding conflicts where there are really none.
  4369  *       i.e. it is finding conflicts where there seemingly are really none.
  4377  *       The rule was therefore replaced by the equivalent following
  4370  *       The rule was therefore replaced by the equivalent following
  4378  *       two rules.
  4371  *       two rules.
  4379  */
  4372  */
  4380 /*
  4373 /*
  4381 | il_simple_operator il_operand
  4374 | il_simple_operator il_operand
  4438 	{$$ = new il_function_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));}
  4431 	{$$ = new il_function_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));}
  4439 ;
  4432 ;
  4440 
  4433 
  4441 
  4434 
  4442 
  4435 
  4443 
       
  4444 
       
  4445 il_expression:
  4436 il_expression:
       
  4437 // il_expr_operator '(' [il_operand] EOL {EOL} [simple_instr_list] ')'
       
  4438 /*
       
  4439  * Note: Bison is getting confused with the use of il_expr_operator,
       
  4440  *       i.e. it is finding conflicts where there seemingly are really none.
       
  4441  *       il_expr_operator was therefore replaced by the equivalent 
       
  4442  *       il_expr_operator_noclash | il_expr_operator_clash.
       
  4443  */
  4446   il_expr_operator_noclash '(' eol_list ')'
  4444   il_expr_operator_noclash '(' eol_list ')'
  4447 	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
  4445 	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
  4448 | il_expr_operator_noclash '(' il_operand eol_list ')'
  4446 | il_expr_operator_noclash '(' il_operand eol_list ')'
  4449 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4447 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4450 | il_expr_operator_noclash '(' eol_list simple_instr_list ')'
  4448 | il_expr_operator_noclash '(' eol_list simple_instr_list ')'
  4467 	{$$ = new il_jump_operation_c($1, $2, locloc(@$));}
  4465 	{$$ = new il_jump_operation_c($1, $2, locloc(@$));}
  4468 ;
  4466 ;
  4469 
  4467 
  4470 
  4468 
  4471 il_fb_call:
  4469 il_fb_call:
       
  4470 // il_call_operator fb_name ['(' (EOL {EOL} [il_param_list]) | [il_operand_list] ')']
  4472   il_call_operator prev_declared_fb_name
  4471   il_call_operator prev_declared_fb_name
  4473 	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
  4472 	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
  4474 | il_call_operator prev_declared_fb_name '(' ')'
  4473 | il_call_operator prev_declared_fb_name '(' ')'
  4475 	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
  4474 	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
  4476 | il_call_operator prev_declared_fb_name '(' eol_list ')'
  4475 | il_call_operator prev_declared_fb_name '(' eol_list ')'
  4482 ;
  4481 ;
  4483 
  4482 
  4484 
  4483 
  4485 /* NOTE: Please read note above the definition of function_name_without_clashes */
  4484 /* NOTE: Please read note above the definition of function_name_without_clashes */
  4486 il_formal_funct_call:
  4485 il_formal_funct_call:
       
  4486 // function_name '(' EOL {EOL} [il_param_list] ')'
  4487 /*  function_name '(' eol_list ')'  */
  4487 /*  function_name '(' eol_list ')'  */
  4488 /* NOTE: il_formal_funct_call is only used in the definition of
  4488 /* NOTE: il_formal_funct_call is only used in the definition of
  4489  *         - il_incomplete_instruction
  4489  *         - il_incomplete_instruction
  4490  *         - il_simple_instruction
  4490  *         - il_simple_instruction
  4491  *       In both of the above, il_expression also
  4491  *       In both of the above, il_expression also