6364 |
6364 |
6365 |
6365 |
6366 |
6366 |
6367 il_expression: |
6367 il_expression: |
6368 // il_expr_operator '(' [il_operand] EOL {EOL} [simple_instr_list] ')' |
6368 // il_expr_operator '(' [il_operand] EOL {EOL} [simple_instr_list] ')' |
|
6369 /* IMPORTANT NOTE: |
|
6370 * When the <il_operand> exists, and to make it easier to handle the <il_operand> as a general case (i.e. without C++ code handling this as a special case), |
|
6371 * we will create an equivalent LD <il_operand> IL instruction, and prepend it into the <simple_instr_list>. |
|
6372 * The remainder of the compiler may from now on assume that the code being compiled does not contain any IL code like |
|
6373 * LD 1 |
|
6374 * ADD ( 2 |
|
6375 * SUB 3 |
|
6376 * ) |
|
6377 * |
|
6378 * but instead, the equivalent code |
|
6379 * LD 1 |
|
6380 * ADD ( |
|
6381 * LD 2 |
|
6382 * SUB 3 |
|
6383 * ) |
|
6384 * |
|
6385 * Note, however, that in the first case, we still store in the il_expression_c a pointer to the <il_operand> (the literal '2' in the above example), in case |
|
6386 * somewhere further on in the compiler we really want to handle it as a special case. To handle it as a special case, it should be easy to simply delete the first |
|
6387 * artificial entry in <simple_instr_list> with il_expression->simple_instr_list->remove_element(0) !! |
|
6388 */ |
6369 /* |
6389 /* |
6370 * Note: Bison is getting confused with the use of il_expr_operator, |
6390 * Note: Bison is getting confused with the use of il_expr_operator, |
6371 * i.e. it is finding conflicts where there seemingly are really none. |
6391 * i.e. it is finding conflicts where there seemingly are really none. |
6372 * il_expr_operator was therefore replaced by the equivalent |
6392 * il_expr_operator was therefore replaced by the equivalent |
6373 * il_expr_operator_noclash | il_expr_operator_clash. |
6393 * il_expr_operator_noclash | il_expr_operator_clash. |
6374 */ |
6394 */ |
6375 il_expr_operator_noclash '(' eol_list ')' |
6395 il_expr_operator_noclash '(' eol_list ')' |
6376 {$$ = new il_expression_c($1, NULL, NULL, locloc(@$));} |
6396 {$$ = new il_expression_c($1, NULL, NULL, locloc(@$));} |
6377 | il_expr_operator_noclash '(' il_operand eol_list ')' |
6397 | il_expr_operator_noclash '(' il_operand eol_list ')' |
6378 {$$ = new il_expression_c($1, $3, NULL, locloc(@$));} |
6398 { simple_instr_list_c *tmp_simple_instr_list = new simple_instr_list_c(locloc(@3)); |
|
6399 tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0); |
|
6400 $$ = new il_expression_c($1, $3, tmp_simple_instr_list, locloc(@$)); |
|
6401 } |
6379 | il_expr_operator_noclash '(' eol_list simple_instr_list ')' |
6402 | il_expr_operator_noclash '(' eol_list simple_instr_list ')' |
6380 {$$ = new il_expression_c($1, NULL, $4, locloc(@$));} |
6403 {$$ = new il_expression_c($1, NULL, $4, locloc(@$));} |
6381 | il_expr_operator_noclash '(' il_operand eol_list simple_instr_list ')' |
6404 | il_expr_operator_noclash '(' il_operand eol_list simple_instr_list ')' |
6382 {$$ = new il_expression_c($1, $3, $5, locloc(@$));} |
6405 { simple_instr_list_c *tmp_simple_instr_list = dynamic_cast <simple_instr_list_c *> $5; |
|
6406 tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0); |
|
6407 $$ = new il_expression_c($1, $3, $5, locloc(@$)); |
|
6408 } |
6383 | il_expr_operator_clash '(' eol_list ')' |
6409 | il_expr_operator_clash '(' eol_list ')' |
6384 {$$ = new il_expression_c($1, NULL, NULL, locloc(@$));} |
6410 {$$ = new il_expression_c($1, NULL, NULL, locloc(@$));} |
6385 | il_expr_operator_clash '(' il_operand eol_list ')' |
6411 | il_expr_operator_clash '(' il_operand eol_list ')' |
6386 {$$ = new il_expression_c($1, $3, NULL, locloc(@$));} |
6412 { simple_instr_list_c *tmp_simple_instr_list = new simple_instr_list_c(locloc(@3)); |
|
6413 tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0); |
|
6414 $$ = new il_expression_c($1, $3, tmp_simple_instr_list, locloc(@$)); |
|
6415 } |
6387 | il_expr_operator_clash '(' il_operand eol_list simple_instr_list ')' |
6416 | il_expr_operator_clash '(' il_operand eol_list simple_instr_list ')' |
6388 {$$ = new il_expression_c($1, $3, $5, locloc(@$));} |
6417 { simple_instr_list_c *tmp_simple_instr_list = dynamic_cast <simple_instr_list_c *> $5; |
|
6418 tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0); |
|
6419 $$ = new il_expression_c($1, $3, $5, locloc(@$)); |
|
6420 } |
6389 | il_expr_operator_clash_eol_list simple_instr_list ')' |
6421 | il_expr_operator_clash_eol_list simple_instr_list ')' |
6390 {$$ = new il_expression_c($1, NULL, $2, locloc(@$));} |
6422 {$$ = new il_expression_c($1, NULL, $2, locloc(@$));} |
6391 /* ERROR_CHECK_BEGIN */ |
6423 /* ERROR_CHECK_BEGIN */ |
6392 | il_expr_operator_noclash '(' eol_list error |
6424 | il_expr_operator_noclash '(' eol_list error |
6393 {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of IL expression."); yyerrok;} |
6425 {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of IL expression."); yyerrok;} |