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


Ignore:
Timestamp:
2010-04-04T22:32:39Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0a72efc
Parents:
73060801 (diff), 23de644 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jsvoboda/helenos/sysel.

File:
1 edited

Legend:

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

    r73060801 recb6ac32  
    3434#include <stdio.h>
    3535#include <stdlib.h>
     36#include "bigint.h"
    3637#include "mytypes.h"
    3738#include "input.h"
     
    135136        { lc_assign,    "=" },
    136137        { lc_plus,      "+" },
     138        { lc_minus,     "-" },
     139        { lc_mult,      "*" },
    137140        { lc_increase,  "+=" },
    138141
     
    205208                break;
    206209        case lc_lit_int:
    207                 printf("(%d)", lem->u.lit_int.value);
     210                printf("(");
     211                bigint_print(&lem->u.lit_int.value);
     212                printf(")");
    208213                break;
    209214        case lc_lit_string:
     
    267272 *
    268273 * @param lex           Lexer object.
     274 * @return              Pointer to current lem. Owned by @a lex and only valid
     275 *                      until next call to lex_next().
    269276 */
    270277lem_t *lex_get_current(lex_t *lex)
     
    376383                lex->current.lclass = lc_plus; ++bp; break;
    377384
     385        case '-':
     386                lex->current.lclass = lc_minus; ++bp; break;
     387
     388        case '*':
     389                lex->current.lclass = lc_mult; ++bp; break;
     390
    378391        case '<':
    379392                if (bp[1] == '=') {
     
    458471{
    459472        char *bp;
    460         int value;
     473        bigint_t value;
     474        bigint_t dgval;
     475        bigint_t base;
     476        bigint_t tprod;
    461477
    462478        bp = lex->ibp;
    463         value = 0;
     479
     480        bigint_init(&value, 0);
     481        bigint_init(&base, 10);
    464482
    465483        while (is_digit(*bp)) {
    466                 value = value * 10 + digit_value(*bp);
     484                bigint_mul(&value, &base, &tprod);
     485                bigint_init(&dgval, digit_value(*bp));
     486
     487                bigint_destroy(&value);
     488                bigint_add(&tprod, &dgval, &value);
     489                bigint_destroy(&tprod);
     490                bigint_destroy(&dgval);
     491
    467492                ++bp;
    468493        }
    469494
     495        bigint_destroy(&base);
     496
    470497        lex->ibp = bp;
    471498
    472499        lex->current.lclass = lc_lit_int;
    473         lex->current.u.lit_int.value = value;
     500        bigint_shallow_copy(&value, &lex->current.u.lit_int.value);
    474501}
    475502
Note: See TracChangeset for help on using the changeset viewer.