Changeset 883fedc in mainline for uspace/app/sbi/src/parse.c
- Timestamp:
- 2010-04-23T23:09:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37c9fc8
- Parents:
- 80badbe (diff), 6c39a907 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/parse.c
r80badbe r883fedc 54 54 static stree_csimbr_t *parse_csimbr(parse_t *parse, stree_csi_t *outer_csi); 55 55 56 static stree_deleg_t *parse_deleg(parse_t *parse, stree_csi_t *outer_csi); 56 57 static stree_fun_t *parse_fun(parse_t *parse, stree_csi_t *outer_csi); 57 58 static stree_var_t *parse_var(parse_t *parse, stree_csi_t *outer_csi); … … 62 63 static stree_proc_arg_t *parse_proc_arg(parse_t *parse); 63 64 static stree_arg_attr_t *parse_arg_attr(parse_t *parse); 65 static stree_fun_sig_t *parse_fun_sig(parse_t *parse); 66 64 67 65 68 /* … … 157 160 stree_symbol_t *symbol; 158 161 stree_ident_t *targ_name; 162 stree_targ_t *targ; 159 163 160 164 switch (dclass) { … … 170 174 csi->name = parse_ident(parse); 171 175 172 list_init(&csi->targ _names);176 list_init(&csi->targ); 173 177 174 178 while (lcur_lc(parse) == lc_slash) { 175 179 lskip(parse); 176 180 targ_name = parse_ident(parse); 177 list_append(&csi->targ_names, targ_name); 181 182 targ = stree_targ_new(); 183 targ->name = targ_name; 184 185 list_append(&csi->targ, targ); 178 186 } 179 187 … … 201 209 while (lcur_lc(parse) != lc_end && !parse_is_error(parse)) { 202 210 csimbr = parse_csimbr(parse, csi); 211 if (csimbr == NULL) 212 break; 213 203 214 list_append(&csi->members, csimbr); 204 215 } … … 213 224 * @param parse Parser object. 214 225 * @param outer_csi CSI containing this declaration or @c NULL if global. 215 * @return New syntax tree node. 226 * @return New syntax tree node. In case of parse error, 227 * @c NULL may (but need not) be returned. 216 228 */ 217 229 static stree_csimbr_t *parse_csimbr(parse_t *parse, stree_csi_t *outer_csi) … … 220 232 221 233 stree_csi_t *csi; 234 stree_deleg_t *deleg; 222 235 stree_fun_t *fun; 223 236 stree_var_t *var; … … 232 245 csimbr->u.csi = csi; 233 246 break; 247 case lc_deleg: 248 deleg = parse_deleg(parse, outer_csi); 249 csimbr = stree_csimbr_new(csimbr_deleg); 250 csimbr->u.deleg = deleg; 251 break; 234 252 case lc_fun: 235 253 fun = parse_fun(parse, outer_csi); … … 250 268 lunexpected_error(parse); 251 269 lex_next(parse->lex); 270 csimbr = NULL; 271 break; 252 272 } 253 273 … … 255 275 } 256 276 277 /** Parse delegate. 278 * 279 * @param parse Parser object. 280 * @param outer_csi CSI containing this declaration or @c NULL if global. 281 * @return New syntax tree node. 282 */ 283 static stree_deleg_t *parse_deleg(parse_t *parse, stree_csi_t *outer_csi) 284 { 285 stree_deleg_t *deleg; 286 stree_symbol_t *symbol; 287 stree_symbol_attr_t *attr; 288 289 deleg = stree_deleg_new(); 290 symbol = stree_symbol_new(sc_deleg); 291 292 symbol->u.deleg = deleg; 293 symbol->outer_csi = outer_csi; 294 deleg->symbol = symbol; 295 296 lmatch(parse, lc_deleg); 297 deleg->name = parse_ident(parse); 298 299 #ifdef DEBUG_PARSE_TRACE 300 printf("Parsing delegate '%s'.\n", strtab_get_str(deleg->name->sid)); 301 #endif 302 303 deleg->sig = parse_fun_sig(parse); 304 305 list_init(&symbol->attr); 306 307 /* Parse attributes. */ 308 while (lcur_lc(parse) == lc_comma && !parse_is_error(parse)) { 309 lskip(parse); 310 attr = parse_symbol_attr(parse); 311 list_append(&symbol->attr, attr); 312 } 313 314 lmatch(parse, lc_scolon); 315 316 return deleg; 317 } 257 318 258 319 /** Parse member function. … … 265 326 { 266 327 stree_fun_t *fun; 267 stree_proc_arg_t *arg;268 328 stree_symbol_t *symbol; 269 329 stree_symbol_attr_t *attr; … … 278 338 lmatch(parse, lc_fun); 279 339 fun->name = parse_ident(parse); 280 lmatch(parse, lc_lparen);281 340 282 341 #ifdef DEBUG_PARSE_TRACE 283 342 printf("Parsing function '%s'.\n", strtab_get_str(fun->name->sid)); 284 343 #endif 285 286 list_init(&fun->args); 287 288 if (lcur_lc(parse) != lc_rparen) { 289 290 /* Parse formal parameters. */ 291 while (!parse_is_error(parse)) { 292 arg = parse_proc_arg(parse); 293 294 if (stree_arg_has_attr(arg, aac_packed)) { 295 fun->varg = arg; 296 break; 297 } else { 298 list_append(&fun->args, arg); 299 } 300 301 if (lcur_lc(parse) == lc_rparen) 302 break; 303 304 lmatch(parse, lc_scolon); 305 } 306 } 307 308 lmatch(parse, lc_rparen); 309 310 if (lcur_lc(parse) == lc_colon) { 311 lskip(parse); 312 fun->rtype = parse_texpr(parse); 313 } else { 314 fun->rtype = NULL; 315 } 344 fun->sig = parse_fun_sig(parse); 316 345 317 346 list_init(&symbol->attr); … … 522 551 arg->type = parse_texpr(parse); 523 552 524 list_init(&arg->attr); 553 #ifdef DEBUG_PARSE_TRACE 554 printf("Parse procedure argument.\n"); 555 #endif 556 list_init(&arg->attr); 525 557 526 558 /* Parse attributes. */ … … 531 563 } 532 564 533 #ifdef DEBUG_PARSE_TRACE534 printf("Parsed arg attr, type=%p.\n", arg->type);535 #endif536 565 return arg; 537 566 } … … 557 586 attr = stree_arg_attr_new(aac_packed); 558 587 return attr; 588 } 589 590 /** Parse function signature. 591 * 592 * @param parse Parser object. 593 * @return New syntax tree node. 594 */ 595 static stree_fun_sig_t *parse_fun_sig(parse_t *parse) 596 { 597 stree_fun_sig_t *sig; 598 stree_proc_arg_t *arg; 599 600 sig = stree_fun_sig_new(); 601 602 lmatch(parse, lc_lparen); 603 604 #ifdef DEBUG_PARSE_TRACE 605 printf("Parsing function signature.\n"); 606 #endif 607 608 list_init(&sig->args); 609 610 if (lcur_lc(parse) != lc_rparen) { 611 612 /* Parse formal parameters. */ 613 while (!parse_is_error(parse)) { 614 arg = parse_proc_arg(parse); 615 616 if (stree_arg_has_attr(arg, aac_packed)) { 617 sig->varg = arg; 618 break; 619 } else { 620 list_append(&sig->args, arg); 621 } 622 623 if (lcur_lc(parse) == lc_rparen) 624 break; 625 626 lmatch(parse, lc_scolon); 627 } 628 } 629 630 lmatch(parse, lc_rparen); 631 632 if (lcur_lc(parse) == lc_colon) { 633 lskip(parse); 634 sig->rtype = parse_texpr(parse); 635 } else { 636 sig->rtype = NULL; 637 } 638 639 return sig; 559 640 } 560 641
Note:
See TracChangeset
for help on using the changeset viewer.