escape_char_parser.html 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Escape Character Parser</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="theme/style.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body>
  9. <table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
  10. <tr>
  11. <td width="10" height="49"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</b></font></td>
  12. <td width="85%" height="49"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Escape Character Parser</b></font></td>
  13. <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>
  14. </tr>
  15. </table>
  16. <br>
  17. <table border="0">
  18. <tr>
  19. <td width="10"></td>
  20. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  21. <td width="30"><a href="switch_parser.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  22. <td width="30"><a href="loops.html"><img src="theme/r_arr.gif" border="0"></a></td>
  23. </tr>
  24. </table>
  25. <p><a name="escape_char_parser"></a>The Escape Character Parser is a utility
  26. parser, which parses escaped character sequences used in C/C++,
  27. 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
  28. characters:</p>
  29. <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>
  30. <p>There are two different types of the Escape Character Parser:
  31. <tt>c_escape_ch_p</tt>, which parses C/C++ escaped character sequences and
  32. <tt>lex_escape_ch_p</tt>, which parses LEX style escaped character sequences.
  33. The following table shows the valid character sequences understood by these
  34. utility parsers.</p>
  35. <table width="90%" border="0" align="center">
  36. <tr>
  37. <td colspan="2" class="table_title"><b>Summary of valid escaped character
  38. sequences</b></td>
  39. </tr>
  40. <tr>
  41. <td width="29%" height="27" class="table_cells"><b>c_escape_ch_p</b></td>
  42. <td width="71%" class="table_cells"><p><code>\b, \t, \n, \f, \r, \\, \&quot;,
  43. \', \xHH, \OOO</code><br>
  44. where: H is some hexadecimal digit (0..9, a..f, A..F) and O is some octal
  45. digit (0..7)</p></td>
  46. </tr>
  47. <tr>
  48. <td height="27" class="table_cells"><strong>lex_escape_ch_p</strong></td>
  49. <td class="table_cells">
  50. <p>all C/C++ escaped character sequences as described above and additionally
  51. any other character, which follows a backslash</p>
  52. </td>
  53. </tr>
  54. </table>
  55. <p>If there is a semantic action attached directly to the Escape Character Parser,
  56. all valid escaped characters are converted to their character equivalent
  57. (i.e. a backslash followed by a 'r' is converted to '\r'), which is
  58. fed to the attached actor. The number of hexadecimal
  59. or octal digits parsed depends on the size of one input character. An
  60. overflow will be detected and will generate a non-match. lex_escape_ch_p
  61. will strip the leading backslash for all character
  62. sequences which are not listed as valid C/C++ escape sequences when passing
  63. the unescaped character to an attached action.</p>
  64. <p>Please note though, that if there is a semantic action attached to an
  65. outermost parser (for instance as in <tt>(*c_escape_ch_p)[some_actor]</tt>,
  66. where the action is attached to the kleene star generated parser) no conversion
  67. takes place at the moment, but nevertheless the escaped characters are parsed
  68. correctly. This limitation will be removed in a future version of the library.</p>
  69. <table border="0">
  70. <tr>
  71. <td width="10"></td>
  72. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  73. <td width="30"><a href="switch_parser.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  74. <td width="30"><a href="loops.html"><img src="theme/r_arr.gif" border="0"></a></td>
  75. </tr>
  76. </table>
  77. <br>
  78. <hr size="1">
  79. <p class="copyright">Copyright &copy; 2001-2002 Daniel C. Nuffer<br>
  80. Copyright &copy; 2003 Hartmut Kaiser <br>
  81. <br>
  82. <font size="2">Use, modification and distribution is subject to the Boost Software
  83. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  84. http://www.boost.org/LICENSE_1_0.txt) </font> </p>
  85. </body>
  86. </html>