2
0
mirror of https://github.com/boostorg/wave.git synced 2026-01-19 04:42:16 +00:00

This commit was manufactured by cvs2svn to create branch

'thread_rewrite'.

[SVN r30953]
This commit is contained in:
nobody
2005-09-13 14:20:32 +00:00
parent e152ad4269
commit 7a1a09f057
298 changed files with 0 additions and 40224 deletions

1314
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -1,64 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Build Jamfile
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/build ;
SOURCES = instantiate_cpp_exprgrammar
instantiate_cpp_grammar
instantiate_cpp_literalgrs
instantiate_defined_grammar
instantiate_predef_macros
instantiate_re2c_lexer
instantiate_re2c_lexer_str
cpplexer/re2clex/aq
cpplexer/re2clex/cpp_re
;
lib boost_wave
: ../src/$(SOURCES).cpp
: # build requirements
[ common-names ] # magic for install and auto-link features
<include>$(BOOST_ROOT)
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
<no-warn>cpp_re.cpp
: debug release # build variants
;
#dll boost_wave
# : ../src/$(SOURCES).cpp
# : # build requirements
# [ common-names ] # magic for install and auto-link features
# <define>BOOST_WAVE_DYN_LINK=1 # tell source we're building dll's
# <runtime-link>dynamic # build only for dynamic runtimes
# <include>$(BOOST_ROOT)
# <sysinclude>$(BOOST_ROOT)
# : debug release # build variants
# ;
install wave lib
: <lib>boost_wave
# <dll>boost_wave
;
stage stage/lib : <lib>boost_wave # <dll>boost_wave
:
# copy to a path rooted at BOOST_ROOT:
<locate>$(BOOST_ROOT)
# make sure the names of the libraries are correctly named:
[ common-names ]
# add this target to the "stage" and "all" pseudo-targets:
<target>stage
<target>all
:
debug release
;
# end

View File

@@ -1,46 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Build Jamfile
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
project boost/wave
:
source-location ../src
;
SOURCES =
instantiate_cpp_exprgrammar
instantiate_cpp_grammar
instantiate_cpp_literalgrs
instantiate_defined_grammar
instantiate_predef_macros
instantiate_re2c_lexer
instantiate_re2c_lexer_str
cpplexer/re2clex/aq
cpplexer/re2clex/cpp_re
;
lib boost_wave
:
$(SOURCES).cpp
/boost/filesystem//boost_filesystem
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
# Not supported by V2
# <no-warn>cpp_re.cpp
;
install dist-lib
:
boost_wave
:
<install-type>LIB
<location>../../../dist/lib
;
explicit dist-lib ;

View File

@@ -1,91 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Acknowledgements</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="theme/style.css" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Acknowledgements</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="references.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>Special thanks to:</p>
<blockquote>
<p> <b>Paul Mensonides</b> for his invaluable help while developing the macro
expansion engine and his insightful tips. He developed the recursive macro
expansion algorithm implemented herein and also contributed most of the small
testcases used for testing the correctness of the macro expansion.</p>
<p><b>Dan Nuffer</b>, who wrote the initial Re2C based C++ lexer and the Slex
(Spirit Lex) scanner generator sample.</p>
<p><b>Martin Wille</b> for helping with the port to Linux, testing on Linux and for contributing
the automated test scripts.</p>
<p><b>Vladimir Prus</b> for helping with the command line and config file options
analysis for the <tt>Wave</tt> driver executable.</p>
<p><b>Juan Carlos Arevalo-Baeza</b>, who wrote the Spirit cpp_lexer sample,
from which are taken some ideas.</p>
<p> <strong>Andrei Alexandrescu</strong> for allowing to use his flex_string class,
a policy based std::basic_string&lt;&gt; compatible string implementation.</p>
<p><strong>Reece Dunn</strong>, <strong>Vesa Karvonen</strong>, <strong>Faisal Vali</strong>, <strong>Porter Schermerhorn</strong> and <strong>Daniel Fontijne</strong> for
reporting several problems and bugs.</p>
<p><strong>Tarmo Pikaro</strong> for reporting several bug while compiling specific
headers from the Microsoft Windows SDK.</p>
<p><strong>Rob Stewart</strong> helped a lot with proof reading the documentation. </p>
<p><strong>Stefan Seefeld</strong> for integrating Wave into his Synopsis library and finding a couple of bugs along the way. </p>
</blockquote>
<p>and last but not least </p>
<blockquote>
<p><b>Joel de Guzman</b> for nudging me into this adventure and for his work
on the <tt>Spirit</tt> parser framework, without which the <tt>Wave</tt> library
wouldn't have been possible.</p>
</blockquote>
<p> Special thanks also to people who gave feedback and valuable comments, particularly members of Boost and Spirit mailing lists. This includes all those who participated in the Boost review:
<blockquote>
<p><strong>Tom Brinkman</strong> (who volunteered to be the review managaer), <strong>David Abrahams</strong>, <strong>Beman Dewes</strong>, <strong>Reece Dunn</strong>, <strong>Larry Evans</strong>, <strong>Doug Gregor</strong>, <strong>Joel de Guzman</strong>, <strong>Baptiste Lepilleur</strong>, <strong>Andy Little</strong>, <strong>Paul Mensonides</strong>, <strong>Dan Nuffer</strong>, <strong>Andreas Pokorny</strong>, <strong>Vladimir Prus</strong>, <strong>Gennadiy Rozental</strong>, <strong>Michiel Salters</strong>, <strong>Jonathan Turkanis</strong>, <strong>Chris Uzdavinis</strong>, <strong>Pavel Vozenilek</strong>, <strong>Michael Walter</strong></p>
</blockquote>
<p>The <tt>Wave</tt> library uses the following <tt>Boost</tt> <a href="references.html#boost">[8]</a>
libraries:</p>
<blockquote>
<p><b><img src="theme/bullet.gif" width="13" height="13" id="IMG1"></b>&nbsp;Boost
Spirit (LL parser framework that represents parsers directly as EBNF grammars
in inlined C++)<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1"></b> Boost
Iterator Adaptor Library (Adapt a base type into a standard conforming iterator)<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1"></b> Boost
Filesystem Library (Portable paths, iteration over directories, and other
useful filesystem operations)<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1"></b>&nbsp;Boost Program
options and arguments library</p>
</blockquote>
<p>and other small parts of different <tt>Boost</tt> libraries. </p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="references.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
</font> </p>
<span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span>
</body>
</html>

View File

@@ -1,450 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Context Object</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="theme/style.css" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Context Object</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="quickstart.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_context.html#introduction">Introduction</a><br>
<a href="class_reference_context.html#header_synopsis">Header 'wave/context.hpp' synopsis</a><br>
<a href="class_reference_context.html#public_typedefs">Public Typedefs</a><br>
<a href="class_reference_context.html#template_parameters">Template parameters</a><br>
<a href="class_reference_context.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>The <tt>boost::wave::context&lt;&gt;</tt> object is the main user visible object of
the <tt>Wave</tt> library. It exists to generate the pair of iterators, which
while dereferenced return the preprocessed tokens. Additionally it is used
to control other aspects of the preprocessing, such as </p>
<blockquote>
<p><STRONG><IMG id="IMG1" height="13" src="theme/bullet.gif" width="13"></STRONG>&nbsp;include
search paths, which define, where to search for files to be included with
<tt>#include&nbsp;&lt;...&gt;</tt> and <tt>#include&nbsp;"..."</tt> directives<br>
<STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>which
macros to predefine and which of the predefined macros to undefine<br>
<STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>several
other options as for instance to control, whether to enable several extensions
to the C++ Standard (as for instance variadics and placemarkers) or not.</p>
</blockquote>
<h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/cpp_context.hpp?view=markup">wave/cpp_context.hpp</a>
synopsis</b></h2>
<pre><span class="keyword">namespace</span> <span class="identifier">boost</span> {
<span class="keyword">namespace</span> <span class="identifier">wave</span> {
<span class="keyword">template</span> &lt;
<span class="keyword">typename</span> Iterator, <span class="keyword">typename</span> LexIterator,
<span class="keyword">typename</span> InputPolicy, <span class="keyword">typename</span> TracePolicy
&gt;
<span class="keyword">class</span> context <span class="special">:</span> <span class="keyword">public</span> InputPolicy
{
<span class="keyword">public</span>:
<span class="keyword">typedef</span> pp_iterator&lt;context&gt; iterator_type;
<span class="keyword">typedef</span> Token token_type;
<span class="keyword">typedef</span> <span class="keyword">typename</span> token_type::position_type position_type;
<span class="comment">// constructor</span>
<a href="class_reference_context.html#constructor">context</a>(Iterator<span class="keyword"> const</span> &amp;first_,
Iterator <span class="keyword">const</span> &amp;last_,
<span class="keyword">char const</span> *fname = <span class="string">"&lt;Unknown&gt;"</span>,
TracePolicy &amp;trace = TracePolicy())
<span class="comment">// iterator interface</span>
iterator_type <a href="class_reference_context.html#iterator_interface_begin">begin</a>() <span class="keyword">const</span>;
iterator_type <a href="class_reference_context.html#iterator_interface_end">end</a>() <span class="keyword">const</span>;
<span class="comment">// maintain include paths</span>
<span class="keyword">bool</span> <a href="class_reference_context.html#add_include_path">add_include_path</a>(<span class="keyword">char const</span> *path_);
<span class="keyword">bool</span> <a href="class_reference_context.html#add_sysinclude_path">add_sysinclude_path</a>(<span class="keyword">char const</span> *path_);
<span class="keyword">void</span> <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter</a>();
size_t <a href="class_reference_context.html#get_iteration_depth">get_iteration_depth</a>() <span class="keyword">const</span>;
<span class="comment">// maintain defined macros</span>
<span class="keyword">bool</span> <a href="class_reference_context.html#add_macro_definition">add_macro_definition</a>(<span class="keyword">std::string</span> macrostring,
<span class="keyword">bool</span> is_predefined = <span class="keyword">false</span>);
<span class="keyword">bool</span> <a href="class_reference_context.html#is_defined_macro">is_defined_macro</a>(<span class="keyword">std::string const</span> &amp;name) <span class="keyword">const</span>;
<span class="keyword">bool</span> <a href="class_reference_context.html#remove_macro_definition">remove_macro_definition</a>(<span class="keyword">std::string const</span> &amp;name,
<span class="keyword">bool</span> even_predefined = <span class="keyword">false</span>);
<span class="keyword">void</span> <a href="class_reference_context.html#reset_macro_definitions">reset_macro_definitions</a>();
<span class="comment">// other options</span>
<span class="keyword">void</span> <a href="class_reference_context.html#language_support">set_language</a>(language_support enable);
language_support <a href="class_reference_context.html#language_support">get_language</a>() <span class="keyword">const</span>;<br>
<span class="keyword">void</span> <a href="class_reference_context.html#set_max_include_nesting_depth">set_max_include_nesting_depth</a>(std::size_t new_depth);<br> size_t <a href="class_reference_context.html#set_max_include_nesting_depth">get_max_include_nesting_depth</a>() <span class="keyword">const</span>;<br>
<span class="comment">// get the Wave version information </span>
<span class="keyword">static std::string</span> <a href="class_reference_context.html#get_version">get_version</a>();
<span class="keyword">static std::string</span> <a href="class_reference_context.html#get_version">get_version_string</a>();
};
} <span class="comment">// namespace wave</span>
} <span class="comment">// namespace boost</span></pre>
<h2><b><a name="template_parameters"></a>Template parameters</b></h2>
<p>The <tt>boost::wave::context</tt> object has three template parameters to specify
the concrete behaviour of its operation. The following table describes these
with more detail.</p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Template parameters required for the
<tt>boost::wave::context</tt> class </b></td>
</tr>
<tr>
<td width="32%" class="table_cells"><code>Iterator</code></td>
<td width="68%" class="table_cells"><p>The type of the underlying iterator,
through which the input stream is accessed. <br>
This should be at least an <tt>forward_iterator</tt> type iterator.</p></td>
</tr>
<tr>
<td class="table_cells"><code>LexIterator</code></td>
<td class="table_cells"><p>The type of the lexer type to be used by the <tt>Wave</tt>
library to identify tokens in the input stream.</p></td>
</tr>
<tr>
<td class="table_cells"><code>InputPolicy</code></td>
<td class="table_cells"><p>The type of the input policy class, which allows
to customize the behaviour of the Wave library and the type of the iterators
to use, when it comes to including and opening an included file.</p></td>
</tr>
<tr>
<td class="table_cells"><code>TracePolicy</code></td>
<td class="table_cells"><p>The type of the trace policy class, which allows
to customize the trace output generated while expanding macros. </p></td>
</tr>
</table>
<p>For further information about the lexer type to use, please refer to the <a href="class_reference_lexer.html">The
Lexer Interface </a>.</p>
<p>If the template parameter <tt>InputPolicy</tt> is omitted, the template <tt>wave::iteration_context_policies::load_file_to_string</tt>
is used. For further information about the input policy, please refer to the
topic <a href="class_reference_inptpolcy.html">The Input Policy</a>.</p>
<p>If the template parameter TracePolicyT is omitted, the <tt>wave::macro_trace_policies::no_tracing</tt>
policy type is used, i.e. by default there is no tracing performed. For further
information about the tracing policy, please refer to the topic <a href="class_reference_ctxpolicy.html">The
Tracing Policy</a>. </p>
<h2><a name="public_typedefs"></a>Public Typedefs</h2>
<p>The <tt>boost::wave::context</tt> template defines the following public typedefs, which may be useful while using this class:</p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Public typedef's defined by the <tt>boost::wave::context</tt> class </b></td>
</tr>
<tr>
<td class="table_cells"><code>iterator_type</code></td>
<td class="table_cells"><p>The <tt>Iterator</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td>
</tr>
<tr>
<td class="table_cells"><code>lex_type</code></td>
<td class="table_cells"><p>The <tt>LexIterator</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td>
</tr>
<tr>
<td width="32%" class="table_cells"><code>token_type</code></td>
<td width="68%" class="table_cells"><p>The token type, which is returned by the <tt>context</tt> generated iterators. This type is taken from the <tt>LexIterator</tt> template parameter provided, whicle the <tt>context</tt> class was instantiated.</p></td>
</tr>
<tr>
<td class="table_cells"><code>input_policy_type</code></td>
<td class="table_cells"><p>The <tt>InputPolicy</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td>
</tr>
<tr>
<td class="table_cells"><code>trace_policy_type</code></td>
<td class="table_cells"><p>The <tt>TracePolicy</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td>
</tr>
<tr>
<td class="table_cells"><code>position_type</code></td>
<td class="table_cells"><p>The type of the position information contained in every returned token, which describes the point, at which the given token was recognised. </p></td>
</tr>
</table>
<h2><b><a name="member_functions"></a>Member functions</b></h2>
<p><b><a name="constructor" id="constructor"></a>Constructor</b></p>
<pre> context(Iterator <span class="keyword">const</span> &amp;first,
Iterator <span class="keyword">const</span> &amp;last, <span class="keyword">char</span> <span class="keyword">const</span> *filename,
TracePolicy &amp;trace);</pre>
<p>Constructs a context object on top of the input stream given by the pair
of auxilliary iterators <tt>[first,&nbsp;last)</tt>. The iterators should
be at least <tt>forward_iterator</tt> type iterators. The filename parameter
is to be supplied for informational purposes only. This string is used for
indicating the token positions inside the input stream, it is not validated
against the file system. If the filename parameter is not given it defaults
to <span class="copyright">&quot;&lt;Unknown&gt;&quot;</span>. If the trace
parameter isn't supplied it defaults to a default constructed <tt>TracePolicy</tt>
object. </p>
<p>Additionally the macro symbol table is filled with the predefined macros
and the current reference directory is set to the path of the given filename.
If this filename does not reference valid file system item, the current reference
directory is set to the current system directory. (The current reference directory
is the file system path, which is used as the target directory during the
processing of <tt>#include&nbsp;&quot;...&quot;</tt> directives).</p>
<h3>Iterator interface</h3>
<p>The pair of iterators returned by the <tt>context::begin</tt> and <tt>context::end</tt>
functions is the main interface for accessing the preprocessed tokens from the
preprocessor engine. While iterating over the given iterator range <tt>[begin,&nbsp;end)</tt>
there are returned the preprocessed C++ tokens, which are generated on the fly
from the underlying input stream. The returned iterators are conceptually of
<tt>forward_iterator</tt> type.</p>
<p><b><a name="iterator_interface_begin"></a></b><b>begin</b></p>
<pre> iterator_type begin();</pre>
<blockquote>
<p>Initializes and returns the starting iterator for the preprocessed token
stream.</p>
</blockquote>
<p><b><a name="iterator_interface_end" id="iterator_interface_end"></a></b><b>end</b></p>
<pre> iterator_type end() <span class="keyword">const</span>;</pre>
<blockquote>
<p>Initializes and returns the end of stream iterator to compare with for detecting
the end of the preprocessed token stream.</p>
</blockquote>
<h3>Maintain include paths</h3>
<p>The <tt>Wave</tt> library maintains two separate search paths for include
files. A search path for user include files and a search path for system include
files. Any directories specified with the <a href="#add_include_path">add_include_path()</a>
function before the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>
is called are searched only for the case of <tt>#include&nbsp;&quot;...&quot;</tt>
directives, they are not searched for <tt>#include&nbsp;&lt;file&gt;</tt> directives.
I.e. these directories are added to the user include search path. </p>
<p>If additional directories are specified with the <a href="#add_include_path">add_include_path()</a>
function after a call to the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>,
these directories are searched for all <tt>#include</tt> directives. I.e. these
directories are added to the system include search path.</p>
<p>In addition, a call to the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>
inhibits the use of the current reference directory as the first search directory
for <tt>#include&nbsp;&quot;...&quot;</tt> directives. Therefore, the current
reference directory is searched only, if it is requested explicitly with a call
to the function <a href="#add_include_path">add_include_path(&quot;.&quot;)</a>.
</p>
<p>Callig both functions, the <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>
and <a href="#add_include_path">add_include_path(&quot;.&quot;)</a> allows you
to control precisely, which directories are searched before the current one
and which are searched after.</p>
<p>These functions are modelled after the command line behaviour implemented by
the popular gcc compiler.<br>
</p>
<p><a name="add_include_path"></a><b>add_include_path</b></p>
<pre> <span class="keyword">bool</span> add_include_path(<span class="keyword">char const</span> *path);
</pre>
<blockquote>
<p>Adds the given file system path to the user include search paths. After a
call to the <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>
this function adds the given file system path to the system include search
paths. Note though, that the given path is validated against the file system.
</p>
<p>If the given path string does not form a name of a valid file system directory
item, the function returns <tt>false</tt>. If the given path was successfully
added to the include search paths in question, the function returns <tt>true</tt>.</p>
</blockquote>
<p><a name="add_sysinclude_path"></a><b>add_sysinclude_path</b></p>
<pre> <span class="keyword">bool</span> add_sysinclude_path(<span class="keyword">char const</span> *path);</pre>
<blockquote>
<p>Adds the given file system path to the system include search paths. This
function operates on the system include search path regardless of the mode
of operation of the <a href="#add_include_path">add_include_path()</a>. Note
though, that the given path is validated against the file system.</p>
<p>If the given path string does not form a name of a valid file system directory
item, the function returns <tt>false</tt>. If the given path was successfully
added to the system include search paths, the function returns <tt>true</tt>.</p>
</blockquote>
<p><a name="set_sysinclude_delimiter"></a><b>set_sysinclude_delimiter</b></p>
<pre> <span class="keyword">void</span> set_sysinclude_delimiter();</pre>
<blockquote>
<p>Switches the mode, how the <a href="#add_include_path">add_include_path()</a>
function operates. By default the given file system path is added to the user
include search paths. After calling this function a subsequent call to the
<a href="#add_include_path">add_include_path()</a> adds the given file system
path to the system include search paths. Additionally it inhibits the the
use of the current reference directory as the first search directory for <tt>#include&nbsp;&quot;...&quot;</tt>
directives.</p>
</blockquote>
<p><a name="get_iteration_depth"></a><b>get_iteration_depth</b></p>
<pre> size_t get_iteration_depth() <span class="keyword">const</span>;</pre>
<blockquote>
<p>Returns the actual include iteration depth, i.e. the current number of include
levels to be poped from the include iteration context, before the main (topmost)
iteration context is reached.</p>
</blockquote>
<h3>Maintain defined macros</h3>
<p><a name="add_macro_definition"></a><b>add_macro_definition</b></p>
<pre><span class="keyword"> bool</span> add_macro_definition(
<span class="keyword">std::string</span> macrostring,
bool is_predefined);
</pre>
<blockquote>
<p>Adds a new macro definition to the macro symbol table. The parameter <tt>macrostring</tt>
should contain the macro to define in the command line format, i.e. something
like <tt>MACRO(x)=definition</tt>. The following table describes this format
in more detail. The parameter <tt>is_predefined</tt> should be true while
defining predefined macros, i.e. macros, which are not undefinable with an
<tt>#undef</tt> directive from inside the preprocessed input stream. If this
parameter is not given, it defaults to <tt>false</tt>.</p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Summary of possible formats for defining
macros </b></td>
</tr>
<tr>
<td width="32%" class="table_cells"><code>MACRO</code></td>
<td width="68%" class="table_cells"><code>define <tt>MACRO</tt> as 1</code></td>
</tr>
<tr>
<td class="table_cells"><code>MACRO=</code></td>
<td class="table_cells"><code>define <tt>MACRO</tt> as nothing (empty)</code></td>
</tr>
<tr>
<td class="table_cells"><code>MACRO=definition</code></td>
<td class="table_cells"><code>define <tt>MACRO</tt> as <tt>definition</tt></code></td>
</tr>
<tr>
<td width="32%" class="table_cells"><code>MACRO(x)</code></td>
<td width="68%" class="table_cells"><code>define <tt>MACRO(x)</tt> as 1</code></td>
</tr>
<tr>
<td class="table_cells"><code>MACRO(x)=</code></td>
<td class="table_cells"><code>define <tt>MACRO(x)</tt> as nothing (empty)</code></td>
</tr>
<tr>
<td class="table_cells"><code>MACRO(x)=definition</code></td>
<td class="table_cells"><code>define <tt>MACRO(x)</tt> as <tt>definition</tt></code></td>
</tr>
</table>
<p>The function returns <tt>false</tt>, if the macro to define already was defined
and the new definition is equivalent to the existing one, it returns true,
if the new macro was successfully added to the macro symbol table.</p>
<p>If the given macro definition resembles a redefinition and the new macro
is not identical to the already defined macro (in the sense defined by the
C++ Standard), the function throws a corresponding <tt>preprocess_exception</tt>.</p>
</blockquote>
<p><a name="is_defined_macro"></a><b>is_defined_macro</b></p>
<pre><span class="keyword"> bool</span> is_defined_macro(<span class="keyword">std::string const</span> &amp;name) <span class="keyword">const</span>; </pre>
<blockquote>
<p>Returns, if a macro with the given <tt>name</tt> is defined, i.e. if it is
contained in the macro symbol table.</p>
</blockquote>
<p><a name="remove_macro_definition"></a><b>remove_macro_definition</b></p>
<pre><span class="keyword"> bool</span> remove_macro_definition(
<span class="keyword">std::string const</span> &amp;name,
<span class="keyword">bool</span> even_predefined); </pre>
<blockquote>
<p>Removes the definition of the macro with the given <tt>name</tt> from the
macro symbol table. This operation is equivalent to an <tt>#undef</tt> directive
with this <tt>name</tt> executed from within the input stream. If the parameter
<tt>even_predefined</tt> is <tt>true</tt>, then the macro is removed from
the macro symbol table even, if it is defined as a predefined macro. </p>
<p>Note though, that the following macros are <b>not</b> undefinable in any
case: <tt>__FILE__</tt>, <tt>__LINE__</tt>, <tt>__DATE__</tt>, <tt>__TIME__</tt>,
<tt>__cplusplus</tt>, <tt>__STDC__</tt>. If the parameter <tt>even_predefined</tt>
is not given, it defaults to <tt>false</tt>.</p>
<p>The function returns <tt>false</tt>, if the macro to undefine was not defined
and returns <tt>true</tt> otherwise.</p>
<p>If the macro to remove may not be undefined (it is a predefined macro and
the parameter <tt>even_predefined</tt> is set to <tt>false</tt> or it is one
of the mentioned not undefinable macros above) the function throws a <tt>preprocess_exception</tt>.</p>
</blockquote>
<p><a name="reset_macro_definitions"></a><b>reset_macro_definitions</b></p>
<pre><span class="keyword"> void</span> reset_macro_definitions(); </pre>
<blockquote>
<p>Resets the macro symbol table to it's initial state, i.e. undefines all user defined macros and inserts the internal predefined macros as described <a href="predefined_macros.html">here</a>.</p>
</blockquote>
<h3><a name="get_version"></a>Get Version information</h3>
<p><b>get_version</b></p>
<pre><span class="keyword"> </span><span class="keyword">static std::string</span> get_version(); </pre>
<blockquote>
<p>Returns a string containing the current Wave version formatted as <span class="string">0xvvrsbbbb</span>
(this is a string representation of the equivalent hexadecimal number), where
<span class="literal">'vv'</span> is the version number, <span class="literal">'r'</span>
the release number, <span class="literal">'s'</span> the subrelease number
and <span class="literal">'bbbb'</span> the build number. A possible return
value looks like <span class="literal">0x00910454</span>. The returned value
is the same as is inserted in the preprocessed token stream, when the predefined
macro <tt>__WAVE_VERSION__</tt> is expanded.</p>
</blockquote>
<p><b>get_version_str</b></p>
<pre><span class="keyword"> </span><span class="keyword">static std::string</span> get_version_str(); </pre>
<blockquote>
<p>Returns a string containing the current Wave version formatted as <span class="string">&quot;v.rr.ss.bbbb&quot;</span>,
where <span class="literal">'v'</span> is the version number, <span class="literal">'rr'</span>
the release number, <span class="literal">'ss'</span> the subrelease number
and <span class="literal">'bbbb'</span> the build number. A possible return
value looks like <span class="literal">&quot;0.9.1.454&quot;</span>. The returned
value is the same as is inserted in the preprocessed token stream, when the
predefined macro <tt>__WAVE_VERSION_STR__</tt> is expanded.</p>
</blockquote>
<h3>Control extended options</h3>
<p><a name="language_support"></a>set_language<br>
get_language</p>
<pre><span class="keyword"> void</span> set_language(<span class="keyword">language_support</span> language);
<span class="keyword">language_support</span> get_language() <span class="keyword">const</span>;</pre>
<blockquote>
<p>This functions allows to specify the language mode, in which the <tt>Wave</tt>
library should work. The possible language modes are defined by the enumerated
type <tt>language_support</tt>:</p>
<pre> <span class="keyword">enum</span> language_support {
<span class="comment">// support flags for C++98</span>
support_normal = 0x01,
support_cpp = support_normal,
<span class="comment">// support flags for C99</span>
support_long_long = 0x02,
support_variadics = 0x04,
support_c99 = support_variadics |
support_long_long | 0x08,
<span class="comment"> // the mask for the main language settings</span>
support_option_mask = 0xFF00,<br>
<span class="comment"> // additional fine tuning of the general behaviour</span>
support_option_preserve_comments = 0x0100,<br> support_option_no_character_validation = 0x0200,<br> support_option_convert_trigraphs = 0x0400<br> };</pre>
<p>When used with <tt>support_variadics</tt> the support for variadics, placemarkers
and the <tt>operator _Pragma()</tt> is enabled in normal C++ mode. When used with the <tt>support_long_long</tt> the support for long long suffixes is enabled in C++ mode. </p>
<p>The <tt>support_c99</tt> switches to the C99 language support, which enables variadics, placemarkers, the <tt>operator _Pragma</tt> and long long suffixes by default. Additionally it disables the C++ specific tokens such as <tt>'-&gt;*'</tt>, <tt>'.*'</tt>, <tt>'::'</tt> etc. </p>
<p>The <tt>support_option_...</tt> values are to be used in conjunction with the main language settings (<tt>support_normal</tt> and <tt>support_c99</tt>) . </p>
<ul>
<li>If the <tt>support_option_preserve_comments</tt> flag is set, the <tt>Wave</tt> library preserves almost all comments in the source code. The only comments not preserved are those contained inside macro definitions. By default all comments are replaced by a single space. </li>
<li>If the <tt>support_option_no_character_validation</tt> flag is set , the <tt>Wave</tt> library doesn't validate universal character literals (given in the form of <tt>'u1234'</tt> or <tt>'U12345678'</tt>) to be in the allowed value range. This flag is merely used for internal purposes by the testing framework and will be rarely used by a user of the library.</li>
<li>If the <tt>support_option_convert_trigraphs</tt> flag is set, the <tt>Wave</tt> library replaces all occurences of trigraph characters with their non-trigraph character sequence (i.e. <tt>'??='</tt> is replaced by <tt>'#'</tt> etc.) . By default no replacement is performed. </li>
</ul>
</blockquote>
<p><strong>Note:</strong> The set_language function internally resets the list of defined macros, so please be careful not to call it after you have defined your own macros already. </p>
<p><a name="set_max_include_nesting_depth" id="set_max_include_nesting_depth"></a>set_max_include_nesting_depth<br>
g et_max_include_nesting_depth</p>
<pre><span class="keyword"> void</span> set_max_include_nesting_depth(size_t new_depth);
size_t get_max_include_nesting_depth() <span class="keyword">const</span>;</pre>
<blockquote>
<p>This functions allow to set or to get the maximal possible include file nesting
depth supported by the <tt>Wave</tt> library. The initial value for this is
determined by the preprocessing constant <tt>WAVE_MAX_INCLUDE_LEVEL_DEPTH</tt>
(see <a href="compiletime_config.html">here</a>).</p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="quickstart.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span>
</p>
<p>&nbsp;</p>
</body>
</html>

View File

@@ -1,285 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Context Policy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Context Policy</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_lexer.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_ctxpolicy.html#introduction">Introduction</a><br>
<a href="class_reference_ctxpolicy.html#header_synopsis">Header 'wave/preprocessing_hooks.hpp'
synopsis</a><br>
<a href="class_reference_ctxpolicy.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>The context policy is used to provide callback hooks, which are called from inside the library into the user code, whenever</p>
<ul>
<li>a macro get's defined or undefind, </li>
<li>a macro is expanded or rescanned,</li>
<li>an include file is opened or left, </li>
<li> a pragma of the form <tt>'wave option[(value)]'</tt> is recognised. </li>
</ul>
<p>This policy type is used as a template parameter to the <a href="class_reference_context.html"><tt>wave::context&lt;&gt;</tt></a>
object, where the default policy provides empty hooks functions only.</p>
<h2><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/preprocessing_hooks.hpp?view=markup">wave/preprocessing_hooks.hpp</a>
synopsis</h2>
<pre>
<span class="keyword">namespace</span> boost {
<span class="keyword">namespace</span> wave {
<span class="keyword">namespace</span> context_policies {
<span class="keyword">struct</span> default_preprocessing_hooks {
<span class="comment">// general control function</span>
template</span> &lt;<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanding_function_like_macro">expanding_function_like_macro</a>(TokenT <span class="keyword">const</span> &amp;macrodef,
<span class="keyword">std::vector</span>&lt;TokenT&gt; <span class="keyword">const</span> &amp;formal_args,
ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall,
<span class="keyword">std::vector</span>&lt;ContainerT&gt; <span class="keyword">const</span> &amp;arguments);
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanding_object_like_macro">expanding_object_like_macro</a>(TokenT <span class="keyword">const</span> &amp;macro,
ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall);
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanded_macro">expanded_macro</a>(ContainerT <span class="keyword">const</span> &amp;result);
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanded_macro">rescanned_macro</a>(ContainerT <span class="keyword">const</span> &amp;result);
<span class="comment">// include file tracing functions</span>
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#opened_include_file">found_include_directive</a>(std::string <span class="keyword">const</span> &amp;filename,
<span class="keyword">bool</span> include_next);
<span class="keyword">void </span><a href="class_reference_ctxpolicy.html#opened_include_file">opened_include_file</a>(std::string <span class="keyword">const</span> &amp;relname,
std::string const&amp; absname,
std::size_t include_depth, <span class="keyword">bool</span> is_system_include);
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#returning_from_include_file">returning_from_include_file</a>();
<span class="comment">// interpretation of #pragma's of the form </span>
<span class="comment">// 'wave option[(value)]'</span>
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;
bool <a href="class_reference_ctxpolicy.html#interpret_pragma">interpret_pragma</a>(ContextT <span class="keyword">const</span> &amp;ctx, ContainerT &amp;pending,
<span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;option,
ContainerT <span class="keyword">const</span> &amp;values,
<span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;pragma_token);
<span class="comment">// macro definition hooks</span>
<span class="keyword">template</span> &lt;
<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ParametersT, <span class="keyword">typename</span> DefinitionT
&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#defined_macro">defined_macro</a>(TokenT <span class="keyword">const</span> &amp;name, <span class="keyword">bool</span> is_functionlike,
ParametersT <span class="keyword">const</span> &amp;parameters, DefinitionT <span class="keyword">const</span> &amp;definition,
<span class="keyword">bool</span> is_predefined);
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> TokenT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#undefined_macro">undefined_macro</a>(TokenT<span class="keyword">const</span> &amp;name);
};
}}} <span class="comment">// namespace boost::wave::context_policies</span></pre>
<h2><a name="member_functions"></a>Member functions</h2>
<h3>Macro expansion tracking functions</h3>
<p><a name="expanding_function_like_macro"></a><b>expanding_function_like_macro</b></p>
<pre><span class="keyword"> template</span> &lt;<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> expanding_function_like_macro(TokenT <span class="keyword">const</span> &amp;macrodef,
<span class="keyword">std::vector</span>&lt;TokenT&gt; <span class="keyword">const</span> &amp;formal_args,
ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall,
<span class="keyword">std::vector</span>&lt;ContainerT&gt; <span class="keyword">const</span> &amp;arguments);</pre>
<blockquote>
<p>The function <tt>expanding_function_like_macro</tt> is called, whenever a
function-like macro is to be expanded, i.e. <i>before</i> the actual expansion
starts.</p>
<p>The <tt>macroname</tt> parameter marks the position where the macro to expand
is defined. It contains the token which identifies the macro name used inside
the corresponding macro definition.</p>
<p>The <tt>formal_args</tt> parameter holds the formal arguments used during
the definition of the macro. </p>
<p>The <tt>definition</tt> parameter holds the macro definition for the macro
to trace. This is a standard STL container which holds the token sequence
identified during the macro definition as the macro replacement list.</p>
<p>The <tt>macrocall</tt> parameter marks the position where this macro is invoked.
It contains the token, which identifies the macro call inside the preprocessed
input stream. </p>
<p>The <tt>arguments</tt> parameter holds the macro arguments used during the
invocation of the macro. This is a vector of standard STL containers which
contain the token sequences identified at the position of the macro call as
the arguments to be used during the macro expansion. </p>
</blockquote>
<p><a name="expanding_object_like_macro"></a><b>expanding_object_like_macro</b></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> expanding_object_like_macro(TokenT <span class="keyword">const</span> &amp;macro,
ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall);
</pre>
<blockquote>
<p>The function <tt>expanding_object_like_macro</tt> is called, whenever a object-like
macro is to be expanded, i.e. <i>before</i> the actual expansion starts.</p>
<p>The <tt>macroname</tt> parameter marks the position where the macro to expand
is defined. It contains the token which identifies the macro name used inside
the corresponding macro definition.</p>
<p> The <tt>definition</tt> parameter holds the macro definition for the macro
to trace. This is a standard STL container which holds the token sequence
identified during the macro definition as the macro replacement list.</p>
<p>The <tt>macrocall</tt> parameter marks the position where this macro is invoked.
It contains the token which identifies the macro call inside the preprocessed
input stream. </p>
</blockquote>
<p><a name="expanded_macro"></a><b>expanded_macro</b></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> expanded_macro(ContainerT <span class="keyword">const</span> &amp;result);
</pre>
<blockquote>
<p>The function <tt>expanded_macro</tt> is called whenever the expansion of
a macro is finished, the replacement list is completely scanned and the identified
macros herein are replaced by its corresponding expansion results, but <i>before</i>
the rescanning process starts.</p>
<p>The parameter <tt>result</tt> contains the the result of the macro expansion
so far. This is a standard STL container containing the generated token sequence.</p>
</blockquote>
<p><a name="rescanned_macro"></a><b>rescanned_macro</b></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContainerT&gt;
<span class="keyword">void</span> rescanned_macro(ContainerT <span class="keyword">const</span> &amp;result);
</pre>
<blockquote>
<p>The function <tt>rescanned_macro</tt> is called whenever the rescanning
of a macro is finished, i.e. the macro expansion is complete.</p>
<p>The parameter <tt>result</tt> contains the the result of the whole macro
expansion. This is a standard STL container containing the generated token
sequence.</p>
</blockquote>
<h3>Include file tracing functions</h3>
<p><a name="opened_include_file" id="found_include_directive"></a><strong>found_include_directive</strong></p>
<pre> <span class="keyword">void</span> found_include_directive(std::string <span class="keyword">const</span> &amp;filename,
<span class="keyword">bool</span> include_next);
</pre>
<blockquote>
<p>The function <tt>found_include_directive</tt> is called whenever whenever a #include directive was located..</p>
<p>The parameter <tt>filename</tt> contains the (expanded) file name found after
the <span class="preprocessor">#include</span> directive. This has the format <tt>&lt;file&gt;</tt>, <tt>&quot;file&quot;</tt> or
<tt>file</tt>.
The formats <tt>&lt;file&gt;</tt> or <tt>&quot;file&quot;</tt> are used for <span class="preprocessor">#include</span> directives found
in the preprocessed token stream, the format <tt>file</tt> is used for files
specified through the --force_include command line argument.</p>
<p>The parameter <tt>include_next</tt> is set to true if the found directive was
a <span class="preprocessor">#include_next</span> directive and the <tt>BOOST_WAVE_SUPPORT_INCLUDE_NEXT</tt> preprocessing constant was defined to something != 0.<br>
</p>
</blockquote>
<p><a name="opened_include_file" id="opened_include_file"></a><strong>opened_include_file</strong></p>
<pre> <span class="keyword">void</span> opened_include_file(std::string <span class="keyword">const</span> &amp;rel_filename,
std::string <span class="keyword">const</span> &amp;abs_filename,
std::size_t include_depth, <span class="keyword">bool</span> is_system_include);
</pre>
<blockquote>
<p>The function <tt>opened_include_file</tt> is called whenever a file referred
by an <span class="preprocessor">#include</span> directive was successfully located and opened.</p>
<p>The parameter <tt>rel_filename</tt> contains the (normalised) probably relative file system path of the opened file. The concrete format of this file name depends on the format of the include search path given to the library beforehand.</p>
<p>The parameter <tt>abs_filename</tt> contains the (normalised) full file system path of the
opened file.</p>
<p>The <tt>include_depth</tt> parameter contains the current include file depth.
</p>
<p>The <tt>is_system_include</tt> parameter denotes, if the given file was found
as a result of a <tt>#include&nbsp;&lt;...&gt;</tt> directive.</p>
</blockquote>
<p><a name="returning_from_include_file" id="returning_from_include_file"></a><strong>returning_from_include_file</strong></p>
<pre> <span class="keyword">void</span> returning_from_include_file();
</pre>
<blockquote>
<p>The function <tt>returning_from_include_file</tt> is called whenever an
included file is about to be closed after it's processing is complete.</p>
</blockquote>
<h3>Interpretation of #pragma's</h3>
<p><strong><a name="interpret_pragma"></a>interpret_pragma</strong></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Context, <span class="keyword">typename</span> ContainerT&gt;
bool <a href="class_reference_ctxpolicy.html#interpret_pragma">interpret_pragma</a>(ContextT <span class="keyword">const</span> &amp;ctx, ContainerT &amp;pending,
<span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;option,
ContainerT <span class="keyword">const</span> &amp;values,
<span class="keyword">typename</span> ContextT::token_type<span class="keyword"> const</span> &amp;pragma_token);
</pre>
<blockquote>
<p>The function <tt>interpret_pragma</tt> is called whenever an unrecognized
<tt>#pragma&nbsp;wave&nbsp;...</tt> or operator <tt>_Pragma(&quot;wave&nbsp;...&quot;)</tt>
is found in the input stream.</p>
<p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user. </p>
<p>The <tt>pending</tt> parameter may be used to push tokens back into the input
stream which are to be used as the replacement text for the whole <tt>#pragma&nbsp;wave()</tt>
directive. If this sequence is left empty, no replacement takes place, i.e.
the interpreted directive is removed from the generated token stream.</p>
<p>The <tt>option</tt> parameter contains the name of the interpreted pragma.</p>
<p>The <tt>values</tt> parameter holds the value of the parameter provided to
the pragma operator.</p>
<p>The <tt>pragma_token</tt> parameter contains the actual #pragma token which
may be used for extraction of the location information for some error output.</p>
<p>If the return value is 'false', the whole #pragma directive is interpreted
as unknown and a corresponding error message is issued. A return value of
'true' signs a successful interpretation of the given #pragma.<br>
</p>
</blockquote>
<h3>Macro definition </h3>
<p><strong><a name="defined_macro" id="defined_macro"></a>defined_macro</strong></p>
<pre> <span class="keyword">template</span> &lt;
<span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ParametersT, <span class="keyword">typename</span> DefinitionT
&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#defined_macro">defined_macro</a>(TokenT <span class="keyword">const</span> &amp;name, <span class="keyword">bool</span> is_functionlike,
ParametersT <span class="keyword">const</span> &amp;parameters, DefinitionT <span class="keyword">const</span> &amp;definition,
<span class="keyword">bool</span> is_predefined);
</pre>
<blockquote> <p>The function <tt>defined_macro</tt> is called whenever a macro was defined successfully.</p>
<p>The parameter <tt>name</tt> is a reference to the token holding the macro name.</p>
<p>The parameter <tt>is_functionlike</tt> is set to true whenever the newly
defined macro is defined as a function like macro.</p>
<p>The parameter <tt>parameters</tt> holds the parameter tokens for the macro
definition. If the macro has no parameters or if it is a object like
macro, then this container is empty.</p>
<p>The parameter <tt>definition</tt> contains the token sequence given as the
replacement sequence (definition part) of the newly defined macro.</p>
<p>The parameter <tt>is_predefined</tt> is set to true for all macros predefined
during the initialisation pahase of the library.<br>
</p>
</blockquote>
<p><strong><a name="undefined_macro" id="undefined_macro"></a>undefined_macro</strong></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> TokenT&gt;
<span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#undefined_macro">undefined_macro</a>(TokenT<span class="keyword">const</span> &amp;name);
</pre>
<blockquote>
<p>The function <tt>undefined_macro</tt> is called whenever a macro definition
was removed successfully.</p>
<p>The parameter <tt>name</tt> holds the token of the macro which definition was removed.<br>
</p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_lexer.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,119 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The File Position</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
File Position</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="token_ids.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="predefined_macros.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_filepos.html#introduction">Introduction</a><br>
<a href="class_reference_filepos.html#header_synopsis">Header 'wave/util/file_position.hpp'
synopsis</a><br>
<a href="class_reference_filepos.html#template_parameters">Template parameters</a><br>
<a href="class_reference_filepos.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>The file position template is used to represent a concrete token position inside
the underlying input stream. This token position contains the corresponding
filename, the line number and the column number, where the token was recognized.</p>
<h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/util/file_position.hpp?view=markup">wave/util/file_position.hpp</a>
synopsis</b></h2>
<pre><span class="keyword">namespace</span> <span class="identifier">boost</span> {
<span class="keyword">namespace</span> <span class="identifier">wave</span> {
<span class="keyword">namespace</span> <span class="identifier">util</span> {
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> String = <span class="keyword">std::string</span>&gt;
<span class="keyword">class</span> file_position {
<span class="keyword">public</span>:
<a href="class_reference_filepos.html#constructors">file_position</a>();
<span class="keyword">explicit</span> <a href="class_reference_filepos.html#constructors">file_position</a>(String const &amp;file,
int line_ = 1, int column_ = 1);
// accessors
String <span class="keyword">const</span> &amp;<a href="class_reference_filepos.html#get_accessors">get_file</a>() <span class="keyword">const</span>;
<span class="keyword">int</span> <a href="class_reference_filepos.html#get_accessors">get_line</a>() <span class="keyword">const</span>;
<span class="keyword">int</span> <a href="class_reference_filepos.html#get_accessors">get_column</a>() <span class="keyword">const</span>;
<span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_file</a>(String <span class="keyword">const</span> &amp;file);
<span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_line</a>(<span class="keyword">int</span> line);
<span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_column</a>(<span class="keyword">int</span> column);
};
} <span class="comment">// namespace util</span>
} <span class="comment">// namespace wave</span>
} <span class="comment">// namespace boost</span></pre>
<h2><a name="template_parameters"></a>Template parameters</h2>
<p>The <tt>file_position</tt> template used by the default token type has to be instantiated with one template parameter,
which gives the string type to use for storing the file name member of the file
position. If this parameter isn't given, it defaults to a <tt>std::string</tt>.
Please note, that the type given as the template parameter must be compatible
with a <tt>std::string</tt>.</p>
<p>You may use your own position types if appropriate, but in any case these should implement the same interface as the <tt>file_position</tt> template described here. </p>
<h2><a name="member_functions"></a>Member functions</h2>
<h3><a name="constructors"></a>Constructors</h3>
<pre> <a href="class_reference_filepos.html#constructors">file_position</a>();
<span class="keyword">explicit</span> <a href="class_reference_filepos.html#constructors">file_position</a>(String const &amp;file,
int line_ = 1, int column_ = 1);
</pre>
<blockquote>
<p>The constructors initialize a new instance of a <tt>file_position</tt> in
correspondence to the supplied parameters. The parameters default to an empty
filename and the line number and column number set to one.</p>
</blockquote>
<p><a name="get_accessors"></a><b>get_file</b>, <b>get_line</b>, <b>get_column</b></p>
<pre> String <span class="keyword">const</span> &amp;<a href="class_reference_filepos.html#get_accessors">get_file</a>() <span class="keyword">const</span>;
<span class="keyword">int</span> <a href="class_reference_filepos.html#get_accessors">get_line</a>() <span class="keyword">const</span>;
<span class="keyword">int</span> <a href="class_reference_filepos.html#get_accessors">get_column</a>() <span class="keyword">const</span>;
</pre>
<blockquote>
<p>The <tt>get_...</tt> functions are used to access the current values of the
file position members: the filename (<tt>get_file</tt>), the line number (<tt>get_line</tt>)
and the column number (<tt>get_column</tt>).</p>
</blockquote>
<p><a name="set_accessors"></a><b>set_file</b>, <b>set_line</b>, <b>set_column</b></p>
<pre> <span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_file</a>(String <span class="keyword">const</span> &amp;file);
<span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_line</a>(<span class="keyword">int</span> line);
<span class="keyword">void</span> <a href="class_reference_filepos.html#set_accessors">set_column</a>(<span class="keyword">int</span> column);
</pre>
<blockquote>
<p>The <tt>set_...</tt> functions are used to set new values to the file position
members: the filename (<tt>set_file</tt>), the line number (<tt>set_line</tt>)
and the column number (<tt>set_column</tt>).</p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="token_ids.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="predefined_macros.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span><!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->e format:fcAm1m -->Thursday, May 12, 2005 9:14<!-- #EndDate -->
</span></p>
</body>
</html>
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->

