00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef EXTENDED_REGULAR_EXPRESSIONONE_CHAR_OR_COLL_ELEM_ERE_H
00021 #define EXTENDED_REGULAR_EXPRESSIONONE_CHAR_OR_COLL_ELEM_ERE_H
00022
00023 namespace extended_regular_expression {
00024
00044 template<typename E>
00045 class one_char_or_coll_elem_ere
00046 {
00047 typedef typename grammar_to_parser::basic_parser<E>::parser_list
00048 parser_list;
00049 typedef bracket_expression::bracket_expr<E> bracket_expr_type;
00050 typedef bracket_expression::collating_symbol<E> collating_symbol_type;
00051
00052 class quoted_char
00053 {
00054 grammar_to_parser::basic_terminal<E,'\\'> m_backslash;
00055 grammar_to_parser::basic_choice<E, special_chars<E> >
00056 m_spec_chars;
00057 public:
00058 quoted_char() {};
00059 ~quoted_char() {};
00060
00061 void push_parsers( parser_list &l )
00062 {
00063 l.push_back(&m_backslash);
00064 l.push_back(&m_spec_chars);
00065 }
00066 unsigned long recognize( const E* buf,
00067 const unsigned long buf_length )
00068 {
00069 return m_spec_chars->recognize(buf,buf_length);
00070 }
00071 };
00072 grammar_to_parser::basic_except_terminal<E,special_chars<E> >
00073 m_ord_char;
00074 grammar_to_parser::basic_non_terminal<E,quoted_char> m_quoted_char;
00075 grammar_to_parser::basic_terminal<E,'.'> m_dot;
00076 grammar_to_parser::basic_choice<E, bracket_expr_type > m_bracket_expr;
00077 public:
00078 one_char_or_coll_elem_ere() {};
00079 ~one_char_or_coll_elem_ere() {};
00080
00081 void push_parsers( parser_list &l )
00082 {
00083 l.push_back(&m_ord_char);
00084 l.push_back(&m_quoted_char);
00085 l.push_back(&m_dot);
00086 l.push_back(&m_bracket_expr);
00087 }
00088
00089 unsigned long recognize( const E* buf,
00090 const unsigned long buf_length,
00091 const unsigned long buf_offset )
00092 {
00093 if( m_ord_char.is_parsed() )
00094 {
00095 if( m_ord_char.get_valid() == buf[buf_offset] )
00096 {
00097 return collating_symbol_type::get_symbol_len(buf+buf_offset,
00098 buf_length-buf_offset);
00099 }
00100 else
00101 {
00102 return 0;
00103 }
00104 }
00105 else if( m_quoted_char.is_parsed() )
00106 {
00107 return m_quoted_char->recognize( buf+buf_offset,
00108 buf_length-buf_offset );
00109 }
00110 else if( m_dot.is_parsed() )
00111 {
00112 return collating_symbol_type::get_symbol_len( buf+buf_offset,
00113 buf_length-buf_offset );
00114 }
00115 else
00116 {
00117 return m_bracket_expr->recognize( buf+buf_offset,
00118 buf_length-buf_offset );
00119 }
00120 }
00121 };
00122
00123
00124 };
00125 #endif