2
0
mirror of https://github.com/boostorg/wave.git synced 2026-01-26 07:02:23 +00:00
Files
wave/doc/class_reference_lexer.html
2004-01-26 06:23:58 +00:00

103 lines
6.0 KiB
HTML

<!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://spirit.sf.net"><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_tracepolicy.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. </p>
<h2><a name="header_synopsis"></a>Wave lexer
synopsis</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_t</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> IteratorT&gt;
<a href="class_reference_lexer.html#constructor">lex_iterator</a>(IteratorT <span class="keyword">const</span> &amp;first, IteratorT <span class="keyword">const</span> &amp;last
<span class="keyword">typename</span> token_t::position_t <span class="keyword">const</span> &amp;pos,
boost::wave::language_support language)
};
</pre>
<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_t</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="destructor"></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> IteratorT&gt;
lex_iterator(IteratorT <span class="keyword">const</span> &amp;first, IteratorT <span class="keyword">const</span> &amp;last,
<span class="keyword">typename</span> token_t::position_t <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_tracepolicy.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-2004 Hartmut Kaiser<br>
<br>
<font size="2">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)
</font> </p>
<span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, January 18, 2004 12:16<!-- #EndDate -->
</span></body>
</html>
<!-- #BeginDate format:fcAm1m -->Sunday, January 18, 2004 12:16<!-- #EndDate -->