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

ere_branch.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 EXTENDED_REGULAR_EXPRESSIONERE_BRANCH_H
00021 #define EXTENDED_REGULAR_EXPRESSIONERE_BRANCH_H
00022 
00023 namespace extended_regular_expression {
00024 
00025 template< typename E > class ere_expression;
00026 
00045 template<typename E>
00046 class ere_branch : public ere_base<E>
00047 {
00048 typedef typename grammar_to_parser::basic_parser<E>::parser_list 
00049                                                                                                                                 parser_list;
00050         
00051         class ere_expression_ere_branch : public ere_base<E>
00052         {
00053                 grammar_to_parser::basic_choice<E, ere_expression<E> >  m_ere_expression;       
00054                 grammar_to_parser::basic_choice<E, ere_branch<E> >              m_ere_branch;
00055         public: 
00056                 ere_expression_ere_branch() : ere_base<E>() {};
00057                 ~ere_expression_ere_branch() {};
00058                 
00059                 unsigned long recognize( const E* buf, 
00060                                                                 const unsigned long buf_length, 
00061                                                                 const unsigned long buf_offset,
00062                                                                 bool try_positions = true );
00063                 void push_parsers( parser_list& l );
00064                 
00065                 void assign_matches( matches::match_key parent_address, 
00066                                                         unsigned long& branch_pos, 
00067                                                         matches& m );
00068         };
00069         
00070         grammar_to_parser::basic_choice<E, ere_expression<E> >  m_ere;
00071         grammar_to_parser::basic_non_terminal<E,ere_expression_ere_branch>
00072                                                                                                                         m_ere_expression_ere_branch;
00073 
00074 public:
00075     ere_branch() :
00076                 ere_base<E>(), 
00077                 m_ere_expression_ere_branch() {};
00078         ~ere_branch() {};
00079 
00080         unsigned long recognize( const E* buf, 
00081                                                         const unsigned long buf_length, 
00082                                                         const unsigned long buf_offset,
00083                                                         bool try_positions = true );
00084         
00085         void assign_matches( matches::match_key parent_address, 
00086                                                 unsigned long& branch_pos, 
00087                                                 matches& m );
00088         
00089         bool is_right_anchor()
00090         {
00091                 return m_ere.is_parsed() && m_ere->is_right_anchor();
00092         }
00093                 
00094         void push_parsers( parser_list& l );
00095 };
00096 
00097 };
00098 
00099 #endif

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