00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef EXTENDED_REGULAR_EXPRESSIONSPECIAL_CHARS_H
00021 #define EXTENDED_REGULAR_EXPRESSIONSPECIAL_CHARS_H
00022
00023 namespace extended_regular_expression {
00024
00025 template<typename E>
00026 class special_chars
00027 {
00028 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00029
00030 grammar_to_parser::basic_terminal<E,'.'> m_period;
00031 grammar_to_parser::basic_terminal<E,'['> m_left_bracket;
00032 grammar_to_parser::basic_terminal<E,'\\'> m_backslash;
00033 grammar_to_parser::basic_terminal<E,'('> m_left_parenthesis;
00034 grammar_to_parser::basic_terminal<E,')'> m_right_parenthesis;
00035 grammar_to_parser::basic_terminal<E,'*'> m_asterix;
00036 grammar_to_parser::basic_terminal<E,'+'> m_plus;
00037 grammar_to_parser::basic_terminal<E,'?'> m_question_mark;
00038 grammar_to_parser::basic_terminal<E,'{'> m_left_brace;
00039 grammar_to_parser::basic_terminal<E,'}'> m_right_brace;
00040 grammar_to_parser::basic_terminal<E,'|'> m_vertical_line;
00041 grammar_to_parser::basic_terminal<E,'^'> m_circumflex;
00042 grammar_to_parser::basic_terminal<E,'$'> m_dollar;
00043
00044 public:
00045 special_chars() {};
00046
00047 ~special_chars() {};
00048
00049 void push_parsers( parser_list &l )
00050 {
00051 l.push_back(&m_period);
00052 l.push_back(&m_left_bracket);
00053 l.push_back(&m_backslash);
00054 l.push_back(&m_left_parenthesis);
00055 l.push_back(&m_right_parenthesis);
00056 l.push_back(&m_asterix);
00057 l.push_back(&m_plus);
00058 l.push_back(&m_question_mark);
00059 l.push_back(&m_left_brace);
00060 l.push_back(&m_right_brace);
00061 l.push_back(&m_vertical_line);
00062 l.push_back(&m_circumflex);
00063 l.push_back(&m_dollar);
00064 }
00065
00066 unsigned long recognize( const E* buf, const unsigned long buf_length )
00067 {
00068 E c=0;
00069 if( m_period.is_parsed() ) c = m_period.get_valid();
00070 else if( m_left_bracket.is_parsed() ) c = m_left_bracket.get_valid();
00071 else if( m_backslash.is_parsed() ) c = m_backslash.get_valid();
00072 else if( m_left_parenthesis.is_parsed() ) c = m_left_parenthesis.get_valid();
00073 else if( m_right_parenthesis.is_parsed() ) c = m_right_parenthesis.get_valid();
00074 else if( m_asterix.is_parsed() ) c = m_asterix.get_valid();
00075 else if( m_plus.is_parsed() ) c = m_plus.get_valid();
00076 else if( m_question_mark.is_parsed() ) c = m_question_mark.get_valid();
00077 else if( m_left_brace.is_parsed() ) c = m_left_brace.get_valid();
00078 else if( m_right_brace.is_parsed() ) c = m_right_brace.get_valid();
00079 else if( m_vertical_line.is_parsed() ) c = m_vertical_line.get_valid();
00080 else if( m_circumflex.is_parsed() ) c = m_circumflex.get_valid();
00081 else if( m_dollar.is_parsed()) c = m_dollar.get_valid();
00082
00083 if( c == buf[0] ) return 1;
00084 else return 0;
00085 }
00086 };
00087
00088 };
00089
00090 #endif