Changes in uspace/app/sbi/src/parse.c [38aaacc2:074444f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/parse.c
r38aaacc2 r074444f 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);57 56 static stree_fun_t *parse_fun(parse_t *parse, stree_csi_t *outer_csi); 58 57 static stree_var_t *parse_var(parse_t *parse, stree_csi_t *outer_csi); … … 63 62 static stree_proc_arg_t *parse_proc_arg(parse_t *parse); 64 63 static stree_arg_attr_t *parse_arg_attr(parse_t *parse); 65 static stree_fun_sig_t *parse_fun_sig(parse_t *parse);66 67 64 68 65 /* … … 160 157 stree_symbol_t *symbol; 161 158 stree_ident_t *targ_name; 162 stree_targ_t *targ;163 159 164 160 switch (dclass) { … … 174 170 csi->name = parse_ident(parse); 175 171 176 list_init(&csi->targ );172 list_init(&csi->targ_names); 177 173 178 174 while (lcur_lc(parse) == lc_slash) { 179 175 lskip(parse); 180 176 targ_name = parse_ident(parse); 181 182 targ = stree_targ_new(); 183 targ->name = targ_name; 184 185 list_append(&csi->targ, targ); 177 list_append(&csi->targ_names, targ_name); 186 178 } 187 179 … … 209 201 while (lcur_lc(parse) != lc_end && !parse_is_error(parse)) { 210 202 csimbr = parse_csimbr(parse, csi); 211 if (csimbr == NULL)212 break;213 214 203 list_append(&csi->members, csimbr); 215 204 } … … 224 213 * @param parse Parser object. 225 214 * @param outer_csi CSI containing this declaration or @c NULL if global. 226 * @return New syntax tree node. In case of parse error, 227 * @c NULL may (but need not) be returned. 215 * @return New syntax tree node. 228 216 */ 229 217 static stree_csimbr_t *parse_csimbr(parse_t *parse, stree_csi_t *outer_csi) … … 232 220 233 221 stree_csi_t *csi; 234 stree_deleg_t *deleg;235 222 stree_fun_t *fun; 236 223 stree_var_t *var; … … 245 232 csimbr->u.csi = csi; 246 233 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;252 234 case lc_fun: 253 235 fun = parse_fun(parse, outer_csi); … … 268 250 lunexpected_error(parse); 269 251 lex_next(parse->lex); 270 csimbr = NULL;271 break;272 252 } 273 253 … … 275 255 } 276 256 277 /** Parse delegate. 257 258 /** Parse member function. 278 259 * 279 260 * @param parse Parser object. … … 281 262 * @return New syntax tree node. 282 263 */ 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_TRACE300 printf("Parsing delegate '%s'.\n", strtab_get_str(deleg->name->sid));301 #endif302 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 }318 319 /** Parse member function.320 *321 * @param parse Parser object.322 * @param outer_csi CSI containing this declaration or @c NULL if global.323 * @return New syntax tree node.324 */325 264 static stree_fun_t *parse_fun(parse_t *parse, stree_csi_t *outer_csi) 326 265 { 327 266 stree_fun_t *fun; 267 stree_proc_arg_t *arg; 328 268 stree_symbol_t *symbol; 329 269 stree_symbol_attr_t *attr; … … 338 278 lmatch(parse, lc_fun); 339 279 fun->name = parse_ident(parse); 280 lmatch(parse, lc_lparen); 340 281 341 282 #ifdef DEBUG_PARSE_TRACE 342 283 printf("Parsing function '%s'.\n", strtab_get_str(fun->name->sid)); 343 284 #endif 344 fun->sig = parse_fun_sig(parse); 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 } 345 316 346 317 list_init(&symbol->attr); … … 551 522 arg->type = parse_texpr(parse); 552 523 553 #ifdef DEBUG_PARSE_TRACE 554 printf("Parse procedure argument.\n"); 555 #endif 556 list_init(&arg->attr); 524 list_init(&arg->attr); 557 525 558 526 /* Parse attributes. */ … … 563 531 } 564 532 533 #ifdef DEBUG_PARSE_TRACE 534 printf("Parsed arg attr, type=%p.\n", arg->type); 535 #endif 565 536 return arg; 566 537 } … … 586 557 attr = stree_arg_attr_new(aac_packed); 587 558 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_TRACE605 printf("Parsing function signature.\n");606 #endif607 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;640 559 } 641 560
Note:
See TracChangeset
for help on using the changeset viewer.