[boost-doc-zh] r333 committed - Spirit库译文,由 青菜肉丝 提供,第一批

  • From: codesite-noreply@xxxxxxxxxx
  • To: boost-doc-zh-notify@xxxxxxxxxxxxx
  • Date: Thu, 17 Sep 2009 03:27:03 +0000

Revision: 333
Author: alai04
Date: Wed Sep 16 20:25:53 2009
Log: Spirit库译文,由 青菜肉丝 提供,第一批
http://code.google.com/p/boost-doc-zh/source/detail?r=333

Modified:
 /trunk/glossary/glossary.txt
 /trunk/libs/spirit/classic/doc/basic_concepts.html
 /trunk/libs/spirit/classic/doc/directives.html
 /trunk/libs/spirit/classic/doc/epsilon.html
 /trunk/libs/spirit/classic/doc/grammar.html
 /trunk/libs/spirit/classic/doc/indepth_the_parser.html
 /trunk/libs/spirit/classic/doc/indepth_the_parser_context.html
 /trunk/libs/spirit/classic/doc/indepth_the_scanner.html
 /trunk/libs/spirit/classic/doc/introduction.html
 /trunk/libs/spirit/classic/doc/numerics.html
 /trunk/libs/spirit/classic/doc/operators.html
 /trunk/libs/spirit/classic/doc/organization.html
 /trunk/libs/spirit/classic/doc/preface.html
 /trunk/libs/spirit/classic/doc/primitives.html
 /trunk/libs/spirit/classic/doc/quick_start.html
 /trunk/libs/spirit/classic/doc/rule.html
 /trunk/libs/spirit/classic/doc/scanner.html
 /trunk/libs/spirit/classic/doc/semantic_actions.html
 /trunk/libs/spirit/classic/doc/subrules.html

=======================================
--- /trunk/glossary/glossary.txt        Wed Sep  2 00:28:21 2009
+++ /trunk/glossary/glossary.txt        Wed Sep 16 20:25:53 2009
@@ -137,7 +137,15 @@

  7) graph                      //alai04
  predecessor                   前趋
-
+
+ 8) spirit
+ parser                        解析器,分析器
+ skip parser                   跳读解析器
+ parser elements               解析器基元
+ Semantic Actions              语义动作
+ primitives                    基元
+ composites                    合成件
+ actor                         动作器

 f) misc 其它
 rationale              理论注记
=======================================
--- /trunk/libs/spirit/classic/doc/basic_concepts.html Sat Oct 4 05:29:09 2008 +++ /trunk/libs/spirit/classic/doc/basic_concepts.html Wed Sep 16 20:25:53 2009
@@ -1,6 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>



@@ -47,8 +46,8 @@



-  <title>Basic Concepts</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Basic Concepts</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



@@ -67,9 +66,7 @@



-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -292,7 +289,7 @@



-<p>有几个基础概念必须理解得很清楚: 1) 解析器<strong>Parser</strong>, 2) 匹 配<strong>Match</strong>, 3) 扫描器<strong>Scanner</strong>, 和 4) 语义行为 <strong>Semantic Actions</strong>。 这些基础概念相互联系着,它们的功能融会在 框架中,形成一个统一的整体。 +<p>有几个基础概念必须理解得很清楚: 1) 解析器<strong>Parser</strong>, 2) 匹 配<strong>Match</strong>, 3) 扫描器<strong>Scanner</strong>, 和 4) 语义动作 <strong>Semantic Actions</strong>。 这些基础概念相互联系着,它们的功能融会在 框架中,形成一个统一的整体。
     </p>


@@ -389,8 +386,8 @@


<p>框架的中心是解析器。&nbsp;扫描器从头到尾地读入线性输入的数据流,然后交给 解析器进行实际的识别工作。 -根据完备定义的文法规则,解析器尝试匹配输入串。 通过一个匹配对象,解析器向客 户报告成功或者失败。 -当解析成功时,用户提供的语义行为会被自动调用。 最后,依赖于解析器的层次上下 文,和解析器给其连接的语义行为的数据,语义行为会提取出结构化信息。 +根据完备定义的文法规则,解析器尝试匹配输入串。通过一个匹配对象,解析器向客 户报告成功或者失败。 +当解析成功时,用户提供的语义行为会被自动调用。最后,语义动作从分析器中获得 结构化的信息,这些信息依赖于分析器传剃的数据和分析器所处的语境层次。
     </p>


@@ -402,7 +399,7 @@



-<p>解析器有不同的实现风格。Spirit框架捆绑了广泛的预定义解析器,有简单的也有 复杂的。 在概念上,解析器有公开约定的接口。 只要遵守约定,任何人都可以写一个 在框架中一致的解析器,这就可以和其他预定义的部分良好地合作。 关于公约的细 节,我们将在后面给出蓝图。 +<p>解析器有不同的实现风格。Spirit框架捆绑了广泛的预定义解析器,有简单的也有 复杂的。在概念上,解析器有公开约定的接口。只要遵守约定,任何人都可以写一个与 框架一致的解析器,这就可以和其他预定义的部分良好地合作。我们将在后面给出相关 接口细节的蓝图。
     </p>


@@ -414,9 +411,8 @@



-<p> 框架的客户一般不需要手写出解析器。
-Spirit有极其广泛的预定义解析器部件,涉及到语法和语义分析的方方面面。我们会 在下面的章节中检阅这些解析器。 -很罕见地,如果特定的功能没有提供,那写一个用户定义的解析器也是非常容易的事 情。&nbsp;开发新解析器部件的不费吹灰之力,造就了Spirit的可 +<p> 框架的客户一般不需要手工写出解析器。Spirit有极其广泛的预定义解析器部 件,涉及到语法和语义分析的方方面面。我们会在下面的章节中介绍这些解析器。 +很罕见地,如果特定的功能没有提供,那么写一个用户自定义的解析器也是非常容易 的事情。开发新解析器部件不费吹灰之力,这造就了Spirit的可
 扩展性。 </p>


@@ -442,7 +438,7 @@


 <p>
- Spirit的解析器分成两类: 基元<b>primitives</b> 和合成件 <b>composites</b>。 这两类的意义或多或少地相似于解析领域所谓的节点和非节 点。 基元是不可分解的原子部件。而合成件则是由几个解析器合成的,用来合成的可 以是基元,也可以是其他合成件。 为了说明这点,请考虑如下Spirit表达式: + Spirit的解析器分成两类:基元<b>primitives</b> 和合成件 <b>composites</b>。这两类的意义或多或少地类似于解析领域所谓的节点和非节点。 基元是不可分解的原子部件。而合成件则是由几个解析器合成的,用来合成的可以是基 元,也可以是其他合成件。为了说明这点,请考虑如下Spirit表达式:
     </p>


@@ -466,7 +462,7 @@


 <p>
- <tt><tt>real_p</tt></tt> 是一个可解析浮点数的基元解析器。 表达式中在 单引号内的逗号 <tt class="quotes">','</tt> 是一种简化的写法,等效于 <tt>ch_p<span class="operators">(</span><span class="quotes">','</span><span class="operators">)</span></tt>,这是另一个解 析单个字符的基元解析器。 + <tt><tt>real_p</tt></tt> 是一个可解析浮点数的基元解析器。表达式中在单 引号内的逗号 <tt class="quotes">','</tt> 是一种简化的写法,等效于 <tt>ch_p<span class="operators">(</span><span class="quotes">','</span><span class="operators">)</span></tt>,这是另一个解 析单个字符的基元解析器。
     </p>


@@ -587,7 +583,7 @@


 <p>
- 合成了一个序列解析器。 序列 <tt>sequence</tt> 解析器是一个合成件,它 包括两个解析器:左手边(lhs)一个, <tt>ch_p<span class="operators">(</span><span class="quotes">','</span><span class="operators">)</span></tt>&nbsp;;和右手边(rhs)一个, <tt>real_p</tt>。 调用这个合成件时,会按顺序转调用lhs和rhs,当两个都成功匹配 时,合成件才报告成功。 + 合成了一个序列解析器。 序列 <tt>sequence</tt> 解析器是一个合成件,它 包括两个解析器:一个左操作数(lhs),<tt>ch_p<span class="operators">(</span><span class="quotes">','</span><span class="operators">)</span></tt>;和一个右操作参数(rhs), <tt>real_p</tt>。 调用这个合成件时,会按顺序转为调用lhs和rhs,当两个都成功匹配时,合成件才会报 告成功。
     </p>


@@ -672,8 +668,7 @@


 <p>
- 序列 <tt>sequence</tt> 解析器是一个二元合成件。它由两个解析器组成。 也有一元合成件,它仅含单个子部件。 类似于二元合成件,一元合成件可以改变嵌入 子部件的行为。 一个特殊的例子是 - Kleene星号<b>Kleene star</b>。当用Kleene星号解析的时候,子部件被调用零 次或更多次。 &ldquo;零或者更多&rdquo;意味着Kleene星号总是返回一个成功的匹 配,可能是匹配到空串: "" 。 + 序列 <tt>sequence</tt> 解析器是一个二元合成件。它由两个解析器组成。也 有一元合成件,它仅含单个子部件。类似于二元合成件,一元合成件可以改变嵌入子部 件的行为。一个特殊的例子是Kleene星号。当用Kleene星号解析的时候,子部件被调用 零次或更多次。"零或者更多"意味着Kleene星号总是返回一个成功的匹配,可能是匹配 到空串:""。
     </p>


@@ -709,7 +704,7 @@



-<p>把整个上面的序列合成件包装在一个kleene星号 <tt>kleene_star</tt>里面。
+<p>把整个上面的序列合成件包装在一个 <tt>kleene_star</tt> 里面。
     </p>


@@ -793,7 +788,7 @@



-<p>最终,全部表达式组合一个<tt>real_p</tt>基元解析器和我们刚才提的 <tt>kleene_star</tt>解析器,成为另一个更高层次的序列解析器合成件。 +<p>最终,整个表达式组合了一个<tt>real_p</tt>基元解析器和我们刚才提的 <tt>kleene_star</tt>解析器,成为另一个更高层次的序列解析器合成件。
     </p>


@@ -877,7 +872,7 @@



-<p>几个简单的类,组合成一个层次化结构,则形成一个非常强大的面向对象的递归下 降解析器引擎。 这些类提供了复杂解析器需要的基础构造。最终的解析器是一个非节 点的递归下降解析器,并可能无限向前解析。 +<p>几个简单的类,组合成一个层次化结构,则形成一个非常强大的面向对象的递归下 降解析器引擎。这些类提供了复杂解析器需要的基础构造。最终的解析器是一个非节点 的递归下降解析器,并可能无限向前解析。
     </p>


@@ -889,9 +884,9 @@



-<p>自顶向下地经过结构层次。 外层的 <tt>sequence</tt>
- 解析器调用最左边的 <tt>real_p</tt> 解析器。 如果成功,接着调用 <tt>kleene_star</tt> 解析器。 这个 <tt>kleene_star</tt> 星号不断调用内部的 <tt>sequence</tt>&nbsp;直到不能匹配或者输入序列完全匹配。 在此过程内部, <tt>ch_p(',')</tt> 解析器和 - <tt>real_p</tt> 解析器顺序调用。 下面的图描述函数调用过程,有点类似 Pascal语法图。
+<p>自顶向下地经过结构层次。外层的 <tt>sequence</tt>
+ 解析器调用最左边的 <tt>real_p</tt> 解析器。 如果成功,接着调用 <tt>kleene_star</tt> 解析器。 这个 <tt>kleene_star</tt> 星号不断调用内部的 <tt>sequence</tt>&nbsp;直到不能匹配或者输入序列完全匹配。在此过程内部, <tt>ch_p(',')</tt> 解析器和 + <tt>real_p</tt> 解析器被顺序调用。下面的图描述函数调用过程,有点类似 Pascal语法图。
     </p>


@@ -975,7 +970,7 @@



-<p>对象的可递归的嵌入和合成的适应性,开辟了文本解析的道路。 子类很容易构造 出任意复杂的聚合和算法。 复杂的解析器可用几个简单的类来组合出来。 +<p>对象的可递归嵌入和递归的合成,开辟了文本解析的道路。子类很容易构造出任意 复杂的聚合和算法。复杂的解析器可用几个简单的类来组合出来。
     </p>


@@ -987,7 +982,7 @@



-<p>框架被设计成完全无限制的和可扩充的。 在任意时候都可以加入新的基元和合成 件,无论复杂或简单。 合成件在编译期生成。 这是可能的,通过C++表达式模板和模 板元编程的灵活的表达性。 +<p>框架被设计成完全无限制的和可扩充的。在任意时候都可以加入新的基元和合成 件,无论复杂或简单。合成件在编译期生成。借助于C++表达式模板和模板元编程的灵 活的表达性,这是可实现的。
     </p>


@@ -1000,8 +995,7 @@


 <p>
- 结果就是一个基元和小合成件的组合。 这种嵌入式策略给我们能建造层次结 构,去完全模拟任意复杂的EBNF表达式。
-      稍后,我们将见到更多基元和合成件模块。
+ 结果就是一个基元和小合成件的组合。这种嵌入式策略让我们能够建造层次结 构,去完全模拟任意复杂的EBNF表达式。稍后,我们将见到更多基元和合成件模块。
     </p>


@@ -1026,9 +1020,9 @@



-<p>像解析器一样,扫描器也是一个抽象的概念。 扫描器的任务是给解析器提供连续 的输入数据流。 -扫描器有两个STL相容的前向迭代组成,first和last,其中first按引用传递,last按 值传递。 -first按引用传递是为了允许解析器进行重定位。 有一系列规范规定了扫描器的行 为。 解析器从扫描器提取出数据,然后根据它的成员函数恰当地定位输入迭代器。 </p> +<p>像解析器一样,扫描器也是一个抽象的概念。扫描器的任务是给解析器提供连续的 输入数据流。 +扫描器包含两个STL相容的前向迭代器,first和last,其中first以引用方式保 存,last则按值方式保存。first按引用方式保存是为了 +允许解析器进行重定位。有一系列规范规定了扫描器的行为。解析器从扫描器提取出 数据,然后根据它的成员函数恰当地定位输入迭代器。 </p>



@@ -1039,10 +1033,10 @@



-<p>在大多数情况下,我们不需要知道这些复杂的技法。 但是,如果想写与Spirit一 致的解析器,知道扫描器的基础的API是需要的。 -扫描器的API概要在独立的章节中描述。 另外,为了高级用户和规避使用中潜在的危 险,一整章会用来介绍扫描器的内幕。 -扫描器采用的方针使Spirit非常灵活和可扩充。 例如,可以修改一些政策来过滤数 据。 -一个现实的例子是有一个忽略大小写的扫描器方针,在解析大小写不敏感的数据时很 有用。 另一个例子是有一个跳过输入空白的扫描器政策。 </p> +<p>在大多数情况下,我们不需要知道这些复杂的技法。但是,如果想写一个与 Spirit一致的解析器,那么知道扫描器的基础的API是需要的。 +扫描器的API概要在单独的章节中描述。另外,为了高级用户和规避使用中潜在的危 险,我们有一整章来介绍扫描器的内幕。采用
+扫描器的策略使Spirit非常灵活和可扩充。例如,可以修改一些策略来过滤数据。
+一个现实的例子是有一个忽略大小写的扫描器策略,在解析大小写不敏感的数据时很 有用。另一个例子是有一个跳过输入空白的扫描器策略。 </p>



@@ -1066,9 +1060,7 @@



-<p>解析器有一个概念上的解析成员函数,接收一个扫描器输入,返回一个匹配对 象。 匹配对象主要的作用是向调用者报告解析的成功(或失败);也就是,当解析成 功它的值为真,反之为假。 - 如果解析器成功,匹配对象也被要求报告成功匹配的字符个数(用 <tt>match.length()</tt>)。 - 如果匹配成功,长度是非负的,还有典型的解析失败的长度是-1。零长度是完 全合法的并且仍然代表一个成功匹配。 +<p>解析器有一个概念上的 parse 成员函数,接收一个扫描器输入,返回一个匹配对 象。匹配对象主要的作用是向调用者报告解析的成功(或失败);也就是说,当解析成 功时它的值为真,反之为假。如果解析器成功,匹配对象也被要求报告成功匹配的字符 个数(用<tt>match.length()</tt>)。如果匹配成功,长度是非负的,还有典型的解 析失败的长度是-1。零长度是完全合法的并且仍然代表一个成功匹配。
     </p>


@@ -1080,7 +1072,7 @@



-<p>解析器可能有相关的属性数据。 例如,real_p解析器有一个相关的数值属性。 这 个属性就是解析出的数值,它会被传递到返回的匹配对象。 我们就可从匹配对象中取 得此数值。 这个数据仅仅在解析成功时有效。 +<p>解析器可能有相关的属性数据。例如,real_p解析器有一个相关的数值属性。这个 属性就是解析出的数值,它会被传递到返回的匹配对象。我们就可从匹配对象中取得此 数值。这个数据仅仅在解析成功时有效。
     </p>


@@ -1092,8 +1084,7 @@



-<h2>语义行为
-    </h2>
+<h2>语义动作</h2>



@@ -1104,7 +1095,7 @@



-<p>一个合成件形成了一个层次结构。 解析过程从最高层父解析器开始,把解析任务 委托和分配到子解析器,然后到儿子再到儿子的儿子,一直到达一个基元解析器。 通 过在这个层次中缚上语义行为,我们可以有效地从扁平的线性输入构造出一个结构表 示。 这就是解析器本质上的作用。 +<p>一个合成件形成了一个层次结构。解析过程从最高层父解析器开始,把解析任务委 派和分配到子解析器,然后到子节点再到子节点的子节点,一直到达一个基元解析器。 通过在这个层次中绑上语义动作,我们可以有效地从扁平的线性输入构造出一个结构表 示。这就是解析器本质上的作用。
     </p>


@@ -1141,7 +1132,7 @@


 <p>
- 通过在real_p解析器上挂接一个函数(或者函数子),我们可以从输入中提取 数值: + 通过在real_p解析器上挂接一个函数(或者仿函数),我们可以从输入中提取 数值:
     </p>


@@ -1236,7 +1227,7 @@



-<p>其中 <tt>f</tt> 是一个单输入函数。 代码 <tt><span class="operators">[&amp;</span>f<span class="operators">]</span></tt> 在解析 器上挂接了一个函数,使当<tt>real_p</tt>识别一个合法的数值时,将调用 <tt>f</tt>函数。 然后让函数决定做恰当的事情。 例如,它可以把数值填充进一个 vector向量。 又或者,如果语法稍微改变,用<tt class="quotes">'+'</tt>代替<tt class="quotes">','</tt>,那么则得到一个求和的简单计算器。 函数<tt>f</tt> 可 以设计成迭加所有的输入数值。<br> +<p>其中 <tt>f</tt> 是一个单输入函数。代码 <tt><span class="operators">[&amp;</span>f<span class="operators">]</span></tt> 在解析 器上挂接了一个函数,使当<tt>real_p</tt>识别一个合法的数值时,将调用 <tt>f</tt>函数。然后让函数决定做恰当的事情。 例如,它可以把数值填充进一个 vector向量。又或者,如果语法稍微改变,用<tt class="quotes">'+'</tt>代替<tt class="quotes">','</tt>,那么则得到一个求和的简单计算器。 函数<tt>f</tt> 可 以设计成对所有的输入数值进行相加。<br>



@@ -1375,7 +1366,7 @@
 <hr size="1">

 <p class="copyright">
-      Copyright &copy; 1998-2003 Joel de Guzman<br>
+      Copyright (c) 1998-2003 Joel de Guzman<br>



@@ -1422,5 +1413,4 @@



-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/directives.html      Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/directives.html      Wed Sep 16 20:25:53 2009
@@ -1,35 +1,33 @@
-<html>
-<head>
-<title>Directives</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>Directives</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Directives</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>Directives 指示符</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="epsilon.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="scanner.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
-<p>Parser directives have the form: <b>directive[expression]</b></p>
+</tbody></table>
+<p>Parser directives have the form: <b>directive[expression]</b><br>分析器 指示符具有如下形式:<b>directive[expression]</b></p> <p>A directive modifies the behavior of its enclosed expression, essentially <em>decorating</em> it. The framework pre-defines a few directives. Clients of the framework are free to define their own directives as needed. Information on how this is done - will be provided later. For now, we shall deal only with predefined directives.</p> + will be provided later. For now, we shall deal only with predefined directives.<br>指示符可以改变它所包含的表达式的行为,即对其进行<em>装饰 </em>。本框架预定义了一些指示符。用户也可以随便定义他们所需的指示符。稍后再 给出如何来实现的信息。目前,我们只讨论预定义的指示符。</p>
 <h2>lexeme_d</h2>
<p>Turns off white space skipping. At the phrase level, the parser ignores white spaces, possibly including comments. Use <tt>lexeme_d</tt> in situations where
@@ -37,60 +35,65 @@
can be made to work at the character level by enclosing the pertinent parts inside the lexeme_d directive. For example, let us complete the example presented in the <a href="introduction.html">Introduction</a>. There, we skipped the definition
-  of the <tt>integer</tt> rule. Here's how it is actually defined:</p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=identifier>integer </span><span class=special>= </span><span class=identifier>lexeme_d</span><span class=special>[ </span><span class=special>!(</span><span class=identifier>ch_p</span><span class=special>(</span><span class=literal>'+'</span><span class=special>) </span><span class=special>| </span><span class=literal>'-'</span><span class=special>) </span><span class=special>&gt;&gt; </span><span class=special>+</span><span class=identifier>digit </span><span class=special>];</span></font></code></pre> + of the <tt>integer</tt> rule. Here's how it is actually defined:<br>关闭 空白字符的跳过。在语句层面上,分析器会忽略空白字符,其中可能包含注释。当我们 希望在字符层面而不是语句层面上工作时,使用 <tt>lexeme_d</tt>。通过将有关的部 分包含到 lexeme_d 指示符内部,就可以令分析器在字符层面上工作。例如,我们来完 成在 <a href="introduction.html">介绍</a> 中给出的例子。当时,我们略过了 <tt>integer</tt> 规则的定义。以下是它的真实定义:</p> +<pre><code><font color="#000000"><span class="identifier"> </span><span class="identifier">integer </span><span class="special">= </span><span class="identifier">lexeme_d</span><span class="special">[ </span><span class="special">!(</span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'+'</span><span class="special">) </span><span class="special">| </span><span class="literal">'-'</span><span class="special">) </span><span class="special">&gt;&gt; </span><span class="special">+</span><span class="identifier">digit </span><span class="special">];</span></font></code></pre> <p>The <tt>lexeme_d</tt> directive instructs the parser to work on the character level. Without it, the <tt>integer</tt> rule would have allowed erroneous embedded - white spaces in inputs such as <span class="quotes">&quot;1 2 345&quot;</span> - which will be parsed as <span class="quotes">&quot;12345&quot;</span>.</p>
+  white spaces in inputs such as <span class="quotes">"1 2 345"</span>
+ which will be parsed as <span class="quotes">"12345"</span>.<br><tt>lexeme_d</tt> 指示符命令分析器工作在字 符层面上。没有它,<tt>integer</tt> 规则将允许错误地把空白嵌入到输入中,如 <span class="quotes">"1 2 345"</span>
+  将被分析为 <span class="quotes">"12345"</span>。</p>
 <h2>as_lower_d</h2>
<p>There are times when we want to inhibit case sensitivity. The <tt>as_lower_d</tt>
-  directive converts all characters from the input to lower-case.</p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/alert.gif" width="16" height="16"><b> + directive converts all characters from the input to lower-case.<br>有时我 们希望抑制大小写敏感。<tt>as_lower_d</tt>
+  指示符将来自输入的所有字符转换为小写。</p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/alert.gif" height="16" width="16"><b>
       as_lower_d behavior</b> <br>
       <br>
It is important to note that only the input is converted to lower case. Parsers enclosed inside the <tt>as_lower_d</tt> expecting upper case characters will fail to parse. Example: <tt>as_lower_d[<span class="quotes">'X'</span>]</tt> will never succeed because it expects an upper case <tt class="quotes">'X'</tt>
-      that the <tt>as_lower_d</tt> directive will never supply.</td>
+ that the <tt>as_lower_d</tt> directive will never supply.<br>要留 意,只是输入被转换为小写,这很重要。括在 <tt>as_lower_d</tt> 中的分析器如果 期待大写字母,将会解析失败。例如:<tt>as_lower_d[<span class="quotes">'X'</span>]</tt> + 永远不会成功,因为它期待一个大写的 <tt class="quotes">'X'</tt>,而 <tt>as_lower_d</tt> 指示符永远不会提供。</td>
   </tr>
-</table>
+</tbody></table>
<p>For example, in Pascal, keywords and identifiers are case insensitive. Pascal ignores the case of letters in identifiers and keywords. Identifiers Id, ID and id are indistinguishable in Pascal. Without the as_lower_d directive, it - would be awkward to define a rule that recognizes this. Here's a possibility:</p> -<pre><code><font color="#000000"><span class=special> </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>str_p</span><span class=special>(</span><span class=string>"id"</span><span class=special>) </span><span class=special>| </span><span class=string>"Id" </span><span class=special>| </span><span class=string>"iD" </span><span class=special>| </span><span class=string>"ID"</span><span class=special>;</span></font></code></pre> -<p>Now, try doing that with the case insensitive Pascal keyword <span class="quotes">&quot;BEGIN&quot;</span>.
-  The <tt>as_lower_d</tt> directive makes this simple:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>as_lower_d</span><span class=special>[</span><span class=string>"begin"</span><span class=special>];</span></font></code></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><div align="justify"><img src="theme/note.gif" width="16" height="16">
-        <b>Primitive arguments</b> <br>
+ would be awkward to define a rule that recognizes this. Here's a possibility:<br>例如,在Pascal中,关键字和标识符是大小写不敏感的。Pascal会忽 略标识符和关键字中的字母大小写。标识符 Id, ID 和 id 在Pascal中都是一样的。没 有 as_lower_d 指示符,定义一个标识此标识符的规则将非常难看。以下是一种可能 性:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">str_p</span><span class="special">(</span><span class="string">"id"</span><span class="special">) </span><span class="special">| </span><span class="string">"Id" </span><span class="special">| </span><span class="string">"iD" </span><span class="special">| </span><span class="string">"ID"</span><span class="special">;</span></font></code></pre> +<p>Now, try doing that with the case insensitive Pascal keyword <span class="quotes">"BEGIN"</span>. + The <tt>as_lower_d</tt> directive makes this simple:<br>现在,尝试一下大 小写不敏感的Pascal关键字 <span class="quotes">"BEGIN"</span>。用 <tt>as_lower_d</tt> 指示符就可以很简单:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">as_lower_d</span><span class="special">[</span><span class="string">"begin"</span><span class="special">];</span></font></code></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><div align="justify"><img src="theme/note.gif" height="16" width="16">
+        <b>Primitive arguments</b> &nbsp;基本参数<br>
         <br>
- The astute reader will notice that we did not explicitly wrap <span class="quotes">&quot;begin&quot;</span> + The astute reader will notice that we did not explicitly wrap <span class="quotes">"begin"</span> inside an <tt>str_p</tt>. Whenever appropriate, directives should be able to allow primitive types such as <tt>char</tt>, <tt>int</tt>, <tt>wchar_t</tt>, <tt>char const<span class="operators">*</span></tt>, <tt>wchar_t const<span class="operators">*</span></tt>
-        and so on. Examples: <tt><br>
+ and so on. Examples: <br>细心的读者会留意到,这里没有把<span class="quotes">"begin"</span>显式地封入一个 <tt>str_p</tt> 中。在适当情况 下,指示符可以允许基本类型,如 <tt>char</tt>, <tt>int</tt>, <tt>wchar_t</tt>, + <tt>char const<span class="operators">*</span></tt>, <tt>wchar_t const<span class="operators">*</span></tt>
+        等等。例如:<tt><br>
         <br>
- </tt><code><span class=identifier>as_lower_d</span><tt><span class=special>[</span><span class=string>"hello"</span><span class=special>] - </span><span class=comment>// same as as_lower_d[str_p("hello")]</span></tt><code></code><span class=identifier><br> - as_lower_d</span><span class=special>[</span><span class=literal>'x'</span><span class=special>] - </span><span class=comment>// same as as_lower_d[ch_p('x')]</span></code></div></td> + </tt><code><span class="identifier">as_lower_d</span><tt><span class="special">[</span><span class="string">"hello"</span><span class="special">] + </span><span class="comment">// same as as_lower_d[str_p("hello")]</span></tt><code></code><span class="identifier"><br> + as_lower_d</span><span class="special">[</span><span class="literal">'x'</span><span class="special">] + </span><span class="comment">// same as as_lower_d[ch_p('x')]</span></code></div></td>
   </tr>
-</table>
+</tbody></table>
 <h3>no_actions_d</h3>
<p>There are cases where you want <a href="semantic_actions.html">semantic actions</a> not to be triggered. By enclosing a parser in the <tt>no_actions_d</tt> directive, all semantic actions directly or indirectly attached to the parser will not
-  fire. </p>
-<pre><code><font color="#000000"><span class=special> </span>no_actions_d<span class=special>[</span><span class=identifier>expression</span><span class=special>]</span></font></code><code><font color="#000000"><span class=special></span></font></code></pre>
-<h3>Tweaking the Scanner Type</h3>
-<p><img src="theme/note.gif" width="16" height="16"> How does <tt>lexeme_d, as_lower_d</tt> + fire.<br>有些情况下,你不希望 <a href="semantic_actions.html">语义动作 </a> + 被触发。通过将分析器包入 <tt>no_actions_d</tt> 指示符,则连接到该分析器的 所有直接或间接的语义动作都不会触发。</p><pre><code><font color="#000000"><span class="special"> </span>no_actions_d<span class="special">[</span><span class="identifier">expression</span><span class="special">]</span></font></code><code><font color="#000000"><span class="special"></span></font></code></pre>
+<h3>Tweaking the Scanner Type 调整扫描器类型</h3>
+<p><img src="theme/note.gif" height="16" width="16"> How does <tt>lexeme_d, as_lower_d</tt> and <font color="#000000"><tt>no_actions_d</tt></font> work? These directives do their magic by tweaking the scanner policies. Well, you don't need to know what that means for now. Scanner policies are discussed <a href="indepth_the_scanner.html">later</a>.
@@ -99,104 +102,96 @@
is tied to a particular scanner (one or more scanners, to be precise). If you wrap a rule inside a <tt>lexeme_d, as_lower_d</tt> or <font color="#000000"><tt>no_actions_d,</tt>the compiler will complain about <a href="faq.html#scanner_business">scanner mismatch</a>
-  unless you associate the required scanner with the rule. </font></p>
-<p><tt>lexeme_scanner</tt>, <tt>as_lower_scanner</tt> and <tt>no_actions_scanner</tt> - are your friends if the need to wrap a rule inside these directives arise. Learn - bout these beasts in the next chapter on <a href="scanner.html#lexeme_scanner">The
-  Scanner and Parsing</a>.</p>
+ unless you associate the required scanner with the rule.</font><br><img src="theme/note.gif" height="16" width="16">&nbsp;<tt>lexeme_d, as_lower_d</tt> 和 <font color="#000000"><tt>no_actions_d</tt></font> 是如何 工作的呢?这些指示符是通过调整扫描器的策略来实现它们的魔法的。好的,你现在并 不需要明白这是什么意思。扫描器策略将在 <a href="indepth_the_scanner.html">稍 后</a> 讨论。不过要留意,当扫描器策略被调整后,其结果是一个不同的扫描器,这 很重要。为什么这很重要?因为 <a href="rule.html">规则</a>&nbsp;被绑定到一个 特定的扫描器(准确地说,是一个或多个扫描器)。如果你将一个规则包入某个 <tt>lexeme_d, as_lower_d</tt> 或 <font color="#000000"><tt>no_actions_d</tt> 中,编译器将会抱怨 <a href="faq.html#scanner_business">扫描器不匹配</a>,除非你将所需的扫描器关联 至该规则。</font></p> +<p><tt>lexeme_scanner</tt>, <tt>as_lower_scanner</tt> 和 <tt>no_actions_scanner</tt> 都是你的朋友,如果你需要将一个规则包入这些指示 符。你可以在下一章的 <a href="scanner.html#lexeme_scanner">扫描器与分析</a> 中了解到这些。</p>
 <h2>longest_d</h2>
<p>Alternatives in the Spirit parser compiler are short-circuited (see <a href="operators.html">Operators</a>). Sometimes, this is not what is desired. The <tt>longest_d</tt> directive instructs the parser not to short-circuit alternatives enclosed inside this directive, but instead makes the parser try all possible alternatives and choose the one
-  matching the longest portion of the input stream.</p>
-<p>Consider the parsing of integers and real numbers:</p>
-<pre><code><font color="#000000"><span class=comment> </span><span class=identifier>number </span><span class=special>= </span><span class=identifier>real </span><span class=special>| </span><span class=identifier>integer</span><span class=special>;</span></font></code></pre> -<p>A number can be a real or an integer. This grammar is ambiguous. An input <span class="quotes">&quot;1234&quot;</span> + matching the longest portion of the input stream.<br>在Spirit分析器编译器 中,选择操作是短路的(见 <a href="operators.html">操作符</a>)。有时候这不是想 要的。<tt>longest_d</tt> 指示符命令分析器不要将指示符内的选择操作短路,而是 令分析器尝试所有可能的选择,并选中与输入流中最长部分相对应的匹配。</p> +<p>Consider the parsing of integers and real numbers:<br>看一下对整数和实数 的分析:</p> +<pre><code><font color="#000000"><span class="comment"> </span><span class="identifier">number </span><span class="special">= </span><span class="identifier">real </span><span class="special">| </span><span class="identifier">integer</span><span class="special">;</span></font></code></pre> +<p>A number can be a real or an integer. This grammar is ambiguous. An input <span class="quotes">"1234"</span> should potentially match both real and integer. Recall though that alternatives are short-circuited . Thus, for inputs such as above, the real alternative always
-  wins. However, if we swap the alternatives:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>number </span><span class=special>= </span><span class=identifier>integer </span><span class=special>| </span><span class=identifier>real</span><span class=special>;</span></font></code></pre> -<p>we still have a problem. Now, an input <span class="quotes">&quot;123.456&quot;</span> + wins. However, if we swap the alternatives:<br>一个 number 可以是一个 real 或是一个 integer。这个语法是模糊的。输入 <span class="quotes">"1234"</span> + 可以同时匹配 real 和 integer。回想一下,选择操作是短路的。因此,对于以上 输入,总是会选中 real。但是,如果我们交换一下两个选择:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">number </span><span class="special">= </span><span class="identifier">integer </span><span class="special">| </span><span class="identifier">real</span><span class="special">;</span></font></code></pre> +<p>we still have a problem. Now, an input <span class="quotes">"123.456"</span> will be partially matched by integer until the decimal point. This is not what we want. The solution here is either to fix the ambiguity by factoring out the common prefixes of real and integer or, if that is not possible nor desired,
-  use the <tt>longest_d</tt> directive:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>number </span><span class=special>= </span><span class=identifier>longest_d</span><span class=special>[ </span><span class=identifier>integer </span><span class=special>| </span><span class=identifier>real </span><span class=special>];</span></font></code></pre> + use the <tt>longest_d</tt> directive:<br>我们还是会有问题。现在,输入 <span class="quotes">"123.456"</span> + 会被 integer 部分匹配至小数点之前。这不是我们想要的。解决的方法是,通过提 取实数与整数的共同前缀来修正此歧义,如果这样做不可能也不想如此,则使用 <tt>longest_d</tt> 指示符:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">number </span><span class="special">= </span><span class="identifier">longest_d</span><span class="special">[ </span><span class="identifier">integer </span><span class="special">| </span><span class="identifier">real </span><span class="special">];</span></font></code></pre>
 <h2>shortest_d</h2>
-<p>Opposite of the <tt>longest_d</tt> directive.</p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/note.gif" width="16" height="16"> <b>Multiple
-      alternatives</b> <br>
+<p>Opposite of the <tt>longest_d</tt> directive.<br>与 <tt>longest_d</tt> 指示符相反。</p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/note.gif" height="16" width="16"> <b>Multiple
+      alternatives</b> &nbsp;多重选择<br>
       <br>
The <tt>longest_d</tt> and <tt>shortest_d</tt> directives can accept two
-      or more alternatives. Examples:<br>
+ or more alternatives. Examples:<br><tt>longest_d</tt> 和 <tt>shortest_d</tt> 指示符可以接受两个或以上的选项。例如:<br>
       <br>
- <font color="#000000"><span class=identifier><code>longest</code></span><code><span class=special>[ - </span><span class=identifier>a </span><span class=special>| </span><span class=identifier>b - </span><span class=special>| </span><span class=identifier>c </span><span class=special>];
-      </span><span class=identifier><br>
- shortest</span><span class=special>[ </span><span class=identifier>a </span><span class=special>| - </span><span class=identifier>b </span><span class=special>| </span><span class=identifier>c - </span><span class=special>| </span><span class=identifier>d </span><span class=special>];</span></code></font></td> + <font color="#000000"><span class="identifier"><code>longest</code></span><code><span class="special">[ + </span><span class="identifier">a </span><span class="special">| </span><span class="identifier">b + </span><span class="special">| </span><span class="identifier">c </span><span class="special">];
+      </span><span class="identifier"><br>
+ shortest</span><span class="special">[ </span><span class="identifier">a </span><span class="special">| + </span><span class="identifier">b </span><span class="special">| </span><span class="identifier">c + </span><span class="special">| </span><span class="identifier">d </span><span class="special">];</span></code></font></td>
   </tr>
-</table>
+</tbody></table>
 <h2>limit_d</h2>
<p>Ensures that the result of a parser is constrained to a given min..max range
-  (inclusive). If not, then the parser fails and returns a no-match.</p>
-<p><b>Usage:</b></p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>limit_d</span><span class=special>(</span><span class=identifier>min</span><span class=special>, </span><span class=identifier>max</span><span class=special>)[</span><span class=identifier>expression</span><span class=special>]</span></font></code></pre> + (inclusive). If not, then the parser fails and returns a no-match.<br>确 保分析器的结果被限制在给定的 min..max 范围内(含端点)。否则分析器失败并返回不 匹配。</p>
+<p><b>Usage:<br>用法:</b></p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">limit_d</span><span class="special">(</span><span class="identifier">min</span><span class="special">, </span><span class="identifier">max</span><span class="special">)[</span><span class="identifier">expression</span><span class="special">]</span></font></code></pre> <p>This directive is particularly useful in conjunction with parsers that parse specific scalar ranges (for example, <a href="numerics.html">numeric parsers</a>). Here's a practical example. Although the numeric parsers can be configured to accept only a limited number of digits (say, 0..2), there is no way to limit the result to a range (say -1.0..1.0). This design is deliberate. Doing so would - have undermined Spirit's design rule that <i><span class="quotes">&quot;the - client should not pay for features that she does not use&quot;</span></i>. We
+  have undermined Spirit's design rule that <i><span class="quotes">"the
+  client should not pay for features that she does not use"</span></i>. We
would have stored the min, max values in the numeric parser itself, used or unused. Well, we could get by by using static constants configured by a non-type template parameter, but that is not acceptable because that way, we can only accommodate integers. What about real numbers or user defined numbers such as
-  big-ints?</p>
-<p><b>Example</b>, parse time of the form <b>HH:MM:SS</b>:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>2</span><span class=special>, </span><span class=number>2</span><span class=special>&gt; </span><span class=identifier>uint2_p</span><span class=special>;
-
- </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>lexeme_d
-        </span><span class=special>[
- </span><span class=identifier>limit_d</span><span class=special>(</span><span class=number>0u</span><span class=special>, </span><span class=number>23u</span><span class=special>)[</span><span class=identifier>uint2_p</span><span class=special>] </span><span class=special>&gt;&gt; </span><span class=literal>':' </span><span class=comment>// Hours 00..23 - </span><span class=special>&gt;&gt; </span><span class=identifier>limit_d</span><span class=special>(</span><span class=number>0u</span><span class=special>, </span><span class=number>59u</span><span class=special>)[</span><span class=identifier>uint2_p</span><span class=special>] </span><span class=special>&gt;&gt; </span><span class=literal>':' </span><span class=comment>// Minutes 00..59 - </span><span class=special>&gt;&gt; </span><span class=identifier>limit_d</span><span class=special>(</span><span class=number>0u</span><span class=special>, </span><span class=number>59u</span><span class=special>)[</span><span class=identifier>uint2_p</span><span class=special>] </span><span class=comment>// Seconds 00..59
-        </span><span class=special>];</span></font></code>
+ big-ints?<br>当这个指示符与那些分析特定范围内(如 <a href="numerics.html">数值分析器</a>)的分析器一起使用时,尤其有用。虽然数值分 析器可以被配置为只接受限定长度的数字(如 0..2),但是却没有办法限定结果的范围 (如 -1.0..1.0)。这种设计是经过深思熟虑的。这样做将会破坏Spirit的设计原 则:<i><span class="quotes">"用户无需为不需要的特性付出代价"</span></i>。因 为无论是否需要,我们都要将 min, max 值保存在数值分析器中。当然,我们可以通过 一个非类型模板参数来使用静态常量配置,但这也是不可接受的,因为这样的话,我们 就只能容纳整数了。那么实数或是用户自定义的数值类型如 big-ints 该怎么办?</p> +<p><b>Example</b>, parse time of the form <b>HH:MM:SS</b>:<br><b>例 如,</b>分析形如 <b>HH:MM:SS</b> 的时间:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">2</span><span class="special">, </span><span class="number">2</span><span class="special">&gt; </span><span class="identifier">uint2_p</span><span class="special">;<br><br> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">lexeme_d<br> </span><span class="special">[<br> </span><span class="identifier">limit_d</span><span class="special">(</span><span class="number">0u</span><span class="special">, </span><span class="number">23u</span><span class="special">)[</span><span class="identifier">uint2_p</span><span class="special">] </span><span class="special">&gt;&gt; </span><span class="literal">':' </span><span class="comment">// Hours 00..23<br> </span><span class="special">&gt;&gt; </span><span class="identifier">limit_d</span><span class="special">(</span><span class="number">0u</span><span class="special">, </span><span class="number">59u</span><span class="special">)[</span><span class="identifier">uint2_p</span><span class="special">] </span><span class="special">&gt;&gt; </span><span class="literal">':' </span><span class="comment">// Minutes 00..59<br> </span><span class="special">&gt;&gt; </span><span class="identifier">limit_d</span><span class="special">(</span><span class="number">0u</span><span class="special">, </span><span class="number">59u</span><span class="special">)[</span><span class="identifier">uint2_p</span><span class="special">] </span><span class="comment">// Seconds 00..59<br> </span><span class="special">];</span></font></code>
 </pre>
 <h2>min_limit_d</h2>
<p>Sometimes, it is useful to unconstrain just the maximum limit. This will allow for an interval that's unbounded in one direction. The directive min_limit_d ensures that the result of a parser is not less than minimun. If not, then the
-  parser fails and returns a no-match.</p>
-<p><b>Usage:</b></p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>min_limit_d</span><span class=special>(</span><span class=identifier>min</span><span class=special>)[</span><span class=identifier>expression</span><span class=special>]</span></font></code></pre>
-<p><b>Example</b>, ensure that a date is not less than 1900</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>min_limit_d</span><span class=special>(</span><span class=number>1900u</span><span class=special>)[</span><span class=identifier>uint_p</span><span class=special>]</span></font></code></pre> + parser fails and returns a no-match.<br>有时,我们需要不限制最大值。这样 可以使用在某个方向无界的区间。指示符 min_limit_d
+  确保了分析器的结果不小于最小值。否则,分析器失败且返回不匹配。</p>
+<p><b>Usage:<br>用法:</b></p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">min_limit_d</span><span class="special">(</span><span class="identifier">min</span><span class="special">)[</span><span class="identifier">expression</span><span class="special">]</span></font></code></pre> +<p><b>Example</b>, ensure that a date is not less than 1900<br><b>例 如,</b>确保某个日期不小于 1900</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">min_limit_d</span><span class="special">(</span><span class="number">1900u</span><span class="special">)[</span><span class="identifier">uint_p</span><span class="special">]</span></font></code></pre>
 <h2>max_limit_d</h2>
<p>Opposite of <tt>min_limit_d</tt>. Take note that <tt>limit_d[p]</tt> is equivalent
-  to:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>min_limit_d</span><span class=special>(</span><span class=identifier>min</span><span class=special>)[</span><span class=identifier>max_limit_d</span><span class=special>(</span><span class=identifier>max</span><span class=special>)[</span><span class=identifier>p</span><span class=special>]]</span></font></code><code><font color="#000000"><span class=special></span></font></code></pre> + to:<br>与 <tt>min_limit_d</tt> 相反。注意,<tt>limit_d[p]</tt> 相当 于:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">min_limit_d</span><span class="special">(</span><span class="identifier">min</span><span class="special">)[</span><span class="identifier">max_limit_d</span><span class="special">(</span><span class="identifier">max</span><span class="special">)[</span><span class="identifier">p</span><span class="special">]]</span></font></code><code><font color="#000000"><span class="special"></span></font></code></pre>
 <table border="0">
-  <tr>
+  <tbody><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="epsilon.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="scanner.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/epsilon.html Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/epsilon.html Wed Sep 16 20:25:53 2009
@@ -1,56 +1,55 @@
-<html>
-<head>
-<title>Epsilon</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>Epsilon</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
- <td width="85%"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Epsilon</b></font> + <td width="85%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>Epsilon 空串</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="rule.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="directives.html"><img src="theme/r_arr.gif" border="0"></a></td>
    </tr>
-</table>
+</tbody></table>
<p>The <strong>Epsilon</strong> (<tt>epsilon_p</tt> and <tt>eps_p</tt>) is a multi-purpose
-  parser that returns a zero length match. </p>
-<h3>Simple Form</h3>
+ parser that returns a zero length match.<br><strong>空串</strong> (<tt>epsilon_p</tt>&nbsp;和 <tt>eps_p</tt>) 是一个总是返回零长度匹配,有多种 用途的分析器。</p>
+<h3>Simple Form 简单形式</h3>
<p>In its simplest form, epsilon_p matches the null string and always returns
-  a match of zero length:</p>
-<pre><code><span class=special> </span><span class="identifier">epsilon_p </span><span class="comment">// always returns a zero-length match</span></code></pre> + a match of zero length:<br>在最简单的形式下,epsilon_p 匹配空串并且永远返 回一个零长度匹配。</p> +<pre><code><span class="special"> </span><span class="identifier">epsilon_p </span><span class="comment">// always returns a zero-length match 总是返回一个零长度匹配</span></code></pre> <p>This form is usually used to trigger a <a href="semantic_actions.html">semantic action</a> unconditionally. For example, it is useful in triggering error messages
-  when a set of alternatives fail:</p>
-<pre><code><span class=special> </span><span class="identifier">r</span><span class="special"> = </span><span class="identifier">A</span><span class="special"> | </span><span class="identifier">B</span><span class="special"> | </span><span class="identifier">C</span><span class="special"> | </span><span class="identifier">eps_p</span><span class="special">[</span><span class="identifier">error</span><span class="special">];</span><span class="identifier"></span><span class="comment"> // error if A, B, or C fails to match</span></code></pre>
-<h3>Semantic Predicate</h3>
+ when a set of alternatives fail:<br>这种形式通常用于无条件触发一个<a href="semantic_actions.html">语义动作</a>。比如,可用于在选择的某个集合失败 的情况下触发错误信息:</p> +<pre><code><span class="special"> </span><span class="identifier">r</span><span class="special"> = </span><span class="identifier">A</span><span class="special"> | </span><span class="identifier">B</span><span class="special"> | </span><span class="identifier">C</span><span class="special"> | </span><span class="identifier">eps_p</span><span class="special">[</span><span class="identifier">error</span><span class="special">];</span><span class="identifier"></span><span class="comment"> // error if A, B, or C fails to match 如果A,B或C不能匹配,则错误</span></code></pre>
+<h3>Semantic Predicate 语义断言</h3>
<p>Semantic predicates allow you to attach a function anywhere in the grammar. In this role, the epsilon takes a 0-ary (nullary) function/functor. The run-time function/functor is typically a test that is called upon to resolve ambiguity in the grammar. A parse failure will be reported when the function/functor result evaluates to false. Otherwise an empty match will be reported. The general form
-  is:</p>
+ is:<br>语义断言使你能够在语法的任意点挂接某个函数。在这种情况下,空串使用 一个零元(无参数)函数/函数对象。运行时的函数/函数对象通常是用于解决语法二义 性的一个测试。如果函数/函数对象的结果推演为假,将报告一个分析失败,否则报告 空匹配。通用的格式为:</p> <pre> eps_p<span class="special">(</span>f<span class="special">) &gt;&gt;</span> rest<span class="special">;</span>
 </pre>
<p>The nullary function <tt>f</tt> is called to do a semantic test (say, checking if a symbol is in the <a href="symbols.html">symbol table</a>). If test returns <tt>true</tt>, <tt>rest</tt> will be evaluated. Otherwise, the production will
-  return early with a no-match without ever touching <tt>rest</tt>.</p>
-<h3>Syntactic Predicate</h3>
+ return early with a no-match without ever touching <tt>rest</tt>.<br>无参 数函数 <tt>f</tt>&nbsp;被调用,以进行语义测试(比如,检测一个符号是否在<a href="symbols.html">符号表</a>中)。如果测试返回 + <tt>true</tt>,则 <tt>rest</tt>&nbsp;将被执行。否则,产生式将不再接触 <tt>rest</tt>,并且提前返回一个匹配失败。</p>
+<h3>Syntactic Predicate 句意断言</h3>
<p>Similar to Semantic predicates, Syntactic predicates assert a certain conditional syntax to be satisfied before evaluating another production. This time, epsilon_p
-  accepts a (conditional) parser. The general form is:</p>
+ accepts a (conditional) parser. The general form is:<br>类似于语义断 言,句意断言断言了在推演其他产生式之前必须满足某个确定的条件句意。这 次,epsilon_p 接受一个(条件)分析器。通用的格式是:</p> <pre> eps_p<span class="special">(</span>p<span class="special">) &gt;&gt;</span> rest<span class="special">;</span>
 </pre>
<p>If <tt>p</tt> is matched on the input stream then attempt to recognize <tt>rest</tt>.
@@ -58,64 +57,64 @@
success, <tt>eps_p(p)</tt> will always return a zero length match (i.e. the input is not consumed). If test returns <tt>true</tt>, <tt>rest</tt> will be evaluated. Otherwise, the production will return early with a no-match without
-  ever touching <tt>rest</tt>.</p>
-<p>Example:</p>
-<pre><code><span class=special> </span><span class="identifier">eps_p</span><span class="special">(</span><span class="literal">'0'</span><span class="special">) &gt;&gt; </span><span class="identifier">oct_p </span><span class="comment">// note that '0' is actually a ch_p('0')</span><span class="identifier"> </span></code></pre> + ever touching <tt>rest</tt>.<br>如果输入流匹配 <tt>p</tt>&nbsp;,则将进 行 <tt>rest</tt> 的识别。分析器 <tt>p</tt>&nbsp;用于作一个句意检查。无论 <tt>p</tt>&nbsp;的匹配是否成功,<tt>eps_p(p)</tt> 将总是返回零长匹配。(比 如,没有消耗输入)。如果测试返回 <tt>true</tt>,则 <tt>rest</tt>&nbsp;将被推 演。否则,产生式将不再接触 <tt>rest</tt>,并且提前返回一个匹配失败。</p>
+<p>Example:<br>例如:</p>
+<pre><code><span class="special"> </span><span class="identifier">eps_p</span><span class="special">(</span><span class="literal">'0'</span><span class="special">) &gt;&gt; </span><span class="identifier">oct_p </span><span class="comment">// note that '0' is actually a ch_p('0') 注意,'0'实际上就是</span></code><code><span class="comment">ch_p('0')</span></code><code><span class="comment"></span><span class="identifier"> </span></code></pre> <p>Epsilon here is used as a syntactic predicate. <tt>oct_p</tt> (see <a href="numerics.html">numerics</a>) is parsed only if we see a leading <tt>'0'</tt>. Wrapping the leading <tt>'0'</tt> inside an epsilon makes the parser not consume anything from the input. If a <tt>'0'</tt> is seen, <tt>epsilon_p</tt> reports a successful match with zero
-  length. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><div align="justify"><img src="theme/note.gif" width="16" height="16">
-        <b>Primitive arguments</b> <br>
+ length.<br>空串在这里被作为句意断言使用。<tt>oct_p</tt>(查看<a href="numerics.html">数值</a>)只在有看到有先导的<tt>'0'</tt>时才会产生分析。 将先导的<tt>'0'</tt>封装在空串中使得分析器不会消耗任何输入。如果发现一个 <tt>'0'</tt>,<tt>epsilon_p</tt> 将报告一个零长度的成功匹配。</p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><div align="justify"><img src="theme/note.gif" height="16" width="16">
+        <b>Primitive arguments</b> 内置参数<br>
         <br>
Epsilon allows primitive type arguments such as <tt>char</tt>, <tt>int</tt>, <tt>wchar_t</tt>, <tt>char const<span class="operators">*</span></tt>, <tt>wchar_t const<span class="operators">*</span></tt> and so on. Examples:
-        <tt><br>
-        <br>
- </tt><code><span class="identifier">eps_p</span><tt><span class=special>(</span><span class=string>"hello"</span><span class=special>)</span><span class=comment> - // same as eps_p(str_p("hello"))</span></tt><span class=identifier><br> - eps_p</span><span class=special>(</span><span class=literal>'x'</span><span class="special">) - </span><span class=comment>// same as eps_p(ch_p('x'))</span></code></div></td>
+        <br>空串允许使用语言的内置类型诸如 <tt>char</tt>, <tt>int</tt>,
+ <tt>wchar_t</tt>, <tt>char const<span class="operators">*</span></tt>, + <tt>wchar_t const<span class="operators">*</span></tt>&nbsp;等等作 为参数。例子:<tt><br></tt><tt><br> + </tt><code><span class="identifier">eps_p</span><tt><span class="special">(</span><span class="string">"hello"</span><span class="special">)</span><span class="comment"> + // same as eps_p(str_p("hello"))</span></tt><span class="identifier"><br> + eps_p</span><span class="special">(</span><span class="literal">'x'</span><span class="special">) + </span><span class="comment">// same as eps_p(ch_p('x'))</span></code></div></td>
   </tr>
-</table>
-<h3><img src="theme/alert.gif" width="16" height="16"> Inhibiting Semantic Actions</h3>
+</tbody></table>
+<h3><img src="theme/alert.gif" height="16" width="16"> Inhibiting Semantic Actions&nbsp;受限制的语义动作</h3> <p>In a syntactic predicate <tt>eps_p(p)</tt>, any semantic action directly or indirectly attached to the conditional parser <tt>p</tt> will not be called. However, semantic actions attached to epsilon itself will always be called.
-  The following code snippets illustrates the behavior:</p>
+ The following code snippets illustrates the behavior:<br>在一个句意断言 <tt>eps_p(p)</tt> 中,任何直接或间接地挂接于条件分析器 <tt>p</tt>&nbsp;都将 不被调用。然而,挂接到空集自身的语义动作却总是被调用。下面的代码片断描绘了这 一特征:</p> <pre> eps_p<span class="special">(</span>c<span class="special">[</span>f<span class="special">])</span> <span class="comment">// f not called</span><br> eps_p<span class="special">(</span>c<span class="special">)[</span>f<span class="special">]</span> <span class="comment">// f is called</span><br> eps_p<span class="special">[</span>f<span class="special">]</span> <span class="comment">// f is called</span></pre> <p>Actually, the conditional parser <tt>p</tt> is implicitly wrapped in a <tt><a href="scanner.html#no_actions_scanner">no_actions_d</a></tt>
-  directive:</p>
-<pre><code><span class=special> </span>no_actions_d<span class="special">[</span>p<span class="special">]</span></code></pre> + directive:<br>实际上,条件分析器p隐式地被封装在一个 <a href="http://www.boost.org/libs/spirit/doc/scanner.html#no_actions_scanner";><tt><a href="scanner.html#no_actions_scanner">no_actions_d</a></tt></a> 定向器 中:</p> +<pre><code><span class="special"> </span>no_actions_d<span class="special">[</span>p<span class="special">]</span></code></pre> <p>The conditional parser is required to be free from side-effects (semantic actions). <code></code>The conditional parser's purpose is to resolve ambiguity by looking ahead in the input stream for a certain pattern. Ambiguity and semantic actions do not mix well. On an ambiguous grammar, backtracking happens. And when it
-  happens, we cannot undo the effects of triggered semantic actions. </p>
-<h3>Negation</h3>
+ happens, we cannot undo the effects of triggered semantic actions.<br>作 为条件的分析器被要求不带有副作用(语义动作)。条件分析器的目的是通过在输入中 超前寻找特定的模式来消除二义性。二义性和语义动作不能很好地混合。在一个有二义 性的语法中,会发生回溯。当回溯发生时,是无法将已经触发的语义动作也回溯的。 </p>
+<h3>Negation 取反</h3>
<p>Operator <tt>~</tt> is defined for parsers constructed by <tt>epsilon_p</tt>/<tt>eps_p</tt>. It performs negation by complementing the results reported. <tt>~~eps_p(x)</tt>
-  is identical to <tt>eps_p(x)</tt>.</p>
+ is identical to <tt>eps_p(x)</tt>.<br>由 <tt>epsilon_p</tt>/<tt>eps_p</tt> 构建的分析器定义有操作符 <tt>~</tt>。它通 过对报告的结果求补来求反。<tt>~~eps_p(x)</tt> 与 <tt>eps_p(x)</tt>&nbsp;等 价。</p>
 <table border="0">
-  <tr>
+  <tbody><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="rule.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="directives.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
-  Copyright &copy; 2003 Martin Wille<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<br>
+  Copyright (c) 2003 Martin Wille<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>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/grammar.html Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/grammar.html Wed Sep 16 20:25:53 2009
@@ -1,128 +1,90 @@
-<html>
-<head>
-<title>The Grammar</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>The Grammar</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>The Grammar</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>The Grammar 语法</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="scanner.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="subrules.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
<p>The <b>grammar</b> encapsulates a set of rules. The <tt>grammar</tt> class is a protocol base class. It is essentially an interface contract. The <tt>grammar</tt> is a template class that is parameterized by its derived class, <tt>DerivedT</tt>, and its context, <tt>ContextT</tt>. The template parameter ContextT defaults
-  to <tt>parser_context</tt>, a predefined context. </p>
+ to <tt>parser_context</tt>, a predefined context.<span style="font-weight: bold;"><br>语法</span>是一个语义集合的封装。 <tt>grammar</tt> 类是一个协议基类。本质上是一个接口约定。<tt>grammar</tt> 是 一个以它的派生类 <tt>DerivedT</tt> 以及语境 <tt>ContextT</tt> 为模板参数的模 板类。模板参数ContextT的默认值为 <tt>parser_context</tt>,一个预定义的语境 类。 </p> <p>You need not be concerned at all with the ContextT template parameter unless you wish to tweak the low level behavior of the grammar. Detailed information on the ContextT template parameter is provided <a href="indepth_the_parser_context.html">elsewhere</a>. The <tt>grammar</tt> relies on the template parameter DerivedT, a grammar subclass
-  to define the actual rules.</p>
+ to define the actual rules.<br>你完全不用关心ContextT这个模板参数,除非你 想调整语法的底层的行为。关于ContextT模板参数的详细信息在<a href="indepth_the_parser_context.html">其他地方</a>提供。 <tt>grammar</tt>&nbsp;依赖于模板参数DerivedT,它是定义实际规则的语法子类。 </p> <p>Presented below is the public API. There may actually be more template parameters after <tt>ContextT</tt>. Everything after the <tt>ContextT</tt> parameter should - not be of concern to the client and are strictly for internal use only.</p> -<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>template</span><span class=special>&lt; - </span><span class=keyword>typename </span><span class=identifier>DerivedT</span><span class=special>, - </span><span class=keyword>typename </span><span class=identifier>ContextT </span><span class=special>= </span><span class=identifier>parser_context</span><span class=special>&lt;</span><span class=special>&gt; &gt; - </span><span class=keyword>struct </span><span class=identifier>grammar</span><span class=special>;</span></font></code></pre>
-<h2>Grammar definition</h2>
+ not be of concern to the client and are strictly for internal use only.<br>下面就是公开的API。实际上在 <tt>ContextT</tt> 后面可能有更多的模板 参数。在 <tt>ContextT</tt> 后面的所有东西都不应该被用户所考虑,并且被严格限 定于只在内部使用。</p> +<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">template</span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">DerivedT</span><span class="special">,<br> </span><span class="keyword">typename </span><span class="identifier">ContextT </span><span class="special">= </span><span class="identifier">parser_context</span><span class="special">&lt;</span><span class="special">&gt; &gt;<br> </span><span class="keyword">struct </span><span class="identifier">grammar</span><span class="special">;</span></font></code></pre>
+<h2>Grammar definition 语法定义</h2>
<p>A concrete sub-class inheriting from <tt>grammar</tt> is expected to have a
-  nested template class (or struct) named <tt>definition</tt>:</p>
+ nested template class (or struct) named <tt>definition</tt>:<br>一个派生 自 <tt>grammar</tt> 的实际子类必须有一个名为 <tt>definition</tt> 的嵌套模板 类/结构:</p>
 <blockquote>
- <p><img src="theme/bullet.gif" width="13" height="13"> It is a nested template
-    class with a typename <tt>ScannerT</tt> parameter.<br>
- <img src="theme/bullet.gif" width="13" height="13"> Its constructor defines
-    the grammar rules.<br>
- <img src="theme/bullet.gif" width="13" height="13"> Its constructor is passed
-    in a reference to the actual grammar <tt>self</tt>.<br>
- <img src="theme/bullet.gif" width="13" height="13"> It has a member function - named <tt>start</tt> that returns a reference to the start <tt>rule</tt>.</p> + <p><img src="theme/bullet.gif" height="13" width="13"> It is a nested template + class with a typename <tt>ScannerT</tt> parameter.<br>它是一个带有 typename&nbsp;<tt>ScannerT</tt> 参数的嵌套模板类。<br><img src="theme/bullet.gif" height="13" width="13"> Its constructor defines
+    the grammar rules.<br>它的构造函数定义了语法规则。<br>
+ <img src="theme/bullet.gif" height="13" width="13"> Its constructor is passed + in a reference to the actual grammar <tt>self</tt>.<br>它的构造函数被传 入一个实际语法类的引用 <tt>self</tt>。<br> + <img src="theme/bullet.gif" height="13" width="13">It has a member function + named <tt>start</tt> that returns a reference to the start <tt>rule</tt>.<br>它有一个名为 <tt>start</tt> 的成员函数,返回起始 <tt>rule</tt> 的引用。</p>
 </blockquote>
-<h2>Grammar skeleton</h2>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>my_grammar </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>grammar</span><span class=special>&lt;</span><span class=identifier>my_grammar</span><span class=special>&gt;
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>definition
-        </span><span class=special>{
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=identifier>r</span><span class=special>; - </span><span class=identifier>definition</span><span class=special>(</span><span class=identifier>my_grammar </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>self</span><span class=special>) </span><span class=special>{ </span><span class=identifier>r </span><span class=special>= </span><span class=comment>/*..define here..*/</span><span class=special>; </span><span class=special>} - </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>start</span><span class=special>() </span><span class=keyword>const </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>r</span><span class=special>; </span><span class=special>}
-        </span><span class=special>};
-    </span><span class=special>};</span></font></code></pre>
+<h2>Grammar skeleton 语法骨架</h2>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">my_grammar </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">grammar</span><span class="special">&lt;</span><span class="identifier">my_grammar</span><span class="special">&gt;<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">definition<br> </span><span class="special">{<br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="identifier">r</span><span class="special">;<br> </span><span class="identifier">definition</span><span class="special">(</span><span class="identifier">my_grammar </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">self</span><span class="special">) </span><span class="special">{ </span><span class="identifier">r </span><span class="special">= </span><span class="comment">/*..define here..*/</span><span class="special">; </span><span class="special">}<br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">start</span><span class="special">() </span><span class="keyword">const </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">r</span><span class="special">; </span><span class="special">}<br> </span><span class="special">};<br> </span><span class="special">};</span></font></code></pre> <p>Decoupling the scanner type from the rules that form a grammar allows the grammar to be used in different contexts possibly using different scanners. We do not care what scanner we are dealing with. The user-defined <tt>my_grammar</tt> can be used with <b>any</b> type of scanner. Unlike the rule, the grammar is - not tied to a specific scanner type. See <a href="faq.html#scanner_business">&quot;Scanner - Business&quot;</a> to see why this is important and to gain further understanding
-  on this scanner-rule coupling problem.</p>
-<h2>Instantiating and using my_grammar</h2>
-<p>Our grammar above may be instantiated and put into action:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>my_grammar </span><span class=identifier>g</span><span class=special>;
-
- </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>, </span><span class=identifier>g</span><span class=special>, </span><span class=identifier>space_p</span><span class=special>).</span><span class=identifier>full</span><span class=special>) - </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"parsing succeeded\n"</span><span class=special>;
-    </span><span class=keyword>else
- </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"parsing failed\n"</span><span class=special>;</span></font></code></pre> + not tied to a specific scanner type. See <a href="faq.html#scanner_business">"Scanner + Business"</a> to see why this is important and to gain further understanding + on this scanner-rule coupling problem.<br>将扫描器类从构成语法的规则中解 耦形成了一个可以在不同语境下使用不同扫描器的语法类。我们可以不关心使用的是什 么扫描器。用户定义的 <tt>my_grammar</tt>&nbsp;可以与<span style="font-weight: bold;">任意</span>类型的扫描器配合使用。与规则不同,语法 并不与特定的扫描器绑定。阅读"<a href="faq.html#scanner_business">扫描器事务 </a>"以理解为什么这种解耦是重要的,且获得对这个"扫描器----规则"问题的进一步理 解。</p>
+<h2>Instantiating and using my_grammar 实例化并使用 my_grammar</h2>
+<p>Our grammar above may be instantiated and put into action:<br>我们前面的 语法可以这么实例化并使用:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">my_grammar </span><span class="identifier">g</span><span class="special">;<br><br> </span><span class="keyword">if </span><span class="special">(</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">, </span><span class="identifier">g</span><span class="special">, </span><span class="identifier">space_p</span><span class="special">).</span><span class="identifier">full</span><span class="special">)<br> </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"parsing succeeded\n"</span><span class="special">;<br> </span><span class="keyword">else<br> </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"parsing failed\n"</span><span class="special">;</span></font></code></pre> <p><tt>my_grammar</tt> <b>IS-A </b>parser and can be used anywhere a parser is
-  expected, even referenced by another rule:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>rule</span><span class=special>&lt;&gt; </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>g </span><span class=special>&gt;&gt; </span><span class=identifier>str_p</span><span class=special>(</span><span class=string>"cool huh?"</span><span class=special>);</span></font></code></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/alert.gif" width="16" height="16"> <b>Referencing
-      grammars<br>
+ expected, even referenced by another rule:</p><p><tt>my_grammar</tt><span style="font-weight: bold;"> 是一个 </span>分析器且可以用在任意分析器适用的场合,甚至被另一个规则引用:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">g </span><span class="special">&gt;&gt; </span><span class="identifier">str_p</span><span class="special">(</span><span class="string">"cool huh?"</span><span class="special">);</span></font></code></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/alert.gif" height="16" width="16"> <b>Referencing
+      grammars 引用语法<br>
       </b><br>
Like the rule, the grammar is also held by reference when it is placed in the right hand side of an EBNF expression. It is the responsibility of the client to ensure that the referenced grammar stays in scope and does not
-      get destructed while it is being referenced. </td>
+ get destructed while it is being referenced.<br>与规则相类似,当语法 被放在EBNF表达式的等号右边时,它也是被引用的。用户有责任保证语法在被引用的过 程中始终处于作用域内,并且不被析构。 </td>
   </tr>
-</table>
-<h2><a name="full_grammar"></a>Full Grammar Example</h2>
+</tbody></table>
+<h2><a name="full_grammar"></a>Full Grammar Example 完事的语法例子</h2>
<p>Recalling our original calculator example, here it is now rewritten using a
-  grammar:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>calculator </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>grammar</span><span class=special>&lt;</span><span class=identifier>calculator</span><span class=special>&gt;
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>definition
-        </span><span class=special>{
- </span><span class=identifier>definition</span><span class=special>(</span><span class=identifier>calculator </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>self</span><span class=special>)
-            </span><span class=special>{
- </span><span class=identifier>group </span><span class=special>= </span><span class=literal>'(' </span><span class=special>&gt;&gt; </span><span class=identifier>expression </span><span class=special>&gt;&gt; </span><span class=literal>')'</span><span class=special>; - </span><span class=identifier>factor </span><span class=special>= </span><span class=identifier>integer </span><span class=special>| </span><span class=identifier>group</span><span class=special>; - </span><span class=identifier>term </span><span class=special>= </span><span class=identifier>factor </span><span class=special>&gt;&gt; </span><span class=special>*((</span><span class=literal>'*' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>) </span><span class=special>| </span><span class=special>(</span><span class=literal>'/' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)); - </span><span class=identifier>expression </span><span class=special>= </span><span class=identifier>term </span><span class=special>&gt;&gt; </span><span class=special>*((</span><span class=literal>'+' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>) </span><span class=special>| </span><span class=special>(</span><span class=literal>'-' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>));
-            </span><span class=special>}
-
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=identifier>expression</span><span class=special>, </span><span class=identifier>term</span><span class=special>, </span><span class=identifier>factor</span><span class=special>, </span><span class=identifier>group</span><span class=special>;
-
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& - </span><span class=identifier>start</span><span class=special>() </span><span class=keyword>const </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>expression</span><span class=special>; </span><span class=special>}
-        </span><span class=special>};
-    </span><span class=special>};</span></font></code></pre>
-<p><img src="theme/lens.gif" width="15" height="16"> A fully working example with
+  grammar:<br>回想一下我们最初的计算器例子,下面我们用语法来重写一次:</p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">calculator </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">grammar</span><span class="special">&lt;</span><span class="identifier">calculator</span><span class="special">&gt;<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">definition<br> </span><span class="special">{<br> </span><span class="identifier">definition</span><span class="special">(</span><span class="identifier">calculator </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">self</span><span class="special">)<br> </span><span class="special">{<br> </span><span class="identifier">group </span><span class="special">= </span><span class="literal">'(' </span><span class="special">&gt;&gt; </span><span class="identifier">expression </span><span class="special">&gt;&gt; </span><span class="literal">')'</span><span class="special">;<br> </span><span class="identifier">factor </span><span class="special">= </span><span class="identifier">integer </span><span class="special">| </span><span class="identifier">group</span><span class="special">;<br> </span><span class="identifier">term </span><span class="special">= </span><span class="identifier">factor </span><span class="special">&gt;&gt; </span><span class="special">*((</span><span class="literal">'*' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">) </span><span class="special">| </span><span class="special">(</span><span class="literal">'/' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">));<br> </span><span class="identifier">expression </span><span class="special">= </span><span class="identifier">term </span><span class="special">&gt;&gt; </span><span class="special">*((</span><span class="literal">'+' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">) </span><span class="special">| </span><span class="special">(</span><span class="literal">'-' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">));<br> </span><span class="special">}<br><br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="identifier">expression</span><span class="special">, </span><span class="identifier">term</span><span class="special">, </span><span class="identifier">factor</span><span class="special">, </span><span class="identifier">group</span><span class="special">;<br><br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp;<br> </span><span class="identifier">start</span><span class="special">() </span><span class="keyword">const </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">expression</span><span class="special">; </span><span class="special">}<br> </span><span class="special">};<br> </span><span class="special">};</span></font></code></pre> +<p><img src="theme/lens.gif" height="16" width="15"> A fully working example with <a href="semantic_actions.html">semantic actions</a> can be <a href="../example/fundamental/calc_plain.cpp">viewed
-  here</a>. This is part of the Spirit distribution. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/lens.gif" width="15" height="16"> <b>self</b><br> + here</a>. This is part of the Spirit distribution.<br>一个添加了<a href="semantic_actions.html">语义动作</a>的可工作的完整例子可以在<a href="../example/fundamental/calc_plain.cpp">这里</a>查阅。这是Spirit包的一 部分。 </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/lens.gif" height="16" width="15"> <b>self</b><br>
       <br>
You might notice that the definition of the grammar has a constructor that accepts a const reference to the outer grammar. In the example above, notice
@@ -131,10 +93,12 @@
is very useful. The self argument is the definition's window to the outside world. For example, the calculator class might have a reference to some state information that the definition can update while parsing proceeds
-      through <a href="semantic_actions.html">semantic actions</a>. </td>
+ through <a href="semantic_actions.html">semantic actions</a>.<br>你也 许已经注意到了,语法的definition类有一个接受外部grammar常量引用的构造函数。 在上面的例子中,注意 <tt>calculator::definition</tt>&nbsp;接受一个 <tt>calculator const&amp; + self</tt>。虽然上面的例子中并没有使用,但依然是十分有用的。self这个参 数是definition与通往外界的窗口。例如,calculator类可 +能会引用一些状态信息,而definition可以通过<a href="semantic_actions.html">语义动作</a>更新这些信息。 </td>
   </tr>
-</table>
-<h2>Grammar Capsules</h2>
+</tbody></table>
+<h2>Grammar Capsules 语法封装</h2>
<p>As a grammar becomes complicated, it is a good idea to group parts into logical modules. For instance, when writing a language, it might be wise to put expressions and statements into separate grammar capsules. The grammar takes advantage of
@@ -142,100 +106,72 @@
makes it a perfect fit for the definition of grammars. Since the grammar is nothing more than a class declaration, we can conveniently publish it in header files. The idea is that once written and fully tested, a grammar can be reused
-  in many contexts. We now have the notion of grammar libraries.</p>
-<h2><a name="multithreading"></a>Reentrancy and multithreading</h2>
+ in many contexts. We now have the notion of grammar libraries.<br>随着语 法变得复杂,把不同的部分封装到不同的逻辑模块中是个好主意。例如,在写一门语言 时,把表达式和句子分开放到不同的语法封装中会是个明智的主 +意。语法从C++的类封装中获得不少优点。由于grammar除了是类的声明以外什么也不 是,我们可以舒服地把它放在头文件中。这样,一旦写完并且经过完成的测
+试,一个语法就可以在很多语境中重用。现在我们就有了语法库的概念。</p>
+<h2><a name="multithreading"></a>Reentrancy and multithreading 再入与多线程 </h2> <p>An instance of a grammar may be used in different places multiple times without any problem. The implementation is tuned to allow this at the expense of some overhead. However, we can save considerable cycles and bytes if we are certain that a grammar will only have a single instance. If this is desired, simply define <tt>BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE</tt> before including any spirit
-  header files.</p>
-<pre><font face="Courier New, Courier, mono"><code><span class="preprocessor"> #define</span></code></font><span class="preprocessor"><code><font face="Courier New, Courier, mono"> </font><tt>BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE</tt></code></span></pre> -<p> On the other hand, if a grammar is intended to be used in multithreaded code, + header files.<br>一个语法的实例可以在不同的地方反复使用而不带来任何问题。 它的实现被调整为在可以接受的效率损失下允许这种重用。然而,如果我们确信一个语 法将只有一个对象,我们可以节省显著的时钟周期和字节。如果想这么做,只需在包含 任何spirit头文件前定义 <tt>BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE。</tt></p> +<pre><font face="Courier New, Courier, mono"><code><span class="preprocessor"> #define</span></code></font><span class="preprocessor"><code><font face="Courier New, Courier, mono"> </font><tt>BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE</tt></code></span></pre><p> On the other hand, if a grammar is intended to be used in multithreaded code, we should then define <tt>BOOST_SPIRIT_THREADSAFE</tt> before including any - spirit header files. In this case it will also be required to link against <a href="http://www.boost.org/libs/thread/doc/index.html";>Boost.Threads</a></p> + spirit header files. In this case it will also be required to link against <a href="http://www.boost.org/libs/thread/doc/index.html";>Boost.Threads</a><br>另 一方面,如果一个语法是倾向于在多线程的代码中使用,我们就应该在包含任何 spirit头文件前定义 <tt>BOOST_SPIRIT_THREADSAFE</tt>。在这种情况下,还需要链 接 <a href="http://www.boost.org/libs/thread/doc/index.html";>Boost.Threads</a></p> <pre><font face="Courier New, Courier, mono"><span class="preprocessor"> #define</span></font> <span class="preprocessor"><tt>BOOST_SPIRIT_THREADSAFE</tt></span></pre>
-<h2>Using more than one grammar start rule </h2>
+<h2>Using more than one grammar start rule 在语法中使用多重起始规则 </h2>
<p>Sometimes it is desirable to have more than one visible entry point to a grammar (apart from the start rule). To allow additional start points, Spirit provides a helper template <tt>grammar_def</tt>, which may be used as a base class for - the <tt>definition</tt> subclass of your <tt>grammar</tt>. Here's an example:</p> -<pre><code> <span class="comment">// this header has to be explicitly included</span> - <span class="preprocessor">#include</span> <span class="string">&lt;boost/spirit/utility/grammar_def.hpp&gt;</span>
-
- </span><span class=keyword>struct </span><span class=identifier>calculator2 </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>grammar</span><span class=special>&lt;</span><span class=identifier>calculator2</span><span class=special>&gt;
-    {
-</span>        <span class="keyword">enum</span>
-        {
-            expression = 0,
-            term = 1,
-            factor = 2,
-        };
-
-<span class=special> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>definition - </span><span class="special">:</span> <span class="keyword">public</span><span class=identifier> grammar_def</span><span class="special">&lt;</span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;,</span> same<span class="special">,</span> same<span class="special">&gt;</span>
-        <span class=special>{</span>
- <span class=identifier>definition</span><span class=special>(</span><span class=identifier>calculator2 </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>self</span><span class=special>)
-            {
- </span><span class=identifier>group </span><span class=special>= </span><span class=literal>'(' </span><span class=special>&gt;&gt; </span><span class=identifier>expression </span><span class=special>&gt;&gt; </span><span class=literal>')'</span><span class=special>; - </span><span class=identifier>factor </span><span class=special>= </span><span class=identifier>integer </span><span class=special>| </span><span class=identifier>group</span><span class=special>; - </span><span class=identifier>term </span><span class=special>= </span><span class=identifier>factor </span><span class=special>&gt;&gt; *((</span><span class=literal>'*' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>) | (</span><span class=literal>'/' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)); - </span><span class=identifier>expression </span><span class=special>= </span><span class=identifier>term </span><span class=special>&gt;&gt; *((</span><span class=literal>'+' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>) | (</span><span class=literal>'-' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>));</span>
-
- <span class="keyword">this</span><span class="special">-&gt;</span>start_parsers<span class="special">(</span>expression<span class="special">,</span> term<span class="special">,</span> factor<span class="special">);</span>
-            <span class="special">}</span>
-
- <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=identifier>expression</span><span class=special>, </span><span class=identifier>term</span><span class=special>, </span><span class=identifier>factor, group</span><span class=special>;
-</span><span class=special>        };
-    };</span></font></code></pre>
+ the <tt>definition</tt> subclass of your <tt>grammar</tt>. Here's an example:<br>有时,我们希望一个语法有不止一个的可见的入口(不是起始规则)。为 了允许附加的规则起点,Spirit提供了一个 <tt>grammar_def</tt> 模板,它可以用作 你的 <tt>grammar</tt> 里 <tt>definition</tt> 的基类。以下是例子:</p> +<pre><code> <span class="comment">// this header has to be explicitly included 必须显式包含该头文件</span> + <span class="preprocessor">#include</span> <span class="string">&lt;boost/spirit/utility/grammar_def.hpp&gt;</span> <br><br> <span class="keyword">struct </span><span class="identifier">calculator2 </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">grammar</span><span class="special">&lt;</span><span class="identifier">calculator2</span><span class="special">&gt;<br> {<br></span> <span class="keyword">enum</span> <br> {<br> expression = 0,<br> term = 1,<br> factor = 2,<br> };<br><br><span class="special"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">definition<br> </span><span class="special">:</span> <span class="keyword">public</span><span class="identifier"> grammar_def</span><span class="special">&lt;</span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;,</span> same<span class="special">,</span> same<span class="special">&gt;</span>
+        <span class="special">{</span>
+ <span class="identifier">definition</span><span class="special">(</span><span class="identifier">calculator2 </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">self</span><span class="special">)<br> {<br> </span><span class="identifier">group </span><span class="special">= </span><span class="literal">'(' </span><span class="special">&gt;&gt; </span><span class="identifier">expression </span><span class="special">&gt;&gt; </span><span class="literal">')'</span><span class="special">;<br> </span><span class="identifier">factor </span><span class="special">= </span><span class="identifier">integer </span><span class="special">| </span><span class="identifier">group</span><span class="special">;<br> </span><span class="identifier">term </span><span class="special">= </span><span class="identifier">factor </span><span class="special">&gt;&gt; *((</span><span class="literal">'*' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">) | (</span><span class="literal">'/' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">));<br> </span><span class="identifier">expression </span><span class="special">= </span><span class="identifier">term </span><span class="special">&gt;&gt; *((</span><span class="literal">'+' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">) | (</span><span class="literal">'-' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">));</span>
+
+ <span class="keyword">this</span><span class="special">-&gt;</span>start_parsers<span class="special">(</span>expression<span class="special">,</span> term<span class="special">,</span> factor<span class="special">);</span> <br> <span class="special">}</span>
+
+ <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="identifier">expression</span><span class="special">, </span><span class="identifier">term</span><span class="special">, </span><span class="identifier">factor, group</span><span class="special">;<br></span><span class="special"> };<br> };</span></code></pre> <p>The <tt>grammar_def</tt> template has to be instantiated with the types of - all the rules you wish to make visible from outside the <tt>grammar</tt>:</p> -<pre><code><span class=identifier> </span><span class=identifier>grammar_def</span><span class="special">&lt;</span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;,</span> same<span class="special">,</span> same<span class="special">&gt;</span></code> </pre> + all the rules you wish to make visible from outside the <tt>grammar</tt>:<br><tt>grammar_def</tt>&nbsp;模板需要以你想使其在 <tt>grammar</tt>&nbsp;外部可见的全部规则类型来实例化:</p> +<pre><code><span class="identifier"> </span><span class="identifier">grammar_def</span><span class="special">&lt;</span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;,</span> same<span class="special">,</span> same<span class="special">&gt;</span></code> </pre> <p>The shorthand notation <tt>same</tt> is used to indicate that the same type be used as specified by the previous template parameter (e.g. <code><tt>rule&lt;ScannerT&gt;</tt></code>). - Obviously, <tt>same</tt> may not be used as the first template parameter. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"> <img src="theme/bulb.gif" width="13" height="18"> <strong>grammar_def + Obviously, <tt>same</tt> may not be used as the first template parameter.<br><tt>same</tt> 这个简写用来表明,这个参数使用的类型与前面的模板 参数(比如 <code><tt>rule&lt;ScannerT&gt;</tt></code>)相同。很明 显,<tt>same</tt> 不一定被用作第一个模板参数。 </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"> <img src="theme/bulb.gif" height="18" width="13"> <strong>grammar_def
       start types</strong><br>
       <br>
It may not be obvious, but it is interesting to note that aside from rule&lt;&gt;s, any parser type may be specified (e.g. chlit&lt;&gt;, strlit&lt;&gt;, int_parser&lt;&gt;,
-      etc.).</td>
+ etc.).<br>可能并不明显,但是有趣的是,除了 rule&lt;&gt;,也可以指定任 意分析器类型(比如chlit&lt;&gt;,strlit&lt;&gt;,int_parser&lt;&gt; 等等)。 </td>
   </tr>
-</table>
-<p>Using the grammar_def class, there is no need to provide a <tt>start()</tt>member
+</tbody></table>
+<p>Using the grammar_def class, there is no need to provide a <tt>start()</tt> member function anymore. Instead, you'll have to insert a call to the <tt>this-&gt;start_parsers()</tt> (which is a member function of the <tt>grammar_def</tt> template) to define - the start symbols for your <tt>grammar</tt>. <img src="theme/note.gif" width="16" height="16"> + the start symbols for your <tt>grammar</tt>. <img src="theme/note.gif" height="16" width="16"> Note that the number and the sequence of the rules used as the parameters to the <tt>start_parsers()</tt> function should match the types specified in the
-  <tt>grammar_def</tt> template:</p>
+ <tt>grammar_def</tt> template:<br>使用 grammar_def 类后,就没有必要提供 <tt>start()</tt> 成员函数了。取而代之的是,你要插入一个 <tt>this-&gt;start_parsers()</tt>(这个是 <tt>grammar_def</tt>&nbsp;的成员函 数)的调用来指明你的 <tt>grammar</tt> 的起始规则。&nbsp;<img src="theme/note.gif" height="16" width="16">注意用于 <tt>start_parsers()</tt> 函数的参数数量和顺序必须与 <tt>grammar_def</tt> 的 模板参数的数量和类型相匹配:</p> <pre><code> <span class="keyword">this</span><span class="special">-&gt;</span>start_parsers<span class="special">(</span>expression<span class="special">,</span> term<span class="special">,</span> factor<span class="special">);</span></code></pre> -<p> The grammar entry point may be specified using the following syntax:</p> -<pre><code><font color="#000000"><span class=identifier> g</span><span class="special">.</span><span class=identifier>use_parser</span><span class="special">&lt;</span><span class=identifier>N</span><span class=special>&gt;() </span><span class="comment">// Where g is your grammar and N is the Nth entry.</span></font></code></pre> +<p> The grammar entry point may be specified using the following syntax:<br>语法的入口点可以用下面的语法指定:</p> +<pre><code><font color="#000000"><span class="identifier"> g</span><span class="special">.</span><span class="identifier">use_parser</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;() </span><span class="comment">// Where g is your grammar and N is the Nth entry. g是你的 语法,而N是第N个入口。</span></font></code></pre> <p>This sample shows how to use the <tt>term</tt> rule from the <tt>calculator2</tt>
-  grammar above:</p>
-<pre><code><font color="#000000"><span class=identifier> calculator2 g</span><span class=special>;
-
- </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier> - first</span><span class=special>, </span><span class=identifier>last</span><span class=special>, - </span><span class=identifier>g</span><span class="special">.</span><span class=identifier>use_parser</span><span class="special">&lt;</span><span class=identifier>calculator2::term</span><span class=special>&gt;(),</span><span class=identifier>
-            space_p</span><span class=special>
-        ).</span><span class=identifier>full</span><span class=special>)
-    {
- </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"parsing succeeded\n"</span><span class=special>;
-    }
-    </span><span class=keyword>else</span> <span class="special">{</span>
- <span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"parsing failed\n"</span><span class=special>;
-    }</span></font></code></pre>
+ grammar above:<br>这个例子示范了如何在以上的 <tt>calculator2</tt> 语法中 使用 <tt>term</tt> 规则作为起始符:</p> +<pre><code><font color="#000000"><span class="identifier"> calculator2 g</span><span class="special">;<br><br> </span><span class="keyword">if </span><span class="special">(</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier"> + first</span><span class="special">, </span><span class="identifier">last</span><span class="special">, <br> </span><span class="identifier">g</span><span class="special">.</span><span class="identifier">use_parser</span><span class="special">&lt;</span><span class="identifier">calculator2::term</span><span class="special">&gt;(),</span><span class="identifier">
+            space_p</span><span class="special">
+ ).</span><span class="identifier">full</span><span class="special">)<br> {<br> </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"parsing succeeded\n"</span><span class="special">;<br> }<br> </span><span class="keyword">else</span> <span class="special">{</span> + <span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"parsing failed\n"</span><span class="special">;<br> }</span></font></code></pre> <p>The template parameter for the <tt>use_parser&lt;&gt;</tt> template type should be the zero based index into the list of rules specified in the <tt>start_parsers()</tt>
-  function call. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/note.gif" width="16" height="16"> <tt><strong>use_parser&lt;0&gt;</strong></tt><br> + function call.<br><tt>use_parser&lt;&gt;</tt>&nbsp;的模板参数必须是与 <tt>start_parsers()</tt> 函数的参数列表相对应的从零开始的索引号。 </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/note.gif" height="16" width="16"> <tt><strong>use_parser&lt;0&gt;</strong></tt><br>
       <br>
Note, that using <span class="literal">0</span> (zero) as the template parameter to <tt>use_parser</tt> is equivalent to using the start rule, exported by
@@ -244,28 +180,27 @@
above. So this notation may be used even for grammars exporting one rule through its <tt>start()</tt> function only. On the other hand, calling a <tt>grammar</tt> without the <tt>use_parser</tt> notation will execute the - rule specified as the first parameter to the <tt>start_parsers()</tt> function. + rule specified as the first parameter to the <tt>start_parsers()</tt> function.<br>注意,使用<span class="literal">0</span>(零)作为 <tt>use_parser</tt> 的模板参数等价于使用 起始规则,就是在上面第一个 <tt><a href="grammar.html#full_grammar">calculator</a></tt> 里展示的,通过约定的 <tt>start()</tt>&nbsp;函数导出的规则。因此这种做法甚至可以用于只通过 <tt>start()</tt>&nbsp;函数输入一个规则的语法。而在另一方面,不通过 <tt>use_parser</tt>&nbsp;而直接调用一个 <tt>grammar</tt> 则等价与使用 <tt>start_parsers()</tt>&nbsp;里指定的第一个参数。
     </td>
   </tr>
-</table>
-<p>The maximum number of usable start rules is limited by the preprocessor constant:</p> -<pre> <span class="identifier">BOOST_SPIRIT_GRAMMAR_STARTRULE_TYPE_LIMIT</span> <span class="comment">// defaults to 3</span></pre>
+</tbody></table>
+<p>The maximum number of usable start rules is limited by the preprocessor constant:<br>起始规则的最大数目是被一个预处理器常量限制的:</p> +<pre> <span class="identifier">BOOST_SPIRIT_GRAMMAR_STARTRULE_TYPE_LIMIT</span> <span class="comment">// defaults to 3 默认为3</span></pre>
 <table border="0">
-  <tr>
+  <tbody><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="scanner.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="subrules.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
-  Copyright &copy; 2003-2004 Hartmut Kaiser <br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<br>
+  Copyright (c) 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>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/indepth_the_parser.html Tue Mar 31 01:07:16 2009 +++ /trunk/libs/spirit/classic/doc/indepth_the_parser.html Wed Sep 16 20:25:53 2009
@@ -1,101 +1,93 @@
-<html>
-<head>
-<title>In-depth: The Parser</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>In-depth: The Parser</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>In-depth: The Parser</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>In-depth: The Parser 深入:分析器</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="semantic_actions.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="indepth_the_scanner.html"><img src="theme/r_arr.gif" border="0"></a></td>
    </tr>
-</table>
+</tbody></table>
<p>What makes Spirit tick? Now on to some details... The parser class is the most fundamental entity in the framework. A parser accepts a scanner comprised of a first-last iterator pair and returns a match object as its result. The iterators delimit the data currently being parsed. The match object evaluates to true if the parse succeeds, in which case the input is advanced accordingly. Each parser can represent a specific pattern or algorithm, or it can be a more complex
-  parser formed as a composition of other parsers.</p>
-<p>All parsers inherit from the base template class, parser:</p>
-<pre>
-<span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>DerivedT</span><span class=special>&gt;
-</span><span class=keyword>struct </span><span class=identifier>parser
-</span><span class=special>{
-    </span><span class=comment>/*...*/
-
- </span><span class=identifier>DerivedT</span><span class=special>&amp; </span><span class=identifier>derived</span><span class=special>(); - </span><span class=identifier>DerivedT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>derived</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
-</span><span class=special>};</span></pre>
+ parser formed as a composition of other parsers.<br>是什么使得Spirit运 行?现在来看些细节...... parser 类是框架中最基础的实体。分析器接受一个包含 first-last 分析器对的扫描器并返回一个匹 +配对象作为分析结果。迭代器界定了当前要分析的数据。如果分析成功则匹配对象为 真,在这种情况下输入产生相应的步进。每个分析器都代表了特定的模式或者算
+法,或者可以作为一个更复杂的分析器的构成物。</p>
+<p>All parsers inherit from the base template class, parser:<br>所有的分析 器都派生自模板基类 parser:</p> +<pre><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">DerivedT</span><span class="special">&gt;<br></span><span class="keyword">struct </span><span class="identifier">parser<br></span><span class="special">{<br> </span><span class="comment">/*...*/<br><br> </span><span class="identifier">DerivedT</span><span class="special">&amp; </span><span class="identifier">derived</span><span class="special">();<br> </span><span class="identifier">DerivedT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">derived</span><span class="special">() </span><span class="keyword">const</span><span class="special">;<br></span><span class="special">};</span></pre> <p>This class is a protocol base class for all parsers. The parser class does not really know how to parse anything but instead relies on the template parameter - <tt>DerivedT</tt> to do the actual parsing. This technique is known as the <a href="references.html#curious_recurring">&quot;Curiously - Recurring Template Pattern&quot;</a> in template meta-programming circles. This + <tt>DerivedT</tt> to do the actual parsing. This technique is known as the <a href="references.html#curious_recurring">"Curiously + Recurring Template Pattern"</a> in template meta-programming circles. This inheritance strategy gives us the power of polymorphism without the virtual function overhead. In essence this is a way to implement <a href="references.html#generic_patterns">compile
-  time polymorphism</a>.</p>
+ time polymorphism</a>.<br>该类是针对所有分析器的协议基类。parser 类并不真 正知道如何分析,而是依赖于它的模板参数 + <tt>DerivedT</tt>&nbsp;来做真正的分析。这种技术在模板元编程圈子里被称为 "<a href="references.html#curious_recurring">神奇递归模板模式(CRTP</a><a href="references.html#curious_recurring">)</a>"。这种继承策略使我们拥有了多 态的威力而不必承担虚函数的代价。本质上这是一个实现<a href="references.html#generic_patterns">编译期多态</a>的方法。</p>
 <h2> parser_category_t</h2>
<p> Each derived parser has a typedef <tt>parser_category_t</tt> that defines its category. By default, if one is not specified, it will inherit from the base parser class which typedefs its parser_category_t as <tt>plain_parser_category</tt>. Some template classes are provided to distinguish different types of parsers. The following categories are the most generic. More specific types may inherit
-  from these.</p>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td colspan="2" class="table_title">Parser categories</td>
+ from these.<br>每个派生的分析器都有一个名为定义其种类的typedef <tt>parser_category_t</tt>。默认情况下,如果没有指定分析器,则它将派生自一个 将 parser_category_t typedef为 <tt>plain_parser_category</tt> 的 parser 类。 我们提供了一些模板类以区分分析器的种类。以下分类是最粗泛的。更为具体的分类将 派生自这些类。<tt></tt></p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+    <td colspan="2" class="table_title">Parser categories 分析器分类</td>
   </tr>
   <tr>
     <td class="table_cells" width="33%"><tt>plain_parser_category</tt></td>
-    <td class="table_cells" width="67%">Your plain vanilla parser</td>
+ <td class="table_cells" width="67%">Your plain vanilla parser<br>纯分析 器</td>
   </tr>
   <tr>
<td class="table_cells" width="33%"><tt>binary_parser_category</tt></td> <td class="table_cells" width="67%">A parser that has subject a and b (e.g.
-      alternative)</td>
+ alternative)<font color="#c0c0c0"><br></font>有a项和b项的分析器(比如 选择分析器)</td>
   </tr>
   <tr>
     <td class="table_cells" width="33%"><tt>unary_parser_category</tt></td>
<td class="table_cells" width="67%">A parser that has single subject (e.g.
-      kleene star)</td>
+      kleene star)<br>只有单项的分析器(比如克林星)</td>
   </tr>
   <tr>
<td class="table_cells" width="33%"><tt>action_parser_category</tt></td> - <td class="table_cells" width="67%">A parser with an attached semantic action</td> + <td class="table_cells" width="67%">A parser with an attached semantic action<br>挂接了语义动作的分析器</td>
   </tr>
-</table>
-<pre><span class=identifier> </span><span class=keyword>struct </span><span class=identifier>plain_parser_category </span><span class=special>{}; - </span><span class=keyword>struct </span><span class=identifier>binary_parser_category </span><span class=special>: </span><span class=identifier>plain_parser_category </span><span class=special>{}; - </span><span class=keyword>struct </span><span class=identifier>unary_parser_category </span><span class=special>: </span><span class=identifier>plain_parser_category </span><span class=special>{}; - </span><span class=keyword>struct </span><span class=identifier>action_parser_category </span><span class=special>: </span><span class=identifier>unary_parser_category </span><span class=special>{};</span></pre>
+</tbody></table>
+<pre><span class="identifier"> </span><span class="keyword">struct </span><span class="identifier">plain_parser_category </span><span class="special">{};<br> </span><span class="keyword">struct </span><span class="identifier">binary_parser_category </span><span class="special">: </span><span class="identifier">plain_parser_category </span><span class="special">{};<br> </span><span class="keyword">struct </span><span class="identifier">unary_parser_category </span><span class="special">: </span><span class="identifier">plain_parser_category </span><span class="special">{};<br> </span><span class="keyword">struct </span><span class="identifier">action_parser_category </span><span class="special">: </span><span class="identifier">unary_parser_category </span><span class="special">{};</span></pre>
 <h2>embed_t</h2>
<p>Each parser has a typedef <tt>embed_t</tt>. This typedef specifies how a parser is embedded in a composite. By default, if one is not specified, the parser will be embedded by value. That is, a copy of the parser is placed as a member variable of the composite. Most parsers are embedded by value. In certain situations however, this is not desirable or possible. One particular example is the <a href="rule.html">rule</a>.
-  The rule, unlike other parsers is embedded by reference.</p>
-<h2><a name="match"></a>The match</h2>
+ The rule, unlike other parsers is embedded by reference.<br>每个分析器都 有一个typedef&nbsp; <tt>embed_t</tt>。 +这个typedef指定了分析器是如何被嵌入合成物的。默认情况下,如果某个分析器未指 定的话,它将以值的方式内嵌。即,该分析器的一份拷贝将被作为该组 +合的一个成员变量。多数分析器是以值的方式内嵌的。然而在特定的情况下,这可能 不是我们想要的或者是不可能的。特定的例子就是 <a href="rule.html">规则</a>。 规则与其他分析器不同,它是以引用的方式内嵌的。</p>
+<h2><a name="match"></a>The match 匹配</h2>
<p>The match holds the result of a parser. A match object evaluates to true when a succesful match is found, otherwise false. The length of the match is the number of characters (or tokens) that is successfully matched. This can be queried through its <tt>length()</tt> member function. A negative value means that the
-  match is unsucessful. </p>
+ match is unsucessful.<br>匹配持有分析器的分析结果。一个 match 对象的值在 产生成功匹配时为 true,否则为 false。匹配的长度即被成功匹配的字符(记号)的 长度。这可以用成员函数 <tt>length()</tt>&nbsp;获得。负数意味着匹配失败。 </p> <p> Each parser may have an associated attribute. This attribute is also returned back to the client on a successful parse through the match object. We can get this attribute via the match's <tt>value()</tt> member function. Be warned though
@@ -103,39 +95,31 @@
will result in an exception. The member function <tt>has_valid_attribute()</tt> can be queried to know if it is safe to get the match's attribute. The attribute may be set anytime through the member function <tt>value(v)</tt>where <tt>v</tt>
-  is the new attribute value.<br>
+ is the new attribute value.<br>每个分析器都有一个相关联的属性。这个属性在 成功分析后也会通过匹配对象返回给客户程序。我们可以通过匹配对象的 <tt>value()</tt>&nbsp;成员函数获得这个属性。注 +意匹配的属性有可能无效,在这种情况下,试图取得这个属性将导致一个异常。 <tt>has_valid_attribute()</tt>&nbsp;成员函数可以用来探知是否可以安全 +地取得匹配的属性。可以在任意时间通过 <tt>value(v)</tt>成员函数给匹配的属性 设定新的属性值 <tt>v</tt>。<br>
   <br>
-  A match attribute is valid:</p>
+  A match attribute is valid:<br>一个匹配属性是有效的:</p>
 <ul>
-  <li> on a successful match</li>
- <li>when its value is set through the <tt>value(val)</tt> member function</li>
+  <li> on a successful match<br>在成功匹配时</li>
+ <li>when its value is set through the <tt>value(val)</tt> member function<br>当它的值通过 <tt>value(val)</tt>&nbsp;成员函数设置时</li> <li> if it is assigned or copied from a compatible match object (e.g. <tt>match&lt;double&gt;</tt> from <tt>match&lt;int&gt;</tt>) with a valid attribute. A match object <tt>A</tt> is compatible with another match object <tt>B</tt> if the attribute type of - <tt>A</tt> can be assigned from the attribute type of <tt></tt> <tt>B</tt>
-    (i.e. <tt>a = b;</tt> must compile).</li>
+    <tt>A</tt> can be assigned from the attribute type of  <tt>B</tt>
+ (i.e. <tt>a = b;</tt> must compile).<br>如果它是一个兼容的带有有效属性 的匹配对象(比如从 <tt>match&lt;int&gt;</tt> 到 <tt>match&lt;double&gt;</tt>&nbsp;)的赋值或者拷贝时。一个匹配对象 <tt>A</tt>&nbsp;与另一个匹配对象 <tt>B</tt>&nbsp;是兼容的如果 <tt>A</tt>&nbsp;的属性可以被从 <tt>B</tt>&nbsp;的属性赋值(即 <tt>a = b;</tt> 必须能编译)。</li>
 </ul>
-<p>The match attribute is undefined:</p>
+<p>The match attribute is undefined:<br>匹配属性为未定义的:</p>
 <ul>
-  <li>on an unsuccessful match </li>
+  <li>on an unsuccessful match<br>在没有成功匹配时 </li>
<li>when an attempt to copy or assign from another match object with an incompatible - attribute type (e.g. <tt>match&lt;std::string&gt;</tt> from <tt>match&lt;int&gt;</tt>).</li> + attribute type (e.g. <tt>match&lt;std::string&gt;</tt> from <tt>match&lt;int&gt;</tt>).<br>当试图从不兼容的另外的匹配对象拷贝或赋值匹配 属性时(比如从 <tt>match&lt;int&gt;</tt> 到 <tt>match&lt;std::string&gt;</tt>&nbsp;)。</li>
 </ul>
 <h3>The match class:</h3>
-<pre><span class=keyword> template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
-</span><span class=keyword>    class </span><span class=identifier>match
-</span><span class=keyword>    </span><span class=special>{
-</span><span class=keyword>    public</span><span class=special>:
-
-    </span><span class=keyword>    </span><span class=comment>/*...*/
-
-</span><span class=special> </span><span class=keyword> typedef</span><span class="identifier"> T attr_t</span><span class="special">;<br> - </span><span class=keyword> </span><span class="special"> </span><span class=keyword>operator safe_bool</span><span class=special>() </span><span class=keyword>const</span>; <span class="comment">// convertible to a bool</span> - <span class=keyword> int </span><span class=identifier>length</span><span class=special>() </span><span class=keyword>const</span>; - <span class="keyword">bool</span> has_valid_attribute<span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> - <span class=keyword> </span> <span class=identifier>void</span><span class=special> </span><span class=identifier>value</span><span class=special>(</span><span class="identifier">T </span><span class="keyword">const</span><span class=special>&amp;) </span><span class=keyword>const; - </span><span class=identifier>T </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>value</span><span class=special>();
-</span><span class=keyword>    </span><span class=special>};</span></pre>
+<pre><span class="keyword"> template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br></span><span class="keyword"> class </span><span class="identifier">match<br></span><span class="keyword"> </span><span class="special">{<br></span><span class="keyword"> public</span><span class="special">:<br><br> </span><span class="keyword"> </span><span class="comment">/*...*/<br><br></span><span class="special"> </span><span class="keyword"> typedef</span><span class="identifier"> T attr_t</span><span class="special">;<br> + </span><span class="keyword"> </span><span class="special"> </span><span class="keyword">operator safe_bool</span><span class="special">() </span><span class="keyword">const</span>; <span class="comment">// convertible to a bool</span> + <span class="keyword"> int </span><span class="identifier">length</span><span class="special">() </span><span class="keyword">const</span>;<br> <span class="keyword">bool</span> has_valid_attribute<span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="keyword"> </span> <span class="identifier">void</span><span class="special"> </span><span class="identifier">value</span><span class="special">(</span><span class="identifier">T </span><span class="keyword">const</span><span class="special">&amp;) </span><span class="keyword">const;<br> </span><span class="identifier">T </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">value</span><span class="special">();<br></span><span class="keyword"> </span><span class="special">};</span></pre>
 <h2>match_result</h2>
<p>It has been mentioned repeatedly that the parser returns a match object as its result. This is a simplification. Actually, for the sake of genericity,
@@ -143,19 +127,22 @@
a parser returns an object that adheres to a conceptual interface, of which the match is an example. Nevertheless, we shall call the result type of a parser a match object regardless if it is actually a match class, a derivative or a
-  totally unrelated type.</p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/lens.gif" width="15" height="16"> <b>Meta-functions</b><br>
+  totally unrelated type.<br>前
+面反复提到过分析器返回一个 match 对象作为结果。这只是简略的说法。事实上,为 了通用性,并不要求分析器一定要返回 match
+对象。更准确的说,分析器返回的是与某个概念接口一致的对象,而 match
+只是一个例子。不过,不管实际类型是什么,我们都把分析器的结果的类型称为 match 对象。</p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/lens.gif" height="16" width="15"> <b>Meta-functions 元函数</b><br>
       <br>
What are meta-functions? We all know how functions look like. In simplest terms, a function accepts some arguments and returns a result. Here is the
-      function we all love so much:<br>
+ function we all love so much:<br>什么是元函数?我们都知道函数长什么 样。用最简单的话说,一个函数接受某些参数并返回一个结果。这里是我们可爱的函 数:<br>
       <br>
<code><span class="keyword">int</span> identity_func<span class="special">(</span><span class="keyword">int</span>
       arg<span class="special">)</span><br>
<span class="special">{</span> <span class="keyword">return</span> arg<span class="special">;
-      }</span> <span class="comment">// return the argument arg</span><br>
+ }</span> <span class="comment">// return the argument arg 返回参数 arg</span><br>
       </code><br>
Meta-functions are essentially the same. These beasts also accept arguments and return a result. However, while functions work at runtime on values,
@@ -163,125 +150,90 @@
deal only with types). The meta-function is a template class (or struct). The template parameters are the arguments to the meta-function and a typedef within the class is the meta-function's return type. Here is the corresponding
-      meta-function:<code><br>
+ meta-function:<font face="Courier New"><br>元函数本质上是一样的。这些 东西同样接受参数并返回结果。然而,函数在运行时针对值工作,而元函数在 +编译期针对类工作(或者常数,但我们应该只和类型打交道)。元函数是一个模板类 (或者结构)。模板参数即为元函数的参数而模板类内的一个typdef则为元函
+数的返回类型。这里是对应的元函数:</font><code></code><code><br>
       <br>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span>
       ArgT<span class="special">&gt;</span><br>
       <span class="keyword">struct</span> identity_meta_func<br>
<span class="special">{</span> <span class="keyword">typedef</span> ArgT type<span class="special">; } </span><span class="comment">// return the
-      argument ArgT</span><br>
+      argument ArgT 返回参数ArgT</span><br>
       <br>
-      </code>The meta-function above is invoked as:<br>
+ </code>The meta-function above is invoked as:<br>以上元函数被调用如 下:<br>
       <br>
<code><span class="keyword">typename</span> identity_meta_func<span class="special">&lt;</span>ArgT<span class="special">&gt;::</span>type</code><br>
       <br>
By convention, meta-functions return the result through the typedef <tt>type</tt>. - Take note that <tt>typename</tt> is only required within templates.</td> + Take note that <tt>typename</tt> is only required within templates.<br>按照习惯,元函数通过typedef&nbsp;<tt>type</tt>返回结果。注意 <tt>typename</tt> 只有在模板中才是必须的。</td>
   </tr>
-</table>
+</tbody></table>
<p>The actual match type used by the parser depends on two types: the parser's attribute type and the scanner type. <tt>match_result</tt> is the meta-function - that returns the desired match type given an attribute type and a scanner type. + that returns the desired match type given an attribute type and a scanner type.<br>分析器所使用的实际的匹配类型取决于两个类型:分析器的属性类 型和扫描器类型。<tt>match_result</tt>&nbsp;是一个被给予一个属性类和扫描器类 并返回所希望的匹配类型的元函数。
 </p>
-<p>Usage:</p>
-<pre> <span class=keyword>typename </span><span class=identifier>match_result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type</span></pre> -<p>The meta-function basically answers the question &quot;given a scanner type
+<p>Usage:<br>用法:</p>
+<pre> <span class="keyword">typename </span><span class="identifier">match_result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></pre>
+<p>The meta-function basically answers the question "given a scanner type
<tt>ScannerT</tt> and an attribute type <tt>T</tt>, what is the desired match - type?&quot; [<img src="theme/note.gif" width="16" height="16"> <tt>typename</tt>
-  is only required within templates ].</p>
-<h2>The parse member function</h2>
+ type?" [<img src="theme/note.gif" height="16" width="16"> <tt>typename</tt> + is only required within templates ].<br>这个元函数基本上回答了"给定一个分 析器类 + <tt>ScannerT</tt>&nbsp;和一个属性类 <tt>T</tt>,所期望的匹配类型为何"这个 问题。[<img src="theme/note.gif" height="16" width="16"> <tt>typename</tt>&nbsp;只在模板中才是必须的 ]。</p>
+<h2>The parse member function 成员函数parse</h2>
<p>Concrete sub-classes inheriting from parser must have a corresponding member - function <tt>parse(...)</tt> compatible with the conceptual Interface:<br> + function <tt>parse(...)</tt> compatible with the conceptual Interface:<br>从 parser 派生的具体子类必须相应地有与概念接口一致的 <tt>parse(...)</tt>&nbsp;成员函数:
 </p>
-<pre><span class=identifier> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-    </span><span class=identifier>RT
- </span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special></span> const<span class=special>&amp; </span>scan<span class=identifier></span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span></pre>
-<p>where <tt>RT</tt> is the desired return type of the parser. </p>
-<h2>The parser result</h2>
+<pre><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="identifier">RT<br> </span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special"></span> const<span class="special">&amp; </span>scan<span class="identifier"></span><span class="special">) </span><span class="keyword">const</span><span class="special">;</span></pre> +<p>where <tt>RT</tt> is the desired return type of the parser.<br>其中 <tt>RT</tt> 是分析器所要返回的类型。 </p>
+<h2>The parser result 分析器的结果</h2>
<p>Concrete sub-classes inheriting from parser in most cases need to have a nested meta-function <tt>result</tt> that returns the result <tt>type</tt> of the parser's - parse member function, given a scanner type. The meta-function has the form:</p> -<pre><span class=keyword> template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-    </span><span class=keyword>struct </span><span class=identifier>result
-    </span><span class=special>{
- </span><span class=keyword>typedef </span>RT <span class=identifier></span><span class=identifier>type</span><span class=special>;
-    </span><span class=special>};</span></pre>
+ parse member function, given a scanner type. The meta-function has the form:<br>从 parse 派生的具体子类在大多数情况下需要一个嵌套的元函数 <tt>result</tt>,给定一个分析器类,它将返回该分析器的 parse 成员函数的结果 <tt>type</tt>。该元函数有如下形式:</p> +<pre><span class="keyword"> template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">result<br> </span><span class="special">{<br> </span><span class="keyword">typedef </span>RT <span class="identifier"></span><span class="identifier">type</span><span class="special">;<br> </span><span class="special">};</span></pre> <p>where <tt>RT</tt> is the desired return type of the parser. This is usually, but not always, dependent on the template parameter <tt>ScannerT</tt>. For example, - given an attribute type <tt>int</tt>, we can use the match_result metafunction:</p> -<pre><span class=keyword> template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-    </span><span class=keyword>struct </span><span class=identifier>result
-    </span><span class=special>{
- </span><span class=keyword>typedef typename </span><span class=identifier>match_result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class="keyword">int</span><span class=special>&gt;::</span><span class=identifier>type type</span><span class=special>;
-    };</span></pre>
+ given an attribute type <tt>int</tt>, we can use the match_result metafunction:<br>其中 <tt>RT</tt>&nbsp;是分析器要返回的类型。通常是这样 的,但并非总是如此,这取决与模板参数 <tt>ScannerT</tt>。举例来说,给定属性 类 <tt>int</tt>,我们可以如下使用match_result 元函数:</p> +<pre><span class="keyword"> template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">result<br> </span><span class="special">{<br> </span><span class="keyword">typedef typename </span><span class="identifier">match_result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="keyword">int</span><span class="special">&gt;::</span><span class="identifier">type type</span><span class="special">;<br> };</span></pre> <p>If a parser does not supply a result metafunction, a default is provided by - the base parser class.<span class=special> </span>The default is declared as:</p> -<pre><span class=keyword> template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-    </span><span class=keyword>struct </span><span class=identifier>result
-    </span><span class=special>{
- </span><span class=keyword>typedef typename </span><span class=identifier>match_result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class="identifier">nil_t</span><span class=special>&gt;::</span><span class=identifier>type type</span><span class=special>;
-    };</span></pre>
+ the base parser class.<span class="special"> </span>The default is declared as:<br>如果一个分析器没有提供 result 元函数,则由 parser 基类提供一 个默认的。默认元函数声明如下:</p> +<pre><span class="keyword"> template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">result<br> </span><span class="special">{<br> </span><span class="keyword">typedef typename </span><span class="identifier">match_result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">nil_t</span><span class="special">&gt;::</span><span class="identifier">type type</span><span class="special">;<br> };</span></pre> <p>Without a result metafunction, notice that the parser's default attribute is
-  <tt>nil_t</tt> (i.e. the parser has no attribute).</p>
-<h2><span class=special></span>parser_result</h2>
+ <tt>nil_t</tt> (i.e. the parser has no attribute).</p><p>没有 result 元函 数的话,分析器的默认属性为
+  <tt>nil_t</tt>(即该分析器没有属性)。</p>
+<h2><span class="special"></span>parser_result</h2>
<p>Given a a scanner type <tt>ScannerT</tt> and a parser type <tt>ParserT</tt>, what will be the actual result of the parser? The answer to this question is
-  provided to by the <tt>parser_result</tt> meta-function.</p>
-<p>Usage:</p>
-<pre> <span class=keyword>typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>ParserT, ScannerT</span><span class=special>&gt;::</span><span class=identifier>type</span></pre> + provided to by the <tt>parser_result</tt> meta-function.<br>给定一个扫描 器类 <tt>ScannerT</tt> 和一个分析器类型 <tt>ParserT</tt>,分析器的真正结果类 型为何?这个问题的答案有 <tt>parser_result</tt>&nbsp;元函数提供。</p>
+<p>Usage:<br>用法:</p>
+<pre> <span class="keyword">typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">ParserT, ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span></pre> <p>In general, the meta-function just forwards the invocation to the parser's
-  result meta-function:</p>
-<pre><span class=identifier> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>parser_result
-    </span><span class=special>{
- </span><span class=keyword>typedef </span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>::</span><span class=keyword>template </span><span class=identifier>result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>type</span><span class=special>;
-    </span><span class=special>};</span></pre>
+ result meta-function:<br>通常,这个元函数只是前转至对分析器的 result 元函 数的调用:</p> +<pre><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">parser_result<br> </span><span class="special">{<br> </span><span class="keyword">typedef </span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">::</span><span class="keyword">template </span><span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type </span><span class="identifier">type</span><span class="special">;<br> </span><span class="special">};</span></pre> <p>This is similar to a global function calling a member function. Most of the
-  time, the usage above is equivalent to:</p>
-<pre><span class=keyword> typename </span><span class=identifier>ParserT</span><span class=special>::</span><span class=keyword>template </span><span class=identifier>result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type</span></pre> + time, the usage above is equivalent to:<br>这类似于通过全局函数来调用成员 函数。大多数时候,上面的使用等同于:</p> +<pre><span class="keyword"> typename </span><span class="identifier">ParserT</span><span class="special">::</span><span class="keyword">template </span><span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span></pre> <p>Yet, this should not be relied upon to be true all the time because the parser_result - metafunction might be specialized for specific parser and/or scanner types.</p> + metafunction might be specialized for specific parser and/or scanner types.<br>但是,并不是在所有的情况下都是如此,因为 parse_result 元函数有可能 针对特定的分析器和/或扫描器类型而特化。</p> <p>The parser_result metafunction makes the signature of the required parse member
-  function almost canonical:</p>
-<pre><span class=identifier> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>self_t, ScannerT</span><span class=special>&gt;::</span><span class=identifier>type</span><br> <span class=identifier>parse</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special></span> const<span class=special>&amp; </span>scan<span class=identifier></span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span></pre> -<p>where<span class=special></span> <tt>self_t</tt> is a typedef to the parser.</p>
-<h2>parser class declaration</h2>
-<pre><span class=identifier> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>DerivedT</span><span class=special>&gt;
-    </span><span class=keyword>struct </span><span class=identifier>parser
-    </span><span class=special>{
- </span><span class=keyword>typedef </span><span class=identifier>DerivedT embed_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>DerivedT derived_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>plain_parser_category parser_category_t</span><span class=special>;
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class="keyword">typename</span> ScannerT<span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>result
-        </span><span class=special>{
- </span><span class=keyword>typedef typename </span><span class=identifier>match_result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class=identifier>nil_t</span><span class=special>&gt;::</span><span class=identifier>type type</span><span class=special>;
-        };
-
- </span><span class=identifier>DerivedT</span><span class=special>&amp; </span><span class=identifier>derived</span><span class=special>(); - </span><span class=identifier>DerivedT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>derived</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ActionT</span><span class=special>&gt; - </span><span class=identifier>action</span><span class=special>&lt;</span><span class=identifier>DerivedT</span><span class=special>, </span><span class=identifier>ActionT</span><span class=special>&gt; - </span><span class=keyword>operator</span><span class=special>[](</span><span class=identifier>ActionT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>actor</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    };</span></pre>
+ function almost canonical:<br>parse_result 元函数使得其所需要的 parse 成 员函数的签名总是规范的:</p> +<pre><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">self_t, ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span><br> <span class="identifier">parse</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special"></span> const<span class="special">&amp; </span>scan<span class="identifier"></span><span class="special">) </span><span class="keyword">const</span><span class="special">;</span></pre> +<p>where<span class="special"></span> <tt>self_t</tt> is a typedef to the parser.<br>其中<span class="special"></span> <tt>self_t</tt> 是对这个分析器 的一个 typedef。</p>
+<h2>parser class declaration &nbsp;parser类的声明</h2>
+<pre><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">DerivedT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">parser<br> </span><span class="special">{<br> </span><span class="keyword">typedef </span><span class="identifier">DerivedT embed_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">DerivedT derived_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">plain_parser_category parser_category_t</span><span class="special">;<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename</span> ScannerT<span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">result<br> </span><span class="special">{<br> </span><span class="keyword">typedef typename </span><span class="identifier">match_result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">nil_t</span><span class="special">&gt;::</span><span class="identifier">type type</span><span class="special">;<br> };<br><br> </span><span class="identifier">DerivedT</span><span class="special">&amp; </span><span class="identifier">derived</span><span class="special">();<br> </span><span class="identifier">DerivedT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">derived</span><span class="special">() </span><span class="keyword">const</span><span class="special">;<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ActionT</span><span class="special">&gt;<br> </span><span class="identifier">action</span><span class="special">&lt;</span><span class="identifier">DerivedT</span><span class="special">, </span><span class="identifier">ActionT</span><span class="special">&gt;<br> </span><span class="keyword">operator</span><span class="special">[](</span><span class="identifier">ActionT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">actor</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> };</span></pre>
 <table border="0">
-  <tr>
+  <tbody><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="semantic_actions.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="indepth_the_scanner.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/indepth_the_parser_context.html Tue Mar 31 01:07:16 2009 +++ /trunk/libs/spirit/classic/doc/indepth_the_parser_context.html Wed Sep 16 20:25:53 2009
@@ -1,107 +1,82 @@
-<html>
-<head>
-<title>In-depth: The Parser Context</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>In-depth: The Parser Context</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
- <td width="85%"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>In-depth:
-      The Parser Context</b></font></td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="85%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>In-depth:
+      The Parser Context 深入:分析器语境</b></font></td>
+ <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><tr>
     <td width="10"></td>
     <td width="30"><a href="../index.html">
-    <img src="theme/u_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/u_arr.gif" border="0" height="19" width="20"></a></td>
     <td width="30"><a href="indepth_the_scanner.html">
-    <img src="theme/l_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/l_arr.gif" border="0" height="19" width="20"></a></td>
     <td width="30"><a href="predefined_actors.html">
-    <img src="theme/r_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/r_arr.gif" border="0" height="19" width="20"></a></td>
   </tr>
-</table>
-<h2>Overview</h2>
+</tbody></table>
+<h2>Overview 概览</h2>
<p>The parser's <b>context</b> is yet another concept. An instance (object) of the <tt>context</tt> class is created before a non-terminal starts parsing and is destructed after parsing has concluded. A non-terminal is either a <tt>rule</tt>, a <tt>subrule</tt>, or a <tt>grammar</tt>. Non-terminals have a <tt>ContextT</tt> template parameter. The following pseudo code depicts what's happening when
-    a non-terminal is invoked:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>return_type - </span><span class=identifier>a_non_terminal</span><span class=special>::</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>scan</span><span class=special>)
-    {
- </span><span class=identifier>context_t ctx</span><span class=special>(/**/); - </span><span class=identifier>ctx</span><span class=special>.</span><span class=identifier>pre_parse</span><span class=special>(/**/);
-
- </span><span class=comment>// main parse code of the non-terminal here...
-
- </span><span class=keyword>return </span><span class=identifier>ctx</span><span class=special>.</span><span class=identifier>post_parse</span><span class=special>(/**/);
-    }</span></font></code></pre>
+ a non-terminal is invoked:<br>分析器的<strong>语境</strong>是另一个概 念。<tt>context</tt>&nbsp;类的一个实例在非终结符的分析开始前被构造并在分析结 束后析构。非终结符是指 <tt>rule</tt>,&nbsp;<tt>subrule</tt> 或 <tt>grammar</tt>。非终结符有一个 <tt>ContextT</tt>&nbsp;模板参数。下面的伪代 码说明了当非终结符被调用时所发生的事情:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">return_type<br> </span><span class="identifier">a_non_terminal</span><span class="special">::</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> {<br> </span><span class="identifier">context_t ctx</span><span class="special">(/**/);<br> </span><span class="identifier">ctx</span><span class="special">.</span><span class="identifier">pre_parse</span><span class="special">(/**/);<br><br> </span><span class="comment">// main parse code of the non-terminal here... 非终结符的分析代码在 此...<br><br> </span><span class="keyword">return </span><span class="identifier">ctx</span><span class="special">.</span><span class="identifier">post_parse</span><span class="special">(/**/);<br> }</span></font></code></pre> <p>The context is provided for extensibility. Its main purpose is to expose the start and end of the non-terminal's parse member function to accommodate external hooks. We can extend the non-terminal in a multitude of ways by writing specialized context classes, without modifying the class itself. For example, we can make the non-terminal emit debug diagnostics information by writing a context class that prints out the current state of the scanner at each point in the parse
-  traversal where the non-terminal is invoked.</p>
-<p>Example of a parser context that prints out debug information:</p>
-<pre><code><font color="#000000"> pre_parse</font>:<font color="#000000"> non-terminal XXX is entered<font color="#0000ff">.</font> The current state of the input - is <font color="#616161"><i>&quot;hello world, this is a test&quot;</i></font>
-
- post_parse</font>:<font color="#000000"> non-terminal XXX has concluded<font color="#0000ff">,</font> the non-terminal matched <font color="#616161"><i>&quot;hello world&quot;</i></font><font color="#0000ff">.</font> - The current state of the input is <font color="#616161"><i>&quot;, this is a test&quot;</i></font></font></code></pre> + traversal where the non-terminal is invoked.<br>语境是为了可扩展性而被提 供的。它的主要目的是将非终结符的 parse 成员函数的开始和终结暴露给外部的钩子 函数。我们可以通过编写特定的语境类代 +码来以多种方式扩展非终结符而不用修改类本身。例如我们可以通过编写一个使得扫 描器在非终结符被激活时的分析周游中的每个节点上都输出扫描器的当前状态的语
+境类来使得非终结符产生调试诊断信息。</p>
+<p>Example of a parser context that prints out debug information:<br>分析器 语境打印调试信息的例子:</p> +<pre><code><font color="#000000"> pre_parse</font>:<font color="#000000"> non-terminal XXX is entered<font color="#0000ff">.</font> The current state of the input<br> is <font color="#616161"><i>"hello world, this is a test"</i></font>
+
+ post_parse</font>:<font color="#000000"> non-terminal XXX has concluded<font color="#0000ff">,</font> the non-terminal matched <font color="#616161"><i>"hello world"</i></font><font color="#0000ff">.</font> + The current state of the input is <font color="#616161"><i>", this is a test"</i></font></font></code></pre> <p>Most of the time, the context will be invisible from the user's view. In general, clients of the framework need not deal directly nor even know about contexts. Power users, however, might find some use of contexts. Thus, this is part of the public API. Other parts of the framework in other layers above the core
-  take advantage of the context to extend non-terminals. </p>
-<h2>Class declaration</h2>
+ take advantage of the context to extend non-terminals.<br>多数时候,从用 户的角度来看语境是不可见的。大体而言,框架的客户不需要直接和语境打交道,甚至 不需要了解。但有能力的用户,可能会找到语境的用处。因此,这是公共API的一部 分。框架中核心之上其他层次的其他部分借助语境的优势以扩展非终结符。</p>
+<h2>Class declaration 类的声明</h2>
<p>The <tt>parser_context</tt> class is the default context class that the non-terminal
-    uses. </p>
-<pre><span class=keyword> </span><span class="identifier">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">AttrT</span> <span class="special">=</span> <span class="identifier">nil_t</span><span class="special">&gt;</span><span class=keyword><br> struct </span><span class=identifier>parser_context
-</span><span class=special>    {
- </span><span class=keyword>typedef </span>AttrT <span class=identifier>attr_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>implementation_defined base_t</span><span class=special>; - </span><span class="keyword">typedef</span><span class=special> </span>parser_context_linker<span class="special">&lt;</span>parser_context<span class="special">&lt;</span><span class="identifier">AttrT</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">context_linker_t</span><span class=special>;
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>&gt; - </span><span class=identifier>parser_context</span><span class=special>(</span><span class=identifier>ParserT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>p</span><span class=special>) {}
-
- </span><span class=keyword> template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-    </span><span class=keyword>    void
- </span><span class=identifier> pre_parse</span><span class=special>(</span><span class=identifier>ParserT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>p</span><span class=special>, </span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) {}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ResultT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=identifier>ResultT</span><span class=special>&amp; - </span><span class=identifier> post_parse</span><span class=special>(</span><span class=identifier>ResultT</span><span class=special>&amp; </span><span class=identifier>hit</span><span class=special>, </span><span class=identifier>ParserT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>p</span><span class=special>, </span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>hit</span><span class=special>; }
-    };</span></pre>
+ uses.<br><tt>parser_context</tt>&nbsp;<font face="Courier New">类是非终 结符使用的默认语境类。</font>&nbsp;</p> +<pre><span class="keyword"> </span><span class="identifier">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">AttrT</span> <span class="special">=</span> <span class="identifier">nil_t</span><span class="special">&gt;</span><span class="keyword"><br> struct </span><span class="identifier">parser_context<br></span><span class="special"> {<br> </span><span class="keyword">typedef </span>AttrT <span class="identifier">attr_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">implementation_defined base_t</span><span class="special">;<br> </span><span class="keyword">typedef</span><span class="special"> </span>parser_context_linker<span class="special">&lt;</span>parser_context<span class="special">&lt;</span><span class="identifier">AttrT</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">context_linker_t</span><span class="special">;<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">&gt;<br> </span><span class="identifier">parser_context</span><span class="special">(</span><span class="identifier">ParserT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p</span><span class="special">) {}<br><br> </span><span class="keyword"> template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword"> void<br> </span><span class="identifier"> pre_parse</span><span class="special">(</span><span class="identifier">ParserT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p</span><span class="special">, </span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">) {}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ResultT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="identifier">ResultT</span><span class="special">&amp;<br> </span><span class="identifier"> post_parse</span><span class="special">(</span><span class="identifier">ResultT</span><span class="special">&amp; </span><span class="identifier">hit</span><span class="special">, </span><span class="identifier">ParserT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p</span><span class="special">, </span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">hit</span><span class="special">; }<br> };</span></pre> <p>The non-terminal's <tt>ContextT</tt> template parameter is a concept. The <tt>parser_context</tt> class above is the simplest model of this concept. The default <tt>parser_context</tt>'s<tt> pre_parse</tt> and <tt>post_parse</tt> member functions are simply no-ops. You can think of the non-terminal's <tt>ContextT</tt> template parameter as the policy that governs how the non-terminal will behave before and after parsing. The client can supply her own context policy by passing a user defined context
-  template parameter to a particular non-terminal.</p>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="8"> Parser Context Policies </td>
+ template parameter to a particular non-terminal.<br>非终结符的 <tt>ContextT</tt>&nbsp;模板参数是一个概念。上面的 <tt>parser_context</tt>&nbsp;类是这个概念的最简单的模型。默认的 <tt>parser_context</tt>&nbsp;的<tt> + pre_parse</tt> 和 <tt>post_parse</tt>&nbsp;函数只是简单的空函数。你可以把 非终结符的 <tt>ContextT</tt>&nbsp;模板参数视为管理非 +终结符在分析前和分析后的行为的策略。用户可以通过把用户定义的语境模板参数传 递给非终结符来提供自己的语境策略。</p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td class="table_title" colspan="8"> Parser Context Policies 分析器语境 策略 </td>
   </tr>
   <tr>
-  <tr>
- <td class="table_cells"><strong><span class=identifier>attr_t</span></strong></td>
+  </tr><tr>
+ <td class="table_cells"><strong><span class="identifier">attr_t</span></strong></td> <td class="table_cells">typedef: the attribute type of the non-terminal. See
-      the <a href="indepth_the_parser.html#match">match</a>.</td>
+ the <a href="indepth_the_parser.html#match">match</a>.<br>typedef: 非 终结符的属性类,见 <a href="indepth_the_parser.html#match">匹配</a>。</td>
   </tr>
- <td class="table_cells"><strong><span class=identifier>base_t</span></strong></td> + <tr><td class="table_cells"><strong><span class="identifier">base_t</span></strong></td> <td class="table_cells">typedef: the base class of the non-terminal. The non-terminal
-    inherits from this class.</td>
+ inherits from this class.<br>typedef: 非终结符的基类。非终结符派生自该 类。</td>
   </tr>
   <tr>
<td class="table_cells"><strong><span class="identifier">context_linker_t</span></strong></td>
@@ -109,25 +84,25 @@
for Spirit to plug in additional functionality into the non-terminal parse function or even bypass the given context. This should simply be typedefed to <tt>parser_context_linker&lt;T&gt;</tt> where T is the type of the user
-      defined context class.</td>
+ defined context class.<br>typedef: 这个类使得Spirit有能力把附加的功能 加入非终结符的 parse 函数中,甚至可以绕开给定的语境。通常这是 <tt>parser_context_linker&lt;T&gt;</tt>&nbsp;的 typedef,其中T是用户定义的语 境类。</td>
   </tr>
-  <td class="table_cells"><strong>constructor</strong></td>
+  <tr><td class="table_cells"><strong>constructor</strong></td>
<td class="table_cells">Construct the context. The non-terminal is passed as
-    an argument to the constructor.</td>
+ an argument to the constructor.<br>构造语境。构造函数参数为非终结符。 </td>
   </tr>
   <tr>
     <td class="table_cells"><strong>pre_parse</strong></td>
<td class="table_cells">Do something prior to parsing. The non-terminal and
-      the current scanner are passed as arguments.</td>
+ the current scanner are passed as arguments.<br>先于分析的行为。函数 参数为非终结符和当前的扫描器。</td>
   </tr>
   <tr>
     <td class="table_cells"><strong>post_parse</strong></td>
<td class="table_cells">Do something after parsing. This is called regardless of the parse result. A reference to the parser's result is passed in. The context has the power to modify this. The non-terminal and the current scanner
-      are also passed as arguments.</td>
+ are also passed as arguments.<br>分析之后的行为。无论分析结果如何,该 函数都被调用。一个分析结果的引用将被传入函数。语境有能力修改这个引用。同样非 终结符和当前扫描器也作为参数被传入。</td>
   </tr>
-</table>
+</tbody></table>
<p>The <tt>base_t</tt> deserves further explanation. Here goes... The context is strictly a stack based class. It is created before parsing and destructed
   after the non-terminal's parse member function exits. Sometimes, we need
@@ -136,91 +111,78 @@
Since the non-terminal inherits from the context's <tt>base_t</tt>, the context itself, when created, gets access to this upon construction when the non-terminal is passed as an argument to the constructor. Ditto on <tt>pre_parse</tt> and
-  <tt>post_parse</tt>.</p>
+ <tt>post_parse</tt>.<br>对 <tt>base_t</tt>&nbsp;值得做更多的说明。这就开 始......语境类是严格的基于栈的类。它在分析前构造并在离开非终结符的分析函数之后析 构。有时,我们需要贯穿 +非终结符整个声明周期的附加信息。由于非终结符派生自语境的 <tt>base_t</tt>,因此语境本身,在构造中,当终结符作为构造函数参数传入时,可 以接触到上层
+(base_t)的构造。这 <tt>pre_parse</tt> 和
+  <tt>post_parse</tt>e 同样成立。</p>
<p>The non-terminal inherits from the context's <tt>base_t</tt> typedef. The sole requirement is that it is a class that is default constructible. The copy-construction and assignment requirements depends on the host. If the host requires it, so does the context's <tt>base_t</tt>. In general, it wouldn't hurt to provide
-  these basic requirements.</p>
-<h2>Non-default Attribute Type </h2>
-<p>Right out of the box, the <tt>parser_context</tt> class may be paramaterized with a type other than the default <tt>nil_t</tt>. The following code demonstrates the usage of the <tt>parser_context</tt> template with an explicit argument to declare rules with match results different from <tt>nil_t</tt>:</p> -<pre><span class=number> </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_context</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt; </span><span class=special>&gt; </span><span class=identifier>int_rule </span><span class=special>= </span><span class=identifier>int_p</span><span class=special>;
-
-    </span><span class=identifier>parse</span><span class=special>(
- </span><span class=string>&quot;123&quot;</span><span class=special>, - </span><span class=comment>// Using a returned value in the semantic action - </span><span class=identifier>int_rule</span><span class=special>[</span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>arg1 </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>]
-    </span><span class=special>);</span> </pre>
-<p>In this example, <tt>int_rule</tt> is declared with <tt>int</tt> attribute type. Hence, the <tt>int_rule</tt> variable can hold any parser which returns an <tt>int</tt> value (for example <tt>int_p</tt> or <tt>bin_p</tt>). The important thing to note is that we can use the returned value in the semantic action bound to the <tt>int_rule</tt>. </p> -<p><img src="theme/lens.gif" width="15" height="16"> See <a href="../example/fundamental/parser_context.cpp">parser_context.cpp</a> in the examples. This is part of the Spirit distribution.</p>
-<h2>An Example </h2>
-<p>As an example let's have a look at the Spirit parser context, which inserts some debug output to the parsing process:</p> -<pre> <span class="keyword">template</span>&lt;<span class="keyword">typename</span> ContextT&gt; - <span class="keyword">struct</span> parser_context_linker : <span class="keyword">public</span> ContextT
-    <span class="special">{</span>
-        <span class="keyword">typedef</span> ContextT base_t;
-
- <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ParserT&gt;
-        parser_context_linker(ParserT const&amp; p)
-        : ContextT(p) {}
-
- <span class="comment">// This is called just before parsing of this non-terminal</span> + these basic requirements.<br>非终结符派生自语境的 <tt>base_t</tt>&nbsp;这 个 typedef。对此唯一的要求是这个类必须有默认的构造函数。构造函数和赋值号取决 于应用环境。如果应用环境需要这些,那么语境的 <tt>base_t</tt>&nbsp;也同样需 要。大体而言,满足这些基本的要求并没有什么害处。</p>
+<h2>Non-default Attribute Type 非默认属性类型 </h2>
+<p>Right out of the box, the <tt>parser_context</tt> class may be paramaterized with a type other than the default <tt>nil_t</tt>. The following code demonstrates the usage of the <tt>parser_context</tt> template with an explicit argument to declare rules with match results different from <tt>nil_t</tt>:<br>在使用中,<tt>parser_context</tt>&nbsp;类 可以使用默认的 <tt>nil_t</tt> 以外的类作为模板参数。下面的代码展示了 <tt>parser_context</tt>&nbsp;类显式地以与 <tt>nil_t</tt> 不同的类为模板参 数:</p> +<pre><span class="number"> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_context</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt; </span><span class="special">&gt; </span><span class="identifier">int_rule </span><span class="special">= </span><span class="identifier">int_p</span><span class="special">;<br><br> </span><span class="identifier">parse</span><span class="special">(<br> </span><span class="string">"123"</span><span class="special">,<br> </span><span class="comment">// Using a returned value in the semantic action 在语义动作使用返回值<br> </span><span class="identifier">int_rule</span><span class="special">[</span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="identifier">arg1 </span><span class="special">&lt;&lt; </span><span class="identifier">endl</span><span class="special">] <br> </span><span class="special">);</span> </pre> +<p>In this example, <tt>int_rule</tt> is declared with <tt>int</tt> attribute type. Hence, the <tt>int_rule</tt> variable can hold any parser which returns an <tt>int</tt> value (for example <tt>int_p</tt> or <tt>bin_p</tt>). The important thing to note is that we can use the returned value in the semantic action bound to the <tt>int_rule</tt>.<br>在 这个例子中,<tt>int_rule</tt>&nbsp;声明的属性类为 <tt>int</tt>。因 此,<tt>int_rule</tt>&nbsp;变量可以持有任意可以返回 <tt>int</tt> 的分析器 (比如 <tt>int_p</tt> 或 <tt>bin_p</tt>)。要注意的重点是我们可以在绑定到 <tt>int_rule</tt>&nbsp;上的语义动作中使用这些返回值。</p> +<p><img src="theme/lens.gif" height="16" width="15"> See <a href="../example/fundamental/parser_context.cpp">parser_context.cpp</a> in the examples. This is part of the Spirit distribution.<br><img src="theme/lens.gif" height="16" width="15"> 例子见 <a href="../example/fundamental/parser_context.cpp">parser_context.cpp</a>。这 是Spirit发行包的一部分。</p>
+<h2>An Example 例子 </h2>
+<p>As an example let's have a look at the Spirit parser context, which inserts some debug output to the parsing process:<br>我们以一个例子来说明 Spirit的分析器语境,即在分析过程中插入一些调试输出:</p> +<pre> <span class="keyword">template</span>&lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">struct</span> parser_context_linker : <span class="keyword">public</span> ContextT<br> <span class="special">{</span> + <span class="keyword">typedef</span> ContextT base_t;<br><br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ParserT&gt;<br> parser_context_linker(ParserT const&amp; p)<br> : ContextT(p) {}<br> <br> <span class="comment">// This is called just before parsing of this non-terminal 在分析非终结符前被调用</span> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> ParserT<span class="special">,</span> <span class="keyword">typename</span> ScannerT<span class="special">&gt;</span> <span class="keyword">void</span> pre_parse<span class="special">(</span>ParserT <span class="keyword">const</span><span class="special">&amp;</span> p<span class="special">,</span> ScannerT <span class="special">&amp;</span>scan<span class="special">)</span>
         <span class="special">{</span>
- <span class="comment">// call the pre_parse function of the base class</span> + <span class="comment">// call the pre_parse function of the base class 调用基类的pre_parse函数</span> <span class="keyword">this</span><span class="special">-&gt;</span>base_t<span class="special">::</span>pre_parse<span class="special">(</span>p<span class="special">,</span> scan<span class="special">);</span>
 <span class="preprocessor">
#if</span> <span class="identifier">BOOST_SPIRIT_DEBUG_FLAGS</span> <span class="special">&amp;</span> <span class="identifier">BOOST_SPIRIT_DEBUG_FLAGS_NODES</span> <span class="keyword">if</span> <span class="special">(</span>trace_parser<span class="special">(</span>p<span class="special">.</span>derived<span class="special">())) {</span>
-            <span class="comment">// print out pre parse info</span>
+ <span class="comment">// print out pre parse info 打印出pre parse信息</span> impl<span class="special">::</span>print_node_info<span class="special">(</span> <span class="keyword">false</span><span class="special">,</span> scan.get_level<span class="special">(),</span> <span class="keyword">false</span><span class="special">,</span> parser_name<span class="special">(</span>p.derived<span class="special">()),</span> scan<span class="special">.</span>first<span class="special">,</span> scan.last<span class="special">);</span>
             <span class="special">}</span>
- scan.get_level<span class="special">()++;</span> <span class="comment">// increase nesting level</span>
-<span class="preprocessor">#endif</span>
-        <span class="special">}</span>
- <span class="comment">// This is called just after parsing of the current non-terminal</span> + scan.get_level<span class="special">()++;</span> <span class="comment">// increase nesting level 增加缩入级别</span> +<span class="preprocessor">#endif</span> <br> <span class="special">}</span> + <span class="comment">// This is called just after parsing of the current non-terminal 在分析当前非终结符后被调用</span> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> ResultT<span class="special">,</span> <span class="keyword">typename</span> ParserT<span class="special">,</span> <span class="keyword">typename</span> ScannerT<span class="special">&gt;</span> ResultT<span class="special">&amp;</span> post_parse<span class="special">(</span> - ResultT<span class="special">&amp;</span> hit<span class="special">,</span> ParserT <span class="keyword">const</span><span class="special">&amp;</span> p<span class="special">,</span> ScannerT<span class="special">&amp;</span> scan<span class="special">)
-        {</span>
+ ResultT<span class="special">&amp;</span> hit<span class="special">,</span> ParserT <span class="keyword">const</span><span class="special">&amp;</span> p<span class="special">,</span> ScannerT<span class="special">&amp;</span> scan<span class="special">)<br> {</span>
 <span class="preprocessor">
#if</span> <span class="identifier">BOOST_SPIRIT_DEBUG_FLAGS</span> <span class="special">&amp;</span> <span class="identifier">BOOST_SPIRIT_DEBUG_FLAGS_NODES</span> - <span class="special">--</span>scan.get_level<span class="special">();</span> <span class="comment">// decrease nesting level</span> + <span class="special">--</span>scan.get_level<span class="special">();</span> <span class="comment">// decrease nesting level 递减缩入级别</span> <span class="keyword">if</span> <span class="special">(</span>trace_parser<span class="special">(</span>p<span class="special">.</span>derived<span class="special">())) {</span> impl<span class="special">::</span>print_node_info<span class="special">(</span> hit<span class="special">,</span> scan<span class="special">.</span>get_level<span class="special">(),</span> <span class="keyword">true</span><span class="special">,</span> parser_name<span class="special">(</span>p<span class="special">.</span>derived<span class="special">()),</span> - scan<span class="special">.</span>first<span class="special">,</span> scan<span class="special">.</span>last<span class="special">);
-            }</span>
+ scan<span class="special">.</span>first<span class="special">,</span> scan<span class="special">.</span>last<span class="special">);<br> }</span>
 <span class="preprocessor">#endif</span>
- <span class="comment">// call the post_parse function of the base class</span> - <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-&gt;</span>base_t<span class="special">::</span>post_parse<span class="special">(</span>hit<span class="special">,</span> p<span class="special">,</span> scan<span class="special">);
-        }
-    };</span>
+ <span class="comment">// call the post_parse function of the base class 调用基类的post_parse函数</span> + <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-&gt;</span>base_t<span class="special">::</span>post_parse<span class="special">(</span>hit<span class="special">,</span> p<span class="special">,</span> scan<span class="special">);<br> }<br> };</span>
 </pre>
-<p>During debugging (<tt>BOOST_SPIRIT_DEBUG</tt> is defined) this parser context is injected into the derivation hierarchy of the current <tt>parser_context</tt>, which was originally specified to be used for a concrete parser, so the template parameter <tt>ContextT</tt> represents the original <tt>parser_context</tt>. For this reason the <tt>pre_parse</tt> and <tt>post_parse</tt> functions call it's counterparts from the base class. Additionally these functions call a special <tt>print_node_info</tt> function, which does the actual output of the parser state info of the current non-terminal. For more info about the printed information, you may want to have a look at the topic <a href="debugging.html">Debugging</a>.</p> +<p>During debugging (<tt>BOOST_SPIRIT_DEBUG</tt> is defined) this parser context is injected into the derivation hierarchy of the current <tt>parser_context</tt>, which was originally specified to be used for a concrete parser, so the template parameter <tt>ContextT</tt> represents the original <tt>parser_context</tt>. For this reason the <tt>pre_parse</tt> and <tt>post_parse</tt> functions call it's counterparts from the base class. Additionally these functions call a special <tt>print_node_info</tt>
+function, which does the actual output of the parser state info of the
+current non-terminal. For more info about the printed information, you
+may want to have a look at the topic <a href="debugging.html">Debugging</a>.<br>在调试(即定义了 <tt>BOOST_SPIRIT_DEBUG</tt><font face="Courier New"></font>)中这个语境被注 入到 +当前的 <tt>parser_context</tt>(即原先用于普通的具体分析器的语境)的派生层 次中,因此这个类的模板函数 <tt>ContextT</tt>&nbsp;即原先的 <tt>parser_context</tt>。因此 <tt>pre_parse</tt> 和 <tt>post_parse</tt>&nbsp;函数调用了基类中相应的函数。另外这些函数调用了一个 特殊的&nbsp; <tt>print_node_info</tt>&nbsp;函数,用于输出当前非终结符的分析 器状态信息。如果想了解更多的打印信息,可以查阅<a href="debugging.html">调试 </a>这一主题。</p>
 <table border="0">
-  <tr>
+  <tbody><tr>
     <td width="10"></td>
     <td width="30"><a href="../index.html">
-    <img src="theme/u_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/u_arr.gif" border="0" height="19" width="20"></a></td>
     <td width="30"><a href="indepth_the_scanner.html">
-    <img src="theme/l_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/l_arr.gif" border="0" height="19" width="20"></a></td>
     <td width="30"><a href="predefined_actors.html">
-    <img src="theme/r_arr.gif" border="0" width="20" height="19"></a></td>
+    <img src="theme/r_arr.gif" border="0" height="19" width="20"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
 <p class="copyright">&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/indepth_the_scanner.html Tue Mar 31 01:07:16 2009 +++ /trunk/libs/spirit/classic/doc/indepth_the_scanner.html Wed Sep 16 20:25:53 2009
@@ -1,290 +1,250 @@
-<html>
-<head>
-<title>In-depth The Scanner</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><title>In-depth The Scanner</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <link rel="stylesheet" href="theme/style.css" type="text/css">
 </head>
-
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
-    <td width="10">
-    </td>
- <td width="85%"> <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>In-depth:
-      The Scanner</b></font> </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td>
-  </tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+<tbody>
+<tr>
+<td width="10"> </td>
+<td width="85%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>In-depth:
+The Scanner 深入:扫描器</b></font> </td>
+<td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
+</tr>
+</tbody>
 </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="indepth_the_parser.html"><img src="theme/l_arr.gif" border="0"></a></td> - <td width="30"><a href="indepth_the_parser_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
-   </tr>
+<tbody>
+<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="indepth_the_parser.html"><img src="theme/l_arr.gif" border="0"></a></td> +<td width="30"><a href="indepth_the_parser_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
+</tr>
+</tbody>
 </table>
-<h2>Basic Scanner API </h2>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="10"> class scanner </td>
-  </tr>
-  <tr>
-  <tr>
- <td class="table_cells"><code><span class=identifier>value_t</span></code></td> - <td class="table_cells">typedef: The value type of the scanner's iterator</td>
-  </tr>
- <td class="table_cells"><code><span class=identifier>ref_t</span></code></td> - <td class="table_cells">typedef: The reference type of the scanner's iterator</td>
-  </tr>
- <td class="table_cells"><code><span class=keyword>bool </span><span class=identifier>at_end</span><span class=special>()
-    </span><span class=keyword>const</span></code></td>
-  <td class="table_cells">Returns true if the input is exhausted</td>
-  </tr>
- <td class="table_cells"><code><span class=identifier>value_t </span><span class=keyword>operator</span><span class=special>*()
-    </span><span class=keyword>const</span></code></td>
- <td class="table_cells">Dereference/get a <code><span class=identifier>value_t</span></code>
-      from the input</td>
-  </tr>
- <td class="table_cells"><code><span class=keyword> </span><span class=identifier>scanner - </span><span class=keyword>const</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>++()</span></code></td>
-  <td class="table_cells">move the scanner forward</td>
-  </tr>
-  <tr>
- <td class="table_cells"><code><span class=identifier>IteratorT&amp; first</span><span class=special></span></code></td> - <td class="table_cells">The iterator pointing to the current input position.
-      Held by reference</td>
-  </tr>
-  <tr>
- <td class="table_cells"><code><span class=identifier>IteratorT </span><span class=keyword>const</span> - <span class=identifier>last</span><span class=special></span></code></td> - <td class="table_cells">The iterator pointing to the end of the input. Held
-      by value</td>
-  </tr>
+<h2>Basic Scanner API 基本的扫描器API </h2>
+<table align="center" border="0" width="90%">
+<tbody>
+<tr>
+<td class="table_title" colspan="10"> class
+scanner </td>
+</tr>
+<tr>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="identifier">value_t</span></code></td>
+<td class="table_cells">typedef: The value type of
+the scanner's iterator
+<p>typedef,扫描器的迭代器的值类型</p>
+</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="identifier">ref_t</span></code></td>
+<td class="table_cells">typedef: The reference type
+of the scanner's iterator
+<p>typedef,扫描器迭代器的引用类型</p>
+</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="keyword">bool </span><span class="identifier">at_end</span><span class="special">() </span><span class="keyword">const</span></code></td>
+<td class="table_cells">Returns true if the input is
+exhausted<br>
+如果输入耗尽则返回真</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="identifier">value_t </span><span class="keyword">operator</span><span class="special">*()
+</span><span class="keyword">const</span></code></td>
+<td class="table_cells">Dereference/get a <code><span class="identifier">value_t</span></code> from
+the input
+<p>从输入解引用/取得一个value_t</p>
+</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="keyword"> </span><span class="identifier">scanner +</span><span class="keyword">const</span><span class="special">&amp; </span><span class="keyword">operator</span><span class="special">++()</span></code></td>
+<td class="table_cells">move the scanner forward<br>
+使扫描器步进</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="identifier">IteratorT&amp; first</span><span class="special"></span></code></td>
+<td class="table_cells">The iterator pointing to the
+current input position. Held by reference
+<p>指向当前位置的迭代器,以引用的方式保存。</p>
+</td>
+</tr>
+<tr>
+<td class="table_cells"><code><span class="identifier">IteratorT </span><span class="keyword">const</span> <span class="identifier">last</span><span class="special"></span></code></td>
+<td class="table_cells">The iterator pointing to the
+end of the input. Held by value
+<p>指向输入终点的迭代器,以值的方式保存。</p>
+</td>
+</tr>
+</tbody>
 </table>
-<p> The basic behavior of the scanner is handled by policies. The actual execution - of the scanner's public member functions listed in the table above is implemented
-  by the scanner policies.</p>
-<p> Three sets of policies govern the behavior of the scanner. These policies - make it possible to extend Spirit non-intrusively. The scanner policies allow - the core-functionality to be extended without requiring any potentially destabilizing - changes to the code. A library writer might provide her own policies that override
-  the ones that are already in place to fine tune the parsing process
- to fit her own needs. Layers above the core might also want to take advantage - of this policy based machanism. Abstract syntax tree generation, debuggers and
-  lexers come to mind.</p>
-<p> There are three sets of policies that govern:</p>
+<p> The basic behavior of the scanner is handled by policies. The
+actual execution of the scanner's public member functions listed in the
+table above is implemented by the scanner policies.<br>
+扫描器的基本行为是通过策略执行的。上表中列出的扫描器的公有成员函数的真正执 行是由扫描器策略来实现的。</p>
+<p> Three sets of policies govern the behavior of the scanner.
+These policies make it possible to extend Spirit non-intrusively. The
+scanner policies allow the core-functionality to be extended without
+requiring any potentially destabilizing changes to the code. A library
+writer might provide her own policies that override the ones that are
+already in place to fine tune the parsing process to fit her own needs.
+Layers above the core might also want to take advantage of this policy
+based machanism. Abstract syntax tree generation, debuggers and lexers
+come to mind.<br>
+有三类策略决定了扫描器的行为。这些策略使得非侵入性地扩展Spirit成为可能。扫 描器的策略使得从根本上不必对原有代码进行修改就可以扩展其核心 +功能。一个库的编写者可以用他自己编写的策略覆盖原有的策略来调整分析过程以适 应自己的需要。核心之上的层次也有可能从基于策略的设计方式获得好处。抽象
+语法树的生成、调试器、词法分析器等等就是这种情况。</p>
+<p> There are three sets of policies that govern:<br>
+三类策略分别管理:</p>
 <ul>
-  <li>Iteration and filtering</li>
-  <li>Recognition and matching</li>
-  <li>Handling semantic actions</li>
+<li>Iteration and filtering<br>
+迭代与过滤</li>
+<li>Recognition and matching<br>
+识别与匹配</li>
+<li>Handling semantic actions<br>
+处理语义动作</li>
 </ul>
 <a name="iteration_policy"></a>
 <h2>iteration_policy</h2>
-<p> Here are the default policies that govern iteration and filtering:</p>
-<pre>
- <code><span class=keyword>struct </span><span class=identifier>iteration_policy
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt;
-        </span><span class=keyword>void
- </span><span class=identifier>advance</span><span class=special>(</span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) </span><span class=keyword>const - </span><span class=special>{ </span><span class=special>++</span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>first</span><span class=special>; </span><span class=special>}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>bool </span><span class=identifier>at_end</span><span class=special>(</span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) </span><span class=keyword>const - </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>first </span><span class=special>== </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>last</span><span class=special>; </span><span class=special>}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=identifier>T </span><span class=identifier>filter</span><span class=special>(</span><span class=identifier>T </span><span class=identifier>ch</span><span class=special>) </span><span class=keyword>const - </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>ch</span><span class=special>; </span><span class=special>}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>::</span><span class=identifier>ref_t - </span><span class=identifier>get</span><span class=special>(</span><span class=identifier>ScannerT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) </span><span class=keyword>const - </span><span class=special>{ </span><span class=keyword>return </span><span class=special>*</span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>first</span><span class=special>; </span><span class=special>}
-    </span><span class=special>};</span></code></pre>
-<table width="90%" border="0" align="center">
-  <tr>
- <td class="table_title" colspan="8"> Iteration and filtering policies </td>
-  </tr>
-  <tr>
-  <tr>
-    <td class="table_cells"><b>advance</b></td>
-    <td class="table_cells">Move the iterator forward</td>
-  </tr>
-  <td class="table_cells"><b>at_end</b></td>
-    <td class="table_cells">Return true if the input is exhausted</td>
-  </tr>
-  <td class="table_cells"><b>filter</b></td>
-    <td class="table_cells">Filter a character read from the input</td>
-  </tr>
-  <td class="table_cells"><b>get</b></td>
-    <td class="table_cells">Read a character from the input</td>
-  </tr>
+<p> Here are the default policies that govern iteration and
+filtering:<br>
+这是管理迭代和过滤的默认策略:</p><pre> <code><span class="keyword">struct </span><span class="identifier">iteration_policy<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">void<br> </span><span class="identifier">advance</span><span class="special">(</span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="special">++</span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">first</span><span class="special">; </span><span class="special">}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">bool </span><span class="identifier">at_end</span><span class="special">(</span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">first </span><span class="special">== </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">last</span><span class="special">; </span><span class="special">}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="identifier">T </span><span class="identifier">filter</span><span class="special">(</span><span class="identifier">T </span><span class="identifier">ch</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">ch</span><span class="special">; </span><span class="special">}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">::</span><span class="identifier">ref_t<br> </span><span class="identifier">get</span><span class="special">(</span><span class="identifier">ScannerT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword">return </span><span class="special">*</span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">first</span><span class="special">; </span><span class="special">}<br> </span><span class="special">};</span></code></pre><table align="center" border="0" width="90%">
+<tbody>
+<tr>
+<td class="table_title" colspan="8">
+Iteration and filtering policies 迭代与过滤策略 </td>
+</tr>
+<tr>
+</tr>
+<tr>
+<td class="table_cells"><b>advance</b></td>
+<td class="table_cells">Move the iterator forward<br>
+步进迭代器</td>
+</tr>
+<tr>
+<td class="table_cells"><b>at_end</b></td>
+<td class="table_cells">Return true if the input is
+exhausted<br>
+如果输入耗尽则返回真</td>
+</tr>
+<tr>
+<td class="table_cells"><b>filter</b></td>
+<td class="table_cells">Filter a character read from
+the input<br>
+过滤从输入中读入的一个字符
+</td>
+</tr>
+<tr>
+<td class="table_cells"><b>get</b></td>
+<td class="table_cells">Read a character from the
+input从<br>
+输入中读取一个字符</td>
+</tr>
+</tbody>
 </table>
-<p> The following code snippet demonstrates a simple policy that converts all
-  characters to lower case:</p>
-<pre>
- <code><span class=keyword>struct </span><span class=identifier>inhibit_case_iteration_policy </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>iteration_policy
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>CharT</span><span class=special>&gt; - </span><span class=identifier>CharT filter</span><span class=special>(</span><span class=identifier>CharT ch</span><span class=special>) </span><span class=keyword>const
-        </span><span class=special>{
- </span><span class=keyword>return </span>std::<span class=identifier>tolower</span><span class=special>(</span><span class=identifier>ch</span><span class=special>);
-        }
-    };</span></code></pre>
-<a name="match_policy"></a>
+<p> The following code snippet demonstrates a simple policy that
+converts all characters to lower case:<br>下面的代码片断展示了一个把所有字 母转为小写的简单策略:</p><pre> <code><span class="keyword">struct </span><span class="identifier">inhibit_case_iteration_policy </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">iteration_policy<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">CharT</span><span class="special">&gt;<br> </span><span class="identifier">CharT filter</span><span class="special">(</span><span class="identifier">CharT ch</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ <br> </span><span class="keyword">return </span>std::<span class="identifier">tolower</span><span class="special">(</span><span class="identifier">ch</span><span class="special">); <br> }<br> };</span></code></pre><a name="match_policy"></a>
 <h2>match_policy</h2>
-<p> Here are the default policies that govern recognition and matching:</p>
-<pre>
- <code><span class=keyword>struct </span><span class=identifier>match_policy
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>result </span><span class=special>
-        {
- </span><span class=keyword>typedef </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt; </span><span class=identifier>type</span><span class=special>; </span><span class=special>
-        };
-
- </span><span class=keyword>const </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>nil_t</span><span class=special>&gt; - </span><span class=identifier>no_match</span><span class=special>() </span><span class=keyword>const
-        </span><span class=special>{ </span><span class=keyword>
- return </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>nil_t</span><span class=special>&gt;(); </span><span class=special>
-        }
-
- </span><span class=keyword>const </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>nil_t</span><span class=special>&gt; - </span><span class=identifier>empty_match</span><span class=special>() </span><span class=keyword>const
-        </span><span class=special>{ </span><span class=keyword>
- return </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>nil_t</span><span class=special>&gt;(</span><span class=number>0</span><span class=special>, </span><span class=identifier>nil_t</span><span class=special>());
-        </span><span class=special>}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>AttrT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>IteratorT</span><span class=special>&gt; - </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>AttrT</span><span class=special>&gt; - </span><span class=identifier>create_match</span><span class=special>( - </span><span class=keyword>std::size_t </span><span class=identifier>length</span><span class=special>, - </span><span class=identifier>AttrT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>val</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=comment>/*first*/</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=comment>/*last*/</span><span class=special>) </span><span class=keyword>const
-        </span><span class=special>{ </span><span class=keyword>
- return </span><span class=identifier>match</span><span class=special>&lt;</span><span class=identifier>AttrT</span><span class=special>&gt;(</span><span class=identifier>length</span><span class=special>, </span><span class=identifier>val</span><span class=special>); </span><span class=special>
-        }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>MatchT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>IteratorT</span><span class=special>&gt;
-        </span><span class=keyword>void
- </span><span class=identifier>group_match</span><span class=special>( - </span><span class=identifier>MatchT</span><span class=special>&amp; </span><span class=comment>/*m*/</span><span class=special>, - </span><span class=identifier>parser_id </span><span class=keyword>const</span><span class=special>&amp; </span><span class=comment>/*id*/</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=comment>/*first*/</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=comment>/*last*/</span><span class=special>) </span><span class=keyword>const </span><span class=special>{}
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Match1T</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>Match2T</span><span class=special>&gt;
-        </span><span class=keyword>void
- </span><span class=identifier>concat_match</span><span class=special>(</span><span class=identifier>Match1T</span><span class=special>&amp; </span><span class=identifier>l</span><span class=special>, </span><span class=identifier>Match2T </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>r</span><span class=special>) </span><span class=keyword>const
-        </span><span class=special>{ </span><span class=identifier>
- l</span><span class=special>.</span><span class=identifier>concat</span><span class=special>(</span><span class=identifier>r</span><span class=special>);
-        </span><span class=special>}
-    </span><span class=special>};</span></code></pre>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="12"> Recognition and matching </td>
-  </tr>
-  <tr>
-  <tr>
-    <td class="table_cells"><b>result</b></td>
- <td class="table_cells">A metafunction that returns a match type given an
-      attribute type (see In-depth: The Parser)</td>
-  </tr>
-  <td class="table_cells"><b>no_match</b></td>
-  <td class="table_cells">Create a failed match</td>
-  </tr>
-  <td class="table_cells"><b>empty_match</b></td>
- <td class="table_cells">Create an empty match. An empty match is a successful
-    epsilon match (matching length == 0)</td>
-  </tr>
-  <td class="table_cells"><b>create_match</b></td>
- <td class="table_cells">Create a match given the matching length, an attribute - and the iterator pair pointing to the matching portion of the input</td>
-  </tr>
-  <td class="table_cells"><b>group_match</b></td>
- <td class="table_cells">For non terminals such as rules, this is called after
-    a successful match has been made to allow post processing</td>
-  </tr>
-  <td class="table_cells"><b>concat_match</b></td>
-  <td class="table_cells">Concatenate two match objects</td>
-  </tr>
+<p> Here are the default policies that govern recognition and
+matching:<br>这是管理识别和匹配的默认策略:</p><pre> <code><span class="keyword">struct </span><span class="identifier">match_policy<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">result </span><span class="special"><br> { <br> </span><span class="keyword">typedef </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt; </span><span class="identifier">type</span><span class="special">; </span><span class="special"><br> };<br><br> </span><span class="keyword">const </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">nil_t</span><span class="special">&gt;<br> </span><span class="identifier">no_match</span><span class="special">() </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword"><br> return </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">nil_t</span><span class="special">&gt;(); </span><span class="special"><br> }<br><br> </span><span class="keyword">const </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">nil_t</span><span class="special">&gt;<br> </span><span class="identifier">empty_match</span><span class="special">() </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword"><br> return </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">nil_t</span><span class="special">&gt;(</span><span class="number">0</span><span class="special">, </span><span class="identifier">nil_t</span><span class="special">()); <br> </span><span class="special">}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">AttrT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">IteratorT</span><span class="special">&gt;<br> </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">AttrT</span><span class="special">&gt;<br> </span><span class="identifier">create_match</span><span class="special">(<br> </span><span class="keyword">std::size_t </span><span class="identifier">length</span><span class="special">,<br> </span><span class="identifier">AttrT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">val</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="comment">/*first*/</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="comment">/*last*/</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="keyword"><br> return </span><span class="identifier">match</span><span class="special">&lt;</span><span class="identifier">AttrT</span><span class="special">&gt;(</span><span class="identifier">length</span><span class="special">, </span><span class="identifier">val</span><span class="special">); </span><span class="special"><br> }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">MatchT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">IteratorT</span><span class="special">&gt;<br> </span><span class="keyword">void<br> </span><span class="identifier">group_match</span><span class="special">(<br> </span><span class="identifier">MatchT</span><span class="special">&amp; </span><span class="comment">/*m*/</span><span class="special">,<br> </span><span class="identifier">parser_id </span><span class="keyword">const</span><span class="special">&amp; </span><span class="comment">/*id*/</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="comment">/*first*/</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="comment">/*last*/</span><span class="special">) </span><span class="keyword">const </span><span class="special">{}<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">Match1T</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">Match2T</span><span class="special">&gt;<br> </span><span class="keyword">void<br> </span><span class="identifier">concat_match</span><span class="special">(</span><span class="identifier">Match1T</span><span class="special">&amp; </span><span class="identifier">l</span><span class="special">, </span><span class="identifier">Match2T </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">r</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{ </span><span class="identifier"><br> l</span><span class="special">.</span><span class="identifier">concat</span><span class="special">(</span><span class="identifier">r</span><span class="special">); <br> </span><span class="special">}<br> </span><span class="special">};</span></code></pre><table align="center" border="0" width="90%">
+<tbody>
+<tr>
+<td class="table_title" colspan="12">
+Recognition and matching 识别与匹配 </td>
+</tr>
+<tr>
+</tr>
+<tr>
+<td class="table_cells"><b>result</b></td>
+<td class="table_cells">A metafunction that returns
+a match type given an attribute type (see In-depth: The Parser)<br><font color="#000000">给定属性类型返回匹配</font>类型的元函数(见 深入:分析器 )</td>
+</tr>
+<tr>
+<td class="table_cells"><b>no_match</b></td>
+<td class="table_cells">Create a failed match<br>生成一个失败匹配</td>
+</tr>
+<tr>
+<td class="table_cells"><b>empty_match</b></td>
+<td class="table_cells">Create an empty match. An
+empty match is a successful epsilon match (matching length == 0)<br>生成一 个空匹配。空匹配是指成功的空集匹配(匹配长度为0)</td>
+</tr>
+<tr>
+<td class="table_cells"><b>create_match</b></td>
+<td class="table_cells">Create a match given the
+matching length, an attribute and the iterator pair pointing to the
+matching portion of the input<br>生成一个带着匹配长度、匹配属性和指向输入中 的匹配段的迭代器对的匹配</td>
+</tr>
+<tr>
+<td class="table_cells"><b>group_match</b></td>
+<td class="table_cells">For non terminals such as
+rules, this is called after a successful match has been made to allow
+post processing<br>对诸如 rule 这样的非终结符,将在成功匹配后调用它以进行后 续处理</td>
+</tr>
+<tr>
+<td class="table_cells"><b>concat_match</b></td>
+<td class="table_cells">Concatenate two match objects<br>联接两个匹配对象 </td>
+</tr>
+</tbody>
 </table>
 <a name="action_policy"></a>
 <h2>action_policy</h2>
-<p> The action policy has only one function for handling semantic actions:</p>
-<pre>
- <code><span class=keyword>struct </span><span class=identifier>action_policy
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ActorT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>AttrT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>IteratorT</span><span class=special>&gt;
-        </span><span class=keyword>void
-        </span><span class=identifier>do_action</span><span class=special>(
- </span><span class=identifier>ActorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>actor</span><span class=special>, - </span><span class=identifier>AttrT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>val</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>first</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>last</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    </span><span class=special>};</span></code></pre>
-<p> The default action policy forwards to:</p>
-<pre>
- <code><span class=identifier>actor</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>);</span></code></pre>
-<p> If the attribute <tt>val</tt> is of type nil_t. Otherwise:</p>
-<pre>
- <code><span class=identifier>actor</span><span class=special>(</span><span class=identifier>val</span><span class=special>);</span></code></pre>
+<p> The action policy has only one function for handling semantic
+actions:<br>动作策略只有一个处理语义动作的函数:</p><pre> <code><span class="keyword">struct </span><span class="identifier">action_policy<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ActorT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">AttrT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">IteratorT</span><span class="special">&gt;<br> </span><span class="keyword">void<br> </span><span class="identifier">do_action</span><span class="special">(<br> </span><span class="identifier">ActorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">actor</span><span class="special">,<br> </span><span class="identifier">AttrT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">val</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">first</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">last</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> </span><span class="special">};</span></code></pre><p> The default action policy forwards to:<br>默认的策略为:</p> +<pre> <code><span class="identifier">actor</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">);</span></code><code><span class="special"></span></code></pre>
+<p> If the attribute <tt>val</tt> is of type nil_t.
+Otherwise:<br>如果属性 <tt>val</tt> 的类型是 nil_t 的话。否则:</p>
+<pre> <code><span class="identifier">actor</span><span class="special">(</span><span class="identifier">val</span><span class="special">);</span></code><code><span class="special"></span></code></pre>
 <a name="scanner_policies_mixer"></a>
 <h3>scanner_policies mixer</h3>
-<p> The class <tt>scanner_policies</tt> combines the three scanner policy classes
-  above into one:</p>
-<pre>
-    <code><span class=keyword>template </span><span class=special>&lt;
- </span><span class=keyword>typename </span><span class=identifier>IterationPolicyT </span><span class=special>= </span><span class=identifier>iteration_policy</span><span class=special>, - </span><span class=keyword>typename </span><span class=identifier>MatchPolicyT </span><span class=special>= </span><span class=identifier>match_policy</span><span class=special>, - </span><span class=keyword>typename </span><span class=identifier>ActionPolicyT </span><span class=special>= </span><span class=identifier>action_policy</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>scanner_policies</span><span class=special>;
-</span></code></pre>
-<p> This <i>mixer</i> class inherits from all the three policies. This scanner_policies
-  class is then used to parameterize the scanner:</p>
-<pre>
-    <code><span class=keyword>template </span><span class=special>&lt;
- </span><span class=keyword>typename </span><span class=identifier>IteratorT </span><span class=special>= </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, - </span><span class=keyword>typename </span><span class=identifier>PoliciesT </span><span class=special>= </span><span class=identifier>scanner_policies</span><span class=special>&lt;&gt; </span><span class=special>&gt; - </span><span class=keyword>class </span><span class=identifier>scanner</span><span class=special>;
-</span></code></pre>
-<p> The scanner in turn inherits from the PoliciesT.</p>
+<p> The class <tt>scanner_policies</tt> combines the
+three scanner policy classes above into one:<br><tt>scanner_policies</tt>&nbsp;类把上面三类策略捆绑在了一起:</p> +<pre> <code><span class="keyword">template </span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">IterationPolicyT </span><span class="special">= </span><span class="identifier">iteration_policy</span><span class="special">,<br> </span><span class="keyword">typename </span><span class="identifier">MatchPolicyT </span><span class="special">= </span><span class="identifier">match_policy</span><span class="special">,<br> </span><span class="keyword">typename </span><span class="identifier">ActionPolicyT </span><span class="special">= </span><span class="identifier">action_policy</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">scanner_policies</span><span class="special">;</span></code><code><span class="special"><br></span></code></pre>
+<p> This <i>mixer</i> class inherits from all the
+three policies. This scanner_policies class is then used to
+parameterize the scanner:<br>这个混合器类同时继承了三个策略。然后这个 scanner_policies 就被用于将扫描器参数化:</p> +<pre> <code><span class="keyword">template </span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">IteratorT </span><span class="special">= </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*,<br> </span><span class="keyword">typename </span><span class="identifier">PoliciesT </span><span class="special">= </span><span class="identifier">scanner_policies</span><span class="special">&lt;&gt; </span><span class="special">&gt;<br> </span><span class="keyword">class </span><span class="identifier">scanner</span><span class="special">;</span></code><code><span class="special"></span></code></pre> +<p>The scanner in turn inherits from the PoliciesT.<br>而空上扫描器则继承 自 PoliciesT。</p>
 <a name="rebinding_policies"></a>
-<h3>Rebinding Policies</h3>
-<p> The scanner can be made to rebind to a different set of policies anytime. - It has a member function <tt>change_policies(new_policies)</tt>. Given a new - set of policies, this member function creates a new scanner with the new set - of policies. The result type of the <i>rebound</i> scanner can be can be obtained
-  by calling the metafunction:</p>
-<pre>
- <code><span class=identifier>rebind_scanner_policies</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class=identifier>PoliciesT</span><span class=special>&gt;::</span><span class=identifier>type</span></code></pre>
+<h3>Rebinding Policies 重绑定策略</h3>
+<p> The scanner can be made to rebind to a different set of
+policies anytime. It has a member function <tt>change_policies(new_policies)</tt>.
+Given a new set of policies, this member function creates a new scanner
+with the new set of policies. The result type of the <i>rebound</i>
+scanner can be can be obtained by calling the metafunction:<br>扫描器在任何 时刻都可以绑定另外的策略。它有一个 <tt>change_policies(new_policies)</tt><font face="Courier New"> 成员函数。给 定一个新的策略集,这个成员函数产生一个带有给定策略集的新的扫描器。重新绑定的 扫描器的结果类型可以通过下述元函数取得:</font></p> +<pre> <code><span class="identifier">rebind_scanner_policies</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">PoliciesT</span><span class="special">&gt;::</span><span class="identifier">type</span></code></pre>
 <a name="rebinding_iterators"></a>
-<h3>Rebinding Iterators</h3>
-<p> The scanner can also be made to rebind to a different iterator type anytime. - It has a member function <tt>change_iterator(first, last)</tt>. Given a new - pair of iterator of type different from the ones held by the scanner, this member - function creates a new scanner with the new pair of iterators. The result type - of the <i>rebound</i> scanner can be can be obtained by calling the metafunction:</p>
-<pre>
- <code><span class=identifier>rebind_scanner_iterator</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class=identifier>IteratorT</span><span class=special>&gt;::</span><span class=identifier>type</span></code></pre>
+<h3>Rebinding Iterators 重绑定迭代器</h3>
+<p> The scanner can also be made to rebind to a different
+iterator type anytime. It has a member function <tt>change_iterator(first,
+last)</tt>. Given a new pair of iterator of type different from
+the ones held by the scanner, this member function creates a new
+scanner with the new pair of iterators. The result type of the <i>rebound</i> +scanner can be can be obtained by calling the metafunction:<br>扫描器也可以 在任何时刻重新绑定不同的迭代器类。它有一个 <tt>change_iterator(first, +last)</tt> <font face="Courier New">成员函数。给定一对与原先的扫描器所持有 的迭代器的类型不同的迭代器,这个成员函数将产生一个带有新的迭代器对的扫描器。 重绑定的扫描器的结果类可以通过下述元函数取得:</font></p> +<pre> <code><span class="identifier">rebind_scanner_iterator</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">IteratorT</span><span class="special">&gt;::</span><span class="identifier">type</span></code></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="indepth_the_parser.html"><img src="theme/l_arr.gif" border="0"></a></td> - <td width="30"><a href="indepth_the_parser_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
-  </tr>
+<tbody>
+<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="indepth_the_parser.html"><img src="theme/l_arr.gif" border="0"></a></td> +<td width="30"><a href="indepth_the_parser_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
+</tr>
+</tbody>
 </table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<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>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
 <p class="copyright">&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/introduction.html Sat Oct 4 05:29:09 2008 +++ /trunk/libs/spirit/classic/doc/introduction.html Wed Sep 16 20:25:53 2009
@@ -1,6 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>



@@ -12,15 +11,13 @@



-  <title>Introduction</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Introduction</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -96,13 +93,13 @@


 <p>
- Spirit是一个面向对象的递归下降解析器的生成框架,利用模板元编程技术实 现。表达式模板允许我们完全用C++模仿扩展Backus泛式(EBNF)的语法。 + Spirit是一个面向对象的递归下降解析器的生成框架,利用模板元编程技术实 现。表达式模板允许我们完全用C++来模拟扩展Backus泛式(EBNF)的语法。
     </p>



-<p> Spirit框架允许一个写一个独立于C++的目标文法。
-内联EBNF文法规范可以自由地混合在其他C++代码中,还有马上能执行;这个要归功于 C++模板强大的生成能力。&nbsp;回顾一下,常规的编译器编译或者解析器生成器,需 要额外的一个翻译步骤,去把EBNF源码翻译为C代码。
+<p> Spirit框架允许只用C++来写一个目标文法。
+内联的EBNF文法规范可以自由地混合在其他C++代码中,而且还能立即执行;这个要归 功于C++模板强大的生成能力。&nbsp;回顾一下,常规的编译器-编译译或者解析器-生 成器,都需要一个额外的翻译步骤,去把EBNF源码翻译为C代码。
 </p>


@@ -118,7 +115,7 @@


 <p>
-      用Spirit的方法来近似此片段:
+      用Spirit的方法来模拟此片段:
     </p>


@@ -127,7 +124,7 @@
 </pre>


-<p>通过表达式模板的魔力,这是完全合法和可执行的C++代码。 产生的规则 <tt>expression</tt> 事实上是一个对象,有一个parse成员函数用来按照刚定义的文 法来解析。 是的,这是一个计算器。 为了简化,省略了<tt>factor</tt>里的 <tt>integer</tt>的声明。 产生的规则 <tt>expression</tt> ,在我们规范的文法 中,传统上叫做&ldquo;开始符号&rdquo;,能够识别下面的输入: +<p>通过表达式模板的魔力,这是完全合法和可执行的C++代码。 产生的规则 <tt>expression</tt> 事实上是一个对象,有一个parse成员函数用来按照所定义的文 法来解析。 是的,这是一个计算器。 为了简化,省略了<tt>factor</tt>里的 <tt>integer</tt>的声明。 产生的规则 <tt>expression</tt> ,在我们规范的文法 中,传统上叫做"开始符号",能够识别下面的输入:
     </p>


@@ -136,7 +133,7 @@
 </pre>


-<p>当然,我们对原来的EBNF语法做了一些修改。 这是为了和C++语法规则保持一 致。 最显著的是移位操作符&gt;&gt;的冗余。 因为C++中没有&ldquo;空&rdquo;操作 符,简直不可能写出下面代码: +<p>当然,我们对原来的EBNF语法做了一些修改。 这是为了和C++语法规则保持一 致。 最显著的是增加了移位操作符&gt;&gt;。 因为C++中没有"空"操作符,不可能写 出以下代码:
     </p>


@@ -145,7 +142,7 @@
 </pre>


-<p>例如在数学语法中,这意味着乘法。在EBNF语法中,意味着跟随(b跟随a)。 Spirit框架用移位操作符 <tt class="operators">&gt;&gt;</tt> 表达这跟随的意 思。 我们用操作符&gt;&gt;, 指向右的箭头,意味着&ldquo;紧接着&rdquo;。因此我 们写: +<p>例如在数学语法中,这意味着乘法。在EBNF语法中,意味着跟随(b跟随a)。 Spirit框架用移位操作符 <tt class="operators">&gt;&gt;</tt> 表达跟随的意思。 我们用操作符&gt;&gt;, 指向右的箭头,意味着"紧接着"。因此我们写:
     </p>


@@ -156,7 +153,7 @@

 <p>选择操作符 <tt class="operators">|</tt> 和圆括号
       <tt class="operators">()</tt> 保留原意。 附值操作符
- <tt class="operators">=</tt> 用来代替 EBNF的 <tt class="operators">::=</tt> 。 最后但还有,Kleene星号 <tt class="operators">*</tt> 由原来EBNF的后缀改变为前缀。代替: + <tt class="operators">=</tt> 用来代替 EBNF的 <tt class="operators">::=</tt> 。 最后但还有,Kleene星号 <tt class="operators">*</tt> 由原来EBNF中的后缀改变为前缀。对于:
     </p>


@@ -175,7 +172,7 @@


 <p>
- 因为C++中没有后缀星号 "<tt class="operators">*</tt>"。 最后,每一规则 当然地用分号"<tt>;</tt>"结尾。&nbsp; + 因为C++中没有后缀星号 "<tt class="operators">*</tt>"。 最后,每一条规 则当然要用分号"<tt>;</tt>"来结尾。&nbsp;
     </p>


@@ -221,7 +218,7 @@
 <hr size="1">

 <p class="copyright">
-      Copyright &copy; 1998-2003 Joel de Guzman<br>
+      Copyright (c) 1998-2003 Joel de Guzman<br>


       <br>
@@ -240,5 +237,4 @@



-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/numerics.html        Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/numerics.html        Wed Sep 16 20:25:53 2009
@@ -1,30 +1,28 @@
-<html>
-<head>
-<title>Numerics</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>Numerics</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Numerics</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>Numerics 数值</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="operators.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="rule.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
<p>Similar to <tt>chlit</tt>, <tt>strlit</tt> etc. numeric parsers are also primitives.
   Numeric parsers are placed on

@@ -38,7 +36,10 @@
to suit. This includes the radix base, the minimum and maximum number of allowable digits, the exponent, the fraction etc. Policies control the real number parsers' behavior. There are some predefined policies covering the most common real number
-  formats but the user can supply her own when needed. </p>
+ formats but the user can supply her own when needed.<br>与 <tt>chlit</tt>, <tt>strlit</tt>&nbsp; +等类似,数值分析器也是基元。把数值分析器单独放在一节是为了让你更好地关注这 个重要的构件。框架包含了很多预定义的、成对的有符号/无符号整数、实数分 +析器。这些分析器都是可参数化的。调整参数就可以很好的适应数值解析的大多数方 面。这些参数包含了进制、可允许的数字位数的最大最小 +值、幂、小数部分等。策略用于控制实数分析器的行为。已经预定义了涵盖常见的实 数格式分析器,同时,当必要时,用户也可以使用自定义的策略。 </p>
 <h2>uint_parser</h2>
<p>This class is the simplest among the members of the numerics package. The <tt>uint_parser</tt> can parse unsigned integers of arbitrary length and size. The <tt>uint_parser</tt>
@@ -46,120 +47,110 @@
scalars such as bigints (unlimited precision integers). Like most of the classes in Spirit, the <tt>uint_parser</tt> is a template class. Template parameters fine tune its behavior. The uint_parser is so flexible that the other numeric
-  parsers are implemented using it as the backbone.</p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>template </span><span class=special>&lt; - </span><span class=keyword>typename </span><span class=identifier>T </span><span class=special>= </span><span class="keyword">unsigned</span><span class=special>, - </span><span class=keyword>int </span><span class=identifier>Radix </span><span class=special>= </span><span class=number>10</span><span class=special>, - </span><span class=keyword>unsigned </span><span class=identifier>MinDigits </span><span class=special>= </span><span class=number>1</span><span class=special>, - </span><span class=keyword>int </span><span class=identifier>MaxDigits </span><span class=special>= -</span><span class=number>1</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>uint_parser </span><span class=special>{ </span><span class=comment>/*...*/ </span><span class=special>};</span></font></code></pre>
-<table width="90%" border="0" align="center">
-  <tr>
- <td colspan="2" class="table_title">uint_parser template parameters</td> + parsers are implemented using it as the backbone.<br>这个类是数值构件中最 简单的一个成员。<tt>uint_parser</tt> 可分析任意长度和大小的无符号整数。 <tt>uint_parser</tt> 不仅可用于分析普通的C/C++整数,还可以分析用户自定义的整 数,如 bigints(没有精度限制的整数)。像Spirit里面大多数的类那 样,<tt>uint_parser</tt> 是 +一个模板类。模板参数可以很好的调整它的行为。<tt>uint_parser</tt> 是如此的灵 活,因此其他的数值分析器都是以它为骨架构建的。</p> +<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">T </span><span class="special">= </span><span class="keyword">unsigned</span><span class="special">,<br> </span><span class="keyword">int </span><span class="identifier">Radix </span><span class="special">= </span><span class="number">10</span><span class="special">,<br> </span><span class="keyword">unsigned </span><span class="identifier">MinDigits </span><span class="special">= </span><span class="number">1</span><span class="special">,<br> </span><span class="keyword">int </span><span class="identifier">MaxDigits </span><span class="special">= -</span><span class="number">1</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">uint_parser </span><span class="special">{ </span><span class="comment">/*...*/ </span><span class="special">};</span></font></code></pre>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td colspan="2" class="table_title">uint_parser template parameters 模 板参数</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>T</b></td>
<td class="table_cells" width="79%">The numeric base type of the numeric parser.
-      Defaults to <tt>unsigned</tt></td>
+ Defaults to <tt>unsigned<br></tt>数值分析器的基本数值类型。默认为 <tt>unsigned</tt></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>Radix</b></td>
<td class="table_cells" width="79%">The radix base. This can be either 2: - binary, 8: octal, 10: decimal and 16: hexadecimal. Defaults to 10; decimal</td> + binary, 8: octal, 10: decimal and 16: hexadecimal. Defaults to 10; decimal<br>数值进制。可以为:2:二进制、8:八进制、10:十进制以及16:十六进 制。默认为10;十进制</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>MinDigits</b></td>
- <td class="table_cells" width="79%">The minimum number of digits allowable</td> + <td class="table_cells" width="79%">The minimum number of digits allowable<br>所允许的最少数位</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>MaxDigits</b></td>
<td class="table_cells" width="79%">The maximum number of digits allowable.
-      If this is -1, then the maximum limit becomes unbounded</td>
+ If this is -1, then the maximum limit becomes unbounded<br>所允许的最 多数位,如果为-1,则允许任意多数位</td>
   </tr>
-</table>
+</tbody></table>
 <br>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td colspan="2" class="table_title">Predefined uint_parsers</td>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td colspan="2" class="table_title">Predefined uint_parsers 预定义的 unit_parser</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>bin_p</b></td>
- <td class="table_cells" width="79%"><code><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, - </span><span class=number>2</span><span class=special>, </span><span class=number>1</span><span class=special>, - -</span><span class=number>1</span><span class=special>&gt; </span><span class=keyword>const</span></code></td> + <td class="table_cells" width="79%"><code><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, + </span><span class="number">2</span><span class="special">, </span><span class="number">1</span><span class="special">, + -</span><span class="number">1</span><span class="special">&gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>oct_p</b></td>
- <td class="table_cells" width="79%"><code><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, - </span><span class=number>8</span><span class=special>, </span><span class=number>1</span><span class=special>, - -</span><span class=number>1</span><span class=special>&gt; </span><span class=keyword>const</span></code></td> + <td class="table_cells" width="79%"><code><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, + </span><span class="number">8</span><span class="special">, </span><span class="number">1</span><span class="special">, + -</span><span class="number">1</span><span class="special">&gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>uint_p</b></td>
- <td class="table_cells" width="79%"><code><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, - </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, - -</span><span class=number>1</span><span class=special>&gt; </span><span class=keyword>const</span></code></td> + <td class="table_cells" width="79%"><code><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, + </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, + -</span><span class="number">1</span><span class="special">&gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>hex_p</b></td>
- <td class="table_cells" width="79%"><code><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, - </span><span class=number>16</span><span class=special>, </span><span class=number>1</span><span class=special>, - -</span><span class=number>1</span><span class=special>&gt; </span><span class=keyword>const</span></code></td> + <td class="table_cells" width="79%"><code><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, + </span><span class="number">16</span><span class="special">, </span><span class="number">1</span><span class="special">, + -</span><span class="number">1</span><span class="special">&gt; </span><span class="keyword">const</span></code></td>
   </tr>
-</table>
+</tbody></table>
<p>The following example shows how the uint_parser can be used to parse thousand - separated numbers. The example can correctly parse numbers such as 1,234,567,890.</p> -<pre><span class=keyword> </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, </span><span class=number>3</span><span class=special>&gt; </span><span class=identifier>uint3_p</span><span class=special>; </span><span class=comment>// 1..3 digits - </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>3</span><span class=special>, </span><span class=number>3</span><span class=special>&gt; </span><span class=identifier>uint3_3_p</span><span class=special>; </span><span class=comment>// exactly 3 digits - </span><span class=identifier>ts_num_p </span><span class=special>= </span><span class=special>(</span><span class=identifier>uint3_p </span><span class=special>&gt;&gt; </span><span class=special>*(</span><span class=literal>',' </span><span class=special>&gt;&gt; </span><span class=identifier>uint3_3_p</span><span class=special>)); </span><span class=comment>// our thousand separated number parser</span></pre> + separated numbers. The example can correctly parse numbers such as 1,234,567,890.<br>下面的例子示范了如何使用uint_parser分析千位分隔的数值。该 例子可正确地分析诸如1,234,567,890这样的数字。</p> +<pre><span class="keyword"> </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, </span><span class="number">3</span><span class="special">&gt; </span><span class="identifier">uint3_p</span><span class="special">; </span><span class="comment">// 1..3 digits 1-3位数字<br> </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">3</span><span class="special">, </span><span class="number">3</span><span class="special">&gt; </span><span class="identifier">uint3_3_p</span><span class="special">; </span><span class="comment">// exactly 3 digits 正好3位数字<br> </span><span class="identifier">ts_num_p </span><span class="special">= </span><span class="special">(</span><span class="identifier">uint3_p </span><span class="special">&gt;&gt; </span><span class="special">*(</span><span class="literal">',' </span><span class="special">&gt;&gt; </span><span class="identifier">uint3_3_p</span><span class="special">)); </span><span class="comment">// our thousand separated number parser 我们的 千位分隔数值分析器</span></pre> <p><tt>bin_p</tt>, <tt>oct_p</tt>, <tt>uint_p</tt> and <tt>hex_p</tt> are parser generator objects designed to be used within expressions. Here's an example - of a rule that parses comma delimited list of numbers (We've seen this <a href="quick_start.html#list_of_numbers">before</a>):</p> -<pre><code><span class=identifier> </span><span class=identifier>list_of_numbers </span><span class=special>=</span> <span class=identifier>real_p </span><span class=special>&gt;&gt; *(</span><span class=literal>','</span> <span class=special>&gt;&gt; </span><span class=identifier>real_p</span><span class=special>)</span></code>;
-</pre>
-<p></p>
+ of a rule that parses comma delimited list of numbers (We've seen this <a href="quick_start.html#list_of_numbers">before</a>):<br><tt>bin_p</tt>, <tt>oct_p</tt>, <tt>uint_p</tt> 和 <tt>hex_p</tt> 是设计成在表达式中使用的分 析器生成器。以下是一个分析以逗号分隔的数值的规则例子(<a href="quick_start.html#list_of_numbers">之前</a> 我们已经见过这个例子):</p> +<pre><code><span class="identifier"> </span><span class="identifier">list_of_numbers </span><span class="special">=</span> <span class="identifier">real_p </span><span class="special">&gt;&gt; *(</span><span class="literal">','</span> <span class="special">&gt;&gt; </span><span class="identifier">real_p</span><span class="special">)</span></code>;<br></pre>
+
<p>Later, we shall see how we can extract the actual numbers parsed by the numeric parsers. We shall deal with this when we get to the section on <a href="semantic_actions.html#specialized_actions">specialized
-  actions</a>.</p>
+ actions</a>.<br>稍后,我们将会看到如何从数值分析器中获得它们分析出的数 字。我们将在<a href="http://www.boost.org/libs/spirit/doc/semantic_actions.html#specialized_actions";>特 定动作</a>一节中接触这些。</p>
 <h2>int_parser</h2>
<p>The <tt>int_parser</tt> can parse signed integers of arbitrary length and size. This is almost the same as the <tt>uint_parser</tt>. The only difference is the additional task of parsing the <tt><span class="quotes">'+'</span></tt> or <tt class="quotes">'-'</tt> sign preceding the number. The class interface
-  is the same as that of the uint_parser.<br>
+ is the same as that of the uint_parser.<br><tt>int_parser</tt> 可以分析任 意长度和大小的有符号整数。这与 <tt>uint_parser</tt>&nbsp;几乎完全一样,唯一 的不同是 <tt>int_parser</tt>&nbsp;多分析了数值前面的'+'、'-'号。这个类的接口 与 <tt>uint_parser</tt> 一样。
 </p>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td colspan="2" class="table_title">A predefined int_parser</td>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td colspan="2" class="table_title">A predefined int_parser &nbsp;预定 义的 int_parser</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>int_p</b></td>
- <td class="table_cells" width="79%"><span class=identifier><code>int_parser</code></span><code><span class=special>&lt;</span><span class=keyword>int</span><span class=special>, - </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, - -</span><span class=number>1</span><span class=special>&gt; </span><span class=keyword>const</span></code></td> + <td class="table_cells" width="79%"><span class="identifier"><code>int_parser</code></span><code><span class="special">&lt;</span><span class="keyword">int</span><span class="special">, + </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, + -</span><span class="number">1</span><span class="special">&gt; </span><span class="keyword">const</span></code></td>
   </tr>
-</table>
+</tbody></table>
 <h2>real_parser</h2>
<p>The <tt>real_parser</tt> can parse real numbers of arbitrary length and size limited by its parametric type <tt>T</tt>. The <tt>real_parser</tt> is a template - class with 2 template parameters. Here's the <tt>real_parser</tt> template interface:</p>
-<pre><span class=keyword>    template</span><span class=special>&lt;
- </span><span class=keyword>typename </span><span class=identifier>T </span><span class=special>= </span><span class=keyword>double</span><span class=special>, - </span><span class=keyword>typename </span><span class=identifier>RealPoliciesT </span><span class=special>= </span><span class=identifier>ureal_parser_policies</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt; </span><span class=special>&gt; -</span><span class=keyword> struct </span><span class=identifier>real_parser</span><span class=special>;</span></pre> + class with 2 template parameters. Here's the <tt>real_parser</tt> template interface:<br><tt>real_parser</tt> 可以在它的模板参数 <tt>T</tt> 所 限制的范围内的分析任意长度和大小的实数。<tt>real_parser</tt> 是一个有两个模 板参数的模板类。以下是 <tt>real_parser</tt> 的接口:</p> +<pre><span class="keyword"> template</span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">T </span><span class="special">= </span><span class="keyword">double</span><span class="special">,<br> </span><span class="keyword">typename </span><span class="identifier">RealPoliciesT </span><span class="special">= </span><span class="identifier">ureal_parser_policies</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt; </span><span class="special">&gt;<br></span><span class="keyword"> struct </span><span class="identifier">real_parser</span><span class="special">;</span></pre> <p>The first template parameter is its numeric base type <tt>T</tt>. This defaults
-  to <tt>double</tt>. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/bulb.gif" width="13" height="18"><b>
-      Parsing special numeric types</b><br>
+ to <tt>double</tt>.<br>第一个模板参数是它的数值基类型 <tt>T</tt>。默认值 为 <tt>double</tt>. </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/bulb.gif" height="18" width="13"><b> + Parsing special numeric types </b><strong>分析特定的数值类型 </strong><br>
       <br>
Notice that the numeric base type <tt>T</tt> can be specified by the user. This means that we can use the numeric parsers to parse user defined numeric types such as <tt>fixed_point</tt> (fixed point reals) and <tt>bigint</tt>
-      (unlimited precision integers).</td>
+ (unlimited precision integers).<br>注意,数值类型 <tt>T</tt> 可以由用 户定义。这意味着我们可以使用数值分析器分析用户定义的的数值类型,比如 <tt>fixed_point</tt>(定点实数)和 <tt>bigint</tt>(精度无限的整数)。</td>
   </tr>
-</table>
+</tbody></table>
<p>The second template parameter is a class that groups all the policies and defaults to <tt>ureal_parser_policies&lt;T&gt;</tt>. Policies control the real number parsers' behavior. The default policies provided are designed to parse C/C++
@@ -168,293 +159,177 @@
or <tt class="quotes">'E'</tt> and <b>eee</b> is the exponent optionally preceded by <tt class="quotes">'-'</tt> or <tt><span class="quotes">'+'</span></tt>. This corresponds to the following grammar, with the exception that plain integers
-  without the decimal point are also accepted by default.</p>
-<pre><code><font color="#000000"><span class=keyword> </span><span class=identifier>floatingliteral - </span><span class=special>= </span><span class=identifier>fractionalconstant </span><span class=special>&gt;&gt; </span><span class=special>!</span><span class=identifier>exponentpart - </span><span class=special>| </span><span class=special>+</span><span class=identifier>digit_p </span><span class=special>&gt;&gt; </span><span class=identifier>exponentpart
-        </span><span class=special>;
-
-    </span><span class=identifier>fractionalconstant
- </span><span class=special>= </span><span class=special>*</span><span class=identifier>digit_p </span><span class=special>&gt;&gt; </span><span class=literal>'.' </span><span class=special>&gt;&gt; </span><span class=special>+</span><span class=identifier>digit_p - </span><span class=special>| </span><span class=special>+</span><span class=identifier>digit_p </span><span class=special>&gt;&gt; </span><span class=literal>'.'
-        </span><span class=special>;
-
-    </span><span class=identifier>exponentpart
- </span><span class=special>= </span><span class=special>(</span><span class=literal>'e' </span><span class=special>| </span><span class=literal>'E'</span><span class=special>) </span><span class=special>&gt;&gt; </span><span class=special>!(</span><span class=literal>'+' </span><span class=special>| </span><span class=literal>'-'</span><span class=special>) </span><span class=special>&gt;&gt; </span><span class=special>+</span><span class=identifier>digit_p
-        </span><span class=special>;</span></font></code></pre>
+ without the decimal point are also accepted by default.<br>第二个模板参数 是组织全部策略的策略类,默认值为 <tt>ureal_parser_policies&lt;T&gt;</tt>。策 略控制着实数分析器的行为。所提供的默认策略被设计成识别C/C++风格的实数,格式 为 <span style="font-weight: bold;">nnn.fff.Eeee</span>,<span style="font-weight: bold;">nnn</span>为整数部分,<span style="font-weight: bold;">fff</span>为小数部分,<span style="font-weight: bold;">E</span>为字 母'E'或'e'<span style="font-weight: bold;">,eee</span>为指数部分,前面可以 有'+'或'-'。这对应于以下语法,除了一点,缺省情况下,如果没有小数点,普通的整 数也是被接受的。</p> +<pre><code><font color="#000000"><span class="keyword"> </span><span class="identifier">floatingliteral<br> </span><span class="special">= </span><span class="identifier">fractionalconstant </span><span class="special">&gt;&gt; </span><span class="special">!</span><span class="identifier">exponentpart<br> </span><span class="special">| </span><span class="special">+</span><span class="identifier">digit_p </span><span class="special">&gt;&gt; </span><span class="identifier">exponentpart<br> </span><span class="special">;<br><br> </span><span class="identifier">fractionalconstant<br> </span><span class="special">= </span><span class="special">*</span><span class="identifier">digit_p </span><span class="special">&gt;&gt; </span><span class="literal">'.' </span><span class="special">&gt;&gt; </span><span class="special">+</span><span class="identifier">digit_p<br> </span><span class="special">| </span><span class="special">+</span><span class="identifier">digit_p </span><span class="special">&gt;&gt; </span><span class="literal">'.'<br> </span><span class="special">;<br><br> </span><span class="identifier">exponentpart<br> </span><span class="special">= </span><span class="special">(</span><span class="literal">'e' </span><span class="special">| </span><span class="literal">'E'</span><span class="special">) </span><span class="special">&gt;&gt; </span><span class="special">!(</span><span class="literal">'+' </span><span class="special">| </span><span class="literal">'-'</span><span class="special">) </span><span class="special">&gt;&gt; </span><span class="special">+</span><span class="identifier">digit_p<br> </span><span class="special">;</span></font></code></pre> <p>The default policies are provided to take care of the most common case (there are many ways to represent, and hence parse, real numbers). In most cases, the default setting of the <tt>real_parser</tt> is sufficient and can be used straight out of the box. Actually, there are four <tt>real_parser</tt>s pre-defined for
-  immediate use:</p>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td colspan="2" class="table_title">Predefined real_parsers</td>
+ immediate use:<br>为了应付最常见的情况(实数有很多种写法,因此分析过程也 是),我们提供了默认策略。再大多数情况下,<tt>real_parser</tt> 的默认设定完 全够用,而且可以拿来就用。实际上,有四种预定义的 <tt>real_parser</tt> 可以直 接使用:</p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td colspan="2" class="table_title">Predefined real_parsers &nbsp;预定 义的 real_parser</td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>ureal_p</b></td>
- <td class="table_cells" width="79%"><span class=identifier><code>real_parser</code></span><code><span class=special>&lt;</span><span class=keyword>double</span><span class=special>, - </span><span class=identifier>ureal_parser_policies</span><span class=special>&lt;</span><span class=keyword>double</span><span class=special>&gt;
-      &gt; </span><span class=keyword>const</span></code></td>
+ <td class="table_cells" width="79%"><span class="identifier"><code>real_parser</code></span><code><span class="special">&lt;</span><span class="keyword">double</span><span class="special">, + </span><span class="identifier">ureal_parser_policies</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;
+      &gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>real_p</b></td>
- <td class="table_cells" width="79%"><span class=identifier><code>real_parser</code></span><code><span class=special>&lt;</span><span class=keyword>double</span><span class=special>, - </span><span class=identifier>real_parser_policies</span><span class=special>&lt;</span><span class=keyword>double</span><span class=special>&gt;
-      &gt; </span><span class=keyword>const</span></code></td>
+ <td class="table_cells" width="79%"><span class="identifier"><code>real_parser</code></span><code><span class="special">&lt;</span><span class="keyword">double</span><span class="special">, + </span><span class="identifier">real_parser_policies</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;
+      &gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>strict_ureal_p</b></td>
- <td class="table_cells" width="79%"><span class=identifier><code>real_parser</code></span><code><span class=special>&lt;</span><span class=keyword>double</span><span class=special>, - </span><span class=identifier>strict_ureal_parser_policies</span><span class=special>&lt;</span><span class=keyword>double</span><span class=special>&gt;
-      &gt; </span><span class=keyword>const</span></code></td>
+ <td class="table_cells" width="79%"><span class="identifier"><code>real_parser</code></span><code><span class="special">&lt;</span><span class="keyword">double</span><span class="special">, + </span><span class="identifier">strict_ureal_parser_policies</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;
+      &gt; </span><span class="keyword">const</span></code></td>
   </tr>
   <tr>
     <td class="table_cells" width="21%"><b>strict_real_p</b></td>
- <td class="table_cells" width="79%"><span class=identifier><code>real_parser</code></span><code><span class=special>&lt;</span><span class=keyword>double</span><span class=special>, - </span><span class=identifier>strict_real_parser_policies</span><span class=special>&lt;</span><span class=keyword>double</span><span class=special>&gt;
-      &gt; </span><span class=keyword>const</span></code></td>
+ <td class="table_cells" width="79%"><span class="identifier"><code>real_parser</code></span><code><span class="special">&lt;</span><span class="keyword">double</span><span class="special">, + </span><span class="identifier">strict_real_parser_policies</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;
+      &gt; </span><span class="keyword">const</span></code></td>
   </tr>
-</table>
-<p>We've seen <tt>real_p</tt> before. <tt>ureal_p</tt> is its unsigned variant.</p>
-<h3><a name="strict_reals"></a>Strict Reals </h3>
+</tbody></table>
+<p>We've seen <tt>real_p</tt> before. <tt>ureal_p</tt> is its unsigned variant.<br>前面我们已经见过 <tt>real_p</tt>。<tt>ureal_p</tt> 是它的有符号 变体。</p> +<h3><a name="strict_reals"></a>Strict Reals&nbsp;<span style="font-weight: bold;">严格实数</span> </h3> <p>Integer numbers are considered a subset of real numbers, so <tt>real_p</tt> and <tt>ureal_p</tt> recognize integer numbers (without a dot) as real numbers. <tt>strict_real_p</tt> and <tt>strict_ureal_p</tt> are the equivalent parsers that <strong>require</strong> a dot to be present for a number to be considered
-  a successful match.</p>
-<h2>Advanced: real_parser policies</h2>
-<p>The parser policies break down real number parsing into 6 steps:</p>
-<table width="90%" border="0" align="center">
-  <tr>
+ a successful match.<br>整数被认为是实数的一个子集,所以 <tt>real_p</tt> 和 <tt>ureal_p</tt>&nbsp;将整数(没有小数点的数值)识别为实数。 <tt>strict_real_p</tt> 和 <tt>strict_ureal_p</tt>&nbsp;与前面两个分析器相 同,只是<span style="font-weight: bold;">需要</span>小数点在数值中出现才会产 生成功匹配。</p>
+<h2>Advanced: real_parser policies&nbsp;高级:real_parser的策略</h2>
+<p>The parser policies break down real number parsing into 6 steps:<br>分析 器的策略将实数的分析过程分为六步:</p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
     <td class="table_cells">1</td>
     <td class="table_cells"><b>parse_sign</b></td>
-    <td class="table_cells">Parse the prefix sign</td>
+    <td class="table_cells">Parse the prefix sign<br>分析前缀的符号</td>
   </tr>
   <tr>
     <td class="table_cells">2</td>
     <td class="table_cells"><b>parse_n</b></td>
- <td class="table_cells">Parse the integer at the left of the decimal point</td> + <td class="table_cells">Parse the integer at the left of the decimal point<br>分析小数点左边的整数部分</td>
   </tr>
   <tr>
     <td class="table_cells">3</td>
     <td class="table_cells"><b>parse_dot</b></td>
-    <td class="table_cells">Parse the decimal point</td>
+    <td class="table_cells">Parse the decimal point<br>分析小数点</td>
   </tr>
   <tr>
     <td class="table_cells">4</td>
     <td class="table_cells"><b>parse_frac_n</b></td>
-    <td class="table_cells">Parse the fraction after the decimal point</td>
+ <td class="table_cells">Parse the fraction after the decimal point<br>分析小数点之后的小数部分</td>
   </tr>
   <tr>
     <td class="table_cells">5</td>
     <td class="table_cells"><b>parse_exp</b></td>
-    <td class="table_cells">Parse the exponent prefix (e.g. 'e')</td>
+ <td class="table_cells">Parse the exponent prefix (e.g. 'e')<br>分析指 数前缀(比如字母'e')</td>
   </tr>
   <tr>
     <td class="table_cells">6</td>
     <td class="table_cells"><b>parse_exp_n</b></td>
-    <td class="table_cells">Parse the actual exponent</td>
+ <td class="table_cells">Parse the actual exponent<br>分析实际的指数 </td>
   </tr>
-</table>
+</tbody></table>
<p>And the interaction of these sub-parsing tasks is further controlled by these
-  3 policies:</p>
-<table width="90%" border="0" align="center">
-  <tr>
+ 3 policies:<br>而且这些子分析步骤间的互动更进一步被下面这三个策略所控 制:</p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
     <td class="table_cells">1</td>
     <td class="table_cells"><b>allow_leading_dot</b></td>
- <td class="table_cells">Allow a leading dot to be present (&quot;.1&quot; becomes
-      equivalent to &quot;0.1&quot;)</td>
+    <td class="table_cells">Allow a leading dot to be present (".1" becomes
+ equivalent to "0.1")<br>允许数值以小数点打头(".1"变得与"0.1"等价 )</td>
   </tr>
   <tr>
     <td class="table_cells">2</td>
     <td class="table_cells"><b>allow_trailing_dot</b></td>
- <td class="table_cells">Allow a trailing dot to be present (&quot;1.&quot; becomes
-    equivalent to &quot;1.0&quot;)</td>
+ <td class="table_cells">Allow a trailing dot to be present ("1." becomes
+    equivalent to "1.0")<br>允许数值以小数点结尾("1."变得与"1.0"等价)</td>
   </tr>
   <tr>
     <td class="table_cells">3</td>
     <td class="table_cells"><b>expect_dot</b></td>
- <td class="table_cells">Require a dot to be present (disallows &quot;1&quot; to
-    be equivalent to &quot;1.0&quot;)</td>
+    <td class="table_cells">Require a dot to be present (disallows "1" to
+ be equivalent to "1.0")<br>要求数值中有小数点(不允许"1"与"1.0"等价 )</td>
   </tr>
-</table>
-<p>[ <img src="theme/lens.gif" width="15" height="16"> From here on, required
+</tbody></table>
+<p>[ <img src="theme/lens.gif" height="16" width="15"> From here on, required reading: <a href="scanner.html">The Scanner</a>, <a href="indepth_the_parser.html">In-depth The Parser</a> and <a href="indepth_the_scanner.html">In-depth The Scanner</a>
-  ]</p>
+ ]</p><p>[<img style="width: 15px; height: 16px;" alt="" src="theme/lens.gif"> 要理解以下内容,需要阅读:<a href="scanner.html">扫描 器</a>、<a href="indepth_the_parser.html">深入分析器</a> 和 <a href="indepth_the_scanner.html">深入扫描器</a>]</p>
 <h2>sign_parser and sign_p</h2>
<p>Before we move on, a small utility parser is included here to ease the parsing of the <span class="quotes">'-'</span> or <span class="quotes">'+'</span> sign.
-  While it is easy to write one:</p>
-<pre> <span class=identifier>sign_p </span><span class=special>= </span><span class=special>(</span><span class=identifier>ch_p</span><span class=special>(</span><span class=literal>'+'</span>) <span class=special>| </span><span class=literal>'-'</span><span class="special">)</span><span class=literal>;</span></pre> + While it is easy to write one:<br>在我们继续深入之前,先加入一个工具分析 器,以使解析 <span class="quotes">'-'</span> 或 <span class="quotes">'+'</span> 符号变得容易些。虽然这玩意很容易写:<span class="quotes"></span></p> +<pre> <span class="identifier">sign_p </span><span class="special">= </span><span class="special">(</span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'+'</span>) <span class="special">| </span><span class="literal">'-'</span><span class="special">)</span><span class="literal">;</span></pre> <p>it is not possible to extract the actual sign (positive or negative) without resorting to semantic actions. The sign_p parser has a bool attribute returned to the caller through the match object which, after parsing, is set to <strong>true</strong> if the parsed sign is negative. This attribute detects if the negative sign
-  has been parsed. Examples:</p>
-<pre><span class=special> </span><span class=keyword>bool </span><span class=identifier>is_negative</span><span class=special>; - </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>sign_p</span><span class=special>[</span><span class=identifier>assign_a</span><span class=special>(</span><span class=identifier>is_negative</span><span class=special>)]</span><span class=special>;</span></pre>
-<p><span class=special></span>or simply...</p>
-<pre> <span class=comment>// directly extract the result from the match result's value</span> - <span class=keyword>bool </span><span class=identifier>is_negative </span><span class=special>= </span><span class=identifier>sign_p</span><span class=special>.</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>).</span><span class=identifier>value</span><span class=special>();</span><span class=comment> </span></pre> + has been parsed. Examples:<br>抛开语义动作而又正确的提取符号(正或负)是 不可能的。sign_p分析器在匹配后,在返回给调用着的匹配对象中有一个bool属性,如 果所解析的符号为负号,则该属性值为<strong>true</strong>。这个属性用于检测是 否分析到符号。例:</p> +<pre><span class="special"> </span><span class="keyword">bool </span><span class="identifier">is_negative</span><span class="special">;<br> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">sign_p</span><span class="special">[</span><span class="identifier">assign_a</span><span class="special">(</span><span class="identifier">is_negative</span><span class="special">)]</span><span class="special">;</span></pre>
+<p><span class="special"></span>or simply...<br>或者简单些...</p>
+<pre> <span class="comment">// directly extract the result from the match result's value 从匹配结果的值中直接取出结果</span> + <span class="keyword">bool </span><span class="identifier">is_negative </span><span class="special">= </span><span class="identifier">sign_p</span><span class="special">.</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">).</span><span class="identifier">value</span><span class="special">();</span><span class="comment"> </span></pre> <p>The sign_p parser expects attached semantic actions to have a signature (see <a href="semantic_actions.html#specialized_actions">Specialized Actions</a>
-  for further detail) compatible with: </p>
-<p><b>Signature for functions:</b></p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>void </span><span class=identifier>func</span><span class=special>(</span><span class="keyword">bool</span><span class=identifier> is_negative</span><span class=special>);</span></font></code></pre>
-<p><b>Signature for functors:</b> </p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>ftor
-    </span><span class=special>{
- </span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()(</span><span class="keyword">bool</span><span class=identifier> is_negative</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    </span><span class=special>};</span></font></code></pre>
-<h2><span class=identifier>ureal_parser_policies</span></h2>
-<pre><span class=comment> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>ureal_parser_policies
-    </span><span class=special>{
- </span><span class=keyword>typedef </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, -</span><span class=number>1</span><span class=special>&gt; </span><span class=identifier>uint_parser_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>int_parser</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, -</span><span class=number>1</span><span class=special>&gt; </span><span class=identifier>int_parser_t</span><span class=special>;
-
- </span><span class=keyword>static const bool</span> <span class=identifier>allow_leading_dot</span> <span class=special> =</span> <span class=literal>true</span><span class=special>;</span><span class=special> - </span><span class=keyword>static const bool</span> <span class=identifier>allow_trailing_dot </span><span class=special>=</span> <span class=literal>true</span><span class=special>;</span><span class=special></span> -<span class=special> </span><span class=keyword>static const bool</span> <span class=identifier>expect_dot</span> <span class=special> =</span> <span class=literal>false</span><span class=special>;</span><span class=special></span><span class=special><br> - </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>match_result</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>, </span><span class="identifier">nil_t</span><span class=special>&gt;::</span><span class=identifier>type - parse_sign</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>no_match</span><span class=special>(); }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>uint_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>uint_parser_t</span><span class=special>().</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>chlit</span><span class=special>&lt;&gt;, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_dot</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>ch_p</span><span class=special>(</span><span class=literal>'.'</span><span class=special>).</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>uint_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_frac_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>uint_parser_t</span><span class=special>().</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>chlit</span><span class=special>&lt;&gt;, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_exp</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>as_lower_d</span><span class=special>[</span><span class=literal>'e'</span><span class=special>].</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=keyword>int</span><span class=identifier>_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_exp_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return int</span><span class=identifier>_parser_t</span><span class=special>().</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-    };
-</span></pre>
-<p><span class=special></span><span class=identifier>The default ureal_parser_policies
-  uses the lower level integer numeric parsers to do its job. </span></p>
-<h2><span class=identifier>real_parser_policies</span></h2>
-<pre> <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>real_parser_policies </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>ureal_parser_policies</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static </span><span class=keyword>typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>sign_parser</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - </span><span class=identifier>parse_sign</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>sign_p</span><span class=special>.</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); </span><span class=special>}
-    </span><span class=special>};</span></pre>
+ for further detail) compatible with:<br>sign_p分析器要求连接的语义动作有 与下面兼容的签名(查看<a href="semantic_actions.html#specialized_actions">特 定动作</a>可获得更进一步的细节): </p>
+<p><b>Signature for functions: 函数签名:</b></p>
+<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">void </span><span class="identifier">func</span><span class="special">(</span><span class="keyword">bool</span><span class="identifier"> is_negative</span><span class="special">);</span></font></code></pre>
+<p><b>Signature for functors: 仿函数签名:</b> </p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">ftor<br> </span><span class="special">{<br> </span><span class="keyword">void </span><span class="keyword">operator</span><span class="special">()(</span><span class="keyword">bool</span><span class="identifier"> is_negative</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> </span><span class="special">};</span></font></code></pre>
+<h2><span class="identifier">ureal_parser_policies</span></h2>
+<pre><span class="comment"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">ureal_parser_policies<br> </span><span class="special">{<br> </span><span class="keyword">typedef </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, -</span><span class="number">1</span><span class="special">&gt; </span><span class="identifier">uint_parser_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">int_parser</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, -</span><span class="number">1</span><span class="special">&gt; </span><span class="identifier">int_parser_t</span><span class="special">;<br><br> </span><span class="keyword">static const bool</span> <span class="identifier">allow_leading_dot</span> <span class="special"> =</span> <span class="literal">true</span><span class="special">;</span><span class="special"> + </span><span class="keyword">static const bool</span> <span class="identifier">allow_trailing_dot </span><span class="special">=</span> <span class="literal">true</span><span class="special">;</span><span class="special"></span> +<span class="special"> </span><span class="keyword">static const bool</span> <span class="identifier">expect_dot</span> <span class="special"> =</span> <span class="literal">false</span><span class="special">;</span><span class="special"></span><span class="special"><br> + </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">match_result</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">, </span><span class="identifier">nil_t</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_sign</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">no_match</span><span class="special">(); }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">uint_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">uint_parser_t</span><span class="special">().</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">chlit</span><span class="special">&lt;&gt;, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_dot</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'.'</span><span class="special">).</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">uint_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_frac_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">uint_parser_t</span><span class="special">().</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">chlit</span><span class="special">&lt;&gt;, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_exp</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">as_lower_d</span><span class="special">[</span><span class="literal">'e'</span><span class="special">].</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br><br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="keyword">int</span><span class="identifier">_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_exp_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return int</span><span class="identifier">_parser_t</span><span class="special">().</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br> };<br></span></pre> +<p><span class="special"></span><span class="identifier">The default ureal_parser_policies + uses the lower level integer numeric parsers to do its job.<br>默认的 ureal_parser_policies用更低一层的整数分析器来完成它的工作。</span></p>
+<h2><span class="identifier">real_parser_policies</span></h2>
+<pre> <span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">real_parser_policies </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">ureal_parser_policies</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static </span><span class="keyword">typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">sign_parser</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> </span><span class="identifier">parse_sign</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">sign_p</span><span class="special">.</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); </span><span class="special">}<br> </span><span class="special">};</span></pre> <p>Notice how the real_parser_policies replaced <b><tt>parse_sign</tt></b> of the <b>u</b>real_parser_policies from which it is subclassed. The default real_parser_policies simply uses a <tt>sign_p</tt> instead of <tt>scan.no_match()</tt> in the <tt>parse_sign
-  </tt> step. </p>
-<h2><span class=identifier>strict_ureal_parser_policies and strict_real_parser_policies</span></h2> -<pre> <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>strict_ureal_parser_policies </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>ureal_parser_policies</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;
-    </span><span class=special>{</span>
-<span class=special> </span><span class=keyword>static const bool</span> <span class=identifier>expect_dot</span><span class=special> =</span> <span class=literal>true</span><span class=special>;</span><span class=special></span><span class=special></span>
-    <span class=special>};</span>
-
- <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>strict_real_parser_policies </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>real_parser_policies</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;
-    </span><span class=special>{</span>
-<span class=special> </span><span class=keyword>static const bool</span> <span class=identifier>expect_dot</span><span class=special> =</span> <span class=literal>true</span><span class=special>;</span><span class=special></span><span class=special></span>
-    <span class=special>};</span></pre>
+ </tt> step.<br>注意,real_parser_policies 是如何替换<span style="font-weight: bold;">u</span>real_parser_policies----它的基类的 <b><tt>parse_sign</tt></b> 的。默认的real_parser_policies只是在 <b><tt>parse_sign</tt></b> 这步简单的使用 <tt>sign_p</tt>&nbsp;替换 <tt>scan.no_match()</tt>。 </p> +<h2><span class="identifier">strict_ureal_parser_policies and strict_real_parser_policies</span></h2> +<pre> <span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">strict_ureal_parser_policies </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">ureal_parser_policies</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="special">{</span> +<span class="special"> </span><span class="keyword">static const bool</span> <span class="identifier">expect_dot</span><span class="special"> =</span> <span class="literal">true</span><span class="special">;</span><span class="special"></span><span class="special"></span>
+    <span class="special">};</span>
+
+ <span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">strict_real_parser_policies </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">real_parser_policies</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="special">{</span> +<span class="special"> </span><span class="keyword">static const bool</span> <span class="identifier">expect_dot</span><span class="special"> =</span> <span class="literal">true</span><span class="special">;</span><span class="special"></span><span class="special"></span>
+    <span class="special">};</span></pre>
<p>Again, these policies replaced just the policies they wanted different from
-  their superclasses.</p>
+ their superclasses.<br>再次,这些策略类只替换了那些它们想与基类不同的策 略。</p> <p><i>Specialized</i> real parser policies can reuse some of the defaults while replacing a few. For example, the following is a real number parser policy that - parses thousands separated numbers with at most two decimal places and no exponent. + parses thousands separated numbers with at most two decimal places and no exponent.<br><span style="font-style: italic;">特化的</span>实数分析器策 略可复用一些经过小的修改的默认策略。例如,下面是 一个分析千位分隔、最多两位 小数、没有指数部分的实数。
 </p>
-<p><img src="theme/lens.gif" width="15" height="16">The full source code can be - viewed <a href="../example/fundamental/thousand_separated.cpp">here</a>. </p>
-<pre>
-<span class=identifier> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>ts_real_parser_policies </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>ureal_parser_policies</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;
-    {
- </span><span class=comment>// These policies can be used to parse thousand separated
-        //  numbers with at most 2 decimal digits after the decimal
-        //  point. e.g. 123,456,789.01
-
- </span><span class=keyword>typedef </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, </span><span class=number>2</span><span class=special>&gt; </span><span class=identifier>uint2_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, -</span><span class=number>1</span><span class=special>&gt; </span><span class=identifier>uint_parser_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>int_parser</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, -</span><span class=number>1</span><span class=special>&gt; </span><span class=identifier>int_parser_t</span><span class=special>;
-
- </span><span class=comment>////////////////////////////////// 2 decimal places Max - </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>uint2_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_frac_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>uint2_t</span><span class=special>().</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>); }
-
-</span><span class=special> </span><span class=comment>////////////////////////////////// No exponent<br></span> <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>chlit</span><span class=special>&lt;&gt;, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_exp</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>no_match</span><span class=special>(); }
-
-</span><span class=special> </span><span class=comment>////////////////////////////////// No exponent<br></span> <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>int_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - parse_exp_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>) - { </span><span class=keyword>return </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>no_match</span><span class=special>(); }
-
- </span><span class=comment>////////////////////////////////// Thousands separated numbers - </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>static typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>uint_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type - <a name="scanner_save"></a>parse_n</span><span class=special>(</span><span class=identifier>ScannerT</span><span class=special>&amp; </span><span class=identifier>scan</span><span class=special>)
-        {
- </span><span class=keyword>typedef typename </span><span class=identifier>parser_result</span><span class=special>&lt;</span><span class=identifier>uint_parser_t</span><span class=special>, </span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class=identifier>type RT</span><span class=special>; - </span><span class="keyword">static </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>1</span><span class=special>, </span><span class=number>3</span><span class=special>&gt; </span><span class=identifier>uint3_p</span><span class=special>; - </span><span class="keyword">static </span><span class=identifier>uint_parser</span><span class=special>&lt;</span><span class=keyword>unsigned</span><span class=special>, </span><span class=number>10</span><span class=special>, </span><span class=number>3</span><span class=special>, </span><span class=number>3</span><span class=special>&gt; </span><span class=identifier>uint3_3_p</span><span class=special>;
-
- </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>RT hit </span><span class=special>= </span><span class=identifier>uint3_p</span><span class=special>.</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>))
-            {
- </span><span class=identifier>T n</span><span class=special>; - </span><span class="keyword">typedef typename </span>ScannerT<span class="special">::</span>iterator_t iterator_t;<span class=special> - </span>iterator_t save<span class="special"> = </span>scan.first<span class="special">; - </span><span class=keyword>while </span><span class=special>(</span><span class=identifier>match</span><span class=special>&lt;&gt; </span><span class=identifier>next </span><span class=special>= (</span><span class=literal>',' </span><span class=special>&gt;&gt; </span><span class=identifier>uint3_3_p</span><span class=special>[</span><span class=identifier>assign_a</span><span class=special>(</span><span class=identifier>n</span><span class=special>)]).</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>))
-                {
- </span><span class=identifier>hit</span><span class=special>.</span><span class=identifier>value</span><span class=special>() *= </span><span class=number>1000</span><span class=special>; - </span><span class=identifier>hit</span><span class=special>.</span><span class=identifier>value</span><span class=special>() += </span><span class=identifier>n</span><span class=special>; - </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>concat_match</span><span class=special>(</span><span class=identifier>hit</span><span class=special>, </span><span class=identifier>next</span><span class=special>); - </span><span class="identifier">save </span><span class=special><span class="special">= </span></span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">first</span><span class=special><span class="special">;</span>
-                }
- </span>scan<span class="special">.</span>first<span class="special"> = </span>save<span class="special">; - </span><span class=keyword>return </span><span class=identifier>hit</span><span class=special>;
-
-</span><span class=special> // Note: On erroneous input such as &quot;123,45&quot;, the result should<br> // be a partial match &quot;123&quot;. 'save' is used to makes sure that<br> // the scanner position is placed at the last *valid* parse<br> // position.<br> } - </span><span class=keyword>return </span><span class=identifier>scan</span><span class=special>.</span><span class=identifier>no_match</span><span class=special>();
-        }
-    };</span></pre>
+<p><img src="theme/lens.gif" height="16" width="15">The full source code can be + viewed <a href="../example/fundamental/thousand_separated.cpp">here</a>.<br><img src="theme/lens.gif" height="16" width="15">完整的代码在 <a href="../example/fundamental/thousand_separated.cpp">这里</a>。 </p> +<pre><span class="identifier"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">T</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">ts_real_parser_policies </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">ureal_parser_policies</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;<br> {<br> </span><span class="comment">// These policies can be used to parse thousand separated<br> // numbers with at most 2 decimal digits after the decimal<br> // point. e.g. 123,456,789.01<br></span><span class="special"> </span><span class="comment">// 这些策略可用于分析小数点后最多两位数字的千 位分隔数值。如 123,456,789.01<br></span><br><span class="comment"> </span><span class="keyword">typedef </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, </span><span class="number">2</span><span class="special">&gt; </span><span class="identifier">uint2_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, -</span><span class="number">1</span><span class="special">&gt; </span><span class="identifier">uint_parser_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">int_parser</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, -</span><span class="number">1</span><span class="special">&gt; </span><span class="identifier">int_parser_t</span><span class="special">;<br><br> </span><span class="comment">////////////////////////////////// 2 decimal places Max 最 多两位数字<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">uint2_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_frac_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">uint2_t</span><span class="special">().</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">); }<br><br></span><span class="special"> </span><span class="comment">////////////////////////////////// No exponent 无指数 <br></span> <span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">chlit</span><span class="special">&lt;&gt;, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_exp</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">no_match</span><span class="special">(); }<br><br></span><span class="special"> </span><span class="comment">////////////////////////////////// No exponent 无指数<br></span> <span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">int_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> parse_exp_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> { </span><span class="keyword">return </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">no_match</span><span class="special">(); }<br><br> </span><span class="comment">////////////////////////////////// Thousands separated numbers 千位分隔数值<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">static typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">uint_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type<br> <a name="scanner_save"></a>parse_n</span><span class="special">(</span><span class="identifier">ScannerT</span><span class="special">&amp; </span><span class="identifier">scan</span><span class="special">)<br> {<br> </span><span class="keyword">typedef typename </span><span class="identifier">parser_result</span><span class="special">&lt;</span><span class="identifier">uint_parser_t</span><span class="special">, </span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type RT</span><span class="special">;<br> </span><span class="keyword">static </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">1</span><span class="special">, </span><span class="number">3</span><span class="special">&gt; </span><span class="identifier">uint3_p</span><span class="special">;<br> </span><span class="keyword">static </span><span class="identifier">uint_parser</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">, </span><span class="number">10</span><span class="special">, </span><span class="number">3</span><span class="special">, </span><span class="number">3</span><span class="special">&gt; </span><span class="identifier">uint3_3_p</span><span class="special">;<br><br> </span><span class="keyword">if </span><span class="special">(</span><span class="identifier">RT hit </span><span class="special">= </span><span class="identifier">uint3_p</span><span class="special">.</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">))<br> {<br> </span><span class="identifier">T n</span><span class="special">;<br> </span><span class="keyword">typedef typename </span>ScannerT<span class="special">::</span>iterator_t iterator_t;<span class="special"> + </span>iterator_t save<span class="special"> = </span>scan.first<span class="special">;<br> </span><span class="keyword">while </span><span class="special">(</span><span class="identifier">match</span><span class="special">&lt;&gt; </span><span class="identifier">next </span><span class="special">= (</span><span class="literal">',' </span><span class="special">&gt;&gt; </span><span class="identifier">uint3_3_p</span><span class="special">[</span><span class="identifier">assign_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)]).</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">))<br> {<br> </span><span class="identifier">hit</span><span class="special">.</span><span class="identifier">value</span><span class="special">() *= </span><span class="number">1000</span><span class="special">;<br> </span><span class="identifier">hit</span><span class="special">.</span><span class="identifier">value</span><span class="special">() += </span><span class="identifier">n</span><span class="special">;<br> </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">concat_match</span><span class="special">(</span><span class="identifier">hit</span><span class="special">, </span><span class="identifier">next</span><span class="special">);<br> </span><span class="identifier">save </span><span class="special"><span class="special">= </span></span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">first</span><span class="special"><span class="special">;</span>
+                }
+ </span>scan<span class="special">.</span>first<span class="special"> = </span>save<span class="special">;<br> </span><span class="keyword">return </span><span class="identifier">hit</span><span class="special">;<br><br></span><span class="special"> // Note: On erroneous input such as "123,45", the result should<br> // be a partial match "123". 'save' is used to makes sure that<br> // the scanner position is placed at the last *valid* parse<br> // position.<br></span><span class="special"> // 注:当输入错误 时,如 "123,45",结果会是部分匹配 "123"。'save' 用于确保<br> // 扫描器位置位于最后的 *有效* 分析位置。<br> }<br> </span><span class="keyword">return </span><span class="identifier">scan</span><span class="special">.</span><span class="identifier">no_match</span><span class="special">();<br> }<br> };</span></pre>
 <table border="0">
-  <tr>
+  <tbody><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="operators.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="rule.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2002 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2002 Joel de Guzman<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>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/operators.html       Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/operators.html       Wed Sep 16 20:25:53 2009
@@ -1,81 +1,79 @@
-<html>
-<head>
-<title>Operators</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>Operators</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Operators</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>Operators 操作符</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="primitives.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="numerics.html"><img src="theme/r_arr.gif" border="0"></a></td>
    </tr>
-</table>
+</tbody></table>
<p>Operators are used as a means for object composition and embedding. Simple parsers may be composed to form composites through operator overloading, crafted to approximate the syntax of an Extended Backus-Normal Form (EBNF) variant.
-  An expression such as:</p>
-<pre><code><font color="#000000"> <span class=identifier>a </span><span class=special>| </span><span class=identifier>b</span></font></code></pre> + An expression such as:<br>操作符用于对象的组合和内嵌。简单的分析器可以经 由操作符重载组合而成合成分析器,构造类似于EBNF的语法变体。诸如下面的表达 式:</p> +<pre><code><font color="#000000"> <span class="identifier">a </span><span class="special">| </span><span class="identifier">b</span></font></code></pre> <p>actually yields a new parser type which is a composite of its operands, a and b. Taking this example further, if a and b were of type <tt>chlit</tt>&lt;&gt;,
-  the result would have the composite type:</p>
-<pre><code><font color="#000000"> <span class=identifier>alternative</span><span class=special>&lt;</span><span class=identifier>chlit</span><span class=special>&lt;&gt;, </span><span class=identifier>chlit</span><span class=special>&lt;&gt; </span><span class=special>&gt;</span></font></code></pre> + the result would have the composite type:<br>实际上构成了一个新的分析 器,它的类型由两个操作子组合而成,a与b。在这例子上更进一步,如果a和b的类型 是 <tt>chlit</tt>&lt;&gt;,那么结果就是一个合成的类:</p> +<pre><code><font color="#000000"> <span class="identifier">alternative</span><span class="special">&lt;</span><span class="identifier">chlit</span><span class="special">&lt;&gt;, </span><span class="identifier">chlit</span><span class="special">&lt;&gt; </span><span class="special">&gt;</span></font></code></pre> <p> In general, for any binary operator, it will take its two arguments, parser1
-  and parser2, and create a new composed parser of the form</p>
-<pre><code><font color="#000000"> <span class=identifier>op</span><span class=special>&lt;</span><span class=identifier>parser1</span><span class=special>, </span><span class=identifier>parser2</span><span class=special>&gt;</span></font></code></pre> + and parser2, and create a new composed parser of the form<br>总而言之,任 意二元操作符都接受两个参数,parser1 和 parser2,并创建一个新的合成分析器,形 式为:</p> +<pre><code><font color="#000000"> <span class="identifier">op</span><span class="special">&lt;</span><span class="identifier">parser1</span><span class="special">, </span><span class="identifier">parser2</span><span class="special">&gt;</span></font></code></pre> <p>where parser1 and parser2 can be arbitrarily complex parsers themselves, with
-  the only limitations being what your compiler imposes. </p>
-<h3>Set Operators</h3>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="3">Set operators</td>
+ the only limitations being what your compiler imposes.<br>其中 parser1 和 parser2 可以是任意复杂的分析器,他们的复杂度仅取决于编译期的限制。 </p>
+<h3>Set Operators 集合操作符</h3>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+    <td class="table_title" colspan="3">Set operators 集合操作符</td>
   </tr>
   <tr>
- <td class="table_cells" width="20%"><code><span class=identifier>a </span><span class=special>|
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="24%">Union</td>
- <td class="table_cells" width="56%">Match a or b. Also referred to as alternative</td> + <td class="table_cells" width="20%"><code><span class="identifier">a </span><span class="special">|
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="24%">Union<br>并集</td>
+ <td class="table_cells" width="56%">Match a or b. Also referred to as alternative<br>匹配a或b。也叫选择操作符</td>
   </tr>
   <tr>
- <td class="table_cells" width="20%"><code><span class=identifier>a </span><span class=special>&
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="24%">Intersection</td>
-    <td class="table_cells" width="56%">Match a and b</td>
+ <td class="table_cells" width="20%"><code><span class="identifier">a </span><span class="special">&amp;
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="24%">Intersection<br>交集</td>
+    <td class="table_cells" width="56%">Match a and b<br>同时匹配a和b</td>
   </tr>
   <tr>
- <td class="table_cells" width="20%"><code><span class=identifier>a </span><span class=special>-
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="24%">Difference</td>
+ <td class="table_cells" width="20%"><code><span class="identifier">a </span><span class="special">-
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="24%">Difference<br>差集</td>
<td class="table_cells" width="56%">Match a but not b. If both match and b's - matched text is shorter than a's matched text, a successful match is made</td> + matched text is shorter than a's matched text, a successful match is made<br><span style="color: rgb(0, 0, 0);">匹配a,但并不匹配b。如果二者同时 匹配且b的匹配串长度小于a的匹配串长度,那么认为匹配成功</span></td>
   </tr>
   <tr>
- <td class="table_cells" width="20%"><code><span class=identifier>a </span><span class=special>^
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="24%">XOR</td>
-    <td class="table_cells" width="56%">Match a or b, but not both</td>
+ <td class="table_cells" width="20%"><code><span class="identifier">a </span><span class="special">^
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="24%">XOR<br>异或</td>
+ <td class="table_cells" width="56%">Match a or b, but not both<br>匹配 a或b,但不同时匹配二者</td>
   </tr>
-</table>
-<p><b>Short-circuiting</b></p>
+</tbody></table>
+<p><b>Short-circuiting 短路行为</b></p>
<p>Alternative operands are tried one by one on a first come first served basis starting from the leftmost operand. After a successfully matched alternative is found, the parser concludes its search, essentially short-circuiting the search for other potentially viable candidates. This short-circuiting implicitly
-  gives the highest priority to the leftmost alternative.</p>
+ gives the highest priority to the leftmost alternative.<br>选择符自左向右 以先到先得的方式逐个测试它的操作数。当成功地找到一个可选匹配之后,分析器就结 束搜索,从而彻底停止搜索潜在的匹配,也就是短路搜索。这种短路行为隐式地给予最 左边的选项以最高优先级。</p> <p>Short-circuiting is done in the same manner as C or C++'s logical expressions; e.g. <tt>if</tt> <tt><span class="operators">(</span>x <span class="operators">&lt;</span> 3 <span class="operators">||</span> y <span class="operators">&lt;</span> 2<span class="operators">)</span></tt>
@@ -84,139 +82,143 @@
rule for alternatives which is necessary, given the non-deterministic nature of the Spirit parser compiler, short-circuiting improves the execution time. If the order of your alternatives is logically irrelevant, strive to put the
-  (expected) most common choice first for maximum efficiency.</p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/lens.gif" width="15" height="16"> <b>Intersections</b><br> + (expected) most common choice first for maximum efficiency.<br>这种短路在 C/C++的表达式中同样存在:比如在 <tt>if</tt> <tt><span class="operators">(</span>x <span class="operators">&lt;</span> + 3 <span class="operators">||</span> y <span class="operators">&lt;</span> 2<span class="operators">)</span></tt>&nbsp;中,如果x小于3成立,那么y&lt;2这个条件 根本就不 +会被测试。短路行为除了给予选项必要的隐式优先级规则,还赋予Spirit分析器非确 定性行为,从而缩短了执行时间。如果你的选项的顺序与表达式的逻辑没 +有关系,那么尽可能的把最可能出现的匹配项放在最前面,这样可以将效率最大化。 </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/lens.gif" height="16" width="15"> <b>Intersections 交集</b><br>
       <br>
Some researchers assert that the intersections (e.g. <tt>a &amp; b</tt>) - let us define context sensitive languages (<a href="references.html#intersections">&quot;XBNF&quot;</a> - [citing Leu-Weiner, 1973]). &quot;The theory of defining a language as the + let us define context sensitive languages (<a href="references.html#intersections">"XBNF"</a>
+      [citing Leu-Weiner, 1973]). "The theory of defining a language as the
intersection of a finite number of context free languages was developed
-      by Leu and Weiner in 1973&quot;.<br>
+ by Leu and Weiner in 1973".<br>某些研究者断言,交集(如 <tt>a &amp; b</tt>)使我们能够定义语境相关的语法(<a href="references.html#intersections">"XBNF"</a><a href="http://www.boost.org/libs/spirit/doc/references.html#intersections";></a> [citing Leu-Weiner, 1973])。"定义一个语言,使之成为有限语境无关语言的交集的 理论,由Leu 和 Weiner在1973年提出"。<br>
       <br>
- <b><img src="theme/lens.gif" width="15" height="16"> <b></b>~ Operator</b><br> + <b><img src="theme/lens.gif" height="16" width="15"> ~ Operator 取反 操作符</b><br>
       <br>
The complement operator <tt>~</tt> was originally put into consideration. Further understanding of its value and meaning leads us to uncertainty. The basic problem stems from the fact that <tt>~a</tt> will yield <tt>U-a</tt>, where <tt>U</tt> is the universal set of all strings. However, where it makes sense, some parsers can be complemented (see the <a href="primitives.html#negation">primitive
-      character parsers</a> for examples).</td>
+ character parsers</a> for examples).<br>最初是打算实现取反操作符~的。 但是随着对它的值和含义的进一步理解,我们变得没那么确定了。问题来源于这里: <tt>~a</tt> 将产生 <tt>U-a</tt>,其中 <tt>U</tt> 是所有串的全集。然而,对某 些分析器来说,求反是有意义的(相关例子在<a href="primitives.html#negation">单字符分析器</a>)。</td>
   </tr>
-</table>
-<h3>Sequencing Operators</h3>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="3">Sequencing operators</td>
+</tbody></table>
+<h3>Sequencing Operators 序列操作符</h3>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+ <td class="table_title" colspan="3">Sequencing operators 序列操作符 </td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=identifier>a </span><span class=special>&gt;&gt;
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="23%">Sequence</td>
-    <td class="table_cells" width="56%">Match a and b in sequence</td>
+ <td class="table_cells" width="21%"><code><span class="identifier">a </span><span class="special">&gt;&gt;
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="23%">Sequence <br>并置</td>
+ <td class="table_cells" width="56%">Match a and b in sequence<br>顺序匹 配a和b</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=identifier>a </span><span class=special>&&
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="23%">Sequential-and</td>
+ <td class="table_cells" width="21%"><code><span class="identifier">a </span><span class="special">&amp;&amp;
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="23%">Sequential-and<br>顺序与</td>
<td class="table_cells" width="56%">Sequential-and. Same as above, match a
-      and b in sequence</td>
+      and b in sequence<br>顺序与,与上面类似,顺序匹配a与b</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=identifier>a </span><span class=special>||
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="23%">Sequential-or</td>
-    <td class="table_cells" width="56%">Match a or b in sequence</td>
+ <td class="table_cells" width="21%"><code><span class="identifier">a </span><span class="special">||
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="23%">Sequential-or<br>顺序或</td>
+ <td class="table_cells" width="56%">Match a or b in sequence<br>顺序匹 配a或b</td>
   </tr>
-</table>
+</tbody></table>
<p>The sequencing operator <tt class="operators">&gt;&gt;</tt> can alternatively be thought of as the sequential-and operator. The expression <tt>a <span class="operators">&amp;&amp;</span> b</tt> reads as match a and b in sequence. Continuing this logic, we can also have a sequential-or operator where the expression <tt>a <span class="operators">||</span> b</tt> reads as match a or b and in sequence. That is, if both a and b match, - it must be in sequence; this is equivalent to <tt>a &gt;&gt; !b | b</tt>. </p>
-<h3>Optional and Loops</h3>
-<table width="90%" border="0" align="center">
-  <tr>
-    <td class="table_title" colspan="3">Optional and Loops</td>
+ it must be in sequence; this is equivalent to <tt>a &gt;&gt; !b | b</tt>.<br>可以认为并置操作符 <tt class="operators">&gt;&gt;</tt>&nbsp;和顺 序与一样。表达式 <tt>a <span class="operators">&amp;&amp;</span> + b</tt> 读作顺序匹配a与b。照着这个逻辑,我们就有了顺序或操作符,它的表达 式 <tt>a <span class="operators">||</span> + b</tt> 读作顺序匹配a或b。即,如果a与b都匹配了,那么他们一定是按顺序匹配 的。这个表达式等价于 <tt>a &gt;&gt; !b | b</tt>. </p>
+<h3>Optional and Loops 可选与循环</h3>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
+    <td class="table_title" colspan="3">Optional and Loops 可选与循环</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=special>*</span><span class=identifier>a</span></code></td>
-    <td class="table_cells" width="23%">Kleene star</td>
-    <td class="table_cells" width="56%">Match a zero (0) or more times</td>
+ <td class="table_cells" width="21%"><code><span class="special">*</span><span class="identifier">a</span></code></td>
+    <td class="table_cells" width="23%">Kleene star<br>克林闭包</td>
+ <td class="table_cells" width="56%">Match a zero (0) or more times<br>匹配a 零到任意多次</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=special>+</span><span class=identifier>a</span></code></td>
-    <td class="table_cells" width="23%">Positive</td>
-    <td class="table_cells" width="56%">Match a one (1) or more times</td>
+ <td class="table_cells" width="21%"><code><span class="special">+</span><span class="identifier">a</span></code></td>
+    <td class="table_cells" width="23%">Positive<br>加号</td>
+ <td class="table_cells" width="56%">Match a one (1) or more times<br>匹 配a 一到任意多次</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=special>!</span><span class=identifier>a</span></code></td>
-    <td class="table_cells" width="23%">Optional</td>
- <td class="table_cells" width="56%">Match a zero (0) or one (1) time</td> + <td class="table_cells" width="21%"><code><span class="special">!</span><span class="identifier">a</span></code></td>
+    <td class="table_cells" width="23%">Optional<br>可选</td>
+ <td class="table_cells" width="56%">Match a zero (0) or one (1) time<br>匹配a零次或一次</td>
   </tr>
   <tr>
- <td class="table_cells" width="21%"><code><span class=identifier>a </span><span class=special>%
-      </span><span class=identifier>b</span></code></td>
-    <td class="table_cells" width="23%">List</td>
+ <td class="table_cells" width="21%"><code><span class="identifier">a </span><span class="special">%
+      </span><span class="identifier">b</span></code></td>
+    <td class="table_cells" width="23%">List<br>列表</td>
<td class="table_cells" width="56%">Match a list of one or more repetitions of a separated by occurrences of b. This is the same as <tt>a &gt;&gt; *(b - &gt;&gt; a)</tt>. Note that <tt>a</tt> must not also match <tt>b</tt></td> + &gt;&gt; a)</tt>. Note that <tt>a</tt> must not also match <tt>b<br></tt>匹配出现任意多 a 的列表,表中各项由 b 分隔。等同于 <tt>a &gt;&gt; *(b
+      &gt;&gt; a)</tt>。注意,<tt>a</tt> 必须不能也匹配 <tt>b</tt></td>
   </tr>
-</table>
-<p><img src="theme/note.gif" width="16" height="16"> If we look more closely,
+</tbody></table>
+<p><img src="theme/note.gif" height="16" width="16"> If we look more closely, take note that we generalized the optional expression of the form <tt>!a</tt> in the same category as loops. This is logical, considering that the optional
-  matches the expression following it zero (0) or one (1) time. </p>
-<p><b>Primitive type operands</b></p>
+ matches the expression following it zero (0) or one (1) time.<br>如果看得 更近一些,会注意到 <tt>!a</tt> 这种形式的可选符被划分到循环这类里。这是逻辑 上的划分,可以认为可选符循环它的操作子0或1次。 </p>
+<p><b>Primitive type operands 基本的类型操作数</b></p>
<p> For binary operators, one of the operands but not both may be a <tt>char</tt>, <tt> wchar_t</tt>, <tt>char const<span class="operators">*</span></tt> or <tt>wchar_t const<span class="operators">*</span></tt>. Where P is a parser object, here
-  are some examples:</p>
-<pre><code><span class=identifier> </span><span class=identifier>P </span><span class=special>| </span><span class=literal>'x' - </span><span class=identifier>P </span><span class=special>- </span><span class=identifier>L</span><span class=string>"Hello World" - </span><span class=literal>'x' </span><span class=special>&gt;&gt; </span><span class=identifier>P - </span><span class=string>"bebop" </span><span class=special>&gt;&gt; </span><span class=identifier>P</span></code></pre> + are some examples:<br>对于二元操作符,他们的操作数中的一个,且只有一个可 以是 <tt>char</tt>, + <tt> wchar_t</tt>, <tt>char const<span class="operators">*</span></tt> or <tt>wchar_t + const<span class="operators">*</span></tt>。下面是一些例子,其中 P 是分析 器对象:</p> +<pre><code><span class="identifier"> </span><span class="identifier">P </span><span class="special">| </span><span class="literal">'x'<br> </span><span class="identifier">P </span><span class="special">- </span><span class="identifier">L</span><span class="string">"Hello World"<br> </span><span class="literal">'x' </span><span class="special">&gt;&gt; </span><span class="identifier">P<br> </span><span class="string">"bebop" </span><span class="special">&gt;&gt; </span><span class="identifier">P</span></code></pre> <p>It is important to emphasize that C++ mandates that operators may only be overloaded if at least one argument is a user-defined type. Typically, in an expression involving multiple operators, explicitly typing the leftmost operand as a parser is enough to cause propagation to all the rest of the operands to its right
-  to be regarded as parsers. Examples:</p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=identifier>r </span><span class=special>= </span><span class=literal>'a' </span><span class=special>| </span><span class=literal>'b' </span><span class=special>| </span><span class=literal>'c' </span><span class=special>| </span><span class=literal>'d'</span><span class=special>; </span><span class=comment>// ill formed - </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>ch_p</span><span class=special>(</span><span class=literal>'a'</span><span class=special>) </span><span class=special>| </span><span class=literal>'b' </span><span class=special>| </span><span class=literal>'c' </span><span class=special>| </span><span class=literal>'d'</span><span class=special>; </span><span class=comment>// OK</span></font></code></pre>
-<p>The second case is parsed as follows:</p>
-<pre><code><font color="#000000"> r <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(((</span><span class=identifier>chlit</span><span class=special>&lt;</span><span class=keyword>char</span><span class=special>&gt; </span><span class=special>| </span><span class=keyword>char</span><span class=special>) </span><span class=special>| </span><span class=keyword>char</span><span class=special>) </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font>
-
- a <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(</span><span class=identifier>chlit</span><span class=special>&lt;</span><span class=keyword>char</span><span class=special>&gt; </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font> - r <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(((</span><span class=identifier>a</span><span class=special>) </span><span class=special>| </span><span class=keyword>char</span><span class=special>) </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font>
-
- b <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(</span><span class=identifier>a </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font> - r <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(((</span><span class=identifier>b</span><span class=special>)) </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font>
-
- c <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(</span><span class=identifier>b </span><span class=special>| </span><span class=keyword>char</span><span class=special>)</span></font> - r <font color="#0000ff"><img src="theme/arrow.gif"> <span class=special>(((</span><span class=identifier>c</span><span class=special>)))</span></font></font></code></pre>
-<p><b>Operator precedence and grouping</b></p>
+ to be regarded as parsers. Examples:<br>必须强调,C++要求只有在至少一个操 作数为用户定义类型时,才允许操作符重载。一般而言,在一个包涵多个操作符的表达 式中,显式地将最左边的操作数的类型声明为分析器就足以使其他的操作数也被视为分 析器了。例如:</p> +<pre><code><font color="#000000"><span class="identifier"> </span><span class="identifier">r </span><span class="special">= </span><span class="literal">'a' </span><span class="special">| </span><span class="literal">'b' </span><span class="special">| </span><span class="literal">'c' </span><span class="special">| </span><span class="literal">'d'</span><span class="special">; </span><span class="comment">// 错误形式<br> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'a'</span><span class="special">) </span><span class="special">| </span><span class="literal">'b' </span><span class="special">| </span><span class="literal">'c' </span><span class="special">| </span><span class="literal">'d'</span><span class="special">; </span><span class="comment">// OK</span></font></code></pre>
+<p>The second case is parsed as follows:<br>第二个表达式是这样分析的:</p>
+<pre><code><font color="#000000"> r <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(((</span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt; </span><span class="special">| </span><span class="keyword">char</span><span class="special">) </span><span class="special">| </span><span class="keyword">char</span><span class="special">) </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font>
+
+ a <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(</span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt; </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font> + r <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(((</span><span class="identifier">a</span><span class="special">) </span><span class="special">| </span><span class="keyword">char</span><span class="special">) </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font>
+
+ b <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(</span><span class="identifier">a </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font> + r <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(((</span><span class="identifier">b</span><span class="special">)) </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font>
+
+ c <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(</span><span class="identifier">b </span><span class="special">| </span><span class="keyword">char</span><span class="special">)</span></font> + r <font color="#0000ff"><img src="theme/arrow.gif"> <span class="special">(((</span><span class="identifier">c</span><span class="special">)))</span></font></font></code></pre>
+<p><b>Operator precedence and grouping 操作符优先级和分组</b></p>
<p>Since we are defining our meta-language in C++, we follow C/C++'s operator precedence rules. Grouping expressions inside the parentheses override this (e.g., <tt><span class="operators">*(</span>a <span class="operators">| </span> b<span class="operators">)</span></tt> reads: match a or b zero (0) or more
-  times). </p>
+ times).<br>由于我们的元语言是在C++里定义的,我们必须遵守C/C++的操作符优先 级规则。把表达式用括号分组则可超越这个规则。比如,<tt><span class="operators">*(</span>a <span class="operators">|</span> + b<span class="operators">)</span></tt> 解读为:匹配a或b零到任意多次。 </p>
 <table border="0">
-  <tr>
+  <tbody><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="primitives.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="numerics.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/organization.html Sat Oct 4 05:29:09 2008 +++ /trunk/libs/spirit/classic/doc/organization.html Wed Sep 16 20:25:53 2009
@@ -1,19 +1,16 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>





-  <title>Organization</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Organization</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -382,47 +379,47 @@
 </table>


-<p>Spirit有四层,再加一个独立的顶层。 独立的那层由行为器和迭代器组成,不依 赖于其他层。 框架的结构是完全正交的。 层与层之间的关系是无循环的。 下层不需 要依赖或了解上层。
-  同一层的模块之间也不互相依赖。 </p>
+<p>Spirit有四层,再加一个独立的顶层。独立的那层由动作器和迭代器组成,不依赖 于其他层。框架的结构是完全正交的。层与层之间的关系是无循环的。 下层不需要依 赖或了解上层。同一层的模块之间也不互相依赖。 </p>


-<p>客户可以只使用需要的模块,而不会带来任何的编译器或运行期的负担。 最小的 使用方法是仅仅使用内核core。 高度流水化内核本身就是可用的。 内核core足够执行 一些如宏解析的任务。</p> +<p>客户可以只使用需要的模块,而不会带来任何的编译器或运行期的负担。最小的使 用方法是仅仅使用内核core。这个高度流水化的内核是自给自足的。 内核core足以执 行一些如宏解析这样的任务。</p>


-<p>迭代器<strong>iterator</strong>模块是独立于Spirit的,它也可用于非 Spirit的应用。 这个模块的编制包括独立的迭代器和迭代器的Spirit兼容包装。随着 时间的流逝,这些迭代器被发现是最有用的Spirit解析工具。 </p> +<p>迭代器<strong>iterator</strong>模块是独立于Spirit的,它也可用于非 Spirit的应用。这个模块包括独立的迭代器和迭代器的Spirit兼容封装。时间已经证 明,这些迭代器被发现是最有用的Spirit解析工具。 </p>


-<p>行为器<strong>actor</strong>模块,也是独立于Spirit,编制为预定义的语义行 为,包含了最常用的语义操作任务。</p> +<p>动作器<strong>actor</strong>模块,也是独立于Spirit的,汇集了预定义的语义 动作,包含了最常用的语义处理任务。</p>


-<p>调试器<strong>debug</strong>模块提供对库的解析调试。 这个模块穿过中间层 次,直接把自己挂接在内核上,并且是非侵入式的和仅仅在需要的地方挂接。</p> -<p><span style="font-weight: bold;"></span>属性<strong>attribute</strong>模 块引入了高阶语义行为机制,利用经继承和综合的属性对象,加强了在解析器层次间提 取和传递数据。 属性也可以用来实际控制解析过程。 参数化的解析器是动态的,能够 基于一些属性或者数据,在运行时改变行为。</p> +<p>调试器<strong>debug</strong>模块提供对库的解析调试。 这个模块穿过中间层 次,直接把自己挂接在内核上,是非侵入式的,且仅在需要的地方挂接。</p> +<p><span style="font-weight: bold;"></span>属性<strong>attribute</strong>模 块引入了高阶语义动作机制,通过属性的继承和合成,加强了在解析器层次间提取和传 递数据。属性也可以用来实际控制解析过程。参数化的解析器是动态的,能够基于一些 属性或者数据,在运行时改变行为。</p>


-<p>动态<strong>dynamic</strong>模块关注在解析器在运行时能改变行为。</p>
+<p>动态<strong>dynamic</strong>模块关注的是在运行时能改变行为的解析器。</p>


-<p>出错处理<strong>error_handling</strong>。 没有出错处理的框架是不完整的框 架。 C++的异常(exception)处理机制是可以完美地实现Spirit的出错处理,因为它 的高度可递归的函数本质。 在这个模块中,C++异常被广泛用作出错处理。</p> +<p>出错处理<strong>error_handling</strong>。没有出错处理的框架是不完整的框 架。C++的异常(exception)处理机制是可以完美地实现Spirit的出错处理,因为它的 高度可递归的函数本质。在这个模块中,C++异常被广泛用作出错处理。</p>


-<p>符号<strong>symbols</strong>模块关注于符号表管理。 这个模块现在是非常基 础的。 目标是建立一个子框架,可以容纳C++风格的多可见域机制。 C++是一个伟大的 模型,在控制可见域的复杂度上可能其他语言无出其右。 - 那里有类和继承,私有、保护和公有访问限制,友元,命名空间,using声 明,using指示符,Koenig查找(参数依赖查找)等等。 我们现有的符号表功能是一个 基础部件,为了以后完全模拟和实现C++的可见域功能。</p> +<p>符号<strong>symbols</strong>模块关注于符号表管理。这个模块现在还很简陋。 目标是建立一个子框架以适应C++风格的多重范围控制机制。C+ ++是一个伟大的模型,在范围控制的复杂度上可能其他语言无出其右。那里有类和继 承,私有、保护和公有访问限制,友元,命名空间,using声明, +using指示符,Koenig查找(参数依赖查找)等等。我们现有的符号表功能是一个基础 部件,为了以后完全模拟和实现C++的以上功能。</p>


 <blockquote>


- <p><em><font color="#003366">我盼望我能够看见,一个结构如同树般美 &hellip; (I wish that I could ever see, a structure as lovely + <p><em><font color="#003366">我盼望我能够看见,一个结构如同树般美... (I wish that I could ever see, a structure as lovely
     as a tree</font></em><font color="#003366">...)</font></p>


 </blockquote>


-<p> 解析树和抽象语法树(AST)的产生通过树<b>Tree</b>模块处理。 使用解析树和 抽象语法树,比使用语义行为有若干优点。 你可以多次传递数据而不用每次都重新解 析输入。 你可以对树进行转换。 你可以以任意的顺序进行计算,但是按照属性计划你 必须从头到尾处理。 你不须担心在有歧义的文法中可能发生的反向作用和行为附作 用。</p> +<p> 解析树和抽象语法树(AST)的产生通过树<b>Tree</b>模块处理。 使用解析树和 抽象语法树,比使用语义动作有若干优点。你可以多次传递数据而不用每次都重新解析 输入。你可以对树进行转换。你可以以任意的顺序进行计算,但是按照属性计划你必须 从头到尾处理。你无须担心在有歧义的文法中可能发生的回溯和动作副作用。</p>


-<p>有用部件<b>utility</b>模块有很多通用的解析器和一些有用的支持类,适用于普 通的任务例如表处理,注释,confix表达式,等等。</p> +<p>工具部件<b>utility</b>模块有很多通用的解析器和一些有用的支持类,适用于普 通的任务,例如表处理、注释、confix表达式,等等。</p>


<p>元<strong>meta</strong>, 为高端Spirit开发者提供元编程工具。这个模块使 Spirit解析器的编译时和运行时的内部分析设计更方便。</p>
@@ -460,7 +457,7 @@


 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<br>


   <br>
@@ -474,5 +471,4 @@
 <p class="copyright">&nbsp;</p>


-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/preface.html Sat Oct  4 05:29:09 2008
+++ /trunk/libs/spirit/classic/doc/preface.html Wed Sep 16 20:25:53 2009
@@ -1,6 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>



@@ -17,17 +16,15 @@



-  <title>Preface</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Preface</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">






-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -145,9 +142,9 @@


       <p>
- <i>&ldquo;作为设计的例子要符合多数的&ldquo;好&rdquo;标准 (如:易读性,灵活
+            <i>"作为设计的例子要符合多数的"好"标准(如:易读性,灵活
 性,有效性)。递归下降解析器,作为传统的过程化代码,正是这样的一个好例子。
-另外一个例子是STL,它是一个基于传统过程化代码与参数化多态性的通用的容器与算 法的库。&rdquo;</i> +另外一个例子是STL,它是一个基于传统过程化代码与参数化多态性的通用的容器与算 法的库。"</i>
           </p>


@@ -185,7 +182,7 @@



-<p>十五年前,我用Pascal写下了自己的第一计算器。这是一段难忘的编程经历,我惊 讶于一组互相递归的函数集如何相互协作并表达出一个特定文法模 +<p>十五年前,我用Pascal写下了自己的第一个计算器。这是一段难忘的编程经历,我 惊讶于一组互相递归的函数集如何相互协作并表达出一个特定文法模 型。 同时,我从这个学术经验中得到的技能是很有用的。 时不时地,我被分派到一 些写解析器的任务。 例如:每当需要执行任何形式的输入/输出操作,即使是二进制形式,我完成任务的途 径都是,先写好一个类Pascal的语法分析图,再写一个相应的递归下降
 解析器。这样运作良好。 </p>
@@ -202,11 +199,11 @@



-<p> 它必须能实用地解析简单的文法(例如emal地址)到适度复杂的文法(例如XML和 一些小的脚本语言)。 +<p> 它必须能实用地解析简单的文法(例如email地址)到适度复杂的文法(例如 XML和一些小的脚本语言)。 可伸缩性是一个主要的目标。当你用它解决小任务例如命令行解析时,并不会带来很 重的运行开销,而当你用YACC或PCCTS时则不然。 -到现在,它已经进化并成熟,已经成为一个多模块的库,这正如最初的目 的,Spirit仍然可以用在极小的解析任务中。
-只有你需要的特性才会产生开销。Spirit的威力在于它的模块性和可扩充性。
-不同于用一把万能而笨重的锤子,它能使你很容易地订制一把有恰当成分的锤子。 例 如,它没有 lexer +到现在,它已经进化并成熟,已经成为一个由多个模块组成的库,正如最初的目 的,Spirit仍然可以用在极小的解析任务中。
+只有你需要的特性才会产生开销。Spirit的威力在于它的模块化和可扩充性。
+不同于一把万能而笨重的锤子,它能使你很容易地订制一把有恰当分量的锤子。 例 如,它没有 lexer
 ,但它提供了所有的原始材料,如果你想要,你就写一个。 </p>


@@ -214,8 +211,8 @@

<p>考虑以上种种,结果就是 Spirit。 我在日本做R&amp;D开发时构思出Spirit 这个 个人项目。 受到GoF的合成和解释模式启发,我意识到可以把递归下降解析器模型化为一个由终端 对象和合成对象构成的层次组合。 -最初的版本是用运行时多态性来实现的。 通过提供描述合成规则的字符串(例 <tt>"prod ::= {&lsquo;A&rsquo; - | &lsquo;B&rsquo;} &lsquo;C&rsquo;;"</tt>),解析器在运行时产生。 一 个函数对编译出解析器,动态创建对象的层次组合和对象间语义连接。 很早前的参考 文本在&nbsp;<a href="http://spirit.sourceforge.net/dl_docs/pre-spirit.htm";>这里</a> 找到。 +最初的版本是用运行时多态性来实现的。 通过提供描述合成规则的字符串(例 <tt>"prod ::= {'A' + | 'B'} 'C';"</tt>),解析器在运行时产生。 一个编译函数对其编译出解析 器,动态创建对象的层次组合和对象间的语义连接。 早期的参考文档在&nbsp;<a href="http://spirit.sourceforge.net/dl_docs/pre-spirit.htm";>这里</a> 找到。
     </p>


@@ -230,7 +227,7 @@


<p>在它最初的开源发布(2001年5月)之后, static-Spirit 得到了胜利。 在大约 &nbsp;2001年11月,Spirit的网站有98%的活动百分点,一跃成为 Source Forge - 当时排名第一的解析器。 对于这般一个小项目(一个解析器库),已经是不错的 了。&nbsp; 后来"static"这个词被省略, static-Spirit 简称为 Spirit。 整个框架 很快地进化,拥有更多动态特性。 + 当时排名第一的解析器。 对于这样一个小项目(一个解析器库),已经是不错的 了。&nbsp; 后来"static"这个词被省略, static-Spirit 简称为 Spirit。 整个框架 很快地进化,拥有更多动态特性。
     </p>


@@ -244,7 +241,7 @@


 <p>
- Spirit的框架以逻辑模块来组织,首先以内核开始。 这个文档提供一个用户向 导和每个模块的使用参考。 一个简单和干净的代码离子值得用一百行文档介绍; 因 此, 用户向导里有丰富的例子,带有注释和一步步的解析。 用户向导多数是基于例子 的。 + Spirit的框架以逻辑模块来组织,首先以内核开始。 这个文档提供一个用户指 南和每个模块的使用参考。 一个简单和干净的代码例子顶得上一百行的文档介绍; 因 此, 用户指南里有丰富的例子,带有注释和一步步的解析。 用户指南多数是基于例子 的。
     </p>


@@ -314,7 +311,7 @@


               <td class="table_cells" width="627">
-                提供的信息是适当地重要,应该得到读者注意。
+                提供的信息比较重要,应该得到读者注意。
               </td>


@@ -391,7 +388,7 @@


               <td class="table_cells" width="627">
-                有潜在的作用的一小块信息。
+                有潜在作用的一小块信息。
               </td>


@@ -592,7 +589,7 @@
 <hr size="1">

 <p class="copyright">
-      Copyright &copy; 1998-2003 Joel de Guzman<br>
+      Copyright (c) 1998-2003 Joel de Guzman<br>



@@ -615,5 +612,4 @@



-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/primitives.html      Sat Oct  4 05:29:09 2008
+++ /trunk/libs/spirit/classic/doc/primitives.html      Wed Sep 16 20:25:53 2009
@@ -1,6 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>



@@ -21,8 +20,8 @@



-  <title>Primitives</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Primitives</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



@@ -36,9 +35,7 @@



-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -207,7 +204,7 @@



-<p>框架预定义了一些基元解析器。 这里有最底层的建造单元,用户可用它来构造更 复杂的解析器。 这些基元解析器是模板类,这使它们很灵活。</p> +<p>框架预定义了一些基元解析器。这里有最底层的建造单元,用户可用它来构造更复 杂的解析器。这些基元解析器是模板类,这使它们很灵活。</p>



@@ -215,7 +212,7 @@



-<p>这些基元解析器能够直接实例化或者通过一个模板帮助函数。 一般来说,帮助函 数是非常容易处理,因为它需要更少输入。</p> +<p>这些基元解析器能够直接实例化或者通过一个模板辅助函数。一般来说,辅助函数 是非常容易处理,因为它需要更少输入。</p>



@@ -223,8 +220,7 @@



-<p>我很已经见过字面字符解析器,通过函数<tt>ch_p</tt> 就可以产生。
- 类 <tt>chlit&lt;CharT&gt;</tt> 是隐藏在字面解析器背后的实际的模板类。 要 去实例化一个<tt>chlit</tt>对象,你必须在模板参数中显示提供字符的类 型,<tt>CharT</tt>,来确定字符的类型。 这个类型正是和输入类型相关,通常是 <tt>char</tt> 或者 <tt>wchar_t</tt>。 下面的表达式创建一个临时的解析器对 象,只识别单个子 <span class="quotes">'X'</span> 。</p> +<p>我很已经见过字面字符解析器,通过函数<tt>ch_p</tt> 就可以产生。类 <tt>chlit&lt;CharT&gt;</tt> 是隐藏在字面解析器背后的实际的模板类。要去实例化 一个<tt>chlit</tt>对象,你必须在模板参数中显示提供字符的类 型,<tt>CharT</tt>,来确定字符的类型。这个类型正是和输入类型相关,通常是 <tt>char</tt> 或者 <tt>wchar_t</tt>。下面的表达式创建一个临时的解析器对 象,只识别单个子 <span class="quotes">'X'</span> 。</p>



@@ -240,7 +236,7 @@



-<p>用<tt>chlit</tt>的产生函数 <tt>ch_p</tt> 能简化<tt>chlit&lt;&gt;</tt>类 的使用(这是大多数Spirit解析器类的情况,多数都有相应的产生函数)。 调用函数 更方便,因为编译器会自动进行参数推导得模板类型。 上面的例子可以用更简短的方 式表达,用<tt>ch_p</tt>帮助函数。 </p> +<p>用<tt>chlit</tt>的产生函数 <tt>ch_p</tt> 能简化<tt>chlit&lt;&gt;</tt>类 的使用(这是大多数Spirit解析器类的情况,多数都有相应的产生函数)。调用函数更 方便,因为编译器会自动进行参数推导得模板类型。上面的例子可以用更简短的方式表 达,用<tt>ch_p</tt>帮助函数。 </p>



@@ -330,7 +326,7 @@



-<pre><code><span class="comment"> </span><span class="comment">// 一个规 则rule 可以&ldquo;保存&rdquo;一个解析器对象。 规则rule将以后介绍<br> </span><span class="comment">// , 但是现在只把规则rule考虑为一个黑匣,不需 要知道内部实现<br> </span><span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">r1</span><span class="special">, </span><span class="identifier">r2</span><span class="special">, </span><span class="identifier">r3</span><span class="special">;<br><br> </span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt; </span><span class="identifier">x</span><span class="special">(</span><span class="literal">'X'</span><span class="special">); </span><span class="comment">// 声明有名解析器 x<br><br> </span><span class="identifier">r1 </span><span class="special">= </span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;(</span><span class="literal">'X'</span><span class="special">); </span><span class="comment">// 显式声明<br> </span><span class="identifier">r2 </span><span class="special">= </span><span class="identifier">x</span><span class="special">; </span><span class="comment">// 使用 x<br> </span><span class="identifier">r3 </span><span class="special">= </span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'X'</span><span class="special">) </span><span class="comment">// 使用生成器</span></code></pre> +<pre><code><span class="comment"> </span><span class="comment">// 一个规 则rule 可以"保存"一个解析器对象。 规则rule将以后介绍<br> </span><span class="comment">// , 但是现在只把规则rule考虑为一个黑盒,不需要知道内部实现 <br> </span><span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">r1</span><span class="special">, </span><span class="identifier">r2</span><span class="special">, </span><span class="identifier">r3</span><span class="special">;<br><br> </span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt; </span><span class="identifier">x</span><span class="special">(</span><span class="literal">'X'</span><span class="special">); </span><span class="comment">// 声明有名解析器 x<br><br> </span><span class="identifier">r1 </span><span class="special">= </span><span class="identifier">chlit</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;(</span><span class="literal">'X'</span><span class="special">); </span><span class="comment">// 显式声明<br> </span><span class="identifier">r2 </span><span class="special">= </span><span class="identifier">x</span><span class="special">; </span><span class="comment">// 使用 x<br> </span><span class="identifier">r3 </span><span class="special">= </span><span class="identifier">ch_p</span><span class="special">(</span><span class="literal">'X'</span><span class="special">) </span><span class="comment">// 使用生成器</span></code></pre>



@@ -346,7 +342,7 @@



-<p>匹配单一个字面字符。 <tt>chlit</tt> 有单一个模板类型,默认值是 <tt>char</tt>(也就是,<tt>chlit&lt;&gt;</tt>等价于 <tt>chlit&lt;char&gt;</tt>)。 这个类型变量是<tt>chlit</tt>在解析的时候将识 别的字符类型。 函数生成器版本会从实际函数参数中推导出模板类型参数。 模板类 <tt>chlit</tt>构造函数接受单一参数:用于匹配输入的字符。 例子:</p> +<p>匹配单一个字面字符。 <tt>chlit</tt> 有一个模板参数,默认值是 <tt>char</tt>(也就是,<tt>chlit&lt;&gt;</tt>等价于 <tt>chlit&lt;char&gt;</tt>)。这个类型参数是<tt>chlit</tt>在解析的时候将识别 的字符类型。函数生成器版本会从实际函数参数中推导出模板类型参数。模板类 <tt>chlit</tt>构造函数接受单一参数:用于匹配输入的字符。 例子:</p>



@@ -378,7 +374,7 @@



-<p></p>
+



@@ -491,7 +487,7 @@



-<p>一个字符的范围 <tt>range</tt> 是通过一对字符创建的,表示下界和上界。 这 样的解析器匹配在范围<tt>range</tt>内(包含两端点)的单一个字符。 类似 <tt>chlit</tt>, <tt>range</tt> 只有一个模板参数,类型默认为<tt>char</tt>。 类 <tt>range</tt> 构造函数接受两个参数:匹配字符的范围(起始和结束,包含端点 ) 。 它的函数生成器的版本是 <tt>range_p</tt>。 +<p>一个字符的范围 <tt>range</tt> 是通过一对字符创建的,表示下界和上界。这样 的解析器匹配在范围<tt>range</tt>内(包含两端点)的单一个字符。类似 <tt>chlit</tt>, <tt>range</tt> 只有一个模板参数,类型默认为<tt>char</tt>。 类 <tt>range</tt> 构造函数接受两个参数:匹配字符的范围(起始和结束,包含端点 )。它的函数生成器的版本是 <tt>range_p</tt>。
   例子:</p>


@@ -508,7 +504,7 @@



-<p>注意,第一个字符必须在第二个&ldquo;之前&rdquo;,要取决与内在编码方式。 范围 range,和chlit一样是单个字符的解析器。</p> +<p>注意,第一个字符必须在第二个"之前",要取决与内在编码方式。 范围 range,和chlit一样是单个字符的解析器。</p>



@@ -551,7 +547,7 @@
       <br>


-字符映射固有地平台相关的。 在标准中并不保证例如 'A' &lt; 'Z' 的关系,但 是,在很多情况下,我们很清楚所用的字符集如 ASCII, ISO-8859-1 或者 Unicode。 但是在平台移植时要很小心。</td> +字符映射自然与平台相关。在标准中并不保证例如 'A' &lt; 'Z' 的关系,但是,在 很多情况下,我们很清楚所用的字符集如 ASCII, ISO-8859-1 或者 Unicode。但是在 平台移植时要很小心。</td>



@@ -590,11 +586,9 @@



-<p>这个解析器匹配字面字符串。类<tt>strlit</tt> 有单个模板参数:一个迭代器的 类型。 在内部,<tt>strlit</tt> 含有一对表示开始和终止的迭代器,指向有字符的 串或容器。&nbsp; <tt>strlit</tt> - 尝试用此串来匹配当前输入流。 模板参数类型默认是 <tt>char const<span class="operators">*</span></tt>。 <tt>strlit</tt>
-  有两个构造函数。 第一个接受一个以字符零结尾的字符指针。
-  这个构造函数可用于从一个字面字符串引用构件 <tt>strlits</tt> 。
- 第二个构造函数接受首/尾迭代器对。 函数生成器的版本是 <tt>str_p</tt>。 例 子:</p> +<p>这个解析器匹配字面字符串。类<tt>strlit</tt> 只有一个模板参数:迭代器的类 型。在内部,<tt>strlit</tt> 含有一对表示开始和终止的迭代器,指向字符串或字符 容器。<tt>strlit</tt> + 尝试用此串来匹配当前输入流。模板参数类型默认是 <tt>char const<span class="operators">*</span></tt>。<tt>strlit</tt> + 有两个构造函数。第一个接受一个以NULL结尾的字符指针。这个构造函数可用于从 一个字面字符串引用构件 <tt>strlits</tt>。第二个构造函数接受首/尾迭代器对。函 数生成器的版本是 <tt>str_p</tt>。例子:</p>



@@ -643,8 +637,7 @@

       <br>

-典型的解析器把字符(组成词或词位的符号)处理和单词(组成句子的词)处理分开 考虑。 - 各种实体例如保留词,操作符,字面字符串,数值常量等等,都是一个文法的 终端节点;一般在一个独立的词法分析阶段提取这些实体。<br> +典型的解析器把字符(组成词或词位的符号)处理和单词(组成句子的词)处理分开 考虑。各种实体例如保留词,操作符、字面字符串、数值常量等等,都是一个文法的终 端节点;一般在一个独立的词法分析阶段提取这些实体。<br>



@@ -653,7 +646,7 @@


       <br>
-在这个问题上,从目前所举的例子中显然地可以注意到很重要的一点,此点和一般标 准做法不同,就是在Spirit框架同时在字符层和词语层处理解析任务。 你可以认为一 个词法分析器被无缝地整合在Spirit框架中。<br> +在这个问题上,从目前所举的例子中显然地可以注意到很重要的一点,此点和一般标 准做法不同,就是在Spirit框架同时在字符层和词语层处理解析任务。你可以认为一个 词法分析器被无缝地整合在Spirit框架中。<br>



@@ -662,7 +655,7 @@


       <br>
-虽然Spirit解析器库不需要一个词法分析器,但是我们仍然有理由需要一个。 你总是 可以需要有任意多的解析层次。 理论上,你可以在同样的Spirit框架下,创建一个预 处理器,一个词法分析器和一个正规的解析器。</td> +虽然Spirit解析器库不需要一个词法分析器,但是我们仍然有理由需要一个。你总是 可以需要有任意多的解析层次。理论上,你可以在同一个Spirit框架下,创建一个预处 理器,一个词法分析器和一个正规的解析器。</td>



@@ -701,9 +694,7 @@



-<p>Matches a character sequence. <tt>chseq</tt> has the same template type parameters - and constructor parameters as strlit. The function generator version is <tt>chseq_p</tt>.
-  Examples:</p>
+<p>匹配一个字符序列。<tt>chseq</tt> 拥有与 strlit 相同的模板类型参数和构造 函数参数。生成器函数是 <tt>chseq_p</tt>。例如:</p>



@@ -719,10 +710,7 @@



-<p><tt>strlit</tt> is an implicit lexeme. That is, it works solely on the character - level. <tt>chseq</tt>, <tt>strlit</tt>'s twin, on the other hand, can work on - both the character and phrase levels. What this simply means is that it can
-  ignore white spaces in between the string characters. For example:</p>
+<p><tt>strlit</tt>&nbsp;是一个隐式的词位。也就是说,它只在字符层面工作。 <tt>chseq</tt> 是 <tt>strlit</tt> 的孪生子,但是另一方面,它在字符层面和句子 层面都可以工作。简而言之,它可以忽略连续字符之间的空格。例如:</p>



@@ -738,7 +726,7 @@



-<p>can parse:</p>
+<p>可以匹配:</p>



@@ -754,7 +742,7 @@



-<h2>More character parsers</h2>
+<h2>其它字符解析器</h2>



@@ -762,7 +750,7 @@



-<p>The framework also predefines the full repertoire of single character parsers:</p>
+<p>本框架还预定义了全部的单字符解析器:</p>



@@ -793,7 +781,7 @@



-    <td class="table_title" colspan="2">Single character parsers</td>
+    <td class="table_title" colspan="2">单字符解析器</td>



@@ -825,8 +813,7 @@



- <td class="table_cells" width="70%">Matches any single character (including
-      the null terminator: '\0')</td>
+ <td class="table_cells" width="70%">匹配任意单字符(包括NULL终结 符'\0')</td>



@@ -858,7 +845,7 @@



- <td class="table_cells" width="70%">Matches alpha-numeric characters</td>
+    <td class="table_cells" width="70%">匹配字母和数字字符</td>



@@ -890,7 +877,7 @@



-    <td class="table_cells" width="70%">Matches alphabetic characters</td>
+    <td class="table_cells" width="70%">匹配字母字符</td>



@@ -922,7 +909,7 @@



-    <td class="table_cells" width="70%">Matches spaces or tabs</td>
+    <td class="table_cells" width="70%">匹配空格或制表符</td>



@@ -954,7 +941,7 @@



-    <td class="table_cells" width="70%">Matches control characters</td>
+    <td class="table_cells" width="70%">匹配控制字符</td>



@@ -986,7 +973,7 @@



-    <td class="table_cells" width="70%">Matches numeric digits</td>
+    <td class="table_cells" width="70%">匹配数字字符</td>



@@ -1018,7 +1005,7 @@



- <td class="table_cells" width="70%">Matches non-space printing characters</td>
+    <td class="table_cells" width="70%">匹配非空格的打印字符</td>



@@ -1050,7 +1037,7 @@



-    <td class="table_cells" width="70%">Matches lower case letters</td>
+    <td class="table_cells" width="70%">匹配小写字符</td>



@@ -1082,7 +1069,7 @@



-    <td class="table_cells" width="70%">Matches printable characters</td>
+    <td class="table_cells" width="70%">匹配可打印字符</td>



@@ -1114,7 +1101,7 @@



-    <td class="table_cells" width="70%">Matches punctuation symbols</td>
+    <td class="table_cells" width="70%">匹配标点符号</td>



@@ -1146,7 +1133,7 @@



- <td class="table_cells" width="70%">Matches spaces, tabs, returns, and newlines</td>
+    <td class="table_cells" width="70%">匹配空格、制表、回车、换行符</td>



@@ -1178,7 +1165,7 @@



-    <td class="table_cells" width="70%">Matches upper case letters</td>
+    <td class="table_cells" width="70%">匹配大写字符</td>



@@ -1210,7 +1197,7 @@



-    <td class="table_cells" width="70%">Matches hexadecimal digits</td>
+    <td class="table_cells" width="70%">匹配16进制数字字符</td>



@@ -1241,7 +1228,7 @@



-<h2><a name="negation"></a>negation ~</h2>
+<h2><a name="negation"></a>取反 ~</h2>



@@ -1249,8 +1236,8 @@



-<p>Single character parsers such as the <tt>chlit</tt>, <tt>range</tt>, <tt>anychar_p</tt>,
-  <tt>alnum_p</tt> etc. can be negated. For example:</p>
+<p>象 <tt>chlit</tt>, <tt>range</tt>, <tt>anychar_p</tt>,
+  <tt>alnum_p</tt> 等等这样的单字符解析器可以被取反。例如:</p>



@@ -1266,8 +1253,7 @@



-<p>matches any character except <tt>'x'</tt>. Double negation of a character parser - cancels out the negation. <tt>~~alpha_p</tt> is equivalent to <tt>alpha_p</tt>.</p> +<p>匹配除 <tt>'x'</tt> 以外的任意字符。一个字符解析器的两次取反相当于不取 反。<tt>~~alpha_p</tt> 等价于 <tt>alpha_p</tt>.</p>



@@ -1283,7 +1269,7 @@



-<p>Matches the end of line (CR/LF and combinations thereof).</p>
+<p>匹配换行符(CR/LF 或它们的混合)。</p>



@@ -1299,7 +1285,7 @@



-<p>Never matches anything and always fails.</p>
+<p>永不匹配,总是返回失败。</p>



@@ -1315,8 +1301,7 @@



-<p>Matches the end of input (returns a sucessful match with 0 length when the
-  input is exhausted)</p>
+<p>匹配输入的结束(当输入耗尽时返回长度为零的成功匹配)。</p>



@@ -1411,7 +1396,7 @@


 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<br>



@@ -1419,7 +1404,7 @@



-  Copyright &copy; 2003 Martin Wille<br>
+  Copyright (c) 2003 Martin Wille<br>



@@ -1453,5 +1438,4 @@



-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/quick_start.html     Sat Oct  4 05:29:09 2008
+++ /trunk/libs/spirit/classic/doc/quick_start.html     Wed Sep 16 20:25:53 2009
@@ -1,6 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
+<html><head>



@@ -22,8 +21,8 @@



-  <title>Quick Start</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <title>Quick Start</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



@@ -32,9 +31,7 @@



-  <link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+  <link rel="stylesheet" href="theme/style.css" type="text/css"></head>

 <body>

@@ -154,34 +151,32 @@


 <h2>
-      <b>你为什么想用 Spirit ?</b>
+      <b>你为什么要用 Spirit ?</b>
     </h2>





-<p> Spirit
-设计为实际的解析工具。&nbsp;从一个内联于C++中的标准EBNF规范,产生一个能完全 工作的解析器,这种能力的确能减少了开发的时间。当要开发一 -个计算机语言例如C或Pascal,实际中也可用一个成熟并且卓越的解析器(如 YACC,ANTLR),但是当我们需要非常微小的解析器时,继续这样做无 -异于大炮打蚊子。在这领域的一端,程序员在着手处理时一般不是把任务看待为标准 的解析任务,而是特定地用粗糙的工具如<tt>scanf</tt>来"搞"任务。 真的,是有一 些解析工具例如正则表达式库 (如 <a href="http://www.boost.org/libs/regex/index.html";>boost regex</a>) 或者扫描 +<p> Spirit 是作为实用的解析工具来设计的。从一个内联于C++中的标准EBNF规 范,产生一个能完全工作的解析器,这种能力的确能减少了开发的时间。当要开发一 +个计算机语言时,例如C或Pascal,实际中也可以用一个成熟并且卓越的解析器(如 YACC,ANTLR),但是当我们需要微型的解析器时,这样做无 +异于大炮打蚊子。在这个领域的这一端,程序员在着手处理时一般不会把任务看待为 标准的解析任务,而是特定地用粗糙的工具如<tt>scanf</tt>来完成任务。 确实,是 有一些解析工具例如正则表达式库 (如 <a href="http://www.boost.org/libs/regex/index.html";>boost regex</a>) 或者扫描
       (如 <a href="http://www.boost.org/libs/tokenizer/index.html";>boost
- tokenizer</a>), 但是当我们需要写更精细的解析器的时候,这些工具不能很 好地伸缩扩展。 如果企图用这些工具写一个适度复杂的解析器,将导致难理解,难维 护的代码。 + tokenizer</a>), 但是当我们需要编写更为精细的解析器的时候,这些工具不 能很好地伸缩扩展。 如果企图用这些工具写一个适度复杂的解析器,将导致难以理解 和维护的代码。
     </p>





-<p>其中一个最初目的是使工具很容易使用。 当提起解析器生成器时,通常的想法是 &ldquo;它一定是很大很复杂,并且很难学的&rdquo;。 现在不是这样了! Spirit&nbsp;设计成完全可伸缩。 - Spirit的框架是层次化结构。 在学习最小的内核和基础概念之后,可以只学习 需要的基础。 +<p>其中一个最初的目的是使工具很容易使用。当提起解析器生成器时,通常的想法是 "它一定是很大很复杂,并且很难学的"。现在不是这样了!Spirit&nbsp;设计成完全可 伸缩。Spirit的框架是层次化结构。在学习最小的内核和基础概念之后,可以只学习你 需要的部分。
     </p>





-<p>为了开发的简易,整个框架只由头文件组成,不需要连接或者编译额外的库。 只 需要把Spirit的发布包放在include目录下,编译,运就可以了。 代码的大小?非常 少。在快速上手中,我们给出很简短的例子,代码的大小主要由 <tt>std::vector</tt>和<tt>std::iostream</tt>实例化的开销主导。 +<p>为了开发的简易,整个框架只由头文件组成,不需要连接或者编译额外的库。只需 要把Spirit的发布包放在include目录下,编译,运行就可以了。代码的大小?非常 小。在快速上手中,我们给出一些简短的例子,代码的大小主要是由 <tt>std::vector</tt>和<tt>std::iostream</tt>实例化所导致的开销。
     </p>


@@ -238,14 +233,14 @@

 <p>
       这里你看到熟悉的浮点数解析器
- <code><tt>real_p</tt></code> 被用了两次, 每个数用一次。 那么操作符 <tt class="operators">&gt;&gt;</tt> 在这里做什么呢? 恩,一定要有些东西分开 它们吧,操作符<tt class="operators">&gt;&gt;</tt>用作&ldquo;紧跟着&rdquo;序 列操作符。 上面的程序通过用胶水(序列操作符)把两个简单的解析器粘在一起,建立 了一个稍复杂的解析器。&nbsp; 数字之间的空白符的处理隐含于解析器的调用方法 (见下面)。 + <code><tt>real_p</tt></code> 被用了两次,每个数用一次。那么操作符 <tt class="operators">&gt;&gt;</tt> 在这里做什么呢?恩,一定要有些东西分开它 们吧,操作符<tt class="operators">&gt;&gt;</tt>被用作"跟随"序列操作符。上面 的程序通过用胶水(序列操作符)把两个简单的解析器粘在一起,建立了一个稍复杂的解 析器。数字之间的空白符的处理隐含于解析器的调用方法(见下文)。
   </p>





-<p>注意:对解析器进行组合的时候,我们得到一个&ldquo;更大&rdquo;的解析器,但 是它仍然是个解析器,所以可以继续嵌套,越变越大。总之,当你用胶水的时候,将产 生一个更大的解析器,这是一个重要的概念。 +<p>注意:对解析器进行组合的时候,我们得到了一个"更大"的解析器,但它仍然是个 解析器,所以可以继续嵌套,越变越大。总之,当你用胶水的时候,将产生一个更大的 解析器,这是一个重要的概念。
     </p>


@@ -268,14 +263,14 @@



-<p>这样很像正则表达式的 Kleene 星号,语法上可能有点古怪,特别对于那些没见过 重载<tt class="operators">*</tt>操作符的C++程序员。 但事实上,如果你了解过正 则表达式,古怪之处或许在于星号是作为表达式的前缀而不是后缀。 C'est la vie先 生把这种形式不协调指责于我们不得不遵守的C++语法规则。 +<p>这样很像正则表达式的 Kleene 星号,语法上可能有点古怪,特别对于那些没见过 重载<tt class="operators">*</tt>操作符的C++程序员。但事实上,如果你了解过正 则表达式,古怪之处或许在于星号是作为表达式的前缀而不是后缀。没办法,这就是生 活,要怪就怪我们要和C++的语法一起工作吧。
   </p>





-<p> Kleene 星号可用在任意的解析器表达式上。 但要谨记着,因为C++操作符的优先 级规则,你可能需要用圆括号括上复杂的表达式。&nbsp; Kleene 星号也被称作 Kleene 结尾,但文中多数地方仍称之为 Kleene星号。 +<p> Kleene 星号可用在任意的解析器表达式上。但要谨记着,因为C++操作符的优先 级规则,你可能需要用圆括号括上复杂的表达式。Kleene 星号也被称作 Kleene 结 尾,但文中多数地方仍称之为 Kleene星号。
     </p>


@@ -283,7 +278,7 @@


 <h3>
-      <b><a name="list_of_numbers"></a> 例子 #4 [ 一个稍不简单的例子</b>
+      <b><a name="list_of_numbers"></a> 例子 #4 [ 一个不太简单的例子</b>
 ]    </h3>


@@ -310,7 +305,7 @@



-<p>请注意 <tt>ch_p(',') 。</tt> 这是一个识别逗号<tt>','</tt>的字面字符解析 器。 在这里,Kleene星号作用在一个更复杂的解析器上,这是指由下面的表达式生成 的解析器: +<p>请注意 <tt>ch_p(',')。</tt>这是一个识别逗号<tt>','</tt>的字面字符解析 器。在这里,Kleene星号作用在一个更复杂的解析器上,这是指由下面的表达式生成的 解析器:
     </p>


@@ -324,7 +319,7 @@



-<p>要注意,这种情况必须要用圆括号。&nbsp;Kleene 星号作用在上面写的整个表达 式上。
+<p>要注意,这种情况必须要用圆括号。Kleene 星号作用在上面写的整个表达式上。
   </p>


@@ -366,14 +361,14 @@


 <p>
- 并不十分惊讶,这只是你用了多年的平常的附值操作。 真正酷的事情是,当你 把解析器存储在规则中时,规则就是解析器,以后你就可以用名字来引用它。 (在上面 情况下,规则名字就是 <tt><b>r</b></tt>)。 要注意,这是一个完整的附值表达 式,所以我们要用分号"<tt>;</tt>"终结。 + 并不十分惊讶,这只是你用了多年的平常的赋值操作。真正酷的事情是,当你 把解析器存储在规则中时,规则就是解析器,以后你就可以用名字来引用它。 (在上面 情况下,规则名字就是 <tt><b>r</b></tt>)。 要注意,这是一个完整的赋值表达 式,所以我们要用分号"<tt>;</tt>"终结。
   </p>





-<p>正是如此。我们已经懂得去定义一个解析器了。那么下一步就是要让解析器进行操 作了。 这有很多方法。 在这里,我们介绍的方法是用非成员函数 <tt>parse</tt> 来 解析一个字符串 <tt>char const*</tt> 。 这个函数有三个输入参数: +<p>正是如此。我们已经懂得如何去定义一个解析器了。那么下一步就是要让解析器进 行操作了。这有很多方法。在这里,我们介绍的方法是用非成员函数 <tt>parse</tt> 来解析一个字符串 <tt>char const*</tt> 。这个函数有三个输入参数:
     </p>


@@ -386,7 +381,7 @@


   <p>
-        <img src="theme/bullet.gif" height="12" width="12"> 以带零终止符的
+        <img src="theme/bullet.gif" height="12" width="12"> 以NULL结尾的
         <tt>const char*</tt> 作为输入字符串<br>


@@ -410,7 +405,7 @@


 <p>
- 在如下例子中,我们希望跳过空白符和tab符。 另一个称为 <tt>space_p</tt>的解析器是Spirit库预定义的。一个非常简单的只识别空白符的解析 器。 我们会用 <tt>space_p</tt> 作为跳读解析器。 跳读解析器负责跳过那些解析器 基元(如<tt>real_p</tt>和<tt>ch_p</tt>)之间的字符。 + 在以下例子中,我们希望跳过空白符和tab符。另一个称为<tt>space_p</tt>的 解析器是Spirit库预定义的。一个非常简单的、只识别空白符的解析器。我们会用 <tt>space_p</tt> 作为跳读解析器。跳读解析器负责跳过那些解析器基元(如 <tt>real_p</tt>和<tt>ch_p</tt>)之间的字符。
     </p>


@@ -476,7 +471,7 @@


 <p>
- 这里要注意我们没有用带名字的规则,而直接把解析器内联在parse函数中。当 调用函数parse时,表达式的值被放在一个临时解析器变量中,这个无名的解析器被传 入到parse函数,用完后就销毁。 + 这里要注意,我们没有用带名字的规则,而直接把解析器内联在parse函数中。 当调用函数parse时,表达式的值被放在一个临时解析器变量中,这个无名的解析器被 传入到parse函数,用完后就销毁。
   </p>


@@ -504,8 +499,7 @@


           <br>
-细心的读者可能注意到解析器表达式里用一个<tt class="quotes">','</tt>代替了之 前例子的<tt>ch_p(',')</tt>。 这在C++的类型转换语法规则中是允许的。 库中重载 了<tt>&gt;&gt;</tt>操作符,接受<tt>char</tt>或者<tt>wchar_t</tt>类型的参 数,左参数或者右参数(但不能同时)。&nbsp;起码一个参数是用户定义类型的时 候,操作符就会进行重载。 在例子的情况下, - <tt>real_p</tt> 是<tt>operator<span class="operators">&gt;&gt;</span></tt>的第二个参数,所以重载了恰当的<tt class="operators">&gt;&gt;</tt> ,&nbsp;<tt class="quotes">','</tt> 被自动转 换为字面字符解析器。<br> +细心的读者可能注意到解析器表达式里用一个<tt class="quotes">','</tt>代替了之 前例子的<tt>ch_p(',')</tt>。 这在C++的类型转换语法规则中是允许的。 库中重载 了<tt>&gt;&gt;</tt>操作符,接受<tt>char</tt>或者<tt>wchar_t</tt>类型的参数作 为左参数或者右参数(但不能同时)。在起码有一个参数是用户自定义类型的时候,操 作符就会进行重载。在例子的情况下,<tt>real_p</tt> 是<tt>operator<span class="operators">&gt;&gt;</span></tt>的第二个参数,所以重载了恰当的<tt class="operators">&gt;&gt;</tt> ,<tt class="quotes">','</tt> 被自动转换为字 面字符解析器。<br>



@@ -516,7 +510,7 @@


            省略<tt>ch_p</tt> 会有明显的问题:
- <tt>'a' &gt;&gt; 'b'</tt> <span style="font-weight: bold;">不是 </span>一个spirit解析器,而是一个数值表达式,代表对ASCII值(或其他编码)<tt class="quotes">'a'</tt> 进行右移ASCII值<tt class="quotes">'b'</tt>的操作。 但是, <tt>ch_p('a') &gt;&gt; + <tt>'a' &gt;&gt; 'b'</tt> <span style="font-weight: bold;">不是 </span>一个spirit解析器,而是一个数值表达式,代表对ASCII值(或其他编码)<tt class="quotes">'a'</tt> 进行右移ASCII值<tt class="quotes">'b'</tt>的操作。但 是,<tt>ch_p('a') &gt;&gt; 'b'</tt> 和 <tt>'a' &gt;&gt; ch_p('b')</tt> 都是 Spirit方式的 序列解析器,字 <tt class="quotes">'a'</tt> 后面紧跟着<tt class="quotes">'b'</tt>。你迟早会习惯这样的。
         </td>

@@ -539,7 +533,7 @@



-<p>请注意,从parse函数返回的对象有一个布尔成员叫<tt>full</tt>,它是真 (true),仅当我们的两个要求都满足(也就是输入字符串被完全地解析)。 +<p>请注意,从parse函数返回的对象有一个布尔成员叫<tt>full</tt>,它仅当我们的 两个要求都满足(也就是输入字符串被完全地解析)时为真(true)。
     </p>


@@ -553,9 +547,10 @@



-<p>刚才的解析器只不过是一个识别器。它回答了问题<i class="quotes">"输入符合 我们定义的文法吗?"</i>, 但它没有记录任何数据,也没有执行额外的操作。 谨 记:我们想把被解析的数字放入一个vector中。 这通过一种<b>action</b>操作来完 成,此操作要连接到特定的解析器中。 例如,当我们解析一个实数的时候,我们希望 保存下成功解析匹配得到的数。 我们现在希望从解析器中提取信息。 - 这需要执行语义行为。 语义行为可以连接在语法规范的任意一点上。 这些行 为是C++的函数或者函数子(functor);当解析器的一部分成功匹配了输入的一部分 时,就会调用语义行为。 设你有一个解析器<b>P</b>,和一个C++函数 - <b>F</b>,你可以把<b>F</b>连接到解析器,当解析器匹配了输入时则会调用 <b>F</b>: +<p>刚才的解析器只不过是一个识别器。它回答了问题<i class="quotes">"输入符合 我们定义的文法吗?"</i>,但它没有记录任何数据,也没有执行额外的操作。记 住:我们要把被解析的数字放入一个vector中。这通过一种<b>action</b>操 +作来完成,此操作要连接到特定的解析器中。例如,当我们解析一个实数的时候,我 们希望保存下成功解析匹配得到的数。我们现在希望从解析器中提取信息。这需 +要执行语义行为。语义行为可以连接到语法规范的任意一点上。这些行为是C++的函数 或者仿函数;当解析器的一部分成功匹配了输入的一部分时,就会调用语义 +行为。假设你有一个解析器<b>P</b>,和一个C++函数<b>F</b>,你可以把<b>F</b>连 接到解析器,当解析器匹配了输入时则会调用<b>F</b>:
     </p>


@@ -569,7 +564,7 @@


 <p>
-      又或者 <b>F</b> 是一个函数子(functor)时:
+      又或者 <b>F</b> 是一个仿函数时:
   </p>


@@ -582,7 +577,7 @@



-<p>这种函数/函数子签名,依赖于它连接的解析器的类型。 解析器 <tt>real_p</tt> 传递单一个参数:被解析的数。因此如果我们要连接函数<b>F</b>到 <tt>real_p</tt> ,我们要求<b>F</b>被声明为: +<p>这种函数/仿函数签名,依赖于它连接的解析器的类型。解析器 <tt>real_p</tt> 传递单个参数:被解析的数。因此如果我们要连接函数<b>F</b>到 <tt>real_p</tt>,我们要求<b>F</b>被声明为:
   </p>


@@ -594,7 +589,7 @@



-<p>在我们的例子中,我们再次利用一些预定义的语义函数子和函数子生成器(<img src="theme/lens.gif" height="16" width="15">一个函数子生成器是一个返回函数子 的函数)。 为了达到目的,我们用Spirit的一个函数子生成器 <tt>push_back_a(c)</tt>。 简单地讲,这个语义行为被调用时,会把从连接的解析器 接收到的的数<b>appends</b>添加到一个容器<tt>c</tt>中。 +<p>在我们的例子中,我们再次利用一些预定义的语义仿函数和仿函数生成器(<img src="theme/lens.gif" height="16" width="15">一个仿函数生成器是一个返回仿函数 的函数)。为了达到目的,我们用Spirit的一个仿函数生成器 <tt>push_back_a(c)</tt>。简单地讲,这个语义行为被调用时,会把从所连接的解析 器接收到的的数添加到一个容器<tt>c</tt>中。
   </p>


@@ -614,7 +609,7 @@



-<p>这是和之前相同的解析器。这次有合适的语义行为连接到计划好的地方,这样解析 到的数会被提取出来填充在vector <tt>v</tt>中。 如果解析成功,函数 parse_numbers 返回真。 +<p>这是和之前相同的解析器。这次有合适的语义行为连接到预定的位置,这样解析到 的数会被提取出来填入在 vector <tt>v</tt> 中。如果解析成功,函数 parse_numbers 返回真。
   </p>


@@ -695,12 +690,12 @@
 <hr size="1">

 <p class="copyright">
-      Copyright &copy; 1998-2003 Joel de Guzman<br>
+      Copyright (c) 1998-2003 Joel de Guzman<br>




-       Copyright &copy; 2002 Chris Uzdavinis<br>
+       Copyright (c) 2002 Chris Uzdavinis<br>



@@ -727,5 +722,4 @@



-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/rule.html    Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/rule.html    Wed Sep 16 20:25:53 2009
@@ -1,41 +1,35 @@
-<html>
-<head>
-<title>The Rule</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>The Rule</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>The Rule</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>The Rule 规则</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="numerics.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="epsilon.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
<p>The <b>rule</b> is a polymorphic parser that acts as a named place-holder capturing the behavior of an EBNF expression assigned to it. Naming an EBNF expression allows it to be referenced later. The <tt>rule</tt> is a template class parameterized by the type of the scanner (<tt>ScannerT</tt>), the rule's <a href="indepth_the_parser_context.html">context</a> and its <a href="#tag">tag</a>. Default template parameters are provided to
-  make it easy to use the rule.</p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>template</span><span class=special>&lt; - </span><span class=keyword>typename </span><span class=identifier>ScannerT </span><span class=special>= </span><span class=identifier>scanner</span><span class=special>&lt;&gt;, - </span><span class=keyword>typename </span><span class=identifier>ContextT </span><span class=special>= </span><span class=identifier>parser_context</span><span class=special>&lt;&gt;</span><span class=identifier>, - </span><span class="keyword">typename</span><span class=identifier> TagT </span><span class="special">=</span><span class=identifier> parser_address_tag</span><span class=special>&gt; - </span><span class=keyword>class </span><span class=identifier>rule</span><span class=special>;</span></font></code></pre> + make it easy to use the rule.<br><span style="font-weight: bold;">规则 </span>是一个多态的分析器,就是一个有名字的占位符,这个占位符保有赋给它的 EBNF表达式的行为。为EBNF表达式命名是为了在以后能引用它。<tt>rule</tt>是一个 模板类,其模板参数是扫描器类型(<tt>ScannerT</tt>)、规则的语境(<a href="indepth_the_parser_context.html">context</a>)和标签(<a href="#tag">tag</a>)。所提供的默认模板参数使得规则很易于使用。</p> +<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">template</span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">ScannerT </span><span class="special">= </span><span class="identifier">scanner</span><span class="special">&lt;&gt;,<br> </span><span class="keyword">typename </span><span class="identifier">ContextT </span><span class="special">= </span><span class="identifier">parser_context</span><span class="special">&lt;&gt;</span><span class="identifier">,<br> </span><span class="keyword">typename</span><span class="identifier"> TagT </span><span class="special">=</span><span class="identifier"> parser_address_tag</span><span class="special">&gt;<br> </span><span class="keyword">class </span><span class="identifier">rule</span><span class="special">;</span></font></code></pre> <p>Default template parameters are supplied to handle the most common case. <tt>ScannerT</tt> defaults to <tt>scanner&lt;&gt;</tt>, a plain vanilla scanner that acts on <tt>char const<span class="operators">*</span></tt> iterators and does nothing special
@@ -45,30 +39,21 @@
cases, declaring a rule as <tt>rule&lt;&gt;</tt> is enough. You need not be concerned at all with the <tt>ContextT</tt> template parameter unless you wish to tweak the low level behavior of the rule. Detailed information on the <tt>ContextT</tt> - template parameter is provided <a href="indepth_the_parser_context.html">elsewhere</a>. + template parameter is provided <a href="indepth_the_parser_context.html">elsewhere</a>.<br>所提供的默认模板参 数足以应付最常见的情况。<tt>ScannerT</tt> 默认为 <tt>scanner&lt;&gt;</tt>,一个最基本的分析器,使用 <tt>char + const<span class="operators">*</span></tt> 迭代器,且除了以每次读取一个字 符的方式对一个null结尾的输入的所有字符进行迭代,什么也不作。规则的标签 <tt>TagT</tt>,主要配合抽象语法树(<a href="trees.html">ASTs</a>)使用,用于 识别不同的规则。在<a href="#tag">这里</a>有说明。在简单类里,将规则声明为 <tt>rule&lt;&gt;</tt> 就足够了。你完全不必考虑 <tt>ContextT</tt>&nbsp;参 数,除非你想调整规则的底层行为。<tt>ContextT</tt>&nbsp;参数的详细信息将<a href="indepth_the_parser_context.html">另行提供</a>。
 </p>
-<h3><a name="order_of_parameters"></a>Order of parameters</h3>
+<h3><a name="order_of_parameters"></a>Order of parameters 参数的顺序</h3>
<p>As of v1.8.0, the <tt>ScannerT</tt>, <tt>ContextT</tt> and <tt>TagT</tt> can be specified in any order. If a template parameter is missing, it will assume
-  the defaults. Examples:</p>
-<pre><span class=identifier> rule</span><span class=special>&lt;&gt; </span><span class=identifier>rx1</span><span class=special>; - </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>scanner</span><span class=special>&lt;&gt; </span><span class=special>&gt; </span><span class=identifier>rx2</span><span class=special>; -</span> <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_context<code><font color="#000000"><span class=special>&lt;&gt;</span></font></code> </span><span class=special>&gt; </span><span class=identifier>rx3</span><span class=special>; - </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_context<code><font color="#000000"><span class=special>&lt;&gt;</span></font></code></span><span class=special>, </span><span class=identifier>parser_address_tag</span><span class=special>&gt; </span><span class=identifier>rx4</span><span class=special>; -</span> <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_address_tag</span><span class=special>&gt; </span><span class=identifier>rx5</span><span class=special>; -</span> <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_address_tag</span><span class=special>, </span><span class=identifier>scanner</span><span class=special>&lt;&gt;, </span><span class=identifier>parser_context<code><font color="#000000"><span class=special>&lt;&gt;</span></font></code> </span><span class=special>&gt; </span><span class=identifier>rx6</span><span class=special>; - </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>parser_context<code><font color="#000000"><span class=special>&lt;&gt;</span></font></code></span><span class=special>, </span><span class=identifier>scanner</span><span class=special>&lt;&gt;, </span><span class=identifier>parser_address_tag</span><span class=special>&gt; </span><span class=identifier>rx7</span><span class=special>;</span></pre> -<h3><a name="multiple_scanner_support" id="multiple_scanner_support"></a>Multiple scanners</h3> + the defaults. Examples:<br>在1.8.0这个版本中,<tt>ScannerT</tt>, <tt>ContextT</tt> 和 <tt>TagT</tt>&nbsp;可以以任意顺序排列。如果某个模板参数 缺失,则适用默认的参数。例:</p> +<pre><span class="identifier"> rule</span><span class="special">&lt;&gt; </span><span class="identifier">rx1</span><span class="special">;<br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">scanner</span><span class="special">&lt;&gt; </span><span class="special">&gt; </span><span class="identifier">rx2</span><span class="special">;<br></span> <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_context<code><font color="#000000"><span class="special">&lt;&gt;</span></font></code> </span><span class="special">&gt; </span><span class="identifier">rx3</span><span class="special">;<br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_context<code><font color="#000000"><span class="special">&lt;&gt;</span></font></code></span><span class="special">, </span><span class="identifier">parser_address_tag</span><span class="special">&gt; </span><span class="identifier">rx4</span><span class="special">;<br></span> <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_address_tag</span><span class="special">&gt; </span><span class="identifier">rx5</span><span class="special">;<br></span> <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_address_tag</span><span class="special">, </span><span class="identifier">scanner</span><span class="special">&lt;&gt;, </span><span class="identifier">parser_context<code><font color="#000000"><span class="special">&lt;&gt;</span></font></code> </span><span class="special">&gt; </span><span class="identifier">rx6</span><span class="special">;<br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">parser_context<code><font color="#000000"><span class="special">&lt;&gt;</span></font></code></span><span class="special">, </span><span class="identifier">scanner</span><span class="special">&lt;&gt;, </span><span class="identifier">parser_address_tag</span><span class="special">&gt; </span><span class="identifier">rx7</span><span class="special">;</span></pre> +<h3><a name="multiple_scanner_support" id="multiple_scanner_support"></a>Multiple scanners 多扫描器</h3> <p>As of v1.8.0, rules can use one or more scanner types. There are cases, for instance, where we need a rule that can work on the phrase and character levels. Rule/scanner mismatch has been a source of confusion and is the no. 1 <a href="faq.html#scanner_business">FAQ</a>.
-  To address this issue, we now have multiple scanner support. Example:</p>
-<pre><span class=special> </span><span class=keyword>typedef </span><span class=identifier>scanner_list</span><span class=special>&lt;</span><span class=identifier>scanner</span><span class=special>&lt;&gt;, </span><span class=identifier>phrase_scanner_t</span><span class=special>&gt; </span><span class=identifier>scanners</span><span class=special>;
-
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>scanners</span><span class=special>&gt; </span><span class=identifier>r </span><span class=special>= </span><span class=special>+</span><span class=identifier>anychar_p</span><span class=special>; - </span><span class=identifier>assert</span><span class=special>(</span><span class=identifier>parse</span><span class=special>(</span><span class=string>&quot;abcdefghijk&quot;</span><span class=special>, </span><span class=identifier>r</span><span class=special>).</span><span class=identifier>full</span><span class=special>); - </span><span class=identifier>assert</span><span class=special>(</span><span class=identifier>parse</span><span class=special>(</span><span class=string>&quot;a b c d e f g h i j k&quot;</span><span class=special>, </span><span class=identifier>r</span><span class=special>, </span><span class=identifier>space_p</span><span class=special>).</span><span class=identifier>full</span><span class=special>);</span></pre> -<p>Notice how rule <tt>r</tt> is used in both the phrase and character levels. + To address this issue, we now have multiple scanner support. Example:<br>在1.8.0中,规则可以使用一个或者多个扫描器类型。在诸如需要一个能 同时工作于短句层次和字符层次的分析器的情况下,规则/扫描器的不匹配是迷惑的来 源,也是最常见的 <a href="faq.html#scanner_business">FAQ</a>。为了解决这个问 题,就有了对多扫描器的支持。例子:</p> +<pre><span class="special"> </span><span class="keyword">typedef </span><span class="identifier">scanner_list</span><span class="special">&lt;</span><span class="identifier">scanner</span><span class="special">&lt;&gt;, </span><span class="identifier">phrase_scanner_t</span><span class="special">&gt; </span><span class="identifier">scanners</span><span class="special">;<br><br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">scanners</span><span class="special">&gt; </span><span class="identifier">r </span><span class="special">= </span><span class="special">+</span><span class="identifier">anychar_p</span><span class="special">;<br> </span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">parse</span><span class="special">(</span><span class="string">"abcdefghijk"</span><span class="special">, </span><span class="identifier">r</span><span class="special">).</span><span class="identifier">full</span><span class="special">);<br> </span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">parse</span><span class="special">(</span><span class="string">"a b c d e f g h i j k"</span><span class="special">, </span><span class="identifier">r</span><span class="special">, </span><span class="identifier">space_p</span><span class="special">).</span><span class="identifier">full</span><span class="special">);</span></pre> +<p>Notice how rule <tt>r</tt> is used in both the phrase and character levels.<br>留意规则 <tt>r</tt> 是如何同时在句子和字符的层次中使用的 <tt></tt>。
 </p>
 <p>By default support for multiple scanners is disabled.  The macro
   <tt>BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT</tt> must be defined to the
@@ -76,156 +61,146 @@
   be greater than 1 to enable multiple scanners.  Given the
   example above, to define a limit of two scanners for the list, the
   following line must be inserted into the source file before the
-  inclusion of Spirit headers:
+  inclusion of Spirit headers:<br>对多扫描器的支持在默认情况下是关闭的。宏
+ <tt>BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT</tt>&nbsp;<font face="Courier New">必须定义成 scanner_list 所允许的扫描器的最大数目。</font>&nbsp;比如上面 的例子,要把扫描器列表的最大数目限定为2,就必须在源码中Spirit的头文件之前插 入以下一行:
 </p>
-<pre><span class=special> </span><span class=preprocessor>#define </span><span class=identifier>BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT</span> <span class=literal>2</span></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/bulb.gif" width="13" height="18"> See +<pre><span class="special"> </span><span class="preprocessor">#define </span><span class="identifier">BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT</span> <span class="literal">2</span></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/bulb.gif" height="18" width="13"> See the techniques section for an <a href="techniques.html#multiple_scanner_support">example</a> of a <a href="grammar.html">grammar</a> using a multiple scanner enabled - rule, <a href="scanner.html#lexeme_scanner">lexeme_scanner</a> and <a href="scanner.html#as_lower_scanner">as_lower_scanner.</a></td> + rule, <a href="scanner.html#lexeme_scanner">lexeme_scanner</a> and <a href="scanner.html#as_lower_scanner">as_lower_scanner.</a><p>查看关于<a href="grammar.html">语法</a>如何使用允许多扫描器的规则、<a href="scanner.html#lexeme_scanner">lexeme_scanner</a> 和 <a href="scanner.html#as_lower_scanner">as_lower_scanner</a> 的<a href="techniques.html#multiple_scanner_support">例子</a>,请见技术一节。<a href="scanner.html#as_lower_scanner"></a><a href="http://www.boost.org/libs/spirit/doc/scanner.html#as_lower_scanner";></a></p></td>
   </tr>
-</table>
-<h3>Rule Declarations</h3>
-<p>The rule class models EBNF's production rule. Example:</p>
-<pre><code><font color="#000000"> <span class=identifier>rule</span><span class=special>&lt;&gt; </span><span class=identifier>a_rule </span><span class=special>= </span><span class=special>*(</span><span class=identifier>a </span><span class=special>| </span><span class=identifier>b</span><span class=special>) </span><span class=special>& </span><span class=special>+(</span><span class=identifier>c </span><span class=special>| </span><span class=identifier>d </span><span class=special>| </span><span class=identifier>e</span><span class=special>);</span></font></code></pre>
+</tbody></table>
+<h3>Rule Declarations 规则声明</h3>
+<p>The rule class models EBNF's production rule. Example:<br>rule 类实现了 EBNF的产生规则。例:</p> +<pre><code><font color="#000000"> <span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">a_rule </span><span class="special">= </span><span class="special">*(</span><span class="identifier">a </span><span class="special">| </span><span class="identifier">b</span><span class="special">) </span><span class="special">&amp; </span><span class="special">+(</span><span class="identifier">c </span><span class="special">| </span><span class="identifier">d </span><span class="special">| </span><span class="identifier">e</span><span class="special">);</span></font></code></pre> <p>The type and behavior of the right-hand (rhs) EBNF expression, which may be arbitrarily complex, is encoded in the rule named a_rule. a_rule may now be
-  referenced elsewhere in the grammar:</p>
-<pre><code><font color="#000000"> <span class=identifier>rule</span><span class=special>&lt;&gt; </span><span class=identifier>another_rule </span><span class=special>= </span><span class=identifier>f </span><span class=special>&gt;&gt; </span><span class=identifier>g </span><span class=special>&gt;&gt; </span><span class=identifier>h </span><span class=special>&gt;&gt; </span><span class=identifier>a_rule</span><span class=special>;</span></font></code></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/alert.gif" width="16" height="16"> <b>Referencing
-      rules <br>
+ referenced elsewhere in the grammar:<br>右操作数(rhs)的EBNF表达式的类型 (它可以有任意的复杂度),被一个名为a_rule的规则所包含。a_rule可以在语法的任 意处被引用。</p> +<pre><code><font color="#000000"> <span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">another_rule </span><span class="special">= </span><span class="identifier">f </span><span class="special">&gt;&gt; </span><span class="identifier">g </span><span class="special">&gt;&gt; </span><span class="identifier">h </span><span class="special">&gt;&gt; </span><span class="identifier">a_rule</span><span class="special">;</span></font></code></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/alert.gif" height="16" width="16"> <b>Referencing
+      rules &nbsp;引用规则<br>
       </b><br>
When a rule is referenced anywhere in the right hand side of an EBNF expression, the rule is held by the expression by reference. It is the responsibility of the client to ensure that the referenced rule stays in scope and does
-      not get destructed while it is being referenced. </td>
+ not get destructed while it is being referenced.<p>当一个规则被在 EBNF的表达式右边引用时,表达式适用的是规则的引用。保证被引用的规则的可见性和 被引用时的有效性,是客户程序的责任。</p> </td>
   </tr>
-</table>
-<pre><span class=special> </span><span class=identifier>a </span><span class=special>= </span><span class=identifier>int_p</span><span class=special>; - </span><span class=identifier>b </span><span class=special>= </span><span class=identifier>a</span><span class=special>; - </span><span class=identifier>c </span><span class=special>= </span><span class=identifier>int_p </span><span class=special>&gt;&gt; </span><span class=identifier>b</span><span class=special>;</span></pre>
-<h3>Copying Rules</h3>
+</tbody></table>
+<pre><span class="special"> </span><span class="identifier">a </span><span class="special">= </span><span class="identifier">int_p</span><span class="special">;<br> </span><span class="identifier">b </span><span class="special">= </span><span class="identifier">a</span><span class="special">;<br> </span><span class="identifier">c </span><span class="special">= </span><span class="identifier">int_p </span><span class="special">&gt;&gt; </span><span class="identifier">b</span><span class="special">;</span></pre>
+<h3>Copying Rules 复制规则</h3>
<p>The rule is a weird C++ citizen, unlike any other C++ object. It does not have the proper copy and assignment semantics and cannot be stored and passed around by value. If you need to copy a rule you have to explicitly call its member
-  function <tt>copy()</tt>:</p>
-<pre><span class=special> </span><span class=identifier>r</span><span class="special">.</span><span class=identifier>copy()</span><span class=special>;</span></pre> + function <tt>copy()</tt>:<br>规则是一个别扭的C++公民。与其他C++对象不 同,它没有拷贝和赋值语义,且不能被存储和以值方式传递。如果你需要复制一个规 则,就必须显式地调用它的成员函数 <tt>copy()</tt>:</p> +<pre><span class="special"> </span><span class="identifier">r</span><span class="special">.</span><span class="identifier">copy()</span><span class="special">;</span></pre> <p>However, be warned that copying a rule will not deep copy other referenced rules of the source rule being copied. This might lead to dangling references. Again, it is the responsibility of the client to ensure that all referenced rules stay in scope and does not get destructed while it is being referenced.
-  Caveat emptor.</p>
+ Caveat emptor.<br>然而,对一个规则的拷贝并不会引起对这个规则所引用的其他 规则的深度拷贝。因为这可能会导致悬挂引用。当然,客户程序同样有责任保证所有被 引用的规则都在范围内,并且在被引用期间不会被析构。你得风险自担。</p> <p>If you copy a rule, then you'll want to place it in a storage somewhere. The
-  problem is how? The storage can't be another rule:</p>
-<pre> <code><font color="#000000"><span class=identifier>rule</span><span class=special>&lt;&gt;</span></font></code> r2 <span class="special">=</span> <span class=identifier>r</span><span class="special">.</span><span class=identifier>copy()</span><span class=special>; </span><span class="comment">// BAD!</span></pre> + problem is how? The storage can't be another rule:<br>如果你复制一个规 则,那么你可能会想把它储存在某处。问题是怎么储存?反正不能用另一个规则:</p> +<pre> <code><font color="#000000"><span class="identifier">rule</span><span class="special">&lt;&gt;</span></font></code> r2 <span class="special">=</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">copy()</span><span class="special">; </span><span class="comment">// BAD!</span></pre> <p>because rules are weird and does not have the expected C++ copy-constructor and assignment semantics! As a general rule: <strong>Don't put a copied rule into another rule! </strong>Instead, use the <a href="stored_rule.html">stored_rule</a>
-  for that purpose.</p>
-<h3>Forward declarations</h3>
+ for that purpose.<br>因为规则是别扭的,而且没有所需要的C++拷贝构造函数和 赋值语义!基本原则:<strong>不要把拷贝的规则放到另一个规则中去</strong>。而 是使用<a href="stored_rule.html">可存储规则</a>来达到这一目的。</p>
+<h3>Forward declarations 前向声明</h3>
<p>A <tt>rule</tt> may be declared before being defined to allow cyclic structures
-  typically found in BNF declarations. Example:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>rule</span><span class=special>&lt;&gt; </span><span class=identifier>a</span><span class=special>, </span><span class=identifier>b</span><span class=special>, </span><span class=identifier>c</span><span class=special>;
-
- </span><span class=identifier>a </span><span class=special>= </span><span class=identifier>b </span><span class=special>| </span><span class=identifier>a</span><span class=special>; - </span><span class=identifier>b </span><span class=special>= </span><span class=identifier>c </span><span class=special>| </span><span class=identifier>a</span><span class=special>;</span></font></code></pre>
-<h3>Recursion</h3>
+ typically found in BNF declarations. Example:<br><tt>rule</tt> 可以在定义 前声明以允许EBNF中常见的循环结构。例子:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">a</span><span class="special">, </span><span class="identifier">b</span><span class="special">, </span><span class="identifier">c</span><span class="special">;<br><br> </span><span class="identifier">a </span><span class="special">= </span><span class="identifier">b </span><span class="special">| </span><span class="identifier">a</span><span class="special">;<br> </span><span class="identifier">b </span><span class="special">= </span><span class="identifier">c </span><span class="special">| </span><span class="identifier">a</span><span class="special">;</span></font></code></pre>
+<h3>Recursion 递归</h3>
<p>The right-hand side of a rule may reference other rules, including itself. The limitation is that direct or indirect left recursion is not allowed (this is an unchecked run-time error that results in an infinite loop). This is typical
-  of top-down parsers. Example:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=identifier>a </span><span class=special>= </span><span class=identifier>a </span><span class=special>| </span><span class=identifier>b</span><span class=special>; </span><span class=comment>// infinite loop!</span></font></code></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/lens.gif" width="15" height="16"> <b>What
-      is left recursion?<br>
+ of top-down parsers. Example:<br>规则的右边可以是其他规则,包括它自己。但 是直接或间接的左递归是不允许的(这是一个无法自动检查的错误,在运行时将引起无 限循环)。这是自顶向下分析器的典型情况。例子:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="identifier">a </span><span class="special">= </span><span class="identifier">a </span><span class="special">| </span><span class="identifier">b</span><span class="special">; </span><span class="comment">// infinite loop! 无限循环!</span></font></code></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/lens.gif" height="16" width="15"> <b>What
+      is left recursion? 什么是左递归?<br>
       </b><br>
Left recursion happens when you have a rule that calls itself before anything else. A top-down parser will go into an infinite loop when this happens. See the <a href="faq.html#left_recursion">FAQ</a> for details on how to
-      eliminate left recursion.</td>
+ eliminate left recursion.<p>当某个规则的等号右边的第一个元素是它自己 的时候,就产生了左递归。一个自顶向下分析器在这种情况下将陷入无限循环中。 <a href="faq.html#left_recursion">FAQ</a>中有如何消除左递归的细节。</p></td>
   </tr>
-</table>
-<h3>Undefined rules</h3>
-<p>An undefined rule matches nothing and is semantically equivalent to <tt>nothing_p</tt>.</p>
-<h3>Redeclarations</h3>
+</tbody></table>
+<h3>Undefined rules 未定义规则</h3>
+<p>An undefined rule matches nothing and is semantically equivalent to <tt>nothing_p</tt>.<br>未定义的规则什么都不匹配,语义上等同于 <tt>nothing_p</tt>。</p>
+<h3>Redeclarations 重声明</h3>
<p>Like any other C++ assignment, a second assignment to a rule is destructive and will redefine it. The old definition is lost. Rules are dynamic. A rule
-  can change its definition anytime:</p>
-<pre><code><font color="#000000"><span class=identifier> r </span><span class=special>= </span><span class=identifier>a_definition</span><span class=special>; -</span><span class=identifier> r </span><span class=special>= </span><span class=identifier>another_definition</span><span class=special>;</span></font></code></pre> + can change its definition anytime:<br>与C++的其他赋值相同,对一个规则的二 次赋值会引起它的析构和重定义。老的定义就此丢失。规则是动态的。一个规则可以在 任意时间改变它的定义:</p> +<pre><code><font color="#000000"><span class="identifier"> r </span><span class="special">= </span><span class="identifier">a_definition</span><span class="special">;<br></span><span class="identifier"> r </span><span class="special">= </span><span class="identifier">another_definition</span><span class="special">;</span></font></code></pre> <p>Rule <tt>r</tt> loses the old definition when the second assignment is made. As mentioned, an undefined rule matches nothing and is semantically equivalent
-  to <tt>nothing_p</tt>.
-<h3>Dynamic Parsers</h3>
+ to <tt>nothing_p</tt>.<br>规则 <tt>r</tt>&nbsp;在第二次赋值发生时,丢掉了 它的旧定义。正如上面所提到的,一个未定义的规则总是不匹配,语义上等同于 <tt>nothing_p</tt>。&nbsp;</p><h3>Dynamic Parsers 动态分析器</h3> <p>Hosting declarative EBNF in imperative C++ yields an interesting blend. We have the best of both worlds. We have the ability to conveniently modify the grammar at run time using imperative constructs such as <tt>if</tt>, <tt>else</tt>
-  statements. Example:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>feature_is_available</span><span class=special>) - </span><span class=identifier>r </span><span class=special>= </span><span class=identifier>add_this_feature</span><span class=special>;</span></font></code></pre> + statements. Example:<br>将函数式的EBNF置于指令式的C++中,产生了一个有趣的 混合。我们集二者之长。我们可以轻松地在运行时使用指令式的构造,比如 <tt>if</tt>, <tt>else</tt>&nbsp;语句,来改变一个语法。例如:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">if </span><span class="special">(</span><span class="identifier">feature_is_available</span><span class="special">)<br> </span><span class="identifier">r </span><span class="special">= </span><span class="identifier">add_this_feature</span><span class="special">;</span></font></code></pre> <p>Rules are essentially dynamic parsers. A dynamic parser is characterized by its ability to modify its behavior at run time. Initially, an undefined rule matches nothing. At any time, the rule may be defined and redefined, thus, dynamically
-  altering its behavior.</p>
-<h3>No start rule</h3>
+ altering its behavior.<br>规则本质上就是动态分析器。之所以是动态的,是因 为它在运行时可以改变其行为的这一特征。最初,一个未定义的规则总是不匹配。而在 任何时候,规则都可以定义和重定义,由此动态地改变它的行为。</p>
+<h3>No start rule 没有起始规则</h3>
<p>Typically, parsers have what is called a start symbol, chosen to be the root of the grammar where parsing starts. The Spirit parser framework has no notion of a start symbol. Any rule can be a start symbol. This feature promotes step-wise creation of parsers. We can build parsers from the bottom up while fully testing
-  each level or module up untill we get to the top-most level.</p>
-<h3><a name="tag"></a>Parser Tags</h3>
+ each level or module up untill we get to the top-most level.<br>一般来 说,分析器都有一个起始符号,作为语法的根源,分析的起点。Spirit分析器框架并没 有起始符号。任何规则都可以是起始符号。这加强了逐步构造分析器的能力。构建分析 器时,可以自底向上,同时完整测试所有层次,或者构建所有层次,直到最顶层。</p>
+<h3><a name="tag"></a>Parser Tags 分析器标签</h3>
<p>Rules may be tagged for identification purposes. This is necessary, especially when dealing with <a href="trees.html">parse trees and ASTs</a> to see which rule created a specific AST/parse tree node. Each rule has an ID of type <tt>parser_id</tt>. - This ID can be obtained through the rule's <tt>id()</tt> member function:</p> -<pre><code><font color="#000000"><span class=identifier> my_rule</span><span class=special>.</span><span class=identifier>id</span><span class=special>(); </span><span class=comment>// get my_rule's id</span></font></code></pre>
-<p>The <tt>parser_id</tt> class is declared as:</p>
+ This ID can be obtained through the rule's <tt>id()</tt> member function:<br>为了识别,可以给规则加上标签。这是有需要的,尤其是在<a href="trees.html">分析树和AST树</a>中要判断是哪个规则产生了特定的AST/分析树 节点时。每个规则都有一个类型为 <tt>parser_id</tt> 的ID。这个ID可以通过规则 的 <tt>id()</tt>&nbsp;成员函数得到:</p> +<pre><code><font color="#000000"><span class="identifier"> my_rule</span><span class="special">.</span><span class="identifier">id</span><span class="special">(); </span><span class="comment">// get my_rule's id 取出my_rule的 id</span></font></code></pre> +<p>The <tt>parser_id</tt> class is declared as:<br>类 &nbsp;<tt>parser_id</tt> 声明如下:</p> <pre> <span class="keyword">class</span> <span class="identifier">parser_id</span><br> <span class="special">{</span><br> <span class="keyword">public</span><span class="special">:</span><br> parser_id<span class="special">();</span><br> <span class="keyword">explicit</span> parser_id<span class="special">(</span><span class="keyword">void const</span><span class="special">*</span> p<span class="special">);</span><br> parser_id<span class="special">(</span><span class="keyword">std::size_t</span> l<span class="special">);</span>

<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="identifier">parser_id</span> <span class="keyword">const</span><span class="special">&amp;</span> x<span class="special">)</span> const<span class="special">;</span><br> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="identifier">parser_id</span> <span class="keyword">const</span><span class="special">&amp;</span> x<span class="special">)</span> const<span class="special">;</span> <span class="keyword">bool</span> <span class="keyword"> operator</span><span class="special">&lt;(</span><span class="identifier">parser_id</span> <span class="keyword">const</span><span class="special">&amp;</span> x<span class="special">)</span> const<span class="special">;</span> - <span class="special"></span><span class="keyword">std::size_t</span><span class="identifier"> to_long</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;
-    };</span></pre>
+ <span class="special"></span><span class="keyword">std::size_t</span><span class="identifier"> to_long</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;<br> };</span></pre>
 <h3>parser_address_tag</h3>
<p>The rule's <tt>TagT</tt> template parameter supplies this ID. This defaults to <tt>parser_address_tag</tt>. The <tt>parser_address_tag</tt> uses the address of the rule as its ID. This is often not the most convenient, since it is not
-  always possible to get the address of a rule to compare against. </p>
+ always possible to get the address of a rule to compare against.<br>规则 的TagT模板参数支持这个ID。默认是 <tt>parser_address_tag</tt>。 <tt>parser_address_tag</tt> 适用规则在内存中的地址作为它的ID。这样通常不是很 方便,因为并不总是能够得到一个规则的地址拿来比较的。</p>
 <h3>parser_tag</h3>
<p>It is possible to have specific constant integers to identify a rule. For this purpose, we can use the <tt>parser_tag&lt;N&gt;</tt>, where N is a constant
-  integer:</p>
-<pre><code><font color="#000000"><span class=identifier> rule</span><span class=special>&lt;</span><span class=identifier>parser_tag</span><span class="special">&lt;</span><span class=identifier>123</span><span class="special">&gt; &gt; </span><span class="identifier">my_rule</span><span class="special">; </span><span class="comment">// set my_rule's id to 123</span></font></code></pre> + integer:<br>使用特定的常整数来识别规则也是可以的。为了达到这一目的,可以 使用 <tt>parser_tag&lt;N&gt;</tt>,这里N是一个常整数。</p> +<pre><code><font color="#000000"><span class="identifier"> rule</span><span class="special">&lt;</span><span class="identifier">parser_tag</span><span class="special">&lt;</span><span class="identifier">123</span><span class="special">&gt; &gt; </span><span class="identifier">my_rule</span><span class="special">; </span><span class="comment">// set my_rule's id to 123 将my_rule的id设为 123</span></font></code></pre>
 <h3>dynamic_parser_tag</h3>
<p>The <tt>parser_tag&lt;N&gt;</tt> can only specifiy a <strong>static ID</strong>, which is defined at compile time. If you need the ID to be <strong>dynamic</strong> (changeable at runtime), you can use the <tt>dynamic_parser_tag</tt> class as the <tt>TagT</tt> template parameter. This template parameter enables the <tt>set_id()</tt>
-  function, which may be used to set the required id at runtime:</p>
-<pre><code><font color="#000000"><span class=identifier> rule</span><span class=special>&lt;</span><span class=identifier>dynamic_parser_tag</span><span class="special">&gt; </span><span class="identifier">my_dynrule</span><span class="special">;</span> - my_dynrule.set_id(1234); <span class="comment">// set my_dynrule's id to 1234</span></font></code></pre> + function, which may be used to set the required id at runtime:<br><tt>parser_tag&lt;N&gt;</tt>&nbsp;只能表示一个在编译期定义的 <strong>静态ID</strong>。如果你想让ID变成动态的(在运行期可更改),可以使用 <tt>dynamic_parser_tag</tt> 类作为 <tt>TagT</tt> 模板参数。这个参数允许 <tt>set_id()</tt>&nbsp;函数,作用是在运行时设定所需的 id 值:</p> +<pre><code><font color="#000000"><span class="identifier"> rule</span><span class="special">&lt;</span><span class="identifier">dynamic_parser_tag</span><span class="special">&gt; </span><span class="identifier">my_dynrule</span><span class="special">;</span><br> my_dynrule.set_id(1234); <span class="comment">// set my_dynrule's id to 1234</span></font></code><code><font color="#000000"><span class="comment"> 将my_rule的id设为1234</span></font></code></pre> <p>If the <tt>set_id()</tt> function isn't called, the parser id defaults to the address of the rule as its ID, just like the <tt>parser_address_tag</tt> template
-  parameter would do. </p>
+ parameter would do.<br>如果 <tt>set_id()</tt>&nbsp;没有被调用,分析器的 id默认为它的地址。就像 <tt>parser_address_tag</tt>&nbsp;模板参数那样。</p>
 <table border="0">
-  <tr>
+  <tbody><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="numerics.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="epsilon.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/scanner.html Tue Mar 31 01:07:16 2009
+++ /trunk/libs/spirit/classic/doc/scanner.html Wed Sep 16 20:25:53 2009
@@ -1,186 +1,146 @@
-<html>
-<head>
-<title>The Scanner and Parsing</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>The Scanner and Parsing</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>The Scanner and Parsing</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>The Scanner and Parsing 扫描器与分析</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="directives.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="grammar.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
<p>The <b>scanner</b>'s task is to feed the sequential input data stream to the parser. The scanner extracts data from the input, parceling, potentially modifying or filtering, and then finally relegating the result to individual parser elements on demand until the input is exhausted. The scanner is composed of two STL conforming forward iterators, first and last, where first is held by reference and last, by value. The first iterator is held by reference to allow it to be re-positioned.
-  The following diagram illustrates what's happening:</p>
-<table width="62%" border="0" align="center">
-  <tr>
+ The following diagram illustrates what's happening:</p><p><span style="font-weight: bold;">扫描器</span>的任务是将线性输入的数据流喂给分析 器。它从输入中提 +取,包裹,还有可能修改或者过滤数据,接着最后把结果移交给每个有需要的分析 器,直到耗尽输入。扫描器有两个STL兼容的前向迭代器,first 和 +last,first 以引用方式保存,last 以值方式保存。first 迭代器作为引用保存,使 得它可以被重定位。下图描绘的就是所发生的:</p>
+<table align="center" border="0" width="62%">
+  <tbody><tr>
     <td><img src="theme/scanner1.png"></td>
   </tr>
-</table>
+</tbody></table>
<p>The scanner manages various aspects of the parsing process through a set of
-  policies. There are three sets of policies that govern:</p>
+ policies. There are three sets of policies that govern:<br>扫描器通过一系 列策略集管理分析过程的多个方面。策略集有三个:</p>
 <blockquote>
- <p><img src="theme/bullet.gif" width="12" height="12"> Iteration and filtering<br> - <img src="theme/bullet.gif" width="12" height="12"> Recognition and matching<br> - <img src="theme/bullet.gif" width="12" height="12"> Handling semantic actions</p> + <p><img src="theme/bullet.gif" height="12" width="12"> Iteration and filtering 迭代与过滤<br> + <img src="theme/bullet.gif" height="12" width="12"> Recognition and matching 识别与匹配<br> + <img src="theme/bullet.gif" height="12" width="12"> Handling semantic actions 处理语义动作</p>
 </blockquote>
<p>These policies are mostly hidden from view and users generally need not know about them. Advanced users might however provide their own policies that override
   the ones that are already in place to fine tune the parsing process
to fit their own needs. We shall see how this can be done. This will be covered
-  in further detail later.</p>
+ in further detail later.<br>这些策略隐藏在最深处,用户一般是不需要了解它 们的。然而高级用户也许会提供自己的策略来代替它们以调整分析器,使之符合用户的 需求。我们将会看到这是如何做到的。不久将会看到更详尽的细节。</p> <p>The <tt>scanner</tt> is a template class expecting two parameters: <tt>IteratorT</tt>, the iterator type and <tt>PoliciesT</tt>, its set of policies. <tt>IteratorT</tt> defaults to <tt>char const*</tt> while <tt>PoliciesT</tt> defaults to <tt>scanner_policies&lt;&gt;</tt>, - a predefined set of scanner policies that we can use straight out of the box.</p> -<pre><code><font color="#000000"><span class=keyword> template</span><span class=special>&lt; - </span><span class=keyword>typename </span><span class=identifier>IteratorT </span><span class=special>= </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, - </span><span class=keyword>typename </span><span class=identifier>PoliciesT </span><span class=special>= </span><span class=identifier>scanner_policies</span><span class=special>&lt;&gt; </span><span class=special>&gt; - </span><span class=keyword>class </span><span class=identifier>scanner</span><span class=special>;</span></font></code></pre> + a predefined set of scanner policies that we can use straight out of the box.<br><tt>scanner</tt> 是一个模板类,有两个模板参 数:<tt>IteratorT</tt>&nbsp;迭代器类型,以及 <tt>PoliciesT</tt> 它的策略集。 <tt>IteratorT</tt> 默认为 <tt>char const*</tt>&nbsp;而 <tt>PoliciesT</tt> 默 认为 <tt>scanner_policies&lt;&gt;</tt>,一个可以直接使用的预定义分析器策略 集。</p> +<pre><code><font color="#000000"><span class="keyword"> template</span><span class="special">&lt;<br> </span><span class="keyword">typename </span><span class="identifier">IteratorT </span><span class="special">= </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*,<br> </span><span class="keyword">typename </span><span class="identifier">PoliciesT </span><span class="special">= </span><span class="identifier">scanner_policies</span><span class="special">&lt;&gt; </span><span class="special">&gt;<br> </span><span class="keyword">class </span><span class="identifier">scanner</span><span class="special">;</span></font></code></pre> <p>Spirit uses the same iterator concepts and interface formally defined by the C++ Standard Template Library (STL). We can use iterators supplied by STL's containers (e.g. <tt>list</tt>, <tt>vector</tt>, <tt>string</tt>, etc.) as is, or perhaps write our own. Iterators can be as simple as a pointer (e.g. <tt>char const<span class="operators">*</span></tt>). At the other end of the spectrum, iterators can be quite complex; for instance, an iterator adapter that wraps
-  a lexer such as LEX.</p>
-<h2>The Free Parse Functions</h2>
+ a lexer such as LEX.<br>Spirit使用与在C++标准模板库(STL)中正式定义的迭 代器概念和接口相一致的迭代器。我们可以使用STL的容器(比如 <tt>list</tt>, <tt>vector</tt>, <tt>string</tt> 等)提供的迭代器,或者,也可以用自己写的。 迭代器可以和一个指针一样简单(比如 <tt>char + const<span class="operators">*</span></tt>)。而在族谱的另一端,它也可以 相当复杂;比如一个封装了诸如LEX这样的词法分析器的迭代器适配器。</p>
+<h2>The Free Parse Functions 自由分析函数</h2>
<p>The framework provides a couple of free functions to make parsing a snap. These parser functions have two forms. The first form works on the <b>character level</b>. - The second works on the <b>phrase level</b> and asks for a <b>skip parser</b>.</p> + The second works on the <b>phrase level</b> and asks for a <b>skip parser</b>.<br>本框架提供了一些自由函数,以进行短小的分析。这些分析函数有两 种形式。第一种工作于<span style="font-weight: bold;">字符层面</span>,第二种 则工作于<span style="font-weight: bold;">短句层面</span>,并且需要一个<span style="font-weight: bold;">跳读分析器</span>。</p> <p>The <b>skip parser</b> is just about any parser primitive or composite. Its purpose is to move the scanner's <tt>first</tt> iterator to valid tokens by skipping white spaces. In C for instance, the tab <tt class="quotes">'\t'</tt>, the newline <tt class="quotes">'\n'</tt>, return <tt><span class="quotes">'\r'</span></tt>, space <tt class="quotes">' '</tt> and characters inside comments <tt class="quotes">/*...*/</tt>
-  are considered as white spaces.</p>
-<p><b>Character level parsing</b></p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>IteratorT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>DerivedT</span><span class=special>&gt; - </span><span class=identifier>parse_info</span><span class=special>&lt;</span><span class=identifier>IteratorT</span><span class=special>&gt;
-    </span><span class=identifier>parse
-    </span><span class=special>(
- </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>first</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>last</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>DerivedT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>p
-    </span><span class=special>);</span></font></code></pre>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>CharT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>DerivedT</span><span class=special>&gt; - </span><span class=identifier>parse_info</span><span class=special>&lt;</span><span class=identifier>CharT </span><span class=keyword>const</span><span class=special>*&gt;
-    </span><span class=identifier>parse
-    </span><span class=special>(
- </span><span class=identifier>CharT </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>str</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>DerivedT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>p
-    </span><span class=special>);</span></font></code></pre>
+ are considered as white spaces.<br><span style="font-weight: bold;">跳读 分析器</span>可以是任意的基本或者合成分析器。它的目的是跳过空白字符,把扫描 器的<tt>first</tt>迭代器移动到有效的记号上。比如在C语言里,制表符 <tt class="quotes">'\t'</tt>、回车<tt><span class="quotes">'\r'</span></tt>、空 格<tt class="quotes">' '</tt>以及注释内的字符<tt class="quotes">/*...*/</tt>被认为是空白字符。</p>
+<p><b>Character level parsing 字符层面的分析</b></p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">IteratorT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">DerivedT</span><span class="special">&gt;<br> </span><span class="identifier">parse_info</span><span class="special">&lt;</span><span class="identifier">IteratorT</span><span class="special">&gt;<br> </span><span class="identifier">parse<br> </span><span class="special">(<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">first</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">last</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">DerivedT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p<br> </span><span class="special">);</span></font></code></pre> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">CharT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">DerivedT</span><span class="special">&gt;<br> </span><span class="identifier">parse_info</span><span class="special">&lt;</span><span class="identifier">CharT </span><span class="keyword">const</span><span class="special">*&gt;<br> </span><span class="identifier">parse<br> </span><span class="special">(<br> </span><span class="identifier">CharT </span><span class="keyword">const</span><span class="special">* </span><span class="identifier">str</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">DerivedT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p<br> </span><span class="special">);</span></font></code></pre> <p>There are two variants. The first variant accepts a <tt>first</tt>, <tt>last</tt> iterator pair like you do STL algorithms. The second variant accepts a null terminated string. The last argument is a parser <tt>p</tt> which will be used
-  to parse the input.</p>
-<p><b>Phrase level parsing</b></p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>IteratorT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>SkipT</span><span class=special>&gt; - </span><span class=identifier>parse_info</span><span class=special>&lt;</span><span class=identifier>IteratorT</span><span class=special>&gt;
-    </span><span class=identifier>parse
-    </span><span class=special>(
- </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>first</span><span class=special>, - </span><span class=identifier>IteratorT </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>last</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>ParserT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>p</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>SkipT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>skip
-    </span><span class=special>);</span></font></code></pre>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>CharT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>ParserT</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>SkipT</span><span class=special>&gt; - </span><span class=identifier>parse_info</span><span class=special>&lt;</span><span class=identifier>CharT </span><span class=keyword>const</span><span class=special>*&gt;
-    </span><span class=identifier>parse
-    </span><span class=special>(
- </span><span class=identifier>CharT </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>str</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>ParserT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>p</span><span class=special>, - </span><span class=identifier>parser</span><span class=special>&lt;</span><span class=identifier>SkipT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>skip
-    </span><span class=special>);</span></font></code></pre>
+ to parse the input.<br>这里存在两种变体,第一个变体接受一对 <tt>first</tt>, <tt>last</tt>&nbsp;迭代器,就像你在STL算法里面用的一样。第二 个变体接受一个null结尾的字符串。最后一个参数是一个用于分析输入的分析器 <tt>p</tt>。</p>
+<p><b>Phrase level parsing 短句层面的分析</b></p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">IteratorT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">SkipT</span><span class="special">&gt;<br> </span><span class="identifier">parse_info</span><span class="special">&lt;</span><span class="identifier">IteratorT</span><span class="special">&gt;<br> </span><span class="identifier">parse<br> </span><span class="special">(<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">first</span><span class="special">,<br> </span><span class="identifier">IteratorT </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">last</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">ParserT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">SkipT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">skip<br> </span><span class="special">);</span></font></code></pre> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">CharT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">ParserT</span><span class="special">, </span><span class="keyword">typename </span><span class="identifier">SkipT</span><span class="special">&gt;<br> </span><span class="identifier">parse_info</span><span class="special">&lt;</span><span class="identifier">CharT </span><span class="keyword">const</span><span class="special">*&gt;<br> </span><span class="identifier">parse<br> </span><span class="special">(<br> </span><span class="identifier">CharT </span><span class="keyword">const</span><span class="special">* </span><span class="identifier">str</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">ParserT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">p</span><span class="special">,<br> </span><span class="identifier">parser</span><span class="special">&lt;</span><span class="identifier">SkipT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">skip<br> </span><span class="special">);</span></font></code></pre> <p>Like above, there are two variants. The first variant accepts a <tt>first</tt>, <tt>last</tt> iterator pair like you do STL algorithms. The second variant accepts a null terminated string. The argument <tt>p</tt> is the parser which will be - used to parse the input. The last argument <tt>skip</tt> is the skip parser.</p>
-<p><b>The parse_info structure</b></p>
+ used to parse the input. The last argument <tt>skip</tt> is the skip parser.<br>和前面一样,这里也有两个变体。第一个变体接受一对 <tt>first</tt>, <tt>last</tt>&nbsp;迭代器,就像你在STL算法里面用的一样。第二个变体接受一个 null结尾的字符串。参数 <tt>p</tt> 是一个用于分析输入的分析器。最后一个参数 <tt>skip</tt>&nbsp;就是跳读分析器。</p>
+<p><b>The parse_info structure &nbsp;结构 parse_info</b></p>
<p>The functions above return a <tt>parse_info</tt> structure parameterized by
-  the iterator type passed in. The parse_info struct has these members:</p>
-<table width="90%" border="0" align="center">
-  <tr>
+ the iterator type passed in. The parse_info struct has these members:<br>以上函数返回一个以传入的迭代器类型为模板参数的 <tt>parse_info</tt> 结构。parse_info 结构有如下成员:</p>
+<table align="center" border="0" width="90%">
+  <tbody><tr>
     <td colspan="2" class="table_title"><b>parse_info</b></td>
   </tr>
   <tr>
-    <td width="14%" class="table_cells"><b>stop</b></td>
- <td width="86%" class="table_cells">Points to the final parse position (i.e
-      The parser recognized and processed the input up to this point)</td>
+    <td class="table_cells" width="14%"><b>stop</b></td>
+ <td class="table_cells" width="86%">Points to the final parse position (i.e + The parser recognized and processed the input up to this point)<br>指 向最终的分析位置(比如,分析器识别和处理的输入到这里为止)</td>
   </tr>
   <tr>
-    <td width="14%" class="table_cells"><b>hit</b></td>
- <td width="86%" class="table_cells">True if parsing is successful. This may
+    <td class="table_cells" width="14%"><b>hit</b></td>
+ <td class="table_cells" width="86%">True if parsing is successful. This may be full: the parser consumed all the input, or partial: the parser consumed
-      only a portion of the input.</td>
+ only a portion of the input.<br>如果分析成功,则为真。这个成功有可能 是完全的:分析器消耗了全部的输入,或者部分的:分析器只消耗了一部分输入</td>
   </tr>
   <tr>
-    <td width="14%" class="table_cells"><b>full</b></td>
- <td width="86%" class="table_cells">True when we have a full match (i.e The
-      parser consumed all the input).</td>
+    <td class="table_cells" width="14%"><b>full</b></td>
+ <td class="table_cells" width="86%">True when we have a full match (i.e The + parser consumed all the input).<br>如果完全匹配则为真(比如分析器消耗 了全部输入)</td>
   </tr>
   <tr>
-    <td width="14%" class="table_cells"><b>length</b></td>
- <td width="86%" class="table_cells">The number of characters consumed by the
+    <td class="table_cells" width="14%"><b>length</b></td>
+ <td class="table_cells" width="86%">The number of characters consumed by the parser. This is valid only if we have a successful match (either partial
-      or full). </td>
+ or full).<br>分析器消耗的字符数目。只有在成功匹配(无论是部分的或者全 部的)时,这个值才有效。 </td>
   </tr>
-</table>
-<h2><a name="phrase_scanner_t" id="phrase_scanner_t"></a><img src="theme/lens.gif" width="15" height="16">
+</tbody></table>
+<h2><a name="phrase_scanner_t" id="phrase_scanner_t"></a><img src="theme/lens.gif" height="16" width="15">
   The phrase_scanner_t and wide_phrase_scanner_t</h2>
-<p>For convenience, Spirit declares these typedefs:</p>
-<pre>
- <span class="keyword">typedef</span> scanner<span class="special">&lt;</span><span class="keyword">char const</span><span class="special">*,</span> unspecified<span class="special">&gt;</span> phrase_scanner_t<span class="special">;</span> +<p>For convenience, Spirit declares these typedefs:<br>方便起见,Spirit声明 了这些 typedef:</p> +<pre> <span class="keyword">typedef</span> scanner<span class="special">&lt;</span><span class="keyword">char const</span><span class="special">*,</span> unspecified<span class="special">&gt;</span> phrase_scanner_t<span class="special">;</span> <span class="keyword">typedef</span> scanner<span class="special">&lt;</span><span class="keyword">wchar_t const</span><span class="special">*,</span> <span class="identifier">unspecified</span><span class="special">&gt;</span> wide_phrase_scanner_t<span class="special">;</span>
 </pre>
<p>These are the exact scanner types used by Spirit on calls to the parse function passing in a <tt>char const*</tt> (C string) or a <tt>wchar_t const*</tt> (wide string) as the first parameter and a <tt>space_p</tt> as skip-parser (the third - parameter). For instance, we can use these typedefs to declare some rules. Example:</p> -<pre> rule<span class="special">&lt;</span>phrase_scanner_t<span class="special">&gt; </span><span class="identifier">my_rule</span><span class="special">; - </span><span class="identifier">parse</span><span class="special">(</span><span class="string">&quot;abrakadabra&quot;</span><span class="special">, </span><span class="identifier">my_rule</span><span class="special">,</span> <span class="identifier">space_p</span><span class="special">);</span></pre> -<h2><img src="theme/lens.gif" width="15" height="16"> Direct parsing with Iterators</h2> + parameter). For instance, we can use these typedefs to declare some rules. Example:<br>这些是这些是Spirit里那些被传入 <tt>char const*</tt>(C字符 串)或者 <tt>wchar_t const*</tt>(宽字符串)作为第一个参数,以及以一个 <tt>space_p</tt> 作为跳读分析器(第三个参数)的parse函数所用的扫描器的准确类 型。比如,我们可以使
+用这些 typedef 去声明一些规则。例子:</p>
+<pre> rule<span class="special">&lt;</span>phrase_scanner_t<span class="special">&gt; </span><span class="identifier">my_rule</span><span class="special">;<br> </span><span class="identifier">parse</span><span class="special">(</span><span class="string">"abrakadabra"</span><span class="special">, </span><span class="identifier">my_rule</span><span class="special">,</span> <span class="identifier">space_p</span><span class="special">);</span></pre> +<h2><img src="theme/lens.gif" height="16" width="15"> Direct parsing with Iterators 使用迭代器直接分析</h2> <p>The free parse functions make it easy for us. By using them, we need not bother with the scanner intricacies. The free parse functions hide the dirty details. However, sometime in the future, we will need to get under the hood. It's nice that we know what we are dealing with when that need comes. We will need to
-  go low-level and call the parser's parse member function directly. </p>
-<p>If we wish to work on the <b>character level</b>, the procedure is quite simple:</p> -<pre><span class=identifier> </span><span class=identifier>scanner</span><span class=special>&lt;</span><span class=identifier>IteratorT</span><span class=special>&gt; </span><span class=identifier>scan</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>);
-
- </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>p</span><span class=special>.</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>))
-    </span><span class=special>{
- </span><span class=comment>// Parsed successfully. If first == last, then we have
-        //  a full parse, the parser recognized the input in whole.
-    </span><span class=special>}
-    </span><span class=keyword>else
-    </span><span class=special>{
- </span><span class=comment>// Parsing failure. The parser failed to recognize the input
-    </span><span class=special>}</span></pre>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/alert.gif" width="16" height="16"> <strong>The
-      scanner position on an unsucessful match</strong><br> <br>
+ go low-level and call the parser's parse member function directly.<br>自 由分析函数把这件事情变简单了。通过使用他们,我们不必为分析器的复杂细节烦神。 自由分析函数隐藏了那些肮脏的细节。然而,将来的某些时候,我们将需要 +更深入底层。在需求来临时,我们知道我们对付的是什么,这样会比较好。我们将需 要深入底层并直接调用分析器的 parse 成员函数。 </p> +<p>If we wish to work on the <b>character level</b>, the procedure is quite simple:<br>如果我们想在<span style="font-weight: bold;">字符层面 </span>上工作,那么过程很简单:</p> +<pre><span class="identifier"> </span><span class="identifier">scanner</span><span class="special">&lt;</span><span class="identifier">IteratorT</span><span class="special">&gt; </span><span class="identifier">scan</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">);<br><br> </span><span class="keyword">if </span><span class="special">(</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">))<br> </span><span class="special">{<br> </span><span class="comment">// Parsed successfully. If first == last, then we have 分析成功。如果 first == last,则为<br> // a full parse, the parser recognized the input in whole. </span><span class="comment">全分析,</span><span class="comment">分 析器识别出整个输入。<br> </span><span class="special">}<br> </span><span class="keyword">else<br> </span><span class="special">{<br> </span><span class="comment">// Parsing failure. The parser failed to recognize the input 分析失败。分析器不能识别输 入。<br> </span><span class="special">}</span></pre>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/alert.gif" height="16" width="16"> <strong>The + scanner position on an unsucessful match </strong><strong>匹配不成功 时扫描器的位置</strong><br> <br> On a successful match, the input is advanced accordingly. But what happens on an unsuccessful match? Be warned. It might be intuitive to think that the scanner position is reset to its initial position prior to parsing.
@@ -190,37 +150,23 @@
descent. If this behavior is not desired, you may need to position the scanner yourself. The <a href="numerics.html#scanner_save">example in the numerics chapter</a> illustrates how the scanner position can be saved and later
-      restored.</td>
+ restored.<br>在成功匹配的情况下,输入会一直步进。但如果匹配没成功会发 生什么?注意,也许你会直觉地认为扫描器的位置会被重置到上个分析阶段的初始位 置。但是不对,它的位置不会被重置。在匹配不成功的情况下,扫描器的位置是<span style="font-weight: bold;">未定义的</span>!通常,它会被放到在递归下降过程中 所产生的最深的一个错误那儿。如果你不想要这种行为,那就要自己改变分析器的位 置。在<a href="numerics.html#scanner_save">数值分析里的例子</a>描绘了如何保 存分析器的位置并在之后恢复。</td>
   </tr>
-</table>
+</tbody></table>
<p>Where <tt>p</tt> is the parser we want to use, and <tt>first</tt>/<tt>last</tt> are the iterator pairs referring to the input. We just create a scanner given - the iterators. The scanner type we will use here uses the default <tt>scanner_policies&lt;&gt;</tt>.</p> -<p>The situation is a bit more complex when we wish to work on the <b>phrase level</b>:</p> -<pre><span class=special> </span><span class=keyword>typedef </span><span class=identifier>skip_parser_iteration_policy</span><span class=special>&lt;</span><span class=identifier>SkipT</span><span class=special>&gt; </span><span class=identifier>iter_policy_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>scanner_policies</span><span class=special>&lt;</span><span class=identifier>iter_policy_t</span><span class=special>&gt; </span><span class=identifier>scanner_policies_t</span><span class=special>; - </span><span class=keyword>typedef </span><span class=identifier>scanner</span><span class=special>&lt;</span><span class=identifier>IteratorT</span><span class=special>, </span><span class=identifier>scanner_policies_t</span><span class=special>&gt; </span><span class=identifier>scanner_t</span><span class=special>;
-
-</span><span class=special> </span><span class=identifier>iter_policy_t </span><span class=identifier>iter_policy</span><span class=special>(</span><span class=identifier>skip</span><span class=special>); - </span><span class=identifier>scanner_policies_t </span><span class=identifier>policies</span><span class=special>(</span><span class=identifier>iter_policy</span><span class=special>); - </span><span class=identifier>scanner_t </span><span class=identifier>scan</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>, </span><span class=identifier>policies</span><span class=special>);
-</span>
- <span class=keyword>if </span><span class=special>(</span><span class=identifier>p</span><span class=special>.</span><span class=identifier>parse</span><span class=special>(</span><span class=identifier>scan</span><span class=special>))
-    </span><span class=special>{
- </span><span class=comment>// Parsed successfully. If first == last, then we have
-        //  a full parse, the parser recognized the input in whole.
-    </span><span class=special>}
-    </span><span class=keyword>else
-    </span><span class=special>{
- </span><span class=comment>// Parsing failure. The parser failed to recognize the input
-    </span><span class=special>}</span></pre>
+ the iterators. The scanner type we will use here uses the default <tt>scanner_policies&lt;&gt;</tt>.<br>这里 <tt>p</tt>&nbsp;是我们想使用的分 析器,而 <tt>first</tt>/<tt>last</tt>&nbsp;是指向输入的迭代器对。我们只是创 建了一个使用这两个迭代器的扫描器。这里使用的扫描器类使用的是默认的 <tt>scanner_policies&lt;&gt;</tt>。</p> +<p>The situation is a bit more complex when we wish to work on the <b>phrase level</b>:<br>当我们想在<span style="font-weight: bold;">短句层面 </span>上工作时,情况就有些复杂了:</p> +<pre><span class="special"> </span><span class="keyword">typedef </span><span class="identifier">skip_parser_iteration_policy</span><span class="special">&lt;</span><span class="identifier">SkipT</span><span class="special">&gt; </span><span class="identifier">iter_policy_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">scanner_policies</span><span class="special">&lt;</span><span class="identifier">iter_policy_t</span><span class="special">&gt; </span><span class="identifier">scanner_policies_t</span><span class="special">;<br> </span><span class="keyword">typedef </span><span class="identifier">scanner</span><span class="special">&lt;</span><span class="identifier">IteratorT</span><span class="special">, </span><span class="identifier">scanner_policies_t</span><span class="special">&gt; </span><span class="identifier">scanner_t</span><span class="special">;<br><br></span><span class="special"> </span><span class="identifier">iter_policy_t </span><span class="identifier">iter_policy</span><span class="special">(</span><span class="identifier">skip</span><span class="special">);<br> </span><span class="identifier">scanner_policies_t </span><span class="identifier">policies</span><span class="special">(</span><span class="identifier">iter_policy</span><span class="special">);<br> </span><span class="identifier">scanner_t </span><span class="identifier">scan</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">, </span><span class="identifier">policies</span><span class="special">);<br></span> + <span class="keyword">if </span><span class="special">(</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">parse</span><span class="special">(</span><span class="identifier">scan</span><span class="special">))<br> </span><span class="special">{<br> </span><span class="comment">// Parsed successfully. If first == last, then we have 分析成功。如果 first == last,则为<br> // a full parse, the parser recognized the input in whole. 全分析,分析器识别出整个输入。<br> </span><span class="special">}<br> </span><span class="keyword">else<br> </span><span class="special">{<br> </span><span class="comment">// Parsing failure. The parser failed to recognize the input 分析失败。分析器 不能识别输入。<br> </span><span class="special">}</span></pre> <p>Where <tt>SkipT</tt> is the type of the skip-parser, <tt>skip</tt>. Again, <tt>p</tt> is the parser we want to use, and <tt>first</tt>/<tt>last</tt> are the iterator pairs referring to the input. Given a skip-parser type <tt>SkipT</tt>, - <span class=identifier><tt>skip_parser_iteration_policy</tt></span> creates + <span class="identifier"><tt>skip_parser_iteration_policy</tt></span> creates a scanner iteration policy that skips over portions that are recognized by the skip-parser. This may then be used to create a scanner. The <tt>scanner_policies</tt> - class wraps all scanner related policies including the iteration policies.</p> + class wraps all scanner related policies including the iteration policies.<br>这里 <tt>SkipT</tt> 是跳读分析器 <tt>skip</tt> 的类型。同 样,<tt>p</tt>&nbsp;是我们要用的分析器,而 <tt>first</tt>/<tt>last</tt>&nbsp;是指向输入的迭代器对。给与一个类型为 <tt>SkipT</tt> 的跳读分析器, +则<span class="identifier"><tt>skip_parser_iteration_policy</tt></span>&nbsp;将创建 一个会跳过被跳读分析器所匹配的内容的扫描器迭代策略。 <tt>scanner_policies</tt>&nbsp;类封装了包括迭代策略在内的所有与扫描器相关的 策略。</p>
 <h2><a name="lexeme_scanner"></a>lexeme_scanner</h2>
<p>When switching from phrase level to character level parsing, the <tt>lexeme_d</tt> (see <a href="directives.html">directives.html</a>) does its magic by disabling
@@ -229,60 +175,61 @@
type. This should not be a problem in most cases. However, when rules are called inside the <tt>lexeme_d</tt>, the compiler will choke if the rule does not have the proper scanner type. If a rule must be used inside a <tt>lexeme_d</tt>,
-  the rule's type must be:</p>
-<pre> <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>lexeme_scanner</span><span class="special">&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class="identifier">type</span><span class=special>&gt; </span>r<span class=special>;</span></pre> -<p>where <span class=identifier><tt>ScannerT</tt></span> is the actual type of - the scanner used. Take note that <tt>lexeme_scanner</tt> will only work for phrase level scanners. </p> + the rule's type must be:<br>当分析层面从字符层面转向短句层面 时,<tt>lexeme_d</tt> (见 <a href="directives.html">directives.html</a>)通过 禁止跳过空白字符来完成它的魔法。这是通过调整<a href="scanner.html">扫描器 </a>来 +完成的。然而,当我们这么做时,所有在 lexeme 里的分析器都会得到一个变换后的 分析器类。在大多数情况下,这并不是问题。可是,当规则在 &nbsp;<tt>lexeme_d</tt> 内被调用时,如果它没有恰当的分析器类型,那么编译器会 在此受阻。如果非要在 <tt>lexeme_d</tt> 内使用规则,那么规则的类型必须 是:</p> +<pre> <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">lexeme_scanner</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt; </span>r<span class="special">;</span></pre> +<p>where <span class="identifier"><tt>ScannerT</tt></span> is the actual type of + the scanner used. Take note that <tt>lexeme_scanner</tt> will only work for phrase level scanners.<br>这里 <span class="identifier"><tt>ScannerT</tt></span>&nbsp;是所使用的分析器的真正类 型。注意 <tt>lexeme_scanner</tt>&nbsp;将只在短句层面工作。 </p>
 <h2><a name="as_lower_scanner"></a>as_lower_scanner</h2>
<p>Similarly, the <tt>as_lower_d</tt> does its work by filtering and converting all characters received from the scanner to lower case. This is also done by tweaking the <a href="scanner.html">scanner</a>. Then again, all parsers inside the <tt>as_lower_d</tt> gets a transformed scanner type. If a rule must be used
-  inside a <tt>as_lower_d</tt>, the rule's type must be:</p>
-<pre> <span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>as_lower_scanner</span><span class="special">&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class="identifier">type</span><span class=special>&gt; </span>r<span class=special>;</span></pre> -<p>where <span class=identifier><tt>ScannerT</tt></span> is the actual type of
-  the scanner used. </p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/bulb.gif" width="13" height="18"> See + inside a <tt>as_lower_d</tt>, the rule's type must be:<br>类似 的,<tt>as_lower_d</tt>&nbsp;通过把所有从分析器收到的字符转成小写来完成自己 的工作。这同样是通过调整扫描器来完成的。同样,所有在 <tt>as_lower_d</tt>&nbsp;里面的分析器都会得到一个变换后的分析器类。如果要在 <tt>as_lower_d</tt>&nbsp;内使用规则,那么规则的类型必须是:</p> +<pre> <span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">as_lower_scanner</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt; </span>r<span class="special">;</span></pre> +<p>where <span class="identifier"><tt>ScannerT</tt></span> is the actual type of + the scanner used.<br>其中 <span class="identifier"><tt>ScannerT</tt></span> 是所使用的扫描器的实际类型。 </p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/bulb.gif" height="18" width="13"> See the techniques section for an <a href="techniques.html#multiple_scanner_support">example</a> of a <a href="grammar.html">grammar</a> using a <a href="rule.html#multiple_scanner_support">multiple scanner enabled rule</a>, <a href="scanner.html#lexeme_scanner">lexeme_scanner</a> - and <a href="scanner.html#as_lower_scanner">as_lower_scanner.</a></td> + and <a href="scanner.html#as_lower_scanner">as_lower_scanner.</a><br><img src="theme/bulb.gif" height="18" width="13"> 在技术章节内有关于使用<a href="rule.html#multiple_scanner_support">多扫描器规则</a>、<a href="scanner.html#lexeme_scanner">lexeme_scanner</a> 和 <a href="scanner.html#as_lower_scanner">as_lower_scanner</a>的<a href="grammar.html">语法</a>的<a href="techniques.html#multiple_scanner_support">例子</a>。<a href="scanner.html#as_lower_scanner"></a></td>
   </tr>
-</table>
+</tbody></table>
 <h3><a name="no_actions_scanner"></a>no_actions_scanner</h3>
<p>Again, <tt>no_actions_d</tt> directive tweaks the scanner to disable firing semantic actions. Like before, all parsers inside the <tt>no_actions_d</tt> gets a transformed scanner type. If a rule must be used inside a <tt>no_actions_d</tt>,
-  the rule's type must be:</p>
-<pre> <span class=identifier>rule</span><span class=special>&lt;</span>no_actions_scanner<span class="special">&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt;::</span><span class="identifier">type</span><span class=special>&gt; </span>r<span class=special>;</span></pre> -<p>where <tt>ScannerT</tt> is the actual type of the scanner used. <span class=special></span></p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/note.gif" width="16" height="16"> Be - sure to add &quot;<tt>typename</tt>&quot; before <tt><span class=identifier><tt>lexeme_scanner</tt>, + the rule's type must be:<br>同样,<tt>no_actions_d</tt> 指示符也是通过调 整扫描器来禁止语义动作。就像前面的,在 <tt>no_actions_d</tt>&nbsp;中的所有分 析器得到的也是变换后的分析器类。如果想在 <tt>no_actions_d</tt>&nbsp;里使用规 则,规则的类型必须是:</p> +<pre> <span class="identifier">rule</span><span class="special">&lt;</span>no_actions_scanner<span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt; </span>r<span class="special">;</span></pre> +<p>where <tt>ScannerT</tt> is the actual type of the scanner used.<br>其中 <span class="identifier"><tt>ScannerT</tt></span> 是所使用的扫描器的实际类 型。 <span class="special"></span></p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/note.gif" height="16" width="16"> Be + sure to add "<tt>typename</tt>" before <tt><span class="identifier"><tt>lexeme_scanner</tt>, <tt>as_lower_scanner</tt></span></tt> and <tt>no_actions_scanner</tt> when
-      these are used inside a template class or function.</td>
+ these are used inside a template class or function.<br><img src="theme/note.gif" height="16" width="16"> 记住当在模板类或函数中使用 <tt><span class="identifier"><tt>lexeme_scanner</tt>, + <tt>as_lower_scanner</tt></span></tt> 和 <tt>no_actions_scanner</tt>时,在它们前加 "<tt>typename</tt>"。</td>
   </tr>
-</table>
-<p><img src="theme/lens.gif" width="15" height="16"> See <a href="../example/fundamental/no_actions.cpp">no_actions.cpp</a>. This is part of the Spirit distribution.</p>
+</tbody></table>
+<p><img src="theme/lens.gif" height="16" width="15"> See <a href="../example/fundamental/no_actions.cpp">no_actions.cpp</a>. This is part of the Spirit distribution.<br>可以查看<a href="../example/fundamental/no_actions.cpp">no_actions.cpp</a>。这是 Spirit发布包的一部分。</p>
 <table border="0">
-  <tr>
+  <tbody><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="directives.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="grammar.html"><img src="theme/r_arr.gif" border="0"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <hr size="1">
-<p class="copyright">Copyright &copy; 1998-2003 Joel de Guzman<br>
+<p class="copyright">Copyright (c) 1998-2003 Joel de Guzman<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>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
-</body>
-</html>
+</body></html>
=======================================
--- /trunk/libs/spirit/classic/doc/semantic_actions.html Tue Mar 31 01:07:16 2009 +++ /trunk/libs/spirit/classic/doc/semantic_actions.html Wed Sep 16 20:25:53 2009
@@ -1,31 +1,29 @@
-<html>
-<head>
-<title>Semantic Actions</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="theme/style.css" type="text/css">
-</head>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+<title>Semantic Actions</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="theme/style.css" type="text/css"></head>
 <body>
-<table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
-  <tr>
+<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
+  <tbody><tr>
     <td width="10">
     </td>
     <td width="85%">
- <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Semantic Actions</b></font> + <font face="Verdana, Arial, Helvetica, sans-serif" size="6"><b>Semantic Actions 语义动作</b></font>
     </td>
- <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" width="112" height="48" align="right" border="0"></a></td> + <td width="112"><a href="http://spirit.sf.net";><img src="theme/spirit.gif" align="right" border="0" height="48" width="112"></a></td>
   </tr>
-</table>
+</tbody></table>
 <br>
 <table border="0">
-  <tr>
+  <tbody><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="subrules.html"><img src="theme/l_arr.gif" border="0"></a></td> <td width="30"><a href="indepth_the_parser.html"><img src="theme/r_arr.gif" border="0"></a></td>
    </tr>
-</table>
-<p>Semantic actions have the form: <b>expression[action]</b></p>
+</tbody></table>
+<p>Semantic actions have the form: <b>expression[action]</b><br>语义动作有 如下格式:<strong>表达式[动作]</strong></p> <p>Ultimately, after having defined our grammar and having generated a corresponding parser, we will need to produce some output and do some work besides syntax analysis; unless, of course, what we want is merely to check for the conformance
@@ -33,47 +31,39 @@
may be attached to any expression at any level within the parser hierarchy. An action is a C/C++ function or function object that will be called if a match is found in the particular context where it is attached. The action function
-  serves as a hook into the parser and may be used to, for example:</p>
+ serves as a hook into the parser and may be used to, for example:<br>总的 来说,在定义了我们的语法并生成相应的分析器之后,我们就需要在语法分析之外产生 某些输出或者其他的工作;当然,除非我们仅仅想验证输入与语法 +的一致性,但是这种情况不大可能。语义动作可以挂接到分析器内任意层次的任意表 达式上。一个动作就是一个在其挂接的特定语境下产生匹配时被调用的C/C++函数或者 函数对象。一个动作函数就像一个钩入分析器内并且可能被使用的钩子。比如:</p>
 <blockquote>
- <p><img src="theme/bullet.gif" width="13" height="13"> Generate output from
-    the parser (ASTs, for example)<br>
- <img src="theme/bullet.gif" width="13" height="13"> Report warnings or errors<br> - <img src="theme/bullet.gif" width="13" height="13"> Manage symbol tables</p> + <p><img src="theme/bullet.gif" height="13" width="13"> Generate output from
+    the parser (ASTs, for example)<br>从分析器产生输出(AST树,比如)<br>
+ <img src="theme/bullet.gif" height="13" width="13"> Report warnings or errors<br>报告警告或者错误<br> + <img src="theme/bullet.gif" height="13" width="13"> Manage symbol tables<br>管理符号表</p>
 </blockquote>
-<h2>Generic Semantic Actions (Transduction Interface)</h2>
+<h2>Generic Semantic Actions (Transduction Interface) 一般的语义动作 (Transduction接口)</h2> <p>A generic semantic action can be any free function or function object that
-  is compatible with the interface:</p>
-<pre><code><font color="#000000"><span class=identifier></span><span class=keyword> void </span><span class=identifier>f</span><span class=special>(</span><span class=identifier>IteratorT </span><span class=identifier>first</span><span class=special>, </span><span class=identifier>IteratorT </span><span class=identifier>last</span><span class=special>);</span></font></code></pre> + is compatible with the interface:<br>一个一般的语义动作可以是与接口兼容的 任意的自由函数或者函数对象:</p> +<pre><code><font color="#000000"><span class="identifier"></span><span class="keyword"> void </span><span class="identifier">f</span><span class="special">(</span><span class="identifier">IteratorT </span><span class="identifier">first</span><span class="special">, </span><span class="identifier">IteratorT </span><span class="identifier">last</span><span class="special">);</span></font></code></pre> <p>where <tt>IteratorT</tt> is the type of iterator used, <tt>first</tt> points to the current input and <tt>last</tt> points to one after the end of the input (identical to STL iterator ranges). A function object (functor) should have
-  a member <tt>operator()</tt> with the same signature as above:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>my_functor
-    </span><span class=special>{
- </span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()(</span><span class=identifier>IteratorT </span><span class=identifier>first</span><span class=special>, </span><span class=identifier>IteratorT </span><span class=identifier>last</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    </span><span class=special>};</span></font></code></pre>
+ a member <tt>operator()</tt> with the same signature as above:<br>其中 <tt>IteratorT</tt><font face="Courier New"> 是所使用的迭代器类 型,</font><tt>first</tt><font face="Courier New"> 指向当前输入而 </font><tt>last</tt><font face="Courier New"> 指向输入终点的后一个位置(与 STL迭代器的区间一致)。函数对象(仿函数)则应有与上面签名一致的 </font><tt>operator()</tt><font face="Courier New"> </font><font face="Courier New">成员函数</font><font face="Courier New">:</font></p> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">my_functor<br> </span><span class="special">{<br> </span><span class="keyword">void </span><span class="keyword">operator</span><span class="special">()(</span><span class="identifier">IteratorT </span><span class="identifier">first</span><span class="special">, </span><span class="identifier">IteratorT </span><span class="identifier">last</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> </span><span class="special">};</span></font></code></pre> <p>Iterators pointing to the matching portion of the input are passed into the
-  function/functor.</p>
+  function/functor.<br>指向输入的迭代器将被传入函数/仿函数</p>
<p>In general, semantic actions accept the first-last iterator pair. This is the transduction interface. The action functions or functors receive the unprocessed data representing the matching production directly from the input. In many cases, this is sufficient. Examples are source to source translation, pre-processing,
-  etc. </p>
-<h3>Example:</h3>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>void - </span><span class=identifier>my_action</span><span class=special>(</span><span class=keyword>char const</span><span class=special>* </span><span class=identifier>first</span><span class=special>, </span><span class=keyword>char const</span><span class=special>* </span><span class=identifier>last</span><span class=special>)
-    {
- </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special> </span><span class="identifier">str</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>); - </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>str </span><span class=special>&lt;&lt; </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;
-    }
-
- </span><span class=identifier>rule</span><span class=special>&lt;&gt; </span><span class=identifier>myrule </span><span class=special>= (</span><span class=identifier>a </span><span class=special>| </span><span class=identifier>b </span><span class=special>| *(</span><span class=identifier>c </span><span class=special>&gt;&gt; </span><span class=identifier>d</span><span class=special>))[&</span><span class=identifier>my_action</span><span class=special>];</span></font></code></pre> + etc.<br>总而言之,语义动作接受 first-last 迭代器对。这是一个 transduction 接口。动作函数或者仿函数直接从输入中接收代表匹配生成式的未处理 的数据。在很多情况下,这已经足够了。比如从代码到代码的翻译、预处理等等。</p>
+<h3>Example: 例子:</h3>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">void<br> </span><span class="identifier">my_action</span><span class="special">(</span><span class="keyword">char const</span><span class="special">* </span><span class="identifier">first</span><span class="special">, </span><span class="keyword">char const</span><span class="special">* </span><span class="identifier">last</span><span class="special">)<br> {<br> </span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special"> </span><span class="identifier">str</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">);<br> </span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="identifier">str </span><span class="special">&lt;&lt; </span><span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;<br> }<br><br> </span><span class="identifier">rule</span><span class="special">&lt;&gt; </span><span class="identifier">myrule </span><span class="special">= (</span><span class="identifier">a </span><span class="special">| </span><span class="identifier">b </span><span class="special">| *(</span><span class="identifier">c </span><span class="special">&gt;&gt; </span><span class="identifier">d</span><span class="special">))[&amp;</span><span class="identifier">my_action</span><span class="special">];</span></font></code></pre> <p>The function <tt>my_action</tt> will be called whenever the expression <tt>(a | b | *(c &gt;&gt; d)</tt> matches a portion of the input stream while parsing. Two iterators, <tt>first</tt> and <tt>last</tt>, are passed into the function. These iterators point to the start and end, respectively, of the portion of
-  input stream where the match is found.</p>
-<h3>Const-ness:</h3>
+ input stream where the match is found.<br>函数 <tt>my_action</tt>&nbsp;在 表达式 <tt>(a + | b | *(c &gt;&gt; d)</tt>&nbsp;匹配输入流中的某一段时将被调用。两个迭代 器 <tt>first</tt> 和 <tt>last</tt> 被分别传入函数,它们指向输入流中匹配的片 段的起点和终点。</p>
+<h3>Const-ness: 不变性:</h3>
<p>With functors, take note that the <tt>operator()</tt> should be <tt>const</tt>. This implies that functors are immutable. One may wish to have some member variables that are modified when the action gets called. This is not a good idea. First
@@ -85,174 +75,108 @@
functor that the client passed in since they are distinct copies. If a functor needs to update some state variables, which is often the case, it is better to use references to external data. The following example shows how this can
-  be done:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>my_functor
-    </span><span class=special>{
- </span><span class=identifier>my_functor</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>str_</span><span class=special>) - </span><span class=special>: </span><span class=identifier>str</span><span class=special>(</span><span class=identifier>str_</span><span class=special>) </span><span class=special>{}
-
-        </span><span class=keyword>void
- </span><span class=keyword>operator</span><span class=special>()(</span><span class=identifier>IteratorT </span><span class=identifier>first</span><span class=special>, </span><span class=identifier>IteratorT </span><span class=identifier>last</span><span class=special>) </span><span class=keyword>const
-        </span><span class=special>{
- </span><span class=identifier>str</span><span class=special>.</span><span class=identifier>assign</span><span class=special>(</span><span class=identifier>first</span><span class=special>, </span><span class=identifier>last</span><span class=special>);
-        </span><span class=special>}
-
- </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>str</span><span class=special>;
-    </span><span class=special>};</span></font></code></pre>
-<h3>Full Example:</h3>
-<p>Here now is our calculator enhanced with semantic actions:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>namespace
-    </span><span class=special>{
- </span><span class=keyword>void </span><span class=identifier>do_int</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>str</span><span class=special>, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>end</span><span class=special>)
-        </span><span class=special>{
- </span><span class=identifier>string </span><span class=identifier>s</span><span class=special>(</span><span class=identifier>str</span><span class=special>, </span><span class=identifier>end</span><span class=special>); - </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"PUSH(" </span><span class=special>&lt;&lt; </span><span class=identifier>s </span><span class=special>&lt;&lt; </span><span class=literal>')' </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
-        </span><span class=special>}
-
- </span><span class=keyword>void </span><span class=identifier>do_add</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*) </span><span class=special>{ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"ADD\n"</span><span class=special>; </span><span class=special>} - </span><span class=keyword>void </span><span class=identifier>do_subt</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*) </span><span class=special>{ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"SUBTRACT\n"</span><span class=special>; </span><span class=special>} - </span><span class=keyword>void </span><span class=identifier>do_mult</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*) </span><span class=special>{ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"MULTIPLY\n"</span><span class=special>; </span><span class=special>} - </span><span class=keyword>void </span><span class=identifier>do_div</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*) </span><span class=special>{ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"DIVIDE\n"</span><span class=special>; </span><span class=special>} - </span><span class=keyword>void </span><span class=identifier>do_neg</span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*, </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*) </span><span class=special>{ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=string>"NEGATE\n"</span><span class=special>; </span><span class=special>}
-    </span><span class=special>}</span></font></code></pre>
-<p>We augment our grammar with semantic actions:</p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>calculator </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>grammar</span><span class=special>&lt;</span><span class=identifier>calculator</span><span class=special>&gt;
-    </span><span class=special>{
- </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>ScannerT</span><span class=special>&gt; - </span><span class=keyword>struct </span><span class=identifier>definition
-        </span><span class=special>{
- </span><span class=identifier>definition</span><span class=special>(</span><span class=identifier>calculator </span><span class=keyword>const</span><span class=special>& </span><span class=identifier>self</span><span class=special>)
-            </span><span class=special>{
-                </span><span class=identifier>expression
- </span><span class=special>= </span><span class=identifier>term - </span><span class=special>&gt;&gt; </span><span class=special>*( </span><span class=special>(</span><span class=literal>'+' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>)[&</span><span class=identifier>do_add</span><span class=special>] - </span><span class=special>| </span><span class=special>(</span><span class=literal>'-' </span><span class=special>&gt;&gt; </span><span class=identifier>term</span><span class=special>)[&</span><span class=identifier>do_subt</span><span class=special>]
-                            </span><span class=special>)
-                    </span><span class=special>;
-
- </span><span class=identifier>term </span><span class=special>=
-                    </span><span class=identifier>factor
- </span><span class=special>&gt;&gt; </span><span class=special>*( </span><span class=special>(</span><span class=literal>'*' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)[&</span><span class=identifier>do_mult</span><span class=special>] - </span><span class=special>| </span><span class=special>(</span><span class=literal>'/' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)[&</span><span class=identifier>do_div</span><span class=special>]
-                            </span><span class=special>)
-                        </span><span class=special>;
-
-                </span><span class=identifier>factor
- </span><span class=special>= </span><span class=identifier>lexeme_d</span><span class=special>[(+</span><span class=identifier>digit_p</span><span class=special>)[&</span><span class=identifier>do_int</span><span class=special>]] - </span><span class=special>| </span><span class=literal>'(' </span><span class=special>&gt;&gt; </span><span class=identifier>expression </span><span class=special>&gt;&gt; </span><span class=literal>')' - </span><span class=special>| </span><span class=special>(</span><span class=literal>'-' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)[&</span><span class=identifier>do_neg</span><span class=special>] - </span><span class=special>| </span><span class=special>(</span><span class=literal>'+' </span><span class=special>&gt;&gt; </span><span class=identifier>factor</span><span class=special>)
-                    </span><span class=special>;
-            </span><span class=special>}
-
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=identifier>expression</span><span class=special>, </span><span class=identifier>term</span><span class=special>, </span><span class=identifier>factor</span><span class=special>;
-
- </span><span class=identifier>rule</span><span class=special>&lt;</span><span class=identifier>ScannerT</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>& - </span><span class=identifier>start</span><span class=special>() </span><span class=keyword>const </span><span class=special>{ </span><span class=keyword>return </span><span class=identifier>expression</span><span class=special>; </span><span class=special>}
-        </span><span class=special>};
-    </span><span class=special>};</span></font></code></pre>
+ be done:<br>使用仿函数时,注意 <tt>operator()</tt>&nbsp;需要声明为 <tt>const</tt>。暗示了仿函数是不可变的。有人也许希望当动作被调用时可以改变某 些成员变量。这不是 +个好主意。首先,仿函数应该是轻量级的。仿函数被反复传递,如果它有沉重的负 载,那将产生大量的额外消耗。其次,仿函数是传值的。因此,真正挂接到分析器 +上的函数对象,肯定不是由客户程序提供的最初的实例。这意味着仿函数状态的改变 无法影响到由客户程序传入的原始的仿函数,因为它们是不同的拷贝。如果一个 +仿函数需要更新某些状态变量,这是很常见的,最好还是引用外部数据。下面的例子 说明了如何做到这点:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">my_functor<br> </span><span class="special">{<br> </span><span class="identifier">my_functor</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp; </span><span class="identifier">str_</span><span class="special">)<br> </span><span class="special">: </span><span class="identifier">str</span><span class="special">(</span><span class="identifier">str_</span><span class="special">) </span><span class="special">{}<br><br> </span><span class="keyword">void<br> </span><span class="keyword">operator</span><span class="special">()(</span><span class="identifier">IteratorT </span><span class="identifier">first</span><span class="special">, </span><span class="identifier">IteratorT </span><span class="identifier">last</span><span class="special">) </span><span class="keyword">const<br> </span><span class="special">{<br> </span><span class="identifier">str</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">first</span><span class="special">, </span><span class="identifier">last</span><span class="special">);<br> </span><span class="special">}<br><br> </span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp; </span><span class="identifier">str</span><span class="special">;<br> </span><span class="special">};</span></font></code></pre>
+<h3>Full Example: 完整的例子:</h3>
+<p>Here now is our calculator enhanced with semantic actions:<br>以下用语义 动作来增强我们的计算器:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">namespace<br> </span><span class="special">{<br> </span><span class="keyword">void </span><span class="identifier">do_int</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">* </span><span class="identifier">str</span><span class="special">, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">* </span><span class="identifier">end</span><span class="special">)<br> </span><span class="special">{<br> </span><span class="identifier">string </span><span class="identifier">s</span><span class="special">(</span><span class="identifier">str</span><span class="special">, </span><span class="identifier">end</span><span class="special">);<br> </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"PUSH(" </span><span class="special">&lt;&lt; </span><span class="identifier">s </span><span class="special">&lt;&lt; </span><span class="literal">')' </span><span class="special">&lt;&lt; </span><span class="identifier">endl</span><span class="special">;<br> </span><span class="special">}<br><br> </span><span class="keyword">void </span><span class="identifier">do_add</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*) </span><span class="special">{ </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"ADD\n"</span><span class="special">; </span><span class="special">}<br> </span><span class="keyword">void </span><span class="identifier">do_subt</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*) </span><span class="special">{ </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"SUBTRACT\n"</span><span class="special">; </span><span class="special">}<br> </span><span class="keyword">void </span><span class="identifier">do_mult</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*) </span><span class="special">{ </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"MULTIPLY\n"</span><span class="special">; </span><span class="special">}<br> </span><span class="keyword">void </span><span class="identifier">do_div</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*) </span><span class="special">{ </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"DIVIDE\n"</span><span class="special">; </span><span class="special">}<br> </span><span class="keyword">void </span><span class="identifier">do_neg</span><span class="special">(</span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*, </span><span class="keyword">char </span><span class="keyword">const</span><span class="special">*) </span><span class="special">{ </span><span class="identifier">cout </span><span class="special">&lt;&lt; </span><span class="string">"NEGATE\n"</span><span class="special">; </span><span class="special">}<br> </span><span class="special">}</span></font></code></pre> +<p>We augment our grammar with semantic actions:<br>我们给我们的语法增加语 义动作:</p> +<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">calculator </span><span class="special">: </span><span class="keyword">public </span><span class="identifier">grammar</span><span class="special">&lt;</span><span class="identifier">calculator</span><span class="special">&gt;<br> </span><span class="special">{<br> </span><span class="keyword">template </span><span class="special">&lt;</span><span class="keyword">typename </span><span class="identifier">ScannerT</span><span class="special">&gt;<br> </span><span class="keyword">struct </span><span class="identifier">definition<br> </span><span class="special">{<br> </span><span class="identifier">definition</span><span class="special">(</span><span class="identifier">calculator </span><span class="keyword">const</span><span class="special">&amp; </span><span class="identifier">self</span><span class="special">)<br> </span><span class="special">{<br> </span><span class="identifier">expression<br> </span><span class="special">= </span><span class="identifier">term<br> </span><span class="special">&gt;&gt; </span><span class="special">*( </span><span class="special">(</span><span class="literal">'+' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">)[&amp;</span><span class="identifier">do_add</span><span class="special">]<br> </span><span class="special">| </span><span class="special">(</span><span class="literal">'-' </span><span class="special">&gt;&gt; </span><span class="identifier">term</span><span class="special">)[&amp;</span><span class="identifier">do_subt</span><span class="special">]<br> </span><span class="special">)<br> </span><span class="special">;<br><br> </span><span class="identifier">term </span><span class="special">=<br> </span><span class="identifier">factor<br> </span><span class="special">&gt;&gt; </span><span class="special">*( </span><span class="special">(</span><span class="literal">'*' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">)[&amp;</span><span class="identifier">do_mult</span><span class="special">]<br> </span><span class="special">| </span><span class="special">(</span><span class="literal">'/' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">)[&amp;</span><span class="identifier">do_div</span><span class="special">]<br> </span><span class="special">)<br> </span><span class="special">;<br><br> </span><span class="identifier">factor<br> </span><span class="special">= </span><span class="identifier">lexeme_d</span><span class="special">[(+</span><span class="identifier">digit_p</span><span class="special">)[&amp;</span><span class="identifier">do_int</span><span class="special">]]<br> </span><span class="special">| </span><span class="literal">'(' </span><span class="special">&gt;&gt; </span><span class="identifier">expression </span><span class="special">&gt;&gt; </span><span class="literal">')'<br> </span><span class="special">| </span><span class="special">(</span><span class="literal">'-' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">)[&amp;</span><span class="identifier">do_neg</span><span class="special">]<br> </span><span class="special">| </span><span class="special">(</span><span class="literal">'+' </span><span class="special">&gt;&gt; </span><span class="identifier">factor</span><span class="special">)<br> </span><span class="special">;<br> </span><span class="special">}<br><br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="identifier">expression</span><span class="special">, </span><span class="identifier">term</span><span class="special">, </span><span class="identifier">factor</span><span class="special">;<br><br> </span><span class="identifier">rule</span><span class="special">&lt;</span><span class="identifier">ScannerT</span><span class="special">&gt; </span><span class="keyword">const</span><span class="special">&amp;<br> </span><span class="identifier">start</span><span class="special">() </span><span class="keyword">const </span><span class="special">{ </span><span class="keyword">return </span><span class="identifier">expression</span><span class="special">; </span><span class="special">}<br> </span><span class="special">};<br> </span><span class="special">};</span></font></code></pre> <p>Feeding in the expression <tt>(-1 + 2) * (3 + -4)</tt>, for example, to the
-  rule <tt>expression</tt> will produce the expected output:</p>
-<pre><code><span class=special>-</span><span class=number>1
-</span><span class=number>2
-</span><span class=identifier>ADD
-</span><span class=number>3
-</span><span class=special>-</span><span class=number>4
-</span><span class=identifier>ADD
-</span><span class=identifier>MULT</span></code></pre>
+ rule <tt>expression</tt> will produce the expected output:<br>比如把表达 式 <tt>(-1 + 2) * (3 + -4)</tt> <font face="Courier New">喂给规则</font> <tt>expression</tt><font face="Courier New">,将产生所预期的输 出:</font></p> +<pre><code><span class="special">-</span><span class="number">1<br></span><span class="number">2<br></span><span class="identifier">ADD<br></span><span class="number">3<br></span><span class="special">-</span><span class="number">4<br></span><span class="identifier">ADD<br></span><span class="identifier">MULT</span></code></pre> <p>which, by the way, is the Reverse Polish Notation (RPN) of the given expression,
-  reminiscent of some primitive calculators and the language Forth.</p>
-<p><img src="theme/lens.gif" width="15" height="16"> <a href="../example/fundamental/calc_plain.cpp">View - the complete source code here</a>. This is part of the Spirit distribution.
-</p>
-<h2><a name="specialized_actions"></a>Specialized Actions</h2>
+ reminiscent of some primitive calculators and the language Forth.<br>此即 上面表达式的逆波兰式(RPN),类似于某些低等计算器或Forth语言。</p> +<p><img src="theme/lens.gif" height="16" width="15"> <a href="../example/fundamental/calc_plain.cpp">View + the complete source code here</a>. This is part of the Spirit distribution.<br><img src="theme/lens.gif" height="16" width="15"><a href="../example/fundamental/calc_plain.cpp">在这里查看完整代码。</a>这是 Spirit发布包的一部分。&nbsp;</p>
+<h2><a name="specialized_actions"></a>Specialized Actions 特殊动作</h2>
<p>In general, semantic actions accept the first-last iterator pair. There are situations though where we might want to pass data in its processed form. A concrete example is the numeric parser. It is unwise to pass unprocessed data to a semantic action attached to a numeric parser and just throw away what has
-  been parsed by the parser. We want to pass the actual parsed number.</p>
+ been parsed by the parser. We want to pass the actual parsed number.<br>一般来说,语义动作接受 first-last 迭代器对。但在某些情况下我们希 望以已被处理的格式传入数据。一个典型的例子就是数值分析器。直接把未处理的数据 传给挂接在数值分析器上的语义动作并扔掉刚刚被分析的数据是不明智的。我们希望传 递解析出的实际数值。</p> <p>The function and functor signature of a semantic action varies depending on the parser where it is attached to. The following table lists the parsers that
-  accept unique signatures.</p>
-<table width="80%" border="0" align="center">
-  <tr>
- <td class="note_box"><img src="theme/note.gif" width="16" height="16"> Unless + accept unique signatures.<br>语义动作的函数和仿函数的签名的变化取决于它被 挂接到哪个分析器上。下面的表格列举了接受一元函数签名的分析器。</p>
+<table align="center" border="0" width="80%">
+  <tbody><tr>
+ <td class="note_box"><img src="theme/note.gif" height="16" width="16"> Unless explicitly stated in the documentation of a specific parser type, parsers not included in the list by default expect the generic signature as explained
-      above.</td>
+ above.<p>除非文档中明确指出的分析器类型,否则文档所不包含的分析器都接 受上面所说的一般形式的签名。</p></td>
   </tr>
-</table>
-<h3>Numeric Actions</h3>
-<p><b>Applies to:</b></p>
+</tbody></table>
+<h3>Numeric Actions 数值动作</h3>
+<p><b>Applies to: 对应于:</b></p>
 <blockquote>
-  <p><img src="theme/bullet.gif" width="13" height="13"> uint_p<br>
-    <img src="theme/bullet.gif" width="13" height="13"> int_p<br>
-    <img src="theme/bullet.gif" width="13" height="13"> ureal_p<br>
-    <img src="theme/bullet.gif" width="13" height="13"> real_p</p>
+  <p><img src="theme/bullet.gif" height="13" width="13"> uint_p<br>
+    <img src="theme/bullet.gif" height="13" width="13"> int_p<br>
+    <img src="theme/bullet.gif" height="13" width="13"> ureal_p<br>
+    <img src="theme/bullet.gif" height="13" width="13"> real_p</p>
 </blockquote>
-<p><b>Signature for functions:</b></p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>void </span><span class=identifier>func</span><span class=special>(</span><span class=identifier>NumT </span><span class=identifier>val</span><span class=special>);</span></font></code></pre>
-<p><b>Signature for functors:</b> </p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>ftor
-    </span><span class=special>{
- </span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()(</span><span class=identifier>NumT </span><span class=identifier>val</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    </span><span class=special>};</span></font></code></pre>
+<p><b>Signature for functions: 函数的签名:</b></p>
+<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">void </span><span class="identifier">func</span><span class="special">(</span><span class="identifier">NumT </span><span class="identifier">val</span><span class="special">);</span></font></code></pre>
+<p><b>Signature for functors: 仿函数的签名:</b> </p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">ftor<br> </span><span class="special">{<br> </span><span class="keyword">void </span><span class="keyword">operator</span><span class="special">()(</span><span class="identifier">NumT </span><span class="identifier">val</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> </span><span class="special">};</span></font></code></pre> <p>Where <tt>NumT</tt> is any primitive numeric type such as <tt>int</tt>, <tt>long</tt>, <tt>float</tt>, <tt>double</tt>, etc., or a user defined numeric type such as big_int. <tt>NumT</tt> is the same type used as template parameter to <tt>uint_p</tt>, <tt>int_p</tt>, <tt>ureal_p</tt> or <tt>real_p</tt>. The parsed number is passed
-  into the function/functor.</p>
-<h3>Character Actions</h3>
-<p><b>Applies to:</b></p>
+ into the function/functor.<br>其中&nbsp;<tt>NumT</tt>&nbsp;是任意基本的数 值类型,如 <tt>int</tt>, <tt>long</tt>,
+  <tt>float</tt>, <tt>double</tt> 等等,或者用户定义的数据类型,如
+  big_int。<tt>NumT</tt> 与 <tt>uint_p</tt>,
+ <tt>int_p</tt>, <tt>ureal_p</tt> 或 <tt>real_p</tt> 所使用的模板参数的类 型相同。被解析出的数字将被传入函数/仿函数。</p>
+<h3>Character Actions 字符动作</h3>
+<p><b>Applies to: 对应于:</b></p>
 <blockquote>
-  <p><img src="theme/bullet.gif" width="13" height="13"> chlit, ch_p<br>
-    <img src="theme/bullet.gif" width="13" height="13"> range, range_p<br>
-    <img src="theme/bullet.gif" width="13" height="13"> anychar<br>
-    <img src="theme/bullet.gif" width="13" height="13"> alnum, alpha<br>
-    <img src="theme/bullet.gif" width="13" height="13"> cntrl, digit<br>
-    <img src="theme/bullet.gif" width="13" height="13"> graph, lower<br>
-    <img src="theme/bullet.gif" width="13" height="13"> print, punct<br>
-    <img src="theme/bullet.gif" width="13" height="13"> space, upper<br>
-    <img src="theme/bullet.gif" width="13" height="13"> xdigit</p>
+  <p><img src="theme/bullet.gif" height="13" width="13"> chlit, ch_p<br>
+    <img src="theme/bullet.gif" height="13" width="13"> range, range_p<br>
+    <img src="theme/bullet.gif" height="13" width="13"> anychar<br>
+    <img src="theme/bullet.gif" height="13" width="13"> alnum, alpha<br>
+    <img src="theme/bullet.gif" height="13" width="13"> cntrl, digit<br>
+    <img src="theme/bullet.gif" height="13" width="13"> graph, lower<br>
+    <img src="theme/bullet.gif" height="13" width="13"> print, punct<br>
+    <img src="theme/bullet.gif" height="13" width="13"> space, upper<br>
+    <img src="theme/bullet.gif" height="13" width="13"> xdigit</p>
 </blockquote>
-<p><b>Signature for functions:</b></p>
-<pre><code><font color="#000000"><span class=identifier> </span><span class=keyword>void </span><span class=identifier>func</span><span class=special>(</span><span class=identifier>CharT </span><span class=identifier>ch</span><span class=special>);</span></font></code></pre>
-<p><b>Signature for functors:</b></p>
-<pre><code><font color="#000000"><span class=special> </span><span class=keyword>struct </span><span class=identifier>ftor
-    </span><span class=special>{
- </span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()(</span><span class=identifier>CharT </span><span class=identifier>ch</span><span class=special>) </span><span class=keyword>const</span><span class=special>;
-    </span><span class=special>};</span></font></code></pre>
+<p><b>Signature for functions: 函数的签名:</b></p>
+<pre><code><font color="#000000"><span class="identifier"> </span><span class="keyword">void </span><span class="identifier">func</span><span class="special">(</span><span class="identifier">CharT </span><span class="identifier">ch</span><span class="special">);</span></font></code></pre>
+<p><b>Signature for functors: 仿函数的签名:</b></p>
+<pre><code><font color="#000000"><span class="special"> </span><span class="keyword">struct </span><span class="identifier">ftor<br> </span><span class="special">{<br> </span><span class="keyword">void </span><span class="keyword">operator</span><span class="special">()(</span><span class="identifier">CharT </span><span class="identifier">ch</span><span class="special">) </span><span class="keyword">const</span><span class="special">;<br> </span><span class="special">};</span></font></code></pre> <p>Where <tt>CharT</tt> is the value_type of the iterator used in parsing. A <tt>char const*</tt> iterator for example has a <tt>value_type</tt> of <tt>char</tt>.