Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/lex.c
- Timestamp:
- 2010-03-29T20:30:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a95310e
- Parents:
- 5da468e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/lex.c
r5da468e r1ebc1a62 145 145 }; 146 146 147 /** Print lclass value. */ 147 /** Print lclass value. 148 * 149 * Prints lclass (lexical element class) value in human-readable form 150 * (for debugging). 151 * 152 * @param lclass Lclass value for display. 153 */ 148 154 void lclass_print(lclass_t lclass) 149 155 { … … 184 190 } 185 191 186 /** Print lexical element. */ 192 /** Print lexical element. 193 * 194 * Prints lexical element in human-readable form (for debugging). 195 * 196 * @param lem Lexical element for display. 197 */ 187 198 void lem_print(lem_t *lem) 188 199 { … … 203 214 } 204 215 205 /** Print lem coordinates. */ 216 /** Print lem coordinates. 217 * 218 * Print the coordinates (line number, column number) of a lexical element. 219 * 220 * @param lem Lexical element for coordinate printing. 221 */ 206 222 void lem_print_coords(lem_t *lem) 207 223 { … … 209 225 } 210 226 211 /** Initialize lexer instance. */ 227 /** Initialize lexer instance. 228 * 229 * @param lex Lexer object to initialize. 230 * @param input Input to associate with lexer. 231 */ 212 232 void lex_init(lex_t *lex, struct input *input) 213 233 { … … 229 249 /** Advance to next lexical element. 230 250 * 231 * The new element be read in lazily then it is actually accessed. 251 * The new element is read in lazily then it is actually accessed. 252 * 253 * @param lex Lexer object. 232 254 */ 233 255 void lex_next(lex_t *lex) … … 243 265 * 244 266 * The returned pointer is invalidated by next call to lex_next() 267 * 268 * @param lex Lexer object. 245 269 */ 246 270 lem_t *lex_get_current(lex_t *lex) … … 250 274 } 251 275 252 /** Read in the current lexical element (unless already read in). */ 276 /** Read in the current lexical element (unless already read in). 277 * 278 * @param lex Lexer object. 279 */ 253 280 static void lex_touch(lex_t *lex) 254 281 { … … 267 294 /** Try reading next lexical element. 268 295 * 269 * @return @c b_true on success or @c b_false if it needs restarting. 296 * Attemps to read the next lexical element. In some cases (such as a comment) 297 * this function will need to give it another try and returns @c b_false 298 * in such case. 299 * 300 * @param lex Lexer object. 301 * @return @c b_true on success or @c b_false if it needs 302 * restarting. On success the lem is stored to 303 * the current lem in @a lex. 270 304 */ 271 305 static bool_t lex_read_try(lex_t *lex) … … 369 403 } 370 404 371 /** Lex a word (identifier or keyword). */ 405 /** Lex a word (identifier or keyword). 406 * 407 * Read in a word. This may later turn out to be a keyword or a regular 408 * identifier. It is stored in the current lem in @a lex. 409 * 410 * @param lex Lexer object. 411 */ 372 412 static void lex_word(lex_t *lex) 373 413 { … … 409 449 } 410 450 411 /** Lex a numeric literal. */ 451 /** Lex a numeric literal. 452 * 453 * Reads in a numeric literal and stores it in the current lem in @a lex. 454 * 455 * @param lex Lexer object. 456 */ 412 457 static void lex_number(lex_t *lex) 413 458 { … … 429 474 } 430 475 431 /** Lex a string literal. */ 476 /** Lex a string literal. 477 * 478 * Reads in a string literal and stores it in the current lem in @a lex. 479 * 480 * @param lex Lexer object. 481 */ 432 482 static void lex_string(lex_t *lex) 433 483 { … … 461 511 } 462 512 463 /** Lex a single-line comment. */ 513 /** Lex a single-line comment. 514 * 515 * This does not produce any lem. The comment is just skipped. 516 * 517 * @param lex Lexer object. 518 */ 464 519 static void lex_skip_comment(lex_t *lex) 465 520 { … … 475 530 } 476 531 477 /** Skip whitespace characters. */ 532 /** Skip whitespace characters. 533 * 534 * This does not produce any lem. The whitespace is just skipped. 535 * 536 * @param lex Lexer object. 537 */ 478 538 static void lex_skip_ws(lex_t *lex) 479 539 { … … 485 545 while (b_true) { 486 546 while (*bp == ' ' || *bp == '\t') { 487 if (*bp == '\t') 547 if (*bp == '\t') { 548 /* XXX This is too simplifed. */ 488 549 lex->col_adj += (TAB_WIDTH - 1); 550 } 489 551 ++bp; 490 552 } … … 507 569 } 508 570 509 /** Determine if character can start a word. */ 571 /** Determine if character can start a word. 572 * 573 * @param c Character. 574 * @return @c b_true if @a c can start a word, @c b_false otherwise. 575 */ 510 576 static bool_t is_wstart(char c) 511 577 { … … 514 580 } 515 581 516 /** Determine if character can continue a word. */ 582 /** Determine if character can continue a word. 583 * 584 * @param c Character. 585 * @return @c b_true if @a c can start continue word, @c b_false 586 * otherwise. 587 */ 517 588 static bool_t is_wcont(char c) 518 589 { … … 520 591 } 521 592 593 /** Determine if character is a numeric digit. 594 * 595 * @param c Character. 596 * @return @c b_true if @a c is a numeric digit, @c b_false otherwise. 597 */ 522 598 static bool_t is_digit(char c) 523 599 { … … 525 601 } 526 602 603 /** Determine numeric value of digit character. 604 * 605 * @param c Character, must be a valid decimal digit. 606 * @return Value of the digit (0-9). 607 */ 527 608 static int digit_value(char c) 528 609 {
Note:
See TracChangeset
for help on using the changeset viewer.