View File

@@ -1,132 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Input Policy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Input Policy</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_context.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_ctxpolicy.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_inptpolcy.html#introduction">Introduction</a><br>
<a href="class_reference_inptpolcy.html#header_synopsis">Header 'wave/cpp_iteration_context.hpp'
synopsis</a><br>
<a href="class_reference_inptpolcy.html#template_parameters">Template parameters</a><br>
<a href="class_reference_inptpolcy.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>The input policy type may be specified as a template parameter to the <tt>wave::context</tt>
object and is used for customizing the way, how an included file is to be represented
by a pair of iterators pointing to the beginning and the end of the resulting
input sequence. If this template parameter is not given while instantiating
the context object, it defaults to the <tt>iteration_context_policies::load_file_to_string</tt>
type. </p>
<h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/util/iteration_context.hpp?view=markup">wave/iteration_context.hpp</a>
synopsis</b></h2>
<p>The following code listing does not show the required interface only, but for
brevity reasons the whole implementation of an input policy, which loads the
given file into a string variable and exposes the begin() and end() iterators
of this string to the <tt>Wave</tt> library.</p>
<pre><span class="keyword">namespace</span> boost {
<span class="keyword">namespace</span> wave {
<span class="keyword">namespace</span> iteration_context_policies {
<span class="keyword">struct</span> load_file_to_string {
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> IterContext&gt;
<span class="keyword">class</span> inner {
<span class="keyword">public</span>:
<span class="comment">// expose the begin and end iterators for the</span>
<span class="comment">// included file</span>
<span class="keyword">template</span> &lt;typename Position&gt;
<span class="keyword">static</span>
<span class="keyword">void</span> <a href="class_reference_inptpolcy.html#init_iterators">init_iterators</a>(IterContext&iter_ctx,
Position const &act_pos)
{
<span class="keyword">typedef typename</span> IterContext::iterator_type iterator_type;
<span class="keyword">std::ifstream</span> instream(iter_ctx.filename.c_str());
if (!instream.is_open()) {
CPP_THROW(preprocess_exception, bad_include_file,
iter_ctx.filename, act_pos);
}
iter_ctx.instring = <span class="keyword">std::string</span>(
<span class="keyword">std::istreambuf_iterator</span><char>(instream.rdbuf()),
<span class="keyword">std::istreambuf_iterator</span><char>());
iter_ctx.first = iterator_type(iter_ctx.instring.begin(),
iter_ctx.instring.end(),
PositionT(iter_ctx.filename));
iter_ctx.last = iterator_type();
}
<span class="keyword">private</span>:
<span class="keyword">std::string</span> instring;
};
};
} <span class="comment">// namespace iteration_context_policies</span>
} <span class="comment">// namespace wave </span>
} <span class="comment">// namespace boost </span> </pre>
<p>As you can see, an <tt>input_policy</tt> for the <tt>wave::context</tt> object
should implement one function only, the init_iterators function. The policy
shown is implemented with the help of an embedded class to avoid the need for
template template parameters, which aren't implemented by all systems today.
This embedded class should have the name <tt>inner</tt>.</p>
<h3><a name="template_parameters"></a>Template Parameters</h3>
<p>The <tt>inner</tt> class is instantiated with one template parameter, the iteration
context type, from which the policy is a part of. The iterator type <tt>iterator_type</tt>
which is used to access the underlying input stream has to be derived through
a typedef as shown. The iterator pair to initialize (which is accessible as
<tt>iter_ctx.first</tt> and <tt>iter_ctx.last</tt>) has to initialized from
an abritrary iterator type, representing the actual input stream.</p>
<h3><a name="member_functions"></a>Member Functions</h3>
<p><a name="init_iterators"></a><b>init_iterators</b></p>
<pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Position&gt;
<span class="keyword">static void</span> init_iterators(
IterContext iter_ctx,
Position const &act_pos);</pre>
<p>directive was found in the input token stream. The main rationale for this
function is to initialize the pair of iterators <tt>iter_ctx.first</tt> and
<tt>iter_ctx.last</tt>, which are to be used to access the input stream corresponding
to the include file to be inserted from inside the preprocessing engine.</p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_context.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_ctxpolicy.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,102 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Lexer Interface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Lexer Iterator Interface</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_ctxpolicy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_tokentype.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_lexer.html#introduction">Introduction</a><br>
<a href="class_reference_lexer.html#header_synopsis">Wave Lexer
synopsis</a><br>
<a href="class_reference_lexer.html#public_typedefs">Public Typedefs</a><br>
<a href="class_reference_lexer.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>Every lexer, which should be used in conjunction with the <tt>Wave</tt> library, has to return tokens formed from the input stream. These tokens should conform to the synopsis described in the topic <a href="class_reference_tokentype.html">The Token Type</a>. The lexer type should expose an interface which conforms at least to a <tt>forward_iterator</tt> (in the sense defined by the the C++ Standard) returning the token type. The code sample below does not show the definition of this forward iterator interface because this is highly implementation defined.</p>
<h2><a name="header_synopsis"></a>Wave lexer
synopsis (header: <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/cpplexer/cpp_lex_interface.hpp?view=markup">wave/cpplexer/cpp_lexer_interface.hpp</a>)</h2>
<pre> <span class="keyword">struct</span> lex_iterator
{
<span class="keyword">typedef</span> boost::wave::lex_token&lt;&gt; <a href="class_reference_lexer.html#public_typedefs">token_type</a>;
<span class="comment"> // Every lex_iterator should implement at least a complete
// forward_iterator interface (not shown here)
</span><span class="keyword"> typedef</span> std::forward_iterator_tag iterator_category;
<span class="comment"> // additional requirements
</span> <a href="class_reference_lexer.html#member_functions">lex_iterator</a>();
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Iterator&gt;
<a href="class_reference_lexer.html#constructor">lex_iterator</a>(Iterator <span class="keyword">const</span> &amp;first, Iterator <span class="keyword">const</span> &amp;last
<span class="keyword">typename</span> token_type::position_type <span class="keyword">const</span> &amp;pos,
boost::wave::language_support language)
};
</pre>
<p>Please note, that the <tt>lex_iterator</tt> defined in the library header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/cpplexer/cpp_lex_interface.hpp?view=markup">wave/cpplexer/cpp_lexer_interface.hpp</a> actually is a template class taking the token type to use as its template parameter. This is omitted in the synopsis above because it is an implementation detail of the Re2C lexer provided as part of the Wave library.</p>
<p>If you want to use Wave in conjunction with your own lexing component this will have to conform to the interface described above only. </p>
<h2><a name="public_typedefs" id="public_typedefs"></a>Public Typedefs</h2>
<p>Besides the typedefs mandated for a <tt>forward_iterator</tt> by the C++ standard every lexer to be used with the <tt>Wave</tt> library should define the following typedefs: </p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Public typedef's defined by the <tt>boost::wave::context</tt> class </b></td>
</tr>
<tr>
<td width="32%" class="table_cells"><code>token_type</code></td>
<td width="68%" class="table_cells"><p>The <tt>token</tt> type returned by the lexer. This is type is used as the return value of the main iterators provided by the <tt>boost::wave::context</tt> object too. </p></td>
</tr>
</table>
<h2><a name="member_functions"></a>Member functions</h2>
<p>Besides the functions, which should be provided for <tt>forward_iterators</tt> as mandated by the C++ Standard, every lexer must implement the following functions to be used with the <tt>Wave</tt> library: </p>
<p><a name="constructor" id="constructor"></a><b>constructor</b></p>
<pre> lex_iterator();</pre>
<blockquote>
<p>The default constructor should construct a lexer iterator, which may be used as the end iterator of the provided iterator range.</p>
</blockquote>
<pre>
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Iterator&gt;
lex_iterator(Iterator <span class="keyword">const</span> &amp;first, Iterator <span class="keyword">const</span> &amp;last,
<span class="keyword">typename</span> token_type::position_type <span class="keyword">const</span> &amp;pos,
boost::wave::language_support language);</pre>
<blockquote>
<p>The second constructor should construct a lexer iterator, which may be used as a iterator traversing over the token sequence, generated by the lexer class.</p>
<p>The pair of iterators <tt>first</tt> and <tt>last</tt> should represent the input stream to be tokenized by the given lexer class. </p>
<p>The parameter <tt>pos</tt> contains the initial position information to be used for token generation.</p>
<p>The parameter <tt>language</tt> controls the reuqired mode with which the lexer should be initialised. </p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_ctxpolicy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_tokentype.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
<<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->

View File

@@ -1,176 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Token Type</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="theme/style.css" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Token Type</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_lexer.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="token_ids.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="class_reference_tokentype.html#introduction">Introduction</a><br>
<a href="class_reference_tokentype.html#header_synopsis">Header 'wave/context.hpp'
synopsis</a><br>
<a href="class_reference_tokentype.html#template_parameters">Template parameters</a><br>
<a href="class_reference_tokentype.html#public_typedefs">Public Typedefs </a><br>
<a href="class_reference_tokentype.html#member_functions">Member functions</a></p>
</blockquote>
<h2><a name="Introduction"></a>Introduction</h2>
<p>The token type in <tt>Wave</tt> is the main carrier of information. It is returned
by dereferencing the iterators exposed by the lexing component and the iterator exposed by the preprocessor component. The tokens are originally generated by the
lexer (&quot;An entity that lexically transforms the subject of parsing to a
sequence of objects (called tokens) more suitable for subsequent parsing.&quot;).
The Wave library contains two different, interchangable C++ lexers, which may
be used as a starting point during developing your own application. The lexer
generated tokens are transformed by the preprocessing engine (macro expansion,
include file processing etc.) and after this returned to the user of the <tt>Wave</tt>
library.</p>
<p>You can use arbitrary token types in conjunction with your own lexer as long
as these implement some required interface. The required token type interface
is described below and is implemented by the <tt>wave::cpplexer::lex_token</tt>
template, the required lexer interface is described <a href="class_reference_lexer.html">here</a>.
</p>
<p>In the following is described the token type predefined inside the <tt>Wave</tt>
library, which is used in conjunction with the two predefined C++ lexers contained
in the <tt>Wave</tt> library too. If you need to use your own token type, it
is required to implement the interafce described below.</p>
<h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/cpplexer/cpp_lex_token.hpp?view=markup">wave/cpplexer/cpp_lex_token.hpp</a>
synopsis</b></h2>
<pre><span class="keyword">namespace</span> boost {
<span class="keyword">namespace</span> wave {
<span class="keyword">namespace</span> cpplexer {
<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Position&gt;
<span class="keyword">class</span> lex_token
{
<span class="keyword">public</span>:
<span class="keyword">typedef</span> <span class="keyword">std::basic_string</span><char>&lt;char&gt; string_type;
<span class="keyword">typedef</span> Position position_type;
<a href="class_reference_tokentype.html#constructor">lex_token</a>();
<a href="class_reference_tokentype.html#constructor">lex_token</a>(token_id id, string_type <span class="keyword">const</span> &value,
PositionT <span class="keyword">const</span> &pos);
// accessors
<a href="class_reference_tokentype.html#operator_tokenid">operator token_id</a>() <span class="keyword">const</span>;
string_type const &amp;<a href="class_reference_tokentype.html#get_value">get_value</a>() <span class="keyword">const</span>;
position_type const &amp;<a href="class_reference_tokentype.html#get_position">get_position</a>() <span class="keyword">const</span>;
void <a href="class_reference_tokentype.html#set_token_id">set_token_id</a> (token_id id);
void <a href="class_reference_tokentype.html#set_value">set_value</a> (string_type <span class="keyword">const</span> &amp;newval);
void <a href="class_reference_tokentype.html#set_position">set_position</a> (position_type <span class="keyword">const</span> &amp;pos);
};
} <span class="comment">// namespace cpplexer</span>
} <span class="comment">// namespace wave</span>
} <span class="comment">// namespace boost</span>
</pre>
<h2><b><a name="template_parameters" id="template_parameters"></a>Template parameters</b></h2>
<p>The predefined token type uses a template parameter <tt>Position</tt>, which
allows to specify the type to be used to carry the file position information
contained inside the generated tokens. Your own token type do not need to take this <tt>Position</tt> template parameter, but please note, that the token type in any case needs to have an embedded type definition <tt>position_type</tt> (see below) . </p>
<h2><a name="public_typedefs" id="public_typedefs"></a>Public Typedefs</h2>
<p>The token type needs to define two embedded types: <tt>string_type</tt> and <tt>position_type</tt>. The <tt>string_type</tt> needs to be a type compatible to the <tt>std::basic_string&lt;&gt;</tt> class. </p>
<p>This type should contain at least the filename, the line number and the column number of the position, where the token was recognized. For the predefined token type it defaults to a simple file_position template class described <a href="class_reference_filepos.html">here</a>. Note, that your own <tt>position_type</tt> should follow the interface described for the file_position template as well. </p>
<h2><b><a name="member_functions"></a>Member functions</b></h2>
<p><b><a name="constructor" id="constructor"></a>Constructors</b></p>
<pre> lex_token();
lex_token(token_id id,
string_t <span class="keyword">const</span> &amp;value,
PositionT <span class="keyword">const</span> &amp;pos);</pre>
<blockquote>
<p>The first (default) constructor is for generating an end of stream token,
which is used for indicating the end of the underlying input stream.</p>
<p>The second constructor initializes the newly created token object with its
token id (for a list of valid token id's please look <a href="token_ids.html">here</a>),
the string representation of its value and the file position, describing the
position inside the input stream , where this token was recognized.</p>
</blockquote>
<h2>Accessor functions</h2>
<p><a name="operator_tokenid"></a><b>operator token_id</b></p>
<pre> <span class="keyword">operator</span> token_id() <span class="keyword">const</span>;</pre>
<blockquote>
<p>Allows the access to the token id of the token. This access <!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->operation of <tt>Spirit</tt>
parsers directly on top
top of a token stream. The possible token id's are described
<a href="token_ids.html">here</a></a>. </p>
<p>This function does not throw in any case.</p>
</blockquote>
<p><a name="get_value"></a><b>get_value</b></p>
<pre> string_type <span class="keyword">const</span> &amp;get_value() <span class="keyword">const</span>;</pre>
<blockquote>
<p>Returns the value of the token, as it was recognized in the input stream.
Even for constant tokens (as keywords or operators etc.) the returned value
reflects the character sequence as found in the input stream. </p>
<p>This function does not throw in any case.</p>
</blockquote>
<p><b><a name="get_position"></a>get_position</b></p>
<pre> Position <span class="keyword">const</span> &amp;get_position() <span class="keyword">const</span>;</pre>
<blockquote>
<p>Returns the position of the token in the input stream, where it was recognized.
The position contains information about the filename, the line number and
the column number of the token. By default the <tt>Wave</tt> library uses
a file_position template for this purpose, which is described in more detail
<a href="class_reference_filepos.html">here</a>.</p>
<p>This function does not throw in any case.</p>
</blockquote>
<p><a name="set_token_id"></a><b>set_token_id</b></p>
<pre> void set_token_id(token_id id);</pre>
<blockquote>
<p>Changes the token id of the token to the new value. The possible token id's
are described <a href="token_ids.html">here</a>. Probably this function is
of little value for the library user, but it is required under certain circumstances
for correct operation of the preprocessing engine.</p>
<p>This function does not throw in any case.</p>
</blockquote>
<p><a name="set_value"></a><b>set_value</b></p>
<pre> void set_value(string_type <span class="keyword">const</span> &amp;newval);</pre>
<blockquote>
<p>Changes the value stored inside the token to the new value. Propably this
function is of little value for the library user, but it is required under
certain circumstances for correct operation of the preprocessing engine.</p>
</blockquote>
<p><a name="set_position"></a><b>set_position</b></p>
<pre> void set_position(Position <span class="keyword">const</span> &amp;newpos);</pre>
<blockquote>
<p>Changes the position stored inside the token to the new value. This is used
for instance for implementing the functionality required for to implement
the <tt>#line</tt> directive.</p>
</blockquote>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_lexer.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="token_ids.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,203 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Compile Time Configuration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Compile
Time Configuration</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="samples.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p><b><a name="compiletime_config"></a>Library compile time configuration</b></p>
<P dir="ltr">The C++ preprocessor iterator library may be configured at compile
time by specifying different preprocessor constants to include different additional
features. The possible preprocessor constants are described in the following
table. </P>
<table width="100%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Summary of possible preprocessor constants
for<br>
library configuration</b></td>
</tr>
<tr>
<td width="46%" class="table_cells"><code>BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE</code></td>
<td width="54%" class="table_cells"> <p>Support the #warning directive</p></td>
</tr>
<tr>
<td width="46%" class="table_cells"><code><code>BOOST_</code>WAVE_SUPPORT_MS_EXTENSIONS</code></td>
<td width="54%" class="table_cells"> <p>Support several MS specific language
extensions (i.e. <tt>__int8</tt> et.al.)</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_PREPROCESS_ERROR_MESSAGE_BODY</code></td>
<td class="table_cells"><p>Enable the preprocessing of the message bodies
of <span class="keyword">#error</span> and <span class="keyword">#warning</span>
directives.</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_RETURN_PRAGMA_DIRECTIVES</code></td>
<td class="table_cells"><p>If defined, then the <span class="keyword">#pragma</span>
directives are returned as a token sequence to the caller, if not defined,
the whole <span class="keyword">#pragma</span> directive is skipped. </p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_PREPROCESS_PRAGMA_BODY</code></td>
<td class="table_cells"><p>Enable the preprocessing of the bodies of <span class="keyword">
#pragma</span> directives.<br>
Note though, that the body of an <tt>operator&nbsp;_Pragma()</tt> is preprocessed
always, as required by the C99 Standard <a href="references.html#iso_c">[2]</a>.
</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_ENABLE_COMMANDLINE_MACROS</code></td>
<td class="table_cells"><p>Enable the functionality required to define macros
with the command line syntax (-DMACRO(x)=definition)</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_STRINGTYPE</code></td>
<td class="table_cells"><p>The tokens generated by the <tt>Wave</tt> library
contain the token data and the file position, where this token was found
in the input stream. <br>
This constant may be used to redefine the data type, which is used to
hold the token data and the corresponding file name. If this isn't defined
it defaults to std::string. (The here defined data type should be compatible
to the std::string type)</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_SUPPORT_VARIADICS_PLACEMARKERS</code></td>
<td class="table_cells"><p>If defined, then the preprocessor library supports
variadics and placemarkers. Note, to support C99 mode, this constant must
be defined too.</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_MAX_INCLUDE_LEVEL_DEPTH</code></td>
<td class="table_cells"><p>If defined, it will determine the initial maximal
possible include file nesting depth supported. It defaults to 1024.</p></td>
</tr>
<tr>
<td class="table_cells"><code><code>BOOST_</code>WAVE_SUPPORT_PRAGMA_ONCE</code></td>
<td class="table_cells"><p>If defined, then the <code>#pragma once</code> directive is supported by <tt>Wave</tt>. This specifies that the file, in which the pragma resides, will be included
(opened) only once by the compiler in a build. </p></td>
</tr>
<tr>
<td class="table_cells"><code>BOOST_</code><code>WAVE_SUPPORT_INCLUDE_NEXT</code></td>
<td class="table_cells"><p>If defined, then the <code>#include_next</code> directive is supported by <tt>Wave</tt>. This is syntactically equivalent to the <code>#include</code> directives, but may be used to inherit a header file (i.e. to include a file, which is named as the current file containing the <code>#include_next</code>).</p></td>
</tr>
</table>
<P dir="ltr"><b><a name="using_custom_lexer"></a>Using a different token type or lexer type in conjunction with Wave </b></P>
<P dir="ltr">It is possible to use the <tt>Wave</tt> library while using your own token and/or lexer types. This may be achieved by providing your lexer type as the second template parameter while instantiating the <tt>boost::wave::context&lt;&gt;</tt> object. The token type used by the library is derived from the <tt>token_type</tt> typedef to be provided by the lexer type. If you want to provide your own token type only, you may use the <tt>boost::wave::lex_iterator&lt;&gt;</tt> type contained with the library. This type needs to be parametrized with the token type to use. </P>
<P dir="ltr">To show, how this may be done, the <tt>Wave</tt> library contains several samples illustrating this possibility. The <tt>cpp_tokens</tt> sample shows the usage of a custom lexer and a custom token types. The lexer type used is functionally fully compatible to the <tt>re2c</tt> <a href="references.html#re2c">[3]</a> based lexer used by default. It is implemented based on the <tt>SLex</tt> <a href="references.html#slex">[5]</a> lexer example written by Dan Nuffer. The token type used therein is functionally equivalent to the default token type except for an additional <tt>operator&lt;&lt;</tt> used for dumping the information carried by the token.</P>
<P dir="ltr"><b><a name="compilation_models"></a>Separation and inclusion compilation
models</b></P>
<P dir="ltr">The <tt>Wave</tt> C++ preprocessor iterator library is build almost
completely as a header only library (except for the re2c based lexer). If you're
trying to include all required files at once you will mention, that the resulting
compilation times are very large (up to an hour - depending on your system configuration).
This straightforward method we'll call the inclusion compilation model. If you
do not pay attention to compilation times, that's the way to go, no special
handling is needed.</P>
<P dir="ltr">If you're interested in decreasing compilation times, the following
method is to be used. This we will call it the separation compilation model.
The trick is to separate the different objects such, that they are compilable
separately. The function, which instantiates the templated object in question
is factored out such, that its definition is visible to only one translation
unit. To simplify this further this creation function is packaged into a small
generator template structure.</P>
<P dir="ltr">There are two levels of separation implemented: the separation of
the compilation of the C++ lexer and the separation of the compilation of the
different Spirit grammars used. To use these separations you will have to define
two preprocessor constants while compiling the whole application and you will
have to explicitely instantiate some helper templates. The following tables
shows these constants in detail.</P>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Summary of possible compilation constants
required <br>
to enable the separation compilation model</b></td>
</tr>
<tr class="table_title">
<td width="25%"><b>Separate</b></td>
<td width="75%"><p><code><font face="Verdana, Arial, Helvetica, sans-serif">Preprocessor
constant</font></code></p></td>
</tr>
<tr>
<td width="25%" class="table_cells"><code>C++ lexer</code></td>
<td width="75%" class="table_cells"> <p><code><code>BOOST_</code>WAVE_SEPARATE_LEXER_INSTANTIATION</code></p></td>
</tr>
<tr>
<td width="25%" class="table_cells"><code>Spirit grammars</code></td>
<td width="75%" class="table_cells"> <p><code><code>BOOST_</code>WAVE_SEPARATE_GRAMMAR_INSTANTIATION</code></p></td>
</tr>
</table>
<P dir="ltr">The following table shows the explicit template instantiations required,
if you want to use the separation compilation model. The <tt>TokenT</tt> placeholder
type has to be replaced with your token type to use and the <code><tt>LexIteratorT</tt></code> placeholder type has to be replaced with your lex iterator type you've used while instantiation of the <tt>boost::wave::context&lt;&gt;</tt> object. You will achieve the best
results, if you place these into separate compilation units each. The <tt>IteratorT</tt>
placeholder should be replaced by the iterator type, which was used to instantiate
the <tt>boost::wave::context&lt;&gt;</tt> object.</P>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Summary of required explicit template
instantiations <br>
required when using the separation compilation model</b></td>
</tr>
<tr class="table_title">
<td width="25%"><b>Separate</b></td>
<td width="75%"><p><code><font face="Verdana, Arial, Helvetica, sans-serif">Templates
to explicitly instantiate</font></code></p></td>
</tr>
<tr>
<td width="25%" class="table_cells"><code>C++ lexer</code></td>
<td width="75%" class="table_cells"> <code><span class="keyword">template</span>
cpplexer::re2clex::new_lexer_gen&lt;<tt>IteratorT</tt>&gt;;</code></td>
</tr>
<tr>
<td width="25%" class="table_cells"><code>Spirit grammars</code></td>
<td width="75%" class="table_cells"> <p><code><span class="keyword">template</span> wave::grammars::expression_grammar_gen&lt<tt>TokenT</tt>&gt;;<br>
<span class="keyword"> template</span> wave::grammars::intlit_grammar_gen&lt;<tt>TokenT</tt>&gt;;<br>
<span class="keyword"> template</span> wave::grammars::chlit_grammar_gen&lt;<tt>TokenT</tt>&gt;;<br>
<span class="keyword"> <code>template</code><code></code><code> wave::grammars::cpp_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;<br>
</code>template</span> wave::grammars::predefined_macros_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;<br>
<span class="keyword"> template</span> wave::grammars::defined_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;</code></p></td>
</tr>
</table>
<p>To see an example of this you can look at the <tt>Wave</tt> driver program
included as an acompanion sample to the C++ preprocessor iterator library. The
corresponding files are named obviously <span class="string">&quot;instantiate_...something.cpp&quot;</span>,
where the <span class="string">'...somthing'</span> is a hint, which grammars
are explicitely instantiated inside. By using the separation model the compilation
times required to build the <tt>Wave</tt> example are dropped by up to 90%.</p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="samples.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,93 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Introduction</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Introduction</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<P dir="ltr">The <tt>Wave</tt> C++ preprocessor library is a Standards conformant
implementation of the mandated C99/C++ preprocessor functionality packed behind
a simple to use interface, which integrates well with the well known idioms
of the Standard Template Library (STL).</P>
<P dir="ltr">The <tt>Wave</tt> C++ preprocessor is not a monolitic application,
it's rather a modular library, which exposes mainly a context object and an
iterator interface. The context object helps to configure the actual preprocessing
process (as search path's, predefined macros, etc.). The exposed iterators are
generated by this context object too. Iterating over the sequence defined by
the two iterators will return the preprocessed tokens, which are to be built
on the fly from the given input stream. </P>
<P dir="ltr"> The C++ preprocessor iterator itself is fed by a C++ lexer iterator,
which implements an abstract interface. The C++ lexers packaged with the
<tt>Wave</tt> library may be used standalone, too, and are not tied to the C++
preprocessor iterator at all. </P>
<P dir="ltr">To make the C++ preprocessing library modular, the C++ lexer is held
completely separate and independent from the preprocessor. To prove this concept,
two different, but functionally identical C++ lexers were
implemented. Additionally there is implemented a IDL lexer, which allows to use the preprocessor library as the lexing component of a IDL oriented tool. All these lexers implement the mentioned abstract interface,
so that the C++ preprocessor iterator may be used with all of them. The abstraction
of the lexer from the preprocessor iterator library was done to allow
plugging in different lexers without the need to reimplement the preprocessor.
This will allow for benchmarking and specific fine tuning of the process of preprocessing
itself.</P>
<P dir="ltr">The first of these C++ lexers is implemented with the help of the
well known <tt>Re2C</tt> <a href="references.html#re2c">[3]</a> tool, which generates
C code from given regular expressions. The lexers generated with <tt>Re2C</tt>
are known to be very fast, because they are not table driven but directly code the token building logic
(very similar to hand coded lexers).
</P>
<P dir="ltr">The second of these C++ lexers is built around a table driven lexer,
where the DFA tables (discrete finite automaton tables) are generated from regular expressions with the help of
a Spirit-based lexer generating framework named <tt>Slex</tt> <a href="references.html#slex">[5]</a>.
The <tt>Slex</tt> is fed during runtime with the token definitions (regular
expressions) and generates the resulting DFA table. This table is used to combine
the input characters into corresponding lexemes (tokens). The generated DFA table
can be saved to disk to avoid the generation process at program startup.</P>
<P dir="ltr">Wave may be used for preprocessing IDL files too, since the token set needed for the IDL language is very similar to the C++ token set. That's the reason, why the <tt>Wave</tt> preprocessor library contains also an IDL lexer. The IDL lexer is also based on the <tt>Re2C</tt> tool, but recognizes a different set of tokens. So this lexer does not recognize any keywords (except <tt>true</tt> and <tt>false</tt>, which are needed by the preprocessor itself). This is needed because there exist different IDL language flavours, where identifiers of one flavour may be keywords of others - Ok, this requires postponement of keyword identification until after the
preprocessing, but allows to use Wave for all of the IDL derivatives. </P>
<P dir="ltr">It is possible to build other C++ lexers if needed. Currently there
are plans to adapt the <tt>Spirit</tt> C++ lexer example <tt>cpplexer</tt> <a href="references.html#cpplexer">[6]</a>,
which is completely based on static <tt>Spirit<a href="references.html#spirit">[4]</a></tt>
grammars.</P>
<P dir="ltr">Both of the included lexers and the library itself are able
to act in a C99 compliant mode. In this mode the lexers reject C++-only tokens
(<tt>'::'</tt>, <tt>'-&gt;*'</tt>, <tt>'.*'</tt> and the alternate keywords
such as <tt>'and'</tt>, etc.). The preprocessor additionally handles placemarkers
(empty macro arguments) and variadics (macros with variable parameter counts).
As an extension to the C++ Standard, the library can be enabled to handle placemarkers
and variadics in C++ mode too.</P>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span> </p>
</body>
</html>

View File

@@ -1,101 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Macro Expansion Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Macro Expansion Process</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="compiletime_config.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>The macro expansion process described here was initially developed by <a href="mailto:pmenso57@attbi.com">Paul
Mensonides</a> and is implemented in <tt>Wave</tt>. It is much more understandable
as the description of the desired macro expansion algorithm provided in the
C++ Standard <a href="references.html#iso_cpp">[1]</a>.</p>
<p>Macro replacement proceeds left-to-right. </p>
<p>If, during scanning (or rescanning) an identifier is found, it is looked up
in the symbol table. If the identifier is not found in the symbol table, it
is not a macro and scanning continues.</p>
<p>If the identifier is found, the value of a flag associated with the identifier
is used to determine if the identifier is available for expansion. If it is
not, the specific token (i.e. the specific instance of the identifier) is marked
as disabled and is not expanded. If the identifier is available for expansion,
the value of a different flag associated with the identifier in the symbol table
is used to determine if the identifier is an object-like or function-like macro.
If it is an object-like macro, it is expanded. If it is a function-like macro,
it is only expanded if the next token is an left parenthesis.<br>
An identifier is available for expansion if it is not marked as disabled and
if the the value of the flag associated with the identifier is not set, which
is used to determine if the identifier is available for expansion.</p>
<p>(If a macro is an object-like macro, skip past the next two paragraphs.)</p>
<p>If a macro to be expanded is a function-like macro, it must have the exact
number of actual arguments as the number of formal parameters required by the
definition of the macro. Each argument is recursively scanned and expanded.
Each parameter name found in the replacement list is replaced by the expanded
actual argument after leading and trailing whitespace and all placeholder tokens
are removed unless the parameter name immediately follows the stringizing operator
(<tt>'#'</tt>) or is adjacent to the token-pasting operator (<tt>'##'</tt>).</p>
<p>If the parameter name immediately follows the stringizing operator (<tt>'#'</tt>),
a stringized version of the unexpanded actual argument is inserted. If the parameter
name is adjacent to the token-pasting operator (<tt>'##'</tt>), the unexpanded
actual argument is inserted after all placeholder tokens are removed.</p>
<p>All concatenation takes place in the replacement list. (If a single concatenation
yields multiple tokens, the behavior is undefined. Moreover, <tt>Wave</tt> in
normal C++98 and C99 modes issues an error, if more then one token is produced
as the result of the concatenation. In C++0x mode <tt>Wave</tt> treats token-pasting
of unrelated tokens as well defined and inserts the reparsed string representation
of the concatenated tokens into the replacement list.).</p>
<p>The flag in the symbol table entry associated with the name of the macro being
expanded is set to indicate the that the macro is not available for expansion.</p>
<p>The replacement list is rescanned for further macro expansion. All leading
and trailing whitespace tokens in the replacement list are removed (the placeholder
tokens are left intact). </p>
<p>After rescanning completes, the flag in the symbol table entry associated with
the name of macro being expanded is cleared to indicate that the macro is again
available for expansion, and the sequence of tokens that constitutes the rescanned
replacement list is returned to the point of invocation of the macro.</p>
<p>If this sequence of tokens is empty, it is replaced by a placeholder token.
If a placeholder is found during scanning (or rescanning) it is ignored. (Also,
if the only thing separating a parameter from the stringizing operator or token-pasting
operator is placeholder, it is also ignored in that context.)</p>
<p>This sequence of tokens is inserted at the original point that the macro was
invoked, and scanning continues starting with the last token of the newly inserted
sequence of tokens. I.e. scanning looks back a single token (possibly a placeholder
token) and continues.<br>
</p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="compiletime_config.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span>
</p>
<p>&nbsp; </p>
</body>
</html>

View File

@@ -1,158 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Predefined Macros</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Predefined
Macros </font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p dir="ltr">The following table lists the macros, which are predefined by the
<tt>Wave</tt> library. Some of these (all except the <code class="keyword">__LINE__</code>,
<code class="keyword">__FILE__</code>, <code class="keyword">__BASE_FILE__</code>, <code class="keyword">__DATE__</code>,
<code class="keyword">__TIME__</code>, <code class="keyword">__STDC__, __INCLUDE_LEVEL__</code>
and <code class="keyword">__cplusplus</code> macros) may be undefined from the command line of the driver executable
(<a href="wave_driver.html">see</a> the -U option) or through the function <a href="class_reference_context.html#remove_macro_definition">remove_macro_definition()</a>.</p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="3" class="table_title"><b>Summary of predefined macros</b></td>
</tr>
<tr class="table_title">
<td width="28%"><b>Name</b></td>
<td width="62%"><p><code><font face="Verdana, Arial, Helvetica, sans-serif">Value</font></code></p></td>
<td width="10%">Undefinable</td>
</tr>
<tr>
<td width="28%" class="table_cells"><code>__STDC__</code></td>
<td width="62%" class="table_cells"><p> 1 (a decimal constant)</p></td>
<td width="10%" class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td width="28%" class="table_cells"><code>__cplusplus</code></td>
<td width="62%" class="table_cells"> <p>199711L (a decimal constant), this
is defined in C++ mode only (C99 mode is off)<br>
In the C++0x mode this decimal constant is guaranteed to be larger than
199711L (the concrete value is to be defined by the C++ committee).</p></td>
<td width="10%" class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__LINE__</code></td>
<td class="table_cells"><p>The line number of the current source line (a decimal
constant)</p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__FILE__</code></td>
<td class="table_cells"><p>The presumed name of the source file (a character string literal)</p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__BASE_FILE__</code></td>
<td class="table_cells"><p> This macro expands to the name of the main input file (a character string literal). This is the source file that was specified during construction of the <a href="class_reference_context.html"><tt>wave::context</tt></a> template.</p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__DATE__</code></td>
<td class="table_cells"><p>The date of translation of the source file (a character
string literal of the form<br>
&quot;Mmm dd yyyy&quot;, where the names of the months are the same as
those generated by the asctime function, and the first character of dd
is a space character if the value is less than 10). </p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__TIME__</code></td>
<td class="table_cells"><p>The time of translation of the source file (a character
string literal of the form &quot;hh:mm:ss&quot;<br>
as in the time generated by the asctime function).</p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__INCLUDE_LEVEL__</code></td>
<td class="table_cells"><p>A decimal integer constant that represents the
depth of nesting in include <br>
files. The value of this macro is incremented on every <tt>#include</tt>
directive <br>
and decremented at every end of file. </p></td>
<td class="table_cells"><p>no</p></td>
</tr>
<tr>
<td class="table_cells"><code>__WAVE__</code><br> <code>__SPIRIT_PP__</code></td>
<td class="table_cells"><p>The version of the driver program (a hexadecinal
constant of the form 0xMmrr, where <span class="literal">'M'</span> is
the major version number, <span class="literal">'m'</span> the minor version
number and <span class="literal">'rr'</span> the release number).</p></td>
<td class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td class="table_cells"><code>__WAVE_VERSION__</code><br> <code>__SPIRIT_PP_VERSION__</code></td>
<td class="table_cells"><p>The full version number of the driver program (a
hexadecimal constant of the form 0xMmrrbbbb, where <span class="literal">'M'</span>
is the major version number, <span class="literal">'m'</span> the minor
version number, <span class="literal">'rr'</span> the release number and
<span class="literal">'bbbb'</span> the build number).</p></td>
<td class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td class="table_cells"><code>__WAVE_VERSION_STR__</code><br> <code>__SPIRIT_PP_VERSION_STR__</code></td>
<td class="table_cells"><p>The full version number of the driver program (a
character string literal of the form <span class="string">&quot;M.m.rr.bbbb&quot;</span>,
where <span class="literal">'M'</span> is the major version number, <span class="literal">'m'</span>
the minor version number, <span class="literal">'rr'</span> the release
number and <span class="literal">'bbbb'</span> the build number).</p></td>
<td class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td class="table_cells"><code>__STDC_VERSION__</code></td>
<td class="table_cells"><p>199901L (a decimal constant), this is defined in C99 mode only</p></td>
<td class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td class="table_cells"><code>__STDC_HOSTED__</code></td>
<td class="table_cells"><p>0L (a decimal constant), this is defined in C99 mode only</p></td>
<td class="table_cells"><p>yes</p></td>
</tr>
<tr>
<td class="table_cells"><code>__WAVE_HAS_VARIADICS__</code></td>
<td class="table_cells"><p>1 (a decimal constant), this is defined in C++
mode only if variadics and placemarkers are enabled, and it is defined
in the C99 mode</p></td>
<td class="table_cells"><p>no</p></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="supported_pragmas.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,110 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Preface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Preface</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><img src="theme/l_arr_disabled.gif" width="20" height="19" border="0"></td>
<td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>During the last time many new features were developed as additions to the <tt>Spirit</tt>
<a href="references.html#spirit">[4]</a> parser construction framework and we
felt more and more, that it would be very helpful, to have a 'real world' example,
which could be used as a sandbox for testing the usability of certain features.
Additionally&nbsp;a recent discussion on the Boost mailing list showed the widespread
interest of developers to have a modern, open source C++ preprocessor library
to play with.&nbsp; So we had the idea to implement a C++ preprocessor to fit
this needs&nbsp;-&nbsp;<tt>Wave</tt> was born.</p>
<p align="justify">The <tt>Wave</tt> C++ preprocessor library uses the <a href="http://www.boost.org/">
</a> <tt>Spirit<a href="references.html#spirit">[4]</a></tt> parser construction
library to implement a C++ lexer with ISO/ANSI Standards conformant preprocessing
capabilities. It exposes an iterator interface, which returns the current preprocessed
token from the input stream. This preprocessed token is generated on the fly
while iterating over the preprocessor iterator sequence (in the terminology
of the STL these iterators are forward iterators). </p>
<p align="justify"> The C++ preprocessor is a macro processor that under normal
circumstances is used automatically by your C++ compiler to transform your program
before actual compilation. It is called a macro processor because it allows
you to define macros, which are brief abbreviations for longer constructs. The
C++ preprocessor provides four separate facilities that you can use as you see
fit: </p>
<blockquote>
<p><b><img src="theme/bullet.gif" width="13" height="13" id="IMG1">&nbsp;</b>Inclusion
of header files<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1">&nbsp;</b>Macro
expansion<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1">&nbsp;</b>Conditional
compilation<br>
<b><img src="theme/bullet.gif" width="13" height="13" id="IMG1">&nbsp;</b>Line
control</p>
</blockquote>
<p>These features are greatly underestimated today, even more, the preprocessor
has been frowned on for so long that its usage just hasn't been effectively
pushed until the Boost preprocessor library <a href="references.html#pp_lib">[7]</a>
came into being a few years ago. Only today we begin to understand, that preprocessor
generative metaprogramming combined with template metaprogramming in C++ is
by far one of the most powerful compile-time reflection/metaprogramming facilities
that any language has ever supported.</p>
<p>The C++ Standard <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS%2FISO%2FIEC%2B14882%2D1998">[2] </a> was adopted back in 1998, but there is still no (known to me) C++ compiler, which has a bugfree implementation of the rather simple preprocessor requirements mandated therein. This may be a result of the mentioned underestimation or even banning of the preprocessor from good programming style during the last few years or may stem from the somewhat awkward standardese dialect of English used to describe it. </p>
<p align="justify">So the main goals for the <tt>Wave</tt> project are:</p>
<blockquote>
<p><b><img src="theme/bullet.gif" width="13" height="13" id="IMG1">&nbsp;</b>full
conformance with the C++ standard (ISO/IEC 14882:1998) <a href="references.html#iso_cpp">[1]</a>
and with the C99 standard (INCITS/ISO/IEC 9899:1999) <a href="references.html#iso_c">[2]</a><br>
<b><img src="theme/bullet.gif" width="13" height="13">&nbsp;</b>usage of <tt>Spirit<a href="references.html#spirit">[4]</a></tt>
for the parsing parts of the game (certainly :-)<br>
<b><img src="theme/bullet.gif" width="13" height="13">&nbsp;</b>maximal usage
of STL and/or <tt>Boost</tt> libraries (for compactness and maintainability)<br>
<b><img src="theme/bullet.gif" width="13" height="13">&nbsp;</b>straightforward
extendability for the implementation of additional features<br>
<b><img src="theme/bullet.gif" width="13" height="13">&nbsp;</b>building a
flexible library for different C++ lexing and preprocessing needs</p>
</blockquote>
<p>At the first steps it is not planned to make a very high performance or very
small C++ preprocessor. If you are looking for these objectives you probably
have to look at other places. Although our C++ preprocessor iterator works as expected and is usable as a reference implementation, for instance
for testing of other preprocessor oriented libraries as the Boost Preprocessor
library <a href="references.html#pp_lib">[7]</a> et.al. Nevertheless recent work has lead to surprising performance enhancements (if compared
with earlier versions). Wave is still somewhat slower as for instance EDG
based preprocessors (Intel, Comeau) on simple input files, however, as
complexity increases, time dilates expontentially on EDG. Preprocessing time
dilates linearly under Wave, which causes it to easily outperform EDG based
preprocessors when complexity increases.</p>
<p>As tests showed, the <tt>Wave</tt> library is very conformant to the C++ Standard,
such that it compiles several strict conformant macro definitions, which are
not even compilable with EDG based preprocessors (i.e. Comeau or Intel). The only preprocessor known to have similar Standards conformance
today is the preprocessor of the gcc C/C++ compiler.</p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><img src="theme/l_arr_disabled.gif" width="20" height="19" border="0"></td>
<td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,121 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Quick Start</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Quick
Start </font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>Preprocessing with Wave is highly configurable. You must
define a few options to control it. Here are a few of the
options you can define:</p>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P><STRONG><IMG id="IMG1" height="13" src="theme/bullet.gif" width="13"></STRONG>&nbsp;include
search paths, which define, where to search for files to be included with
<tt>#include&nbsp;&lt;...&gt;</tt> and <tt>#include&nbsp;"..."</tt> directives<br>
<STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>which
macros to predefine and which of the predefined macros to undefine<br>
<STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>whether to enable any of several extensions to the C++
Standard (such as for variadics and placemarkers)<br>
</P>
</BLOCKQUOTE>
<p>You can access all these processing parameters through the <tt>boost::wave::context</tt>
object. So you must instantiate one object of this type to use the <tt>Wave</tt>
library. (For more information about the context template class, please refer
to the class reference <a href="class_reference_context.html">here</a>.) To instantiate
the <tt>boost::wave::context</tt> object you have to supply at least two template parameters:
the iterator type of the underlying input stream to use and the type of the lexer iterator to be used as the token source for the preprocessing engine.</p>
<P dir="ltr">Do not instantiate the main preprocessing iterators yourself.
Get them from the wave::context object instead.<br>
The following code snippet is taken from the <tt>quick_start</tt> sample, which shows a minimal usage scenario for <tt>Wave</tt>. </P>
<pre><span class="comment"> // The following preprocesses a given input file.
// Open the file and read it into a string variable</span>
<span class="keyword">std::ifstream</span> instream(<span class="string">&quot;input.cpp&quot;</span>);
<span class="keyword">std::string </span>input<span class="keyword">(
std::istreambuf_iterator&lt;char&gt;</span>(instream.rdbuf()),
<span class="keyword">std::istreambuf_iterator&lt;char&gt;</span>());
<span class="comment">// The template boost::wave::cpplexer::lex_token&lt;&gt; is the
// token type to be used by the Wave library.
// This token type is one of the central types throughout
// the library, because it is a template parameter to some
// of the public classes and templates and it is returned
// from the iterators.
// The template boost::wave::cpplexer::lex_iterator&lt;&gt; is
// the lexer iterator to use as the token source for the
// preprocessing engine. In this case this is parametrized
// with the token type.</span>
<span class="keyword">typedef</span> <span class="identifier">boost::wave::cpplexer::lex_iterator</span><span class="special">&lt;</span>
<span class="identifier">boost::wave::cpplexer::lex_token</span><span class="special">&lt;&gt; &gt;</span>
<span class="identifier">lex_iterator_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">boost::wave::context</span><span class="special">&lt;</span>
std::string::iterator<span class="special">,</span> lex_iterator_type<span class="special">&gt;</span>
<span class="identifier">context_type</span><span class="special">;</span>
context_type ctx(input.begin(), input.end(), <span class="string">&quot;input.cpp&quot;</span>);
<span class="comment"> // At this point you may want to set the parameters of the
// preprocessing as include paths and/or predefined macros.
</span> ctx.add_include_path(<span class="literal">&quot;...&quot;</span>);
ctx.add_macro_definition(...);
<span class="comment"> // Get the preprocessor iterators and use them to generate
// the token sequence.
</span> context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
<span class="comment"> // The input stream is preprocessed for you during iteration<br> // over [first, last)<br></span> <span class="keyword">while</span> (first != last) {
<span class="keyword">std::cout</span> &lt;&lt; (*first).get_value();
++first;
}
</pre>
<P dir="ltr">The constructor of the <tt>boost::wave::context</tt> object can
take a pair of arbitrary iterator types (at least <tt>input_iterator</tt> type
iterators) to the input stream, which must supply the data to be processed.
The third parameter supplies a filename, filename, which is reported in the preprocessor output to
indicate the current context.
Note though, that this filename is used
only as long as no <tt>#include</tt> or <tt>#line</tt> directives are encountered,
which in turn will alter the current filename reported.</P>
<P dir="ltr">The iteration over the preprocessed tokens is relativley straightforward. Just get the starting and the ending iterators from the context object
(maybe after initializing some include search paths) and you are done! Dereferencing
the iterator will return the preprocessed tokens, which are generated on
the fly from the input stream. (To get further information about the token type,
you may want to look <a href="class_reference_tokentype.html">here</a>.)</P>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,101 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>References</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">References</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="acknowledgements.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><img src="theme/r_arr_disabled.gif" width="20" height="19" border="0"></td>
</tr>
</table>
<br>
<table width="90%" border="0" align="center">
<tr>
<td class="table_cells"> 1.</td>
<td class="table_cells"> <a name="iso_cpp"></a>ISO/IEC </td>
<td class="table_cells"><a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS%2FISO%2FIEC%2B14882%2D1998">&quot;Programming
languages - C++&quot;</a> <br>
ISO/IEC 14882:1998</td>
</tr>
<tr>
<td width="36" class="table_cells">2.</td>
<td width="236" class="table_cells"> <a name="iso_c"></a>INCITS/ISO/IEC </td>
<td width="520" class="table_cells"><a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS/ISO/IEC%2B9899-1999">&quot;Programming
languages - C&quot;</a> <br>
INCITS/ISO/IEC 9899:1999</td>
</tr>
<tr>
<td class="table_cells">3.</td>
<td class="table_cells"> <a name="re2c"></a>Peter Bumbulis and <br>
Donald D. Cowan</td>
<td class="table_cells"><a href="http://re2c.sourceforge.net/">Re2c
V0.9.8 </a><br>
A tool for generating C-based recognizers from regular expressions</td>
</tr>
<tr>
<td class="table_cells">4.</td>
<td class="table_cells"><a name="spirit"></a>Joel de Guzman et.al.</td>
<td class="table_cells"><a href="http://www.boost.org/">Spirit v1.8.2
documentation</a></td>
</tr>
<tr>
<td class="table_cells">5.</td>
<td class="table_cells"><a name="slex"></a>Daniel C. Nuffer</td>
<td class="table_cells"><a href="http://spirit.sourceforge.net/repository/applications/show_contents.php">The
<tt>Spirit</tt> Slex example</a></td>
</tr>
<tr>
<td class="table_cells">6.</td>
<td class="table_cells"><a name="cpplexer"></a>Juan Carlos Arevalo-Baeza</td>
<td class="table_cells"><a href="http://spirit.sourceforge.net/repository/applications/show_contents.php">The
<tt>Spirit</tt> cpplexer example</a></td>
</tr>
<tr>
<td class="table_cells">7.</td>
<td class="table_cells"><a name="pp_lib"></a>Vesa Karvonen and <br>
Paul Mensonides </td>
<td class="table_cells"><a href="http://www.boost.org/libs/preprocessor/doc/index.html">The
Boost Library Preprocessor Subset for C/C++</a> </td>
</tr>
<tr>
<td class="table_cells">8.</td>
<td class="table_cells"><a name="boost"></a>boost.org</td>
<td class="table_cells"><a href="http://www.boost.org">The Boost Libraries
Documentation.</a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="acknowledgements.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><img src="theme/r_arr_disabled.gif" width="20" height="19" border="0"></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Saturday, February 12, 2005 10:07<!-- #EndDate -->
</span></p>
</body>
</html>
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->

View File

@@ -1,96 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Samples</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="theme/style.css" type="text/css">
</head>
<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21">
<h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Samples</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="references.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p dir="ltr">The <tt>Wave</tt> library contains several samples illustrating how to use the different features. This section describes these samples and its main characteristics. </p>
<h2 dir="ltr">The quick_start sample</h2>
<p>The <tt>quick_start</tt> sample shows a minimal way to use the <tt>Wave</tt> preprocessor library. It simply opens the file given as the first command line argument, preprocesses it assuming that there aren't any additional include paths or macros defined and outputs the textual representation of the tokens generated from the given input file. This sample may be used to introduce yourself to <tt>Wave</tt>, because it does not contain all the potential additional complexity exposed by more complex samples. </p>
<h2>The lexed_tokens sample</h2>
<p>The <tt>lexed_tokens</tt> sample shows a minimal way to use the C++ lexing component of Wave without using the preprocessor. It opens the file specified as the first command line argument and prints out the contents of the tokens returned from the lexer. </p>
<h2>The <strong>cpp_tokens sample </strong></h2>
<p dir="ltr">The <tt>cpp_tokens</tt> sample dumps out the information contained within the tokens returned from the iterator supplied by the <tt>Wave</tt> library. It shows, how to use the <tt>Wave</tt> library in conjunction with custom lexer and custom token types. The lexer used within this sample is <tt>SLex</tt> <a href="references.html#slex">[5]</a> based, i.e. it <tt></tt> is feeded during runtime (at startup) with the token definitions (regular expressions) and generates a resulting DFA table. This table is used for token identification and is saved to disc afterwards to avoid the table generation process at the next program startup. The name of the file to which the DFA table is saved is <tt>wave_slex_lexer.dfa</tt>. </p>
<p dir="ltr">The main advantage of this <tt>SLex</tt> based lexer if compared to the default <tt>Re2C</tt> <a href="references.html#re2c">[3]</a> generated lexer is, that it provides not only the line information, where a particular token was recognized, but also the related column position. Otherwise the <tt>SLex</tt> based lexer is functionally fully compatible to the <tt>Re2C</tt> based one, i.e. you always may switch your application to use it, if you additionally need to get the column information back from the preprocessing. </p>
<p dir="ltr">Since no additional command line parameters are supported by this sample, it won't work well with include files, which aren't located in the same directory as the inspected input file. The command line syntax is straight forward:</p>
<pre> cpp_tokens input_file</pre>
<h2 dir="ltr">The list_includes sample </h2>
<p dir="ltr">The <tt>list_includes</tt> sample shows how the <tt>Wave</tt> library may be used to generate a include file dependency list for a particular input file. It completely depends on the default library configuration. The command line syntax for this sample is given below: </p>
<pre> Usage: list_includes [options] file ...:
-h [ --help ] : print out program usage (this message)
-v [ --version ] : print the version number
-I [ --path ] dir : specify additional include directory
-S [ --syspath ] dir : specify additional system include directory
</pre>
<p dir="ltr">Please note though, that this sample will output only those include file names, which are visible to the preprocessor, i.e. given the following code snippet, only one of the two include file directives is triggered during preprocessing and for this reason only the corresponding file name is reported by the <tt>list_includes</tt> sample:
<pre><span class="preprocessor"> #if</span> <span class="keyword">defined</span></span><span class="special">(</span>INCLUDE_FILE_A<span class="special">)</span>
<span class="preprocessor"> # include</span> <span class="literal">&quot;file_a.h&quot;</span>
<span class="preprocessor"> #else</span>
<span class="preprocessor"> # include</span> <span class="literal">&quot;file_b.h&quot;</span>
<span class="preprocessor"> #endif</span></pre>
<h2 dir="ltr">The wave sample</h2>
<p dir="ltr">Because of its general usefulness the <tt>wave</tt> sample is not located in the sample directory of the library, but inside the tools directory of Boost. The wave sample is usable as a full fledged preprocessor executable
on top of any other C++ compiler. It outputs the textual representation of the
preprocessed tokens generated from a given input file. It is described in more details <a href="wave_driver.html">here</a>. </p>
<h2 dir="ltr">The waveidl sample </h2>
<p dir="ltr">The main point of the <tt>waveidl</tt> sample is to show, how a completely independent lexer type may be used in conjunction with the default token type of the <tt>Wave</tt> library. The lexer used in this sample is supposed to be used for an IDL language based preprocessor. It is based on the <tt>Re2C</tt> tool too, but recognizes a different set of tokens as the default C++ lexer contained within the <tt>Wave</tt> library. So this lexer does not recognize any keywords (except <tt>true</tt> and <tt>false</tt>, which are needed by the preprocessor itself). This is needed because there exist different IDL languages, where identifiers of one language may be keywords of others. Certainly this implies to postpone keyword identification after the preprocessing, but allows to use <tt>Wave</tt> for all of the IDL derivatives. </p>
<p dir="ltr">It is only possible to use the <tt>Wave</tt> library to write an IDL preprocessor, because the token sets for both languages are very similar. The tokens to be recognized by the <tt>waveidl</tt> IDL language preprocessor is nearly a complete subset of the full C++ token set. </p>
<p dir="ltr">The command line syntax usable for this sample is shown below:</p>
<pre> Usage: waveidl [options] [@config-file(s)] file:
Options allowed on the command line only:
-h [ --help ] : print out program usage (this message)
-v [ --version ] : print the version number
-c [ --copyright ] : print out the copyright statement
--config-file filepath : specify a config file (alternatively: @filepath)
Options allowed additionally in a config file:
-o [ --output ] path : specify a file to use for output instead of stdout
-I [ --include ] path : specify an additional include directory
-S [ --sysinclude ] syspath : specify an additional system include directory
-D [ --define ] macro[=[value]] : specify a macro to define
-P [ --predefine ] macro[=[value]] : specify a macro to predefine
-U [ --undefine ] macro : specify a macro to undefine
</pre>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="references.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span>
</p>
<p>&nbsp;</p>
</body>
</html>

View File

@@ -1,128 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Supported Pragma Directives</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Supported
Pragma Directives</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="predefined_macros.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="macro_expansion_process.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>The Wave preprocessor library supports a couple of specific <tt>#pragma</tt>
directives, which may be used to control some of the library features. All directives
described here are usable as conventional <tt>#pragma</tt> directives and as
<tt>operator&nbsp;_Pragma</tt> (if variadics are enabled). So for instance the
following directives are functionally identical:</p>
<pre> #pragma wave trace(enable) </pre>
<p>and </p>
<pre> _Pragma(&quot;wave trace(enable)&quot;)</pre>
<p>All <tt>Wave</tt> specific pragma's must have the general form <tt>'wave option[(value)]'</tt>,
where <tt>'wave'</tt> is the specific keyword, <tt>'option'</tt> is the concrete
pragma functionality to trigger and <tt>'value'</tt> is an optional value to
be supplied to the <tt>'option'</tt> functionality. The following table lists
all possible pragma functions supported by the <tt>Wave</tt> library. For all recognised pragmas of this general form the interpret_pragma hook function from inside the context_policies are call, so that the user of the library is responsible for </p>
<table width="77%" border="0" align="center">
<tr>
<td colspan="4"> <p class="table_title">Supported pragma's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%">pragma option</p></td>
<td> <p class="toc_title" width="28%">pragma value</p></td>
<td> <p class="toc_title" width="36%">description</p></td>
<td> <p class="toc_title" width="36%">supported by</p></td>
</tr>
<tr>
<td class="table_cells" width="19%"> <p>trace</p></td>
<td class="table_cells" width="18%"> <p>enable/on/1<br>
disable/off/0</p></td>
<td class="table_cells" width="43%"><p>Enable or disable the tracing of the
macro expansion process. This is needed, even if there is given the --trace
command line option, because the trace output is generated only, if there
is at least one trace(enable) pragma found.</p></td>
<td class="table_cells" width="20%"><p>Wave driver</p></td>
</tr>
<tr>
<td class="table_cells"><p>stop</p></td>
<td class="table_cells"><p>message</p></td>
<td class="table_cells"><p>Stop the execution of <tt>Wave</tt> and print out
the given message. This is very helpful for direct debugging purposes.</p></td>
<td class="table_cells"><p>Wave driver</p></td>
</tr>
<tr>
<td class="table_cells"><p>system</p></td>
<td class="table_cells"><p>command</p></td>
<td class="table_cells"><p>Try to spawn the 'command' as a new operating system
command and intercept the generated stdout and stderr. The stdout output
of this command (if any) is retokenized and used as the replacement text
for the whole pragma, the stderr output is ignored. The command is considered
to be successful, if/when the return value is zero, otherwise an error
is reported. <br>
</p></td>
<td class="table_cells"><p>Wave driver</p></td>
</tr>
<tr>
<td class="table_cells"><p>timer</p></td>
<td class="table_cells"><p> restart/0<br>
&lt;no value&gt; <br>
suspend<br>
resume </p></td>
<td class="table_cells"><p>The value <tt>restart</tt> set the current elapsed
time to 0 and restarts the timer.<br>
If no value is provided, the current elpsed time is printed to the std::cerr
stream.<br>
The values <tt>suspend</tt> and <tt>resume</tt> allow to temporarily stop
the timing.</p></td>
<td class="table_cells"><p>Wave driver</p></td>
</tr>
</table>
<p>All pragma's not listed here but flagged as <tt>'wave'</tt> are reported as
errors. The handling of all remaining pragma's depends on the compilation constant
<code><tt>WAVE_RETURN_PRAGMA_DIRECTIVES</tt></code>, which allows to specify,
if those pragmas are left unchanged in the output stream or not. Please note,
that the operator _Pragma variant is always subject to full preprocessing, before
the pragma itself is evaluated. The #pragma variant is subject to preprocessing
only, if the <code><tt>WAVE_PREPROCESS_PRAGMA_BODY</tt></code> compilation constant
was specified during compilation. For more information about the possible compilation
constants look <a href="compiletime_config.html">here</a>.</p>
<p>Additionally the Wave preprocessor supports the <tt>#pragma once</tt> directive,
which specifies that the file, in which the pragma resides, will be included
(opened) only once by the compiler in a build. This may be used to optimize
the preprocessing of larger compilation units, which include a lot of files. Note though, that the #pragma once directive is supported only, if the compile time constant <tt>WAVE_SUPPORT_PRAGMA_ONCE</tt> was given during compilation of the library</span>.</p>
<p>It is fairly easy to implement your own <tt>#pragma wave ... </tt> directives. All you have to do is to implement your own <tt>interpret_pragma</tt> function (see <a href="class_reference_ctxpolicy.html#interpret_pragma">here</a>) which should the handle additional directives. For an example of how to do it, you may have a look at the Wave driver application, which implements the <tt>#pragma wave timer()</tt> directive with the help of a supplied <tt>interpret_pragma</tt> function. </p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="predefined_macros.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="macro_expansion_process.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span>
</p>
<p>&nbsp;</p>
</body>
</html>

BIN
doc/theme/bkd.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
doc/theme/bkd2.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
doc/theme/bullet.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

BIN
doc/theme/l_arr.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

BIN
doc/theme/r_arr.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

179
doc/theme/style.css vendored
View File

@@ -1,179 +0,0 @@
/* Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
body
{
background-image: url(bkd.gif);
background-color: #FFFFFF;
margin: 1em 2em 1em 2em;
}
h1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; }
h2 { font: 140% sans-serif; font-weight: bold; text-align: left; }
h3 { font: 120% sans-serif; font-weight: bold; text-align: left; }
h4 { font: bold 100% sans-serif; font-weight: bold; text-align: left; }
h5 { font: italic 100% sans-serif; font-weight: bold; text-align: left; }
h6 { font: small-caps 100% sans-serif; font-weight: bold; text-align: left; }
pre
{
border-top: gray 1pt solid;
border-right: gray 1pt solid;
border-left: gray 1pt solid;
border-bottom: gray 1pt solid;
padding-top: 2pt;
padding-right: 2pt;
padding-left: 2pt;
padding-bottom: 2pt;
display: block;
font-family: "courier new", courier, mono;
background-color: #eeeeee; font-size: small
}
code
{
font-family: "Courier New", Courier, mono;
font-size: small
}
tt
{
display: inline;
font-family: "Courier New", Courier, mono;
color: #000099;
font-size: small
}
p
{
text-align: justify;
font-family: Georgia, "Times New Roman", Times, serif
}
ul
{
list-style-image: url(bullet.gif);
font-family: Georgia, "Times New Roman", Times, serif
}
ol
{
font-family: Georgia, "Times New Roman", Times, serif
}
a
{
font-weight: bold;
color: #003366;
text-decoration: none;
}
a:hover { color: #8080FF; }
.literal { color: #666666; font-style: italic}
.keyword { color: #000099}
.identifier {}
.comment { font-style: italic; color: #990000}
.special { color: #800040}
.preprocessor { color: #990099}
.string { font-style: italic; color: #666666}
.copyright { color: #666666; font-size: small}
.white_bkd { background-color: #FFFFFF}
.dk_grey_bkd { background-color: #999999}
.quotes { color: #666666; font-style: italic; font-weight: bold}
.note_box
{
display: block;
border-top: gray 1pt solid;
border-right: gray 1pt solid;
border-left: gray 1pt solid;
border-bottom: gray 1pt solid;
padding-right: 12pt;
padding-left: 12pt;
padding-bottom: 12pt;
padding-top: 12pt;
font-family: Arial, Helvetica, sans-serif;
background-color: #E2E9EF;
font-size: small; text-align: justify
}
.table_title
{
background-color: #648CCA;
font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF;
font-weight: bold
; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px
}
.table_cells
{
background-color: #E2E9EF;
font-family: Geneva, Arial, Helvetica, san-serif;
font-size: small
; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px
}
.toc
{
DISPLAY: block;
background-color: #E2E9EF
font-family: Arial, Helvetica, sans-serif;
border-top: gray 1pt solid;
border-left: gray 1pt solid;
border-bottom: gray 1pt solid;
border-right: gray 1pt solid;
padding-top: 24pt;
padding-right: 24pt;
padding-left: 24pt;
padding-bottom: 24pt;
}
.toc_title
{
background-color: #648CCA;
padding-top: 4px;
padding-right: 4px;
padding-bottom: 4px;
padding-left: 4px;
font-family: Geneva, Arial, Helvetica, san-serif;
color: #FFFFFF;
font-weight: bold
}
.toc_cells
{
background-color: #E2E9EF;
padding-top: 4px;
padding-right: 4px;
padding-bottom: 4px;
padding-left: 4px;
font-family: Geneva, Arial, Helvetica, san-serif;
font-size: small
}
div.logo
{
float: right;
}
.toc_cells_L0 { background-color: #E2E9EF; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; font-family: Geneva, Arial, Helvetica, san-serif; font-size: small }
.toc_cells_L1 { background-color: #E2E9EF; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 44px; font-family: Geneva, Arial, Helvetica, san-serif; font-size: small }
.toc_cells_L2 { background-color: #E2E9EF; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 88px; font-family: Geneva, Arial, Helvetica, san-serif; font-size: small }
.toc_cells_L3 { background-color: #E2E9EF; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 122px; font-family: Geneva, Arial, Helvetica, san-serif; font-size: small }
.toc_cells_L4 { background-color: #E2E9EF; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 166px; font-family: Geneva, Arial, Helvetica, san-serif; font-size: small }
.updated {
font-size: x-small;
color: #666666;
font-style: italic;
}

BIN
doc/theme/u_arr.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

BIN
doc/theme/uc.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
doc/theme/wave.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,981 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Token Identifiers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Token Identifiers</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_tokentype.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_filepos.html"><img src="theme/r_arr.gif" width="20" height="19" border="0"></a></td>
</tr>
</table>
<blockquote>
<p><a href="token_ids.html#literal_tokens">Table of literal token identifiers</a><br>
<a href="token_ids.html#whitespace_tokens">Table of white token identifiers</a><br>
<a href="token_ids.html#keyword_tokens">Table of keyword token identifiers</a><br>
<a href="token_ids.html#operator_tokens">Table of operator token identifiers</a><br>
<a href="token_ids.html#preprocessor_tokens">Table of preprocessor token identifiers</a></p>
</blockquote>
<p>The following tables contain all those tokens, which should be recognized by
a C++ lexer, which is to be used in conjunction with the <tt>Wave</tt> preprocessing
engine. The tokens are grouped into categories to simplify some internal logic
and eventually the driver programs. The token identifiers are defined as an
<tt>enum</tt>, and it is recommended to reuse this definition for your own lexer
implementations.</p>
<p>Note though, that the preprocessor engine does some token transformation, so
that not all of the listet here token identifiers may occur inside tokens, returned
from the preprocessing iterator.</p>
<a name="literal_tokens"></a>
<table width="70%" border="0" align="center">
<tr>
<td colspan="3"> <p class="table_title">List of literal token id's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%" >Token identifier</p></td>
<td> <p class="toc_title" width="28%" >Token category</p></td>
<td> <p class="toc_title" width="36%" >Token value</p></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CHARLIT  </p></td>
<td class="table_cells" width="31%"> <p>CharacterLiteralTokenType</p></td>
<td class="table_cells" width="29%"><p><code>'a', '\t', '\u0057'</code></p></td>
</tr>
<tr>
<td class="table_cells" > <p>T_FLOATLIT </p></td>
<td class="table_cells" > <p>FloatingLiteralTokenType</p></td>
<td class="table_cells" ><code>-1.23456e78</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_IDENTIFIER </p></td>
<td class="table_cells" > <p>IdentifierTokenType</p></td>
<td class="table_cells" ><code> C++ identifier</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_OCTALINT </p></td>
<td class="table_cells" > <p>IntegerLiteralTokenType</p></td>
<td class="table_cells" ><code>007</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_DECIMALINT </p></td>
<td class="table_cells" > <p>IntegerLiteralTokenType</p></td>
<td class="table_cells" ><code>10</code></td>
</tr>
<tr>
<td class="table_cells" >
<p>T_HEXAINT </p></td>
<td class="table_cells" >
<p>IntegerLiteralTokenType</p></td>
<td class="table_cells" ><code>0x1234</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_INTLIT </p></td>
<td class="table_cells" > <p>IntegerLiteralTokenType</p></td>
<td class="table_cells" ><code>T_OCTALINT, T_DECIMALINT or T_HEXAINT</code></td>
</tr>
<tr>
<td class="table_cells" >
<p>T_LONGINTLIT</p></td>
<td class="table_cells" >
<p>IntegerLiteralTokenType</p></td>
<td class="table_cells" ><code>0x1234LL</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_STRINGLIT </p></td>
<td class="table_cells" > <p>StringLiteralTokenType</p></td>
<td class="table_cells" ><code>&quot;abc&quot;</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_FALSE </p></td>
<td class="table_cells" > <p>BoolLiteralTokenType</p></td>
<td class="table_cells" ><code>false</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TRUE </p></td>
<td class="table_cells" width="31%" > <p>BoolLiteralTokenType</p></td>
<td class="table_cells" width="29%" ><code>true</code></td>
</tr>
</table>
<br>
<a name="whitespace_tokens"></a>
<table width="70%" border="0" align="center">
<tr>
<td colspan="3"> <p class="table_title">List of whitespace token id's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%" >Token identifier</p></td>
<td> <p class="toc_title" width="28%" >Token category</p></td>
<td> <p class="toc_title" width="36%" >Token value</p></td>
</tr>
<tr>
<td class="table_cells" width="40%"> <p>T_ANY </p></td>
<td class="table_cells" width="31%"> <p>UnknownTokenType</p></td>
<td class="table_cells" width="29%"> <p><code>any value not matched otherwise</code></p></td>
</tr>
<tr>
<td class="table_cells" > <p>T_CCOMMENT </p></td>
<td class="table_cells" > <p>WhiteSpaceTokenType</p></td>
<td class="table_cells" > <p><code>/* ... */</code></p></td>
</tr>
<tr>
<td class="table_cells" > <p>T_CPPCOMMENT </p></td>
<td class="table_cells" > <p>WhiteSpaceTokenType</p></td>
<td class="table_cells" ><code>// ... \n</code></td>
</tr>
<tr>
<td class="table_cells" > <p>T_SPACE </p></td>
<td class="table_cells" > <p>WhiteSpaceTokenType</p></td>
<td class="table_cells" > <p>blank or '\t'</p></td>
</tr>
<tr>
<td class="table_cells" > <p>T_SPACE2 </p></td>
<td class="table_cells" > <p>WhiteSpaceTokenType</p></td>
<td class="table_cells" ><code>'\v' or '\f'</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_EOF </p></td>
<td class="table_cells" width="31%" > <p>EOFTokenType</p></td>
<td class="table_cells" width="29%" ><code>end of input</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CONTLINE </p></td>
<td class="table_cells" width="31%" > <p>EOLTokenType</p></td>
<td class="table_cells" width="29%" ><code>'\\' followed by '\n'</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NEWLINE </p></td>
<td class="table_cells" width="31%" > <p>EOLTokenType</p></td>
<td class="table_cells" width="29%" ><code>'\n'</code></td>
</tr>
</table>
<br>
<br>
<a name="keyword_tokens"></a>
<table width="70%" border="0" align="center">
<tr>
<td colspan="3"> <p class="table_title">List of keyword token id's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%" >Token identifier</p></td>
<td> <p class="toc_title" width="28%" >Token category</p></td>
<td> <p class="toc_title" width="36%" >Token value</p></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ASM </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>asm</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_AUTO </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>auto</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_BOOL </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>bool</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_BREAK </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>break</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CASE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>case</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CATCH </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>catch</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CHAR </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>char</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CLASS </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>class</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CONST </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>const</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CONSTCAST </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>const_cast</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_CONTINUE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>continue</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DEFAULT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>default</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DEFINED </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>defined</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DELETE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>delete</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DO </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>do</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DOUBLE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>double</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DYNAMICCAST </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>dynamic_cast</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ELSE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>else</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ENUM </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>enum</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_EXPLICIT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>explicit</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_EXPORT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>export</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_EXTERN </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>extern</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_FLOAT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>float</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_FOR </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>for</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_FRIEND </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>friend</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_GOTO </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>goto</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_IF </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>if</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_INLINE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>inline</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_INT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>int</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LONG </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>long</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_MUTABLE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>mutable</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NAMESPACE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>namespace</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NEW </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>new</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_OPERATOR </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>operator</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PRIVATE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>private</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PROTECTED </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>protected</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PUBLIC </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>public</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_REGISTER </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>register</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_REINTERPRETCAST </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>reinterpret_cast</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RETURN </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>return</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SHORT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>short</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SIGNED </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>signed</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SIZEOF </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>sizeof</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_STATIC </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>static</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_STATICCAST </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>static_cast</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_STRUCT </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>struct</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SWITCH </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>switch</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TEMPLATE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>template</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_THIS </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>this</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_THROW </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>throw</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TRY </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>try</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TYPEDEF </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>typedef</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TYPEID </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>typeid</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_TYPENAME </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>typename</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_UNION </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>union</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_UNSIGNED </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>unsigned</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_USING </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>using</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_VIRTUAL </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>virtual</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_VOID </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>void</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_VOLATILE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>volatile</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_WCHART </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>wchar_t</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_WHILE </p></td>
<td class="table_cells" width="31%" > <p>KeywordTokenType</p></td>
<td class="table_cells" width="29%" ><code>while</code></td>
</tr>
</table>
<br>
<a name="operator_tokens"></a>
<table width="70%" border="0" align="center">
<tr>
<td colspan="3"> <p class="table_title">List of operator token id's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%" >Token identifier</p></td>
<td> <p class="toc_title" width="28%" >Token category</p></td>
<td> <p class="toc_title" width="36%" >Token value</p></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_AND </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&amp;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ANDAND </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&amp;&amp;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ANDASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&amp;=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_OR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>|</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ORASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>|=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_XOR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>^</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_XORASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>^=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COMMA </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>,</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COLON </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>:</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DIVIDE </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>/</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DIVIDEASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>/=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DOT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>.</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_DOTSTAR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>.*</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ELLIPSIS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>...</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_EQUAL </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>==</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_GREATER </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_GREATEREQUAL </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&gt;=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACE </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>{</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LESS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LESSEQUAL </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTPAREN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>(</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACKET </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>[</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_MINUS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>-</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_MINUSASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>-=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_MINUSMINUS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>--</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PERCENT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>%</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PERCENTASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>%=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NOT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>!</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NOTEQUAL </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>!=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_OROR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>||</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PLUS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>+</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PLUSASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>+=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PLUSPLUS </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>++</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ARROW </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>-&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ARROWSTAR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>-&gt;*</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_QUESTION_MARK </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>?</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACE </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>}</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTPAREN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>)</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACKET </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>]</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COLON_COLON </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>::</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SEMICOLON </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SHIFTLEFT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;&lt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SHIFTLEFTASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;&lt;=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SHIFTRIGHT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&gt;&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_SHIFTRIGHTASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>&gt;&gt;=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_STAR </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>*</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COMPL </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>~</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_STARASSIGN </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>*=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND_POUND </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>##</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType</p></td>
<td class="table_cells" width="29%" ><code>#</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_AND_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>bitand</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ANDASSIGN_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>and_eq</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_OR_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>or</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_ORASSIGN_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>or_eq</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_XOR_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>xor</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_XORASSIGN_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>xor_eq</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACE_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;%</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACKET_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>&lt;:</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NOT_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>not</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_NOTEQUAL_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>not_eq</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACE_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>%&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACKET_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>:&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COMPL_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>compl</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND_POUND_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>%:%:</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND_ALT </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| AltTokenType</p></td>
<td class="table_cells" width="29%" ><code>%:</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_OR_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??!</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_XOR_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??'</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACE_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??&lt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_LEFTBRACKET_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??(</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACE_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_RIGHTBRACKET_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??)</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_COMPL_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??-</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND_POUND_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??=??=</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_POUND_TRIGRAPH </p></td>
<td class="table_cells" width="31%" > <p>OperatorTokenType&nbsp;| TriGraphTokenType</p></td>
<td class="table_cells" width="29%" ><code>??=</code></td>
</tr>
</table>
<p><br>
<a name="preprocessor_tokens"></a> The preprocessor tokens listet in the following
table are returned by the C++ lexer only. The preprocessor naturally acts on
these tokens and they are not returned by dereferencing the preprocessing iterators.</p>
<table width="70%" border="0" align="center">
<tr>
<td colspan="3"> <p class="table_title">List of preprocessor token id's</p></td>
</tr>
<tr>
<td> <p class="toc_title" width="36%" >Token identifier</p></td>
<td> <p class="toc_title" width="28%" >Token category</p></td>
<td> <p class="toc_title" width="36%" >Token value</p></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_DEFINE </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#define</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_IF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#if</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_IFDEF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#ifdef</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_IFNDEF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#ifndef</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_ELSE </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#else</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_ELIF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#elif</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_ENDIF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#endif</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_ERROR </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#error</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_LINE </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#line</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_PRAGMA </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#pragma</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_UNDEF </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#undef</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_WARNING </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#warning</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_INCLUDE </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#include &quot;...&quot;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_QHEADER </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#include &lt;...&gt;</code></td>
</tr>
<tr>
<td class="table_cells" width="40%" > <p>T_PP_HHEADER </p></td>
<td class="table_cells" width="31%" > <p>PPTokenType</p></td>
<td class="table_cells" width="29%" ><code>#include ...</code></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="class_reference_tokentype.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="class_reference_filepos.html"><img src="theme/r_arr.gif" width="20" height="19" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,163 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Tracing Facility</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Tracing Facility</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="acknowledgements.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>If you ever had the need to debug a macro expansion you had to discover, that
your tools provide only little or no support for this task. For this reason
the <i>Wave</i> library got a tracing facility, which allows to get selectively
some information about the expansion of a certain macro or several macros. </p>
<p>The tracing of macro expansions generates a possibly huge amount of information,
so it is recommended, that you explicitely enable/disable the tracing for the
macro in question only. This may be done with the help of a special, <tt>Wave</tt>
specific #pragma:</p>
<pre><span class="preprocessor"> #pragma</span> wave trace(enable) <span class="comment">// enable the tracing</span>
<span class="comment">// the macro expansions here will be traced</span>
<span class="comment">// ...</span>
<span class="preprocessor"> #pragma</span> wave trace(disable) <span class="comment">// disable the tracing</span></pre>
<p>In C99 mode or when specifying the <tt>--variadics</tt> command line option
you may additionally use the <tt>operator&nbsp;_Pragma()</tt> variant to enable/disable
the tracing output:</p>
<pre><span class="preprocessor"> #define</span> CONCAT(x, y) \
<span class="preprocessor">_Pragma</span>(<span class="string">&quot;wave trace(enable)&quot;</span>) \
x \
<span class="preprocessor">_Pragma</span>(<span class="string">&quot;wave trace(disable)&quot;</span>) \
<span class="keyword">##</span> y</pre>
<p>This way you have the possibility to enable the tracing during the expansion
of a part of a macro only. In the sample shown there is traced the expansion
of the macro argument <tt>'x'</tt> only. Note, that the <tt>operator _Pragma()</tt>
directives expand to nothing inside the macro expansion result.</p>
<p>To see, what the <tt>Wave</tt> driver generates while expanding a simple macro,
let's have a look at the tracing output for the following example:</p>
<pre ><span class="comment"> // test.cpp</span>
<span class="preprocessor"> #define</span> X(x) x<br><span class="preprocessor"> #define</span> Y() 2<br><span class="preprocessor"> #define</span> CONCAT_(x, y) x <span class="keyword">##</span> y
<span class="preprocessor"> #define</span> CONCAT(x, y) CONCAT_(x, y)
<span class="preprocessor"> #pragma</span> wave trace(enable)
<span class="comment"> // this macro expansion is to be traced</span>
CONCAT(X(1), Y()) <span class="comment">// should expand to 12</span>
<span class="preprocessor"> #pragma</span> wave trace(disable)</pre>
<p>When preprocessed with <tt>'wave -t test.trace test.cpp'</tt> the <tt>Wave</tt>
driver generates a file <tt>test.trace</tt>, which contains (without the line
numbers in front of the lines):</p>
<pre> 1: test.cpp(8): CONCAT(X(1), Y())
2: test.cpp(5): see macro definition: CONCAT(x, y)
3: invoked with
4: [
5: x = X(1)
6: y = Y()
7: ]
8: [
9: test.cpp(2): see macro definition: X(x)
10: invoked with
11: [
12: x = 1
13: ]
14: [
15: 1
16: rescanning
17: [
18: 1
19: ]
20: ]
21: test.cpp(3): see macro definition: Y()
22: [
23: 2
24: rescanning
25: [
26: 2
27: ]
28: ]
29: CONCAT_(1, 2)
30: rescanning
31: [
32: test.cpp(4): see macro definition: CONCAT_(x, y)
33: invoked with
34: [
35: x = 1
36: y = 2
37: ]
38: [
39: 12
40: rescanning
41: [
42: 12
43: ]
44: ]
45: 12
46: ]
47: ]
</pre>
<p>The generated trace output is very verbose, but allows to follow every step
of the actual macro expansion process. The first line in this tracing example
contains the reference to the position, from where the macro expansion was initiated.
Additionally the following information is contained for every single macro expansion:</p>
<ul>
<li>The reference to the position, where the macro to expand was defined first
(see lines 2, 9, 21 and 32).</li>
<li>The real parameters supplied for this macro expansion (see lines 3, 10 and
33), this information is traced inside the <tt>invoked with</tt> block, where
the corresponding formal and actual parameters are listed.</li>
<li>The expansion of the given arguments (if any and if these are defined as
macros). This repeats the full tracing information for the argument macro
expansion, only indended by one level. Note though, that the macro expansion
of the actual arguments is traced, regardless of the fact, whether this argument
is really to be inserted into the replacement list after its expansion
or as it was initially supplied (see C++ Standard [16.3.1.1]: &quot;A parameter
in the replacement list, unless preceded by a <tt>#</tt> or <tt>##</tt> preprocessing
token or followed by a <tt>##</tt> preprocessing token, is replaced by the
corresponding argument after all macros contained therein have been expanded&quot;
<a href="references.html#iso_cpp">[1]</a>). </li>
<li>The result of the argument substitution (see lines 15, 23, 29 and 39), i.e.
the substituted replacement list.</li>
<li>The rescanning process, which again includes the full subsequent macro expansion
process of all found macros (see C++ Standard [16.3.4.1]: &quot;After all
parameters in the replacement list have been substituted, the resulting preprocessing
token sequence is rescanned with all subsequent preprocessing tokens of the
source file for more macro names to replace.&quot; <a href="references.html#iso_cpp">[1]</a>).</li>
<li>The result of the actual macro expansion (this is the last line inside the
corresponding rescanning block - see lines 18, 26, 42 and 45).</li>
</ul>
<p>Every found macro to expand will add an additional indentation level inside
the trace output.</p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="wave_driver.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="acknowledgements.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 8, 2005 19:55<!-- #EndDate -->
</span>
</p>
</body>
</html>
<!-- #BeginDate format:fcAm1m -->Sunday, May 8, 2005 19:55<!-- #EndDate --><!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->

View File

@@ -1,237 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The Wave Driver</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The
Wave Driver</font></b></font></td>
<td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="samples.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="tracing_facility.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>There is implemented a driver program for the <tt>Wave</tt> library, which
utilizes nearly all capabilities of the library. It is usable as a preprocessor executable
on top of any other C++ compiler. It outputs the textual representation of the
preprocessed tokens generated from a given input file. This driver program has
the following command line syntax:</p>
<pre>Usage: wave [options] [@config-file(s)] file:
Options allowed on the command line only:
-h [--help]: print out program usage (this message)
-v [--version]: print the version number
-c [--copyright]: print out the copyright statement
--config-file filepath: specify a config file (alternatively: @filepath)
Options allowed additionally in a config file:
-o [--output] path: specify a file to use for output instead of stdout
-I [--include] path: specify an additional include directory
-S [--sysinclude] syspath: specify an additional system include directory
-F [--forceinclude] file: force inclusion of the given file
-D [--define] macro[=[value]]: specify a macro to define
-P [--predefine] macro[=[value]]: specify a macro to predefine
-U [--undefine] macro: specify a macro to undefine
-u [--undefineall]: undefine all macrodefinitions
-n [--nesting] depth: specify a new maximal include nesting depth
Extended options (allowed everywhere)
-t [--traceto] arg: output trace info to a file [arg] or to stderr [-]
--timer output overall elapsed computing time
--long_long: enable long long support if C++ mode
--variadics: enable variadics and placemarkers in C++ mode
--c99: enable C99 mode (implies variadics and placemarkers)
-l [ --listincludes ] arg: list included file to a file [arg] or to stdout [-]
-p [ --preserve ]: preserve comments
</pre>
<P dir="ltr">The possible options are straightforward and self explanatory. The
following describes some of these options in more detail. Please note, that
the extended options (--c99 and --variadics) are available only, if the driver
was compiled with the constant <tt>WAVE_SUPPORT_VARIADICS_PLACEMARKERS</tt>
defined. </P>
<P dir="ltr">-o [--output] path</P>
<blockquote>
<p dir="ltr">Specify a filename to be used for the generated preprocessed output
stream. If this option is not given, then the standard output is used (stdout).</p>
</blockquote>
<P dir="ltr">-I [--include] option</P>
<blockquote>
<p dir="ltr">Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system
header file, substituting your own version, since these directories are
searched before the system header file directories. However, you should
not use this option to add directories that contain vendor-supplied
system header files (use '-S' for that). If you use more than
one '-I' option, the directories are scanned in left-to-right order,
the standard system directories come after. </p>
<p>If a standard system include directory, or a directory specified with
'-S', is also specified with '-I', the '-I' option will be
ignored. The directory will still be searched but as a system
directory at its normal position in the system include chain. </p>
</blockquote>
<p dir="ltr">-I- [--include-] option</p>
<blockquote>
<p dir="ltr">The <tt>Wave</tt> library maintains two separate search paths
for include files. A search path for user include files and a search path
for system include files, where the user include paths are searched before the system include paths. </p>
<p dir="ltr">Any directories specified with '-I' options before
an eventually given '-I-' option are searched only for the case of '#include&nbsp;&quot;file&quot;'
(user include files), they are not searched for '#include&nbsp;&lt;file&gt;'
directives (system include files). If additional directories are specified
with '-I' options after a '-I-' option was given, these directories are searched
for all '#include' directives (ordinarily all '-I' directories are used this way.). </p>
<p dir="ltr">In addition, the '-I-' option inhibits the
use of the current directory (where the current input file came from) as the first search directory for '#include &quot;file&quot;'
directives . With '-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the
preprocessor does by default, but it is often satisfactory. </p>
</blockquote>
<p dir="ltr">-S [--sysinclude] option</p>
<blockquote>
<p dir="ltr">Add the given directory to the head of the list of directories
to be searched for system header files. If you use more than one '-S' option,
the directories are scanned in left-to-right order. This option is most useful
in the wave.cfg configuration file to specify, where the system include files
are to be searched.</p>
</blockquote>
<p dir="ltr">-F [--forceinclude] option</p>
<blockquote>
<p dir="ltr">Process the given file as normal input and include all the resulting
output before the processing the regular input file starts. If more than one
such option is given, the files are pre-included in the sequence of its occurance
on the command line.</p>
</blockquote>
<p dir="ltr">-D [--define] macro[=definition]<br>-P [--predefine] macro[=definition]</p>
<blockquote>
<p dir="ltr">This option allows to define ('-D') or predefine ('-P') a macro
from the command line. The string given in conjunction with the '-D' or '-P'
option should conform to the usual syntax MACRO(x)=definition as is described
in more detail <a href="class_reference_context.html#add_macro_definition">here</a>.</p>
<p dir="ltr"> The only difference between the '-D' and the '-P' options is,
that the latter predefines a macro such, that it is <b>not</b> undefinable
through an <tt>#undef</tt> directive from inside the preprocessed program.</p>
</blockquote>
<p dir="ltr">-U [--undefine] macro </p>
<blockquote>
<p dir="ltr">This allows to undefine some of the automatically predefined macros
of the <tt>Wave</tt> library (see <a href="predefined_macros.html">Predefined macros</a>). The only exception are
the <code class="keyword">__LINE__</code>, <code class="keyword">__FILE__</code>,
<code class="keyword">__DATE__</code>, <code class="keyword">__TIME__</code>,
<code class="keyword">__STDC__</code> and <code class="keyword">__cplusplus</code>
predefined macros, which are not undefinable. If -U and -D are both specified
for one name, the name is not predefined.</p>
</blockquote>
<p dir="ltr">-n [--nesting] depth</p>
<blockquote>
<p dir="ltr">Specify a new maximal include nesting depth. If the preprocessing
reaches this include file nesting depth, it aborts the preprocessing after
emitting an error message. The default include file nesting depth is 1024.</p>
</blockquote>
<p dir="ltr">-t [--traceto] path</p>
<blockquote>
<p dir="ltr">Enable the tracing facility build into the <tt>Wave</tt> library.
The path specifies the filename to use for the output of the generated trace
log. If the filename given equals to <tt>'-'</tt> (without the quotes), the
trace log is put into the standard error stream (stderr).</p>
</blockquote>
<p dir="ltr">--timer</p>
<blockquote>
<p dir="ltr">Enable to track the overall elapsed computing time required for
the given input file. The elapsed time is printed to stdout after the compilation
is completed.</p>
</blockquote>
<p dir="ltr">--variadics</p>
<blockquote>
<p dir="ltr">Enables support for variadics (macros with variable parameter lists),
placemarkers (empty macro arguments) and <tt>operator&nbsp;_Pragma</tt> in
normal C++ mode. This option predefines a special predefined macro <tt>__WAVE_HAS_VARIADICS__</tt>.</p>
</blockquote>
<p dir="ltr">--c99</p>
<blockquote>
<p dir="ltr">Enable the C99 mode. This mode enables certain C99 specific features
as variadics (macros with variable parameter lists), placemarkers (empty macro
arguments) and <tt>operator&nbsp;_Pragma</tt> support and disables some C++
specific token types as for instance <tt>'::'</tt>, <tt>'-&gt;*'</tt> and <tt>'-&gt;.'</tt>.
Several predefined macros are different for this mode, for more information
about predefined macros you may look <a href="predefined_macros.html">here</a>.
</p>
</blockquote>
<p dir="ltr">-l [--listincludes] path</p>
<blockquote>
<p dir="ltr">Enable the output of the names of all opened include files. The path specifies the filename to use for the output of the generated include log. If the filename given equals to <tt>'-'</tt> (without the quotes), the include log is put into the standard output stream (stdout).</p>
</blockquote>
<p dir="ltr">-p [--preserve] </p>
<blockquote>
<p dir="ltr">Preserve the comments from the input stream not located inside of macro definitions. The comments located inside macro definitions are skipped even if this option is specified. If this option is not specified on the command line all comments are skipped. </p>
</blockquote>
<p dir="ltr">@ [--config-file] option</p>
<blockquote>
<p dir="ltr">Some of the possible command line options may be specified inside
of special configuration files. This is very useful, as a shorthand for different
global configurations. A config file may contain additional options (-I, -S,
-F, -U, -D and -P options), one option per line. Empty lines and lines beginning
with a '#' character are ignored (are treated as a comment lines). Note that
the '#' character is treated as the beginning of a comment only, if it is
the first non-whitespace character on a line. Here is a small sample illustrating the supported configuration file syntax:</p>
<pre><span class="comment"> #
# enable variadics et.al. in C++ mode
#</span>
--variadics
<span class="comment"> #
# enable timer support
#
</span> --timer
<span class="comment"> #
# emulate gcc V3.3.2
#
</span> -D__GNUC__=3
-D__GNUC_MINOR__=3
-D__GNUC_PATCHLEVEL__=2
-D__GNUG__
<span class="comment"> #
# add Boost to the system include search paths
#</span>
-S/usr/local/boost</pre>
<p dir="ltr"> There is a shorthand for specifying a configuration file on the
command line: simply use the '@' character immediatly before the corresponding
file name.</p>
<p dir="ltr"> The options found in a configuration file are interpreted, as
if they were place instead of the configuration file option on the command
line.</p>
</blockquote>
<p dir="ltr">The <tt>Wave</tt> driver program looks at startup for a configuration
file named 'wave.cfg' in the same directory, where it was started from (where
is located the driver executable). If this file exists, it is treated as a normal
configuration file and the specified herein options are interpreted as if they
were given as the first options on the command line. This feature is very useful
for defining a global environment for the <tt>Wave</tt> preprocessor driver.</p>
<table border="0">
<tr>
<td width="10"></td>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
<td width="30"><a href="samples.html"><img src="theme/l_arr.gif" border="0"></a></td>
<td width="30"><a href="tracing_facility.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,106 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Wave V1.2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="doc/theme/style.css" rel="stylesheet" type="text/css">
</head>
<body text="#000000" background="doc/theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="doc/theme/bkd2.gif">
<tr>
<td width="21"> <h1></h1></td>
<td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Wave
V1.2.0</font></b></font></td>
<td width="96"><a href="http://spirit.sf.net"><img src="doc/theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
</tr>
</table>
<br>
<table width="75%" border="0" align="center">
<tr>
<td class="table_title">Table of Contents</td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/preface.html">Preface</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/introduction.html">Introduction</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/quickstart.html">Quick Start</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><b><font face="Geneva, Arial, Helvetica, san-serif">Class
References </font></b></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_context.html">The Context
Object</a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_inptpolcy.html">The Input
Policy </a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_ctxpolicy.html">The Context
Policy </a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_lexer.html">The Lexer Iterator Interface
</a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_tokentype.html">The Token
Type</a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/token_ids.html">The Token Identifiers </a></td>
</tr>
<tr>
<td class="toc_cells_L1"><a href="doc/class_reference_filepos.html">The File
Position</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><b><a href="doc/predefined_macros.html">Predefined Macros</a></b></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/supported_pragmas.html">Supported Pragma
Directives </a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/macro_expansion_process.html">The Macro
Expansion Process</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/compiletime_config.html">Compile Time Configuration</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/samples.html">Samples</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><b>The Wave Driver Executable</b></td>
</tr>
<tr>
<td class="toc_cells_L1"><b><a href="doc/wave_driver.html">The Wave Driver Command
Line </a></b></td>
</tr>
<tr>
<td class="toc_cells_L1"><b><a href="doc/tracing_facility.html">The Tracing Facility</a></b></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/acknowledgements.html">Acknowledgments</a></td>
</tr>
<tr>
<td class="toc_cells_L0"><a href="doc/references.html">References</a> </td>
</tr>
</table>
<br>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
<br>
<font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 8, 2005 17:26<!-- #EndDate -->
</span></p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
# Copyright Vladimir Prus 2004.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
project
: requirements <hardcode-dll-paths>true
;
build-project cpp_tokens/build ;
build-project list_includes/build ;
build-project quick_start/build ;
build-project waveidl/build ;

View File

@@ -1,30 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (cpp_tokens)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/samples/cpp_tokens/build ;
exe cpp_tokens
: ../cpp_tokens.cpp
../instantiate_cpp_exprgrammar.cpp
../instantiate_cpp_grammar.cpp
../instantiate_cpp_literalgrs.cpp
../instantiate_defined_grammar.cpp
../instantiate_slex_lexer.cpp
<lib>../../../build/boost_wave
<lib>../../../../../libs/program_options/build/boost_program_options
<lib>../../../../../libs/filesystem/build/boost_filesystem
:
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
:
<runtime-link>static
<threading>single
;

View File

@@ -1,23 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (cpp_tokens)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
exe cpp_tokens
: ../cpp_tokens.cpp
../instantiate_cpp_exprgrammar.cpp
../instantiate_cpp_grammar.cpp
../instantiate_cpp_literalgrs.cpp
../instantiate_defined_grammar.cpp
../instantiate_slex_lexer.cpp
../../../build//boost_wave
$(BOOST_ROOT)/boost/program_options//boost_program_options
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
;

View File

@@ -1,134 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Print out the preprocessed tokens returned by the Wave iterator
This sample shows, how it is possible to use a custom lexer type and a
custom token type with the Wave library.
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // global configuration
///////////////////////////////////////////////////////////////////////////////
// Include Wave itself
#include <boost/wave.hpp>
///////////////////////////////////////////////////////////////////////////////
// The following files contain the custom lexer type to use
#include "slex_token.hpp"
#include "slex_iterator.hpp"
///////////////////////////////////////////////////////////////////////////////
// include lexer specifics, import lexer names
#if !defined(BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION)
#include "slex/cpp_slex_lexer.hpp"
#endif // !defined(BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION)
///////////////////////////////////////////////////////////////////////////////
// import required names
using namespace boost::spirit;
using std::string;
using std::getline;
using std::ifstream;
using std::cout;
using std::cerr;
using std::endl;
using std::ostream;
///////////////////////////////////////////////////////////////////////////////
// main program
int
main(int argc, char *argv[])
{
if (2 != argc) {
cout << "Usage: cpp_tokens input_file" << endl;
return 1;
}
// read the file to analyse into a std::string
ifstream infile(argv[1]);
string teststr;
if (infile.is_open()) {
infile.unsetf(std::ios::skipws);
string line;
for (getline(infile, line); infile.good(); getline(infile, line)) {
teststr += line;
teststr += '\n';
}
}
else {
teststr = argv[1];
}
// The following typedef does the trick. It defines the context type to use,
// which depends on the lexer type (provided by the second template
// parameter). Our lexer type 'slex_iterator<>' depends on a custom token type
// 'slex_token<>'. Our custom token type differs from the original one provided
// by the Wave library only by defining an additional operator<<(), which is
// used to dump the token information carried by a given token (see loop
// below).
typedef boost::wave::cpplexer::slex_token<> token_type;
typedef boost::wave::cpplexer::slex::slex_iterator<token_type> lexer_type;
typedef boost::wave::context<std::string::iterator, lexer_type>
context_type;
// The C++ preprocessor iterator shouldn't be constructed directly. It is to be
// generated through a boost::wave::context<> object. This object is
// additionally to be used to initialize and define different parameters of
// the actual preprocessing.
// The preprocessing of the input stream is done on the fly behind the scenes
// during iteration over the context_type::iterator_type stream.
context_type ctx (teststr.begin(), teststr.end(), argv[1]);
ctx.set_language(boost::wave::enable_long_long(ctx.get_language()));
ctx.set_language(boost::wave::enable_preserve_comments(ctx.get_language()));
context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
context_type::token_type current_token;
try {
// Traverse over the tokens generated from the input and dump the token
// contents.
while (first != last) {
// retrieve next token
current_token = *first;
// output token info
cout << "matched " << current_token << endl;
++first;
}
}
catch (boost::wave::cpp_exception &e) {
// some preprocessing error
cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << endl;
return 2;
}
catch (std::exception &e) {
// use last recognized token to retrieve the error position
cerr
<< current_token.get_position().get_file()
<< "(" << current_token.get_position().get_line() << "): "
<< "unexpected exception: " << e.what()
<< endl;
return 3;
}
catch (...) {
// use last recognized token to retrieve the error position
cerr
<< current_token.get_position().get_file()
<< "(" << current_token.get_position().get_line() << "): "
<< "unexpected exception." << endl;
return 4;
}
return 0;
}

View File

@@ -1,38 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Print out the preprocessed tokens returned by the Wave iterator
This sample shows, how it is possible to use a custom lexer object and a
custom token type with the Wave library.
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(CPP_TOKENS_HPP_D6A31137_CE14_4869_9779_6357E2C43187_INCLUDED)
#define CPP_TOKENS_HPP_D6A31137_CE14_4869_9779_6357E2C43187_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// include often used files from the stdlib
#include <iostream>
#include <fstream>
#include <string>
///////////////////////////////////////////////////////////////////////////////
// include boost config
#include <boost/config.hpp> // global configuration information
///////////////////////////////////////////////////////////////////////////////
// configure this app here (global configuration constants)
#include "cpp_tokens_config.hpp"
///////////////////////////////////////////////////////////////////////////////
// include required boost libraries
#include <boost/assert.hpp>
#include <boost/pool/pool_alloc.hpp>
#endif // !defined(CPP_TOKENS_HPP_D6A31137_CE14_4869_9779_6357E2C43187_INCLUDED)

View File

@@ -1,55 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Print out the preprocessed tokens returned by the Wave iterator
Configuration data
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(CPP_TOKENS_HPP_7C0F1F14_6ACA_4439_A073_32C61C0DB6C5_INCLUDED)
#define CPP_TOKENS_HPP_7C0F1F14_6ACA_4439_A073_32C61C0DB6C5_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// Uncomment the following, if you need debug output, the
// BOOST_SPIRIT_DEBUG_FLAGS constants below help to fine control the amount of
// the generated debug output
//#define BOOST_SPIRIT_DEBUG
#if defined(BOOST_SPIRIT_DEBUG)
///////////////////////////////////////////////////////////////////////////////
// debug flags for the pp-iterator library, possible flags (defined in
// wave_config.hpp):
//
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_GRAMMAR 0x0001
// #define BOOST_SPIRIT_DEBUG_FLAGS_TIME_CONVERSION 0x0002
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_EXPR_GRAMMAR 0x0004
// #define BOOST_SPIRIT_DEBUG_FLAGS_INTLIT_GRAMMAR 0x0008
// #define BOOST_SPIRIT_DEBUG_FLAGS_CHLIT_GRAMMAR 0x0010
// #define BOOST_SPIRIT_DEBUG_FLAGS_DEFINED_GRAMMAR 0x0020
// #define BOOST_SPIRIT_DEBUG_FLAGS_PREDEF_MACROS_GRAMMAR 0x0040
#define BOOST_SPIRIT_DEBUG_FLAGS_CPP (\
/* insert the required flags from above */ \
) \
/**/
#endif
///////////////////////////////////////////////////////////////////////////////
// Include the configuration stuff for the Wave library itself
#include <boost/wave/wave_config.hpp>
///////////////////////////////////////////////////////////////////////////////
// MSVC specific #pragma's
#if defined(BOOST_MSVC)
#pragma warning (disable: 4355) // 'this' used in base member initializer list
#pragma warning (disable: 4800) // forcing value to bool 'true' or 'false'
#pragma inline_depth(255)
#pragma inline_recursion(on)
#endif // defined(BOOST_MSVC)
#endif // !defined(CPP_TOKENS_HPP_7C0F1F14_6ACA_4439_A073_32C61C0DB6C5_INCLUDED)

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: prints out the preprocessed tokens returned by the pp iterator
Explicit instantiation of the cpp_expression_grammar parsing
function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // config data
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include "slex_token.hpp"
#include "slex_iterator.hpp"
#include <boost/wave/grammars/cpp_expression_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the expression_grammar_gen template with the
// correct token type. This instantiates the corresponding parse function,
// which in turn instantiates the expression_grammar object (see
// wave/grammars/cpp_expression_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::slex_token<> token_type;
template struct boost::wave::grammars::expression_grammar_gen<token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: prints out the preprocessed tokens returned by the pp iterator
Explicit instantiation of the cpp_grammar parsing function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // config data
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include "slex_token.hpp"
#include "slex_iterator.hpp"
#include <boost/wave/grammars/cpp_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the cpp_grammar_gen template with the correct
// token type. This instantiates the corresponding pt_parse function, which
// in turn instantiates the cpp_grammar object
// (see wave/grammars/cpp_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::slex::slex_iterator<
boost::wave::cpplexer::slex_token<> >
lexer_type;
template struct boost::wave::grammars::cpp_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,43 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: prints out the preprocessed tokens returned by the pp iterator
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // config data
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include "slex_token.hpp"
#include "slex_iterator.hpp"
#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_intlit_grammar.hpp>
#include <boost/wave/grammars/cpp_chlit_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the intlit_grammar_gen, chlit_grammar_gen and
// floatlit_grammar_gen templates with the correct token type. This
// instantiates the corresponding parse function, which in turn instantiates
// the corresponding parser object.
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::slex_token<> token_type;
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,39 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // config data
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include "slex_token.hpp"
#include "slex_iterator.hpp"
#include <boost/wave/grammars/cpp_defined_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the defined_grammar_gen template
// with the correct token type. This instantiates the corresponding parse
// function, which in turn instantiates the defined_grammar
// object (see wave/grammars/cpp_defined_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::slex::slex_iterator<
boost::wave::cpplexer::slex_token<> >
lexer_type;
template struct boost::wave::grammars::defined_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,47 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Print out the preprocessed tokens returned by the Wave iterator
Explicit instantiation of the lex_functor generation function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "cpp_tokens.hpp" // config data
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include "slex_token.hpp"
#include "slex_iterator.hpp"
///////////////////////////////////////////////////////////////////////////////
// The following file needs to be included only once throughout the whole
// program.
#include "slex/cpp_slex_lexer.hpp"
///////////////////////////////////////////////////////////////////////////////
//
// This instantiates the correct 'new_lexer' function, which generates the
// C++ lexer used in this sample.
//
// This is moved into a separate compilation unit to decouple the compilation
// of the C++ lexer from the compilation of the other modules, which helps to
// reduce compilation time.
//
// The template parameter(s) supplied should be identical to the parameters
// supplied while instantiating the context<> template.
//
///////////////////////////////////////////////////////////////////////////////
template struct boost::wave::cpplexer::slex::new_lexer_gen<
std::string::iterator>;
#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0

View File

@@ -1,713 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
SLex (Spirit Lex) based C++ lexer
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(SLEX_LEXER_HPP_5E8E1DF0_BB41_4938_B7E5_A4BB68222FF6_INCLUDED)
#define SLEX_LEXER_HPP_5E8E1DF0_BB41_4938_B7E5_A4BB68222FF6_INCLUDED
#include <string>
#if defined(BOOST_SPIRIT_DEBUG)
#include <iostream>
#endif // defined(BOOST_SPIRIT_DEBUG)
#include <boost/assert.hpp>
#include <boost/spirit/core.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/util/time_conversion_helper.hpp>
#include <boost/wave/cpplexer/validate_universal_char.hpp>
#include <boost/wave/cpplexer/convert_trigraphs.hpp>
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
#include "../slex_interface.hpp"
#include "../slex_token.hpp"
#include "../slex_iterator.hpp"
#include "lexer.hpp" // "spirit/lexer.hpp"
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace slex {
namespace lexer {
///////////////////////////////////////////////////////////////////////////////
// The following numbers are the arraysizes of the token regex's which we
// need to specify to make the CW compiler happy (at least up to V9.5).
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
#define INIT_DATA_SIZE 176
#define INIT_DATA_CPP_SIZE 15
#else
#define INIT_DATA_SIZE 159
#define INIT_DATA_CPP_SIZE 15
#endif
///////////////////////////////////////////////////////////////////////////////
//
// encapsulation of the boost::spirit::slex based cpp lexer
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// The following lexer_base class was necessary to workaround a CodeWarrior
// bug (at least up to CW V9.5).
template <typename IteratorT, typename PositionT>
class lexer_base
: public boost::spirit::lexer<
boost::wave::util::position_iterator<IteratorT, PositionT> >
{
protected:
typedef boost::wave::util::position_iterator<IteratorT, PositionT>
iterator_type;
typedef typename std::iterator_traits<IteratorT>::value_type char_type;
typedef boost::spirit::lexer<iterator_type> base_type;
lexer_base();
// initialization data (regular expressions for the token definitions)
struct lexer_data {
token_id tokenid; // token data
char_type const *tokenregex; // associated token to match
typename base_type::callback_t tokencb; // associated callback function
unsigned int lexerstate; // valid for lexer state
};
};
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT>
class lexer
: public lexer_base<IteratorT, PositionT>
{
public:
typedef boost::wave::cpplexer::slex_token<PositionT> token_type;
void init_dfa(boost::wave::language_support language);
// get time of last compilation
static std::time_t get_compilation_time()
{ return compilation_time.get_time(); }
// helper for calculation of the time of last compilation
static boost::wave::util::time_conversion_helper compilation_time;
private:
typedef lexer_base<IteratorT, PositionT> base_type;
static typename base_type::lexer_data const init_data[INIT_DATA_SIZE]; // common patterns
static typename base_type::lexer_data const init_data_cpp[INIT_DATA_CPP_SIZE]; // C++ only patterns
};
///////////////////////////////////////////////////////////////////////////////
// data required for initialization of the lexer (token definitions)
#define OR "|"
#define Q(c) "\\" c
#define TRI(c) Q("?") Q("?") c
// definition of some subtoken regexps to simplify the regex definitions
#define BLANK "[ \\t]"
#define CCOMMENT \
Q("/") Q("*") "[^*]*" Q("*") "+" "(" "[^/*][^*]*" Q("*") "+" ")*" Q("/")
#define PPSPACE "(" BLANK OR CCOMMENT ")*"
#define OCTALDIGIT "[0-7]"
#define DIGIT "[0-9]"
#define HEXDIGIT "[0-9a-fA-F]"
#define SIGN "[-+]?"
#define EXPONENT "(" "[eE]" SIGN "[0-9]+" ")"
#define INTEGER \
"(" "(0x|0X)" HEXDIGIT "+" OR "0" OCTALDIGIT "*" OR "[1-9]" DIGIT "*" ")"
#define INTEGER_SUFFIX "(" "[uU][lL]?|[lL][uU]?" ")"
#define LONGINTEGER_SUFFIX "(" "[uU]" "(" "ll" OR "LL" ")" OR \
"(" "ll" OR "LL" ")" "[uU]" "?" ")"
#define FLOAT_SUFFIX "(" "[fF][lL]?|[lL][fF]?" ")"
#define CHAR_SPEC "L?"
#define BACKSLASH "(" Q("\\") OR TRI(Q("/")) ")"
#define ESCAPESEQ BACKSLASH "(" \
"[abfnrtv?'\"]" OR \
BACKSLASH OR \
"x" HEXDIGIT "+" OR \
OCTALDIGIT OCTALDIGIT "?" OCTALDIGIT "?" \
")"
#define HEXQUAD HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT
#define UNIVERSALCHAR BACKSLASH "(" \
"u" HEXQUAD OR \
"U" HEXQUAD HEXQUAD \
")"
#define POUNDDEF "(" "#" OR TRI("=") OR Q("%:") ")"
#define NEWLINEDEF "(" "\\n" OR "\\r" OR "\\r\\n" ")"
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
#define INCLUDEDEF "(include|include_next)"
#else
#define INCLUDEDEF "include"
#endif
///////////////////////////////////////////////////////////////////////////////
// sexer state constants
#define LEXER_STATE_NORMAL 0
#define LEXER_STATE_PP 1
#define NUM_LEXER_STATES 1
// helper for initializing token data
#define TOKEN_DATA(id, regex) \
{ T_##id, regex, 0, LEXER_STATE_NORMAL } \
/**/
#define TOKEN_DATA_EX(id, regex, callback) \
{ T_##id, regex, callback, LEXER_STATE_NORMAL } \
/**/
///////////////////////////////////////////////////////////////////////////////
// common C++/C99 token definitions
template <typename IteratorT, typename PositionT>
typename lexer_base<IteratorT, PositionT>::lexer_data const
lexer<IteratorT, PositionT>::init_data[INIT_DATA_SIZE] =
{
TOKEN_DATA(AND, "&"),
TOKEN_DATA(ANDAND, "&&"),
TOKEN_DATA(ASSIGN, "="),
TOKEN_DATA(ANDASSIGN, "&="),
TOKEN_DATA(OR, Q("|")),
TOKEN_DATA(OR_TRIGRAPH, TRI("!")),
TOKEN_DATA(ORASSIGN, Q("|=")),
TOKEN_DATA(ORASSIGN_TRIGRAPH, TRI("!=")),
TOKEN_DATA(XOR, Q("^")),
TOKEN_DATA(XOR_TRIGRAPH, TRI("'")),
TOKEN_DATA(XORASSIGN, Q("^=")),
TOKEN_DATA(XORASSIGN_TRIGRAPH, TRI("'=")),
TOKEN_DATA(COMMA, ","),
TOKEN_DATA(COLON, ":"),
TOKEN_DATA(DIVIDEASSIGN, Q("/=")),
TOKEN_DATA(DIVIDE, Q("/")),
TOKEN_DATA(DOT, Q(".")),
TOKEN_DATA(ELLIPSIS, Q(".") Q(".") Q(".")),
TOKEN_DATA(EQUAL, "=="),
TOKEN_DATA(GREATER, ">"),
TOKEN_DATA(GREATEREQUAL, ">="),
TOKEN_DATA(LEFTBRACE, Q("{")),
TOKEN_DATA(LEFTBRACE_ALT, "<" Q("%")),
TOKEN_DATA(LEFTBRACE_TRIGRAPH, TRI("<")),
TOKEN_DATA(LESS, "<"),
TOKEN_DATA(LESSEQUAL, "<="),
TOKEN_DATA(LEFTPAREN, Q("(")),
TOKEN_DATA(LEFTBRACKET, Q("[")),
TOKEN_DATA(LEFTBRACKET_ALT, "<:"),
TOKEN_DATA(LEFTBRACKET_TRIGRAPH, TRI(Q("("))),
TOKEN_DATA(MINUS, Q("-")),
TOKEN_DATA(MINUSASSIGN, Q("-=")),
TOKEN_DATA(MINUSMINUS, Q("-") Q("-")),
TOKEN_DATA(PERCENT, Q("%")),
TOKEN_DATA(PERCENTASSIGN, Q("%=")),
TOKEN_DATA(NOT, "!"),
TOKEN_DATA(NOTEQUAL, "!="),
TOKEN_DATA(OROR, Q("|") Q("|")),
TOKEN_DATA(OROR_TRIGRAPH, TRI("!") Q("|") OR Q("|") TRI("!") OR TRI("!") TRI("!")),
TOKEN_DATA(PLUS, Q("+")),
TOKEN_DATA(PLUSASSIGN, Q("+=")),
TOKEN_DATA(PLUSPLUS, Q("+") Q("+")),
TOKEN_DATA(ARROW, Q("->")),
TOKEN_DATA(QUESTION_MARK, Q("?")),
TOKEN_DATA(RIGHTBRACE, Q("}")),
TOKEN_DATA(RIGHTBRACE_ALT, Q("%>")),
TOKEN_DATA(RIGHTBRACE_TRIGRAPH, TRI(">")),
TOKEN_DATA(RIGHTPAREN, Q(")")),
TOKEN_DATA(RIGHTBRACKET, Q("]")),
TOKEN_DATA(RIGHTBRACKET_ALT, ":>"),
TOKEN_DATA(RIGHTBRACKET_TRIGRAPH, TRI(Q(")"))),
TOKEN_DATA(SEMICOLON, ";"),
TOKEN_DATA(SHIFTLEFT, "<<"),
TOKEN_DATA(SHIFTLEFTASSIGN, "<<="),
TOKEN_DATA(SHIFTRIGHT, ">>"),
TOKEN_DATA(SHIFTRIGHTASSIGN, ">>="),
TOKEN_DATA(STAR, Q("*")),
TOKEN_DATA(COMPL, Q("~")),
TOKEN_DATA(COMPL_TRIGRAPH, TRI("-")),
TOKEN_DATA(STARASSIGN, Q("*=")),
TOKEN_DATA(ASM, "asm"),
TOKEN_DATA(AUTO, "auto"),
TOKEN_DATA(BOOL, "bool"),
TOKEN_DATA(FALSE, "false"),
TOKEN_DATA(TRUE, "true"),
TOKEN_DATA(BREAK, "break"),
TOKEN_DATA(CASE, "case"),
TOKEN_DATA(CATCH, "catch"),
TOKEN_DATA(CHAR, "char"),
TOKEN_DATA(CLASS, "class"),
TOKEN_DATA(CONST, "const"),
TOKEN_DATA(CONSTCAST, "const_cast"),
TOKEN_DATA(CONTINUE, "continue"),
TOKEN_DATA(DEFAULT, "default"),
// TOKEN_DATA(DEFINED, "defined"),
TOKEN_DATA(DELETE, "delete"),
TOKEN_DATA(DO, "do"),
TOKEN_DATA(DOUBLE, "double"),
TOKEN_DATA(DYNAMICCAST, "dynamic_cast"),
TOKEN_DATA(ELSE, "else"),
TOKEN_DATA(ENUM, "enum"),
TOKEN_DATA(EXPLICIT, "explicit"),
TOKEN_DATA(EXPORT, "export"),
TOKEN_DATA(EXTERN, "extern"),
TOKEN_DATA(FLOAT, "float"),
TOKEN_DATA(FOR, "for"),
TOKEN_DATA(FRIEND, "friend"),
TOKEN_DATA(GOTO, "goto"),
TOKEN_DATA(IF, "if"),
TOKEN_DATA(INLINE, "inline"),
TOKEN_DATA(INT, "int"),
TOKEN_DATA(LONG, "long"),
TOKEN_DATA(MUTABLE, "mutable"),
TOKEN_DATA(NAMESPACE, "namespace"),
TOKEN_DATA(NEW, "new"),
TOKEN_DATA(OPERATOR, "operator"),
TOKEN_DATA(PRIVATE, "private"),
TOKEN_DATA(PROTECTED, "protected"),
TOKEN_DATA(PUBLIC, "public"),
TOKEN_DATA(REGISTER, "register"),
TOKEN_DATA(REINTERPRETCAST, "reinterpret_cast"),
TOKEN_DATA(RETURN, "return"),
TOKEN_DATA(SHORT, "short"),
TOKEN_DATA(SIGNED, "signed"),
TOKEN_DATA(SIZEOF, "sizeof"),
TOKEN_DATA(STATIC, "static"),
TOKEN_DATA(STATICCAST, "static_cast"),
TOKEN_DATA(STRUCT, "struct"),
TOKEN_DATA(SWITCH, "switch"),
TOKEN_DATA(TEMPLATE, "template"),
TOKEN_DATA(THIS, "this"),
TOKEN_DATA(THROW, "throw"),
TOKEN_DATA(TRY, "try"),
TOKEN_DATA(TYPEDEF, "typedef"),
TOKEN_DATA(TYPEID, "typeid"),
TOKEN_DATA(TYPENAME, "typename"),
TOKEN_DATA(UNION, "union"),
TOKEN_DATA(UNSIGNED, "unsigned"),
TOKEN_DATA(USING, "using"),
TOKEN_DATA(VIRTUAL, "virtual"),
TOKEN_DATA(VOID, "void"),
TOKEN_DATA(VOLATILE, "volatile"),
TOKEN_DATA(WCHART, "wchar_t"),
TOKEN_DATA(WHILE, "while"),
TOKEN_DATA(PP_DEFINE, POUNDDEF PPSPACE "define"),
TOKEN_DATA(PP_IF, POUNDDEF PPSPACE "if"),
TOKEN_DATA(PP_IFDEF, POUNDDEF PPSPACE "ifdef"),
TOKEN_DATA(PP_IFNDEF, POUNDDEF PPSPACE "ifndef"),
TOKEN_DATA(PP_ELSE, POUNDDEF PPSPACE "else"),
TOKEN_DATA(PP_ELIF, POUNDDEF PPSPACE "elif"),
TOKEN_DATA(PP_ENDIF, POUNDDEF PPSPACE "endif"),
TOKEN_DATA(PP_ERROR, POUNDDEF PPSPACE "error"),
TOKEN_DATA(PP_QHEADER, POUNDDEF PPSPACE \
INCLUDEDEF PPSPACE Q("\"") "[^\\n\\r\"]+" Q("\"")),
TOKEN_DATA(PP_HHEADER, POUNDDEF PPSPACE \
INCLUDEDEF PPSPACE "<" "[^\\n\\r>]+" ">"),
TOKEN_DATA(PP_INCLUDE, POUNDDEF PPSPACE \
INCLUDEDEF PPSPACE),
TOKEN_DATA(PP_LINE, POUNDDEF PPSPACE "line"),
TOKEN_DATA(PP_PRAGMA, POUNDDEF PPSPACE "pragma"),
TOKEN_DATA(PP_UNDEF, POUNDDEF PPSPACE "undef"),
TOKEN_DATA(PP_WARNING, POUNDDEF PPSPACE "warning"),
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
TOKEN_DATA(MSEXT_INT8, "__int8"),
TOKEN_DATA(MSEXT_INT16, "__int16"),
TOKEN_DATA(MSEXT_INT32, "__int32"),
TOKEN_DATA(MSEXT_INT64, "__int64"),
TOKEN_DATA(MSEXT_BASED, "_?" "_based"),
TOKEN_DATA(MSEXT_DECLSPEC, "_?" "_declspec"),
TOKEN_DATA(MSEXT_CDECL, "_?" "_cdecl"),
TOKEN_DATA(MSEXT_FASTCALL, "_?" "_fastcall"),
TOKEN_DATA(MSEXT_STDCALL, "_?" "_stdcall"),
TOKEN_DATA(MSEXT_TRY , "__try"),
TOKEN_DATA(MSEXT_EXCEPT, "__except"),
TOKEN_DATA(MSEXT_FINALLY, "__finally"),
TOKEN_DATA(MSEXT_LEAVE, "__leave"),
TOKEN_DATA(MSEXT_INLINE, "_?" "_inline"),
TOKEN_DATA(MSEXT_ASM, "_?" "_asm"),
TOKEN_DATA(MSEXT_PP_REGION, POUNDDEF PPSPACE "region"),
TOKEN_DATA(MSEXT_PP_ENDREGION, POUNDDEF PPSPACE "endregion"),
#endif // BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
TOKEN_DATA(IDENTIFIER, "([a-zA-Z_]" OR UNIVERSALCHAR ")([a-zA-Z0-9_]" OR UNIVERSALCHAR ")*"),
// TOKEN_DATA(OCTALINT, "0" OCTALDIGIT "*" INTEGER_SUFFIX "?"),
// TOKEN_DATA(DECIMALINT, "[1-9]" DIGIT "*" INTEGER_SUFFIX "?"),
// TOKEN_DATA(HEXAINT, "(0x|0X)" HEXDIGIT "+" INTEGER_SUFFIX "?"),
TOKEN_DATA(INTLIT, INTEGER INTEGER_SUFFIX "?"),
TOKEN_DATA(LONGINTLIT, INTEGER LONGINTEGER_SUFFIX),
TOKEN_DATA(FLOATLIT,
"(" DIGIT "*" Q(".") DIGIT "+" OR DIGIT "+" Q(".") ")"
EXPONENT "?" FLOAT_SUFFIX "?" OR
DIGIT "+" EXPONENT FLOAT_SUFFIX "?"),
TOKEN_DATA(CCOMMENT, CCOMMENT),
TOKEN_DATA(CPPCOMMENT, Q("/") Q("/[^\\n\\r]*") NEWLINEDEF ),
TOKEN_DATA(CHARLIT, CHAR_SPEC "'"
"(" ESCAPESEQ OR "[^\\n\\r']" OR UNIVERSALCHAR ")+" "'"),
TOKEN_DATA(STRINGLIT, CHAR_SPEC Q("\"")
"(" ESCAPESEQ OR "[^\\n\\r\"]" OR UNIVERSALCHAR ")*" Q("\"")),
TOKEN_DATA(SPACE, BLANK "+"),
TOKEN_DATA(SPACE2, "[\\v\\f]+"),
TOKEN_DATA(CONTLINE, Q("\\") "\\n"),
TOKEN_DATA(NEWLINE, NEWLINEDEF),
TOKEN_DATA(POUND_POUND, "##"),
TOKEN_DATA(POUND_POUND_ALT, Q("%:") Q("%:")),
TOKEN_DATA(POUND_POUND_TRIGRAPH, TRI("=") TRI("=")),
TOKEN_DATA(POUND, "#"),
TOKEN_DATA(POUND_ALT, Q("%:")),
TOKEN_DATA(POUND_TRIGRAPH, TRI("=")),
TOKEN_DATA(ANY, "."),
TOKEN_DATA(ANY_TRIGRAPH, TRI(Q("/"))),
{ token_id(0) } // this should be the last entry
};
///////////////////////////////////////////////////////////////////////////////
// C++ only token definitions
template <typename IteratorT, typename PositionT>
typename lexer_base<IteratorT, PositionT>::lexer_data const
lexer<IteratorT, PositionT>::init_data_cpp[INIT_DATA_CPP_SIZE] =
{
TOKEN_DATA(AND_ALT, "bitand"),
TOKEN_DATA(ANDASSIGN_ALT, "and_eq"),
TOKEN_DATA(ANDAND_ALT, "and"),
TOKEN_DATA(OR_ALT, "bitor"),
TOKEN_DATA(ORASSIGN_ALT, "or_eq"),
TOKEN_DATA(OROR_ALT, "or"),
TOKEN_DATA(XORASSIGN_ALT, "xor_eq"),
TOKEN_DATA(XOR_ALT, "xor"),
TOKEN_DATA(NOTEQUAL_ALT, "not_eq"),
TOKEN_DATA(NOT_ALT, "not"),
TOKEN_DATA(COMPL_ALT, "compl"),
TOKEN_DATA(ARROWSTAR, Q("->") Q("*")),
TOKEN_DATA(DOTSTAR, Q(".") Q("*")),
TOKEN_DATA(COLON_COLON, "::"),
{ token_id(0) } // this should be the last entry
};
///////////////////////////////////////////////////////////////////////////////
// undefine macros, required for regular expression definitions
#undef INCLUDEDEF
#undef POUNDDEF
#undef CCOMMENT
#undef PPSPACE
#undef DIGIT
#undef OCTALDIGIT
#undef HEXDIGIT
#undef SIGN
#undef EXPONENT
#undef LONGINTEGER_SUFFIX
#undef INTEGER_SUFFIX
#undef INTEGER
#undef FLOAT_SUFFIX
#undef CHAR_SPEC
#undef BACKSLASH
#undef ESCAPESEQ
#undef HEXQUAD
#undef UNIVERSALCHAR
#undef Q
#undef TRI
#undef OR
#undef TOKEN_DATA
#undef TOKEN_DATA_EX
///////////////////////////////////////////////////////////////////////////////
// initialize cpp lexer with token data
template <typename IteratorT, typename PositionT>
inline
lexer_base<IteratorT, PositionT>::lexer_base()
: base_type(NUM_LEXER_STATES)
{
}
template <typename IteratorT, typename PositionT>
inline void
lexer<IteratorT, PositionT>::init_dfa(boost::wave::language_support lang)
{
if (this->has_compiled_dfa())
return;
// if in C99 mode, some of the keywords are not valid
if (!boost::wave::need_c99(lang)) {
for (int j = 0; 0 != init_data_cpp[j].tokenid; ++j) {
this->register_regex(init_data_cpp[j].tokenregex,
init_data_cpp[j].tokenid, init_data_cpp[j].tokencb,
init_data_cpp[j].lexerstate);
}
}
for (int i = 0; 0 != init_data[i].tokenid; ++i) {
this->register_regex(init_data[i].tokenregex, init_data[i].tokenid,
init_data[i].tokencb, init_data[i].lexerstate);
}
}
///////////////////////////////////////////////////////////////////////////////
// get time of last compilation of this file
template <typename IteratorT, typename PositionT>
boost::wave::util::time_conversion_helper
lexer<IteratorT, PositionT>::compilation_time(__DATE__ " " __TIME__);
///////////////////////////////////////////////////////////////////////////////
} // namespace lexer
///////////////////////////////////////////////////////////////////////////////
//
template <typename IteratorT, typename PositionT>
inline void
init_lexer (lexer::lexer<IteratorT, PositionT> &lexer,
boost::wave::language_support language, bool force_reinit = false)
{
if (lexer.has_compiled_dfa())
return; // nothing to do
using std::ifstream;
using std::ofstream;
using std::ios;
using std::cerr;
using std::endl;
ifstream dfa_in("wave_slex_lexer.dfa", ios::in|ios::binary);
lexer.init_dfa(language);
if (force_reinit || !dfa_in.is_open() ||
!lexer.load (dfa_in, (long)lexer.get_compilation_time()))
{
#if defined(BOOST_SPIRIT_DEBUG)
cerr << "Compiling regular expressions for slex ...";
#endif // defined(BOOST_SPIRIT_DEBUG)
dfa_in.close();
lexer.create_dfa();
ofstream dfa_out ("wave_slex_lexer.dfa", ios::out|ios::binary|ios::trunc);
if (dfa_out.is_open())
lexer.save (dfa_out, (long)lexer.get_compilation_time());
#if defined(BOOST_SPIRIT_DEBUG)
cerr << " Done." << endl;
#endif // defined(BOOST_SPIRIT_DEBUG)
}
}
///////////////////////////////////////////////////////////////////////////////
//
// lex_functor
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT = wave::util::file_position_type>
class slex_functor
: public slex_input_interface<
typename lexer::lexer<IteratorT, PositionT>::token_type
>
{
public:
typedef boost::wave::util::position_iterator<IteratorT, PositionT>
iterator_type;
typedef typename std::iterator_traits<IteratorT>::value_type char_type;
typedef BOOST_WAVE_STRINGTYPE string_type;
typedef typename lexer::lexer<IteratorT, PositionT>::token_type token_type;
slex_functor(IteratorT const &first_, IteratorT const &last_,
PositionT const &pos_, boost::wave::language_support language)
: first(first_, last_, pos_), language(language), at_eof(false)
{
// initialize lexer dfa tables
init_lexer(lexer, language);
}
virtual ~slex_functor() {}
// get the next token from the input stream
token_type get()
{
token_type token;
if (!at_eof) {
do {
// generate and return the next token
std::string value;
PositionT pos = first.get_position(); // begin of token position
token_id id = token_id(lexer.next_token(first, last, &value));
if ((token_id)(-1) == id)
id = T_EOF; // end of input reached
string_type token_val(value.c_str());
if (T_CONTLINE != id) {
// The cast should avoid spurious warnings about missing case labels
// for the other token ids's.
switch ((unsigned int)id) {
case T_IDENTIFIER:
// test identifier characters for validity (throws if
// invalid chars found)
if (!(language & support_option_no_character_validation)) {
using boost::wave::cpplexer::impl::validate_identifier_name;
validate_identifier_name(token_val,
pos.get_line(), pos.get_column(), pos.get_file());
}
break;
case T_STRINGLIT:
case T_CHARLIT:
// test literal characters for validity (throws if invalid
// chars found)
if (language & support_option_convert_trigraphs) {
using boost::wave::cpplexer::impl::convert_trigraphs;
token_val = convert_trigraphs(token_val,
pos.get_line(), pos.get_column(), pos.get_file());
}
if (!(language & support_option_no_character_validation)) {
using boost::wave::cpplexer::impl::validate_literal;
validate_literal(token_val,
pos.get_line(), pos.get_column(), pos.get_file());
}
break;
case T_LONGINTLIT: // supported in C99 and long_long mode
if (!boost::wave::need_long_long(language)) {
// syntax error: not allowed in C++ mode
BOOST_WAVE_LEXER_THROW(
boost::wave::cpplexer::lexing_exception,
invalid_long_long_literal, value.c_str(),
pos.get_line(), pos.get_column(),
pos.get_file().c_str());
}
break;
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_HHEADER:
case T_PP_QHEADER:
case T_PP_INCLUDE:
// convert to the corresponding ..._next token, if appropriate
{
// Skip '#' and whitespace and see whether we find an
// 'include_next' here.
typename string_type::size_type start = value.find("include");
if (0 == value.compare(start, 12, "include_next", 12))
id = token_id(id | AltTokenType);
break;
}
#endif // BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_EOF:
// T_EOF is returned as a valid token, the next call will
// return T_EOI, i.e. the actual end of input
at_eof = true;
token_val.clear();
break;
case T_OR_TRIGRAPH:
case T_XOR_TRIGRAPH:
case T_LEFTBRACE_TRIGRAPH:
case T_RIGHTBRACE_TRIGRAPH:
case T_LEFTBRACKET_TRIGRAPH:
case T_RIGHTBRACKET_TRIGRAPH:
case T_COMPL_TRIGRAPH:
case T_POUND_TRIGRAPH:
case T_ANY_TRIGRAPH:
if (language & support_option_convert_trigraphs)
{
using boost::wave::cpplexer::impl::convert_trigraph;
token_val = convert_trigraph(
token_val, pos.get_line(), pos.get_column(),
pos.get_file());
}
break;
}
return token_type(id, token_val, pos);
}
// skip the T_CONTLINE token
} while (true);
}
return token; // return T_EOI
}
void set_position(PositionT const &pos)
{
// set position has to change the file name and line number only
first.get_position().set_file(pos.get_file());
first.get_position().set_line(pos.get_line());
}
private:
iterator_type first;
iterator_type last;
boost::wave::language_support language;
static lexer::lexer<IteratorT, PositionT> lexer; // needed only once
bool at_eof;
};
template <typename IteratorT, typename PositionT>
lexer::lexer<IteratorT, PositionT> slex_functor<IteratorT, PositionT>::lexer;
///////////////////////////////////////////////////////////////////////////////
//
// The 'new_lexer' function allows the opaque generation of a new lexer object.
// It is coupled to the iterator type to allow to decouple the lexer/iterator
// configurations at compile time.
//
// This function is declared inside the cpp_slex_token.hpp file, which is
// referenced by the source file calling the lexer and the source file, which
// instantiates the lex_functor. But is is defined here, so it will be
// instantiated only while compiling the source file, which instantiates the
// lex_functor. While the cpp_slex_token.hpp file may be included everywhere,
// this file (cpp_slex_lexer.hpp) should be included only once. This allows
// to decouple the lexer interface from the lexer implementation and reduces
// compilation time.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// The new_lexer_gen<>::new_lexer function (declared in cpp_slex_token.hpp)
// should be defined inline, if the lex_functor shouldn't be instantiated
// separately from the lex_iterator.
//
// Separate (explicit) instantiation helps to reduce compilation time.
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#define BOOST_WAVE_SLEX_NEW_LEXER_INLINE
#else
#define BOOST_WAVE_SLEX_NEW_LEXER_INLINE inline
#endif
template <typename IteratorT, typename PositionT>
BOOST_WAVE_SLEX_NEW_LEXER_INLINE
slex_input_interface<slex_token<PositionT> > *
new_lexer_gen<IteratorT, PositionT>::new_lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
boost::wave::language_support language)
{
return new slex_functor<IteratorT, PositionT>(first, last, pos,
language);
}
#undef BOOST_WAVE_SLEX_NEW_LEXER_INLINE
///////////////////////////////////////////////////////////////////////////////
} // namespace slex
} // namespace cpplexer
} // namespace wave
} // namespace boost
#endif // !defined(SLEX_LEXER_HPP_5E8E1DF0_BB41_4938_B7E5_A4BB68222FF6_INCLUDED)

