00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
00019 
00020 # include <sstream>
00021 
00022 # include <vaucanson/algebra/implementation/letter/int_letter.hh>
00023 
00024 namespace vcsn {
00025 
00026   namespace algebra {
00027 
00028     template <typename S>
00029     bool op_parse(const algebra::FreeMonoidBase<S>& set,
00030                   std::list<int>& v,
00031                   const std::string& s,
00032                   typename std::string::const_iterator& i,
00033                   const std::list<char>& escaped)
00034     {
00035       typename std::string::const_iterator j = i;
00036       typename std::string::const_iterator k;
00037       typename std::string::const_iterator back;
00038 
00039       while ((i != s.end()) &&
00040              (std::find(escaped.begin(), escaped.end(), *i) == escaped.end())) {
00041         std::string out;
00042         back = i;
00043 
00044         while ((i != s.end()) && (((*i >= '0') && (*i <= '9'))) || (*i == '\\'))
00045           if (*i == '\\') {
00046             k = i;
00047             ++k;
00048             if (k != s.end())
00049               i = k;
00050             out += *i;
00051             ++i;
00052           }
00053           else {
00054             out += *i;
00055             ++i;
00056           }
00057 
00058         int value;
00059         std::istringstream is(out);
00060         is >> value;
00061         if (!set.alphabet().contains(value)) {
00062           i = back;
00063           break ;
00064         }
00065         v.push_back(value);
00066       }
00067       return (i != j);
00068     }
00069 
00070   } 
00071 
00072 } 
00073 
00074 namespace std {
00075 
00076   ostream& operator<<(ostream& o, list<int> s)
00077   {
00078     list<int>::const_iterator i;
00079     list<int>::const_iterator j;
00080 
00081     for (i = s.begin(); i != s.end(); ) {
00082       o << *i;
00083       i++;
00084       if (i != s.end())
00085         o << ",";
00086     }
00087 
00088     return o;
00089   }
00090 
00091 } 
00092 
00093 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX