Changeset 37f527b in mainline for uspace/app/sbi/src/lex.c
- Timestamp:
- 2010-03-26T21:55:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4204ad9
- Parents:
- b535aeb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/lex.c
rb535aeb r37f527b 44 44 #define TAB_WIDTH 8 45 45 46 static bool_t lex_next_try(lex_t *lex); 46 static void lex_touch(lex_t *lex); 47 static bool_t lex_read_try(lex_t *lex); 47 48 48 49 static void lex_skip_comment(lex_t *lex); … … 72 73 /** Keyword names. Used both for printing and recognition. */ 73 74 static struct lc_name keywords[] = { 75 { lc_as, "as" }, 76 { lc_builtin, "builtin" }, 74 77 { lc_class, "class" }, 75 78 { lc_constructor, "constructor" }, … … 96 99 { lc_public, "public" }, 97 100 { lc_raise, "raise" }, 101 { lc_resource, "resource" }, 98 102 { lc_return, "return" }, 99 103 { lc_self, "self" }, … … 221 225 lex->ibp = lex->inbuf; 222 226 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 */ 226 234 void lex_next(lex_t *lex) 227 235 { 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 */ 247 lem_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). */ 254 static void lex_touch(lex_t *lex) 255 { 228 256 bool_t got_lem; 229 257 258 if (lex->current_valid == b_true) 259 return; 260 230 261 do { 231 got_lem = lex_ next_try(lex);262 got_lem = lex_read_try(lex); 232 263 } while (got_lem == b_false); 264 265 lex->current_valid = b_true; 233 266 } 234 267 … … 237 270 * @return @c b_true on success or @c b_false if it needs restarting. 238 271 */ 239 static bool_t lex_ next_try(lex_t *lex)272 static bool_t lex_read_try(lex_t *lex) 240 273 { 241 274 char *bp;
Note:
See TracChangeset
for help on using the changeset viewer.