File diff suppressed because it is too large Load Diff

View File

@@ -1,83 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the abstract lexer interface
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
#define SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace slex {
///////////////////////////////////////////////////////////////////////////////
//
// new_lexer_gen: generates a new instance of the required C++ lexer
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT> struct slex_input_interface;
template <
typename IteratorT,
typename PositionT = boost::wave::util::file_position_type
>
struct new_lexer_gen
{
// 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 slex_input_interface<slex_token<PositionT> > *
new_lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
};
///////////////////////////////////////////////////////////////////////////////
//
// The lex_input_interface decouples the lex_iterator_shim from the actual
// lexer. This is done to allow compile time reduction.
// Thanks to JCAB for having this idea.
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
struct slex_input_interface
{
typedef typename TokenT::position_type position_type;
virtual TokenT get() = 0;
virtual void set_position(position_type const &pos) = 0;
virtual ~slex_input_interface() {}
// 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 slex_input_interface *
new_lexer(IteratorT const &first, IteratorT const &last,
position_type const &pos, boost::wave::language_support language)
{
return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
pos, language);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace slex
} // namespace cpplexer
} // namespace wave
} // namespace boost
#endif // !defined(SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)

View File

@@ -1,172 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the lexer iterator
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(SLEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED)
#define SLEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED
#include <string>
#include <iostream>
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/spirit/iterator/multi_pass.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/util/functor_input.hpp>
#include "slex_interface.hpp"
#if 0 != __COMO_VERSION__
#define BOOST_WAVE_EOF_PREFIX static
#else
#define BOOST_WAVE_EOF_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace slex {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// lex_iterator_functor_shim
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class slex_iterator_functor_shim
{
public:
template <typename IteratorT>
slex_iterator_functor_shim(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: functor_ptr(slex_input_interface<TokenT>
::new_lexer(first, last, pos, language))
#if 0 != __DECCXX_VER
, eof()
#endif // 0 != __DECCXX_VER
{}
// interface to the boost::spirit::multi_pass_policies::functor_input policy
typedef TokenT result_type;
BOOST_WAVE_EOF_PREFIX result_type const eof;
result_type operator()()
{
BOOST_ASSERT(0 != functor_ptr.get());
return functor_ptr->get();
}
void set_position(typename TokenT::position_type const &pos)
{
BOOST_ASSERT(0 != functor_ptr.get());
functor_ptr->set_position(pos);
}
private:
boost::shared_ptr<slex_input_interface<TokenT> > functor_ptr;
};
#if 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
// eof token
template <typename TokenT>
typename slex_iterator_functor_shim<TokenT>::result_type const
slex_iterator_functor_shim<TokenT>::eof =
typename slex_iterator_functor_shim<TokenT>::result_type();
#endif // 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
//
// slex_iterator
//
// A generic C++ lexer interface class, which allows to plug in different
// lexer implementations (template parameter LexT). The following
// requirement apply:
//
// - the lexer type should have a function implemented, which returnes
// the next lexed token from the input stream:
// typename LexT::token_type get();
// - at the end of the input stream this function should return the
// eof token equivalent
// - the lexer should implement a constructor taking two iterators
// pointing to the beginning and the end of the input stream and
// a third parameter containing the name of the parsed input file,
// the 4th parameter contains the information about the mode the
// preprocessor is used in (C99/C++ mode etc.)
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class slex_iterator
: public boost::spirit::multi_pass<
impl::slex_iterator_functor_shim<TokenT>,
boost::wave::util::functor_input
>
{
typedef impl::slex_iterator_functor_shim<TokenT> input_policy_type;
typedef
boost::spirit::multi_pass<input_policy_type,
boost::wave::util::functor_input>
base_type;
public:
typedef TokenT token_type;
slex_iterator()
{}
template <typename IteratorT>
slex_iterator(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: base_type(input_policy_type(first, last, pos, language))
{}
void set_position(typename TokenT::position_type const &pos)
{
typedef typename token_type::position_type position_type;
// set the new position in the current token
token_type const& currtoken = base_type::get_input();
position_type currpos = currtoken.get_position();
currpos.set_file(pos.get_file());
currpos.set_line(pos.get_line());
base_type::get_input().set_position(currpos);
// set the new position for future tokens as well
if (token_type::string_type::npos !=
currtoken.get_value().find_first_of('\n'))
{
currpos.set_line(pos.get_line() + 1);
}
base_type::get_functor().set_position(currpos);
}
};
///////////////////////////////////////////////////////////////////////////////
} // slex
} // namespace cpplexer
} // namespace wave
} // namespace boost
#undef BOOST_WAVE_EOF_PREFIX
#endif // !defined(SLEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED)

