Changeset 94d484a in mainline for uspace/app/sbi/src/parse.c
- Timestamp:
- 2010-03-07T17:45:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d0febca
- Parents:
- fa36f29
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/parse.c
rfa36f29 r94d484a 56 56 57 57 static stree_fun_arg_t *parse_fun_arg(parse_t *parse); 58 static stree_arg_attr_t *parse_arg_attr(parse_t *parse); 58 59 59 60 /* … … 72 73 static stree_exps_t *parse_exps(parse_t *parse); 73 74 75 static stree_except_t *parse_except(parse_t *parse); 76 74 77 void parse_init(parse_t *parse, stree_program_t *prog, struct lex *lex) 75 78 { … … 87 90 stree_symbol_t *symbol; 88 91 89 /* do {90 lex_next(parse->lex);91 printf("Read token: "); lem_print(&parse->lex->current);92 putchar('\n');93 } while (parse->lex->current.lclass != lc_eof);94 */95 92 while (lcur_lc(parse) != lc_eof) { 96 93 switch (lcur_lc(parse)) { … … 245 242 while (b_true) { 246 243 arg = parse_fun_arg(parse); 247 list_append(&fun->args, arg); 244 if (stree_arg_has_attr(arg, aac_packed)) { 245 fun->varg = arg; 246 break; 247 } else { 248 list_append(&fun->args, arg); 249 } 248 250 249 251 if (lcur_lc(parse) == lc_rparen) … … 307 309 { 308 310 stree_fun_arg_t *arg; 311 stree_arg_attr_t *attr; 309 312 310 313 arg = stree_fun_arg_new(); … … 313 316 arg->type = parse_texpr(parse); 314 317 318 list_init(&arg->attr); 319 320 /* Parse attributes. */ 321 while (lcur_lc(parse) == lc_comma) { 322 lskip(parse); 323 attr = parse_arg_attr(parse); 324 list_append(&arg->attr, attr); 325 } 326 315 327 return arg; 328 } 329 330 /** Parse argument attribute. */ 331 static stree_arg_attr_t *parse_arg_attr(parse_t *parse) 332 { 333 stree_arg_attr_t *attr; 334 335 if (lcur_lc(parse) != lc_packed) { 336 printf("Error: Unexpected attribute '"); 337 lem_print(lcur(parse)); 338 printf("'.\n"); 339 exit(1); 340 } 341 342 lskip(parse); 343 344 attr = stree_arg_attr_new(aac_packed); 345 return attr; 316 346 } 317 347 … … 378 408 stat->u.return_s = return_s; 379 409 break; 410 case lc_do: 380 411 case lc_with: 381 412 wef_s = parse_wef(parse); … … 485 516 static stree_raise_t *parse_raise(parse_t *parse) 486 517 { 518 stree_raise_t *raise_s; 519 520 raise_s = stree_raise_new(); 487 521 lmatch(parse, lc_raise); 488 (void)parse_expr(parse);522 raise_s->expr = parse_expr(parse); 489 523 lmatch(parse, lc_scolon); 490 524 491 return stree_raise_new();525 return raise_s; 492 526 } 493 527 … … 510 544 { 511 545 stree_wef_t *wef_s; 512 stree_ block_t *block;546 stree_except_t *except_c; 513 547 514 548 wef_s = stree_wef_new(); 515 list_init(&wef_s->except_blocks); 516 517 lmatch(parse, lc_with); 518 lmatch(parse, lc_ident); 519 lmatch(parse, lc_colon); 520 (void) parse_texpr(parse); 521 lmatch(parse, lc_assign); 522 (void) parse_expr(parse); 523 lmatch(parse, lc_do); 524 wef_s->with_block = parse_block(parse); 525 526 while (lcur_lc(parse) == lc_except) { 527 lmatch(parse, lc_except); 549 list_init(&wef_s->except_clauses); 550 551 if (lcur_lc(parse) == lc_with) { 552 lmatch(parse, lc_with); 528 553 lmatch(parse, lc_ident); 529 554 lmatch(parse, lc_colon); 530 555 (void) parse_texpr(parse); 556 lmatch(parse, lc_assign); 557 (void) parse_expr(parse); 558 } 559 560 lmatch(parse, lc_do); 561 wef_s->with_block = parse_block(parse); 562 563 while (lcur_lc(parse) == lc_except) { 564 except_c = parse_except(parse); 565 list_append(&wef_s->except_clauses, except_c); 566 } 567 568 if (lcur_lc(parse) == lc_finally) { 569 lmatch(parse, lc_finally); 531 570 lmatch(parse, lc_do); 532 533 block = parse_block(parse); 534 list_append(&wef_s->except_blocks, block); 535 } 536 537 lmatch(parse, lc_finally); 538 lmatch(parse, lc_do); 539 wef_s->finally_block = parse_block(parse); 571 wef_s->finally_block = parse_block(parse); 572 } else { 573 wef_s->finally_block = NULL; 574 } 575 540 576 lmatch(parse, lc_end); 541 577 … … 556 592 557 593 return exps; 594 } 595 596 /* Parse @c except clause. */ 597 static stree_except_t *parse_except(parse_t *parse) 598 { 599 stree_except_t *except_c; 600 601 except_c = stree_except_new(); 602 603 lmatch(parse, lc_except); 604 except_c->evar = parse_ident(parse); 605 lmatch(parse, lc_colon); 606 except_c->etype = parse_texpr(parse); 607 lmatch(parse, lc_do); 608 609 except_c->block = parse_block(parse); 610 611 return except_c; 558 612 } 559 613
Note:
See TracChangeset
for help on using the changeset viewer.