Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/p_type.c
- Timestamp:
- 2010-03-29T20:30:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a95310e
- Parents:
- 5da468e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/p_type.c
r5da468e r1ebc1a62 1 /* YI1 /* 2 2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. … … 31 31 #include <assert.h> 32 32 #include <stdlib.h> 33 #include "debug.h" 33 34 #include "lex.h" 34 35 #include "list.h" … … 48 49 static stree_tnameref_t *parse_tnameref(parse_t *parse); 49 50 50 /** Parse type expression. */ 51 static stree_texpr_t *parse_recovery_texpr(parse_t *parse); 52 53 /** Parse type expression. 54 * 55 * Input is read from the input object associated with @a parse. If any 56 * error occurs, parse->error will @c b_true when this function 57 * returns. parse->error_bailout will be @c b_true if the error has not 58 * been recovered yet. Similar holds for other parsing functions in this 59 * module. 60 * 61 * @param parse Parser object. 62 */ 51 63 stree_texpr_t *parse_texpr(parse_t *parse) 52 64 { 65 #ifdef DEBUG_PARSE_TRACE 66 printf("Parse type expression.\n"); 67 #endif 68 if (parse_is_error(parse)) 69 return parse_recovery_texpr(parse); 70 53 71 return parse_tapply(parse); 54 72 } 55 73 56 /** Parse type application expression. */ 74 /** Parse type application expression. 75 * 76 * @param parse Parser object. 77 */ 57 78 static stree_texpr_t *parse_tapply(parse_t *parse) 58 79 { … … 62 83 a = parse_tpostfix(parse); 63 84 while (lcur_lc(parse) == lc_slash) { 85 86 if (parse_is_error(parse)) 87 break; 88 64 89 lskip(parse); 65 90 b = parse_tpostfix(parse); … … 77 102 } 78 103 79 /** Parse postfix type expression. */ 104 /** Parse postfix type expression. 105 * 106 * @param parse Parser object. 107 */ 80 108 static stree_texpr_t *parse_tpostfix(parse_t *parse) 81 109 { … … 86 114 87 115 while (lcur_lc(parse) == lc_period || lcur_lc(parse) == lc_lsbr) { 116 117 if (parse_is_error(parse)) 118 break; 88 119 89 120 switch (lcur_lc(parse)) { … … 96 127 default: 97 128 lunexpected_error(parse); 98 exit(1); 129 tmp = parse_recovery_texpr(parse); 130 break; 99 131 } 100 132 … … 105 137 } 106 138 107 /** Parse access type expression. */ 139 /** Parse access type expression. 140 * 141 * @param parse Parser object. 142 * @param a Base expression. 143 */ 108 144 static stree_texpr_t *parse_pf_taccess(parse_t *parse, stree_texpr_t *a) 109 145 { … … 125 161 } 126 162 127 /** Parse index type expression. */ 163 /** Parse index type expression. 164 * 165 * @param parse Parser object. 166 * @param a Base expression. 167 */ 128 168 static stree_texpr_t *parse_pf_tindex(parse_t *parse, stree_texpr_t *a) 129 169 { … … 142 182 if (lcur_lc(parse) != lc_rsbr && lcur_lc(parse) != lc_comma) { 143 183 while (b_true) { 184 if (parse_is_error(parse)) 185 break; 144 186 expr = parse_expr(parse); 145 187 tindex->n_args += 1; … … 154 196 tindex->n_args = 1; 155 197 while (lcur_lc(parse) == lc_comma) { 198 if (parse_is_error(parse)) 199 break; 156 200 lskip(parse); 157 201 tindex->n_args += 1; … … 167 211 } 168 212 169 /** Parse primitive type expression. */ 213 /** Parse primitive type expression. 214 * 215 * @param parse Parser object. 216 */ 170 217 static stree_texpr_t *parse_tprimitive(parse_t *parse) 171 218 { … … 185 232 default: 186 233 lunexpected_error(parse); 187 exit(1); 234 texpr = parse_recovery_texpr(parse); 235 break; 188 236 } 189 237 … … 191 239 } 192 240 193 /** Parse type literal. */ 241 /** Parse type literal. 242 * 243 * @param parse Parser object. 244 */ 194 245 static stree_tliteral_t *parse_tliteral(parse_t *parse) 195 246 { … … 217 268 } 218 269 219 /** Parse type identifier. */ 270 /** Parse type identifier. 271 * 272 * @param parse Parser object. 273 */ 220 274 static stree_tnameref_t *parse_tnameref(parse_t *parse) 221 275 { … … 227 281 return tnameref; 228 282 } 283 284 /** Construct a special type expression fore recovery. 285 * 286 * @param parse Parser object. 287 */ 288 static stree_texpr_t *parse_recovery_texpr(parse_t *parse) 289 { 290 stree_tliteral_t *tliteral; 291 stree_texpr_t *texpr; 292 293 (void) parse; 294 295 tliteral = stree_tliteral_new(tlc_int); 296 297 texpr = stree_texpr_new(tc_tliteral); 298 texpr->u.tliteral = tliteral; 299 300 return texpr; 301 }
Note:
See TracChangeset
for help on using the changeset viewer.