Changeset 23de644 in mainline for uspace/app/sbi/src/lex.c
- Timestamp:
- 2010-04-04T22:31:01Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 074444f, ecb6ac32
- Parents:
- 3aae4e8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/lex.c
r3aae4e8 r23de644 34 34 #include <stdio.h> 35 35 #include <stdlib.h> 36 #include "bigint.h" 36 37 #include "mytypes.h" 37 38 #include "input.h" … … 135 136 { lc_assign, "=" }, 136 137 { lc_plus, "+" }, 138 { lc_minus, "-" }, 139 { lc_mult, "*" }, 137 140 { lc_increase, "+=" }, 138 141 … … 205 208 break; 206 209 case lc_lit_int: 207 printf("(%d)", lem->u.lit_int.value); 210 printf("("); 211 bigint_print(&lem->u.lit_int.value); 212 printf(")"); 208 213 break; 209 214 case lc_lit_string: … … 267 272 * 268 273 * @param lex Lexer object. 274 * @return Pointer to current lem. Owned by @a lex and only valid 275 * until next call to lex_next(). 269 276 */ 270 277 lem_t *lex_get_current(lex_t *lex) … … 376 383 lex->current.lclass = lc_plus; ++bp; break; 377 384 385 case '-': 386 lex->current.lclass = lc_minus; ++bp; break; 387 388 case '*': 389 lex->current.lclass = lc_mult; ++bp; break; 390 378 391 case '<': 379 392 if (bp[1] == '=') { … … 458 471 { 459 472 char *bp; 460 int value; 473 bigint_t value; 474 bigint_t dgval; 475 bigint_t base; 476 bigint_t tprod; 461 477 462 478 bp = lex->ibp; 463 value = 0; 479 480 bigint_init(&value, 0); 481 bigint_init(&base, 10); 464 482 465 483 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 467 492 ++bp; 468 493 } 469 494 495 bigint_destroy(&base); 496 470 497 lex->ibp = bp; 471 498 472 499 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); 474 501 } 475 502
Note:
See TracChangeset
for help on using the changeset viewer.