Update of /cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30735/libs/wave/samples/waveidl/idllexer
Modified Files:
idl.re idl_lex_interface.hpp idl_lex_iterator.hpp idl_re.cpp
idl_re2c_lexer.hpp
Log Message:
Factored out the pure lex_input_interface to simplify writing different lexer
types for Wave.
Index: idl.re
===================================================================
RCS file: /cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer/idl.re,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- idl.re 29 Sep 2006 16:03:13 -0000 1.11
+++ idl.re 22 Nov 2006 02:33:45 -0000 1.12
@@ -70,13 +70,7 @@
get_one_char(boost::wave::cpplexer::re2clex::Scanner *s)
{
using namespace boost::wave::cpplexer::re2clex;
- if (s->fd != -1) {
- uchar val;
-
- if (read(s->fd, &val, sizeof(val)))
- return val;
- }
- else if (0 != s->act) {
+ if (0 != s->act) {
RE2C_ASSERT(s->first != 0 && s->last != 0);
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
if (s->act < s->last)
@@ -88,10 +82,7 @@
std::ptrdiff_t
rewind_stream (boost::wave::cpplexer::re2clex::Scanner *s, int cnt)
{
- if (s->fd != -1) {
- return lseek(s->fd, cnt, SEEK_CUR);
- }
- else if (0 != s->act) {
+ if (0 != s->act) {
RE2C_ASSERT(s->first != 0 && s->last != 0);
s->act += cnt;
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
@@ -228,13 +219,7 @@
s->bot = buf;
}
- if (s->fd != -1) {
- if((cnt = read(s->fd, (char*) s->lim, BOOST_WAVE_BSIZE)) !=
BOOST_WAVE_BSIZE)
- {
- s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
- }
- }
- else if (s->act != 0) {
+ if (s->act != 0) {
cnt = s->last - s->act;
if (cnt > BOOST_WAVE_BSIZE)
cnt = BOOST_WAVE_BSIZE;
@@ -321,7 +306,7 @@
else if (next != -1) /* -1 means end of file */
{
/* next was something else, so rewind the stream */
- lseek(s->fd, -1, SEEK_CUR);
+ rewind_stream(s, -1);
}
}
/* check \ \r EOB */
Index: idl_lex_interface.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer/idl_lex_interface.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- idl_lex_interface.hpp 17 Mar 2006 22:40:02 -0000 1.4
+++ idl_lex_interface.hpp 22 Nov 2006 02:33:45 -0000 1.5
@@ -10,11 +10,12 @@
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#if
!defined(CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
-#define CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED
+#if !defined(IDL_LEX_INTERFACE_HPP_INCLUDED)
+#define IDL_LEX_INTERFACE_HPP_INCLUDED
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/language_support.hpp>
+#include <boost/wave/cpplexer/cpp_lex_interface.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
@@ -26,8 +27,6 @@
// new_lexer_gen: generates a new instance of the required C++ lexer
//
///////////////////////////////////////////////////////////////////////////////
-template <typename TokenT> struct lex_input_interface;
-
template <
typename IteratorT,
typename PositionT = boost::wave::util::file_position_type
@@ -37,8 +36,8 @@
// The NewLexer function allows the opaque generation of a new lexer object.
// It is coupled to the token type to allow to decouple the lexer/token
// configurations at compile time.
- static lex_input_interface<
- boost::wave::cpplexer::lex_token<PositionT>
+ static cpplexer::lex_input_interface<
+ cpplexer::lex_token<PositionT>
> *
new_lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
@@ -53,24 +52,16 @@
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
-struct lex_input_interface
+struct lex_input_interface_generator
+: cpplexer::lex_input_interface<TokenT>
{
- typedef typename TokenT::position_type position_type;
-
- virtual TokenT get() = 0;
- virtual void set_position(position_type const &pos) = 0;
-
- virtual ~lex_input_interface() {}
+ typedef typename cpplexer::lex_input_interface<TokenT>::position_type
position_type;
-#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- virtual bool has_include_guards(std::string& guard_name) const = 0;
-#endif
-
// The new_lexer function allows the opaque generation of a new lexer object.
// It is coupled to the token type to allow to distinguish different
// lexer/token configurations at compile time.
template <typename IteratorT>
- static lex_input_interface *
+ static cpplexer::lex_input_interface<TokenT> *
new_lexer(IteratorT const &first, IteratorT const &last,
position_type const &pos, boost::wave::language_support language)
{
@@ -84,4 +75,4 @@
} // namespace wave
} // namespace boost
-#endif //
!defined(CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
+#endif // !defined(IDL_LEX_INTERFACE_HPP_INCLUDED)
Index: idl_lex_iterator.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer/idl_lex_iterator.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- idl_lex_iterator.hpp 17 Mar 2006 22:40:02 -0000 1.6
+++ idl_lex_iterator.hpp 22 Nov 2006 02:33:45 -0000 1.7
@@ -48,14 +48,14 @@
template <typename TokenT>
class lex_iterator_functor_shim
{
- typedef lex_input_interface<TokenT> lex_input_interface_t;
+ typedef lex_input_interface_generator<TokenT> lex_input_interface_type;
public:
template <typename IteratorT>
lex_iterator_functor_shim(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
- : functor_ptr(lex_input_interface_t::new_lexer(first, last, pos,
language))
+ : functor_ptr(lex_input_interface_type::new_lexer(first, last, pos,
language))
{}
// interface to the boost::spirit::multi_pass_policies::functor_input policy
@@ -75,7 +75,7 @@
}
private:
- boost::shared_ptr<lex_input_interface_t> functor_ptr;
+ boost::shared_ptr<cpplexer::lex_input_interface<TokenT> > functor_ptr;
};
#if 0 != __COMO_VERSION__
Index: idl_re.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer/idl_re.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- idl_re.cpp 29 Sep 2006 16:03:13 -0000 1.14
+++ idl_re.cpp 22 Nov 2006 02:33:45 -0000 1.15
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.10.6 on Thu Sep 07 19:54:32 2006 */
+/* Generated by re2c 0.10.6 on Tue Nov 21 20:08:15 2006 */
#line 1 "idl.re"
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
@@ -72,13 +72,7 @@
get_one_char(boost::wave::cpplexer::re2clex::Scanner *s)
{
using namespace boost::wave::cpplexer::re2clex;
- if (s->fd != -1) {
- uchar val;
[...3659 lines suppressed...]
if(cursor != s->eof)
@@ -3760,14 +3725,14 @@
/* the comment is unterminated, but nevertheless its a comment */
BOOST_WAVE_RET(T_CPPCOMMENT);
}
-#line 3764 "idl_re.cpp"
-yy382:
+#line 3729 "idl_re.cpp"
+yy383:
++YYCURSOR;
yych = *YYCURSOR;
- goto yy376;
+ goto yy377;
}
}
-#line 574 "idl.re"
+#line 563 "idl.re"
} /* end of scan */
Index: idl_re2c_lexer.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/libs/wave/samples/waveidl/idllexer/idl_re2c_lexer.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- idl_re2c_lexer.hpp 17 Mar 2006 22:40:02 -0000 1.12
+++ idl_re2c_lexer.hpp 22 Nov 2006 02:33:45 -0000 1.13
@@ -62,7 +62,7 @@
typedef char char_t;
typedef boost::wave::cpplexer::re2clex::Scanner base_t;
typedef boost::wave::cpplexer::lex_token<PositionT> token_type;
- typedef typename token_type::string_type string_type;
+ typedef typename token_type::string_type string_type;
lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
@@ -102,7 +102,6 @@
using namespace boost::wave::cpplexer::re2clex;
memset(&scanner, '\0', sizeof(scanner_t));
- scanner.fd = -1;
scanner.eol_offsets = aq_create();
scanner.first = scanner.act = (uchar *)&(*first);
scanner.last = scanner.first + std::distance(first, last);
@@ -194,7 +193,9 @@
typename PositionT = boost::wave::util::file_position_type
>
class lex_functor
-: public lex_input_interface<typename lexer<IteratorT,
PositionT>::token_type>
+: public lex_input_interface_generator<
+ typename lexer<IteratorT, PositionT>::token_type
+ >
{
public:
@@ -255,7 +256,7 @@
template <typename IteratorT, typename PositionT>
BOOST_WAVE_RE2C_NEW_LEXER_INLINE
-lex_input_interface<boost::wave::cpplexer::lex_token<PositionT> > *
+cpplexer::lex_input_interface<cpplexer::lex_token<PositionT> > *
new_lexer_gen<IteratorT, PositionT>::new_lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
wave::language_support language)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs