00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_LETTER_CHAR_LETTER_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_CHAR_LETTER_HXX
00019
00020 # include <string>
00021
00022 # include <vaucanson/algebra/implementation/letter/char_letter.hh>
00023
00024 namespace vcsn {
00025
00026 namespace algebra {
00027
00028 template <>
00029 struct letter_traits<char>
00030 {
00031
00032 typedef misc::true_t is_char_letter;
00033
00034 enum
00035 {
00036
00037
00038
00039
00040 cardinal = 255
00041 };
00042
00043
00044 static const char default_joker() { return '?'; }
00045 static const char default_other() { return '#'; }
00046
00047 LETTER_DEFAULT(open_par, "(")
00048 LETTER_DEFAULT(close_par, ")")
00049 LETTER_DEFAULT(plus, "+")
00050 LETTER_DEFAULT(times, ".")
00051 LETTER_DEFAULT(star, "*")
00052 LETTER_DEFAULT(epsilon, "1")
00053 LETTER_DEFAULT(zero, "0")
00054 LETTER_DEFAULT(open_weight, "{")
00055 LETTER_DEFAULT(close_weight, "}")
00056 LETTER_DEFAULT(space, " ")
00057
00058 static
00059 char
00060 literal_to_letter(const std::string& str)
00061 {
00062 precondition(str.size() == 1);
00063 return str[0];
00064 }
00065
00066 static
00067 std::string
00068 letter_to_literal(const char& c)
00069 {
00070 std::string str;
00071 str = str + c;
00072 return str;
00073 }
00074 };
00075
00076 template <typename S, typename CharContainer>
00077 bool op_parse(const algebra::FreeMonoidBase<S>& set,
00078 std::basic_string<char>& v,
00079 const std::string& s,
00080 typename std::string::const_iterator& i,
00081 const CharContainer&)
00082 {
00083 typename std::string::const_iterator j = i;
00084 typename std::string::const_iterator k;
00085
00086 while ((i != s.end()) && (set.alphabet().contains(*i)))
00087 {
00088 v += *i;
00089 ++i;
00090 }
00091 return (i != j);
00092 }
00093
00094 } // ! algebra
00095
00096 } // ! vcsn
00097
00098 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_CHAR_LETTER_HXX