Changeset 37f527b in mainline for uspace/app/sbi/src/lex.c


Ignore:
Timestamp:
2010-03-26T21:55:23Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4204ad9
Parents:
b535aeb
Message:

Update SBI to rev. 144.

File:
1 edited

Legend:

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

    rb535aeb r37f527b  
    4444#define TAB_WIDTH 8
    4545
    46 static bool_t lex_next_try(lex_t *lex);
     46static void lex_touch(lex_t *lex);
     47static bool_t lex_read_try(lex_t *lex);
    4748
    4849static void lex_skip_comment(lex_t *lex);
     
    7273/** Keyword names. Used both for printing and recognition. */
    7374static struct lc_name keywords[] = {
     75        { lc_as,        "as" },
     76        { lc_builtin,   "builtin" },
    7477        { lc_class,     "class" },
    7578        { lc_constructor,       "constructor" },
     
    9699        { lc_public,    "public" },
    97100        { lc_raise,     "raise" },
     101        { lc_resource,  "resource" },
    98102        { lc_return,    "return" },
    99103        { lc_self,      "self" },
     
    221225        lex->ibp = lex->inbuf;
    222226        lex->col_adj = 0;
    223 }
    224 
    225 /** Read next lexical element. */
     227        lex->current_valid = b_true;
     228}
     229
     230/** Advance to next lexical element.
     231 *
     232 * The new element be read in lazily then it is actually accessed.
     233 */
    226234void lex_next(lex_t *lex)
    227235{
     236        /* Make sure the current lem has already been read in. */
     237        lex_touch(lex);
     238
     239        /* Force a new lem to be read on next access. */
     240        lex->current_valid = b_false;
     241}
     242
     243/** Get current lem.
     244 *
     245 * The returned pointer is invalidated by next call to lex_next()
     246 */
     247lem_t *lex_get_current(lex_t *lex)
     248{
     249        lex_touch(lex);
     250        return &lex->current;
     251}
     252
     253/** Read in the current lexical element (unless already read in). */
     254static void lex_touch(lex_t *lex)
     255{
    228256        bool_t got_lem;
    229257
     258        if (lex->current_valid == b_true)
     259                return;
     260
    230261        do {
    231                 got_lem = lex_next_try(lex);
     262                got_lem = lex_read_try(lex);
    232263        } while (got_lem == b_false);
     264
     265        lex->current_valid = b_true;
    233266}
    234267
     
    237270 * @return @c b_true on success or @c b_false if it needs restarting.
    238271 */
    239 static bool_t lex_next_try(lex_t *lex)
     272static bool_t lex_read_try(lex_t *lex)
    240273{
    241274        char *bp;
Note: See TracChangeset for help on using the changeset viewer.