All pastes #512031 Raw Edit

piromanas

public cpp v1 · immutable
#512031 ·published 2007-05-26 18:01 UTC
rendered paste body
template<typename iterator>void parse (iterator begin,iterator end,list<node *> & output) {    string::iterator i = begin, i1 ;    while (i != end) {        if (*i >= '0' && i* <= '9' && i != end) {            i1 = i ;            while (*i >= '0' && i* <= '9' && i != end) {                ++i ;            }            node* n = new node ;            string str1 (i1,i-1) ;            istringstream stream (str1) ;            float f ;            stream >> f ;            n->value = f ;            output.push_back(n) ;        }        else            if ( isalpha(*i) && i != end ) {                i1 = i ;                while ( isalpha(*i) && i != end ) {                    ++i ;                }                node* n = new node ;                string str1 (i1,i-1) ;                n->operation = find_op(str1.c_str()) ;                output.push_back(n) ;            }        else                if ( (*i == '+') || (*i == '-') || (*i == '*') || (*i == '/') || (*i == '^') && i != end ) {                node* n = new node ;                n->operation = find_op(*i) ;                output.push_back(n) ;                 ++i ;            }    }            }