Changeset 23db8aa in mainline
- Timestamp:
- 2012-08-01T21:59:11Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 47a728e1
- Parents:
- 3f2ea63
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/script.c
r3f2ea63 r23db8aa 495 495 } 496 496 497 /** Create a transform that just produces an empty node. 498 * @param state The parser state. 499 * @return The new transform, or NULL on error. */ 500 static bithenge_transform_t *make_empty_transform(state_t *state) 501 { 502 bithenge_node_t *node; 503 int rc = bithenge_new_empty_internal_node(&node); 504 if (rc != EOK) { 505 error_errno(state, rc); 506 return NULL; 507 } 508 509 bithenge_expression_t *expr; 510 rc = bithenge_const_expression(&expr, node); 511 if (rc != EOK) { 512 error_errno(state, rc); 513 return NULL; 514 } 515 516 bithenge_transform_t *xform; 517 rc = bithenge_expression_transform(&xform, expr); 518 if (rc != EOK) { 519 error_errno(state, rc); 520 return NULL; 521 } 522 523 return xform; 524 } 525 497 526 static bithenge_transform_t *parse_if(state_t *state, bool in_struct) 498 527 { … … 505 534 in_struct ? parse_struct(state) : parse_transform(state); 506 535 expect(state, '}'); 536 507 537 bithenge_transform_t *false_xform = NULL; 508 538 if (state->token == TOKEN_ELSE) { … … 513 543 expect(state, '}'); 514 544 } else { 515 if (in_struct) { 516 bithenge_node_t *node; 517 int rc = bithenge_new_empty_internal_node(&node); 518 if (rc != EOK) { 519 error_errno(state, rc); 520 goto error; 521 } 522 bithenge_expression_t *expr; 523 rc = bithenge_const_expression(&expr, node); 524 if (rc != EOK) { 525 error_errno(state, rc); 526 goto error; 527 } 528 rc = bithenge_expression_transform(&false_xform, expr); 529 if (rc != EOK) { 530 error_errno(state, rc); 531 false_xform = NULL; 532 goto error; 533 } 534 } else 545 if (in_struct) 546 false_xform = make_empty_transform(state); 547 else 535 548 syntax_error(state, "else expected"); 536 549 } 550 537 551 if (state->error != EOK) { 538 error:539 552 bithenge_expression_dec_ref(expr); 540 553 bithenge_transform_dec_ref(true_xform); … … 542 555 return NULL; 543 556 } 557 544 558 bithenge_transform_t *if_xform; 545 559 int rc = bithenge_if_transform(&if_xform, expr, true_xform,
Note:
See TracChangeset
for help on using the changeset viewer.