Obrazki, ktore może narysuje w weekend.
Nie pisemnie
zmieniamy funkcje nexttoken na nastepujaca i w definicji klasy token, zmieniamy liste unsigned intów na signed
int chartoint( char c ) { switch (c) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': return c - '0'; case 'a': case 'A': return 10; case 'b': case 'B': return 11; case 'c': case 'C': return 12; case 'd': case 'D': return 13; case 'e': case 'E': return 14; case 'f': case 'F': return 15; default: return 17; } } token nexttoken( reader& r ) { if( r. lookahead == EOF ) return token::token( tkn_eof ); int val,sign; //hexadecimal number with initial '$' if( r. lookahead == '$' ) { r. moveforward( ); val = 0; if( chartoint(r.lookahead) == 17 ) goto err; while( chartoint(r.lookahead) != 17 ) { val *= 16; val += chartoint( r.lookahead ); r.moveforward(); } token th = tkn_int; th.intattr.push_back( val ); return th; } //decimal integer with possible initial '+' or '-' if( r. lookahead == '-' ) { r.moveforward( ); sign = -1; val = 0; } else if( r.lookahead == '+' ) { r.moveforward( ); sign = 1; val = 0; } else if( r.lookahead >= '0' && r.lookahead <= '9' ) { sign = 1; val = 0; } else { goto err; } if( r.lookahead < '0' || r.lookahead > '9' ) goto err; { while( r.lookahead >= '0' && r.lookahead <= '9' ) { val *= 10; val += r.lookahead - '0'; r.moveforward(); } token t = tkn_int; t.intattr.push_back( sign*val ); return t; } err: token te = tkn_error; te. stringattr. push_back( std::string( )); te. stringattr. back( ) += r. lookahead; r. moveforward( ); return te; }