View File

@@ -1,122 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
A generic C++ lexer token definition
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(SLEX_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED)
#define SLEX_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED
#include <iomanip>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
///////////////////////////////////////////////////////////////////////////////
// forward declaration of the token type
template <typename PositionT = boost::wave::util::file_position_type>
class slex_token;
///////////////////////////////////////////////////////////////////////////////
//
// lex_token
//
///////////////////////////////////////////////////////////////////////////////
template <typename PositionT>
class slex_token
{
public:
typedef BOOST_WAVE_STRINGTYPE string_type;
typedef PositionT position_type;
slex_token()
: id(T_EOI)
{}
slex_token(token_id id_, string_type const &value_, PositionT const &pos_)
: id(id_), value(value_), pos(pos_)
{}
// accessors
operator token_id() const { return id; }
string_type const &get_value() const { return value; }
position_type const &get_position() const { return pos; }
void set_token_id (token_id id_) { id = id_; }
void set_value (string_type const &newval) { value = newval; }
void set_position (position_type const &pos_) { pos = pos_; }
friend bool operator== (slex_token const& lhs, slex_token const& rhs)
{
// two tokens are considered equal even if they contain different
// positions
return (lhs.id == rhs.id && lhs.value == rhs.value) ? true : false;
}
// debug support
#if BOOST_WAVE_DUMP_PARSE_TREE != 0
// access functions for the tree_to_xml functionality
static int get_token_id(lex_token const &t)
{ return ID_FROM_TOKEN(token_id(t)); }
static string_type get_token_value(lex_token const &t)
{ return t.get_value(); }
#endif
// print support
void print (std::ostream &stream) const
{
using namespace std;
using namespace boost::wave;
stream << setw(16) << left << boost::wave::get_token_name(id) << " ("
<< "#" << token_id(ID_FROM_TOKEN(*this))
<< ") at " << get_position().get_file() << " ("
<< setw(3) << right << get_position().get_line() << "/"
<< setw(2) << right << get_position().get_column()
<< "): >";
for (std::size_t i = 0; i < value.size(); ++i) {
switch (value[i]) {
case '\r': stream << "\\r"; break;
case '\n': stream << "\\n"; break;
case '\t': stream << "\\t"; break;
default:
stream << value[i];
break;
}
}
stream << "<";
}
private:
boost::wave::token_id id; // the token id
string_type value; // the text, which was parsed into this token
PositionT pos; // the original file position
};
template <typename PositionT>
inline std::ostream &
operator<< (std::ostream &stream, slex_token<PositionT> const &object)
{
object.print(stream);
return stream;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace wave
} // namespace boost
#endif // !defined(SLEX_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED)

