Changeset 94d484a in mainline for uspace/app/sbi/src/lex.c
- Timestamp:
- 2010-03-07T17:45:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d0febca
- Parents:
- fa36f29
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/lex.c
rfa36f29 r94d484a 35 35 #include <stdlib.h> 36 36 #include <string.h> 37 #include "compat.h"38 37 #include "mytypes.h" 39 38 #include "input.h" 39 #include "os/os.h" 40 40 #include "strtab.h" 41 41 … … 44 44 #define TAB_WIDTH 8 45 45 46 static bool_t lex_next_try(lex_t *lex); 47 48 static void lex_skip_comment(lex_t *lex); 46 49 static void lex_skip_ws(lex_t *lex); 47 50 static bool_t is_wstart(char c); … … 87 90 { lc_nil, "nil" }, 88 91 { lc_override, "override" }, 92 { lc_packed, "packed" }, 89 93 { lc_private, "private" }, 90 94 { lc_prop, "prop" }, … … 222 226 void lex_next(lex_t *lex) 223 227 { 228 bool_t got_lem; 229 230 do { 231 got_lem = lex_next_try(lex); 232 } while (got_lem == b_false); 233 } 234 235 /** Try reading next lexical element. 236 * 237 * @return @c b_true on success or @c b_false if it needs restarting. 238 */ 239 static bool_t lex_next_try(lex_t *lex) 240 { 224 241 char *bp; 225 242 … … 240 257 /* End of input */ 241 258 lex->current.lclass = lc_eof; 242 return ;259 return b_true; 243 260 } 244 261 245 262 if (is_wstart(bp[0])) { 246 263 lex_word(lex); 247 return ;264 return b_true; 248 265 } 249 266 250 267 if (is_digit(bp[0])) { 251 268 lex_number(lex); 252 return ;269 return b_true; 253 270 } 254 271 255 272 if (bp[0] == '"') { 256 273 lex_string(lex); 257 return; 274 return b_true; 275 } 276 277 if (bp[0] == '-' && bp[1] == '-') { 278 lex_skip_comment(lex); 279 return b_false; 258 280 } 259 281 … … 305 327 306 328 lex->ibp = bp; 307 return ;329 return b_true; 308 330 309 331 invalid: … … 311 333 ++bp; 312 334 lex->ibp = bp; 335 336 return b_true; 313 337 } 314 338 … … 340 364 dp = keywords; 341 365 while (dp->name != NULL) { 342 if ( strcmp(ident_buf, dp->name) == 0) {366 if (os_str_cmp(ident_buf, dp->name) == 0) { 343 367 /* Match */ 344 368 lex->current.lclass = dp->lclass; … … 402 426 403 427 lex->current.lclass = lc_lit_string; 404 lex->current.u.lit_string.value = strdup(strlit_buf); 405 } 406 428 lex->current.u.lit_string.value = os_str_dup(strlit_buf); 429 } 430 431 /** Lex a single-line comment. */ 432 static void lex_skip_comment(lex_t *lex) 433 { 434 char *bp; 435 436 bp = lex->ibp + 2; 437 438 while (*bp != '\n' && *bp != '\0') { 439 ++bp; 440 } 441 442 lex->ibp = bp; 443 } 407 444 408 445 /** Skip whitespace characters. */
Note:
See TracChangeset
for help on using the changeset viewer.