Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:51

0001 //  Copyright (c) 2001 Daniel C. Nuffer
0002 //  Copyright (c) 2001-2011 Hartmut Kaiser
0003 // 
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #if !defined(BOOST_SPIRIT_ITERATOR_LEX_INPUT_POLICY_MAR_16_2007_1205PM)
0008 #define BOOST_SPIRIT_ITERATOR_LEX_INPUT_POLICY_MAR_16_2007_1205PM
0009 
0010 #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp>
0011 #include <boost/spirit/home/support/iterators/detail/multi_pass.hpp>
0012 
0013 namespace boost { namespace spirit { namespace iterator_policies
0014 {
0015     ///////////////////////////////////////////////////////////////////////////////
0016     //  class lex_input
0017     //  Implementation of the InputPolicy used by multi_pass
0018     // 
0019     //  The lex_input class gets tokens (integers) from yylex()
0020     ///////////////////////////////////////////////////////////////////////////
0021     struct lex_input
0022     {
0023         typedef int value_type;
0024 
0025         ///////////////////////////////////////////////////////////////////////
0026         template <typename T>
0027         class unique : public detail::default_input_policy
0028         {
0029         public:
0030             typedef std::ptrdiff_t difference_type;
0031             typedef std::ptrdiff_t distance_type;
0032             typedef int* pointer;
0033             typedef int& reference;
0034 
0035         protected:
0036             unique() {}
0037             explicit unique(T) {}
0038 
0039         public:
0040             template <typename MultiPass>
0041             static typename MultiPass::reference get_input(MultiPass& mp)
0042             {
0043                 value_type& curtok = mp.shared()->curtok;
0044                 if (-1 == curtok)
0045                 {
0046                     extern int yylex();
0047                     curtok = yylex();
0048                 }
0049                 return curtok;
0050             }
0051 
0052             template <typename MultiPass>
0053             static void advance_input(MultiPass& mp)
0054             {
0055                 extern int yylex();
0056                 mp.shared()->curtok = yylex();
0057             }
0058 
0059             // test, whether we reached the end of the underlying stream
0060             template <typename MultiPass>
0061             static bool input_at_eof(MultiPass const& mp) 
0062             {
0063                 return mp.shared()->curtok == 0;
0064             }
0065 
0066             template <typename MultiPass>
0067             static bool input_is_valid(MultiPass const&, value_type const& t) 
0068             {
0069                 return -1 != t;
0070             }
0071         };
0072 
0073         ///////////////////////////////////////////////////////////////////////
0074         template <typename T>
0075         struct shared
0076         {
0077             explicit shared(T) : curtok(-1) {}
0078 
0079             value_type curtok;
0080         };
0081     };
0082 
0083 }}}
0084 
0085 #endif
0086