View File

@@ -1,24 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (lexed_tokens)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/samples/lexed_tokens/build ;
exe lexed_tokens
: ../lexed_tokens.cpp
<lib>../../../build/boost_wave
<lib>../../../../../libs/filesystem/build/boost_filesystem
:
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
:
<runtime-link>static
<threading>single
;

View File

@@ -1,17 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (lexed_tokens)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
exe lexed_tokens
: ../lexed_tokens.cpp
../../../build//boost_wave
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
;

View File

@@ -1,151 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
///////////////////////////////////////////////////////////////////////////////
// Include Wave itself
#include <boost/wave.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include the lexer stuff
#include <boost/wave/cpplexer/cpp_lex_token.hpp> // token class
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> // lexer class
///////////////////////////////////////////////////////////////////////////////
//
// Special output operator for a lex_token.
//
// Note: this doesn't compile if BOOST_SPIRIT_DEBUG is defined.
//
///////////////////////////////////////////////////////////////////////////////
template <typename PositionT>
inline std::ostream &
operator<< (std::ostream &stream,
boost::wave::cpplexer::lex_token<PositionT> const &t)
{
using namespace std;
using namespace boost::wave;
token_id id = token_id(t);
stream << setw(16)
<< left << boost::wave::get_token_name(id) << " ("
<< "#" << BASEID_FROM_TOKEN(id);
if (ExtTokenTypeMask & id) {
// this is an extended token id
if (AltTokenType == (id & ExtTokenOnlyMask)) {
stream << ", AltTokenType";
}
else if (TriGraphTokenType == (id & ExtTokenOnlyMask)) {
stream << ", TriGraphTokenType";
}
else if (AltExtTokenType == (id & ExtTokenOnlyMask)){
stream << ", AltExtTokenType";
}
}
stream
<< ") at " << t.get_position().get_file() << " ("
<< setw(3) << right << t.get_position().get_line() << "/"
<< setw(2) << right << t.get_position().get_column()
<< "): >";
typedef typename boost::wave::cpplexer::lex_token<PositionT>::string_type
string_type;
string_type const& value = t.get_value();
for (std::size_t i = 0; i < value.size(); ++i) {
switch (value[i]) {
case '\r': stream << "\\r"; break;
case '\n': stream << "\\n"; break;
case '\t': stream << "\\t"; break;
default:
stream << value[i];
break;
}
}
stream << "<";
return stream;
}
///////////////////////////////////////////////////////////////////////////////
// main entry point
int main(int argc, char *argv[])
{
if (2 != argc) {
std::cerr << "Usage: lexed_tokens infile" << std::endl;
return -1;
}
// current file position is saved for exception handling
boost::wave::util::file_position_type current_position;
try {
// Open and read in the specified input file.
std::ifstream instream(argv[1]);
std::string instr;
if (!instream.is_open()) {
std::cerr << "Could not open input file: " << argv[1] << std::endl;
return -2;
}
instream.unsetf(std::ios::skipws);
instr = std::string(std::istreambuf_iterator<char>(instream.rdbuf()),
std::istreambuf_iterator<char>());
// tokenize the input data into C++ tokens using the C++ lexer
typedef boost::wave::cpplexer::lex_token<> token_type;
typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type;
typedef token_type::position_type position_type;
position_type pos(argv[1]);
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
boost::wave::language_support(
boost::wave::support_cpp|boost::wave::support_long_long));
lexer_type end = lexer_type();
while (it != end) {
current_position = (*it).get_position(); // for error reporting
std::cout << *it << std::endl; // dump the tokenf info
++it;
}
}
catch (boost::wave::cpplexer::lexing_exception &e) {
// some lexing error
std::cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << std::endl;
return 2;
}
catch (std::exception &e) {
// use last recognized token to retrieve the error position
std::cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "exception caught: " << e.what()
<< std::endl;
return 3;
}
catch (...) {
// use last recognized token to retrieve the error position
std::cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "unexpected exception caught." << std::endl;
return 4;
}
return 0;
}

View File

@@ -1,25 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (list_includes)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/samples/list_includes/build ;
exe list_includes
: ../list_includes.cpp
<lib>../../../build/boost_wave
<lib>../../../../../libs/program_options/build/boost_program_options
<lib>../../../../../libs/filesystem/build/boost_filesystem
:
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
:
<runtime-link>static
<threading>single
;

View File

@@ -1,19 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (list_includes)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
exe list_includes
: ../list_includes.cpp
../../../build//boost_wave
$(BOOST_ROOT)/boost/program_options//boost_program_options
$(BOOST_ROOT)/boost/filesystem//boost_filesystem
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
;

View File

