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


Ignore:
Timestamp:
2011-04-15T19:38:07Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dd730d1
Parents:
6b9e85b (diff), b2fb47f (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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r6b9e85b r8b655705  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    8282static stree_vdecl_t *parse_vdecl(parse_t *parse);
    8383static stree_if_t *parse_if(parse_t *parse);
     84static stree_switch_t *parse_switch(parse_t *parse);
    8485static stree_while_t *parse_while(parse_t *parse);
    8586static stree_for_t *parse_for(parse_t *parse);
     
    667668        stree_prop_t *prop;
    668669        stree_symbol_t *symbol;
    669         bool_t body_expected;
    670670
    671671        stree_ident_t *ident;
     
    720720        /* Parse attributes. */
    721721        parse_symbol_attrs(parse, symbol);
    722 
    723         body_expected = (outer_csi->cc != csi_interface);
    724722
    725723        lmatch(parse, lc_is);
     
    10701068        stree_vdecl_t *vdecl_s;
    10711069        stree_if_t *if_s;
     1070        stree_switch_t *switch_s;
    10721071        stree_while_t *while_s;
    10731072        stree_for_t *for_s;
     
    10921091                stat->u.if_s = if_s;
    10931092                break;
     1093        case lc_switch:
     1094                switch_s = parse_switch(parse);
     1095                stat = stree_stat_new(st_switch);
     1096                stat->u.switch_s = switch_s;
     1097                break;
    10941098        case lc_while:
    10951099                while_s = parse_while(parse);
     
    12141218        lmatch(parse, lc_end);
    12151219        return if_s;
     1220}
     1221
     1222/** Parse @c switch statement.
     1223 *
     1224 * @param parse         Parser object.
     1225 * @return              New syntax tree node.
     1226 */
     1227static stree_switch_t *parse_switch(parse_t *parse)
     1228{
     1229        stree_switch_t *switch_s;
     1230        stree_when_t *when_c;
     1231        stree_expr_t *expr;
     1232
     1233#ifdef DEBUG_PARSE_TRACE
     1234        printf("Parse 'switch' statement.\n");
     1235#endif
     1236        lmatch(parse, lc_switch);
     1237
     1238        switch_s = stree_switch_new();
     1239        list_init(&switch_s->when_clauses);
     1240
     1241        switch_s->expr = parse_expr(parse);
     1242        lmatch(parse, lc_is);
     1243
     1244        /* Parse @c when clauses. */
     1245        while (lcur_lc(parse) == lc_when) {
     1246                lskip(parse);
     1247                when_c = stree_when_new();
     1248                list_init(&when_c->exprs);
     1249                while (b_true) {
     1250                        expr = parse_expr(parse);
     1251                        list_append(&when_c->exprs, expr);
     1252                        if (lcur_lc(parse) != lc_comma)
     1253                                break;
     1254                        lskip(parse);
     1255                }
     1256
     1257                lmatch(parse, lc_do);
     1258                when_c->block = parse_block(parse);
     1259
     1260                list_append(&switch_s->when_clauses, when_c);
     1261        }
     1262
     1263        /* Parse @c else clause. */
     1264        if (lcur_lc(parse) == lc_else) {
     1265                lskip(parse);
     1266                lmatch(parse, lc_do);
     1267                switch_s->else_block = parse_block(parse);
     1268        } else {
     1269                switch_s->else_block = NULL;
     1270        }
     1271
     1272        lmatch(parse, lc_end);
     1273        return switch_s;
    12161274}
    12171275
     
    16541712        case lc_except:
    16551713        case lc_finally:
     1714        case lc_when:
    16561715                return b_true;
    16571716        default:
Note: See TracChangeset for help on using the changeset viewer.