Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/lex.c


Ignore:
Timestamp:
2010-03-29T20:30:29Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a95310e
Parents:
5da468e
Message:

Update SBI to rev. 157.

File:
1 edited

Legend:

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

    r5da468e r1ebc1a62  
    145145};
    146146
    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 */
    148154void lclass_print(lclass_t lclass)
    149155{
     
    184190}
    185191
    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 */
    187198void lem_print(lem_t *lem)
    188199{
     
    203214}
    204215
    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 */
    206222void lem_print_coords(lem_t *lem)
    207223{
     
    209225}
    210226
    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 */
    212232void lex_init(lex_t *lex, struct input *input)
    213233{
     
    229249/** Advance to next lexical element.
    230250 *
    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.
    232254 */
    233255void lex_next(lex_t *lex)
     
    243265 *
    244266 * The returned pointer is invalidated by next call to lex_next()
     267 *
     268 * @param lex           Lexer object.
    245269 */
    246270lem_t *lex_get_current(lex_t *lex)
     
    250274}
    251275
    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 */
    253280static void lex_touch(lex_t *lex)
    254281{
     
    267294/** Try reading next lexical element.
    268295 *
    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.
    270304 */
    271305static bool_t lex_read_try(lex_t *lex)
     
    369403}
    370404
    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 */
    372412static void lex_word(lex_t *lex)
    373413{
     
    409449}
    410450
    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 */
    412457static void lex_number(lex_t *lex)
    413458{
     
    429474}
    430475
    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 */
    432482static void lex_string(lex_t *lex)
    433483{
     
    461511}
    462512
    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 */
    464519static void lex_skip_comment(lex_t *lex)
    465520{
     
    475530}
    476531
    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 */
    478538static void lex_skip_ws(lex_t *lex)
    479539{
     
    485545        while (b_true) {
    486546                while (*bp == ' ' || *bp == '\t') {
    487                         if (*bp == '\t')
     547                        if (*bp == '\t') {
     548                                /* XXX This is too simplifed. */
    488549                                lex->col_adj += (TAB_WIDTH - 1);
     550                        }
    489551                        ++bp;
    490552                }
     
    507569}
    508570
    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 */
    510576static bool_t is_wstart(char c)
    511577{
     
    514580}
    515581
    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 */
    517588static bool_t is_wcont(char c)
    518589{
     
    520591}
    521592
     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 */
    522598static bool_t is_digit(char c)
    523599{
     
    525601}
    526602
     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 */
    527608static int digit_value(char c)
    528609{
Note: See TracChangeset for help on using the changeset viewer.