@@ -1,303 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: List include dependencies of a given source file
The 'list_includes' sample shows a simple way, how to use the Wave C++
preprocessor library to extract a list of included files from a given
source file.
To get a hint which commandline options are supported, call it with the
--help option.
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "list_includes.hpp" // config data
///////////////////////////////////////////////////////////////////////////////
// include required boost libraries
#include <boost/assert.hpp>
#include <boost/program_options.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include Wave itself
#include <boost/wave.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include the lexer stuff
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include the default context trace policies
#include <boost/wave/preprocessing_hooks.hpp>
///////////////////////////////////////////////////////////////////////////////
// include lexer specifics, import lexer names
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION == 0
#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp>
#endif
///////////////////////////////////////////////////////////////////////////////
// import required names
using namespace boost::spirit;
using std::string;
using std::vector;
using std::set;
using std::cout;
using std::cerr;
using std::endl;
using std::ifstream;
using std::ostream;
using std::istreambuf_iterator;
namespace po = boost::program_options;
///////////////////////////////////////////////////////////////////////////////
namespace cmd_line_util {
// predicate to extract all positional arguments from the command line
struct is_argument {
bool operator()(po::option const &opt)
{
return (opt.position_key == -1) ? true : false;
}
};
///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
// print the current version
int print_version()
{
// get time of last compilation of this file
boost::wave::util::time_conversion_helper compilation_time(__DATE__ " " __TIME__);
// calculate the number of days since Jan 29 2003
// (the day the list_includes project was started)
std::tm first_day;
std::memset (&first_day, 0, sizeof(std::tm));
first_day.tm_mon = 0; // Jan
first_day.tm_mday = 29; // 29
first_day.tm_year = 103; // 2003
long seconds = long(std::difftime(compilation_time.get_time(),
std::mktime(&first_day)));
cout
<< LIST_INCLUDES_VERSION_MAJOR << '.'
<< LIST_INCLUDES_VERSION_MINOR << '.'
<< LIST_INCLUDES_VERSION_SUBMINOR << '.'
<< seconds/(3600*24); // get number of days from seconds
return 1; // exit app
}
///////////////////////////////////////////////////////////////////////////////
// policy class
struct trace_include_files
: public boost::wave::context_policies::default_preprocessing_hooks
{
trace_include_files(set<string> &files_) : files(files_) {}
void
opened_include_file(string const &relname, string const &filename,
std::size_t include_depth, bool is_system_include)
{
set<string>::iterator it = files.find(filename);
if (it == files.end()) {
// print indented filename
for (std::size_t i = 0; i < include_depth; ++i)
cout << " ";
cout << filename << endl;
files.insert(filename);
}
}
set<string> &files;
};
///////////////////////////////////////////////////////////////////////////////
//
int
do_actual_work(vector<string> const &arguments, po::variables_map const &vm)
{
// current file position is saved for exception handling
boost::wave::util::file_position_type current_position;
try {
// list the included files for all arguments given
vector<string>::const_iterator lastfile = arguments.end();
for (vector<string>::const_iterator file_it = arguments.begin();
file_it != lastfile; ++file_it)
{
ifstream instream((*file_it).c_str());
string instring;
if (!instream.is_open()) {
cerr << "Could not open input file: " << *file_it << endl;
continue;
}
instream.unsetf(std::ios::skipws);
instring = string(istreambuf_iterator<char>(instream.rdbuf()),
istreambuf_iterator<char>());
// The template boost::wave::cpplexer::lex_token<> is the token type to be
// used by the Wave library.
typedef boost::wave::cpplexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lex_iterator_type;
typedef boost::wave::context<
std::string::iterator, lex_iterator_type,
boost::wave::iteration_context_policies::load_file_to_string,
trace_include_files
> context_type;
set<string> files;
trace_include_files trace(files);
// The preprocessor iterator shouldn't be constructed directly. It is
// to be generated through a wave::context<> object. This wave:context<>
// object is additionally to be used to initialize and define different
// parameters of the actual preprocessing.
// The preprocessing of the input stream is done on the fly behind the
// scenes during iteration over the context_type::iterator_type stream.
context_type ctx (instring.begin(), instring.end(), (*file_it).c_str(), trace);
// add include directories to the include path
if (vm.count("include")) {
vector<string> const &paths =
vm["include"].as<vector<string> >();
vector<string>::const_iterator end = paths.end();
for (vector<string>::const_iterator cit = paths.begin();
cit != end; ++cit)
{
ctx.add_include_path((*cit).c_str());
}
}
// add system include directories to the include path
if (vm.count("sysinclude")) {
vector<string> const &syspaths =
vm["sysinclude"].as<vector<string> >();
vector<string>::const_iterator end = syspaths.end();
for (vector<string>::const_iterator cit = syspaths.begin();
cit != end; ++cit)
{
ctx.add_sysinclude_path((*cit).c_str());
}
}
// analyze the actual file
context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
cout << "Printing dependency information for: "
<< *file_it << endl;
while (first != last) {
current_position = (*first).get_position();
++first;
}
// prepend endl before next file
cout << endl;
}
}
catch (boost::wave::cpp_exception &e) {
// some preprocessing error
cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << endl;
return 2;
}
catch (std::exception &e) {
// use last recognized token to retrieve the error position
cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "exception caught: " << e.what()
<< endl;
return 3;
}
catch (...) {
// use last recognized token to retrieve the error position
cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "unexpected exception caught." << endl;
return 4;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// here we go!
int
main (int argc, char *argv[])
{
try {
// analyze the command line options and arguments
vector<string> syspathes;
po::options_description desc("Usage: list_includes [options] file ...");
desc.add_options()
("help,h", "print out program usage (this message)")
("version,v", "print the version number")
("include,I", po::value<vector<string> >(),
"specify additional include directory")
("sysinclude,S", po::value<vector<string> >(),
"specify additional system include directory")
;
using namespace boost::program_options::command_line_style;
po::parsed_options opts = po::parse_command_line(argc, argv, desc, unix_style);
po::variables_map vm;
po::store(opts, vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << endl;
return 1;
}
if (vm.count("version")) {
return print_version();
}
// extract the arguments from the parsed command line
vector<po::option> arguments;
std::remove_copy_if(opts.options.begin(), opts.options.end(),
inserter(arguments, arguments.end()), cmd_line_util::is_argument());
// if there is no input file given, then exit
if (0 == arguments.size() || 0 == arguments[0].value.size()) {
cerr << "list_includes: No input file given. "
<< "Use --help to get a hint." << endl;
return 5;
}
// iterate over all given input files
return do_actual_work(arguments[0].value , vm);
}
catch (std::exception &e) {
cout << "list_includes: exception caught: " << e.what() << endl;
return 6;
}
catch (...) {
cerr << "list_includes: unexpected exception caught." << endl;
return 7;
}
}

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: List include dependencies of a given source file
Configuration data
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(LIST_INCLUDES_HPP_843DB412_3AA8_4BCF_8081_AA4A5FDE0BE7_INCLUDED)
#define LIST_INCLUDES_HPP_843DB412_3AA8_4BCF_8081_AA4A5FDE0BE7_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// include often used files from the stdlib
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
///////////////////////////////////////////////////////////////////////////////
// include boost config
#include <boost/config.hpp> // global configuration information
///////////////////////////////////////////////////////////////////////////////
// build version
#include "list_includes_version.hpp"
///////////////////////////////////////////////////////////////////////////////
// configure this app here (global configuration constants)
#include "list_includes_config.hpp"
///////////////////////////////////////////////////////////////////////////////
// include required boost libraries
#include <boost/assert.hpp>
#include <boost/pool/pool_alloc.hpp>
#endif // !defined(LIST_INCLUDES_HPP_843DB412_3AA8_4BCF_8081_AA4A5FDE0BE7_INCLUDED)

View File

@@ -1,64 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Global application configuration of the list_includes sample
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(LIST_INCLUDES_CONFIG_HPP_0DE80E47_8D50_4DFA_9C1C_0EECAA8A934A_INCLUDED)
#define LIST_INCLUDES_CONFIG_HPP_0DE80E47_8D50_4DFA_9C1C_0EECAA8A934A_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// Uncomment the following, if you need debug output, the
// BOOST_SPIRIT_DEBUG_FLAGS constants below help to fine control the amount of
// the generated debug output
//#define BOOST_SPIRIT_DEBUG
///////////////////////////////////////////////////////////////////////////////
// debug rules, subrules and grammars only, for possible flags see
// spirit/debug.hpp
#if defined(BOOST_SPIRIT_DEBUG)
#define BOOST_SPIRIT_DEBUG_FLAGS ( \
BOOST_SPIRIT_DEBUG_FLAGS_NODES | \
BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES \
) \
/**/
///////////////////////////////////////////////////////////////////////////////
// debug flags for the pp-iterator library, possible flags (defined in
// wave_config.hpp):
//
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_GRAMMAR 0x0001
// #define BOOST_SPIRIT_DEBUG_FLAGS_TIME_CONVERSION 0x0002
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_EXPR_GRAMMAR 0x0004
// #define BOOST_SPIRIT_DEBUG_FLAGS_INTLIT_GRAMMAR 0x0008
// #define BOOST_SPIRIT_DEBUG_FLAGS_CHLIT_GRAMMAR 0x0010
// #define BOOST_SPIRIT_DEBUG_FLAGS_DEFINED_GRAMMAR 0x0020
// #define BOOST_SPIRIT_DEBUG_FLAGS_PREDEF_MACROS_GRAMMAR 0x0040
#define BOOST_SPIRIT_DEBUG_FLAGS_CPP (\
/* insert the required flags from above */ \
) \
/**/
#endif
///////////////////////////////////////////////////////////////////////////////
// Now include the cofiguration stuff for the Wave library itself
#include <boost/wave/wave_config.hpp>
///////////////////////////////////////////////////////////////////////////////
// MSVC specific #pragma's
#if defined(BOOST_MSVC)
#pragma warning (disable: 4355) // 'this' used in base member initializer list
#pragma warning (disable: 4800) // forcing value to bool 'true' or 'false'
#pragma inline_depth(255)
#pragma inline_recursion(on)
#endif // defined(BOOST_MSVC)
#endif // !defined(LIST_INCLUDES_CONFIG_HPP_0DE80E47_8D50_4DFA_9C1C_0EECAA8A934A_INCLUDED)

View File

@@ -1,20 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: List include dependencies of a given source file version number
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED)
#define LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED
#define LIST_INCLUDES_VERSION_MAJOR 0
#define LIST_INCLUDES_VERSION_MINOR 3
#define LIST_INCLUDES_VERSION_SUBMINOR 0
#endif // !defined(LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED)

View File

@@ -1,24 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (quick_start)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/samples/quick_start/build ;
exe quick_start
: ../quick_start.cpp
<lib>../../../build/boost_wave
<lib>../../../../../libs/filesystem/build/boost_filesystem
:
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
:
<runtime-link>static
<threading>single
;

View File

@@ -1,17 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (quick_start)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
exe quick_start
: ../quick_start.cpp
../../../build//boost_wave
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
;

View File

@@ -1,108 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
///////////////////////////////////////////////////////////////////////////////
// Include Wave itself
#include <boost/wave.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include the lexer stuff
#include <boost/wave/cpplexer/cpp_lex_token.hpp> // token class
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> // lexer class
///////////////////////////////////////////////////////////////////////////////
// main entry point
int main(int argc, char *argv[])
{
if (2 != argc) {
std::cerr << "Usage: quick_start infile" << std::endl;
return -1;
}
// current file position is saved for exception handling
boost::wave::util::file_position_type current_position;
try {
// Open and read in the specified input file.
std::ifstream instream(argv[1]);
std::string instring;
if (!instream.is_open()) {
std::cerr << "Could not open input file: " << argv[1] << std::endl;
return -2;
}
instream.unsetf(std::ios::skipws);
instring = std::string(std::istreambuf_iterator<char>(instream.rdbuf()),
std::istreambuf_iterator<char>());
// The template boost::wave::cpplexer::lex_token<> is the token type to be
// used by the Wave library.
typedef boost::wave::cpplexer::lex_token<> token_type;
// The template boost::wave::cpplexer::lex_iterator<> is the lexer type to
// be used by the Wave library.
typedef boost::wave::cpplexer::lex_iterator<token_type> lex_iterator_type;
// This is the resulting context type to use. The first template parameter
// should match the iterator type to be used during construction of the
// corresponding context object (see below).
typedef boost::wave::context<std::string::iterator, lex_iterator_type>
context_type;
// The preprocessor iterator shouldn't be constructed directly. It is
// to be generated through a wave::context<> object. This wave:context<>
// object is to be used additionally to initialize and define different
// parameters of the actual preprocessing (not done here).
//
// The preprocessing of the input stream is done on the fly behind the
// scenes during iteration over the context_type::iterator_type stream.
context_type ctx (instring.begin(), instring.end(), argv[1]);
// analyze the input file
context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
while (first != last) {
current_position = (*first).get_position();
std::cout << (*first).get_value();
++first;
}
}
catch (boost::wave::cpp_exception &e) {
// some preprocessing error
std::cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << std::endl;
return 2;
}
catch (std::exception &e) {
// use last recognized token to retrieve the error position
std::cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "exception caught: " << e.what()
<< std::endl;
return 3;
}
catch (...) {
// use last recognized token to retrieve the error position
std::cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "unexpected exception caught." << std::endl;
return 4;
}
return 0;
}

View File

@@ -1,31 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (waveidl)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/samples/waveidl/build ;
exe waveidl
: ../idl.cpp
../instantiate_cpp_grammar.cpp
../instantiate_defined_grammar.cpp
../instantiate_predef_macros.cpp
../instantiate_re2c_lexer.cpp
../instantiate_re2c_lexer_string.cpp
../idllexer/idl_re.cpp
<lib>../../../build/boost_wave
<lib>../../../../../libs/program_options/build/boost_program_options
<lib>../../../../../libs/filesystem/build/boost_filesystem
:
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
:
<runtime-link>static
<threading>single
;

View File

@@ -1,24 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Sample Build Jamfile (waveidl)
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
exe waveidl
: ../idl.cpp
../instantiate_cpp_grammar.cpp
../instantiate_defined_grammar.cpp
../instantiate_predef_macros.cpp
../instantiate_re2c_lexer.cpp
../instantiate_re2c_lexer_string.cpp
../idllexer/idl_re.cpp
../../../build//boost_wave
$(BOOST_ROOT)/boost/program_options//boost_program_options
:
<toolset>msvc-7.1:<rtti>off # workaround for compiler bug
;

View File

@@ -1,537 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp" // global configuration
#include <boost/assert.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem/path.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include Wave itself
#include <boost/wave.hpp>
///////////////////////////////////////////////////////////////////////////////
// Include the lexer related stuff
#include <boost/wave/cpplexer/cpp_lex_token.hpp> // token type
#include "idllexer/idl_lex_iterator.hpp" // lexer type
///////////////////////////////////////////////////////////////////////////////
// include lexer specifics, import lexer names
//
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION == 0
#include "idllexer/idl_re2c_lexer.hpp"
#endif
///////////////////////////////////////////////////////////////////////////////
// include the grammar definitions, if these shouldn't be compiled separately
// (ATTENTION: _very_ large compilation times!)
//
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION == 0
#include <boost/wave/grammars/cpp_intlit_grammar.hpp>
#include <boost/wave/grammars/cpp_chlit_grammar.hpp>
#include <boost/wave/grammars/cpp_grammar.hpp>
#include <boost/wave/grammars/cpp_expression_grammar.hpp>
#include <boost/wave/grammars/cpp_predef_macros_grammar.hpp>
#include <boost/wave/grammars/cpp_defined_grammar.hpp>
#endif
///////////////////////////////////////////////////////////////////////////////
// import required names
using namespace boost::spirit;
using std::string;
using std::pair;
using std::vector;
using std::getline;
using std::ifstream;
using std::cout;
using std::cerr;
using std::endl;
using std::ostream;
using std::istreambuf_iterator;
namespace po = boost::program_options;
namespace fs = boost::filesystem;
///////////////////////////////////////////////////////////////////////////////
// print the current version
int print_version()
{
typedef boost::wave::idllexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lex_iterator_type;
typedef boost::wave::context<std::string::iterator, lex_iterator_type>
context_type;
string version (context_type::get_version_string());
cout
<< version.substr(1, version.size()-2) // strip quotes
<< " (" << IDL_VERSION_DATE << ")" // add date
<< endl;
return 0; // exit app
}
///////////////////////////////////////////////////////////////////////////////
// print the copyright statement
int print_copyright()
{
char const *copyright[] = {
"",
"Sample: IDL oriented preprocessor",
"Based on: Wave, A Standard conformant C++ preprocessor library",
"It is hosted by http://www.boost.org/.",
"",
"Copyright (c) 2001-2005 Hartmut Kaiser, Distributed under the Boost",
"Software License, Version 1.0. (See accompanying file",
"LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)",
0
};
for (int i = 0; 0 != copyright[i]; ++i)
cout << copyright[i] << endl;
return 0; // exit app
}
///////////////////////////////////////////////////////////////////////////////
namespace cmd_line_util {
// Additional command line parser which interprets '@something' as an
// option "config-file" with the value "something".
pair<string, string> at_option_parser(string const&s)
{
if ('@' == s[0])
return std::make_pair(string("config-file"), s.substr(1));
else
return pair<string, string>();
}
// class, which keeps include file information read from the command line
class include_paths {
public:
include_paths() : seen_separator(false) {}
vector<string> paths; // stores user paths
vector<string> syspaths; // stores system paths
bool seen_separator; // command line contains a '-I-' option
// Function which validates additional tokens from command line.
static void
validate(boost::any &v, vector<string> const &tokens)
{
if (v.empty())
v = boost::any(include_paths());
include_paths *p = boost::any_cast<include_paths>(&v);
BOOST_ASSERT(p);
// Assume only one path per '-I' occurrence.
string t = tokens[0];
if (t == "-") {
// found -I- option, so switch behaviour
p->seen_separator = true;
}
else if (p->seen_separator) {
// store this path as a system path
p->syspaths.push_back(t);
}
else {
// store this path as an user path
p->paths.push_back(t);
}
}
};
// Read all options from a given config file, parse and add them to the
// given variables_map
void read_config_file_options(string const &filename,
po::options_description const &desc, po::variables_map &vm,
bool may_fail = false)
{
ifstream ifs(filename.c_str());
if (!ifs.is_open()) {
if (!may_fail) {
cerr << filename
<< ": command line warning: config file not found"
<< endl;
}
return;
}
vector<string> options;
string line;
while (std::getline(ifs, line)) {
// skip empty lines
string::size_type pos = line.find_first_not_of(" \t");
if (pos == string::npos)
continue;
// skip comment lines
if ('#' != line[pos])
options.push_back(line);
}
if (options.size() > 0) {
using namespace boost::program_options::command_line_style;
po::store(po::command_line_parser(options)
.options(desc).style(unix_style).run(), vm);
po::notify(vm);
}
}
// predicate to extract all positional arguments from the command line
struct is_argument {
bool operator()(po::option const &opt)
{
return (opt.position_key == -1) ? true : false;
}
};
///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
//
// Special validator overload, which allows to handle the -I- syntax for
// switching the semantics of an -I option.
//
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace program_options {
void validate(boost::any &v, std::vector<std::string> const &s,
cmd_line_util::include_paths *, int)
{
cmd_line_util::include_paths::validate(v, s);
}
}} // namespace boost::program_options
///////////////////////////////////////////////////////////////////////////////
// do the actual preprocessing
int
do_actual_work (std::string file_name, po::variables_map const &vm)
{
// current file position is saved for exception handling
boost::wave::util::file_position_type current_position;
try {
// process the given file
ifstream instream(file_name.c_str());
string instring;
if (!instream.is_open()) {
cerr << "waveidl: could not open input file: " << file_name << endl;
return -1;
}
instream.unsetf(std::ios::skipws);
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
// this is known to be very slow for large files on some systems
copy (istream_iterator<char>(instream),
istream_iterator<char>(),
inserter(instring, instring.end()));
#else
instring = string(istreambuf_iterator<char>(instream.rdbuf()),
istreambuf_iterator<char>());
#endif
// This sample uses the lex_token type predefined in the Wave library, but
// but uses a custom lexer type.
typedef boost::wave::idllexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lex_iterator_type;
typedef boost::wave::context<std::string::iterator, lex_iterator_type>
context_type;
// The C++ preprocessor iterators shouldn't be constructed directly. They
// are to be generated through a boost::wave::context<> object. This
// boost::wave::context object is additionally to be used to initialize and
// define different parameters of the actual preprocessing.
// The preprocessing of the input stream is done on the fly behind the
// scenes during iteration over the context_type::iterator_type stream.
context_type ctx (instring.begin(), instring.end(), file_name.c_str());
// add include directories to the system include search paths
if (vm.count("sysinclude")) {
vector<string> const &syspaths =
vm["sysinclude"].as<vector<string> >();
vector<string>::const_iterator end = syspaths.end();
for (vector<string>::const_iterator cit = syspaths.begin();
cit != end; ++cit)
{
ctx.add_sysinclude_path((*cit).c_str());
}
}
// add include directories to the include search paths
if (vm.count("include")) {
cmd_line_util::include_paths const &ip =
vm["include"].as<cmd_line_util::include_paths>();
vector<string>::const_iterator end = ip.paths.end();
for (vector<string>::const_iterator cit = ip.paths.begin();
cit != end; ++cit)
{
ctx.add_include_path((*cit).c_str());
}
// if on the command line was given -I- , this has to be propagated
if (ip.seen_separator)
ctx.set_sysinclude_delimiter();
// add system include directories to the include path
vector<string>::const_iterator sysend = ip.syspaths.end();
for (vector<string>::const_iterator syscit = ip.syspaths.begin();
syscit != sysend; ++syscit)
{
ctx.add_sysinclude_path((*syscit).c_str());
}
}
// add additional defined macros
if (vm.count("define")) {
vector<string> const &macros = vm["define"].as<vector<string> >();
vector<string>::const_iterator end = macros.end();
for (vector<string>::const_iterator cit = macros.begin();
cit != end; ++cit)
{
ctx.add_macro_definition(*cit);
}
}
// add additional predefined macros
if (vm.count("predefine")) {
vector<string> const &predefmacros =
vm["predefine"].as<vector<string> >();
vector<string>::const_iterator end = predefmacros.end();
for (vector<string>::const_iterator cit = predefmacros.begin();
cit != end; ++cit)
{
ctx.add_macro_definition(*cit, true);
}
}
// undefine specified macros
if (vm.count("undefine")) {
vector<string> const &undefmacros =
vm["undefine"].as<vector<string> >();
vector<string>::const_iterator end = undefmacros.end();
for (vector<string>::const_iterator cit = undefmacros.begin();
cit != end; ++cit)
{
ctx.remove_macro_definition((*cit).c_str(), true);
}
}
// open the output file
std::ofstream output;
if (vm.count("output")) {
// try to open the file, where to put the preprocessed output
string out_file (vm["output"].as<string>());
output.open(out_file.c_str());
if (!output.is_open()) {
cerr << "waveidl: could not open output file: " << out_file
<< endl;
return -1;
}
}
else {
// output the preprocessed result to std::cout
output.copyfmt(cout);
output.clear(cout.rdstate());
static_cast<std::basic_ios<char> &>(output).rdbuf(cout.rdbuf());
}
// analyze the input file
context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
// loop over all generated tokens outputing the generated text
while (first != last) {
// print out the string representation of this token (skip comments)
using namespace boost::wave;
// store the last known good token position
current_position = (*first).get_position();
token_id id = token_id(*first);
if (T_CPPCOMMENT == id || T_NEWLINE == id) {
// C++ comment tokens contain the trailing newline
output << endl;
}
else if (id != T_CCOMMENT) {
// print out the current token value
output << (*first).get_value();
}
++first; // advance to the next token
}
}
catch (boost::wave::cpp_exception &e) {
// some preprocessing error
cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << endl;
return 1;
}
catch (boost::wave::cpplexer::lexing_exception &e) {
// some lexing error
cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << endl;
return 2;
}
catch (std::exception &e) {
// use last recognized token to retrieve the error position
cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "exception caught: " << e.what()
<< endl;
return 3;
}
catch (...) {
// use last recognized token to retrieve the error position
cerr
<< current_position.get_file()
<< "(" << current_position.get_line() << "): "
<< "unexpected exception caught." << endl;
return 4;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// main entry point
int
main (int argc, char *argv[])
{
try {
// analyze the command line options and arguments
// declare the options allowed from the command line only
po::options_description desc_cmdline ("Options allowed on the command line only");
desc_cmdline.add_options()
("help,h", "print out program usage (this message)")
("version,v", "print the version number")
("copyright,c", "print out the copyright statement")
("config-file", po::value<vector<string> >(),
"specify a config file (alternatively: @filepath)")
;
// declare the options allowed on command line and in config files
po::options_description desc_generic ("Options allowed additionally in a config file");
desc_generic.add_options()
("output,o", "specify a file to use for output instead of stdout")
("include,I", po::value<cmd_line_util::include_paths>()->composing(),
"specify an additional include directory")
("sysinclude,S", po::value<vector<string> >()->composing(),
"specify an additional system include directory")
("define,D", po::value<vector<string> >()->composing(),
"specify a macro to define (as macro[=[value]])")
("predefine,P", po::value<vector<string> >()->composing(),
"specify a macro to predefine (as macro[=[value]])")
("undefine,U", po::value<vector<string> >()->composing(),
"specify a macro to undefine")
;
// combine the options for the different usage schemes
po::options_description desc_overall_cmdline;
po::options_description desc_overall_cfgfile;
desc_overall_cmdline.add(desc_cmdline).add(desc_generic);
desc_overall_cfgfile.add(desc_generic);
// parse command line and store results
using namespace boost::program_options::command_line_style;
po::parsed_options opts = po::parse_command_line(argc, argv,
desc_overall_cmdline, unix_style, cmd_line_util::at_option_parser);
po::variables_map vm;
po::store(opts, vm);
po::notify(vm);
// Try to find a waveidl.cfg in the same directory as the executable was
// started from. If this exists, treat it as a wave config file
fs::path filename(argv[0], fs::native);
filename = filename.branch_path() / "waveidl.cfg";
cmd_line_util::read_config_file_options(filename.string(),
desc_overall_cfgfile, vm, true);
// if there is specified at least one config file, parse it and add the
// options to the main variables_map
if (vm.count("config-file")) {
vector<string> const &cfg_files =
vm["config-file"].as<vector<string> >();
vector<string>::const_iterator end = cfg_files.end();
for (vector<string>::const_iterator cit = cfg_files.begin();
cit != end; ++cit)
{
// parse a single config file and store the results
cmd_line_util::read_config_file_options(*cit,
desc_overall_cfgfile, vm);
}
}
// ... act as required
if (vm.count("help")) {
po::options_description desc_help (
"Usage: waveidl [options] [@config-file(s)] file");
desc_help.add(desc_cmdline).add(desc_generic);
cout << desc_help << endl;
return 1;
}
if (vm.count("version")) {
return print_version();
}
if (vm.count("copyright")) {
return print_copyright();
}
// extract the arguments from the parsed command line
vector<po::option> arguments;
std::remove_copy_if(opts.options.begin(), opts.options.end(),
inserter(arguments, arguments.end()), cmd_line_util::is_argument());
// if there is no input file given, then exit
if (0 == arguments.size() || 0 == arguments[0].value.size()) {
cerr << "waveidl: no input file given, "
<< "use --help to get a hint." << endl;
return 5;
}
// preprocess the given input file
return do_actual_work(arguments[0].value[0], vm);
}
catch (std::exception &e) {
cout << "waveidl: exception caught: " << e.what() << endl;
return 6;
}
catch (...) {
cerr << "waveidl: unexpected exception caught." << endl;
return 7;
}
}

View File

@@ -1,45 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_HPP_FC7EE131_5CE9_43F2_A713_8D9BBC3C8477_INCLUDED)
#define IDL_HPP_FC7EE131_5CE9_43F2_A713_8D9BBC3C8477_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// This file may be used as a precompiled header (if applicable)
///////////////////////////////////////////////////////////////////////////////
// include often used files from the stdlib
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
///////////////////////////////////////////////////////////////////////////////
// include boost config
#include <boost/config.hpp> // global configuration information
///////////////////////////////////////////////////////////////////////////////
// build version
#include "idl_version.hpp"
///////////////////////////////////////////////////////////////////////////////
// configure this app here (global configuration constants)
#include "idl_config.hpp"
///////////////////////////////////////////////////////////////////////////////
// include required boost libraries
#include <boost/assert.hpp>
#include <boost/pool/pool_alloc.hpp>
#endif // !defined(IDL_HPP_FC7EE131_5CE9_43F2_A713_8D9BBC3C8477_INCLUDED)

View File

@@ -1,65 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Global application configuration of the Wave driver command
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_CONFIG_HPP_012D7524_FF3F_482F_9123_91966C72F4EA_INCLUDED)
#define IDL_CONFIG_HPP_012D7524_FF3F_482F_9123_91966C72F4EA_INCLUDED
///////////////////////////////////////////////////////////////////////////////
// Uncomment the following, if you need debug output, the
// BOOST_SPIRIT_DEBUG_FLAGS constants below help to fine control the amount of
// the generated debug output
//#define BOOST_SPIRIT_DEBUG
///////////////////////////////////////////////////////////////////////////////
// debug rules, subrules and grammars only, for possible flags see
// spirit/debug.hpp
#if defined(BOOST_SPIRIT_DEBUG)
#define BOOST_SPIRIT_DEBUG_FLAGS ( \
BOOST_SPIRIT_DEBUG_FLAGS_NODES | \
BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES \
) \
/**/
///////////////////////////////////////////////////////////////////////////////
// debug flags for the pp-iterator library, possible flags (defined in
// wave_config.hpp):
//
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_GRAMMAR 0x0001
// #define BOOST_SPIRIT_DEBUG_FLAGS_TIME_CONVERSION 0x0002
// #define BOOST_SPIRIT_DEBUG_FLAGS_CPP_EXPR_GRAMMAR 0x0004
// #define BOOST_SPIRIT_DEBUG_FLAGS_INTLIT_GRAMMAR 0x0008
// #define BOOST_SPIRIT_DEBUG_FLAGS_CHLIT_GRAMMAR 0x0010
// #define BOOST_SPIRIT_DEBUG_FLAGS_DEFINED_GRAMMAR 0x0020
// #define BOOST_SPIRIT_DEBUG_FLAGS_PREDEF_MACROS_GRAMMAR 0x0040
#define BOOST_SPIRIT_DEBUG_FLAGS_CPP (\
/* insert the required flags from above */ \
) \
/**/
#endif
///////////////////////////////////////////////////////////////////////////////
// Now include the cofiguration stuff for the Wave library itself
#include <boost/wave/wave_config.hpp>
///////////////////////////////////////////////////////////////////////////////
// MSVC specific #pragma's
#if defined(BOOST_MSVC)
#pragma warning (disable: 4355) // 'this' used in base member initializer list
#pragma warning (disable: 4800) // forcing value to bool 'true' or 'false'
#pragma inline_depth(255)
#pragma inline_recursion(on)
#endif // defined(BOOST_MSVC)
#endif // !defined(IDL_CONFIG_HPP_012D7524_FF3F_482F_9123_91966C72F4EA_INCLUDED)

View File

@@ -1,23 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_VERSION_HPP_780C1190_3107_440B_B303_B687A449749B_INCLUDED)
#define IDL_VERSION_HPP_780C1190_3107_440B_B303_B687A449749B_INCLUDED
#include <boost/wave/wave_version.hpp>
#define IDL_VERSION_MAJOR BOOST_WAVE_VERSION_MAJOR
#define IDL_VERSION_MINOR BOOST_WAVE_VERSION_MINOR
#define IDL_VERSION_SUBMINOR BOOST_WAVE_VERSION_SUBMINOR
#define IDL_VERSION_DATE 20050117L
#endif // !defined(IDL_VERSION_HPP_780C1190_3107_440B_B303_B687A449749B_INCLUDED)

View File

@@ -1,583 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL lexer
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <boost/config.hpp>
#if defined(BOOST_HAS_UNISTD_H)
#include <unistd.h>
#else
#include <io.h>
#endif
#include <boost/assert.hpp>
#include <boost/detail/workaround.hpp>
// reuse the token ids and re2c helper functions from the default C++ lexer
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/re2clex/aq.hpp>
#include <boost/wave/cpplexer/re2clex/scanner.hpp>
#include "idl_re.hpp"
#if defined(_MSC_VER) && !defined(__COMO__)
#pragma warning (disable: 4101) // 'foo' : unreferenced local variable
#pragma warning (disable: 4102) // 'foo' : unreferenced label
#endif
#define BSIZE 196608
#define YYCTYPE uchar
#define YYCURSOR cursor
#define YYLIMIT s->lim
#define YYMARKER s->ptr
#define YYFILL(n) {cursor = fill(s, cursor);}
//#define RET(i) {s->cur = cursor; return (i);}
#define RET(i) \
{ \
s->line += count_backslash_newlines(s, cursor); \
s->cur = cursor; \
return (i); \
} \
/**/
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
namespace re2clex {
#define RE2C_ASSERT BOOST_ASSERT
int
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) {
RE2C_ASSERT(s->first != 0 && s->last != 0);
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
if (s->act < s->last)
return *(s->act)++;
}
return -1;
}
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) {
RE2C_ASSERT(s->first != 0 && s->last != 0);
s->act += cnt;
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
return s->act - s->first;
}
return 0;
}
std::size_t
get_first_eol_offset(boost::wave::cpplexer::re2clex::Scanner* s)
{
if (!AQ_EMPTY(s->eol_offsets))
{
return s->eol_offsets->queue[s->eol_offsets->head];
}
else
{
return (unsigned int)-1;
}
}
void
adjust_eol_offsets(boost::wave::cpplexer::re2clex::Scanner* s,
std::size_t adjustment)
{
boost::wave::cpplexer::re2clex::aq_queue q;
std::size_t i;
if (!s->eol_offsets)
s->eol_offsets = boost::wave::cpplexer::re2clex::aq_create();
q = s->eol_offsets;
if (AQ_EMPTY(q))
return;
i = q->head;
while (i != q->tail)
{
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
++i;
if (i == q->max_size)
i = 0;
}
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
}
int
count_backslash_newlines(boost::wave::cpplexer::re2clex::Scanner *s,
boost::wave::cpplexer::re2clex::uchar *cursor)
{
using namespace boost::wave::cpplexer::re2clex;
std::size_t diff, offset;
int skipped = 0;
/* figure out how many backslash-newlines skipped over unknowingly. */
diff = cursor - s->bot;
offset = get_first_eol_offset(s);
while (offset <= diff && offset != (unsigned int)-1)
{
skipped++;
boost::wave::cpplexer::re2clex::aq_pop(s->eol_offsets);
offset = get_first_eol_offset(s);
}
return skipped;
}
bool is_backslash(
boost::wave::cpplexer::re2clex::uchar *p,
boost::wave::cpplexer::re2clex::uchar *end, int &len)
{
if (*p == '\\') {
len = 1;
return true;
}
else if (*p == '?' && *(p+1) == '?' && (p+2 < end && *(p+2) == '/')) {
len = 3;
return true;
}
return false;
}
boost::wave::cpplexer::re2clex::uchar *
fill(boost::wave::cpplexer::re2clex::Scanner *s,
boost::wave::cpplexer::re2clex::uchar *cursor)
{
using namespace std; // some systems have memcpy etc. in namespace std
using namespace boost::wave::cpplexer::re2clex;
if(!s->eof)
{
uchar* p;
std::ptrdiff_t cnt = s->tok - s->bot;
if(cnt)
{
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
s->ptr -= cnt;
cursor -= cnt;
s->lim -= cnt;
adjust_eol_offsets(s, cnt);
}
if((s->top - s->lim) < BSIZE)
{
uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar));
if (buf == 0)
{
using namespace std; // some systems have printf in std
if (0 != s->error_proc)
(*s->error_proc)(s, "Out of memory!");
else
printf("Out of memory!\n");
/* get the scanner to stop */
*cursor = 0;
return cursor;
}
memcpy(buf, s->tok, s->lim - s->tok);
s->tok = buf;
s->ptr = &buf[s->ptr - s->bot];
cursor = &buf[cursor - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BSIZE];
free(s->bot);
s->bot = buf;
}
if (s->fd != -1) {
if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE)
{
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
}
}
else if (s->act != 0) {
cnt = s->last - s->act;
if (cnt > BSIZE)
cnt = BSIZE;
memcpy(s->lim, s->act, cnt);
s->act += cnt;
if (cnt != BSIZE)
{
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
}
}
/* backslash-newline erasing time */
/* first scan for backslash-newline and erase them */
for (p = s->lim; p < s->lim + cnt - 2; ++p)
{
int len = 0;
if (is_backslash(p, s->lim + cnt, len))
{
if (*(p+len) == '\n')
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
else if (*(p+len) == '\r')
{
if (*(p+len+1) == '\n')
{
int offset = len + 2;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
else
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
}
}
/* FIXME: the following code should be fixed to recognize correctly the
trigraph backslash token */
/* check to see if what we just read ends in a backslash */
if (cnt >= 2)
{
uchar last = s->lim[cnt-1];
uchar last2 = s->lim[cnt-2];
/* check \ EOB */
if (last == '\\')
{
int next = get_one_char(s);
/* check for \ \n or \ \r or \ \r \n straddling the border */
if (next == '\n')
{
--cnt; /* chop the final \, we've already read the \n. */
boost::wave::cpplexer::re2clex::aq_enqueue(s->eol_offsets,
cnt + (s->lim - s->bot));
}
else if (next == '\r')
{
int next2 = get_one_char(s);
if (next2 == '\n')
{
--cnt; /* skip the backslash */
}
else
{
/* rewind one, and skip one char */
rewind_stream(s, -1);
--cnt;
}
boost::wave::cpplexer::re2clex::aq_enqueue(s->eol_offsets,
cnt + (s->lim - s->bot));
}
else if (next != -1) /* -1 means end of file */
{
/* next was something else, so rewind the stream */
lseek(s->fd, -1, SEEK_CUR);
}
}
/* check \ \r EOB */
else if (last == '\r' && last2 == '\\')
{
int next = get_one_char(s);
if (next == '\n')
{
cnt -= 2; /* skip the \ \r */
}
else
{
/* rewind one, and skip two chars */
rewind_stream(s, -1);
cnt -= 2;
}
boost::wave::cpplexer::re2clex::aq_enqueue(s->eol_offsets,
cnt + (s->lim - s->bot));
}
/* check \ \n EOB */
else if (last == '\n' && last2 == '\\')
{
cnt -= 2;
boost::wave::cpplexer::re2clex::aq_enqueue(s->eol_offsets,
cnt + (s->lim - s->bot));
}
}
s->lim += cnt;
if (s->eof) /* eof needs adjusting if we erased backslash-newlines */
{
s->eof = s->lim;
*(s->eof)++ = '\0';
}
}
return cursor;
}
boost::wave::token_id
scan(boost::wave::cpplexer::re2clex::Scanner *s)
{
using namespace boost::wave::cpplexer::re2clex;
uchar *cursor = s->tok = s->cur;
/*!re2c
any = [\t\v\f\r\n\040-\377];
OctalDigit = [0-7];
Digit = [0-9];
HexDigit = [a-fA-F0-9];
ExponentPart = [Ee] [+-]? Digit+;
FractionalConstant = (Digit* "." Digit+) | (Digit+ ".");
FloatingSuffix = [fF][lL]?|[lL][fF]?;
IntegerSuffix = [uU][lL]?|[lL][uU]?;
FixedPointSuffix = [dD];
Backslash = [\\]|"??/";
EscapeSequence = Backslash ([abfnrtv?'"] | Backslash | "x" HexDigit+ | OctalDigit OctalDigit? OctalDigit?);
HexQuad = HexDigit HexDigit HexDigit HexDigit;
UniversalChar = Backslash ("u" HexQuad | "U" HexQuad HexQuad);
Newline = "\r\n" | "\n" | "\r";
PPSpace = ([ \t]|("/*"(any\[*]|Newline|("*"+(any\[*/]|Newline)))*"*"+"/"))*;
Pound = "#" | "??=" | "%:";
*/
/*!re2c
"/*" { goto ccomment; }
"//" { goto cppcomment; }
"TRUE" { RET(T_TRUE); }
"FALSE" { RET(T_FALSE); }
"{" { RET(T_LEFTBRACE); }
"}" { RET(T_RIGHTBRACE); }
"[" { RET(T_LEFTBRACKET); }
"]" { RET(T_RIGHTBRACKET); }
"#" { RET(T_POUND); }
"##" { RET(T_POUND_POUND); }
"(" { RET(T_LEFTPAREN); }
")" { RET(T_RIGHTPAREN); }
";" { RET(T_SEMICOLON); }
":" { RET(T_COLON); }
"?" { RET(T_QUESTION_MARK); }
"." { RET(T_DOT); }
"+" { RET(T_PLUS); }
"-" { RET(T_MINUS); }
"*" { RET(T_STAR); }
"/" { RET(T_DIVIDE); }
"%" { RET(T_PERCENT); }
"^" { RET(T_XOR); }
"&" { RET(T_AND); }
"|" { RET(T_OR); }
"~" { RET(T_COMPL); }
"!" { RET(T_NOT); }
"=" { RET(T_ASSIGN); }
"<" { RET(T_LESS); }
">" { RET(T_GREATER); }
"<<" { RET(T_SHIFTLEFT); }
">>" { RET(T_SHIFTRIGHT); }
"==" { RET(T_EQUAL); }
"!=" { RET(T_NOTEQUAL); }
"<=" { RET(T_LESSEQUAL); }
">=" { RET(T_GREATEREQUAL); }
"&&" { RET(T_ANDAND); }
"||" { RET(T_OROR); }
"++" { RET(T_PLUSPLUS); }
"--" { RET(T_MINUSMINUS); }
"," { RET(T_COMMA); }
([a-zA-Z_] | UniversalChar) ([a-zA-Z_0-9] | UniversalChar)*
{ RET(T_IDENTIFIER); }
(("0" [xX] HexDigit+) | ("0" OctalDigit*) | ([1-9] Digit*)) IntegerSuffix?
{ RET(T_INTLIT); }
((FractionalConstant ExponentPart?) | (Digit+ ExponentPart)) FloatingSuffix?
{ RET(T_FLOATLIT); }
(FractionalConstant | Digit+) FixedPointSuffix
{ RET(T_FIXEDPOINTLIT); }
"L"? (['] (EscapeSequence|any\[\n\r\\']|UniversalChar)+ ['])
{ RET(T_CHARLIT); }
"L"? (["] (EscapeSequence|any\[\n\r\\"]|UniversalChar)* ["])
{ RET(T_STRINGLIT); }
Pound PPSpace "include" PPSpace "<" (any\[\n\r>])+ ">"
{ RET(T_PP_HHEADER); }
Pound PPSpace "include" PPSpace "\"" (any\[\n\r"])+ "\""
{ RET(T_PP_QHEADER); }
Pound PPSpace "include" PPSpace
{ RET(T_PP_INCLUDE); }
Pound PPSpace "if" { RET(T_PP_IF); }
Pound PPSpace "ifdef" { RET(T_PP_IFDEF); }
Pound PPSpace "ifndef" { RET(T_PP_IFNDEF); }
Pound PPSpace "else" { RET(T_PP_ELSE); }
Pound PPSpace "elif" { RET(T_PP_ELIF); }
Pound PPSpace "endif" { RET(T_PP_ENDIF); }
Pound PPSpace "define" { RET(T_PP_DEFINE); }
Pound PPSpace "undef" { RET(T_PP_UNDEF); }
Pound PPSpace "line" { RET(T_PP_LINE); }
Pound PPSpace "error" { RET(T_PP_ERROR); }
Pound PPSpace "pragma" { RET(T_PP_PRAGMA); }
Pound PPSpace "warning" { RET(T_PP_WARNING); }
[ \t\v\f]+
{ RET(T_SPACE); }
Newline
{
s->line++;
RET(T_NEWLINE);
}
"\000"
{
if(cursor != s->eof)
{
using namespace std; // some systems have printf in std
if (0 != s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file\n");
}
RET(T_EOF);
}
any
{
/* if (0 != s->error_proc)
(*s->error_proc)(s, "Unexpected character: '%c'", *s->tok);
else
printf("unexpected character: '%c'\n", *s->tok);
*/
RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType));
}
*/
ccomment:
/*!re2c
"*/" { RET(T_CCOMMENT); }
Newline
{
/*if(cursor == s->eof) RET(T_EOF);*/
/*s->tok = cursor; */
s->line += count_backslash_newlines(s, cursor) +1;
goto ccomment;
}
any { goto ccomment; }
"\000"
{
using namespace std; // some systems have printf in std
if(cursor == s->eof)
{
if (s->error_proc)
(*s->error_proc)(s, "Unterminated comment");
else
printf("Error: Unterminated comment\n");
}
else
{
if (s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file");
}
/* adjust cursor such next call returns T_EOF */
--YYCURSOR;
/* the comment is unterminated, but nevertheless its a comment */
RET(T_CCOMMENT);
}
*/
cppcomment:
/*!re2c
Newline
{
/*if(cursor == s->eof) RET(T_EOF); */
/*s->tok = cursor; */
s->line++;
RET(T_CPPCOMMENT);
}
any { goto cppcomment; }
"\000"
{
using namespace std; // some systems have printf in std
if(cursor != s->eof)
{
if (s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file");
}
/* adjust cursor such next call returns T_EOF */
--YYCURSOR;
/* the comment is unterminated, but nevertheless its a comment */
RET(T_CPPCOMMENT);
}
*/
} /* end of scan */
#undef RE2C_ASSERT
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace idllexer
} // namespace wave
} // namespace boost

