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 typedef undefined_type first_projection_t;
00045 typedef undefined_type second_projection_t;
00046
00047
00048 static char default_joker() { return '?'; }
00049 static char default_other() { return '#'; }
00050
00051 LETTER_DEFAULT(open_par, "(")
00052 LETTER_DEFAULT(close_par, ")")
00053 LETTER_DEFAULT(plus, "+")
00054 LETTER_DEFAULT(times, ".")
00055 LETTER_DEFAULT(star, "*")
00056 LETTER_DEFAULT(epsilon, "1")
00057 LETTER_DEFAULT(zero, "0")
00058 LETTER_DEFAULT(open_weight, "{")
00059 LETTER_DEFAULT(close_weight, "}")
00060 LETTER_DEFAULT(space, " ")
00061
00062 static
00063 char
00064 literal_to_letter(const std::string& str)
00065 {
00066 precondition(str.size() == 1);
00067 return str[0];
00068 }
00069
00070 static
00071 std::string
00072 letter_to_literal(const char& c)
00073 {
00074 std::string str;
00075 str = str + c;
00076 return str;
00077 }
00078
00079 // A char is "simple" with dimension 1.
00080 static std::string kind() { return "simple"; }
00081 static int dim() { return 1; }
00082
00083 };
00084
00085 template <typename S, typename CharContainer>
00086 bool op_parse(const algebra::FreeMonoidBase<S>& set,
00087 std::basic_string<char>& v,
00088 const std::string& s,
00089 typename std::string::const_iterator& i,
00090 const CharContainer&)
00091 {
00092 typename std::string::const_iterator j = i;
00093 typename std::string::const_iterator k;
00094
00095 while ((i != s.end()) && (set.alphabet().contains(*i)))
00096 {
00097 v += *i;
00098 ++i;
00099 }
00100 return (i != j);
00101 }
00102
00103 } // ! algebra
00104
00105 } // ! vcsn
00106
00107 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_CHAR_LETTER_HXX