Changes in uspace/app/sbi/src/lex.c [074444f:23de644] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/lex.c
r074444f r23de644 53 53 static bool_t is_digit(char c); 54 54 static void lex_word(lex_t *lex); 55 static void lex_char(lex_t *lex);56 55 static void lex_number(lex_t *lex); 57 56 static void lex_string(lex_t *lex); … … 75 74 static struct lc_name keywords[] = { 76 75 { lc_as, "as" }, 77 { lc_bool, "bool" },78 { lc_char, "char" },79 76 { lc_builtin, "builtin" }, 80 77 { lc_class, "class" }, … … 84 81 { lc_end, "end" }, 85 82 { lc_except, "except" }, 86 { lc_false, "false" },87 83 { lc_finally, "finally" }, 88 84 { lc_for, "for" }, … … 112 108 { lc_then, "then" }, 113 109 { lc_this, "this" }, 114 { lc_true, "true" },115 110 { lc_var, "var" }, 116 111 { lc_with, "with" }, … … 343 338 } 344 339 345 if (bp[0] == '\'') {346 lex_char(lex);347 return b_true;348 }349 350 340 if (is_digit(bp[0])) { 351 341 lex_number(lex); … … 470 460 lex->current.lclass = lc_ident; 471 461 lex->current.u.ident.sid = strtab_get_sid(ident_buf); 472 }473 474 /** Lex a character literal.475 *476 * Reads in a character literal and stores it in the current lem in @a lex.477 *478 * @param lex Lexer object.479 */480 static void lex_char(lex_t *lex)481 {482 char *bp;483 int idx;484 size_t len;485 int char_val;486 487 bp = lex->ibp + 1;488 idx = 0;489 490 while (bp[idx] != '\'') {491 if (idx >= SLBUF_SIZE) {492 printf("Error: Character literal too long.\n");493 exit(1);494 }495 496 if (bp[idx] == '\0') {497 printf("Error: Unterminated character literal.\n");498 exit(1);499 }500 501 strlit_buf[idx] = bp[idx];502 ++idx;503 }504 505 lex->ibp = bp + idx + 1;506 507 strlit_buf[idx] = '\0';508 len = os_str_length(strlit_buf);509 if (len != 1) {510 printf("Character literal should contain one character, "511 "but contains %u characters instead.\n", (unsigned) len);512 exit(1);513 }514 515 os_str_get_char(strlit_buf, 0, &char_val);516 lex->current.lclass = lc_lit_char;517 bigint_init(&lex->current.u.lit_char.value, char_val);518 462 } 519 463
Note:
See TracChangeset
for help on using the changeset viewer.