View File

@@ -1,83 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the abstract lexer interface
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
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
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/language_support.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
///////////////////////////////////////////////////////////////////////////////
//
// 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
>
struct new_lexer_gen
{
// 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>
> *
new_lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
};
///////////////////////////////////////////////////////////////////////////////
//
// The lex_input_interface decouples the lex_iterator_shim from the actual
// lexer. This is done to allow compile time reduction.
// Thanks to JCAB for having this idea.
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
struct lex_input_interface
{
typedef typename TokenT::position_type position_type;
virtual TokenT get() = 0;
virtual void set_position(position_type const &pos) = 0;
virtual ~lex_input_interface() {}
// 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 *
new_lexer(IteratorT const &first, IteratorT const &last,
position_type const &pos, boost::wave::language_support language)
{
return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
pos, language);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace wave
} // namespace boost
#endif // !defined(CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)

View File

@@ -1,158 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Re2C based IDL lexer
Definition of the lexer iterator
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED)
#define IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED
#include <string>
#include <iostream>
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/spirit/iterator/multi_pass.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/util/functor_input.hpp>
#include "idl_lex_interface.hpp"
#if 0 != __COMO_VERSION__
#define BOOST_WAVE_EOF_PREFIX static
#else
#define BOOST_WAVE_EOF_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// lex_iterator_functor_shim
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator_functor_shim
{
typedef lex_input_interface<TokenT> lex_input_interface_t;
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))
{}
// interface to the boost::spirit::multi_pass_policies::functor_input policy
typedef TokenT result_type;
BOOST_WAVE_EOF_PREFIX result_type const eof;
result_type operator()()
{
BOOST_ASSERT(0 != functor_ptr.get());
return functor_ptr->get();
}
void set_position(typename TokenT::position_type const &pos)
{
BOOST_ASSERT(0 != functor_ptr.get());
functor_ptr->set_position(pos);
}
private:
boost::shared_ptr<lex_input_interface_t> functor_ptr;
};
#if 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
// eof token
template <typename LexT>
typename lex_iterator_functor_shim<LexT>::result_type const
lex_iterator_functor_shim<LexT>::eof;
#endif // 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
//
// lex_iterator
//
// A generic C++ lexer interface class, which allows to plug in different
// lexer implementations (template parameter LexT). The following
// requirement apply:
//
// - the lexer type should have a function implemented, which returnes
// the next lexed token from the input stream:
// typename LexT::token_type get();
// - at the end of the input stream this function should return the
// eof token equivalent
// - the lexer should implement a constructor taking two iterators
// pointing to the beginning and the end of the input stream and
// a third parameter containing the name of the parsed input file
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator
: public boost::spirit::multi_pass<
impl::lex_iterator_functor_shim<TokenT>,
boost::wave::util::functor_input
>
{
typedef impl::lex_iterator_functor_shim<TokenT> input_policy_type;
typedef
boost::spirit::multi_pass<input_policy_type,
boost::wave::util::functor_input>
base_type;
typedef lex_iterator<TokenT> self_type;
public:
typedef TokenT token_type;
lex_iterator()
{}
template <typename IteratorT>
lex_iterator(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: base_type(input_policy_type(first, last, pos, language))
{}
void set_position(typename TokenT::position_type const &pos)
{
typedef typename TokenT::position_type position_type;
// set the new position in the current token
position_type currpos = base_type::get_input().get_position();
currpos.set_file(pos.get_file());
currpos.set_line(pos.get_line());
base_type::get_input().set_position(currpos);
// set the new position for future tokens as well
base_type::get_functor().set_position(pos);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace idllexer
} // namespace wave
} // namespace boost
#endif // !defined(IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED)

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Re2C based IDL lexer
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_RE_HPP_BD62775D_1659_4684_872C_03C02543C9A5_INCLUDED)
#define IDL_RE_HPP_BD62775D_1659_4684_872C_03C02543C9A5_INCLUDED
#include <boost/wave/token_ids.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
namespace re2clex {
///////////////////////////////////////////////////////////////////////////////
// The scanner function to call whenever a new token is requested
boost::wave::token_id scan(
boost::wave::cpplexer::re2clex::Scanner *s);
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace idllexer
} // namespace wave
} // namespace boost
#endif // !defined(IDL_RE_HPP_BD62775D_1659_4684_872C_03C02543C9A5_INCLUDED)

View File

@@ -1,271 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Re2C based IDL lexer
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)
#define IDL_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED
#include <string>
#include <cstdio>
#include <cstdarg>
#if defined(BOOST_SPIRIT_DEBUG)
#include <iostream>
#endif // defined(BOOST_SPIRIT_DEBUG)
#include <boost/concept_check.hpp>
#include <boost/assert.hpp>
#include <boost/spirit/core.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/cpplexer/validate_universal_char.hpp>
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
// reuse the default token type and re2c lexer helpers
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_interface.hpp>
#include <boost/wave/cpplexer/re2clex/scanner.hpp>
#include "idl_re.hpp"
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
namespace re2clex {
///////////////////////////////////////////////////////////////////////////////
//
// encapsulation of the re2c based idl lexer
//
///////////////////////////////////////////////////////////////////////////////
template <
typename IteratorT,
typename PositionT = boost::wave::util::file_position_type
>
class lexer
{
typedef boost::wave::cpplexer::re2clex::Scanner scanner_t;
public:
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;
lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
~lexer();
boost::wave::cpplexer::lex_token<PositionT> get();
void set_position(PositionT const &pos)
{
// set position has to change the file name and line number only
filename = pos.get_file();
scanner.line = pos.get_line();
scanner.file_name = filename.c_str();
}
// error reporting from the re2c generated lexer
static int report_error(scanner_t *s, char *, ...);
private:
static char const *tok_names[];
scanner_t scanner;
string_type filename;
bool at_eof;
boost::wave::language_support language;
};
///////////////////////////////////////////////////////////////////////////////
// initialize cpp lexer
template <typename IteratorT, typename PositionT>
inline
lexer<IteratorT, PositionT>::lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
boost::wave::language_support language)
: filename(pos.get_file()), at_eof(false), language(language)
{
using namespace std; // some systems have memset in std
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);
scanner.line = pos.get_line();
scanner.error_proc = report_error;
scanner.file_name = filename.c_str();
// not used by the lexer
scanner.enable_ms_extensions = 0;
scanner.act_in_c99_mode = 0;
scanner.act_in_cpp0x_mode = 0;
boost::ignore_unused_variable_warning(language);
}
template <typename IteratorT, typename PositionT>
inline
lexer<IteratorT, PositionT>::~lexer()
{
boost::wave::cpplexer::re2clex::aq_terminate(scanner.eol_offsets);
free(scanner.bot);
}
///////////////////////////////////////////////////////////////////////////////
// get the next token from the input stream
template <typename IteratorT, typename PositionT>
inline boost::wave::cpplexer::lex_token<PositionT>
lexer<IteratorT, PositionT>::get()
{
using namespace boost::wave; // to import token ids to this scope
if (at_eof)
return boost::wave::cpplexer::lex_token<PositionT>(); // return T_EOI
token_id id = token_id(scan(&scanner));
string_type value((char const *)scanner.tok, scanner.cur-scanner.tok);
if (T_IDENTIFIER == id) {
// test identifier characters for validity (throws if invalid chars found)
if (!(language & support_option_no_character_validation)) {
boost::wave::cpplexer::impl::validate_identifier_name(value,
scanner.line, -1, filename);
}
}
else if (T_STRINGLIT == id || T_CHARLIT == id) {
// test literal characters for validity (throws if invalid chars found)
if (!(language & support_option_no_character_validation)) {
boost::wave::cpplexer::impl::validate_literal(value, scanner.line,
-1, filename);
}
}
else if (T_EOF == id) {
// T_EOF is returned as a valid token, the next call will return T_EOI,
// i.e. the actual end of input
at_eof = true;
value.clear();
}
return boost::wave::cpplexer::lex_token<PositionT>(id, value,
PositionT(filename, scanner.line, -1));
}
template <typename IteratorT, typename PositionT>
inline int
lexer<IteratorT, PositionT>::report_error(scanner_t *s, char *msg, ...)
{
BOOST_ASSERT(0 != s);
BOOST_ASSERT(0 != msg);
using namespace std; // some system have vsprintf in namespace std
char buffer[200]; // should be large enough
va_list params;
va_start(params, msg);
vsprintf(buffer, msg, params);
va_end(params);
BOOST_WAVE_LEXER_THROW(boost::wave::cpplexer::lexing_exception,
generic_lexing_error, buffer, s->line, -1, s->file_name);
}
///////////////////////////////////////////////////////////////////////////////
//
// lex_functor
//
///////////////////////////////////////////////////////////////////////////////
template <
typename IteratorT,
typename PositionT = boost::wave::util::file_position_type
>
class lex_functor
: public lex_input_interface<typename lexer<IteratorT, PositionT>::token_type>
{
public:
typedef typename lexer<IteratorT, PositionT>::token_type token_type;
lex_functor(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language)
: lexer(first, last, pos, language)
{}
virtual ~lex_functor() {}
// get the next token from the input stream
token_type get() { return lexer.get(); }
void set_position(PositionT const &pos)
{ lexer.set_position(pos); }
private:
lexer<IteratorT, PositionT> lexer;
};
} // namespace re2clex
///////////////////////////////////////////////////////////////////////////////
//
// The new_lexer_gen<>::new_lexer function (declared in cpp_slex_token.hpp)
// should be defined inline, if the lex_functor shouldn't be instantiated
// separately from the lex_iterator.
//
// Separate (explicit) instantiation helps to reduce compilation time.
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE
#else
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE inline
#endif
///////////////////////////////////////////////////////////////////////////////
//
// The 'new_lexer' function allows the opaque generation of a new lexer object.
// It is coupled to the iterator type to allow to decouple the lexer/iterator
// configurations at compile time.
//
// This function is declared inside the cpp_slex_token.hpp file, which is
// referenced by the source file calling the lexer and the source file, which
// instantiates the lex_functor. But is is defined here, so it will be
// instantiated only while compiling the source file, which instantiates the
// lex_functor. While the cpp_re2c_token.hpp file may be included everywhere,
// this file (cpp_re2c_lexer.hpp) should be included only once. This allows
// to decouple the lexer interface from the lexer implementation and reduces
// compilation time.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT>
BOOST_WAVE_RE2C_NEW_LEXER_INLINE
lex_input_interface<boost::wave::cpplexer::lex_token<PositionT> > *
new_lexer_gen<IteratorT, PositionT>::new_lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
wave::language_support language)
{
return new re2clex::lex_functor<IteratorT, PositionT>(first, last, pos,
language);
}
#undef BOOST_WAVE_RE2C_NEW_LEXER_INLINE
///////////////////////////////////////////////////////////////////////////////
} // namespace idllexer
} // namespace wave
} // namespace boost
#endif // !defined(IDL_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Explicit instantiation of the cpp_grammar template
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp"
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include "idllexer/idl_lex_iterator.hpp"
#include <boost/wave/grammars/cpp_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the cpp_grammar_gen template with the correct
// token type. This instantiates the corresponding pt_parse function, which
// in turn instantiates the cpp_grammar object
// (see wave/grammars/cpp_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::idllexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::cpp_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Explicit instantiation of the defined_grammar template
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp"
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include "idllexer/idl_lex_iterator.hpp"
#include <boost/wave/grammars/cpp_defined_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the defined_grammar_gen template
// with the correct token type. This instantiates the corresponding parse
// function, which in turn instantiates the defined_grammar
// object (see wave/grammars/cpp_defined_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::idllexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::defined_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,42 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Explicit instantiation of the predefined_macros_grammar template
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp"
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include "idllexer/idl_lex_iterator.hpp"
#include <boost/wave/grammars/cpp_predef_macros_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the predefined_macros_grammar_gen template
// with the correct token type. This instantiates the corresponding pt_parse
// function, which in turn instantiates the cpp_predefined_macros_grammar
// object (see wave/grammars/cpp_predef_macros_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::idllexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,50 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Explicit instantiation of the lex_functor generation function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp"
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include "idllexer/idl_lex_iterator.hpp"
///////////////////////////////////////////////////////////////////////////////
// The following file needs to be included only once throughout the whole
// program.
#include "idllexer/idl_re2c_lexer.hpp"
///////////////////////////////////////////////////////////////////////////////
//
// This instantiates the correct 'new_lexer' function, which generates the
// C++ lexer used in this sample. You will have to instantiate the
// new_lexer_gen<> template with the same iterator type, as you have used for
// instantiating the boost::wave::context<> object.
//
// This is moved into a separate compilation unit to decouple the compilation
// of the C++ lexer from the compilation of the other modules, which helps to
// reduce compilation time.
//
// The template parameter(s) supplied should be identical to the first
// parameter supplied while instantiating the boost::wave::context<> template
// (see the file cpp.cpp).
//
///////////////////////////////////////////////////////////////////////////////
template struct boost::wave::idllexer::new_lexer_gen<
BOOST_WAVE_STRINGTYPE::iterator>;
#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0

View File

@@ -1,50 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: IDL oriented preprocessor
Explicit instantiation of the lex_functor generation function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "idl.hpp"
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include "idllexer/idl_lex_iterator.hpp"
///////////////////////////////////////////////////////////////////////////////
// The following file needs to be included only once throughout the whole
// program.
#include "idllexer/idl_re2c_lexer.hpp"
///////////////////////////////////////////////////////////////////////////////
//
// If you've used another iterator type as std::string::iterator, you have to
// instantiate the new_lexer_gen<> template for this iterator type too.
// The reason is, that the library internally uses the new_lexer_gen<>
// template with a std::string::iterator. (You just have to undefine the
// following line.)
//
// This is moved into a separate compilation unit to decouple the compilation
// of the C++ lexer from the compilation of the other modules, which helps to
// reduce compilation time.
//
// The template parameter(s) supplied should be identical to the first
// parameter supplied while instantiating the boost::wave::context<> template
// (see the file cpp.cpp).
//
///////////////////////////////////////////////////////////////////////////////
template struct boost::wave::idllexer::new_lexer_gen<std::string::iterator>;
#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0

View File

@@ -1,220 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001 Daniel C. Nuffer.
Copyright (c) 2001-2005 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <cstdlib>
#include <cstring>
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp> // configuration data
#include <boost/wave/cpplexer/re2clex/aq.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
int aq_grow(aq_queue q)
{
using namespace std; // some systems have memcpy/realloc in std
std::size_t new_size = q->max_size << 1;
aq_stdelement* new_queue = (aq_stdelement*)realloc(q->queue,
new_size * sizeof(aq_stdelement));
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->max_size < 100000);
BOOST_ASSERT(q->size <= q->max_size);
#define ASSERT_SIZE BOOST_ASSERT( \
((q->tail + q->max_size + 1) - q->head) % q->max_size == \
q->size % q->max_size)
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
if (!new_queue)
{
BOOST_ASSERT(0);
return 0;
}
q->queue = new_queue;
if (q->tail <= q->head) /* tail has wrapped around */
{
/* move the tail from the beginning to the end */
memcpy(q->queue + q->max_size, q->queue,
(q->tail + 1) * sizeof(aq_stdelement));
q->tail += q->max_size;
}
q->max_size = new_size;
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
return 1;
}
int aq_enqueue(aq_queue q, aq_stdelement e)
{
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
if (AQ_FULL(q))
if (!aq_grow(q))
return 0;
++q->tail;
if (q->tail == q->max_size)
q->tail = 0;
q->queue[q->tail] = e;
++q->size;
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
return 1;
}
int aq_enqueue_front(aq_queue q, aq_stdelement e)
{
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
if (AQ_FULL(q))
if (!aq_grow(q))
return 0;
if (q->head == 0)
q->head = q->max_size - 1;
else
--q->head;
q->queue[q->head] = e;
++q->size;
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
return 1;
}
int aq_serve(aq_queue q, aq_stdelement *e)
{
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
if (AQ_EMPTY(q))
return 0;
*e = q->queue[q->head];
return aq_pop(q);
}
int aq_pop(aq_queue q)
{
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
if (AQ_EMPTY(q))
return 0;
++q->head;
if (q->head == q->max_size)
q->head = 0;
--q->size;
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
return 1;
}
aq_queue aq_create(void)
{
aq_queue q;
using namespace std; // some systems have malloc in std
q = (aq_queue)malloc(sizeof(aq_queuetype));
if (!q)
{
return 0;
}
q->max_size = 8; /* initial size */
q->queue = (aq_stdelement*)malloc(
sizeof(aq_stdelement) * q->max_size);
if (!q->queue)
{
free(q);
return 0;
}
q->head = 0;
q->tail = q->max_size - 1;
q->size = 0;
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
return q;
}
void aq_terminate(aq_queue q)
{
using namespace std; // some systems have free in std
BOOST_ASSERT(NULL != q);
BOOST_ASSERT(q->size <= q->max_size);
ASSERT_SIZE;
BOOST_ASSERT(q->head <= q->max_size);
BOOST_ASSERT(q->tail <= q->max_size);
free(q->queue);
free(q);
}
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost

View File

@@ -1,779 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Copyright (c) 2001 Daniel C. Nuffer
Copyright (c) 2001-2005 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
TODO:
It also may be necessary to add $ to identifiers, for asm.
handle errors better.
have some easier way to parse strings instead of files (done)
=============================================================================*/
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <boost/config.hpp>
#if defined(BOOST_HAS_UNISTD_H)
#include <unistd.h>
#else
#include <io.h>
#endif
#include <boost/assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/re2clex/aq.hpp>
#include <boost/wave/cpplexer/re2clex/scanner.hpp>
#include <boost/wave/cpplexer/re2clex/cpp_re.hpp>
///////////////////////////////////////////////////////////////////////////////
#if defined(BOOST_MSVC)
#pragma warning (disable: 4101) // 'foo' : unreferenced local variable
#pragma warning (disable: 4102) // 'foo' : unreferenced label
#endif
///////////////////////////////////////////////////////////////////////////////
#define BSIZE 196608
#define YYCTYPE uchar
#define YYCURSOR cursor
#define YYLIMIT limit
#define YYMARKER marker
#define YYFILL(n) {cursor = uchar_wrapper(fill(s, cursor), cursor.column);}
//#define RET(i) {s->cur = cursor; return (i);}
#define RET(i) \
{ \
s->line += count_backslash_newlines(s, cursor); \
s->curr_column = cursor.column; \
s->cur = cursor; \
s->lim = limit; \
s->ptr = marker; \
return (i); \
} \
/**/
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
#define RE2C_ASSERT BOOST_ASSERT
int get_one_char(Scanner *s)
{
if (s->fd != -1) {
uchar val;
if (read(s->fd, &val, sizeof(val)))
return val;
}
else 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)
return *(s->act)++;
}
return -1;
}
std::ptrdiff_t rewind_stream (Scanner *s, int cnt)
{
if (s->fd != -1) {
return lseek(s->fd, cnt, SEEK_CUR);
}
else 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);
return s->act - s->first;
}
return 0;
}
std::size_t get_first_eol_offset(Scanner* s)
{
if (!AQ_EMPTY(s->eol_offsets))
{
return s->eol_offsets->queue[s->eol_offsets->head];
}
else
{
return (unsigned int)-1;
}
}
void adjust_eol_offsets(Scanner* s, std::size_t adjustment)
{
aq_queue q;
std::size_t i;
if (!s->eol_offsets)
s->eol_offsets = aq_create();
q = s->eol_offsets;
if (AQ_EMPTY(q))
return;
i = q->head;
while (i != q->tail)
{
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
++i;
if (i == q->max_size)
i = 0;
}
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
}
int count_backslash_newlines(Scanner *s, uchar *cursor)
{
std::size_t diff, offset;
int skipped = 0;
/* figure out how many backslash-newlines skipped over unknowingly. */
diff = cursor - s->bot;
offset = get_first_eol_offset(s);
while (offset <= diff && offset != (unsigned int)-1)
{
skipped++;
aq_pop(s->eol_offsets);
offset = get_first_eol_offset(s);
}
return skipped;
}
bool is_backslash(uchar *p, uchar *end, int &len)
{
if (*p == '\\') {
len = 1;
return true;
}
else if (*p == '?' && *(p+1) == '?' && (p+2 < end && *(p+2) == '/')) {
len = 3;
return true;
}
return false;
}
uchar *fill(Scanner *s, uchar *cursor)
{
using namespace std; // some systems have memcpy etc. in namespace std
if(!s->eof)
{
uchar* p;
std::ptrdiff_t cnt = s->tok - s->bot;
if(cnt)
{
if (NULL == s->lim)
s->lim = s->top;
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
s->ptr -= cnt;
cursor -= cnt;
s->lim -= cnt;
adjust_eol_offsets(s, cnt);
}
if((s->top - s->lim) < BSIZE)
{
uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar));
if (buf == 0)
{
using namespace std; // some systems have printf in std
if (0 != s->error_proc)
(*s->error_proc)(s, "Out of memory!");
else
printf("Out of memory!\n");
/* get the scanner to stop */
*cursor = 0;
return cursor;
}
memcpy(buf, s->tok, s->lim - s->tok);
s->tok = buf;
s->ptr = &buf[s->ptr - s->bot];
cursor = &buf[cursor - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BSIZE];
free(s->bot);
s->bot = buf;
}
if (s->fd != -1) {
if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE)
{
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
}
}
else if (s->act != 0) {
cnt = s->last - s->act;
if (cnt > BSIZE)
cnt = BSIZE;
memcpy(s->lim, s->act, cnt);
s->act += cnt;
if (cnt != BSIZE)
{
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
}
}
/* backslash-newline erasing time */
/* first scan for backslash-newline and erase them */
for (p = s->lim; p < s->lim + cnt - 2; ++p)
{
int len = 0;
if (is_backslash(p, s->lim + cnt, len))
{
if (*(p+len) == '\n')
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
else if (*(p+len) == '\r')
{
if (*(p+len+1) == '\n')
{
int offset = len + 2;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
else
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
}
}
/* FIXME: the following code should be fixed to recognize correctly the
trigraph backslash token */
/* check to see if what we just read ends in a backslash */
if (cnt >= 2)
{
uchar last = s->lim[cnt-1];
uchar last2 = s->lim[cnt-2];
/* check \ EOB */
if (last == '\\')
{
int next = get_one_char(s);
/* check for \ \n or \ \r or \ \r \n straddling the border */
if (next == '\n')
{
--cnt; /* chop the final \, we've already read the \n. */
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
else if (next == '\r')
{
int next2 = get_one_char(s);
if (next2 == '\n')
{
--cnt; /* skip the backslash */
}
else
{
/* rewind one, and skip one char */
rewind_stream(s, -1);
--cnt;
}
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
else if (next != -1) /* -1 means end of file */
{
/* next was something else, so rewind the stream */
rewind_stream(s, -1);
}
}
/* check \ \r EOB */
else if (last == '\r' && last2 == '\\')
{
int next = get_one_char(s);
if (next == '\n')
{
cnt -= 2; /* skip the \ \r */
}
else
{
/* rewind one, and skip two chars */
rewind_stream(s, -1);
cnt -= 2;
}
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
/* check \ \n EOB */
else if (last == '\n' && last2 == '\\')
{
cnt -= 2;
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
}
s->lim += cnt;
if (s->eof) /* eof needs adjusting if we erased backslash-newlines */
{
s->eof = s->lim;
*(s->eof)++ = '\0';
}
}
return cursor;
}
///////////////////////////////////////////////////////////////////////////////
// Special wrapper class holding the current cursor position
struct uchar_wrapper
{
uchar_wrapper (uchar *base_cursor, unsigned int column = 1)
: base_cursor(base_cursor), column(column)
{}
uchar_wrapper& operator++()
{
++base_cursor;
++column;
return *this;
}
uchar_wrapper& operator--()
{
--base_cursor;
--column;
return *this;
}
uchar operator* () const
{
return *base_cursor;
}
operator uchar *() const
{
return base_cursor;
}
friend int operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs)
{
return lhs.base_cursor - rhs.base_cursor;
}
uchar *base_cursor;
unsigned int column;
};
///////////////////////////////////////////////////////////////////////////////
boost::wave::token_id scan(Scanner *s)
{
uchar_wrapper cursor (s->tok = s->cur, s->column = s->curr_column);
uchar_wrapper marker (s->ptr);
uchar_wrapper limit (s->lim);
/*!re2c
any = [\t\v\f\r\n\040-\377];
OctalDigit = [0-7];
Digit = [0-9];
HexDigit = [a-fA-F0-9];
Integer = (("0" [xX] HexDigit+) | ("0" OctalDigit*) | ([1-9] Digit*));
ExponentPart = [Ee] [+-]? Digit+;
FractionalConstant = (Digit* "." Digit+) | (Digit+ ".");
FloatingSuffix = [fF] [lL]? | [lL] [fF]?;
IntegerSuffix = [uU] [lL]? | [lL] [uU]?;
LongIntegerSuffix = [uU] ("ll" | "LL") | ("ll" | "LL") [uU]?;
Backslash = [\\] | "??/";
EscapeSequence = Backslash ([abfnrtv?'"] | Backslash | "x" HexDigit+ | OctalDigit OctalDigit? OctalDigit?);
HexQuad = HexDigit HexDigit HexDigit HexDigit;
UniversalChar = Backslash ("u" HexQuad | "U" HexQuad HexQuad);
Newline = "\r\n" | "\n" | "\r";
PPSpace = ([ \t]|("/*"(any\[*]|Newline|("*"+(any\[*/]|Newline)))*"*"+"/"))*;
Pound = "#" | "??=" | "%:";
*/
/*!re2c
"/*" { goto ccomment; }
"//" { goto cppcomment; }
"asm" { RET(T_ASM); }
"auto" { RET(T_AUTO); }
"bool" { RET(T_BOOL); }
"break" { RET(T_BREAK); }
"case" { RET(T_CASE); }
"catch" { RET(T_CATCH); }
"char" { RET(T_CHAR); }
"class" { RET(T_CLASS); }
"const" { RET(T_CONST); }
"const_cast" { RET(T_CONSTCAST); }
"continue" { RET(T_CONTINUE); }
"default" { RET(T_DEFAULT); }
"delete" { RET(T_DELETE); }
"do" { RET(T_DO); }
"double" { RET(T_DOUBLE); }
"dynamic_cast" { RET(T_DYNAMICCAST); }
"else" { RET(T_ELSE); }
"enum" { RET(T_ENUM); }
"explicit" { RET(T_EXPLICIT); }
"export" { RET(T_EXPORT); }
"extern" { RET(T_EXTERN); }
"false" { RET(T_FALSE); }
"float" { RET(T_FLOAT); }
"for" { RET(T_FOR); }
"friend" { RET(T_FRIEND); }
"goto" { RET(T_GOTO); }
"if" { RET(T_IF); }
"inline" { RET(T_INLINE); }
"int" { RET(T_INT); }
"long" { RET(T_LONG); }
"mutable" { RET(T_MUTABLE); }
"namespace" { RET(T_NAMESPACE); }
"new" { RET(T_NEW); }
"operator" { RET(T_OPERATOR); }
"private" { RET(T_PRIVATE); }
"protected" { RET(T_PROTECTED); }
"public" { RET(T_PUBLIC); }
"register" { RET(T_REGISTER); }
"reinterpret_cast" { RET(T_REINTERPRETCAST); }
"return" { RET(T_RETURN); }
"short" { RET(T_SHORT); }
"signed" { RET(T_SIGNED); }
"sizeof" { RET(T_SIZEOF); }
"static" { RET(T_STATIC); }
"static_cast" { RET(T_STATICCAST); }
"struct" { RET(T_STRUCT); }
"switch" { RET(T_SWITCH); }
"template" { RET(T_TEMPLATE); }
"this" { RET(T_THIS); }
"throw" { RET(T_THROW); }
"true" { RET(T_TRUE); }
"try" { RET(T_TRY); }
"typedef" { RET(T_TYPEDEF); }
"typeid" { RET(T_TYPEID); }
"typename" { RET(T_TYPENAME); }
"union" { RET(T_UNION); }
"unsigned" { RET(T_UNSIGNED); }
"using" { RET(T_USING); }
"virtual" { RET(T_VIRTUAL); }
"void" { RET(T_VOID); }
"volatile" { RET(T_VOLATILE); }
"wchar_t" { RET(T_WCHART); }
"while" { RET(T_WHILE); }
"__int8" { RET(s->enable_ms_extensions ? T_MSEXT_INT8 : T_IDENTIFIER); }
"__int16" { RET(s->enable_ms_extensions ? T_MSEXT_INT16 : T_IDENTIFIER); }
"__int32" { RET(s->enable_ms_extensions ? T_MSEXT_INT32 : T_IDENTIFIER); }
"__int64" { RET(s->enable_ms_extensions ? T_MSEXT_INT64 : T_IDENTIFIER); }
"_"? "_based" { RET(s->enable_ms_extensions ? T_MSEXT_BASED : T_IDENTIFIER); }
"_"? "_declspec" { RET(s->enable_ms_extensions ? T_MSEXT_DECLSPEC : T_IDENTIFIER); }
"_"? "_cdecl" { RET(s->enable_ms_extensions ? T_MSEXT_CDECL : T_IDENTIFIER); }
"_"? "_fastcall" { RET(s->enable_ms_extensions ? T_MSEXT_FASTCALL : T_IDENTIFIER); }
"_"? "_stdcall" { RET(s->enable_ms_extensions ? T_MSEXT_STDCALL : T_IDENTIFIER); }
"__try" { RET(s->enable_ms_extensions ? T_MSEXT_TRY : T_IDENTIFIER); }
"__except" { RET(s->enable_ms_extensions ? T_MSEXT_EXCEPT : T_IDENTIFIER); }
"__finally" { RET(s->enable_ms_extensions ? T_MSEXT_FINALLY : T_IDENTIFIER); }
"__leave" { RET(s->enable_ms_extensions ? T_MSEXT_LEAVE : T_IDENTIFIER); }
"_"? "_inline" { RET(s->enable_ms_extensions ? T_MSEXT_INLINE : T_IDENTIFIER); }
"_"? "_asm" { RET(s->enable_ms_extensions ? T_MSEXT_ASM : T_IDENTIFIER); }
"{" { RET(T_LEFTBRACE); }
"??<" { RET(T_LEFTBRACE_TRIGRAPH); }
"<%" { RET(T_LEFTBRACE_ALT); }
"}" { RET(T_RIGHTBRACE); }
"??>" { RET(T_RIGHTBRACE_TRIGRAPH); }
"%>" { RET(T_RIGHTBRACE_ALT); }
"[" { RET(T_LEFTBRACKET); }
"??(" { RET(T_LEFTBRACKET_TRIGRAPH); }
"<:" { RET(T_LEFTBRACKET_ALT); }
"]" { RET(T_RIGHTBRACKET); }
"??)" { RET(T_RIGHTBRACKET_TRIGRAPH); }
":>" { RET(T_RIGHTBRACKET_ALT); }
"#" { RET(T_POUND); }
"%:" { RET(T_POUND_ALT); }
"??=" { RET(T_POUND_TRIGRAPH); }
"##" { RET(T_POUND_POUND); }
"#??=" { RET(T_POUND_POUND_TRIGRAPH); }
"??=#" { RET(T_POUND_POUND_TRIGRAPH); }
"??=??=" { RET(T_POUND_POUND_TRIGRAPH); }
"%:%:" { RET(T_POUND_POUND_ALT); }
"(" { RET(T_LEFTPAREN); }
")" { RET(T_RIGHTPAREN); }
";" { RET(T_SEMICOLON); }
":" { RET(T_COLON); }
"..." { RET(T_ELLIPSIS); }
"?" { RET(T_QUESTION_MARK); }
"::"
{
if (s->act_in_c99_mode) {
--YYCURSOR;
RET(T_COLON);
}
else {
RET(T_COLON_COLON);
}
}
"." { RET(T_DOT); }
".*"
{
if (s->act_in_c99_mode) {
--YYCURSOR;
RET(T_DOT);
}
else {
RET(T_DOTSTAR);
}
}
"+" { RET(T_PLUS); }
"-" { RET(T_MINUS); }
"*" { RET(T_STAR); }
"/" { RET(T_DIVIDE); }
"%" { RET(T_PERCENT); }
"^" { RET(T_XOR); }
"??'" { RET(T_XOR_TRIGRAPH); }
"xor" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XOR_ALT); }
"&" { RET(T_AND); }
"bitand" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_AND_ALT); }
"|" { RET(T_OR); }
"bitor" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OR_ALT); }
"??!" { RET(T_OR_TRIGRAPH); }
"~" { RET(T_COMPL); }
"??-" { RET(T_COMPL_TRIGRAPH); }
"compl" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_COMPL_ALT); }
"!" { RET(T_NOT); }
"not" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOT_ALT); }
"=" { RET(T_ASSIGN); }
"<" { RET(T_LESS); }
">" { RET(T_GREATER); }
"+=" { RET(T_PLUSASSIGN); }
"-=" { RET(T_MINUSASSIGN); }
"*=" { RET(T_STARASSIGN); }
"/=" { RET(T_DIVIDEASSIGN); }
"%=" { RET(T_PERCENTASSIGN); }
"^=" { RET(T_XORASSIGN); }
"xor_eq" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XORASSIGN_ALT); }
"??'=" { RET(T_XORASSIGN_TRIGRAPH); }
"&=" { RET(T_ANDASSIGN); }
"and_eq" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDASSIGN_ALT); }
"|=" { RET(T_ORASSIGN); }
"or_eq" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ORASSIGN_ALT); }
"??!=" { RET(T_ORASSIGN_TRIGRAPH); }
"<<" { RET(T_SHIFTLEFT); }
">>" { RET(T_SHIFTRIGHT); }
">>=" { RET(T_SHIFTRIGHTASSIGN); }
"<<=" { RET(T_SHIFTLEFTASSIGN); }
"==" { RET(T_EQUAL); }
"!=" { RET(T_NOTEQUAL); }
"not_eq" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOTEQUAL_ALT); }
"<=" { RET(T_LESSEQUAL); }
">=" { RET(T_GREATEREQUAL); }
"&&" { RET(T_ANDAND); }
"and" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDAND_ALT); }
"||" { RET(T_OROR); }
"??!|" { RET(T_OROR_TRIGRAPH); }
"|??!" { RET(T_OROR_TRIGRAPH); }
"or" { RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OROR_ALT); }
"??!??!" { RET(T_OROR_TRIGRAPH); }
"++" { RET(T_PLUSPLUS); }
"--" { RET(T_MINUSMINUS); }
"," { RET(T_COMMA); }
"->*"
{
if (s->act_in_c99_mode) {
--YYCURSOR;
RET(T_ARROW);
}
else {
RET(T_ARROWSTAR);
}
}
"->" { RET(T_ARROW); }
"??/" { RET(T_ANY_TRIGRAPH); }
([a-zA-Z_] | UniversalChar) ([a-zA-Z_0-9] | UniversalChar)*
{ RET(T_IDENTIFIER); }
Integer LongIntegerSuffix
{ RET(T_LONGINTLIT); }
Integer IntegerSuffix?
{ RET(T_INTLIT); }
((FractionalConstant ExponentPart?) | (Digit+ ExponentPart)) FloatingSuffix?
{ RET(T_FLOATLIT); }
"L"? (['] (EscapeSequence|any\[\n\r\\']|UniversalChar)+ ['])
{ RET(T_CHARLIT); }
"L"? (["] (EscapeSequence|any\[\n\r\\"]|UniversalChar)* ["])
{ RET(T_STRINGLIT); }
Pound PPSpace ( "include" | "include_next") PPSpace "<" (any\[\n\r>])+ ">"
{ RET(T_PP_HHEADER); }
Pound PPSpace ( "include" | "include_next") PPSpace "\"" (any\[\n\r"])+ "\""
{ RET(T_PP_QHEADER); }
Pound PPSpace ( "include" | "include_next") PPSpace
{ RET(T_PP_INCLUDE); }
Pound PPSpace "if" { RET(T_PP_IF); }
Pound PPSpace "ifdef" { RET(T_PP_IFDEF); }
Pound PPSpace "ifndef" { RET(T_PP_IFNDEF); }
Pound PPSpace "else" { RET(T_PP_ELSE); }
Pound PPSpace "elif" { RET(T_PP_ELIF); }
Pound PPSpace "endif" { RET(T_PP_ENDIF); }
Pound PPSpace "define" { RET(T_PP_DEFINE); }
Pound PPSpace "undef" { RET(T_PP_UNDEF); }
Pound PPSpace "line" { RET(T_PP_LINE); }
Pound PPSpace "error" { RET(T_PP_ERROR); }
Pound PPSpace "pragma" { RET(T_PP_PRAGMA); }
Pound PPSpace "warning" { RET(T_PP_WARNING); }
Pound PPSpace "region" { RET(T_MSEXT_PP_REGION); }
Pound PPSpace "endregion" { RET(T_MSEXT_PP_ENDREGION); }
[ \t\v\f]+
{ RET(T_SPACE); }
Newline
{
s->line++;
cursor.column = 1;
RET(T_NEWLINE);
}
"\000"
{
if(cursor != s->eof)
{
using namespace std; // some systems have printf in std
if (0 != s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file\n");
}
RET(T_EOF);
}
any
{
/* if (0 != s->error_proc)
(*s->error_proc)(s, "Unexpected character: '%c'", *s->tok);
else
printf("unexpected character: '%c'\n", *s->tok);
*/
RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType));
}
*/
ccomment:
/*!re2c
"*/" { RET(T_CCOMMENT); }
Newline
{
/*if(cursor == s->eof) RET(T_EOF);*/
/*s->tok = cursor; */
s->line += count_backslash_newlines(s, cursor) +1;
cursor.column = 1;
goto ccomment;
}
any { goto ccomment; }
"\000"
{
using namespace std; // some systems have printf in std
if(cursor == s->eof)
{
if (s->error_proc)
(*s->error_proc)(s, "Unterminated comment");
else
printf("Error: Unterminated comment\n");
}
else
{
if (s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file");
}
/* adjust cursor such next call returns T_EOF */
--YYCURSOR;
/* the comment is unterminated, but nevertheless its a comment */
RET(T_CCOMMENT);
}
*/
cppcomment:
/*!re2c
Newline
{
/*if(cursor == s->eof) RET(T_EOF); */
/*s->tok = cursor; */
s->line++;
cursor.column = 1;
RET(T_CPPCOMMENT);
}
any { goto cppcomment; }
"\000"
{
using namespace std; // some systems have printf in std
if(cursor != s->eof)
{
if (s->error_proc)
(*s->error_proc)(s, "'\\000' in input stream");
else
printf("Error: 0 in file");
}
/* adjust cursor such next call returns T_EOF */
--YYCURSOR;
/* the comment is unterminated, but nevertheless its a comment */
RET(T_CPPCOMMENT);
}
*/
} /* end of scan */
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost
#undef RET
#undef BSIZE
#undef YYCTYPE
#undef YYCURSOR
#undef YYLIMIT
#undef YYMARKER
#undef YYFILL

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <utility>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/grammars/cpp_expression_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the expression_grammar_gen template with the
// correct lexer iterator type. This instantiates the corresponding parse
// function, which in turn instantiates the expression_grammar object (see
// wave/grammars/cpp_expression_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::lex_token<> token_type;
template struct boost::wave::grammars::expression_grammar_gen<token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,36 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/grammars/cpp_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the cpp_grammar_gen template with the correct
// token type. This instantiates the corresponding pt_parse function, which
// in turn instantiates the cpp_grammar object
// (see wave/grammars/cpp_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::cpp_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,37 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_intlit_grammar.hpp>
#include <boost/wave/grammars/cpp_chlit_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the intlit_grammar_gen and chlit_grammar_gen
// templates with the correct token type. This instantiates the corresponding
// parse function, which in turn instantiates the corresponding parser object.
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::lex_token<> token_type;
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,36 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/grammars/cpp_defined_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the defined_grammar_gen template
// with the correct token type. This instantiates the corresponding parse
// function, which in turn instantiates the defined_grammar
// object (see wave/grammars/cpp_defined_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::defined_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,36 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#include <string>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/grammars/cpp_predef_macros_grammar.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Explicit instantiation of the predefined_macros_grammar_gen template
// with the correct token type. This instantiates the corresponding pt_parse
// function, which in turn instantiates the cpp_predefined_macros_grammar
// object (see wave/grammars/cpp_predef_macros_grammar.hpp)
//
///////////////////////////////////////////////////////////////////////////////
typedef boost::wave::cpplexer::lex_iterator<
boost::wave::cpplexer::lex_token<> >
lexer_type;
template struct boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0

