stage1_2/iec.y
changeset 93 284ef59bb133
parent 92 a1b03af4b26a
child 94 40288323acc0
equal deleted inserted replaced
92:a1b03af4b26a 93:284ef59bb133
   170 
   170 
   171 %union {
   171 %union {
   172     symbol_c 	*leaf;
   172     symbol_c 	*leaf;
   173     list_c	*list;
   173     list_c	*list;
   174     char 	*ID;	/* token value */
   174     char 	*ID;	/* token value */
   175 /*
       
   176     struct {
       
   177       symbol_c	*first;
       
   178       symbol_c	*second;
       
   179     } tmp_symbol;
       
   180 */ 
       
   181 /* used as a temorary reference to symbols by:
       
   182                                      il_simple_operator_clash_il_operand
       
   183                              */
       
   184 }
   175 }
   185 
   176 
   186 /*
   177 /*
   187  TODO: DO we need to define a destructor do free
   178  TODO: DO we need to define a destructor do free
   188        memory when recovering from errors, or do the
   179        memory when recovering from errors, or do the
  4375 label: identifier;
  4366 label: identifier;
  4376 
  4367 
  4377 
  4368 
  4378 
  4369 
  4379 il_simple_operation:
  4370 il_simple_operation:
       
  4371 // il_simple_operation ::= (il_simple_operator [il_operand]) | (function_name [il_operand_list])
  4380   il_simple_operator
  4372   il_simple_operator
  4381 	{$$ = new il_simple_operation_c($1, NULL, locloc(@$));}
  4373 	{$$ = new il_simple_operation_c($1, NULL, locloc(@$));}
       
  4374 /*
       
  4375  * Note: Bison is getting confused with the following rule,
       
  4376  *       i.e. it is finding conflicts where there are really none.
       
  4377  *       The rule was therefore replaced by the equivalent following
       
  4378  *       two rules.
       
  4379  */
       
  4380 /*
       
  4381 | il_simple_operator il_operand
       
  4382 	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
       
  4383 */
  4382 | il_simple_operator_noclash il_operand
  4384 | il_simple_operator_noclash il_operand
  4383 	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
  4385 	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
  4384 /*
       
  4385 | il_simple_operator_clash_il_operand
       
  4386 	{$$ = new il_simple_operation_c($1.first, $1.second, locloc(@$));}
       
  4387 */
       
  4388 | il_simple_operator_clash il_operand
  4386 | il_simple_operator_clash il_operand
  4389 	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
  4387 	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
  4390 /* NOTE: the line
  4388 /* NOTE: the line
  4391  *         | il_simple_operator
  4389  *         | il_simple_operator
  4392  *       already contains the 'NOT' operator, as well as all the
  4390  *       already contains the 'NOT' operator, as well as all the
  4434  *       function_name_expression_clashes and function_name_simpleop_clashes
  4432  *       function_name_expression_clashes and function_name_simpleop_clashes
  4435  *       are followed by a il_operand_list with __two__ or more il_operands!!
  4433  *       are followed by a il_operand_list with __two__ or more il_operands!!
  4436  */
  4434  */
  4437 | function_name_no_clashes il_operand_list
  4435 | function_name_no_clashes il_operand_list
  4438 	{$$ = new il_function_call_c($1, $2, locloc(@$));}
  4436 	{$$ = new il_function_call_c($1, $2, locloc(@$));}
  4439 /*
       
  4440 | il_simple_operator_clash_il_operand ',' il_operand_list
       
  4441 	{list_c *list = new il_operand_list_c(locloc(@$));
       
  4442 	 list->add_element($1.second);
       
  4443 	 FOR_EACH_ELEMENT(elem, $3, {list->add_element(elem);})
       
  4444 	 $$ = new il_function_call_c(il_operator_c_2_identifier_c($1.first), list, locloc(@$));
       
  4445 	}
       
  4446 */
       
  4447 | il_simple_operator_clash il_operand_list2
  4437 | il_simple_operator_clash il_operand_list2
  4448 	{
  4438 	{$$ = new il_function_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));}
  4449 	 $$ = new il_function_call_c(il_operator_c_2_identifier_c($1), $2, locloc(@$));
  4439 ;
  4450 	}
  4440 
  4451 ;
       
  4452 
       
  4453 
       
  4454 
       
  4455 /*
       
  4456 il_simple_operator_clash_il_operand:
       
  4457   il_simple_operator_clash il_operand
       
  4458 	{$$.first = $1; $$.second = $2;}
       
  4459 ;
       
  4460 */
       
  4461 
  4441 
  4462 
  4442 
  4463 
  4443 
  4464 
  4444 
  4465 il_expression:
  4445 il_expression:
  4469 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4449 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4470 | il_expr_operator_noclash '(' eol_list simple_instr_list ')'
  4450 | il_expr_operator_noclash '(' eol_list simple_instr_list ')'
  4471 	{$$ = new il_expression_c($1, NULL, $4, locloc(@$));}
  4451 	{$$ = new il_expression_c($1, NULL, $4, locloc(@$));}
  4472 | il_expr_operator_noclash '(' il_operand eol_list simple_instr_list ')'
  4452 | il_expr_operator_noclash '(' il_operand eol_list simple_instr_list ')'
  4473 	{$$ = new il_expression_c($1, $3, $5, locloc(@$));}
  4453 	{$$ = new il_expression_c($1, $3, $5, locloc(@$));}
  4474 /*
       
  4475 */
       
  4476 | il_expr_operator_clash '(' eol_list ')'
  4454 | il_expr_operator_clash '(' eol_list ')'
  4477 	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
  4455 	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
  4478 | il_expr_operator_clash '(' il_operand eol_list ')'
  4456 | il_expr_operator_clash '(' il_operand eol_list ')'
  4479 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4457 	{$$ = new il_expression_c($1, $3, NULL, locloc(@$));}
  4480 | il_expr_operator_clash '(' il_operand eol_list simple_instr_list ')'
  4458 | il_expr_operator_clash '(' il_operand eol_list simple_instr_list ')'
  4481 	{$$ = new il_expression_c($1, $3, $5, locloc(@$));}
  4459 	{$$ = new il_expression_c($1, $3, $5, locloc(@$));}
  4482 /*
       
  4483 */
       
  4484 | il_expr_operator_clash_eol_list simple_instr_list ')'
  4460 | il_expr_operator_clash_eol_list simple_instr_list ')'
  4485 	{$$ = new il_expression_c($1, NULL, $2, locloc(@$));}
  4461 	{$$ = new il_expression_c($1, NULL, $2, locloc(@$));}
  4486 ;
  4462 ;
  4487 
  4463 
  4488 
  4464