Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

bracket_expr.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Radko Mihal                                     *
00003  *   rmihal@pobox.sk                                                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
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 //              l.push_back( &m_matching );
00104 //              l.push_back( &m_nonmatching );
00105                 l.push_back( &m_nonmatching );
00106                 l.push_back( &m_matching );
00107         }       
00108 
00109 };
00110 
00111 };
00112 
00113 #endif

Generated on Sun Jul 2 18:39:42 2006 for grammar2parser.kdevelop by  doxygen 1.4.1