I tried to change this parser which was using cin to use stringstream..
when was using cin, everything was going perfectly..
but now if I enter any expression like : 4+5 it'll get stuck on the first char (4 in this exemple..)
But I changed really few things..
added stringstream ist(temp_string);
and then I changed all cin for ist..
Do you guys see anything wrong there?
Code:Token_value get_token() { stringstream ist(temp_string); char ch = 0; do { // skip whitespace except '\n' if(!ist.get(ch)) return curr_tok = END; }while (ch != '\n' && isspace(ch)); switch (ch) { case 0 : case 'E': return curr_tok=END; case ';' : return curr_tok = PRINT; case '\n' : line_count.new_line(); case '*' : case '/' : case '+' : case '-' : case '(' : case ')' : case '=' : return curr_tok = Token_value(ch); case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : case '.' : ist.putback(ch); ist >> number_value; return curr_tok = NUMBER; default: // NAME, NAME =, or error if (isalpha(ch)) { string_value = ch; while (ist.get(ch) && isalnum(ch)) string_value.push_back(ch); ist.putback(ch); return curr_tok = NAME; } error("Bad Token"); return curr_tok = PRINT; } }