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