Escape Character Parser 转义字符分析器 |
转义字符分析器属于工具分析器,用于分析C/C++、LEX或Perl正则表达式中的转移字符串。将之与confix_p工具分析器共同使用,在分析C/C++中由引号引起的字符串方面很有用。
confix_p('"', *c_escape_ch_p, '"')
There are two different types of the Escape Character Parser: c_escape_ch_p, which parses C/C++ escaped character sequences and lex_escape_ch_p, which parses LEX style escaped character sequences. The following table shows the valid character sequences understood by these utility parsers.
有两种不同的转义字符分析器:c_escape_ch_p,分析C/C++转移字符串,和lex_escape_ch_p,分析LEX风格的转移字符串。下面的表格说明了这些工具分析器所能有效识别的转移字符串。
Summary of valid escaped character sequences 有效转移字符串集 | |
c_escape_ch_p |
这里H是二进制数字(0..9, a..f, A..F)而O是八进制数(0..7) |
lex_escape_ch_p | all C/C++ escaped character sequences as described above and additionally any other character, which follows a backslash 上面的所有C/C++转移字符串,以及紧随反斜线的任意字符 |
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.
如果有语义动作挂接在转移字符分析器上,被传递给挂接的动作器的所有的有效转义字符将被转换成与之等价的实际字符(比如一个反斜线后面跟着一个''将被转换为'/r')。所分析出的十六进制或者八进制数值的个数将取决于输入字符的尺寸。而溢出将被检测到并且引发一个匹配失败。 lex_escape_ch_p在分析尚未分析的字符并传递给语义动作时,对所有带反斜线但不是C/C++中有效的转移字符串的字符串,将忽略开头的反斜线。
Please note though, that if there is a semantic action attached to an outermost parser (for instance as in (*c_escape_ch_p)[some_actor], 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.
请注意,如果语义动作挂接在最外围的分析器上(比如类似(*c_escape_ch_p)[some_actor],语义动作挂接在克林星分析器上)将不会产生字符的转换,取而代之的是直接把字符串传递给语义动作。这个限制在以后的版本中将被清除。
Copyright © 2001-2002 Daniel C. Nuffer
Copyright © 2003 Hartmut Kaiser
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)
Powered by Zoundry