Changeset d011038 in mainline for uspace/app/sbi/src/parse.c
- Timestamp:
- 2011-03-29T20:12:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8f17503
- Parents:
- c4fb95d3 (diff), 93ebe4e (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
rc4fb95d3 rd011038 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 82 82 static stree_vdecl_t *parse_vdecl(parse_t *parse); 83 83 static stree_if_t *parse_if(parse_t *parse); 84 static stree_switch_t *parse_switch(parse_t *parse); 84 85 static stree_while_t *parse_while(parse_t *parse); 85 86 static stree_for_t *parse_for(parse_t *parse); … … 667 668 stree_prop_t *prop; 668 669 stree_symbol_t *symbol; 669 bool_t body_expected;670 670 671 671 stree_ident_t *ident; … … 720 720 /* Parse attributes. */ 721 721 parse_symbol_attrs(parse, symbol); 722 723 body_expected = (outer_csi->cc != csi_interface);724 722 725 723 lmatch(parse, lc_is); … … 1070 1068 stree_vdecl_t *vdecl_s; 1071 1069 stree_if_t *if_s; 1070 stree_switch_t *switch_s; 1072 1071 stree_while_t *while_s; 1073 1072 stree_for_t *for_s; … … 1092 1091 stat->u.if_s = if_s; 1093 1092 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; 1094 1098 case lc_while: 1095 1099 while_s = parse_while(parse); … … 1214 1218 lmatch(parse, lc_end); 1215 1219 return if_s; 1220 } 1221 1222 /** Parse @c switch statement. 1223 * 1224 * @param parse Parser object. 1225 * @return New syntax tree node. 1226 */ 1227 static 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; 1216 1274 } 1217 1275 … … 1654 1712 case lc_except: 1655 1713 case lc_finally: 1714 case lc_when: 1656 1715 return b_true; 1657 1716 default:
Note:
See TracChangeset
for help on using the changeset viewer.