00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BRACKET_EXPRESSIONBRACKET_EXPR_H
00021 #define BRACKET_EXPRESSIONBRACKET_EXPR_H
00022
00023 namespace bracket_expression {
00024
00025
00026 template<typename E>
00027 class bracket_expr
00028 {
00029 typedef typename grammar_to_parser::basic_parser<E>::parser_list
00030 parser_list;
00031
00032 class left_bracket_nonmatching_list_right_bracket{
00033 grammar_to_parser::basic_terminal<E,'['>
00034 m_left_bracket;
00035 grammar_to_parser::basic_non_terminal<E,nonmatching_list<E> >
00036 m_nonmatching_list;
00037 grammar_to_parser::basic_terminal<E,']'> m_right_bracket;
00038 public:
00039 unsigned long recognize( const E* buf, const unsigned long buf_length )
00040 {
00041 return m_nonmatching_list->recognize(buf,buf_length);
00042 }
00043 left_bracket_nonmatching_list_right_bracket() :
00044 m_nonmatching_list() {};
00045
00046 ~left_bracket_nonmatching_list_right_bracket() {};
00047 void push_parsers( parser_list &l )
00048 {
00049 l.push_back( &m_left_bracket );
00050 l.push_back( &m_nonmatching_list );
00051 l.push_back( &m_right_bracket );
00052 }
00053 };
00054
00055 class left_bracket_matching_list_rigth_bracket
00056 {
00057 grammar_to_parser::basic_terminal<E,'['> m_left_bracket;
00058 grammar_to_parser::basic_non_terminal<E,matching_list<E> > m_matching_list;
00059 grammar_to_parser::basic_terminal<E,']'> m_right_bracket;
00060 public:
00061 unsigned long recognize( const E* buf, const unsigned long buf_length )
00062 {
00063 return m_matching_list->recognize(buf,buf_length);
00064 }
00065 public:
00066 left_bracket_matching_list_rigth_bracket() :
00067 m_matching_list() {};
00068
00069 ~left_bracket_matching_list_rigth_bracket() {};
00070 void push_parsers( parser_list &l )
00071 {
00072 l.push_back( &m_left_bracket );
00073 l.push_back( &m_matching_list );
00074 l.push_back( &m_right_bracket );
00075 }
00076
00077 };
00078
00079 grammar_to_parser::basic_non_terminal<E,left_bracket_matching_list_rigth_bracket >
00080 m_matching;
00081 grammar_to_parser::basic_non_terminal<E,left_bracket_nonmatching_list_right_bracket >
00082 m_nonmatching;
00083
00084 public:
00085 unsigned long recognize( const E* buf, const unsigned long buf_length )
00086 {
00087 if( m_matching.is_parsed() )
00088 {
00089 return m_matching->recognize(buf,buf_length);
00090 }
00091 else
00092 {
00093 return m_nonmatching->recognize(buf,buf_length);
00094 }
00095 }
00096 bracket_expr() :
00097 m_matching(),
00098 m_nonmatching() {};
00099
00100 ~bracket_expr() {};
00101 void push_parsers( parser_list &l )
00102 {
00103
00104
00105 l.push_back( &m_nonmatching );
00106 l.push_back( &m_matching );
00107 }
00108
00109 };
00110
00111 };
00112
00113 #endif