ValueParser.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:26 CET 2004  ValueParser.hpp
00003 
00004                         ValueParser.hpp -  description
00005                            -------------------
00006     begin                : Mon January 19 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #ifndef VALUEPARSER_HPP
00039 #define VALUEPARSER_HPP
00040 
00041 #include "parser-types.hpp"
00042 #include "CommonParser.hpp"
00043 #include "PeerParser.hpp"
00044 #include "PropertyParser.hpp"
00045 #include "../AttributeRepository.hpp"
00046 
00047 #include <memory>
00048 #include <map>
00049 
00050 namespace RTT
00051 {
00052     class TaskContext;
00053     namespace detail {
00059   class ValueParser
00060   {
00061     rule_t constant, const_float, const_double, const_int, const_uint, const_bool, named_constant,
00062       const_string, const_char;
00063     CommonParser& commonparser;
00064     PeerParser peerparser;
00065     PropertyParser propparser;
00066 
00067     // a auto_ptr used only to make sure we don't forget to delete
00068     // the TaskVariableBase it holds..  Here we store a pointer to
00069     // the TaskVariableBase for a temporary variable we've just
00070     // parsed.  If we parse a non-temporary, then we don't need to
00071     // delete it, as it remains in the values map, however a
00072     // constant only gets stored temporarily in ret, so this
00073     // variable makes sure it gets deleted.
00074     //std::auto_ptr<AttributeBase> deleter;
00075     // the DataSource we've just parsed..  we only store it and
00076     // assume that the ProgramParser will do something useful with
00077     // it.  We don't ever own it, and don't delete it, or set it to
00078     // 0..
00079     DataSourceBase::shared_ptr ret;
00080     // contains the string constant we're parsing ( it has to be
00081     // parsed char-by-char, because of the way c_escape_ch_p works
00082     // )..
00083     std::string mcurstring;
00084 
00085     void seennamedconstant( iter_t begin, iter_t end );
00086     void seenboolconstant( iter_t begin, iter_t end );
00087     void seenintconstant( int c );
00088     void seenuintconstant( unsigned int c ); // RobWork uint -> unsigned int
00089     void seencharconstant( iter_t c );
00090     void seenfloatconstant( double c );
00091     void seendoubleconstant( double c );
00092     void push_str_char( char c );
00093     void seenstring();
00094     void seennull();
00095     void seenpeer();
00096 
00097       TaskContext* context;
00098   public:
00099       ValueParser( TaskContext* tc, CommonParser& cp );
00100 
00101     ~ValueParser();
00105     void clear();
00106 
00107     rule_t& parser();
00108 
00109     const DataSourceBase::shared_ptr lastParsed() const
00110       {
00111         return ret;
00112       }
00113   };
00114 }}
00115 
00116 #endif
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3