Changeset d0febca in mainline for uspace/app/sbi/src/parse.c


Ignore:
Timestamp:
2010-03-13T12:04:37Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7715994
Parents:
94d484a
Message:

Update SBI to rev. 100.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/parse.c

    r94d484a rd0febca  
    5555static stree_prop_t *parse_prop(parse_t *parse);
    5656
    57 static stree_fun_arg_t *parse_fun_arg(parse_t *parse);
     57static stree_proc_arg_t *parse_proc_arg(parse_t *parse);
    5858static stree_arg_attr_t *parse_arg_attr(parse_t *parse);
    5959
     
    227227{
    228228        stree_fun_t *fun;
    229         stree_fun_arg_t *arg;
     229        stree_proc_arg_t *arg;
    230230
    231231        fun = stree_fun_new();
     
    241241                /* Parse formal parameters. */
    242242                while (b_true) {
    243                         arg = parse_fun_arg(parse);
     243                        arg = parse_proc_arg(parse);
    244244                        if (stree_arg_has_attr(arg, aac_packed)) {
    245245                                fun->varg = arg;
     
    292292{
    293293        stree_prop_t *prop;
     294        stree_ident_t *ident;
     295        stree_proc_arg_t *arg;
    294296
    295297        prop = stree_prop_new();
     298        list_init(&prop->args);
    296299
    297300        lmatch(parse, lc_prop);
    298         prop->name = parse_ident(parse);
     301
     302        if (lcur_lc(parse) == lc_self) {
     303                /* Indexed property set */
     304
     305                /* Use some name that is impossible as identifier. */
     306                ident = stree_ident_new();
     307                ident->sid = strtab_get_sid(INDEXER_IDENT);
     308                prop->name = ident;
     309
     310                lskip(parse);
     311                lmatch(parse, lc_lsbr);
     312
     313                /* Parse formal parameters. */
     314                while (b_true) {
     315                        arg = parse_proc_arg(parse);
     316                        if (stree_arg_has_attr(arg, aac_packed)) {
     317                                prop->varg = arg;
     318                                break;
     319                        } else {
     320                                list_append(&prop->args, arg);
     321                        }
     322
     323                        if (lcur_lc(parse) == lc_rsbr)
     324                                break;
     325
     326                        lmatch(parse, lc_scolon);
     327                }
     328
     329                lmatch(parse, lc_rsbr);
     330        } else {
     331                /* Named property */
     332                prop->name = parse_ident(parse);
     333        }
     334
    299335        lmatch(parse, lc_colon);
    300336        prop->type = parse_texpr(parse);
    301337        lmatch(parse, lc_is);
     338
     339        while (lcur_lc(parse) != lc_end) {
     340                switch (lcur_lc(parse)) {
     341                case lc_get:
     342                        lskip(parse);
     343                        lmatch(parse, lc_is);
     344                        if (prop->getter_body != NULL) {
     345                                printf("Error: Duplicate getter.\n");
     346                                exit(1);
     347                        }
     348                        prop->getter_body = parse_block(parse);
     349                        lmatch(parse, lc_end);
     350                        break;
     351                case lc_set:
     352                        lskip(parse);
     353                        prop->setter_arg_name = parse_ident(parse);
     354                        lmatch(parse, lc_is);
     355                        if (prop->setter_body != NULL) {
     356                                printf("Error: Duplicate setter.\n");
     357                                exit(1);
     358                        }
     359                        prop->setter_body = parse_block(parse);
     360                        lmatch(parse, lc_end);
     361                        break;
     362                default:
     363                        lunexpected_error(parse);
     364                }
     365        }
     366
    302367        lmatch(parse, lc_end);
    303368
     
    306371
    307372/** Parse formal function argument. */
    308 static stree_fun_arg_t *parse_fun_arg(parse_t *parse)
    309 {
    310         stree_fun_arg_t *arg;
     373static stree_proc_arg_t *parse_proc_arg(parse_t *parse)
     374{
     375        stree_proc_arg_t *arg;
    311376        stree_arg_attr_t *attr;
    312377
    313         arg = stree_fun_arg_new();
     378        arg = stree_proc_arg_new();
    314379        arg->name = parse_ident(parse);
    315380        lmatch(parse, lc_colon);
Note: See TracChangeset for help on using the changeset viewer.