spirit/classic/doc/escape_char_parser.html
Joel de Guzman 994d4e48cc moving stuff to classic spirit
[SVN r44163]
2008-04-10 23:51:31 +00:00

89 lines
4.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Escape Character Parser</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" background="theme/bkd2.gif" cellspacing="2">
<tr>
<td width="10" height="49"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</b></font></td>
<td width="85%" height="49"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Escape Character Parser</b></font></td>
<td width="112" height="49"><a href="http://spirit.sf.net"><img src="theme/spirit.gif" width="112" height="48" 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="switch_parser.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="loops.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p><a name="escape_char_parser"></a>The Escape Character Parser is a utility
parser, which parses escaped character sequences used in C/C++,
LEX or Perl regular expressions. Combined with the confix_p utility parser, it is useful for parsing C/C++ strings containing double quotes and other escaped
characters:</p>
<pre> confix_p<span class="special">(</span><em class="literal">'"'</em><span class="special">,</span> <span class="special">*</span>c_escape_ch_p<span class="special">,</span> <em><span class="literal">'"</span></em><span class="literal"><em>'</em></span><span class="special">)</span></pre>
<p>There are two different types of the Escape Character Parser:
<tt>c_escape_ch_p</tt>, which parses C/C++ escaped character sequences and
<tt>lex_escape_ch_p</tt>, which parses LEX style escaped character sequences.
The following table shows the valid character sequences understood by these
utility parsers.</p>
<table width="90%" border="0" align="center">
<tr>
<td colspan="2" class="table_title"><b>Summary of valid escaped character
sequences</b></td>
</tr>
<tr>
<td width="29%" height="27" class="table_cells"><b>c_escape_ch_p</b></td>
<td width="71%" class="table_cells"><p><code>\b, \t, \n, \f, \r, \\, \&quot;,
\', \xHH, \OOO</code><br>
where: H is some hexadecimal digit (0..9, a..f, A..F) and O is some octal
digit (0..7)</p></td>
</tr>
<tr>
<td height="27" class="table_cells"><strong>lex_escape_ch_p</strong></td>
<td class="table_cells">
<p>all C/C++ escaped character sequences as described above and additionally
any other character, which follows a backslash</p>
</td>
</tr>
</table>
<p>If there is a semantic action attached directly to the Escape Character Parser,
all valid escaped characters are converted to their character equivalent
(i.e. a backslash followed by a 'r' is converted to '\r'), which is
fed to the attached actor. The number of hexadecimal
or octal digits parsed depends on the size of one input character. An
overflow will be detected and will generate a non-match. lex_escape_ch_p
will strip the leading backslash for all character
sequences which are not listed as valid C/C++ escape sequences when passing
the unescaped character to an attached action.</p>
<p>Please note though, that if there is a semantic action attached to an
outermost parser (for instance as in <tt>(*c_escape_ch_p)[some_actor]</tt>,
where the action is attached to the kleene star generated parser) no conversion
takes place at the moment, but nevertheless the escaped characters are parsed
correctly. This limitation will be removed in a future version of the library.</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="switch_parser.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
<td width="30"><a href="loops.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<br>
<hr size="1">
<p class="copyright">Copyright &copy; 2001-2002 Daniel C. Nuffer<br>
Copyright &copy; 2003 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>
</body>
</html>