View File

@@ -1,47 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Explicit instantiation of the lex_functor generation function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp> // configuration data
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
///////////////////////////////////////////////////////////////////////////////
// The following file needs to be included only once throughout the whole
// program.
#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// This instantiates the correct 'new_lexer' function, which generates the
// C++ lexer used in this sample. You will have to instantiate the
// new_lexer_gen<> template with the same iterator type, as you have used for
// instantiating the boost::wave::context<> object.
//
// This is moved into a separate compilation unit to decouple the compilation
// of the C++ lexer from the compilation of the other modules, which helps to
// reduce compilation time.
//
// The template parameter(s) supplied should be identical to the first
// parameter supplied while instantiating the boost::wave::context<> template
// (see the file cpp.cpp).
//
///////////////////////////////////////////////////////////////////////////////
template struct boost::wave::cpplexer::new_lexer_gen<
BOOST_WAVE_STRINGTYPE::iterator>;
#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0

View File

@@ -1,47 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Explicit instantiation of the lex_functor generation function
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp> // configuration data
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#include <string>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
///////////////////////////////////////////////////////////////////////////////
// The following file needs to be included only once throughout the whole
// program.
#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// If you've used another iterator type as std::string::iterator, you have to
// instantiate the new_lexer_gen<> template for this iterator type too.
// The reason is, that the library internally uses the new_lexer_gen<>
// template with a std::string::iterator. (You just have to undefine the
// following line.)
//
// This is moved into a separate compilation unit to decouple the compilation
// of the C++ lexer from the compilation of the other modules, which helps to
// reduce compilation time.
//
// The template parameter(s) supplied should be identical to the first
// parameter supplied while instantiating the boost::wave::context<> template
// (see the file cpp.cpp).
//
///////////////////////////////////////////////////////////////////////////////
template struct boost::wave::cpplexer::new_lexer_gen<std::string::iterator>;
#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0

View File

@@ -1,136 +0,0 @@
# Boost.Wave: A Standard compliant C++ preprocessor library
#
# Boost Wave Library Test Jamfile
#
# http://www.boost.org/
#
# Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
subproject libs/wave/test/build ;
# bring in the rules for testing
import testing ;
# Make tests run by default.
DEPENDS all : test ;
#
# These are the sources to compile for the testwave application
#
TESTWAVE_SOURCES = testwave testwave_app ;
#
# This is the directory where the test files reside
#
TESTWAVE_DIR = $(BOOST_ROOT)/libs/wave/test/testwave/testfiles
;
#
# This are the arguments for the testwave executable
#
TESTWAVE_ARGUMENTS =
-d9 # use -d4 for verbose results
-S$(TESTWAVE_DIR)
-S$(BOOST_ROOT) -I$(BOOST_ROOT)
;
#
# These are the names of the different unit tests to run
#
TESTWAVE_FILES = test.cfg
;
#
# this template defines the options common to all wave lexer tests:
#
template wave-lexer-test
:
<lib>../../build/boost_wave # sources
:
<include>$(BOOST_ROOT)
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
std::locale-support
:
<runtime-link>static
<threading>single
debug # build variants
;
#
# this template defines the options common to all wave tests:
#
template wave-test
:
<lib>../../build/boost_wave # sources
<lib>../../../program_options/build/boost_program_options
<lib>../../../filesystem/build/boost_filesystem
:
<include>$(BOOST_ROOT)
<sysinclude>$(BOOST_ROOT)
<vc-7_1><*><rtti>off # workaround for compiler bug
std::locale-support
:
<runtime-link>static
<threading>single
debug # build variants
;
#
# Wave test suite
#
test-suite wave
:
# test the wave preprocessing component
[
run
# sources
<template>wave-test
../testwave/$(TESTWAVE_SOURCES).cpp
:
# arguments
$(TESTWAVE_ARGUMENTS)
--config-file=$(TESTWAVE_DIR)/$(TESTWAVE_FILES)
:
# input files
:
# requirements
:
# name
testwave
]
# test the different wave lexing components
[
run
# sources
<template>wave-lexer-test
../testlexers/test_slex_lexer.cpp
:
# arguments
:
# input files
:
# requirements
:
# name
test_slex_lexer
]
[
run
# sources
<template>wave-lexer-test
../testlexers/test_re2c_lexer.cpp
:
# arguments
:
# input files
:
# requirements
:
# name
test_re2c_lexer
]
;

View File

@@ -1,239 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
///////////////////////////////////////////////////////////////////////////////
struct lexem
{
char const*token;
boost::wave::token_id id;
};
///////////////////////////////////////////////////////////////////////////////
lexem const lexems[] =
{
{ "bitand", boost::wave::T_AND_ALT },
{ "and", boost::wave::T_ANDAND_ALT },
{ "and_eq", boost::wave::T_ANDASSIGN_ALT },
{ "bitor", boost::wave::T_OR_ALT },
{ "or_eq", boost::wave::T_ORASSIGN_ALT },
{ "or", boost::wave::T_OROR_ALT },
{ "xor", boost::wave::T_XOR_ALT },
{ "xor_eq", boost::wave::T_XORASSIGN_ALT },
{ "not", boost::wave::T_NOT_ALT },
{ "not_eq", boost::wave::T_NOTEQUAL_ALT },
{ "compl", boost::wave::T_COMPL_ALT },
{ "->*", boost::wave::T_ARROWSTAR },
{ ".*", boost::wave::T_DOTSTAR },
{ "::", boost::wave::T_COLON_COLON },
{ "/* some C comment */", boost::wave::T_CCOMMENT },
{ "/* some multiline \n C comment \n */", boost::wave::T_CCOMMENT },
{ "// some c++ comment\n", boost::wave::T_CPPCOMMENT },
{ "'c'", boost::wave::T_CHARLIT },
{ "'\\n'", boost::wave::T_CHARLIT },
{ "'\\u1234'", boost::wave::T_CHARLIT },
{ "'\\U12345678'", boost::wave::T_CHARLIT },
{ "\"string literal\"", boost::wave::T_STRINGLIT },
{ "\"string literal \\n \\u1234 \\U12345678\"", boost::wave::T_STRINGLIT },
{ "&&", boost::wave::T_ANDAND },
{ "&=", boost::wave::T_ANDASSIGN },
{ "==", boost::wave::T_EQUAL },
{ "=", boost::wave::T_ASSIGN },
{ "|=", boost::wave::T_ORASSIGN },
{ "\?\?!=", boost::wave::T_ORASSIGN_TRIGRAPH },
{ "||", boost::wave::T_OROR },
{ "|\?\?!", boost::wave::T_OROR_TRIGRAPH },
{ "\?\?!|", boost::wave::T_OROR_TRIGRAPH },
{ "\?\?!\?\?!", boost::wave::T_OROR_TRIGRAPH },
{ "|", boost::wave::T_OR },
{ "\?\?!", boost::wave::T_OR_TRIGRAPH },
{ "^=", boost::wave::T_XORASSIGN },
{ "\?\?'=", boost::wave::T_XORASSIGN_TRIGRAPH },
{ "^", boost::wave::T_XOR },
{ "\?\?'", boost::wave::T_XOR_TRIGRAPH },
{ ",", boost::wave::T_COMMA },
{ ":>", boost::wave::T_RIGHTBRACKET_ALT },
{ ":", boost::wave::T_COLON },
{ "/=", boost::wave::T_DIVIDEASSIGN },
{ "/", boost::wave::T_DIVIDE },
{ "...", boost::wave::T_ELLIPSIS },
{ ".", boost::wave::T_DOT },
{ ">>=", boost::wave::T_SHIFTRIGHTASSIGN },
{ ">>", boost::wave::T_SHIFTRIGHT },
{ ">=", boost::wave::T_GREATEREQUAL },
{ ">", boost::wave::T_GREATER },
{ "{", boost::wave::T_LEFTBRACE },
{ "<<=", boost::wave::T_SHIFTLEFTASSIGN },
{ "<<", boost::wave::T_SHIFTLEFT },
{ "<=", boost::wave::T_LESSEQUAL },
{ "<%", boost::wave::T_LEFTBRACE_ALT },
{ "<:", boost::wave::T_LEFTBRACKET_ALT },
{ "<", boost::wave::T_LESS },
{ "\?\?<", boost::wave::T_LEFTBRACE_TRIGRAPH },
{ "(", boost::wave::T_LEFTPAREN },
{ "[", boost::wave::T_LEFTBRACKET },
{ "\?\?(", boost::wave::T_LEFTBRACKET_TRIGRAPH },
{ "--", boost::wave::T_MINUSMINUS },
{ "-=", boost::wave::T_MINUSASSIGN },
{ "->", boost::wave::T_ARROW },
{ "-", boost::wave::T_MINUS },
{ "%:%:", boost::wave::T_POUND_POUND_ALT },
{ "%=", boost::wave::T_PERCENTASSIGN },
{ "%>", boost::wave::T_RIGHTBRACE_ALT },
{ "%:", boost::wave::T_POUND_ALT },
{ "%", boost::wave::T_PERCENT },
{ "!=", boost::wave::T_NOTEQUAL },
{ "!", boost::wave::T_NOT },
{ "+=", boost::wave::T_PLUSASSIGN },
{ "++", boost::wave::T_PLUSPLUS },
{ "+", boost::wave::T_PLUS },
{ "}", boost::wave::T_RIGHTBRACE },
{ "\?\?>", boost::wave::T_RIGHTBRACE_TRIGRAPH },
{ ")", boost::wave::T_RIGHTPAREN },
{ "]", boost::wave::T_RIGHTBRACKET },
{ "\?\?)", boost::wave::T_RIGHTBRACKET_TRIGRAPH },
{ ";", boost::wave::T_SEMICOLON },
{ "*=", boost::wave::T_STARASSIGN },
{ "*", boost::wave::T_STAR },
{ "~", boost::wave::T_COMPL },
{ "\?\?-", boost::wave::T_COMPL_TRIGRAPH },
{ "asm", boost::wave::T_ASM },
{ "auto", boost::wave::T_AUTO },
{ "bool", boost::wave::T_BOOL },
{ "false", boost::wave::T_FALSE },
{ "true", boost::wave::T_TRUE },
{ "break", boost::wave::T_BREAK },
{ "case", boost::wave::T_CASE },
{ "catch", boost::wave::T_CATCH },
{ "char", boost::wave::T_CHAR },
{ "class", boost::wave::T_CLASS },
{ "const_cast", boost::wave::T_CONSTCAST },
{ "const", boost::wave::T_CONST },
{ "continue", boost::wave::T_CONTINUE },
{ "default", boost::wave::T_DEFAULT },
{ "delete", boost::wave::T_DELETE },
{ "do", boost::wave::T_DO },
{ "double", boost::wave::T_DOUBLE },
{ "dynamic_cast", boost::wave::T_DYNAMICCAST },
{ "else", boost::wave::T_ELSE },
{ "enum", boost::wave::T_ENUM },
{ "explicit", boost::wave::T_EXPLICIT },
{ "export", boost::wave::T_EXPORT },
{ "extern", boost::wave::T_EXTERN },
{ "float", boost::wave::T_FLOAT },
{ "for", boost::wave::T_FOR },
{ "friend", boost::wave::T_FRIEND },
{ "goto", boost::wave::T_GOTO },
{ "if", boost::wave::T_IF },
{ "inline", boost::wave::T_INLINE },
{ "int", boost::wave::T_INT },
{ "long", boost::wave::T_LONG },
{ "mutable", boost::wave::T_MUTABLE },
{ "namespace", boost::wave::T_NAMESPACE },
{ "new", boost::wave::T_NEW },
{ "operator", boost::wave::T_OPERATOR },
{ "private", boost::wave::T_PRIVATE },
{ "protected", boost::wave::T_PROTECTED },
{ "public", boost::wave::T_PUBLIC },
{ "register", boost::wave::T_REGISTER },
{ "reinterpret_cast", boost::wave::T_REINTERPRETCAST },
{ "return", boost::wave::T_RETURN },
{ "short", boost::wave::T_SHORT },
{ "signed", boost::wave::T_SIGNED },
{ "sizeof", boost::wave::T_SIZEOF },
{ "static_cast", boost::wave::T_STATICCAST },
{ "static", boost::wave::T_STATIC },
{ "struct", boost::wave::T_STRUCT },
{ "switch", boost::wave::T_SWITCH },
{ "template", boost::wave::T_TEMPLATE },
{ "this", boost::wave::T_THIS },
{ "throw", boost::wave::T_THROW },
{ "try", boost::wave::T_TRY },
{ "typedef", boost::wave::T_TYPEDEF },
{ "typeid", boost::wave::T_TYPEID },
{ "typename", boost::wave::T_TYPENAME },
{ "union", boost::wave::T_UNION },
{ "unsigned", boost::wave::T_UNSIGNED },
{ "using", boost::wave::T_USING },
{ "virtual", boost::wave::T_VIRTUAL },
{ "void", boost::wave::T_VOID },
{ "volatile", boost::wave::T_VOLATILE },
{ "wchar_t", boost::wave::T_WCHART },
{ "while", boost::wave::T_WHILE },
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
{ "__int8", boost::wave::T_MSEXT_INT8 },
{ "__int16", boost::wave::T_MSEXT_INT16 },
{ "__int32", boost::wave::T_MSEXT_INT32 },
{ "__int64", boost::wave::T_MSEXT_INT64 },
{ "__based", boost::wave::T_MSEXT_BASED },
{ "_based", boost::wave::T_MSEXT_BASED },
{ "__declspec", boost::wave::T_MSEXT_DECLSPEC },
{ "_declspec", boost::wave::T_MSEXT_DECLSPEC },
{ "__fastcall", boost::wave::T_MSEXT_FASTCALL },
{ "_fastcall", boost::wave::T_MSEXT_FASTCALL },
{ "__stdcall", boost::wave::T_MSEXT_STDCALL },
{ "_stdcall", boost::wave::T_MSEXT_STDCALL },
{ "__try", boost::wave::T_MSEXT_TRY },
{ "__except", boost::wave::T_MSEXT_EXCEPT },
{ "__finally", boost::wave::T_MSEXT_FINALLY },
{ "__leave", boost::wave::T_MSEXT_LEAVE },
{ "__inline", boost::wave::T_MSEXT_INLINE },
{ "_inline", boost::wave::T_MSEXT_INLINE },
{ "__asm", boost::wave::T_MSEXT_ASM },
{ "_asm", boost::wave::T_MSEXT_ASM },
{ "#region", boost::wave::T_MSEXT_PP_REGION },
{ "#endregion", boost::wave::T_MSEXT_PP_ENDREGION },
#endif // BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
{ "#define", boost::wave::T_PP_DEFINE },
{ "#ifdef", boost::wave::T_PP_IFDEF },
{ "#ifndef", boost::wave::T_PP_IFNDEF },
{ "#if", boost::wave::T_PP_IF },
{ "#else", boost::wave::T_PP_ELSE },
{ "#elif", boost::wave::T_PP_ELIF },
{ "#endif", boost::wave::T_PP_ENDIF },
{ "#error", boost::wave::T_PP_ERROR },
{ "#include \"some_header\"", boost::wave::T_PP_QHEADER },
{ "#include <some_header>", boost::wave::T_PP_HHEADER },
// { "#include SOME_HEADER", boost::wave::T_PP_INCLUDE },
{ "#line", boost::wave::T_PP_LINE },
{ "#pragma", boost::wave::T_PP_PRAGMA },
{ "#undef", boost::wave::T_PP_UNDEF },
{ "#warning", boost::wave::T_PP_WARNING },
{ "some_identifier_1234", boost::wave::T_IDENTIFIER },
{ "some_identifier_\\u00d4", boost::wave::T_IDENTIFIER },
{ "some_identifier_\\U000000d4", boost::wave::T_IDENTIFIER },
{ ".1", boost::wave::T_FLOATLIT },
{ "1.1", boost::wave::T_FLOATLIT },
{ "1.", boost::wave::T_FLOATLIT },
{ ".1e+1", boost::wave::T_FLOATLIT },
{ ".1E-1", boost::wave::T_FLOATLIT },
{ ".1e1", boost::wave::T_FLOATLIT },
{ "1e1", boost::wave::T_FLOATLIT },
{ "1e1f", boost::wave::T_FLOATLIT },
{ "1e1L", boost::wave::T_FLOATLIT },
{ "1.1e1fl", boost::wave::T_FLOATLIT },
{ "1.e1LF", boost::wave::T_FLOATLIT },
{ "1234LL", boost::wave::T_LONGINTLIT },
{ "1234L", boost::wave::T_INTLIT },
{ "1234", boost::wave::T_INTLIT },
{ " ", boost::wave::T_SPACE },
{ "\t", boost::wave::T_SPACE },
{ "\n", boost::wave::T_NEWLINE },
{ "##", boost::wave::T_POUND_POUND },
{ "\?\?=\?\?=", boost::wave::T_POUND_POUND_TRIGRAPH },
{ "#", boost::wave::T_POUND },
{ "\?\?=", boost::wave::T_POUND_TRIGRAPH },
{ "\?\?/", boost::wave::T_ANY_TRIGRAPH },
{ "?", boost::wave::T_QUESTION_MARK },
{ NULL, boost::wave::token_id(0) }
};

View File

@@ -1,85 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// system headers
#include <string>
#include <iostream>
#include <limits>
#include <boost/wave/wave_config.hpp>
#include <boost/detail/lightweight_test.hpp>
#if defined(TESTLEXERS_TIMING)
#include "high_resolution_timer.hpp"
#endif
// include the Re2C lexer related stuff
#include <boost/wave/cpplexer/cpp_lex_token.hpp> // token type
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp> // lexer type
typedef boost::wave::cpplexer::lex_token<> token_type;
typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type;
///////////////////////////////////////////////////////////////////////////////
// include test data
#include "cpp_tokens.hpp"
///////////////////////////////////////////////////////////////////////////////
int
main(int argc, char *argv[])
{
try {
token_type::position_type pos("<testdata>");
#if defined(TESTLEXERS_TIMING)
boost::high_resolution_timer tim;
for (int i = 0; i < 1000; ++i) {
#endif
for (lexem const* data = lexems; NULL != data->token; ++data) {
// feed the token to the lexer
token_type::string_type instr(data->token);
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
boost::wave::support_long_long);
lexer_type end = lexer_type();
// verify the correct outcome of the tokenisation
#if defined(TESTLEXERS_VERBOSE)
std::cerr << boost::wave::get_token_name(data->id) << std::endl;
#endif
if (data->id != boost::wave::token_id(*it)) {
BOOST_TEST(data->id == boost::wave::token_id(*it));
std::cerr << "Expected: "
<< boost::wave::get_token_name(data->id);
std::cerr << ", found: "
<< boost::wave::get_token_name(boost::wave::token_id(*it))
<< std::endl;
}
BOOST_TEST(++it != end);
BOOST_TEST(boost::wave::T_EOF == boost::wave::token_id(*it));
}
#if defined(TESTLEXERS_TIMING)
}
std::cout << tim.elapsed() << " [s]" << std::endl;
#endif
}
catch (boost::wave::cpplexer::lexing_exception &e) {
// some lexing error
std::cerr
<< "test_re2c_lexer: "
<< e.description() << std::endl;
return (std::numeric_limits<int>::max)() - 1;
}
return boost::report_errors();
}

View File

@@ -1,90 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// system headers
#include <string>
#include <iostream>
#include <limits>
#include <boost/wave/wave_config.hpp>
#include <boost/detail/lightweight_test.hpp>
#if defined(TESTLEXERS_TIMING)
#include "high_resolution_timer.hpp"
#endif
///////////////////////////////////////////////////////////////////////////////
// include the Slex lexer related stuff
#include <libs/wave/samples/cpp_tokens/slex_token.hpp> // token type
#include <libs/wave/samples/cpp_tokens/slex/cpp_slex_lexer.hpp> // lexer type
typedef boost::wave::cpplexer::slex_token<> token_type;
typedef boost::wave::cpplexer::slex::slex_iterator<token_type> lexer_type;
// This instantiates the correct 'new_lexer' function, which generates the
// C++ lexer used in this test.
template struct boost::wave::cpplexer::slex::new_lexer_gen<
std::string::iterator>;
///////////////////////////////////////////////////////////////////////////////
// include test data
#include "cpp_tokens.hpp"
///////////////////////////////////////////////////////////////////////////////
int
main(int argc, char *argv[])
{
try {
token_type::position_type pos("<testdata>");
#if defined(TESTLEXERS_TIMING)
boost::high_resolution_timer tim;
for (int i = 0; i < 1000; ++i) {
#endif
for (lexem const* data = lexems; NULL != data->token; ++data) {
// feed the token to the lexer
token_type::string_type instr(data->token);
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
boost::wave::support_long_long);
lexer_type end = lexer_type();
// verify the correct outcome of the tokenisation
#if defined(TESTLEXERS_VERBOSE)
std::cerr << boost::wave::get_token_name(data->id) << std::endl;
#endif
if (data->id != boost::wave::token_id(*it)) {
BOOST_TEST(data->id == boost::wave::token_id(*it));
std::cerr << "Expected: "
<< boost::wave::get_token_name(data->id);
std::cerr << ", found: "
<< boost::wave::get_token_name(boost::wave::token_id(*it))
<< std::endl;
}
BOOST_TEST(++it != end);
BOOST_TEST(boost::wave::T_EOF == boost::wave::token_id(*it));
}
#if defined(TESTLEXERS_TIMING)
}
std::cout << tim.elapsed() << " [s]" << std::endl;
#endif
}
catch (boost::wave::cpplexer::lexing_exception &e) {
// some lexing error
std::cerr
<< "test_slex_lexer: "
<< e.description() << std::endl;
return (std::numeric_limits<int>::max)() - 1;
}
return boost::report_errors();
}

View File

@@ -1,235 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_WAVE_LIBS_WAVE_TEST_CMD_LINE_UTILS_HPP)
#define BOOST_WAVE_LIBS_WAVE_TEST_CMD_LINE_UTILS_HPP
#include <string>
#include <fstream>
#include <vector>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/any.hpp>
///////////////////////////////////////////////////////////////////////////////
// forward declarations only
namespace cmd_line_utils
{
class include_paths;
}
namespace boost { namespace program_options
{
void validate(boost::any &v, std::vector<std::string> const &s,
cmd_line_utils::include_paths *, int);
}} // boost::program_options
///////////////////////////////////////////////////////////////////////////////
#include <boost/program_options.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace cmd_line_utils {
namespace po = boost::program_options;
///////////////////////////////////////////////////////////////////////////
// Additional command line parser which interprets '@something' as an
// option "config-file" with the value "something".
inline std::pair<std::string, std::string>
at_option_parser(std::string const& s)
{
if ('@' == s[0])
return std::make_pair(std::string("config-file"), s.substr(1));
else
return std::pair<std::string, std::string>();
}
///////////////////////////////////////////////////////////////////////////
// class, which keeps the include file information read from the options
class include_paths
{
public:
include_paths() : seen_separator(false) {}
std::vector<std::string> paths; // stores user paths
std::vector<std::string> syspaths; // stores system paths
bool seen_separator; // options contain a '-I-' option
// Function which validates additional tokens from the given option.
static void
validate(boost::any &v, std::vector<std::string> const &tokens)
{
if (v.empty())
v = boost::any(include_paths());
include_paths *p = boost::any_cast<include_paths>(&v);
BOOST_ASSERT(NULL != p);
// Assume only one path per '-I' occurrence.
std::string const& t = po::validators::get_single_string(tokens);
if (t == "-") {
// found -I- option, so switch behaviour
p->seen_separator = true;
}
else if (p->seen_separator) {
// store this path as a system path
p->syspaths.push_back(t);
}
else {
// store this path as an user path
p->paths.push_back(t);
}
}
};
///////////////////////////////////////////////////////////////////////////
// Read all options from a given config string, parse and add them to the
// given variables_map
inline void
read_config_options(int debuglevel, std::string const &indata,
po::options_description const &desc, po::variables_map &vm)
{
if (9 == debuglevel) {
std::cerr << "read_config_options: reading config options"
<< std::endl;
}
std::istringstream istrm(indata);
std::vector<std::string> options;
std::string line;
while (std::getline(istrm, line)) {
// skip empty lines
std::string::size_type pos = line.find_first_not_of(" \t");
if (pos == std::string::npos)
continue;
// skip comment lines
if ('#' != line[pos])
options.push_back(line);
}
if (options.size() > 0) {
if (9 == debuglevel) {
std::cerr << "read_config_options: options size is: "
<< (int)options.size() << std::endl;
}
// (the (int) cast is to make the True64 compiler happy)
using namespace boost::program_options::command_line_style;
po::store(po::command_line_parser(options)
.options(desc).style((int)unix_style).run(), vm);
po::notify(vm);
}
if (9 == debuglevel) {
std::cerr << "read_config_options: succeeded to read config options"
<< std::endl;
}
}
///////////////////////////////////////////////////////////////////////////
// Read all options from a given config file, parse and add them to the
// given variables_map
inline bool
read_config_file(int debuglevel, std::string const &filename,
po::options_description const &desc, po::variables_map &vm)
{
if (9 == debuglevel) {
std::cerr << "read_config_file: reading config options"
<< std::endl;
}
std::ifstream ifs(filename.c_str());
if (!ifs.is_open()) {
std::cerr
<< "testwave: " << filename
<< ": command line warning: config file not found"
<< std::endl;
return false;
}
// parse the file and extract all given arguments and options
std::vector<std::string> options;
std::string line;
while (std::getline(ifs, line)) {
// skip empty lines
std::string::size_type pos = line.find_first_not_of(" \t");
if (pos == std::string::npos)
continue;
// skip comment lines
if ('#' != line[pos])
options.push_back(line);
}
if (options.size() > 0) {
if (9 == debuglevel) {
std::cerr << "read_config_file: options size is: "
<< (int)options.size() << std::endl;
}
// treat positional arguments as --input parameters
po::positional_options_description p;
p.add("input", -1);
// parse the vector of lines and store the results into the given
// variables map
// (the (int) cast is to make the True64 compiler happy)
using namespace boost::program_options::command_line_style;
po::store(po::command_line_parser(options)
.options(desc).positional(p).style((int)unix_style).run(), vm);
po::notify(vm);
}
if (9 == debuglevel) {
std::cerr << "read_config_file: succeeded to read config options"
<< std::endl;
}
return true;
}
///////////////////////////////////////////////////////////////////////////
// predicate to extract all positional arguments from the command line
struct is_argument
{
bool operator()(po::option const &opt)
{
return (opt.position_key == -1) ? true : false;
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace cmd_line_utils
///////////////////////////////////////////////////////////////////////////////
//
// Special validator overload, which allows to handle the -I- syntax for
// switching the semantics of an -I option.
//
// This must be injected into the boost::program_options namespace
//
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace program_options {
inline void
validate(boost::any &v, std::vector<std::string> const &s,
cmd_line_utils::include_paths *, int)
{
cmd_line_utils::include_paths::validate(v, s);
}
}} // namespace boost::program_options
#endif // !defined(BOOST_WAVE_LIBS_WAVE_TEST_CMD_LINE_UTILS_HPP)

View File

@@ -1,16 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// Test macro expansion order
#define A(x, y) x, y
#define B(x, y) [x][y]
#define C(x) B(x)
//R #line 16 "t_1_001.cpp"
C( A(2, 3) ) //R [2][3]

View File

@@ -1,16 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
//O -DTEST
#if defined(TEST)
#define ABC() 1
#endif
//R #line 16 "t_1_002.cpp"
ABC() //R 1

View File

@@ -1,29 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// Tests macro expansion order in conjunction with the need to skip expansion
// of the same macro as it is currently expanded.
#define CONCAT(a, b) a ## b
#define CONCAT_INDIRECT() CONCAT
//R #line 18 "t_1_003.cpp"
//R CONCAT(1, 2)
CONCAT(CON, CAT)(1, 2)
//R #line 21 "t_1_003.cpp"
//R CONCAT(1, 2)
CONCAT(CON, CAT(1, 2))
//R #line 24 "t_1_003.cpp"
//R 12
CONCAT(CONCAT_, INDIRECT)()(1, 2)
//R #line 27 "t_1_003.cpp"
//R CONCAT(1, 2)
CONCAT(CONCAT_, INDIRECT())(1, 2)
//E t_1_003.cpp(29): error: pasting the following two tokens does not give a valid preprocessing token: "1" and "CONCAT"
CONCAT(1, CONCAT(2, 3))

View File

@@ -1,32 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
//O --variadics
// Tests macro expansion order in conjunction with the need to skip expansion
// of the same macro as it is currently expanded.
#define CONCAT(a, b) a ## b
#define CONCAT_INDIRECT() CONCAT
//R #line 20 "t_1_004.cpp"
//R CONCAT(1, 2)
CONCAT(CON, CAT)(1, 2)
//R #line 23 "t_1_004.cpp"
//R CONCAT(1, 2)
CONCAT(CON, CAT(1, 2))
//R #line 26 "t_1_004.cpp"
//R 12
CONCAT(CONCAT_, INDIRECT)()(1, 2)
//R #line 29 "t_1_004.cpp"
//R CONCAT(1, 2)
CONCAT(CONCAT_, INDIRECT())(1, 2)
//R #line 32 "t_1_004.cpp"
//R 1 CONCAT(2, 3)
CONCAT(1, CONCAT(2, 3))

View File

@@ -1,17 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// Tests macro expansion order.
#define A() B
#define B(x) x
//R #line 16 "t_1_005.cpp"
A()(123) //R 123

View File

@@ -1,23 +0,0 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// Tests the correctness of parameter replacement, if the parameter is
// adjacent to an operator '##'.
#define CONCAT(a, b) PRIMITIVE_CONCAT(a, b)
#define PRIMITIVE_CONCAT(a, b) a ## b
//R #line 18 "t_1_006.cpp"
//R 123
CONCAT(1, PRIMITIVE_CONCAT(2, 3))
//R #line 21 "t_1_006.cpp"
//R 123
CONCAT(1, CONCAT(2, 3))
//E t_1_006.cpp(23): error: pasting the following two tokens does not give a valid preprocessing token: "1" and "CONCAT"
PRIMITIVE_CONCAT(1, CONCAT(2, 3))

Some files were not shown because too many files have changed in this diff Show More