Ignore:
File:
1 edited

Legend:

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

    r074444f r23de644  
    5353static bool_t is_digit(char c);
    5454static void lex_word(lex_t *lex);
    55 static void lex_char(lex_t *lex);
    5655static void lex_number(lex_t *lex);
    5756static void lex_string(lex_t *lex);
     
    7574static struct lc_name keywords[] = {
    7675        { lc_as,        "as" },
    77         { lc_bool,      "bool" },
    78         { lc_char,      "char" },
    7976        { lc_builtin,   "builtin" },
    8077        { lc_class,     "class" },
     
    8481        { lc_end,       "end" },
    8582        { lc_except,    "except" },
    86         { lc_false,     "false" },
    8783        { lc_finally,   "finally" },
    8884        { lc_for,       "for" },
     
    112108        { lc_then,      "then" },
    113109        { lc_this,      "this" },
    114         { lc_true,      "true" },
    115110        { lc_var,       "var" },
    116111        { lc_with,      "with" },
     
    343338        }
    344339
    345         if (bp[0] == '\'') {
    346                 lex_char(lex);
    347                 return b_true;
    348         }
    349 
    350340        if (is_digit(bp[0])) {
    351341                lex_number(lex);
     
    470460        lex->current.lclass = lc_ident;
    471461        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);
    518462}
    519463
Note: See TracChangeset for help on using the changeset viewer.