diff --git a/404.html b/404.html index 28823e44a..433a2478d 100644 --- a/404.html +++ b/404.html @@ -31,10 +31,10 @@ } - + -

404

页面不存在

这里什么也没有

- +

404

页面不存在

看起来你访问了一个失效的链接

+ diff --git a/article/index.html b/article/index.html index f72a3c59c..ffc3300f5 100644 --- a/article/index.html +++ b/article/index.html @@ -31,10 +31,13 @@ } - + -
vscode+qemu开发Linux内核

参考于QEMU调试Linux内核环境搭建

+
Chapter0 前言

前言

+# ./scripts/config --file .config -e CONFIG_NUMA_BALANCE CONFIG_NUMA_BALANCING_DEFAULT_ENABLED CONFIG_NUMA +# Todo 还有一些nuuma_balance相关设置项要打开,不然后面要在编译时手动选择Y +

ChiChen大约 2 分钟笔记Linux 内核Linux 内核开发环境
Chapter0 前言

前言

写给华工软院学生

  1. 2021级编译原理考试难度较低,复习优先级低,不建议花太多时间准备。虽然根据老师不同(以徐老师为例),可能上课的内容比较深入,让学生产生了这门科目难度很大的错觉。诚然要彻底理解编译原理需要花费大量的时间,但考试内容基本都是简单的算法,只要把几个重要算法理解了,都不需要把每个概念搞的非常清楚,考试都基本不会出问题。
  2. @@ -107,16 +112,7 @@

    初步分析


ChiChen大约 7 分钟杂谈Debug杂谈General ProtectionDebug
NUMA Balancing

numa_balancing in kernel doc

-

Enables/disables automatic page fault based NUMA memory -balancing. Memory is moved automatically to nodes -that access it often.

-

Enables/disables automatic NUMA memory balancing. On NUMA machines, there -is a performance penalty if remote memory is accessed by a CPU. When this -feature is enabled the kernel samples what task thread is accessing memory -by periodically unmapping pages and later trapping a page fault. At the -time of the page fault, it is determined if the data being accessed should -be migrated to a local memory node.


ChiChen大约 2 分钟笔记Linux 内核Linux 内核NUMA
2
- +
ChiChen大约 2 分钟杂谈网络问题Debug网络问题
2
+ diff --git a/assets/404.html-e490506a.js b/assets/404.html-ac6ecd4a.js similarity index 71% rename from assets/404.html-e490506a.js rename to assets/404.html-ac6ecd4a.js index 4627a0675..ee1cde30f 100644 --- a/assets/404.html-e490506a.js +++ b/assets/404.html-ac6ecd4a.js @@ -1 +1 @@ -import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as t,c}from"./app-75cd46e5.js";const o={};function r(_,n){return t(),c("div")}const f=e(o,[["render",r],["__file","404.html.vue"]]);export{f as default}; +import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as t,c}from"./app-9d555359.js";const o={};function r(_,n){return t(),c("div")}const f=e(o,[["render",r],["__file","404.html.vue"]]);export{f as default}; diff --git "a/assets/Chapter0 \345\211\215\350\250\200.html-064c4e9e.js" "b/assets/Chapter0 \345\211\215\350\250\200.html-f44b1c84.js" similarity index 97% rename from "assets/Chapter0 \345\211\215\350\250\200.html-064c4e9e.js" rename to "assets/Chapter0 \345\211\215\350\250\200.html-f44b1c84.js" index a40ce1f70..35015c2ad 100644 --- "a/assets/Chapter0 \345\211\215\350\250\200.html-064c4e9e.js" +++ "b/assets/Chapter0 \345\211\215\350\250\200.html-f44b1c84.js" @@ -1 +1 @@ -import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as a,c as r,e as o}from"./app-75cd46e5.js";const i={},c=o('

前言

写给华工软院学生

  1. 2021级编译原理考试难度较低,复习优先级低,不建议花太多时间准备。虽然根据老师不同(以徐老师为例),可能上课的内容比较深入,让学生产生了这门科目难度很大的错觉。诚然要彻底理解编译原理需要花费大量的时间,但考试内容基本都是简单的算法,只要把几个重要算法理解了,都不需要把每个概念搞的非常清楚,考试都基本不会出问题。
  2. 编译原理博大精深,作为计算机底层设计的一部分,课堂上教授的内容少之又少,甚至可以说和一些工程实践是严重脱钩的,比如上课会花很大的精力教你自动机和自动机的相关算法,但是在实际工程运用中,我们有诸如 lexer 的工具帮我们完成这个工作,而且如果是编写一个简单的词法分析器,甚至只需要简单的 最长字串匹配 就能实现一个词法分析。仅凭课堂上学的内容,大概率连怎么写一个 TinyC(精简版的C语言) 都不知道。感兴趣的同学可以认真钻研一番,这对编程能力会有极大的提高。

写给全体

1.本系列笔记是对自己大学生活的记录,不保证能记录下所有知识点,仅供同学们学习参考。 2.参考书籍为龙书第二版 (Compilers: Principles,Techniques,and Tools 译名:编译原理 Alfred V. Aho / Monica S. Lam / Ravi Sethi / Jeffrey D. Ullman等著)

',5),d=[c];function t(h,n){return a(),r("div",null,d)}const _=e(i,[["render",t],["__file","Chapter0 前言.html.vue"]]);export{_ as default}; +import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as a,c as r,e as o}from"./app-9d555359.js";const i={},c=o('

前言

写给华工软院学生

  1. 2021级编译原理考试难度较低,复习优先级低,不建议花太多时间准备。虽然根据老师不同(以徐老师为例),可能上课的内容比较深入,让学生产生了这门科目难度很大的错觉。诚然要彻底理解编译原理需要花费大量的时间,但考试内容基本都是简单的算法,只要把几个重要算法理解了,都不需要把每个概念搞的非常清楚,考试都基本不会出问题。
  2. 编译原理博大精深,作为计算机底层设计的一部分,课堂上教授的内容少之又少,甚至可以说和一些工程实践是严重脱钩的,比如上课会花很大的精力教你自动机和自动机的相关算法,但是在实际工程运用中,我们有诸如 lexer 的工具帮我们完成这个工作,而且如果是编写一个简单的词法分析器,甚至只需要简单的 最长字串匹配 就能实现一个词法分析。仅凭课堂上学的内容,大概率连怎么写一个 TinyC(精简版的C语言) 都不知道。感兴趣的同学可以认真钻研一番,这对编程能力会有极大的提高。

写给全体

1.本系列笔记是对自己大学生活的记录,不保证能记录下所有知识点,仅供同学们学习参考。 2.参考书籍为龙书第二版 (Compilers: Principles,Techniques,and Tools 译名:编译原理 Alfred V. Aho / Monica S. Lam / Ravi Sethi / Jeffrey D. Ullman等著)

',5),d=[c];function t(h,n){return a(),r("div",null,d)}const _=e(i,[["render",t],["__file","Chapter0 前言.html.vue"]]);export{_ as default}; diff --git "a/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-5882819b.js" "b/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c19f2788.js" similarity index 99% rename from "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-5882819b.js" rename to "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c19f2788.js" index eb9e78702..2f202ec36 100644 --- "a/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-5882819b.js" +++ "b/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c19f2788.js" @@ -1 +1 @@ -import{_ as s}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as m,e as l,a,b as t}from"./app-75cd46e5.js";const e={},r=l('

Chapter1 编译器组成

编译器的结构

相关信息

以上三步的目的是通过分析输入代码,生成能被统一处理的中间层代码,亦即编译器前端(front-end)

',5),i=a("p",{class:"katex-block"},[a("span",{class:"katex-display"},[a("span",{class:"katex"},[a("span",{class:"katex-mathml"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("semantics",null,[a("mrow",null,[a("mi",null,"C"),a("mo",{stretchy:"false"},"("),a("mtext",null,"源代码"),a("mo",{stretchy:"false"},")"),a("mo",null,"→"),a("mi",null,"T"),a("mi",null,"A"),a("mi",null,"C"),a("mo",{stretchy:"false"},"("),a("mi",null,"T"),a("mi",null,"h"),a("mi",null,"r"),a("mi",null,"e"),a("mi",null,"e"),a("mi",null,"A"),a("mi",null,"d"),a("mi",null,"d"),a("mi",null,"r"),a("mi",null,"e"),a("mi",null,"s"),a("mi",null,"s"),a("mi",null,"C"),a("mi",null,"o"),a("mi",null,"d"),a("mi",null,"e"),a("mo",{stretchy:"false"},")"),a("mtext",null,"中间("),a("mi",null,"i"),a("mi",null,"n"),a("mi",null,"t"),a("mi",null,"e"),a("mi",null,"r"),a("mi",null,"m"),a("mi",null,"e"),a("mi",null,"d"),a("mi",null,"i"),a("mi",null,"a"),a("mi",null,"t"),a("mi",null,"e"),a("mtext",null,")码"),a("mo",null,"→"),a("mtext",null,"机器码")]),a("annotation",{encoding:"application/x-tex"}," C(源代码)\\rightarrow TAC(Three Address Code)中间(intermediate)码\\rightarrow 机器码 ")])])]),a("span",{class:"katex-html","aria-hidden":"true"},[a("span",{class:"base"},[a("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mopen"},"("),a("span",{class:"mord cjk_fallback"},"源代码"),a("span",{class:"mclose"},")"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mrel"},"→"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),a("span",{class:"base"},[a("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord mathnormal"},"A"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mopen"},"("),a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord mathnormal"},"h"),a("span",{class:"mord mathnormal"},"ree"),a("span",{class:"mord mathnormal"},"A"),a("span",{class:"mord mathnormal"},"dd"),a("span",{class:"mord mathnormal"},"ress"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mord mathnormal"},"o"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mclose"},")"),a("span",{class:"mord cjk_fallback"},"中间("),a("span",{class:"mord mathnormal"},"in"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),a("span",{class:"mord mathnormal"},"m"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"ia"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord cjk_fallback"},")码"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mrel"},"→"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),a("span",{class:"base"},[a("span",{class:"strut",style:{height:"0.6833em"}}),a("span",{class:"mord cjk_fallback"},"机器码")])])])])],-1),c=a("h3",{id:"词法分析",tabindex:"-1"},[a("a",{class:"header-anchor",href:"#词法分析","aria-hidden":"true"},"#"),t(" 词法分析")],-1),o=a("ul",null,[a("li",null,[a("p",null,"本质上就是为了输出一个合法的token序列,每个token就是一个关键词或者一个关键词+词素(lexeme)的组合如"),a("p",{class:"katex-block"},[a("span",{class:"katex-display"},[a("span",{class:"katex"},[a("span",{class:"katex-mathml"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("semantics",null,[a("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[a("mtr",null,[a("mtd",null,[a("mstyle",{scriptlevel:"0",displaystyle:"false"},[a("mrow",null,[a("mi",null,"T"),a("mi",{mathvariant:"normal"},"_"),a("mi",null,"W"),a("mi",null,"h"),a("mi",null,"i"),a("mi",null,"l"),a("mi",null,"e"),a("mspace",{width:"1em"}),a("mtext",null,"关键词")])])])]),a("mtr",null,[a("mtd",null,[a("mstyle",{scriptlevel:"0",displaystyle:"false"},[a("mrow",null,[a("mi",null,"T"),a("mi",{mathvariant:"normal"},"_"),a("mi",null,"I"),a("mi",null,"d"),a("mi",null,"e"),a("mi",null,"n"),a("mi",null,"t"),a("mi",null,"i"),a("mi",null,"f"),a("mi",null,"i"),a("mi",null,"e"),a("mi",null,"r"),a("mtext",null,"  "),a("mtext",null,"  "),a("mi",null,"x"),a("mspace",{width:"1em"}),a("mtext",null,"关键词"),a("mo",null,"+"),a("mtext",null,"词素")])])])])]),a("annotation",{encoding:"application/x-tex"}," \\begin{array}{c}T\\_While\\quad 关键词\\\\ T\\_Identifier \\;\\;x \\quad 关键词+词素\\end{array} ")])])]),a("span",{class:"katex-html","aria-hidden":"true"},[a("span",{class:"base"},[a("span",{class:"strut",style:{height:"2.4em","vertical-align":"-0.95em"}}),a("span",{class:"mord"},[a("span",{class:"mtable"},[a("span",{class:"arraycolsep",style:{width:"0.5em"}}),a("span",{class:"col-align-c"},[a("span",{class:"vlist-t vlist-t2"},[a("span",{class:"vlist-r"},[a("span",{class:"vlist",style:{height:"1.45em"}},[a("span",{style:{top:"-3.61em"}},[a("span",{class:"pstrut",style:{height:"3em"}}),a("span",{class:"mord"},[a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),a("span",{class:"mord mathnormal"},"Whi"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mspace",style:{"margin-right":"1em"}}),a("span",{class:"mord cjk_fallback"},"关键词")])]),a("span",{style:{top:"-2.41em"}},[a("span",{class:"pstrut",style:{height:"3em"}}),a("span",{class:"mord"},[a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord mathnormal"},"n"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal"},"i"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),a("span",{class:"mord mathnormal"},"i"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mord mathnormal"},"x"),a("span",{class:"mspace",style:{"margin-right":"1em"}}),a("span",{class:"mord cjk_fallback"},"关键词"),a("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),a("span",{class:"mbin"},"+"),a("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),a("span",{class:"mord cjk_fallback"},"词素")])])]),a("span",{class:"vlist-s"},"​")]),a("span",{class:"vlist-r"},[a("span",{class:"vlist",style:{height:"0.95em"}},[a("span")])])])]),a("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])])])],-1),h=l('

语法分析

语义分析

中间代码生成

',6),p=[r,i,c,o,h];function d(u,g){return n(),m("div",null,p)}const x=s(e,[["render",d],["__file","Chapter1 编译器组成.html.vue"]]);export{x as default}; +import{_ as s}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as m,e as l,a,b as t}from"./app-9d555359.js";const e={},r=l('

Chapter1 编译器组成

编译器的结构

相关信息

以上三步的目的是通过分析输入代码,生成能被统一处理的中间层代码,亦即编译器前端(front-end)

',5),i=a("p",{class:"katex-block"},[a("span",{class:"katex-display"},[a("span",{class:"katex"},[a("span",{class:"katex-mathml"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("semantics",null,[a("mrow",null,[a("mi",null,"C"),a("mo",{stretchy:"false"},"("),a("mtext",null,"源代码"),a("mo",{stretchy:"false"},")"),a("mo",null,"→"),a("mi",null,"T"),a("mi",null,"A"),a("mi",null,"C"),a("mo",{stretchy:"false"},"("),a("mi",null,"T"),a("mi",null,"h"),a("mi",null,"r"),a("mi",null,"e"),a("mi",null,"e"),a("mi",null,"A"),a("mi",null,"d"),a("mi",null,"d"),a("mi",null,"r"),a("mi",null,"e"),a("mi",null,"s"),a("mi",null,"s"),a("mi",null,"C"),a("mi",null,"o"),a("mi",null,"d"),a("mi",null,"e"),a("mo",{stretchy:"false"},")"),a("mtext",null,"中间("),a("mi",null,"i"),a("mi",null,"n"),a("mi",null,"t"),a("mi",null,"e"),a("mi",null,"r"),a("mi",null,"m"),a("mi",null,"e"),a("mi",null,"d"),a("mi",null,"i"),a("mi",null,"a"),a("mi",null,"t"),a("mi",null,"e"),a("mtext",null,")码"),a("mo",null,"→"),a("mtext",null,"机器码")]),a("annotation",{encoding:"application/x-tex"}," C(源代码)\\rightarrow TAC(Three Address Code)中间(intermediate)码\\rightarrow 机器码 ")])])]),a("span",{class:"katex-html","aria-hidden":"true"},[a("span",{class:"base"},[a("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mopen"},"("),a("span",{class:"mord cjk_fallback"},"源代码"),a("span",{class:"mclose"},")"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mrel"},"→"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),a("span",{class:"base"},[a("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord mathnormal"},"A"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mopen"},"("),a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord mathnormal"},"h"),a("span",{class:"mord mathnormal"},"ree"),a("span",{class:"mord mathnormal"},"A"),a("span",{class:"mord mathnormal"},"dd"),a("span",{class:"mord mathnormal"},"ress"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),a("span",{class:"mord mathnormal"},"o"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mclose"},")"),a("span",{class:"mord cjk_fallback"},"中间("),a("span",{class:"mord mathnormal"},"in"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),a("span",{class:"mord mathnormal"},"m"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"ia"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord cjk_fallback"},")码"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mrel"},"→"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),a("span",{class:"base"},[a("span",{class:"strut",style:{height:"0.6833em"}}),a("span",{class:"mord cjk_fallback"},"机器码")])])])])],-1),c=a("h3",{id:"词法分析",tabindex:"-1"},[a("a",{class:"header-anchor",href:"#词法分析","aria-hidden":"true"},"#"),t(" 词法分析")],-1),o=a("ul",null,[a("li",null,[a("p",null,"本质上就是为了输出一个合法的token序列,每个token就是一个关键词或者一个关键词+词素(lexeme)的组合如"),a("p",{class:"katex-block"},[a("span",{class:"katex-display"},[a("span",{class:"katex"},[a("span",{class:"katex-mathml"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("semantics",null,[a("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[a("mtr",null,[a("mtd",null,[a("mstyle",{scriptlevel:"0",displaystyle:"false"},[a("mrow",null,[a("mi",null,"T"),a("mi",{mathvariant:"normal"},"_"),a("mi",null,"W"),a("mi",null,"h"),a("mi",null,"i"),a("mi",null,"l"),a("mi",null,"e"),a("mspace",{width:"1em"}),a("mtext",null,"关键词")])])])]),a("mtr",null,[a("mtd",null,[a("mstyle",{scriptlevel:"0",displaystyle:"false"},[a("mrow",null,[a("mi",null,"T"),a("mi",{mathvariant:"normal"},"_"),a("mi",null,"I"),a("mi",null,"d"),a("mi",null,"e"),a("mi",null,"n"),a("mi",null,"t"),a("mi",null,"i"),a("mi",null,"f"),a("mi",null,"i"),a("mi",null,"e"),a("mi",null,"r"),a("mtext",null,"  "),a("mtext",null,"  "),a("mi",null,"x"),a("mspace",{width:"1em"}),a("mtext",null,"关键词"),a("mo",null,"+"),a("mtext",null,"词素")])])])])]),a("annotation",{encoding:"application/x-tex"}," \\begin{array}{c}T\\_While\\quad 关键词\\\\ T\\_Identifier \\;\\;x \\quad 关键词+词素\\end{array} ")])])]),a("span",{class:"katex-html","aria-hidden":"true"},[a("span",{class:"base"},[a("span",{class:"strut",style:{height:"2.4em","vertical-align":"-0.95em"}}),a("span",{class:"mord"},[a("span",{class:"mtable"},[a("span",{class:"arraycolsep",style:{width:"0.5em"}}),a("span",{class:"col-align-c"},[a("span",{class:"vlist-t vlist-t2"},[a("span",{class:"vlist-r"},[a("span",{class:"vlist",style:{height:"1.45em"}},[a("span",{style:{top:"-3.61em"}},[a("span",{class:"pstrut",style:{height:"3em"}}),a("span",{class:"mord"},[a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),a("span",{class:"mord mathnormal"},"Whi"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mspace",style:{"margin-right":"1em"}}),a("span",{class:"mord cjk_fallback"},"关键词")])]),a("span",{style:{top:"-2.41em"}},[a("span",{class:"pstrut",style:{height:"3em"}}),a("span",{class:"mord"},[a("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),a("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),a("span",{class:"mord mathnormal"},"d"),a("span",{class:"mord mathnormal"},"e"),a("span",{class:"mord mathnormal"},"n"),a("span",{class:"mord mathnormal"},"t"),a("span",{class:"mord mathnormal"},"i"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),a("span",{class:"mord mathnormal"},"i"),a("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),a("span",{class:"mord mathnormal"},"x"),a("span",{class:"mspace",style:{"margin-right":"1em"}}),a("span",{class:"mord cjk_fallback"},"关键词"),a("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),a("span",{class:"mbin"},"+"),a("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),a("span",{class:"mord cjk_fallback"},"词素")])])]),a("span",{class:"vlist-s"},"​")]),a("span",{class:"vlist-r"},[a("span",{class:"vlist",style:{height:"0.95em"}},[a("span")])])])]),a("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])])])],-1),h=l('

语法分析

语义分析

中间代码生成

',6),p=[r,i,c,o,h];function d(u,g){return n(),m("div",null,p)}const x=s(e,[["render",d],["__file","Chapter1 编译器组成.html.vue"]]);export{x as default}; diff --git "a/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-120fdf7e.js" "b/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-08fda3b0.js" similarity index 99% rename from "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-120fdf7e.js" rename to "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-08fda3b0.js" index cb671fa34..53e3c5b37 100644 --- "a/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-120fdf7e.js" +++ "b/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-08fda3b0.js" @@ -1,4 +1,4 @@ -import{_ as n}from"./plugin-vue_export-helper-c27b6911.js";import{o as t,c as m,e as l,a as s,b as a}from"./app-75cd46e5.js";const e="/assets/扫描过程图示-1ef4577e.png",i="/assets/子表达式NFA1-e7c719e6.png",r="/assets/子表达式NFA3-eeac5f40.png",p="/assets/子表达式NFA4-59718514.png",c="/assets/子表达式NFA5-8c2b68d5.png",o="/assets/NFA2DFA-d0082836.png",h="/assets/NFA2DFA2-8f2b7a6a.png",u="/assets/最小化DFA-9d6f7d13.png",g={},d=l(`

Chapter2 词法分析

大纲

扫描过程

 while(137<n) 
+import{_ as n}from"./plugin-vue_export-helper-c27b6911.js";import{o as t,c as m,e as l,a as s,b as a}from"./app-9d555359.js";const e="/assets/扫描过程图示-1ef4577e.png",i="/assets/子表达式NFA1-e7c719e6.png",r="/assets/子表达式NFA3-eeac5f40.png",p="/assets/子表达式NFA4-59718514.png",c="/assets/子表达式NFA5-8c2b68d5.png",o="/assets/NFA2DFA-d0082836.png",h="/assets/NFA2DFA2-8f2b7a6a.png",u="/assets/最小化DFA-9d6f7d13.png",g={},d=l(`

Chapter2 词法分析

大纲

  • 扫描过程 Scanning Process
  • 正则表达式 Regular Expressions
  • 有限自动机 Finite Automata(NFA(nondeterministic 非确定性有限自动机) and DFA(deterministic 确定性))
  • RE转换NFA(McNaughton-Yamda-Thompson algorithm)
  • NFA 转换DFA(子集算法 Subset construction Algorithm)
  • 最小化DFA(State-Minimization Algorithm)

扫描过程

 while(137<n) 
   ++i;
 
`,5),y=s("p",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"→"),s("mi",null,"T"),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"w"),s("mi",null,"h"),s("mi",null,"i"),s("mi",null,"l"),s("mi",null,"e"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mo",null,"→"),s("mi",null,"T"),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"I"),s("mi",null,"n"),s("mi",null,"t"),s("mi",null,"C"),s("mi",null,"o"),s("mi",null,"n"),s("mi",null,"s"),s("mi",null,"t"),s("mo",null,"+"),s("mn",null,"137"),s("mo",null,"→"),s("mo",null,"<"),s("mo",{separator:"true"},"⋅"),s("mo",{separator:"true"},"⋅"),s("mo",{separator:"true"},"⋅"),s("mo",{separator:"true"},"⋅"),s("mo",{separator:"true"},"⋅")]),s("annotation",{encoding:"application/x-tex"},"\\rightarrow T\\_while \\rightarrow( \\rightarrow T\\_IntConst+137\\rightarrow<·····")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.3669em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0044em","vertical-align":"-0.31em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02691em"}},"w"),s("span",{class:"mord mathnormal"},"hi"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9933em","vertical-align":"-0.31em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"tC"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6835em","vertical-align":"-0.0391em"}}),s("span",{class:"mord"},"137"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→<")]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4445em"}}),s("span",{class:"mpunct"},"⋅⋅⋅⋅⋅")])])])],-1),v=s("figure",null,[s("img",{src:e,alt:"扫描过程图示",tabindex:"0",loading:"lazy"}),s("figcaption",null,"扫描过程图示")],-1),x=s("h3",{id:"词元-tokens",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#词元-tokens","aria-hidden":"true"},"#"),a(" 词元(tokens)")],-1),b=s("ul",null,[s("li",null,[a("一个token表示源代码中的一个逻辑语义片段,可以是一个关键字、一个变量名,以"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"<"),s("mi",null,"t"),s("mi",null,"o"),s("mi",null,"k"),s("mi",null,"e"),s("mi",null,"n"),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"t"),s("mi",null,"y"),s("mi",null,"p"),s("mi",null,"e"),s("mo",{separator:"true"},","),s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"e"),s("mi",null,"m"),s("mi",null,"e"),s("mo",null,">")]),s("annotation",{encoding:"application/x-tex"},"")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mrel"},"<"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0044em","vertical-align":"-0.31em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03148em"}},"k"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"y"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">")])])]),a("表示")]),s("li",null,"token表示一组符合特定规则的字符,例如标识符必须以字母开头并只包含字母和数字"),s("li",null,[a("每个token关联一个词素(lexeme) "),s("ul",null,[s("li",null,"lexeme即为token的字面值,如“137”,”int“等")])]),s("li",null,[a("每个token可能有属性(attributes) "),s("ul",null,[s("li",null,[a("从字面值中得到的额外信息,一般是一个数值,如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mn",null,"137"),s("mo",null,"→"),s("mo",null,"<"),s("mi",null,"T"),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"I"),s("mi",null,"n"),s("mi",null,"t"),s("mi",null,"C"),s("mi",null,"o"),s("mi",null,"n"),s("mi",null,"s"),s("mi",null,"t"),s("mo",{separator:"true"},","),s("mn",null,"137"),s("mo",null,">")]),s("annotation",{encoding:"application/x-tex"},"137\\rightarrow ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6835em","vertical-align":"-0.0391em"}}),s("span",{class:"mord"},"137"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→<"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9933em","vertical-align":"-0.31em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"tC"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"137"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">")])])])])])])],-1),k=l('

正则表达式

形式化语言

字符表(alphabet)

',3),w=s("ul",null,[s("li",null,[s("p",null,"是指一个由符号(字符、数字、特殊符号)组成的有限集,例如"),s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mo",null,"∑"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{stretchy:"false"},"}"),s("mo",{separator:"true"},","),s("mi",null,"A"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mo",{separator:"true"},","),s("mi",null,"b"),s("mo",{separator:"true"},","),s("mi",null,"c"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"}," \\sum=\\{0,1\\},A=\\{a,b,c\\} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.6em","vertical-align":"-0.55em"}}),s("span",{class:"mop op-symbol large-op",style:{position:"relative",top:"0em"}},"∑"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mclose"},"}"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mclose"},"}")])])])])])])],-1),f=s("h4",{id:"字符串-string",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#字符串-string","aria-hidden":"true"},"#"),a(" 字符串(string)")],-1),M=s("ul",null,[s("li",null,"一个基于某个字符表的字符串是一个由字符表中给出的符号组成的有穷序列"),s("li",null,[a("特殊的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a(" 表示一个空串,但不等价于空集")]),s("li",null,[a("例如 "),s("ul",null,[s("li",null,[a("0,00,10是"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"∑"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"},"\\sum=\\{0,1\\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"∑"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mclose"},"}")])])]),a("的字符串")]),s("li",null,[a("a,ab,aaca是"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mo",{separator:"true"},","),s("mi",null,"b"),s("mo",{separator:"true"},","),s("mi",null,"c"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"},"A=\\{a,b,c\\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mclose"},"}")])])]),a("的字符串")])])])],-1),_=s("h4",{id:"语言-language",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#语言-language","aria-hidden":"true"},"#"),a(" 语言(language)")],-1),z=s("ul",null,[s("li",null,"由基于某一给定的字符表的一系列字符串组成的集合"),s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"{"),s("mi",null,"ε"),s("mo",{stretchy:"false"},"}"),s("mtext",null,"和空集"),s("mi",{mathvariant:"normal"},"Φ")]),s("annotation",{encoding:"application/x-tex"},"\\{\\varepsilon\\}和空集\\Phi")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mclose"},"}"),s("span",{class:"mord cjk_fallback"},"和空集"),s("span",{class:"mord"},"Φ")])])]),a(" 都是语言")])],-1),L=s("h5",{id:"语言的运算",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#语言的运算","aria-hidden":"true"},"#"),a(" 语言的运算")],-1),A=s("table",null,[s("thead",null,[s("tr",null,[s("th",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"O"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"t"),s("mi",null,"i"),s("mi",null,"o"),s("mi",null,"n")]),s("annotation",{encoding:"application/x-tex"},"Operation")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal"},"Op"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n")])])])]),s("th",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"D"),s("mi",null,"e"),s("mi",null,"f"),s("mi",null,"i"),s("mi",null,"n"),s("mi",null,"i"),s("mi",null,"t"),s("mi",null,"i"),s("mi",null,"o"),s("mi",null,"n"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"A"),s("mi",null,"n"),s("mi",null,"d"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"n"),s("mi",null,"o"),s("mi",null,"t"),s("mi",null,"a"),s("mi",null,"t"),s("mi",null,"i"),s("mi",null,"o"),s("mi",null,"n")]),s("annotation",{encoding:"application/x-tex"},"Definition\\;\\; And \\;\\; notation")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal"},"De"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"ini"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n")])])])])])]),s("tbody",null,[s("tr",null,[s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"U"),s("mi",null,"n"),s("mi",null,"i"),s("mi",null,"o"),s("mi",null,"n"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"L"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"M")]),s("annotation",{encoding:"application/x-tex"},"Union\\;\\; of\\;\\; L\\;\\; and\\;\\; M")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"U"),s("span",{class:"mord mathnormal"},"ni"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M")])])])]),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"L"),s("mo",null,"⋃"),s("mi",null,"M"),s("mo",null,"="),s("mrow",null,[s("mo",{fence:"true"},"{"),s("mi",null,"s"),s("mo",null,"∣"),s("mi",null,"s"),s("mo",null,"∈"),s("mi",null,"L"),s("mo",null,"∨"),s("mi",null,"s"),s("mo",null,"∈"),s("mi",null,"M"),s("mo",{fence:"true"},"}")])]),s("annotation",{encoding:"application/x-tex"},"L\\bigcup M = \\left\\{s\\mid s\\in L \\lor s\\in M\\right\\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"⋃"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"minner"},[s("span",{class:"mopen delimcenter",style:{top:"0em"}},"{"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∨"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M"),s("span",{class:"mclose delimcenter",style:{top:"0em"}},"}")])])])])])]),s("tr",null,[s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"C"),s("mi",null,"o"),s("mi",null,"n"),s("mi",null,"c"),s("mi",null,"a"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"n"),s("mi",null,"a"),s("mi",null,"t"),s("mi",null,"i"),s("mi",null,"o"),s("mi",null,"n"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"L"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"M")]),s("annotation",{encoding:"application/x-tex"},"Concatenation\\;\\; of\\;\\; L\\;\\; and\\;\\; M")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"C"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"na"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M")])])])]),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"L"),s("mi",null,"M"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"s"),s("mi",null,"t"),s("mo",null,"∣"),s("mi",null,"s"),s("mo",null,"∈"),s("mi",null,"L"),s("mo",null,"∧"),s("mi",null,"t"),s("mo",null,"∈"),s("mi",null,"M"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"},"LM=\\{st\\mid s\\in L \\land t\\in M\\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∧"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6542em","vertical-align":"-0.0391em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M"),s("span",{class:"mclose"},"}")])])])])]),s("tr",null,[s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"K"),s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"e"),s("mi",null,"n"),s("mi",null,"e"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"c"),s("mi",null,"l"),s("mi",null,"o"),s("mi",null,"s"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"e"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"L")]),s("annotation",{encoding:"application/x-tex"},"Kleene\\;\\; closure\\;\\; of\\;\\; L")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"K"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"ee"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"os"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"re"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L")])])])]),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"L"),s("mo",null,"∗")]),s("mo",null,"="),s("msubsup",null,[s("mo",null,"⋃"),s("mrow",null,[s("mi",null,"i"),s("mo",null,"="),s("mn",null,"0")]),s("mi",{mathvariant:"normal"},"∞")]),s("msup",null,[s("mi",null,"L"),s("mi",null,"i")])]),s("annotation",{encoding:"application/x-tex"},"L^*=\\bigcup^\\infty_{i=0}L^i")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"L"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.1244em","vertical-align":"-0.2997em"}}),s("span",{class:"mop"},[s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"⋃"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8043em"}},[s("span",{style:{top:"-2.4003em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"i"),s("span",{class:"mrel mtight"},"="),s("span",{class:"mord mtight"},"0")])])]),s("span",{style:{top:"-3.2029em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"∞")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2997em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"L"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8247em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])])])])])])])])])])]),s("tr",null,[s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"P"),s("mi",null,"o"),s("mi",null,"s"),s("mi",null,"i"),s("mi",null,"t"),s("mi",null,"i"),s("mi",null,"v"),s("mi",null,"e"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"c"),s("mi",null,"l"),s("mi",null,"o"),s("mi",null,"s"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"e"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mtext",null,"  "),s("mi",null,"L")]),s("annotation",{encoding:"application/x-tex"},"Positive\\;\\; closure\\;\\; of\\;\\; L")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mord mathnormal"},"os"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"v"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"os"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"re"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L")])])])]),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"L"),s("mo",{lspace:"0em",rspace:"0em"},"+")]),s("mo",null,"="),s("msubsup",null,[s("mo",null,"⋃"),s("mrow",null,[s("mi",null,"i"),s("mo",null,"="),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∞")]),s("msup",null,[s("mi",null,"L"),s("mi",null,"i")])]),s("annotation",{encoding:"application/x-tex"},"L^{+}=\\bigcup^\\infty_{i=1}L^i")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7713em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"L"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"+")])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.1244em","vertical-align":"-0.2997em"}}),s("span",{class:"mop"},[s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"⋃"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8043em"}},[s("span",{style:{top:"-2.4003em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"i"),s("span",{class:"mrel mtight"},"="),s("span",{class:"mord mtight"},"1")])])]),s("span",{style:{top:"-3.2029em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"∞")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2997em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"L"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8247em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])])])])])])])])])])])])],-1),F=s("h3",{id:"正则表达式-1",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#正则表达式-1","aria-hidden":"true"},"#"),a(" 正则表达式")],-1),S=s("h4",{id:"原子表达式",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#原子表达式","aria-hidden":"true"},"#"),a(" 原子表达式")],-1),R=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("匹配一个空串")]),s("li",null,"字符表中的符号a只匹配a")],-1),N=s("h4",{id:"复合表达式",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#复合表达式","aria-hidden":"true"},"#"),a(" 复合表达式")],-1),I=s("p",null,[a("假设"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"R"),s("mn",null,"1")]),s("mtext",null,"和"),s("msub",null,[s("mi",null,"R"),s("mn",null,"2")])]),s("annotation",{encoding:"application/x-tex"},"R_1和R_2")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"和"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("是两个正则表达式,那么:")],-1),D=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"R"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"R"),s("mn",null,"2")])]),s("annotation",{encoding:"application/x-tex"},"R_1R_2")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("是它们的级联")]),s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"R"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"R"),s("mn",null,"2")])]),s("annotation",{encoding:"application/x-tex"},"R_1|R_2")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("是它们的并集")]),s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"R"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"R^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a("是它们的Kleene闭包")]),s("li",null,[a("(R)可以提高运算优先级("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mi",null,"R"),s("mo",{stretchy:"false"},")"),s("mo",null,">"),s("msup",null,[s("mi",null,"R"),s("mo",null,"∗")]),s("mo",null,">"),s("msub",null,[s("mi",null,"R"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"R"),s("mn",null,"2")]),s("mo",null,">"),s("msub",null,[s("mi",null,"R"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"R"),s("mn",null,"2")])]),s("annotation",{encoding:"application/x-tex"},"(R)>R^*>R_1R_2>R_1|R_2")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7278em","vertical-align":"-0.0391em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.00773em"}},"R"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0077em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(")")])],-1),T=s("h4",{id:"例子",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#例子","aria-hidden":"true"},"#"),a(" 例子")],-1),C=s("ul",null,[s("li",null,[a("中间包含00的任意串:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mn",null,"0"),s("mi",{mathvariant:"normal"},"∣"),s("mn",null,"1"),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")]),s("mn",null,"00"),s("mo",{stretchy:"false"},"("),s("mn",null,"0"),s("mi",{mathvariant:"normal"},"∣"),s("mn",null,"1"),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"(0|1)^*00(0|1)^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"0∣1"),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mord"},"00"),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"0∣1"),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("li",null,[a("包含最多一个零:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mn",null,"1"),s("mo",null,"∗")]),s("mo",{stretchy:"false"},"("),s("mn",null,"0"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε"),s("mo",{stretchy:"false"},")"),s("msup",null,[s("mn",null,"1"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"1^*(0|\\varepsilon)1^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},"1"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"0∣"),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mclose"},")"),s("span",{class:"mord"},[s("span",{class:"mord"},"1"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a("或"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mn",null,"1"),s("mo",null,"∗")]),s("mn",null,"0"),s("mo",{stretchy:"false"},"?"),s("msup",null,[s("mn",null,"1"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"1^*0?1^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},"1"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mord"},"0"),s("span",{class:"mclose"},"?"),s("span",{class:"mord"},[s("span",{class:"mord"},"1"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("li",null,[a("标识符:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"t"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mo",{stretchy:"false"},"("),s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"t"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"d"),s("mi",null,"i"),s("mi",null,"g"),s("mi",null,"i"),s("mi",null,"t"),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"letter(letter|digit)^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"tt"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"tt"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"g"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])])],-1),O=s("h2",{id:"有限自动机",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#有限自动机","aria-hidden":"true"},"#"),a(" 有限自动机")],-1),j=s("h3",{id:"概念",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#概念","aria-hidden":"true"},"#"),a(" 概念")],-1),E=s("ul",null,[s("li",null,"正则表达式可以用一个有限自动机来实现"),s("li",null,"有两种类型的有限自动机——NFA与DFA"),s("li",null,[a("核心思想"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"R"),s("mi",null,"E"),s("mo",null,"→"),s("mi",null,"N"),s("mi",null,"F"),s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"D"),s("mi",null,"F"),s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"RE\\rightarrow NFA\\rightarrow DFA")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"RE"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"NF"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"D"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal"},"A")])])])])],-1),U=s("h3",{id:"有限自动机的数学定义",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#有限自动机的数学定义","aria-hidden":"true"},"#"),a(" 有限自动机的数学定义")],-1),P=s("p",null,"是一个五元组(tuple)",-1),K=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"M"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("mo",null,"∑"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{separator:"true"},","),s("mi",null,"F"),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"S"),s("mn",null,"0")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"S"),s("mi",null,"a")]),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mo",null,":"),s("mi",null,"S"),s("mo",null,"×"),s("mo",null,"∑"),s("mo",null,"→"),s("mi",null,"S")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mo",null,"∑"),s("mtext",null,"为符号表")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mtext",null,"为状态集")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mtext",null,"为状态转移函数")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"S"),s("mn",null,"0")]),s("mtext",null,"为初始态")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"S"),s("mi",null,"a")]),s("mtext",null,"为接受态")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} M=( \\sum,S,F,S_{0},S_{a} )\\\\ F:S\\times \\sum \\rightarrow S \\\\ \\sum为符号表 \\\\ S为状态集 \\\\ F为状态转移函数 \\\\ S_0为初始态 \\\\ S_a为接受态 \\end{array} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"8.4em","vertical-align":"-3.95em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.45em"}},[s("span",{style:{top:"-6.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.10903em"}},"M"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"∑"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0576em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"0")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0576em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"a")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},":"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"×"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"∑"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S")])]),s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mop op-symbol small-op",style:{position:"relative",top:"0em"}},"∑"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord cjk_fallback"},"为符号表")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mord cjk_fallback"},"为状态集")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord cjk_fallback"},"为状态转移函数")])]),s("span",{style:{top:"-0.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0576em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"为初始态")])]),s("span",{style:{top:"0.59em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0576em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"a")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"为接受态")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.95em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),B=s("h3",{id:"nfa-nondeterministic-finite-automata",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#nfa-nondeterministic-finite-automata","aria-hidden":"true"},"#"),a(" NFA(Nondeterministic Finite Automata)")],-1),V=s("ul",null,[s("li",null,"对于给定的状态,一个输入会有多个转移"),s("li",null,[a("可以有"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("转移")])],-1),Y=s("h4",{id:"nfa的执行",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#nfa的执行","aria-hidden":"true"},"#"),a(" NFA的执行")],-1),H=s("ol",null,[s("li",null,"维护一个下一状态的集合,初始为空"),s("li",null,[a("对于每个当前状态,执行 "),s("ol",null,[s("li",null,"对于当前输入执行全部转移"),s("li",null,"将所有转移的结果加入下一状态的集合中")])]),s("li",null,[a("再将所有"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("转移加入下一状态集合中")])],-1),q=s("h4",{id:"时间复杂度",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#时间复杂度","aria-hidden":"true"},"#"),a(" 时间复杂度")],-1),G=s("ul",null,[s("li",null,[a("对一个长为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"m")]),s("annotation",{encoding:"application/x-tex"},"m")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"m")])])]),a("的字符串,并且有"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"n")]),s("annotation",{encoding:"application/x-tex"},"n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"n")])])]),a("个状态的自动机,时间复杂度为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"O"),s("mo",{stretchy:"false"},"("),s("mi",null,"m"),s("msup",null,[s("mi",null,"n"),s("mn",null,"2")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"O(mn^2)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0641em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"n"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8141em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])])])])])]),s("span",{class:"mclose"},")")])])])])],-1),J=s("h3",{id:"dfa-deterministic-finite-automate",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#dfa-deterministic-finite-automate","aria-hidden":"true"},"#"),a(" DFA(Deterministic Finite Automate)")],-1),Q=s("ul",null,[s("li",null,"每个状态每个输入只会有一个转移"),s("li",null,[a("没有"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("转移")])],-1),W=l(`

DFA的执行

int kTransitionTable[kNumStates][kNumSymbols]={
 {2,1,3,0,0,3}
diff --git "a/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-bfc131b7.js" "b/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6c926e87.js"
similarity index 99%
rename from "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-bfc131b7.js"
rename to "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6c926e87.js"
index fead24daa..3e2ee7192 100644
--- "a/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-bfc131b7.js"	
+++ "b/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6c926e87.js"	
@@ -1,4 +1,4 @@
-import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as m,a as s,b as a,e as l}from"./app-75cd46e5.js";const e="/assets/语法树与抽象语法树-55a2538f.png",i="/assets/语法树歧义-856a0a66.png",r="/assets/消除歧义1-3c88d6f5.png",p="/assets/消除歧义2-2d8e8b93.png",c="/assets/消除歧义3-c2733db2.png",h="/assets/First()计算3-a852a8c3.png",o="/assets/First()计算4-5825b222.png",g="/assets/First()计算5-0c9e242d.png",u="/assets/Follow()计算2-a7574e0e.png",d="/assets/nullableset计算2-128eb5d5.png",y="/assets/判断LL(1)示例-0369bfb1.png",v="/assets/递归下降示例1-e91fec79.png",x="/assets/递归下降示例2-860ab25f.png",w="/assets/递归下降示例3-e36a312c.png",b="/assets/递归下降示例4-8b22709e.png",k="/assets/递归下降示例5-b9b40593.png",f="/assets/语法树、抽象语法树示例-2ebd7471.png",z="/assets/构建语法树代码1-8fc22f8a.png",_="/assets/构建语法树代码2-33af2f61.png",M="/assets/LL(1)原理-b1d37a61.png",A="/assets/构建LL(1)_parsing_table1-e713a47f.png",L="/assets/构建LL(1)_parsing_table2-63f1d5f2.png",S="/assets/LL(1)流程图-467897f9.png",R="/assets/LL(1)举例-2074e2aa.png",V="/assets/panic_mode1-075d01eb.png",F="/assets/panic_mode2-508f1952.png",T="/assets/panic_mode3-ac49debc.png",N="/assets/ShiftAndReduce-2a39739a.png",X="/assets/LR_Parsing_基本原理-8f25ab56.png",O="/assets/LR_Parsing_table-e92d5ffd.png",j="/assets/LR_Parsing_table2-239cef90.png",E="/assets/LR_parsing_table_example-691cc303.png",B="/assets/LR_parsing_table_example2-3aff05c7.png",G="/assets/LR自动机示意图-44905320.png",I="/assets/LR_parsing_DFA-5d4e18be.png",Y="/assets/SLR(1)语法-0d671576.png",P="/assets/SLR(1)分析表-2e8aff2e.png",C="/assets/SLR(1)的缺点-c38fca03.png",U="/assets/LR(1)项-405e0815.png",K={},W=s("h1",{id:"chapter3-语法分析",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#chapter3-语法分析","aria-hidden":"true"},"#"),a(" Chapter3 语法分析")],-1),Z=s("ul",null,[s("li",null,[a("正则表达式的能力有限,无法分析具体的语法细节(例如嵌套、"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"a"),s("mi",null,"n")]),s("msup",null,[s("mi",null,"b"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"a^nb^n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"b"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])])])])]),a("的n值),与其等价的有穷自动机同理,因此引入了下推自动机和上下文有关、无关文法")])],-1),D=l('

大纲

  • 语法分析的形式化——上下文无关文法
  • 语法分析算法

上下文无关文法(CFG)

  • 是用来描述一个编程语言的语法结构的文法
  • 和正则表达式一样,可以表示递归的规则,而且更强大
  • 是正则表达式的严格超集

Chomsky语言层级

',5),$=s("table",null,[s("thead",null,[s("tr",null,[s("th",null,"Chomsky hierarchy"),s("th",null,"Production(产生式)"),s("th",null,"Explanation")])]),s("tbody",null,[s("tr",null,[s("td",null,"unrestricted(type 0)(自然语言)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α"),s("mo",null,"→"),s("mi",null,"β"),s("mspace",{width:"1em"}),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")]),s("mo",null,"="),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")])]),s("annotation",{encoding:"application/x-tex"},"\\alpha \\rightarrow \\beta \\quad V^+=V_N\\cup V_T")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9658em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"α"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"其中\\alpha\\in V^+,\\; \\beta\\in V^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7224em","vertical-align":"-0.0391em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9658em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("td",null,"无严格约束")]),s("tr",null,[s("td",null,"context sensitive(type 1)(上下文有关文法)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α"),s("mi",null,"A"),s("mi",null,"γ"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"β"),s("mi",null,"γ"),s("mo",{separator:"true"},",")]),s("annotation",{encoding:"application/x-tex"},"\\alpha A \\gamma \\rightarrow \\alpha \\beta \\gamma,")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mpunct"},",")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"α"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"γ"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")])]),s("annotation",{encoding:"application/x-tex"},"其中\\alpha,\\;\\gamma\\in V^*,\\;A \\in V_N, \\; \\beta \\in V^+")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8831em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7713em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])])])])])]),s("td",null,[a("在不同的上下文中,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("可能被不同的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"γ")]),s("annotation",{encoding:"application/x-tex"},"\\gamma")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ")])])]),a("替换")])]),s("tr",null,[s("td",null,"context free(type 2)(上下文无关文法)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},",")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\beta ,\\;A\\in V_N,")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},",")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"其中\\beta \\in V^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("td",null,[a("在任何"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("出现的地方都会被"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"γ")]),s("annotation",{encoding:"application/x-tex"},"\\gamma")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ")])])]),a("替换")])]),s("tr",null,[s("td",null,"regular(type 3)(正则表达式)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"a"),s("mi",null,"B"),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"r"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow aB\\;or\\;A\\rightarrow a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"or"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mtext",null,"其中"),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mi",null,"B"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mi",null,"b"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"  "),s("mo",{separator:"true"},","),s("mi",null,"a"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"(其中A,B\\;A,b\\in V_N\\;,a\\in V_T)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])]),s("td",null,"等价于正则表达式")])])],-1),q=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"和"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")])]),s("annotation",{encoding:"application/x-tex"},"V_N和V_T")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"和"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("分别是非终止符号集(nonterminal)和终止符号(terminal)集,是由语言设计者设计的集合,终止符就是常说的token")]),s("li",null,[a("如果一个符号由它自身定义("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a"),s("mo",null,"→"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a\\rightarrow a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a("或"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"i"),s("mi",null,"n"),s("mi",null,"t"),s("mo",null,"→"),s("mi",null,"i"),s("mi",null,"n"),s("mi",null,"t")]),s("annotation",{encoding:"application/x-tex"},"int \\rightarrow int")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6595em"}}),s("span",{class:"mord mathnormal"},"in"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6595em"}}),s("span",{class:"mord mathnormal"},"in"),s("span",{class:"mord mathnormal"},"t")])])]),a(")那么就是一个终止符号,通常是标点符号,如分号,括号等")]),s("li",null,[a("如果一个符号有其定义的可再分的结构就是一个非终止符号("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"t"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mo",null,"→"),s("mo",{stretchy:"false"},"["),s("mi",null,"A"),s("mo",null,"−"),s("mi",null,"Z"),s("mi",null,"a"),s("mo",null,"−"),s("mi",null,"z"),s("mo",{stretchy:"false"},"]")]),s("annotation",{encoding:"application/x-tex"},"letter\\rightarrow [A-Za-z]")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"tt"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"["),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7667em","vertical-align":"-0.0833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"Z"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.04398em"}},"z"),s("span",{class:"mclose"},"]")])])]),a("),通常是句子,短语,表达式等")]),s("li",null,[a("要注意,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"A"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"A^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a('(Kleene闭包)是正则表达式特有的规则,CFG中没有,"|"在CFG中表示的是或,用来简化表示多个产生式,而不是正则表达式中的Union。')]),s("li",null,"CFG文法规定的第一个文法的左部是开始符号,规定了该语言都满足的一个规则"),s("li",null,"一个处于较低层级的文法是上级文法的特例,例如RE就是一种特殊的CFG")],-1),H=s("h2",{id:"形式化定义",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#形式化定义","aria-hidden":"true"},"#"),a(" 形式化定义")],-1),J=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"C"),s("mi",null,"F"),s("mi",null,"G"),s("mo",null,":"),s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mtext",null,"是终止符集合")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"是非终止符集合,"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∩"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",null,"="),s("mi",{mathvariant:"normal"},"∅")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"P"),s("mtext",null,"是产生式集合,或称语法规则集,满足"),s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"和"),s("mi",null,"β"),s("mo",null,"∈"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mtext",null,"是初始符号,"),s("mi",null,"S"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")])])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} CFG:G=(V_T,V_N,P,S)\\\\ V_T\\text{是终止符集合}\\\\ V_N\\text{是非终止符集合,}V_N\\cap V_T=\\varnothing\\\\ P\\text{是产生式集合,或称语法规则集,满足}A\\rightarrow \\beta \\;A\\in V_N和\\beta \\in (V_N\\cup V_T)^*\\\\ S\\text{是初始符号,}S\\in V_N \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"CFG"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},":"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是终止符集合")])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是非终止符集合,")]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∩"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord amsrm"},"∅")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是产生式集合,或称语法规则集,满足")]),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"和"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])]),s("span",{style:{top:"-0.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是初始符号,")]),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Q=s("h3",{id:"ebnf-extended-backus-naur-form",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#ebnf-extended-backus-naur-form","aria-hidden":"true"},"#"),a(" EBNF(Extended Backus-Naur form)")],-1),ss=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"→")]),s("annotation",{encoding:"application/x-tex"},"\\rightarrow")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.3669em"}}),s("span",{class:"mrel"},"→")])])]),a(":"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("msub",null,[s("mi",null,"Y"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"2")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"3")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"Y"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X\\rightarrow Y_1Y_2Y_3...Y_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"3")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mtext",null,"可以用"),s("msub",null,[s("mi",null,"Y"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"2")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"3")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"Y"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X\\text{可以用}Y_1Y_2Y_3...Y_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"可以用")]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"3")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("来代替,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"X\\rightarrow \\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X")]),s("annotation",{encoding:"application/x-tex"},"X")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])])]),a("可以用空串代替,这种"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a("被称为BNF表示法")]),s("li",null,[a("简化表示: "),s("ol",null,[s("li",null,"除非特殊说明,否则第一个产生式的左部就是初始符号"),s("li",null,"用小写字母表示终止符号"),s("li",null,[a("用大写字符或者"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"<"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",null,">")]),s("annotation",{encoding:"application/x-tex"},"<...>")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mrel"},"<"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">")])])]),a("表示非终止符号")]),s("li",null,[a("如果左部都为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("的一系列产生式"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mo",{separator:"true"},","),s("mtext",null,"  ")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha_2,\\;...,\\;A\\rightarrow \\alpha_n,\\;")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})])])]),a("可以简写为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha_1 | \\alpha _2|...|\\alpha_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])])])]),s("li",null,"特别注意:")],-1),as=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("msup",null,[s("mi",null,"a"),s("mo",null,"∗")]),s("mi",null,"b"),s("mtext",null,"(错误写法,没有Kleene闭包)")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"b")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} S\\rightarrow a^*b \\text{(错误写法,没有Kleene闭包)}\\\\ S\\rightarrow Ab\\\\ A\\rightarrow Aa|\\varepsilon \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"错误写法,没有"),s("span",{class:"mord"},"Kleene"),s("span",{class:"mord cjk_fallback"},"闭包"),s("span",{class:"mord"},")")])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"b")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ls=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"a"),s("mo",{stretchy:"false"},"("),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mtext",null,"错误,没有括号"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"a"),s("mi",null,"X")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} S\\rightarrow a(b|c)(错误,没有括号)\\\\ S\\rightarrow aX\\\\ X\\rightarrow b|c \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord cjk_fallback"},"错误,没有括号"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ts=s("ul",null,[s("li",null,[a("左递归:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mo",{stretchy:"false"},"("),s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"f"),s("mi",null,"t"),s("mtext",null,"  "),s("mi",null,"r"),s("mi",null,"e"),s("mi",null,"c"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"s"),s("mi",null,"i"),s("mi",null,"v"),s("mi",null,"e"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A \\rightarrow A\\alpha|\\beta\\;(left\\;recursive)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"rec"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"rs"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"v"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mclose"},")")])])]),a("可表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mi",null,"α"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mi",null,"α"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},".")]),s("annotation",{encoding:"application/x-tex"},"\\beta ,\\;\\beta \\alpha,\\; \\beta \\alpha \\alpha...")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"αα"),s("span",{class:"mord"},"...")])])]),a("即有推导"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"β"),s("msup",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mo",{stretchy:"false"},"("),s("mi",null,"n"),s("mo",null,"="),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A\\Rightarrow^*\\beta \\alpha^n(n=0,1,2,...)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},")")])])]),a("在EBNF中可表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow\\beta \\{\\alpha \\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},"}")])])])]),s("li",null,[a("右递归:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"A"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mo",{stretchy:"false"},"("),s("mi",null,"r"),s("mi",null,"i"),s("mi",null,"g"),s("mi",null,"h"),s("mi",null,"t"),s("mtext",null,"  "),s("mi",null,"r"),s("mi",null,"e"),s("mi",null,"c"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"s"),s("mi",null,"i"),s("mi",null,"v"),s("mi",null,"e"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A \\rightarrow \\alpha A|\\beta\\;(right\\;recursive)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"r"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"g"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"rec"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"rs"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"v"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mclose"},")")])])]),a("可表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"α"),s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"α"),s("mi",null,"β"),s("mi",null,"β"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},".")]),s("annotation",{encoding:"application/x-tex"},"\\beta,\\; \\alpha \\beta,\\; \\alpha \\beta \\beta...")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"ββ"),s("span",{class:"mord"},"...")])])]),a("即有推导"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("msup",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mi",null,"β"),s("mo",{stretchy:"false"},"("),s("mi",null,"n"),s("mo",null,"="),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A\\Rightarrow^* \\alpha^n \\beta(n=0,1,2,...)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},")")])])]),a("在EBNF中可表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",{stretchy:"false"},"}"),s("mi",null,"β")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\{\\alpha \\}\\beta")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},"}"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β")])])])]),s("li",null,"结合性")],-1),ns=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"}"),s("mtext",null,"(左结合性)")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"["),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"]"),s("mtext",null,"(右结合性)")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} exp\\rightarrow exp\\; addop\\; term|term\\\\ exp\\rightarrow term\\{addop\\;term\\}\\text{(左结合性)}\\\\ exp\\rightarrow term[addop \\; term]\\text{(右结合性)} \\end{array} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mclose"},"}"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"左结合性"),s("span",{class:"mord"},")")])])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mopen"},"["),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mclose"},"]"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"右结合性"),s("span",{class:"mord"},")")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ms=s("ul",null,[s("li",null,"中括号表示其中的符号出现0次或1次,大括号表示0次至无数次")],-1),es=s("h2",{id:"推导-derivation-与规约-reduction",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#推导-derivation-与规约-reduction","aria-hidden":"true"},"#"),a(" 推导(Derivation)与规约(Reduction)")],-1),is=s("ul",null,[s("li",null,"如果能用一步步推导从初始符号得到需要验证的式子,那么式子就是符合规则的"),s("li",null,"推导就是不断用产生式的右部来替换一个非终止符"),s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"\\Rightarrow^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a("表示多步推导")]),s("li",null,"由终止符号构成的串称为句子(sentence),由非终止符号构成的串是句型(sentential form)"),s("li",null,[a("以S为开始符号的CFG构成的语言:"),s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"L"),s("mo",{stretchy:"false"},"("),s("mi",null,"G"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"s"),s("mo",null,"∈"),s("msubsup",null,[s("mi",null,"V"),s("mi",null,"T"),s("mo",null,"∗")]),s("mi",{mathvariant:"normal"},"∣"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"e"),s("mtext",null,"  "),s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"i"),s("mi",null,"s"),s("mi",null,"t"),s("mi",null,"s"),s("mtext",null,"  "),s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"s"),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"G"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"}," L(G)=\\{s\\in V_T^*|\\;there\\;exists\\;S\\Rightarrow^*s\\;of\\; G\\} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-2.453em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])]),s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.247em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"ere"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mclose"},"}")])])])])])])],-1),rs=s("h3",{id:"语法树",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#语法树","aria-hidden":"true"},"#"),a(" 语法树")],-1),ps=s("ul",null,[s("li",null,"根节点是开始符号"),s("li",null,"内部节点是非终止符号"),s("li",null,[a("叶子节点是终止符号或者"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])])]),s("li",null,[a("如果节点A有子节点"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X_1,X_2,...,X_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("则意为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow X_1X_2...X_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])]),s("li",null,"最终的叶子节点连起来就是一个句子"),s("li",null,"不同的推导会得到不同的树,但是可能会有相同的结果。")],-1),cs=s("h3",{id:"最左推导-leftmost-derivation前缀推导",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#最左推导-leftmost-derivation前缀推导","aria-hidden":"true"},"#"),a(" 最左推导(LeftMost Derivation前缀推导)")],-1),hs=s("ul",null,[s("li",null,"总是对句型中最左侧的非终止符号进行一次推导"),s("li",null,"从开始符号推导到结果,被称为Top-down")],-1),os=s("h3",{id:"最右推导-rightmost-derivation",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#最右推导-rightmost-derivation","aria-hidden":"true"},"#"),a(" 最右推导(RightMost Derivation)")],-1),gs=s("ul",null,[s("li",null,[a("从结果反向推回开始符号,这个过程被称为规约"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"s"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"S")]),s("annotation",{encoding:"application/x-tex"},"s\\Rightarrow^*S")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S")])])])]),s("li",null,"等价于对语法树进行后序遍历的逆过程"),s("li",null,"最右推导的能力比最左推导要强")],-1),us=l('

抽象语法树

语法树与抽象语法树
语法树与抽象语法树
  • 比起语法树,省略了部分细节,带来了更好的语法抽象,对于后续编译阶段是一个更好的数据结构
  • 它反映了源码token序列的一个抽象,比语法树更高效

歧义(Ambiguity)

  • 对于一个CFG,同样的输入可能有不同的解析 语法树歧义.png

解决方法

  • 消除歧义(Disambiguity rule):不改变文法,列举所有可能造成歧义的情况并进行消除,不现实的
  • 文法重写:改变文法,进行同义转换:(添加优先级,添加关联性)
',7),ds=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"E"),s("mo",null,"→"),s("mi",null,"E"),s("mo",null,"−"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"E"),s("mo",null,"×"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mo",{stretchy:"false"},"("),s("mi",null,"E"),s("mo",{stretchy:"false"},")"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"i"),s("mtext",null,"  "),s("mo",null,"⇒"),s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"E"),s("mo",null,"→"),s("mi",null,"E"),s("mo",null,"−"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"T")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"T"),s("mo",null,"→"),s("mi",null,"T"),s("mo",null,"×"),s("mi",null,"T"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"F")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"E"),s("mo",{stretchy:"false"},")"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"i")])])])])])]),s("annotation",{encoding:"application/x-tex"}," E\\rightarrow E-E|E \\times E|(E)|i\\;\\Rightarrow \\begin{array}{c} E\\rightarrow E-E|T\\\\ T\\rightarrow T\\times T|F\\\\ F\\rightarrow(E)|i \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7667em","vertical-align":"-0.0833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"×"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mclose"},")"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"⇒"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"×"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mclose"},")"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ys=l('

消除歧义1消除歧义2消除歧义3

语法分析算法(parsing)

Top-Down(Leftmost) parsing

  • 本质上是一个图搜索问题,在树上搜索,查找能否获得一个与输入sentence匹配的路径

回溯算法(Backtracking)

',5),vs=s("ul",null,[s("li",null,"用BFS:进行图遍历搜索,复杂,时间复杂度过高,产生大量无用分支,时间和空间的最差情况都是指数级别。现代编译器中不被使用"),s("li",null,[a("剪枝:由终止符号做前缀时,如果无法与输入的前缀匹配则剪枝。("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",null,"→"),s("mi",null,"c"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"Aa|Ab|c\\rightarrow caaaaa")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"aaaaa")])])]),a("时,无法剪枝,因为前缀一直是非终止符号)")]),s("li",null,[a("用DFS:有比BFS更好的空间复杂度和时间复杂度,但是无法匹配("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",null,"→"),s("mi",null,"c")]),s("annotation",{encoding:"application/x-tex"},"Aa|c\\rightarrow c")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"c")])])]),a(",因为会一直循环)")])],-1),xs=s("h3",{id:"预测推导-predictive-parsing",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#预测推导-predictive-parsing","aria-hidden":"true"},"#"),a(" 预测推导(predictive parsing)")],-1),ws=s("ul",null,[s("li",null,"Idea:利用先行词(lokkahead tokens),也就是上面提到过的终止符前缀"),s("li",null,"两种分析方法:")],-1),bs=s("ol",null,[s("li",null,"递归下降分析(Recursive-descent parsing)"),s("li",null,"LL(1)分析")],-1),ks=s("h4",{id:"预测分析的概念",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#预测分析的概念","aria-hidden":"true"},"#"),a(" 预测分析的概念")],-1),fs=s("ul",null,[s("li",null,"从输入串和文法的开始符号开始分析"),s("li",null,"可以从当前输入的token(s)唯一确定下一个要使用的产生式"),s("li",null,[a("预测分析文法包括LL(k)文法,其中L表示从左向右扫描,L表示最左推导,k表示“需要"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"≤"),s("mi",null,"k")]),s("annotation",{encoding:"application/x-tex"},"\\le k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7719em","vertical-align":"-0.136em"}}),s("span",{class:"mrel"},"≤"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03148em"}},"k")])])]),a("个先行词用于预测 ”")]),s("li",null,"LL(1)文法是常用的,也不完全常用")],-1),zs=s("h5",{id:"lookahead-sets",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#lookahead-sets","aria-hidden":"true"},"#"),a(" Lookahead Sets")],-1),_s=s("h6",{id:"first-sets-具体计算看讲义和书",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#first-sets-具体计算看讲义和书","aria-hidden":"true"},"#"),a(" First Sets(具体计算看讲义和书)")],-1),Ms=s("ul",null,[s("li",null,"定义")],-1),As=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")"),s("mtext",null,"是一个文法")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"β"),s("mo",null,"∈"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"β"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},"}")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"i"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"β"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"ε"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"n"),s("mtext",null,"  "),s("mi",null,"ε"),s("mo",null,"∈"),s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"β"),s("mo",{stretchy:"false"},")")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} G=(V_N,V_T,P,S)\\text{是一个文法}\\\\ \\beta\\in(V_N\\cup V_T)^*\\\\ FIRST(\\beta)=\\{\\alpha\\in V_T|\\beta\\Rightarrow^*a...\\}\\\\ if\\;\\beta\\Rightarrow^*\\varepsilon\\;then\\;\\varepsilon\\in FIRST(\\beta) \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.8em","vertical-align":"-2.15em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.65em"}},[s("span",{style:{top:"-4.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是一个文法")])])]),s("span",{style:{top:"-3.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},"}")])]),s("span",{style:{top:"-1.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mclose"},")")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.15em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Ls=l('
  • 计算

First()计算 3First()计算 4First()计算 5

//Todo 提取简练笔记

Follow Sets
  • 定义:
',5),Ss=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")"),s("mtext",null,"是一个文法")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},"}"),s("mo",{separator:"true"},",")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"i"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"S"),s("mo",null,"⇒"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"n"),s("mtext",null,"  "),s("mi",{mathvariant:"normal"},"$"),s("mo",null,"∈"),s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"$"),s("mtext",null,"是用来标记输入的终止的符号")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} G=(V_N,V_T,P,S)\\text{是一个文法}\\\\A\\in V_N\\\\ FOLLOW(A)=\\{a\\in V_T|S\\Rightarrow^*...Aa...\\},\\\\ if\\;S\\Rightarrow...A,\\;then\\;\\$\\in FOLLOW(A)\\\\ \\$是用来标记输入的终止的符号 \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是一个文法")])])]),s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},"}"),s("span",{class:"mpunct"},",")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"⇒"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"$"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-0.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},"$"),s("span",{class:"mord cjk_fallback"},"是用来标记输入的终止的符号")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Rs=s("ul",null,[s("li",null,[a("计算: "),s("img",{src:u,alt:"Follow()计算 2.png",loading:"lazy"})])],-1),Vs=s("h5",{id:"可空的非终止符-nullable-nonterminal",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#可空的非终止符-nullable-nonterminal","aria-hidden":"true"},"#"),a(" 可空的非终止符(nullable nonterminal)")],-1),Fs=s("ul",null,[s("li",null,[a("定义:"),s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"}," S\\Rightarrow^*\\varepsilon ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7387em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])])])])])],-1),Ts=s("p",null,"则称S是一个可空的非终止符",-1),Ns=s("ul",null,[s("li",null,[a("计算: "),s("img",{src:d,alt:"nullble set计算 2.png",loading:"lazy"})])],-1),Xs=s("h5",{id:"判定ll-1-文法",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#判定ll-1-文法","aria-hidden":"true"},"#"),a(" 判定LL(1)文法")],-1),Os=s("ul",null,[s("li",null,"计算每个可空的非终止符"),s("li",null,[a("计算产生式右侧所有的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"α"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"FIRST(\\alpha)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},")")])])]),a("并验证其两两交集是否为空")]),s("li",null,[a("计算(1)中算出的非终止符的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"FOLLOW(A)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")")])])]),a("并验证"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"∩"),s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mi",{mathvariant:"normal"},"∅")]),s("annotation",{encoding:"application/x-tex"},"FIRST(A)\\cap FOLLOW(A)=\\varnothing")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∩"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6633em","vertical-align":"-0.0817em"}}),s("span",{class:"mord amsrm"},"∅")])])]),s("img",{src:y,alt:"判断LL(1)示例.png",loading:"lazy"})])],-1),js=s("h5",{id:"非ll-1-到ll-1",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#非ll-1-到ll-1","aria-hidden":"true"},"#"),a(" 非LL(1)到LL(1)")],-1),Es=s("ul",null,[s("li",null,"两种简单的非LL(1)情形:")],-1),Bs=s("ol",null,[s("li",null,[a("左因子,例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"β"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("mi",null,"r")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha \\beta|\\alpha r")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"r")])])]),a(",这是两个产生式的简写,其产生式交集为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"\\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a(",改写方法为")])],-1),Gs=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("mtext",null,"  "),s("mtext",null,"重写为"),s("mo",null,":")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")]),s("mspace",{width:"1em"}),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")])])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} A\\rightarrow\\alpha\\beta_1|\\alpha\\beta_2|...|\\alpha\\beta_n\\;重写为:\\\\ A\\rightarrow\\alpha A{'}\\quad A^{'}\\rightarrow\\beta_1|\\beta_2|...|\\beta_n \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"2.5025em","vertical-align":"-1.0012em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.5012em"}},[s("span",{style:{top:"-3.6612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord cjk_fallback"},"重写为"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},":")])]),s("span",{style:{top:"-2.3588em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7519em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.0012em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Is=s("ol",{start:"2"},[s("li",null,[a("左递归,包括直接左递归和间接左递归,例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"β")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow A \\beta")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β")])])]),a("和"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"B"),s("mi",null,"β"),s("mspace",{width:"1em"}),s("mi",null,"B"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow B \\beta\\quad B\\rightarrow A\\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"Bβ"),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a(" 改写方法为")])],-1),Ys=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mtext",null,"重写为:")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mtext",null,"  "),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("mi",null,"α"),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mtext",null,"一般情况为:")])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("mtext",null,"  "),s("mtext",null,"重写为:")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mi",null,"m")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} A\\rightarrow A \\alpha|\\beta\\;\\text{重写为:}\\\\ A\\rightarrow\\beta A^{'}\\; ,\\;A^{'}\\rightarrow\\alpha A^{'}|\\varepsilon\\\\ \\text{一般情况为:}\\\\ A\\rightarrow A \\alpha_1|A \\alpha_2|...|A \\alpha_m|\\beta_1|\\beta_2|...|\\beta_n\\; \\text{重写为:}\\\\ A\\rightarrow \\beta_1 A^{'}|\\beta_2 A^{'}|...|\\beta_n A^{'}\\\\ A^{'}\\rightarrow\\alpha_1 A^{'}|\\alpha_1 A^{'}|...|\\alpha_m A^{'}|\\varepsilon \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"7.5074em","vertical-align":"-3.5037em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.0037em"}},[s("span",{style:{top:"-6.1637em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"重写为:")])])]),s("span",{style:{top:"-4.8612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])]),s("span",{style:{top:"-3.6612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"一般情况为:")])])]),s("span",{style:{top:"-2.4612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"重写为:")])])]),s("span",{style:{top:"-1.1588em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])])])]),s("span",{style:{top:"0.1437em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.5037em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Ps=l(`
  • 要注意:将这两者进行改写后并不能保证改写后的文法是LL(1),仍需要再进行验证

递归下降

输入
  • 非终止符号递归调用,终止符号匹配
int main(){
+import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as m,a as s,b as a,e as l}from"./app-9d555359.js";const e="/assets/语法树与抽象语法树-55a2538f.png",i="/assets/语法树歧义-856a0a66.png",r="/assets/消除歧义1-3c88d6f5.png",p="/assets/消除歧义2-2d8e8b93.png",c="/assets/消除歧义3-c2733db2.png",h="/assets/First()计算3-a852a8c3.png",o="/assets/First()计算4-5825b222.png",g="/assets/First()计算5-0c9e242d.png",u="/assets/Follow()计算2-a7574e0e.png",d="/assets/nullableset计算2-128eb5d5.png",y="/assets/判断LL(1)示例-0369bfb1.png",v="/assets/递归下降示例1-e91fec79.png",x="/assets/递归下降示例2-860ab25f.png",w="/assets/递归下降示例3-e36a312c.png",b="/assets/递归下降示例4-8b22709e.png",k="/assets/递归下降示例5-b9b40593.png",f="/assets/语法树、抽象语法树示例-2ebd7471.png",z="/assets/构建语法树代码1-8fc22f8a.png",_="/assets/构建语法树代码2-33af2f61.png",M="/assets/LL(1)原理-b1d37a61.png",A="/assets/构建LL(1)_parsing_table1-e713a47f.png",L="/assets/构建LL(1)_parsing_table2-63f1d5f2.png",S="/assets/LL(1)流程图-467897f9.png",R="/assets/LL(1)举例-2074e2aa.png",V="/assets/panic_mode1-075d01eb.png",F="/assets/panic_mode2-508f1952.png",T="/assets/panic_mode3-ac49debc.png",N="/assets/ShiftAndReduce-2a39739a.png",X="/assets/LR_Parsing_基本原理-8f25ab56.png",O="/assets/LR_Parsing_table-e92d5ffd.png",j="/assets/LR_Parsing_table2-239cef90.png",E="/assets/LR_parsing_table_example-691cc303.png",B="/assets/LR_parsing_table_example2-3aff05c7.png",G="/assets/LR自动机示意图-44905320.png",I="/assets/LR_parsing_DFA-5d4e18be.png",Y="/assets/SLR(1)语法-0d671576.png",P="/assets/SLR(1)分析表-2e8aff2e.png",C="/assets/SLR(1)的缺点-c38fca03.png",U="/assets/LR(1)项-405e0815.png",K={},W=s("h1",{id:"chapter3-语法分析",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#chapter3-语法分析","aria-hidden":"true"},"#"),a(" Chapter3 语法分析")],-1),Z=s("ul",null,[s("li",null,[a("正则表达式的能力有限,无法分析具体的语法细节(例如嵌套、"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"a"),s("mi",null,"n")]),s("msup",null,[s("mi",null,"b"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"a^nb^n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"b"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])])])])]),a("的n值),与其等价的有穷自动机同理,因此引入了下推自动机和上下文有关、无关文法")])],-1),D=l('

大纲

  • 语法分析的形式化——上下文无关文法
  • 语法分析算法

上下文无关文法(CFG)

  • 是用来描述一个编程语言的语法结构的文法
  • 和正则表达式一样,可以表示递归的规则,而且更强大
  • 是正则表达式的严格超集

Chomsky语言层级

',5),$=s("table",null,[s("thead",null,[s("tr",null,[s("th",null,"Chomsky hierarchy"),s("th",null,"Production(产生式)"),s("th",null,"Explanation")])]),s("tbody",null,[s("tr",null,[s("td",null,"unrestricted(type 0)(自然语言)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α"),s("mo",null,"→"),s("mi",null,"β"),s("mspace",{width:"1em"}),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")]),s("mo",null,"="),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")])]),s("annotation",{encoding:"application/x-tex"},"\\alpha \\rightarrow \\beta \\quad V^+=V_N\\cup V_T")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9658em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"α"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"其中\\alpha\\in V^+,\\; \\beta\\in V^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7224em","vertical-align":"-0.0391em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9658em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("td",null,"无严格约束")]),s("tr",null,[s("td",null,"context sensitive(type 1)(上下文有关文法)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α"),s("mi",null,"A"),s("mi",null,"γ"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"β"),s("mi",null,"γ"),s("mo",{separator:"true"},",")]),s("annotation",{encoding:"application/x-tex"},"\\alpha A \\gamma \\rightarrow \\alpha \\beta \\gamma,")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mpunct"},",")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"α"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"γ"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"+")])]),s("annotation",{encoding:"application/x-tex"},"其中\\alpha,\\;\\gamma\\in V^*,\\;A \\in V_N, \\; \\beta \\in V^+")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8831em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7713em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7713em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"+")])])])])])])])])])])]),s("td",null,[a("在不同的上下文中,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("可能被不同的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"γ")]),s("annotation",{encoding:"application/x-tex"},"\\gamma")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ")])])]),a("替换")])]),s("tr",null,[s("td",null,"context free(type 2)(上下文无关文法)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},",")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\beta ,\\;A\\in V_N,")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},",")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"其中"),s("mi",null,"β"),s("mo",null,"∈"),s("msup",null,[s("mi",null,"V"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"其中\\beta \\in V^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])])]),s("td",null,[a("在任何"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("出现的地方都会被"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"γ")]),s("annotation",{encoding:"application/x-tex"},"\\gamma")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05556em"}},"γ")])])]),a("替换")])]),s("tr",null,[s("td",null,"regular(type 3)(正则表达式)"),s("td",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"a"),s("mi",null,"B"),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"r"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow aB\\;or\\;A\\rightarrow a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"or"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mtext",null,"其中"),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mi",null,"B"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mi",null,"b"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"  "),s("mo",{separator:"true"},","),s("mi",null,"a"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"(其中A,B\\;A,b\\in V_N\\;,a\\in V_T)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord cjk_fallback"},"其中"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])]),s("td",null,"等价于正则表达式")])])],-1),q=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"和"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")])]),s("annotation",{encoding:"application/x-tex"},"V_N和V_T")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"和"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("分别是非终止符号集(nonterminal)和终止符号(terminal)集,是由语言设计者设计的集合,终止符就是常说的token")]),s("li",null,[a("如果一个符号由它自身定义("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a"),s("mo",null,"→"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a\\rightarrow a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a("或"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"i"),s("mi",null,"n"),s("mi",null,"t"),s("mo",null,"→"),s("mi",null,"i"),s("mi",null,"n"),s("mi",null,"t")]),s("annotation",{encoding:"application/x-tex"},"int \\rightarrow int")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6595em"}}),s("span",{class:"mord mathnormal"},"in"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6595em"}}),s("span",{class:"mord mathnormal"},"in"),s("span",{class:"mord mathnormal"},"t")])])]),a(")那么就是一个终止符号,通常是标点符号,如分号,括号等")]),s("li",null,[a("如果一个符号有其定义的可再分的结构就是一个非终止符号("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"t"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mo",null,"→"),s("mo",{stretchy:"false"},"["),s("mi",null,"A"),s("mo",null,"−"),s("mi",null,"Z"),s("mi",null,"a"),s("mo",null,"−"),s("mi",null,"z"),s("mo",{stretchy:"false"},"]")]),s("annotation",{encoding:"application/x-tex"},"letter\\rightarrow [A-Za-z]")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"tt"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"["),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7667em","vertical-align":"-0.0833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07153em"}},"Z"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.04398em"}},"z"),s("span",{class:"mclose"},"]")])])]),a("),通常是句子,短语,表达式等")]),s("li",null,[a("要注意,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mi",null,"A"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"A^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a('(Kleene闭包)是正则表达式特有的规则,CFG中没有,"|"在CFG中表示的是或,用来简化表示多个产生式,而不是正则表达式中的Union。')]),s("li",null,"CFG文法规定的第一个文法的左部是开始符号,规定了该语言都满足的一个规则"),s("li",null,"一个处于较低层级的文法是上级文法的特例,例如RE就是一种特殊的CFG")],-1),H=s("h2",{id:"形式化定义",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#形式化定义","aria-hidden":"true"},"#"),a(" 形式化定义")],-1),J=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"C"),s("mi",null,"F"),s("mi",null,"G"),s("mo",null,":"),s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mtext",null,"是终止符集合")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"是非终止符集合,"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∩"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",null,"="),s("mi",{mathvariant:"normal"},"∅")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"P"),s("mtext",null,"是产生式集合,或称语法规则集,满足"),s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mtext",null,"和"),s("mi",null,"β"),s("mo",null,"∈"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mtext",null,"是初始符号,"),s("mi",null,"S"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")])])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} CFG:G=(V_T,V_N,P,S)\\\\ V_T\\text{是终止符集合}\\\\ V_N\\text{是非终止符集合,}V_N\\cap V_T=\\varnothing\\\\ P\\text{是产生式集合,或称语法规则集,满足}A\\rightarrow \\beta \\;A\\in V_N和\\beta \\in (V_N\\cup V_T)^*\\\\ S\\text{是初始符号,}S\\in V_N \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"CFG"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},":"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是终止符集合")])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是非终止符集合,")]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∩"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord amsrm"},"∅")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是产生式集合,或称语法规则集,满足")]),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},"和"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])]),s("span",{style:{top:"-0.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是初始符号,")]),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Q=s("h3",{id:"ebnf-extended-backus-naur-form",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#ebnf-extended-backus-naur-form","aria-hidden":"true"},"#"),a(" EBNF(Extended Backus-Naur form)")],-1),ss=s("ul",null,[s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"→")]),s("annotation",{encoding:"application/x-tex"},"\\rightarrow")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.3669em"}}),s("span",{class:"mrel"},"→")])])]),a(":"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("msub",null,[s("mi",null,"Y"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"2")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"3")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"Y"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X\\rightarrow Y_1Y_2Y_3...Y_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"3")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mtext",null,"可以用"),s("msub",null,[s("mi",null,"Y"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"2")]),s("msub",null,[s("mi",null,"Y"),s("mn",null,"3")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"Y"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X\\text{可以用}Y_1Y_2Y_3...Y_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"可以用")]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"3")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"Y"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("来代替,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"X\\rightarrow \\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])]),a("表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X")]),s("annotation",{encoding:"application/x-tex"},"X")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])])]),a("可以用空串代替,这种"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a("被称为BNF表示法")]),s("li",null,[a("简化表示: "),s("ol",null,[s("li",null,"除非特殊说明,否则第一个产生式的左部就是初始符号"),s("li",null,"用小写字母表示终止符号"),s("li",null,[a("用大写字符或者"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"<"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",null,">")]),s("annotation",{encoding:"application/x-tex"},"<...>")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mrel"},"<"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.5782em","vertical-align":"-0.0391em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},">")])])]),a("表示非终止符号")]),s("li",null,[a("如果左部都为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A")]),s("annotation",{encoding:"application/x-tex"},"A")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A")])])]),a("的一系列产生式"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mo",{separator:"true"},","),s("mtext",null,"  ")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha_2,\\;...,\\;A\\rightarrow \\alpha_n,\\;")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})])])]),a("可以简写为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha_1 | \\alpha _2|...|\\alpha_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])])])]),s("li",null,"特别注意:")],-1),as=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("msup",null,[s("mi",null,"a"),s("mo",null,"∗")]),s("mi",null,"b"),s("mtext",null,"(错误写法,没有Kleene闭包)")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"b")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} S\\rightarrow a^*b \\text{(错误写法,没有Kleene闭包)}\\\\ S\\rightarrow Ab\\\\ A\\rightarrow Aa|\\varepsilon \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"错误写法,没有"),s("span",{class:"mord"},"Kleene"),s("span",{class:"mord cjk_fallback"},"闭包"),s("span",{class:"mord"},")")])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"b")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ls=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"a"),s("mo",{stretchy:"false"},"("),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mtext",null,"错误,没有括号"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mi",null,"a"),s("mi",null,"X")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"X"),s("mo",null,"→"),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} S\\rightarrow a(b|c)(错误,没有括号)\\\\ S\\rightarrow aX\\\\ X\\rightarrow b|c \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord cjk_fallback"},"错误,没有括号"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ts=s("ul",null,[s("li",null,[a("左递归:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mo",{stretchy:"false"},"("),s("mi",null,"l"),s("mi",null,"e"),s("mi",null,"f"),s("mi",null,"t"),s("mtext",null,"  "),s("mi",null,"r"),s("mi",null,"e"),s("mi",null,"c"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"s"),s("mi",null,"i"),s("mi",null,"v"),s("mi",null,"e"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A \\rightarrow A\\alpha|\\beta\\;(left\\;recursive)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"rec"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"rs"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"v"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mclose"},")")])])]),a("可表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mi",null,"α"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"β"),s("mi",null,"α"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},".")]),s("annotation",{encoding:"application/x-tex"},"\\beta ,\\;\\beta \\alpha,\\; \\beta \\alpha \\alpha...")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"αα"),s("span",{class:"mord"},"...")])])]),a("即有推导"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"β"),s("msup",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mo",{stretchy:"false"},"("),s("mi",null,"n"),s("mo",null,"="),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A\\Rightarrow^*\\beta \\alpha^n(n=0,1,2,...)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},")")])])]),a("在EBNF中可表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow\\beta \\{\\alpha \\}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},"}")])])])]),s("li",null,[a("右递归:"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"A"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mo",{stretchy:"false"},"("),s("mi",null,"r"),s("mi",null,"i"),s("mi",null,"g"),s("mi",null,"h"),s("mi",null,"t"),s("mtext",null,"  "),s("mi",null,"r"),s("mi",null,"e"),s("mi",null,"c"),s("mi",null,"u"),s("mi",null,"r"),s("mi",null,"s"),s("mi",null,"i"),s("mi",null,"v"),s("mi",null,"e"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A \\rightarrow \\alpha A|\\beta\\;(right\\;recursive)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"r"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"g"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"rec"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal"},"rs"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03588em"}},"v"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mclose"},")")])])]),a("可表示"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"α"),s("mi",null,"β"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"α"),s("mi",null,"β"),s("mi",null,"β"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},".")]),s("annotation",{encoding:"application/x-tex"},"\\beta,\\; \\alpha \\beta,\\; \\alpha \\beta \\beta...")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"ββ"),s("span",{class:"mord"},"...")])])]),a("即有推导"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("msup",null,[s("mi",null,"α"),s("mi",null,"n")]),s("mi",null,"β"),s("mo",{stretchy:"false"},"("),s("mi",null,"n"),s("mo",null,"="),s("mn",null,"0"),s("mo",{separator:"true"},","),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"A\\Rightarrow^* \\alpha^n \\beta(n=0,1,2,...)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6644em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])])])])])]),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},"0"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},")")])])]),a("在EBNF中可表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",{stretchy:"false"},"}"),s("mi",null,"β")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\{\\alpha \\}\\beta")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},"}"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β")])])])]),s("li",null,"结合性")],-1),ns=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"}"),s("mtext",null,"(左结合性)")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"p"),s("mo",null,"→"),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"["),s("mi",null,"a"),s("mi",null,"d"),s("mi",null,"d"),s("mi",null,"o"),s("mi",null,"p"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"m"),s("mo",{stretchy:"false"},"]"),s("mtext",null,"(右结合性)")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} exp\\rightarrow exp\\; addop\\; term|term\\\\ exp\\rightarrow term\\{addop\\;term\\}\\text{(左结合性)}\\\\ exp\\rightarrow term[addop \\; term]\\text{(右结合性)} \\end{array} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mclose"},"}"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"左结合性"),s("span",{class:"mord"},")")])])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mopen"},"["),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"dd"),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mclose"},"]"),s("span",{class:"mord text"},[s("span",{class:"mord"},"("),s("span",{class:"mord cjk_fallback"},"右结合性"),s("span",{class:"mord"},")")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ms=s("ul",null,[s("li",null,"中括号表示其中的符号出现0次或1次,大括号表示0次至无数次")],-1),es=s("h2",{id:"推导-derivation-与规约-reduction",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#推导-derivation-与规约-reduction","aria-hidden":"true"},"#"),a(" 推导(Derivation)与规约(Reduction)")],-1),is=s("ul",null,[s("li",null,"如果能用一步步推导从初始符号得到需要验证的式子,那么式子就是符合规则的"),s("li",null,"推导就是不断用产生式的右部来替换一个非终止符"),s("li",null,[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")])]),s("annotation",{encoding:"application/x-tex"},"\\Rightarrow^*")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])])]),a("表示多步推导")]),s("li",null,"由终止符号构成的串称为句子(sentence),由非终止符号构成的串是句型(sentential form)"),s("li",null,[a("以S为开始符号的CFG构成的语言:"),s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"L"),s("mo",{stretchy:"false"},"("),s("mi",null,"G"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"s"),s("mo",null,"∈"),s("msubsup",null,[s("mi",null,"V"),s("mi",null,"T"),s("mo",null,"∗")]),s("mi",{mathvariant:"normal"},"∣"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"e"),s("mtext",null,"  "),s("mi",null,"e"),s("mi",null,"x"),s("mi",null,"i"),s("mi",null,"s"),s("mi",null,"t"),s("mi",null,"s"),s("mtext",null,"  "),s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"s"),s("mtext",null,"  "),s("mi",null,"o"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"G"),s("mo",{stretchy:"false"},"}")]),s("annotation",{encoding:"application/x-tex"}," L(G)=\\{s\\in V_T^*|\\;there\\;exists\\;S\\Rightarrow^*s\\;of\\; G\\} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-2.453em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])]),s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.247em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"ere"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mclose"},"}")])])])])])])],-1),rs=s("h3",{id:"语法树",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#语法树","aria-hidden":"true"},"#"),a(" 语法树")],-1),ps=s("ul",null,[s("li",null,"根节点是开始符号"),s("li",null,"内部节点是非终止符号"),s("li",null,[a("叶子节点是终止符号或者"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"},"\\varepsilon")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])])]),s("li",null,[a("如果节点A有子节点"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"X_1,X_2,...,X_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a("则意为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mi",null,"N")])]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow X_1X_2...X_N")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])]),s("li",null,"最终的叶子节点连起来就是一个句子"),s("li",null,"不同的推导会得到不同的树,但是可能会有相同的结果。")],-1),cs=s("h3",{id:"最左推导-leftmost-derivation前缀推导",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#最左推导-leftmost-derivation前缀推导","aria-hidden":"true"},"#"),a(" 最左推导(LeftMost Derivation前缀推导)")],-1),hs=s("ul",null,[s("li",null,"总是对句型中最左侧的非终止符号进行一次推导"),s("li",null,"从开始符号推导到结果,被称为Top-down")],-1),os=s("h3",{id:"最右推导-rightmost-derivation",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#最右推导-rightmost-derivation","aria-hidden":"true"},"#"),a(" 最右推导(RightMost Derivation)")],-1),gs=s("ul",null,[s("li",null,[a("从结果反向推回开始符号,这个过程被称为规约"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"s"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"S")]),s("annotation",{encoding:"application/x-tex"},"s\\Rightarrow^*S")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6887em"}}),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S")])])])]),s("li",null,"等价于对语法树进行后序遍历的逆过程"),s("li",null,"最右推导的能力比最左推导要强")],-1),us=l('

抽象语法树

语法树与抽象语法树
语法树与抽象语法树
  • 比起语法树,省略了部分细节,带来了更好的语法抽象,对于后续编译阶段是一个更好的数据结构
  • 它反映了源码token序列的一个抽象,比语法树更高效

歧义(Ambiguity)

  • 对于一个CFG,同样的输入可能有不同的解析 语法树歧义.png

解决方法

  • 消除歧义(Disambiguity rule):不改变文法,列举所有可能造成歧义的情况并进行消除,不现实的
  • 文法重写:改变文法,进行同义转换:(添加优先级,添加关联性)
',7),ds=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"E"),s("mo",null,"→"),s("mi",null,"E"),s("mo",null,"−"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"E"),s("mo",null,"×"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mo",{stretchy:"false"},"("),s("mi",null,"E"),s("mo",{stretchy:"false"},")"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"i"),s("mtext",null,"  "),s("mo",null,"⇒"),s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"E"),s("mo",null,"→"),s("mi",null,"E"),s("mo",null,"−"),s("mi",null,"E"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"T")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"T"),s("mo",null,"→"),s("mi",null,"T"),s("mo",null,"×"),s("mi",null,"T"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"F")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"E"),s("mo",{stretchy:"false"},")"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"i")])])])])])]),s("annotation",{encoding:"application/x-tex"}," E\\rightarrow E-E|E \\times E|(E)|i\\;\\Rightarrow \\begin{array}{c} E\\rightarrow E-E|T\\\\ T\\rightarrow T\\times T|F\\\\ F\\rightarrow(E)|i \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7667em","vertical-align":"-0.0833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"×"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mclose"},")"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"⇒"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.6em","vertical-align":"-1.55em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.05em"}},[s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"−"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T")])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"×"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"T"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"E"),s("span",{class:"mclose"},")"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.55em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),ys=l('

消除歧义1消除歧义2消除歧义3

语法分析算法(parsing)

Top-Down(Leftmost) parsing

  • 本质上是一个图搜索问题,在树上搜索,查找能否获得一个与输入sentence匹配的路径

回溯算法(Backtracking)

',5),vs=s("ul",null,[s("li",null,"用BFS:进行图遍历搜索,复杂,时间复杂度过高,产生大量无用分支,时间和空间的最差情况都是指数级别。现代编译器中不被使用"),s("li",null,[a("剪枝:由终止符号做前缀时,如果无法与输入的前缀匹配则剪枝。("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("mi",null,"b"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",null,"→"),s("mi",null,"c"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a"),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"Aa|Ab|c\\rightarrow caaaaa")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"b"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"aaaaa")])])]),a("时,无法剪枝,因为前缀一直是非终止符号)")]),s("li",null,[a("用DFS:有比BFS更好的空间复杂度和时间复杂度,但是无法匹配("),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"c"),s("mo",null,"→"),s("mi",null,"c")]),s("annotation",{encoding:"application/x-tex"},"Aa|c\\rightarrow c")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"c")])])]),a(",因为会一直循环)")])],-1),xs=s("h3",{id:"预测推导-predictive-parsing",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#预测推导-predictive-parsing","aria-hidden":"true"},"#"),a(" 预测推导(predictive parsing)")],-1),ws=s("ul",null,[s("li",null,"Idea:利用先行词(lokkahead tokens),也就是上面提到过的终止符前缀"),s("li",null,"两种分析方法:")],-1),bs=s("ol",null,[s("li",null,"递归下降分析(Recursive-descent parsing)"),s("li",null,"LL(1)分析")],-1),ks=s("h4",{id:"预测分析的概念",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#预测分析的概念","aria-hidden":"true"},"#"),a(" 预测分析的概念")],-1),fs=s("ul",null,[s("li",null,"从输入串和文法的开始符号开始分析"),s("li",null,"可以从当前输入的token(s)唯一确定下一个要使用的产生式"),s("li",null,[a("预测分析文法包括LL(k)文法,其中L表示从左向右扫描,L表示最左推导,k表示“需要"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",null,"≤"),s("mi",null,"k")]),s("annotation",{encoding:"application/x-tex"},"\\le k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7719em","vertical-align":"-0.136em"}}),s("span",{class:"mrel"},"≤"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.03148em"}},"k")])])]),a("个先行词用于预测 ”")]),s("li",null,"LL(1)文法是常用的,也不完全常用")],-1),zs=s("h5",{id:"lookahead-sets",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#lookahead-sets","aria-hidden":"true"},"#"),a(" Lookahead Sets")],-1),_s=s("h6",{id:"first-sets-具体计算看讲义和书",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#first-sets-具体计算看讲义和书","aria-hidden":"true"},"#"),a(" First Sets(具体计算看讲义和书)")],-1),Ms=s("ul",null,[s("li",null,"定义")],-1),As=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")"),s("mtext",null,"是一个文法")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"β"),s("mo",null,"∈"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",null,"∪"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("msup",null,[s("mo",{stretchy:"false"},")"),s("mo",null,"∗")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"β"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"α"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},"}")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"i"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"β"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"ε"),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"n"),s("mtext",null,"  "),s("mi",null,"ε"),s("mo",null,"∈"),s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"β"),s("mo",{stretchy:"false"},")")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} G=(V_N,V_T,P,S)\\text{是一个文法}\\\\ \\beta\\in(V_N\\cup V_T)^*\\\\ FIRST(\\beta)=\\{\\alpha\\in V_T|\\beta\\Rightarrow^*a...\\}\\\\ if\\;\\beta\\Rightarrow^*\\varepsilon\\;then\\;\\varepsilon\\in FIRST(\\beta) \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.8em","vertical-align":"-2.15em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.65em"}},[s("span",{style:{top:"-4.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是一个文法")])])]),s("span",{style:{top:"-3.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∪"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},[s("span",{class:"mclose"},")"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},"}")])]),s("span",{style:{top:"-1.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"ε"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mclose"},")")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.15em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Ls=l('
  • 计算

First()计算 3First()计算 4First()计算 5

//Todo 提取简练笔记

Follow Sets
  • 定义:
',5),Ss=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"G"),s("mo",null,"="),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mo",{separator:"true"},","),s("mi",null,"P"),s("mo",{separator:"true"},","),s("mi",null,"S"),s("mo",{stretchy:"false"},")"),s("mtext",null,"是一个文法")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"N")])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mo",{stretchy:"false"},"{"),s("mi",null,"a"),s("mo",null,"∈"),s("msub",null,[s("mi",null,"V"),s("mi",null,"T")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",null,"A"),s("mi",null,"a"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{stretchy:"false"},"}"),s("mo",{separator:"true"},",")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"i"),s("mi",null,"f"),s("mtext",null,"  "),s("mi",null,"S"),s("mo",null,"⇒"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",null,"A"),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("mi",null,"t"),s("mi",null,"h"),s("mi",null,"e"),s("mi",null,"n"),s("mtext",null,"  "),s("mi",{mathvariant:"normal"},"$"),s("mo",null,"∈"),s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"$"),s("mtext",null,"是用来标记输入的终止的符号")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} G=(V_N,V_T,P,S)\\text{是一个文法}\\\\A\\in V_N\\\\ FOLLOW(A)=\\{a\\in V_T|S\\Rightarrow^*...Aa...\\},\\\\ if\\;S\\Rightarrow...A,\\;then\\;\\$\\in FOLLOW(A)\\\\ \\$是用来标记输入的终止的符号 \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"G"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"P"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mclose"},")"),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"是一个文法")])])]),s("span",{style:{top:"-4.21em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.10903em"}},"N")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])]),s("span",{style:{top:"-3.01em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mopen"},"{"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.22222em"}},"V"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3283em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.2222em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.13889em"}},"T")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.6887em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord"},"..."),s("span",{class:"mclose"},"}"),s("span",{class:"mpunct"},",")])]),s("span",{style:{top:"-1.81em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"i"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"⇒"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord mathnormal"},"h"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},"$"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∈"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")")])]),s("span",{style:{top:"-0.61em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},"$"),s("span",{class:"mord cjk_fallback"},"是用来标记输入的终止的符号")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Rs=s("ul",null,[s("li",null,[a("计算: "),s("img",{src:u,alt:"Follow()计算 2.png",loading:"lazy"})])],-1),Vs=s("h5",{id:"可空的非终止符-nullable-nonterminal",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#可空的非终止符-nullable-nonterminal","aria-hidden":"true"},"#"),a(" 可空的非终止符(nullable nonterminal)")],-1),Fs=s("ul",null,[s("li",null,[a("定义:"),s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"S"),s("msup",null,[s("mo",null,"⇒"),s("mo",null,"∗")]),s("mi",null,"ε")]),s("annotation",{encoding:"application/x-tex"}," S\\Rightarrow^*\\varepsilon ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7387em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},[s("span",{class:"mrel"},"⇒"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7387em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mbin mtight"},"∗")])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"ε")])])])])])])],-1),Ts=s("p",null,"则称S是一个可空的非终止符",-1),Ns=s("ul",null,[s("li",null,[a("计算: "),s("img",{src:d,alt:"nullble set计算 2.png",loading:"lazy"})])],-1),Xs=s("h5",{id:"判定ll-1-文法",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#判定ll-1-文法","aria-hidden":"true"},"#"),a(" 判定LL(1)文法")],-1),Os=s("ul",null,[s("li",null,"计算每个可空的非终止符"),s("li",null,[a("计算产生式右侧所有的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"α"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"FIRST(\\alpha)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mclose"},")")])])]),a("并验证其两两交集是否为空")]),s("li",null,[a("计算(1)中算出的非终止符的"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"FOLLOW(A)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")")])])]),a("并验证"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"F"),s("mi",null,"I"),s("mi",null,"R"),s("mi",null,"S"),s("mi",null,"T"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"∩"),s("mi",null,"F"),s("mi",null,"O"),s("mi",null,"L"),s("mi",null,"L"),s("mi",null,"O"),s("mi",null,"W"),s("mo",{stretchy:"false"},"("),s("mi",null,"A"),s("mo",{stretchy:"false"},")"),s("mo",null,"="),s("mi",{mathvariant:"normal"},"∅")]),s("annotation",{encoding:"application/x-tex"},"FIRST(A)\\cap FOLLOW(A)=\\varnothing")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"F"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"I"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"RST"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∩"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"FO"),s("span",{class:"mord mathnormal"},"LL"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"O"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.13889em"}},"W"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6633em","vertical-align":"-0.0817em"}}),s("span",{class:"mord amsrm"},"∅")])])]),s("img",{src:y,alt:"判断LL(1)示例.png",loading:"lazy"})])],-1),js=s("h5",{id:"非ll-1-到ll-1",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#非ll-1-到ll-1","aria-hidden":"true"},"#"),a(" 非LL(1)到LL(1)")],-1),Es=s("ul",null,[s("li",null,"两种简单的非LL(1)情形:")],-1),Bs=s("ol",null,[s("li",null,[a("左因子,例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"β"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("mi",null,"r")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow \\alpha \\beta|\\alpha r")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"r")])])]),a(",这是两个产生式的简写,其产生式交集为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"\\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a(",改写方法为")])],-1),Gs=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"α"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("mtext",null,"  "),s("mtext",null,"重写为"),s("mo",null,":")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"α"),s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")]),s("mspace",{width:"1em"}),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")])])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} A\\rightarrow\\alpha\\beta_1|\\alpha\\beta_2|...|\\alpha\\beta_n\\;重写为:\\\\ A\\rightarrow\\alpha A{'}\\quad A^{'}\\rightarrow\\beta_1|\\beta_2|...|\\beta_n \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"2.5025em","vertical-align":"-1.0012em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.5012em"}},[s("span",{style:{top:"-3.6612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord cjk_fallback"},"重写为"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},":")])]),s("span",{style:{top:"-2.3588em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7519em"}},[s("span",{style:{top:"-3.063em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.0012em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Is=s("ol",{start:"2"},[s("li",null,[a("左递归,包括直接左递归和间接左递归,例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"β")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow A \\beta")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β")])])]),a("和"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"B"),s("mi",null,"β"),s("mspace",{width:"1em"}),s("mi",null,"B"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α")]),s("annotation",{encoding:"application/x-tex"},"A\\rightarrow B \\beta\\quad B\\rightarrow A\\alpha")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"Bβ"),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05017em"}},"B"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α")])])]),a(" 改写方法为")])],-1),Ys=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.16em",columnalign:"center",columnspacing:"1em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("mi",null,"α"),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"β"),s("mtext",null,"  "),s("mtext",null,"重写为:")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"β"),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mtext",null,"  "),s("mo",{separator:"true"},","),s("mtext",null,"  "),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("mi",null,"α"),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mtext",null,"一般情况为:")])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"A"),s("msub",null,[s("mi",null,"α"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("mtext",null,"  "),s("mtext",null,"重写为:")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"β"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mn",null,"2")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"β"),s("mi",null,"n")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])])])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"false"},[s("mrow",null,[s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mo",null,"→"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mn",null,"1")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"∣"),s("msub",null,[s("mi",null,"α"),s("mi",null,"m")]),s("msup",null,[s("mi",null,"A"),s("msup",null,[s("mrow"),s("mo",{mathvariant:"normal",lspace:"0em",rspace:"0em"},"′")])]),s("mi",{mathvariant:"normal"},"∣"),s("mi",null,"ε")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{array}{c} A\\rightarrow A \\alpha|\\beta\\;\\text{重写为:}\\\\ A\\rightarrow\\beta A^{'}\\; ,\\;A^{'}\\rightarrow\\alpha A^{'}|\\varepsilon\\\\ \\text{一般情况为:}\\\\ A\\rightarrow A \\alpha_1|A \\alpha_2|...|A \\alpha_m|\\beta_1|\\beta_2|...|\\beta_n\\; \\text{重写为:}\\\\ A\\rightarrow \\beta_1 A^{'}|\\beta_2 A^{'}|...|\\beta_n A^{'}\\\\ A^{'}\\rightarrow\\alpha_1 A^{'}|\\alpha_1 A^{'}|...|\\alpha_m A^{'}|\\varepsilon \\end{array}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"7.5074em","vertical-align":"-3.5037em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"arraycolsep",style:{width:"0.5em"}}),s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.0037em"}},[s("span",{style:{top:"-6.1637em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"重写为:")])])]),s("span",{style:{top:"-4.8612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])]),s("span",{style:{top:"-3.6612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"一般情况为:")])])]),s("span",{style:{top:"-2.4612em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord cjk_fallback"},"重写为:")])])]),s("span",{style:{top:"-1.1588em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.05278em"}},"β"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0528em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])])])]),s("span",{style:{top:"0.1437em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣...∣"),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.0037em"}},"α"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0037em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"A"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.9425em"}},[s("span",{style:{top:"-2.9425em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.5795em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},[s("span"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8278em"}},[s("span",{style:{top:"-2.931em","margin-right":"0.0714em"}},[s("span",{class:"pstrut",style:{height:"2.5em"}}),s("span",{class:"sizing reset-size3 size1 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mtight"},"′")])])])])])])])])])])])])])])])]),s("span",{class:"mord"},"∣"),s("span",{class:"mord mathnormal"},"ε")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.5037em"}},[s("span")])])])]),s("span",{class:"arraycolsep",style:{width:"0.5em"}})])])])])])])],-1),Ps=l(`
  • 要注意:将这两者进行改写后并不能保证改写后的文法是LL(1),仍需要再进行验证

递归下降

输入
  • 非终止符号递归调用,终止符号匹配
int main(){
  Token token = getNextToken();
  S();/*S is the start symbol*/
  if(token!='$') throw error;
diff --git "a/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-753ca7bc.js" "b/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-97c404f2.js"
similarity index 99%
rename from "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-753ca7bc.js"
rename to "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-97c404f2.js"
index e7e8c0bb6..43f4a6a3a 100644
--- "a/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-753ca7bc.js"	
+++ "b/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-97c404f2.js"	
@@ -1,4 +1,4 @@
-import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as i,e as l,a as s,b as a}from"./app-75cd46e5.js";const e="/assets/属性示意图-dae7a309.png",m="/assets/无符号数和数字属性-b4eba4bc.png",p="/assets/变量声明和数据类型属性1-3dc8b30d.png",r="/assets/变量声明和数据类型属性2-1a2803ea.png",c="/assets/类型检查与表达式的类型属性-939cc17a.png",h="/assets/依赖图和计算顺序1-7a9da3cd.png",g="/assets/依赖图和计算顺序2-62081fec.png",o="/assets/依赖图和计算顺序3-3687fa04.png",u="/assets/综合属性定义-520dd103.png",d="/assets/继承属性示例1-99431e60.png",v="/assets/继承属性示例2-ff06d43b.png",y="/assets/属性计算dtype1-835e9c47.png",b="/assets/属性计算dtype2-48396766.png",z="/assets/属性计算dtype3-a13c76f0.png",_="/assets/属性计算dtype4-f339c86a.png",x="/assets/属性计算basenum1-4ae72a1d.png",f="/assets/属性计算basenum2-7641d49e.png",k="/assets/属性计算basenum3-c5e4a8fc.png",X="/assets/属性计算basenum4-e762ce07.png",w="/assets/属性计算basenum5-8a613139.png",M="/assets/分析期属性计算例子-7455365c.png",L="/assets/递归下降计算属性1-6f0626f8.png",j="/assets/递归下降计算属性2-55a1a03a.png",R="/assets/递归下降计算属性3-e29f69c3.png",A="/assets/递归下降计算属性4-03d57233.png",S="/assets/LR分析计算属性1-2c55838c.png",C="/assets/LR分析计算属性2-2a4da3d8.png",T="/assets/LR分析计算属性继承属性1-30f6a713.png",D="/assets/LR分析计算属性继承属性2-cb33971a.png",E="/assets/符号表-dee749ff.png",q="/assets/声明的属性文法-e4243e45.png",P="/assets/statement的属性文法4-0ba27082.png",V="/assets/statement的属性文法3-e3862906.png",B="/assets/statement的属性文法1-3b757564.png",G="/assets/statement的属性文法2-9cd2e9b0.png",I={},N=l('

Chapter4 语义分析

目录

介绍

  • 语义分析核心是类型检查(Type check)和作用域检查(Scope check)
  • 语义通过属性的值来刻画
  • 通过一系列属性等式来进行计算,按照一定的顺序进行计算

Recursive AST Walk

  • 一种语义分析的实现方法,本书暂时不表

Attribute Grammars

语法制导的语法分析(Syntax-Directed Semantics Analysis )

  • 又称SDS、SDT、SDD
  • 属性是附着在文法符号上的

属性(Attribute)

',10),F=s("ul",null,[s("li",null,[a("CFG中的所有文法符号"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X")]),s("annotation",{encoding:"application/x-tex"},"X")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])])]),a("都用属性以描述,把某个属性"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a(" 表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mi",{mathvariant:"normal"},"."),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"X.a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mord"},"."),s("span",{class:"mord mathnormal"},"a")])])])])],-1),W=s("h5",{id:"属性等式-attribute-equation",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#属性等式-attribute-equation","aria-hidden":"true"},"#"),a(" 属性等式(Attribute Equation)")],-1),H=s("ul",null,[s("li",null,"又叫语义规则(Semantic Rule)"),s("li",null,[a("给定属性 集合"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mtext",null,","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"a_1 ,... ,a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},","),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])]),s("li",null,[a("对于每个语法规则"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"X_0→X_1X_2...X_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(",每个语法符号"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")])]),s("annotation",{encoding:"application/x-tex"},"X_i")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 的属性 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 的值与规则中其他符号的属性值相关")]),s("li",null,"属性等式就是如下格式")],-1),J=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")]),s("mo",null,"="),s("msub",null,[s("mi",null,"f"),s("mrow",null,[s("mi",null,"i"),s("mi",null,"j")])]),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"}," X_i.a_j = f_{ij} (X_0 .a_1,...,X_0.a_k,X_1 .a_1,... ,X_1.a_k,...,X_n.a_1,...,X_n.a_k) ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0361em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.1076em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"ij")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])])],-1),K=l('
属性文法
  • 通常是以下格式:
Grammar RuleSemantic Rules
Rule1Associated attribute equations
...
Rule nAssociated attribute equations
无符号数和数字属性

[属性示意图.png][无符号数和数字属性.png]

变量声明和数据类型属性

[变量声明和数据类型属性1.png][变量声明和数据类型属性2.png]

类型检查与表达式的类型属性
[类型检查与表达式的类型属性.png]
[类型检查与表达式的类型属性.png]

属性计算

  • 属性计算可以在分析树构建完成后进行,也可以在分析的过程中同时进行。
属性计算的算法
  1. 依赖图的生成和计算顺序的确定

    • 每一个属性等式对应一个依赖图(有向图,边代表属性值计算的计算依赖顺序)
    • 多个属性等式构成一个组合依赖图,通过这个附着在抽象语法树或者分析树的依赖图可以对计算次序进行计算
  2. 综合(Synthesized)属性和继承(Inherited)属性

    • 综合属性:属性由子节点属性决定(如果所有属性都是综合属性,那这个文法是一个综合属性文法S-attributed grammar),在bottom-up的过程中,可以边分析边计算属性(从叶子节点生成父节点)
    • 继承属性:属性由兄弟节点或兄弟和子节点属性决定(不是综合就是继承)
  3. 在分析的过程中计算属性

    • 属性计算的困难:
      • 属性语法是一种抽象规范,属性方程可以按任意顺序编写而不影响其有效性,它们不指定属性计算的顺序
      • 问题主要在于找到属性计算和分配的顺序,以确保每次计算中使用的所有属性值在执行每次计算时都可用
      • 属性方程本身表明属性计算的顺序约束。 我们将使用依赖图来明确顺序约束
依赖图和计算顺序
',14),O=s("ul",null,[s("li",null,[a("依赖图: "),s("ul",null,[s("li",null,[a("每个符号的每个属性 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 对应一个节点")]),s("li",null,[a("对于每个属性方程 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")]),s("mo",null,"="),s("msub",null,[s("mi",null,"f"),s("mrow",null,[s("mi",null,"i"),s("mi",null,"j")])]),s("mo",{stretchy:"false"},"("),s("mo",null,"…"),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j=f_{ij}(…,X_m.a_k,…)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0361em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.1076em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"ij")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mclose"},")")])])]),a(" 都有一条从右侧的每个节点 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"X_m.a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 到节点 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 的边(表示 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 对 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"X_m.a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 的依赖关系)")])])])],-1),Q=l('

[依赖图和计算顺序1.png][依赖图和计算顺序2.png]

  • 我们通常把依赖图直接叠加绘制在分析树上
[依赖图和计算顺序3.png]
[依赖图和计算顺序3.png]
综合属性
',4),U=s("ul",null,[s("li",null,"如果解析树中的所有依赖项都从子级指向父级,那么就是综合属性。"),s("li",null,[a("等价地,如果给定语法规则 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mo",null,"…"),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"A → X_1X_2…X_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(",左侧带有 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a(" 的"),s("em",null,"唯一"),a("(不能存在另一个可能为从非子节点获取属性的属性方程)关联属性方程的形式为以下所示,那么"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a("就是综合属性")])],-1),Y=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",{mathvariant:"normal"},"."),s("mi",null,"a"),s("mo",null,"="),s("mi",null,"f"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"x"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"}," A.a=f(x_1.a_1,..X_1.a_k,…,X_n.a_1,…X_n.a_k) ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},"."),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"x"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},".."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])])],-1),Z=l('
[综合属性定义.png]
[综合属性定义.png]
综合属性文法(S-attributed grammar)
  • 如果文法中所有属性都是综合属性,那么这就是一个综合属性文法。
  • 对综合属性的计算可以在分析树的基础上,通过一次自顶向下或者后续遍历完成计算
procedure PostEval(T:treenode)
+import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as n,c as i,e as l,a as s,b as a}from"./app-9d555359.js";const e="/assets/属性示意图-dae7a309.png",m="/assets/无符号数和数字属性-b4eba4bc.png",p="/assets/变量声明和数据类型属性1-3dc8b30d.png",r="/assets/变量声明和数据类型属性2-1a2803ea.png",c="/assets/类型检查与表达式的类型属性-939cc17a.png",h="/assets/依赖图和计算顺序1-7a9da3cd.png",g="/assets/依赖图和计算顺序2-62081fec.png",o="/assets/依赖图和计算顺序3-3687fa04.png",u="/assets/综合属性定义-520dd103.png",d="/assets/继承属性示例1-99431e60.png",v="/assets/继承属性示例2-ff06d43b.png",y="/assets/属性计算dtype1-835e9c47.png",b="/assets/属性计算dtype2-48396766.png",z="/assets/属性计算dtype3-a13c76f0.png",_="/assets/属性计算dtype4-f339c86a.png",x="/assets/属性计算basenum1-4ae72a1d.png",f="/assets/属性计算basenum2-7641d49e.png",k="/assets/属性计算basenum3-c5e4a8fc.png",X="/assets/属性计算basenum4-e762ce07.png",w="/assets/属性计算basenum5-8a613139.png",M="/assets/分析期属性计算例子-7455365c.png",L="/assets/递归下降计算属性1-6f0626f8.png",j="/assets/递归下降计算属性2-55a1a03a.png",R="/assets/递归下降计算属性3-e29f69c3.png",A="/assets/递归下降计算属性4-03d57233.png",S="/assets/LR分析计算属性1-2c55838c.png",C="/assets/LR分析计算属性2-2a4da3d8.png",T="/assets/LR分析计算属性继承属性1-30f6a713.png",D="/assets/LR分析计算属性继承属性2-cb33971a.png",E="/assets/符号表-dee749ff.png",q="/assets/声明的属性文法-e4243e45.png",P="/assets/statement的属性文法4-0ba27082.png",V="/assets/statement的属性文法3-e3862906.png",B="/assets/statement的属性文法1-3b757564.png",G="/assets/statement的属性文法2-9cd2e9b0.png",I={},N=l('

Chapter4 语义分析

目录

介绍

  • 语义分析核心是类型检查(Type check)和作用域检查(Scope check)
  • 语义通过属性的值来刻画
  • 通过一系列属性等式来进行计算,按照一定的顺序进行计算

Recursive AST Walk

  • 一种语义分析的实现方法,本书暂时不表

Attribute Grammars

语法制导的语法分析(Syntax-Directed Semantics Analysis )

  • 又称SDS、SDT、SDD
  • 属性是附着在文法符号上的

属性(Attribute)

',10),F=s("ul",null,[s("li",null,[a("CFG中的所有文法符号"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X")]),s("annotation",{encoding:"application/x-tex"},"X")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X")])])]),a("都用属性以描述,把某个属性"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a(" 表示为"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"X"),s("mi",{mathvariant:"normal"},"."),s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"X.a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"mord"},"."),s("span",{class:"mord mathnormal"},"a")])])])])],-1),W=s("h5",{id:"属性等式-attribute-equation",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#属性等式-attribute-equation","aria-hidden":"true"},"#"),a(" 属性等式(Attribute Equation)")],-1),H=s("ul",null,[s("li",null,"又叫语义规则(Semantic Rule)"),s("li",null,[a("给定属性 集合"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mtext",null,","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"a_1 ,... ,a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8778em","vertical-align":"-0.1944em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord cjk_fallback"},","),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])])]),s("li",null,[a("对于每个语法规则"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"X_0→X_1X_2...X_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"..."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(",每个语法符号"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")])]),s("annotation",{encoding:"application/x-tex"},"X_i")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 的属性 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 的值与规则中其他符号的属性值相关")]),s("li",null,"属性等式就是如下格式")],-1),J=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")]),s("mo",null,"="),s("msub",null,[s("mi",null,"f"),s("mrow",null,[s("mi",null,"i"),s("mi",null,"j")])]),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"0")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"}," X_i.a_j = f_{ij} (X_0 .a_1,...,X_0.a_k,X_1 .a_1,... ,X_1.a_k,...,X_n.a_1,...,X_n.a_k) ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0361em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.1076em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"ij")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"0")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},"..."),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])])],-1),K=l('
属性文法
  • 通常是以下格式:
Grammar RuleSemantic Rules
Rule1Associated attribute equations
...
Rule nAssociated attribute equations
无符号数和数字属性

[属性示意图.png][无符号数和数字属性.png]

变量声明和数据类型属性

[变量声明和数据类型属性1.png][变量声明和数据类型属性2.png]

类型检查与表达式的类型属性
[类型检查与表达式的类型属性.png]
[类型检查与表达式的类型属性.png]

属性计算

  • 属性计算可以在分析树构建完成后进行,也可以在分析的过程中同时进行。
属性计算的算法
  1. 依赖图的生成和计算顺序的确定

    • 每一个属性等式对应一个依赖图(有向图,边代表属性值计算的计算依赖顺序)
    • 多个属性等式构成一个组合依赖图,通过这个附着在抽象语法树或者分析树的依赖图可以对计算次序进行计算
  2. 综合(Synthesized)属性和继承(Inherited)属性

    • 综合属性:属性由子节点属性决定(如果所有属性都是综合属性,那这个文法是一个综合属性文法S-attributed grammar),在bottom-up的过程中,可以边分析边计算属性(从叶子节点生成父节点)
    • 继承属性:属性由兄弟节点或兄弟和子节点属性决定(不是综合就是继承)
  3. 在分析的过程中计算属性

    • 属性计算的困难:
      • 属性语法是一种抽象规范,属性方程可以按任意顺序编写而不影响其有效性,它们不指定属性计算的顺序
      • 问题主要在于找到属性计算和分配的顺序,以确保每次计算中使用的所有属性值在执行每次计算时都可用
      • 属性方程本身表明属性计算的顺序约束。 我们将使用依赖图来明确顺序约束
依赖图和计算顺序
',14),O=s("ul",null,[s("li",null,[a("依赖图: "),s("ul",null,[s("li",null,[a("每个符号的每个属性 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 对应一个节点")]),s("li",null,[a("对于每个属性方程 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")]),s("mo",null,"="),s("msub",null,[s("mi",null,"f"),s("mrow",null,[s("mi",null,"i"),s("mi",null,"j")])]),s("mo",{stretchy:"false"},"("),s("mo",null,"…"),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j=f_{ij}(…,X_m.a_k,…)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.0361em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.1076em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"ij")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])]),s("span",{class:"mopen"},"("),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mclose"},")")])])]),a(" 都有一条从右侧的每个节点 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"X_m.a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 到节点 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 的边(表示 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"i")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"j")])]),s("annotation",{encoding:"application/x-tex"},"X_i.a_j")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.9694em","vertical-align":"-0.2861em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"i")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3117em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.05724em"}},"j")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.2861em"}},[s("span")])])])])])])])]),a(" 对 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("msub",null,[s("mi",null,"X"),s("mi",null,"m")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")])]),s("annotation",{encoding:"application/x-tex"},"X_m.a_k")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(" 的依赖关系)")])])])],-1),Q=l('

[依赖图和计算顺序1.png][依赖图和计算顺序2.png]

  • 我们通常把依赖图直接叠加绘制在分析树上
[依赖图和计算顺序3.png]
[依赖图和计算顺序3.png]
综合属性
',4),U=s("ul",null,[s("li",null,"如果解析树中的所有依赖项都从子级指向父级,那么就是综合属性。"),s("li",null,[a("等价地,如果给定语法规则 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mo",null,"→"),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("msub",null,[s("mi",null,"X"),s("mn",null,"2")]),s("mo",null,"…"),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")])]),s("annotation",{encoding:"application/x-tex"},"A → X_1X_2…X_n")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8333em","vertical-align":"-0.15em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"2")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])])])])]),a(",左侧带有 "),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a(" 的"),s("em",null,"唯一"),a("(不能存在另一个可能为从非子节点获取属性的属性方程)关联属性方程的形式为以下所示,那么"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"a")]),s("annotation",{encoding:"application/x-tex"},"a")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"a")])])]),a("就是综合属性")])],-1),Y=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"A"),s("mi",{mathvariant:"normal"},"."),s("mi",null,"a"),s("mo",null,"="),s("mi",null,"f"),s("mo",{stretchy:"false"},"("),s("msub",null,[s("mi",null,"x"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"."),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"X"),s("mn",null,"1")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("mo",{separator:"true"},","),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mn",null,"1")]),s("mo",{separator:"true"},","),s("mo",null,"…"),s("msub",null,[s("mi",null,"X"),s("mi",null,"n")]),s("mi",{mathvariant:"normal"},"."),s("msub",null,[s("mi",null,"a"),s("mi",null,"k")]),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"}," A.a=f(x_1.a_1,..X_1.a_k,…,X_n.a_1,…X_n.a_k) ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal"},"A"),s("span",{class:"mord"},"."),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mopen"},"("),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"x"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},".."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3011em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},"1")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"minner"},"…"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal",style:{"margin-right":"0.07847em"}},"X"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.1514em"}},[s("span",{style:{top:"-2.55em","margin-left":"-0.0785em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight"},"n")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mord"},"."),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"a"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.3361em"}},[s("span",{style:{top:"-2.55em","margin-left":"0em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mathnormal mtight",style:{"margin-right":"0.03148em"}},"k")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.15em"}},[s("span")])])])])]),s("span",{class:"mclose"},")")])])])])],-1),Z=l('
[综合属性定义.png]
[综合属性定义.png]
综合属性文法(S-attributed grammar)
  • 如果文法中所有属性都是综合属性,那么这就是一个综合属性文法。
  • 对综合属性的计算可以在分析树的基础上,通过一次自顶向下或者后续遍历完成计算
procedure PostEval(T:treenode)
 begin 
  for each child C of T do 
  PostEval(C); 
diff --git "a/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-5ee35076.js" "b/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-70f2663e.js"
similarity index 99%
rename from "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-5ee35076.js"
rename to "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-70f2663e.js"
index df5f6f927..856672986 100644
--- "a/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-5ee35076.js"	
+++ "b/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-70f2663e.js"	
@@ -1,4 +1,4 @@
-import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as e,c as n,e as l,a as s,b as a}from"./app-75cd46e5.js";const m="/assets/TAC_Code1-35ac8d71.png",p="/assets/TAC_Instruction-8b0d754c.png",r="/assets/TAC_Code2-aa1bc821.png",c="/assets/TAC_Code3-a477aecc.png",i="/assets/TAC_Code4-e53853bd.png",o="/assets/综合属性语义规则1-f5877599.png",h="/assets/综合属性语义规则2-77f42c48.png",d="/assets/综合属性语义分析-bb529420.png",u="/assets/if结构-b90d7266.png",g="/assets/if-else结构-f40d0d05.png",y="/assets/while结构-914bee40.png",x="/assets/or结构-e0a6920c.png",v="/assets/and结构-c1865e2c.png",w="/assets/布尔表达式例子-fe16bc51.png",b="/assets/流程控制示例图-cb809c54.png",f="/assets/尾递归优化-a6197c93.png",_="/assets/代码移动-1080cf5e.png",k="/assets/删除-05da31a9.png",E="/assets/flowgraph-05647f1a.png",z="/assets/DAG1-b4ad6016.png",M="/assets/DAG2-2878e6f4.png",S="/assets/DAG3-8a5b9c83.png",T={},L=l('

Chapter5 代码生成

介绍

  • 代码生成取决于:源代码、目标系统体系结构、运行时环境
  • 代码生成可以被划分为三步:
  1. 生成中间代码(IR Iermediate code码)
  2. 生成某种汇编形式的代码,而不是真正的可执行代码
  3. 优化目标代码

中间代码

  • 以三地址码(TAC Three Address code)为例

生成三地址码

运算

[TAC_Code1.png]
[TAC_Code1.png]

变量赋值

[TAC_Instruction.png]
[TAC_Instruction.png]

布尔值

[TAC_Code2.png]
[TAC_Code2.png]

流程控制语句

[TAC_Code3.png][TAC_Code4.png]

三地址码的实现

  • 有四元组和三元组实现,一般都用四元组实现,因为利于后面进行进一步的优化

四元组实现

',18),A=s("ul",null,[s("li",null,[a("用"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mi",null,"o"),s("mi",null,"p"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"3"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"(op,operand1,operand2,operand3)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"3"),s("span",{class:"mclose"},")")])])]),a("来表示一个三地址指令,用"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",{mathvariant:"normal"},"_")]),s("annotation",{encoding:"application/x-tex"},"\\_")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em","vertical-align":"-0.31em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_")])])]),a("来表示缺省的操作数")]),s("li",null,[a("例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"="),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"∗"),s("mi",null,"x"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"m"),s("mi",null,"u"),s("mi",null,"l"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{separator:"true"},","),s("mi",null,"x"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"t"),s("mn",null,"2"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"t2=fact*x\\rightarrow (mul,fact,x,\\_ t2)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∗"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.06em","vertical-align":"-0.31em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mclose"},")")])])]),a(" ,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"l"),s("mi",null,"a"),s("mi",null,"b"),s("mi",null,"e"),s("mi",null,"l"),s("mtext",null,"  "),s("mi",null,"L"),s("mn",null,"2"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"l"),s("mi",null,"a"),s("mi",null,"b"),s("mo",{separator:"true"},","),s("mi",null,"L"),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"label\\;L2\\rightarrow (lab,L2,\\_,\\_)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"ab"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.06em","vertical-align":"-0.31em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"ab"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mclose"},")")])])])])],-1),C=s("h4",{id:"三元组实现",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#三元组实现","aria-hidden":"true"},"#"),a(" 三元组实现")],-1),I=s("ul",null,[s("li",null,"用指令的地址来替换掉一个返回值变量来压缩掉一个变量"),s("li",null,[a("例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"="),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"∗"),s("mi",null,"x"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mn",null,"4"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mi",null,"m"),s("mi",null,"u"),s("mi",null,"l"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{separator:"true"},","),s("mi",null,"x"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"t2=fact*x \\rightarrow (4)(mul,fact,x)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∗"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"4"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mclose"},")")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"="),s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mn",null,"5"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mi",null,"a"),s("mi",null,"s"),s("mi",null,"n"),s("mo",{separator:"true"},","),s("mo",{stretchy:"false"},"("),s("mn",null,"4"),s("mo",{stretchy:"false"},")"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"fact=t2\\rightarrow (5)(asn,(4),fact)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"5"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"4"),s("span",{class:"mclose"},")"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mclose"},")")])])])])],-1),G=l('

区别

  • 三元组比较高效,因为空间占用减少了,并且编译器不需要为临时变量生成名称
  • 三元组使用指令索引来表示临时值,那么它们的位置的任何移动都变得困难。 四元组更适合优化

生成三地址码的细节

综合属性

',4),D=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"exp"),s("mo",null,"→"),s("mtext",null,"id"),s("mo",null,"="),s("mtext",null,"exp"),s("mo",{fence:"false",stretchy:"true",minsize:"1.2em",maxsize:"1.2em"},"∣"),s("mtext",null,"aexp")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"aexp"),s("mo",null,"→"),s("mtext",null,"aexp+factor"),s("mo",null,"∣"),s("mtext",null,"factor")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"factor"),s("mo",null,"→"),s("mtext",null,"(exp)"),s("mo",null,"∣"),s("mtext",null,"num"),s("mo",null,"∣"),s("mtext",null,"id")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{exp}\\to\\text{id}=\\text{exp}\\big|\\text{aexp} \\\\ &\\text{aexp}\\to\\text{aexp+factor}\\mid\\text{factor} \\\\ &\\text{factor}\\to\\text{(exp)}\\mid\\text{num}\\mid\\text{id} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.51em","vertical-align":"-2.005em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.505em"}},[s("span",{style:{top:"-4.505em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3.005em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-1.505em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.005em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.505em"}},[s("span",{style:{top:"-4.655em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"exp")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"id")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"exp")]),s("span",{class:"mord"},[s("span",{class:"delimsizing mult"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.85em"}},[s("span",{style:{top:"-2.85em"}},[s("span",{class:"pstrut",style:{height:"3.2em"}}),s("span",{style:{width:"0.333em",height:"1.200em"}},[s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"0.333em",height:"1.200em",viewBox:"0 0 333 1200"},[s("path",{d:`M145 15 v585 v0 v585 c2.667,10,9.667,15,21,15 +import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{o as e,c as n,e as l,a as s,b as a}from"./app-9d555359.js";const m="/assets/TAC_Code1-35ac8d71.png",p="/assets/TAC_Instruction-8b0d754c.png",r="/assets/TAC_Code2-aa1bc821.png",c="/assets/TAC_Code3-a477aecc.png",i="/assets/TAC_Code4-e53853bd.png",o="/assets/综合属性语义规则1-f5877599.png",h="/assets/综合属性语义规则2-77f42c48.png",d="/assets/综合属性语义分析-bb529420.png",u="/assets/if结构-b90d7266.png",g="/assets/if-else结构-f40d0d05.png",y="/assets/while结构-914bee40.png",x="/assets/or结构-e0a6920c.png",v="/assets/and结构-c1865e2c.png",w="/assets/布尔表达式例子-fe16bc51.png",b="/assets/流程控制示例图-cb809c54.png",f="/assets/尾递归优化-a6197c93.png",_="/assets/代码移动-1080cf5e.png",k="/assets/删除-05da31a9.png",E="/assets/flowgraph-05647f1a.png",z="/assets/DAG1-b4ad6016.png",M="/assets/DAG2-2878e6f4.png",S="/assets/DAG3-8a5b9c83.png",T={},L=l('

Chapter5 代码生成

介绍

  • 代码生成取决于:源代码、目标系统体系结构、运行时环境
  • 代码生成可以被划分为三步:
  1. 生成中间代码(IR Iermediate code码)
  2. 生成某种汇编形式的代码,而不是真正的可执行代码
  3. 优化目标代码

中间代码

  • 以三地址码(TAC Three Address code)为例

生成三地址码

运算

[TAC_Code1.png]
[TAC_Code1.png]

变量赋值

[TAC_Instruction.png]
[TAC_Instruction.png]

布尔值

[TAC_Code2.png]
[TAC_Code2.png]

流程控制语句

[TAC_Code3.png][TAC_Code4.png]

三地址码的实现

  • 有四元组和三元组实现,一般都用四元组实现,因为利于后面进行进一步的优化

四元组实现

',18),A=s("ul",null,[s("li",null,[a("用"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mo",{stretchy:"false"},"("),s("mi",null,"o"),s("mi",null,"p"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"1"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",null,"o"),s("mi",null,"p"),s("mi",null,"e"),s("mi",null,"r"),s("mi",null,"a"),s("mi",null,"n"),s("mi",null,"d"),s("mn",null,"3"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"(op,operand1,operand2,operand3)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"1"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"o"),s("span",{class:"mord mathnormal"},"p"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.02778em"}},"er"),s("span",{class:"mord mathnormal"},"an"),s("span",{class:"mord mathnormal"},"d"),s("span",{class:"mord"},"3"),s("span",{class:"mclose"},")")])])]),a("来表示一个三地址指令,用"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",{mathvariant:"normal"},"_")]),s("annotation",{encoding:"application/x-tex"},"\\_")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em","vertical-align":"-0.31em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_")])])]),a("来表示缺省的操作数")]),s("li",null,[a("例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"="),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"∗"),s("mi",null,"x"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"m"),s("mi",null,"u"),s("mi",null,"l"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{separator:"true"},","),s("mi",null,"x"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mi",null,"t"),s("mn",null,"2"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"t2=fact*x\\rightarrow (mul,fact,x,\\_ t2)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∗"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.06em","vertical-align":"-0.31em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mclose"},")")])])]),a(" ,"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"l"),s("mi",null,"a"),s("mi",null,"b"),s("mi",null,"e"),s("mi",null,"l"),s("mtext",null,"  "),s("mi",null,"L"),s("mn",null,"2"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mi",null,"l"),s("mi",null,"a"),s("mi",null,"b"),s("mo",{separator:"true"},","),s("mi",null,"L"),s("mn",null,"2"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mo",{separator:"true"},","),s("mi",{mathvariant:"normal"},"_"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"label\\;L2\\rightarrow (lab,L2,\\_,\\_)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"ab"),s("span",{class:"mord mathnormal"},"e"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1.06em","vertical-align":"-0.31em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mord mathnormal"},"ab"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"L"),s("span",{class:"mord"},"2"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mclose"},")")])])])])],-1),C=s("h4",{id:"三元组实现",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#三元组实现","aria-hidden":"true"},"#"),a(" 三元组实现")],-1),I=s("ul",null,[s("li",null,"用指令的地址来替换掉一个返回值变量来压缩掉一个变量"),s("li",null,[a("例如"),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"="),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"∗"),s("mi",null,"x"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mn",null,"4"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mi",null,"m"),s("mi",null,"u"),s("mi",null,"l"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{separator:"true"},","),s("mi",null,"x"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"t2=fact*x \\rightarrow (4)(mul,fact,x)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"∗"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"4"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mord mathnormal"},"u"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.01968em"}},"l"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"x"),s("span",{class:"mclose"},")")])])]),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",null,"="),s("mi",null,"t"),s("mn",null,"2"),s("mo",null,"→"),s("mo",{stretchy:"false"},"("),s("mn",null,"5"),s("mo",{stretchy:"false"},")"),s("mo",{stretchy:"false"},"("),s("mi",null,"a"),s("mi",null,"s"),s("mi",null,"n"),s("mo",{separator:"true"},","),s("mo",{stretchy:"false"},"("),s("mn",null,"4"),s("mo",{stretchy:"false"},")"),s("mo",{separator:"true"},","),s("mi",null,"f"),s("mi",null,"a"),s("mi",null,"c"),s("mi",null,"t"),s("mo",{stretchy:"false"},")")]),s("annotation",{encoding:"application/x-tex"},"fact=t2\\rightarrow (5)(asn,(4),fact)")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8889em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6444em"}}),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mord"},"2"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"5"),s("span",{class:"mclose"},")"),s("span",{class:"mopen"},"("),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"s"),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mopen"},"("),s("span",{class:"mord"},"4"),s("span",{class:"mclose"},")"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.10764em"}},"f"),s("span",{class:"mord mathnormal"},"a"),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mord mathnormal"},"t"),s("span",{class:"mclose"},")")])])])])],-1),G=l('

区别

  • 三元组比较高效,因为空间占用减少了,并且编译器不需要为临时变量生成名称
  • 三元组使用指令索引来表示临时值,那么它们的位置的任何移动都变得困难。 四元组更适合优化

生成三地址码的细节

综合属性

',4),D=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"exp"),s("mo",null,"→"),s("mtext",null,"id"),s("mo",null,"="),s("mtext",null,"exp"),s("mo",{fence:"false",stretchy:"true",minsize:"1.2em",maxsize:"1.2em"},"∣"),s("mtext",null,"aexp")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"aexp"),s("mo",null,"→"),s("mtext",null,"aexp+factor"),s("mo",null,"∣"),s("mtext",null,"factor")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"factor"),s("mo",null,"→"),s("mtext",null,"(exp)"),s("mo",null,"∣"),s("mtext",null,"num"),s("mo",null,"∣"),s("mtext",null,"id")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{exp}\\to\\text{id}=\\text{exp}\\big|\\text{aexp} \\\\ &\\text{aexp}\\to\\text{aexp+factor}\\mid\\text{factor} \\\\ &\\text{factor}\\to\\text{(exp)}\\mid\\text{num}\\mid\\text{id} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.51em","vertical-align":"-2.005em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.505em"}},[s("span",{style:{top:"-4.505em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3.005em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-1.505em"}},[s("span",{class:"pstrut",style:{height:"2.85em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.005em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.505em"}},[s("span",{style:{top:"-4.655em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"exp")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"id")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"exp")]),s("span",{class:"mord"},[s("span",{class:"delimsizing mult"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.85em"}},[s("span",{style:{top:"-2.85em"}},[s("span",{class:"pstrut",style:{height:"3.2em"}}),s("span",{style:{width:"0.333em",height:"1.200em"}},[s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"0.333em",height:"1.200em",viewBox:"0 0 333 1200"},[s("path",{d:`M145 15 v585 v0 v585 c2.667,10,9.667,15,21,15 c10,0,16.667,-5,20,-15 v-585 v0 v-585 c-2.667,-10,-9.667,-15,-21,-15 c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v0 v585 h43z`})])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.35em"}},[s("span")])])])])]),s("span",{class:"mord text"},[s("span",{class:"mord"},"aexp")])])]),s("span",{style:{top:"-3.155em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"aexp")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"aexp+factor")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"factor")])])]),s("span",{style:{top:"-1.655em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"factor")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"(exp)")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"num")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"id")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.005em"}},[s("span")])])])])])])])])])])],-1),B=l('

[综合属性语义规则1.png][综合属性语义规则2.png][综合属性语义分析.png]

语言结构

If
',3),H=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mtext",null,"if-stmt")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mo",null,"→"),s("mtext",null,"if(exp)"),s("mtext",null,"  "),s("mtext",null,"stmt")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mi",{mathvariant:"normal"},"∣"),s("mtext",null,"if"),s("mo",{stretchy:"false"},"("),s("mtext",null,"exp"),s("mo",{stretchy:"false"},")"),s("mtext",null,"  "),s("mtext",null,"stmt else stmt")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} \\text{if-stmt}& \\to\\text{if}\\text{(exp)}\\;\\text{stmt} \\\\ &|\\text{if}(\\text{exp})\\;\\text{stmt else stmt} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3em","vertical-align":"-1.25em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.75em"}},[s("span",{style:{top:"-3.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord text"},[s("span",{class:"mord"},"if-stmt")])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.25em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.75em"}},[s("span",{style:{top:"-3.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"if")]),s("span",{class:"mord text"},[s("span",{class:"mord"},"(exp)")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"stmt")])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord"},"∣"),s("span",{class:"mord text"},[s("span",{class:"mord"},"if")]),s("span",{class:"mopen"},"("),s("span",{class:"mord text"},[s("span",{class:"mord"},"exp")]),s("span",{class:"mclose"},")"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"stmt else stmt")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.25em"}},[s("span")])])])])])])])])])])],-1),V=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"if"),s("mi",{mathvariant:"normal"},"_"),s("mtext",null,"false t1 goto L1")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"goto L2")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"label L1")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"label L2")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{} \\\\ &\\text{if}\\_\\text{false t1 goto L1} \\\\ &\\text{} \\\\ &\\text{goto L2} \\\\ &\\text{label L1} \\\\ &\\text{} \\\\ &\\text{label L2} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"10.5em","vertical-align":"-5em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"5.5em"}},[s("span",{style:{top:"-7.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-6em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-4.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-1.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"0em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"1.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"5em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"5.5em"}},[s("span",{style:{top:"-7.66em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"")])])]),s("span",{style:{top:"-6.16em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"if")]),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord text"},[s("span",{class:"mord"},"false t1 goto L1")])])]),s("span",{style:{top:"-4.66em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"")])])]),s("span",{style:{top:"-3.16em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"goto L2")])])]),s("span",{style:{top:"-1.66em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"label L1")])])]),s("span",{style:{top:"-0.16em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"")])])]),s("span",{style:{top:"1.34em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"label L2")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"5em"}},[s("span")])])])])])])])])])])],-1),N=s("h6",{id:"",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#","aria-hidden":"true"},"#"),a(),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mtext",null,"if E then S1")]),s("annotation",{encoding:"application/x-tex"},"S\\to\\text{if E then S1}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"if E then S1")])])])])],-1),j=s("figure",null,[s("img",{src:u,alt:"[if结构.png]",tabindex:"0",loading:"lazy"}),s("figcaption",null,"[if结构.png]")],-1),q=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"E.true"),s("mo",null,"="),s("mtext",null,"newlabel ();")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"E.false"),s("mo",null,"="),s("mtext",null,"S.next;")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S.code"),s("mo",null,"="),s("mtext",null,"E.code"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"Label E.true"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"S1.code")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{E.true}=\\text{newlabel ();} \\\\ &\\text{E.false}=\\text{S.next;} \\\\ &\\text{S.code}=\\text{E.code}++\\text{Label E.true}++\\text{S1.code} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.5em","vertical-align":"-2em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.5em"}},[s("span",{style:{top:"-4.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-1.5em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.5em"}},[s("span",{style:{top:"-4.66em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.true")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"newlabel ();")])])]),s("span",{style:{top:"-3.16em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.false")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S.next;")])])]),s("span",{style:{top:"-1.66em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S.code")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.code")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"Label E.true")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"S1.code")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2em"}},[s("span")])])])])])])])])])])],-1),O=s("h6",{id:"-1",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#-1","aria-hidden":"true"},"#"),a(),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mi",null,"S"),s("mo",null,"→"),s("mtext",null,"if E then S1 else S2")]),s("annotation",{encoding:"application/x-tex"},"S\\to\\text{if E then S1 else S2}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"if E then S1 else S2")])])])])],-1),F=s("figure",null,[s("img",{src:g,alt:"[if-else结构.png]",tabindex:"0",loading:"lazy"}),s("figcaption",null,"[if-else结构.png]")],-1),R=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"E.true=newlabel"),s("mo",{separator:"true"},";"),s("mtext",null,"E.false=newlabel"),s("mo",{separator:"true"},";")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S1.next=S.next"),s("mo",{separator:"true"},";"),s("mtext",null,"S2.next=S.next;")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S.code=E.code"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"LabelE.true"),s("mo",null,"+"),s("mo",null,"+"),s("mi",null,"S"),s("mn",null,"1."),s("mtext",null,"code"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"goto S.next"),s("mo",null,"+"),s("mo",null,"+")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"Label E.false++S2.code")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{E.true=newlabel};\\text{E.false=newlabel}; \\\\ &\\text{S1.next=S.next};\\text{S2.next=S.next;} \\\\ &\\text{S.code=E.code}++\\text{LabelE.true}++S1.\\text{code}++\\text{goto S.next}++ \\\\ &\\text{Label E.false++S2.code} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-2.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-0.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.true=newlabel")]),s("span",{class:"mpunct"},";"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.false=newlabel")]),s("span",{class:"mpunct"},";")])]),s("span",{style:{top:"-3.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S1.next=S.next")]),s("span",{class:"mpunct"},";"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S2.next=S.next;")])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S.code=E.code")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"LabelE.true")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord mathnormal",style:{"margin-right":"0.05764em"}},"S"),s("span",{class:"mord"},"1."),s("span",{class:"mord text"},[s("span",{class:"mord"},"code")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"goto S.next")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+")])]),s("span",{style:{top:"-0.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"Label E.false++S2.code")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])])])])])])])])],-1),W=s("h5",{id:"while",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#while","aria-hidden":"true"},"#"),a(" While")],-1),J=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"while-stmt"),s("mo",null,"→"),s("mtext",null,"while"),s("mo",{stretchy:"false"},"("),s("mi",null,"exp"),s("mo",null,"⁡"),s("mo",{stretchy:"false"},")"),s("mtext",null,"stmt")]),s("annotation",{encoding:"application/x-tex"}," \\text{while-stmt}\\to\\text{while}(\\exp)\\text{stmt} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"while-stmt")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"1em","vertical-align":"-0.25em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"while")]),s("span",{class:"mopen"},"("),s("span",{class:"mop"},"exp"),s("span",{class:"mclose"},")"),s("span",{class:"mord text"},[s("span",{class:"mord"},"stmt")])])])])])],-1),K=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"label L1")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"if"),s("mi",{mathvariant:"normal"},"_"),s("mtext",null,"false t1 goto L2")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"goto L1")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"label L2")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{label L1} \\\\ &\\text{} \\\\ &\\text{if}\\_\\text{false t1 goto L2} \\\\ &\\text{} \\\\ &\\text{goto L1} \\\\ &\\text{label L2} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"9em","vertical-align":"-4.25em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.75em"}},[s("span",{style:{top:"-6.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-5.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-2.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-0.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"0.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.25em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.75em"}},[s("span",{style:{top:"-6.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"label L1")])])]),s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"")])])]),s("span",{style:{top:"-3.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"if")]),s("span",{class:"mord",style:{"margin-right":"0.02778em"}},"_"),s("span",{class:"mord text"},[s("span",{class:"mord"},"false t1 goto L2")])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"")])])]),s("span",{style:{top:"-0.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"goto L1")])])]),s("span",{style:{top:"0.59em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"label L2")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"4.25em"}},[s("span")])])])])])])])])])])],-1),P=s("h6",{id:"-2",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#-2","aria-hidden":"true"},"#"),a(),s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("semantics",null,[s("mrow",null,[s("mtext",null,"S"),s("mo",null,"→"),s("mtext",null,"while E do S1")]),s("annotation",{encoding:"application/x-tex"},"\\text{S}\\to\\text{while E do S1}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6833em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.6944em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"while E do S1")])])])])],-1),Q=s("figure",null,[s("img",{src:y,alt:"[while结构.png]",tabindex:"0",loading:"lazy"}),s("figcaption",null,"[while结构.png]")],-1),U=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S.begin=newlabel"),s("mo",{separator:"true"},";"),s("mtext",null,"E.true=newlabel"),s("mo",{separator:"true"},";"),s("mtext",null,"E.false=S.next;")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S1.next=S.begin;")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"S.code=Label S.beginin"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"E.code"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"Label E.true"),s("mo",null,"+"),s("mo",null,"+"),s("mtext",null,"S1.code")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mtext",null,"++goto S.begin")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{aligned} &\\text{S.begin=newlabel};\\text{E.true=newlabel};\\text{E.false=S.next;} \\\\ &\\text{S1.next=S.begin;} \\\\ &\\text{S.code=Label S.beginin}++\\text{E.code}++\\text{Label E.true}++\\text{S1.code} \\\\ &\\text{++goto S.begin} \\end{aligned}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"6em","vertical-align":"-2.75em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-3.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-2.25em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})]),s("span",{style:{top:"-0.75em"}},[s("span",{class:"pstrut",style:{height:"2.84em"}}),s("span",{class:"mord"})])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"3.25em"}},[s("span",{style:{top:"-5.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S.begin=newlabel")]),s("span",{class:"mpunct"},";"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.true=newlabel")]),s("span",{class:"mpunct"},";"),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.false=S.next;")])])]),s("span",{style:{top:"-3.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S1.next=S.begin;")])])]),s("span",{style:{top:"-2.41em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"S.code=Label S.beginin")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"E.code")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"Label E.true")]),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},"+"),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord"},"+"),s("span",{class:"mord text"},[s("span",{class:"mord"},"S1.code")])])]),s("span",{style:{top:"-0.91em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mord text"},[s("span",{class:"mord"},"++goto S.begin")])])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.75em"}},[s("span")])])])])])])])])])])],-1),X=s("h5",{id:"布尔表达式",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#布尔表达式","aria-hidden":"true"},"#"),a(" 布尔表达式")],-1),Y=s("ul",null,[s("li",null,"布尔表达式有两个主要作用,一个是用来计算逻辑值,另一个是用在 if 或 while 等语句中作为条件控制。")],-1),Z=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"center",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mtext",null,"E"),s("mo",null,"→"),s("mtext",null,"E or E"),s("mo",null,"∣"),s("mtext",null,"E and E"),s("mo",null,"∣"),s("mtext",null,"not E"),s("mo",null,"∣"),s("mtext",null,"(E)")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mo",{fence:"false",stretchy:"true",minsize:"1.2em",maxsize:"1.2em"},"∣"),s("mtext",null,"id relop id"),s("mo",{fence:"false",stretchy:"true",minsize:"1.2em",maxsize:"1.2em"},"∣"),s("mtext",null,"true"),s("mo",{fence:"false",stretchy:"true",minsize:"1.2em",maxsize:"1.2em"},"∣"),s("mtext",null,"false")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mi",null,"r"),s("mi",null,"e"),s("mi",null,"l"),s("mi",null,"o"),s("mi",null,"p"),s("mo",null,":"),s("mtext",null,"关系运算符"),s("mo",{stretchy:"false"},"("),s("mo",null,"≥"),s("mo",{separator:"true"},","),s("mo",null,"≤"),s("mo",{separator:"true"},","),s("mo",null,"<"),s("mo",{separator:"true"},","),s("mo",null,">"),s("mo",{separator:"true"},","),s("mo",null,"="),s("mo",{separator:"true"},","),s("mo",{mathvariant:"normal"},"≠"),s("mo",{stretchy:"false"},")")])])])])]),s("annotation",{encoding:"application/x-tex"}," \\begin{gathered} \\text{E}\\to\\text{E or E}\\mid\\text{E and E}\\mid\\text{not E}\\mid\\text{(E)} \\\\ \\big|\\text{id relop id}\\big|\\text{true}\\big|\\text{false} \\\\ relop:关系运算符(\\ge,\\le,\\lt,\\gt,=,\\neq) \\end{gathered}")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"4.51em","vertical-align":"-2.005em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-c"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"2.505em"}},[s("span",{style:{top:"-4.665em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord text"},[s("span",{class:"mord"},"E")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"→"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E or E")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"E and E")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"not E")]),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"∣"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord text"},[s("span",{class:"mord"},"(E)")])])]),s("span",{style:{top:"-3.155em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"},[s("span",{class:"delimsizing mult"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.85em"}},[s("span",{style:{top:"-2.85em"}},[s("span",{class:"pstrut",style:{height:"3.2em"}}),s("span",{style:{width:"0.333em",height:"1.200em"}},[s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"0.333em",height:"1.200em",viewBox:"0 0 333 1200"},[s("path",{d:`M145 15 v585 v0 v585 c2.667,10,9.667,15,21,15 c10,0,16.667,-5,20,-15 v-585 v0 v-585 c-2.667,-10,-9.667,-15,-21,-15 diff --git "a/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-0ec43399.js" "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-0ec43399.js" new file mode 100644 index 000000000..12d7d06d2 --- /dev/null +++ "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-0ec43399.js" @@ -0,0 +1 @@ +const e=JSON.parse(`{"key":"v-0feda2e2","path":"/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balance%E5%AE%9E%E7%8E%B0%E6%B5%85%E6%9E%90.html","title":"NUMA Balance实现浅析","lang":"zh-CN","frontmatter":{"title":"NUMA Balance实现浅析","icon":"page","order":1,"author":"ChiChen","category":["笔记","Linux 内核"],"tag":["Linux 内核","NUMA"],"sticky":true,"star":true,"footer":null,"isOriginal":false,"copyright":"转载请注明出处","description":"参考资料 转载于numa balance实现浅析,原作者为wjx5210 ,遵循 CC 4.0 BY 版权协议 NUMA balance的背景","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balance%E5%AE%9E%E7%8E%B0%E6%B5%85%E6%9E%90.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"NUMA Balance实现浅析"}],["meta",{"property":"og:description","content":"参考资料 转载于numa balance实现浅析,原作者为wjx5210 ,遵循 CC 4.0 BY 版权协议 NUMA balance的背景"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-10-29T13:56:28.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"Linux 内核"}],["meta",{"property":"article:tag","content":"NUMA"}],["meta",{"property":"article:modified_time","content":"2023-10-29T13:56:28.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"NUMA Balance实现浅析\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2023-10-29T13:56:28.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[{"level":2,"title":"参考资料","slug":"参考资料","link":"#参考资料","children":[]},{"level":2,"title":"NUMA balance的背景","slug":"numa-balance的背景","link":"#numa-balance的背景","children":[]},{"level":2,"title":"基本原理","slug":"基本原理","link":"#基本原理","children":[{"level":3,"title":"内核配置","slug":"内核配置","link":"#内核配置","children":[]}]},{"level":2,"title":"实现","slug":"实现","link":"#实现","children":[{"level":3,"title":"相关数据结构","slug":"相关数据结构","link":"#相关数据结构","children":[]},{"level":3,"title":"具体实现","slug":"具体实现","link":"#具体实现","children":[]}]},{"level":2,"title":"观测工具","slug":"观测工具","link":"#观测工具","children":[{"level":3,"title":"/proc/vmstat接口","slug":"proc-vmstat接口","link":"#proc-vmstat接口","children":[]},{"level":3,"title":"线程的/proc/…/sched 接口","slug":"线程的-proc-sched-接口","link":"#线程的-proc-sched-接口","children":[]}]},{"level":2,"title":"参考","slug":"参考","link":"#参考","children":[]}],"git":{"createdTime":1698587788000,"updatedTime":1698587788000,"contributors":[{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":20.12,"words":6036},"filePathRelative":"posts/Linux内核/NUMA Balance实现浅析.md","localizedDate":"2023年10月29日","excerpt":"

参考资料

\\n

转载于numa balance实现浅析,原作者为wjx5210\\n,遵循 CC 4.0 BY 版权协议

\\n

NUMA balance的背景

","autoDesc":true}`);export{e as data}; diff --git "a/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-da47ac89.js" "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-da47ac89.js" new file mode 100644 index 000000000..cfc2356c5 --- /dev/null +++ "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-da47ac89.js" @@ -0,0 +1,417 @@ +import{_ as t}from"./plugin-vue_export-helper-c27b6911.js";import{r as e,o,c,a as n,b as s,d as p,e as l}from"./app-9d555359.js";const i={},u=n("h2",{id:"参考资料",tabindex:"-1"},[n("a",{class:"header-anchor",href:"#参考资料","aria-hidden":"true"},"#"),s(" 参考资料")],-1),r={href:"https://blog.csdn.net/faxiang1230/article/details/123709414",target:"_blank",rel:"noopener noreferrer"},k={href:"https://blog.csdn.net/faxiang1230?type=blog",target:"_blank",rel:"noopener noreferrer"},d=l(`

NUMA balance的背景

在NUMA(None Uniform Memory Access)之前是UMA(Uniform Memory Access), UMA 架构下,CPU 和内存之间的通信全部都要通过前端总线,总线模型保证了 CPU 的所有内存访问速率都是一致的,不必考虑不同内存地址之间的差异。此时提高性能的方式,就是不断地提高 CPU、前端总线和内存的工作频率。但是因为物理条件的限制,不断提高工作频率的路子走不下去了,CPU 性能的提升开始从提高主频转向增加 CPU 数量(多核、多 CPU)。越来越多的 CPU 对前端总线的争用,使前端总线成为了瓶颈。为了消除 UMA 架构的瓶颈,NUMA架构诞生了。在 NUMA 架构下,CPU与CPU之间通过核间互连总线连接,内存的访问速率出现了本地和远程的区别,访问远程内存的延时会明显高于访问本地内存。 linux在2.4就支持了NUMA架构,但是存在性能问题,任务运行的CPU和需要访问的数据不在同一节点上,访问延迟会影响发挥CPU的性能。之后厂商一方面提高核间互连总线的速率来消除NUMA的差异,目前x86和arm64上访问非本节点带宽达到本节点带宽的80%,另一方面软件进行优化,争取使CPU访问本节点内存。 在2012年左右,Peter Zijlstra 和 Andrea 分别提交了NUMA优化的patch,中间的过程略过,最终有了现在的numa balance的功能。

numa balance的终极目标: 任务访问本节点内存。实现上将其拆分成两个小目标:

如果任务访问的大部分内存不在本节点,那么把任务迁移到该节点的CPU上运行; 如果任务访问的大部分数据都在本节点,那么将其他节点上的数据迁移到该节点上。

基本原理

  • numa balance功能的基本实现过程:
    1. 周期性扫描task的地址空间并且修改页表项为PAGE_NONE(没有读/写/执行权限,但是有对应的物理地址),之后访问该数据时会发生page fault。
    2. 在page fault中,重新修改页表为正确的权限使得后面能够继续执行
    3. 在page fault中会追踪两个数据: page被哪个节点和任务访问过,任务在各个节点上发生的缺页情况
    4. 根据历史记录,决定是否迁移页和任务迁移

对于单进程单线程的程序来说比较简单,进程没有共享的数据或者非常少,选择一个合适的节点运行就可以了;对于单进程多线程来说,就比较复杂了,线程间共享数据是不确定的,CPU的繁忙程度也是不固定的,特别是对于线程池的方式没有办法采用固定的配置。

  • 总体而言需要解决几个问题:
    1. 扫描尽量不要影响系统正常的性能,因为它会强制触发page fault, 所以必须对扫描周期和一次性扫描的页范围进行限制,特别是扫描周期会根据缺页的历史统计进行动态调整。
    2. 决定是否迁移页
    3. 决定是否迁移线程到不同的节点上

以下基于4.19.190内核进行分析。

内核配置

CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
+CONFIG_NUMA_BALANCING=y
+CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y
+

另外还可以通过内核启动参数的方式 numa_balancing=enable/disable 或者sysctl接口 kernel.numa_balancing 来动态控制该功能工作。 此外还提供了几个sysctl 接口配置参数来控制它的扫描周期和力度:

kernel.numa_balancing = 1      //是否使能自动的numa balance
+kernel.numa_balancing_scan_delay_ms = 1000     //任务启动N ms之后才开启第一次扫描,这样可以避免对短生命周期的任务进行扫描
+kernel.numa_balancing_scan_period_max_ms = 6000   //扫描的最小间隔和最大间隔。
+kernel.numa_balancing_scan_period_min_ms = 1000
+kernel.numa_balancing_scan_size_mb = 256    //一次扫描的空间大小,它会记录上次扫描的位置,下次继续从此次位置扫描
+

实现

相关数据结构

相关的数据结构主要位于task_struct 和 mm_struct中,先清楚需要维护这些状态的用途,之后在实现过程中分析他具体的使用。

task_struct

struct task_struct {
+    int             numa_scan_seq;
+    unsigned int            numa_scan_period;
+    unsigned int            numa_scan_period_max;
+    int             numa_preferred_nid;
+    unsigned long           numa_migrate_retry;
+    /* Migration stamp: */
+    u64             node_stamp;
+    u64             last_task_numa_placement;
+    u64             last_sum_exec_runtime;
+ //多个task可能共享同一片内存,具体可以是单个进程内多线程共享或者是多个进程间通过共享内存的方式
+ //将这些共享物理内存的task组织起来统计,并为后面的页面迁移和task迁移提供历史依据 */
+ struct numa_group __rcu     *numa_group;
+ //N个节点的状态,记录在每个节点上的缺页状态
+ //每个节点包含2组状态,第一组代表当前扫描窗口的平均统计,第二组是临时的buffer,存储上一个窗口的统计
+ //每组4个状态:faults_memory, faults_cpu,faults_memory_buffer, faults_cpu_buffer
+ //faults_memory: 记录缺页状态,每一个周期结束时会根据当前周期的统计进行衰减,类似于load的计算
+  //faults_cpus:发生缺页时,cpu运行在哪个node上
+  //faults_memory_buffer, faults_cpu_buffer:记录当前窗口的缺页状态
+ unsigned long           *numa_faults;
+ //统计线程因为numa balance标记发生了多少次fault
+ unsigned long           total_numa_faults;
+ //[0]: remote,缺页后迁移到其他node; [1]: local,缺页后仍然是本节点; [2]: migrate failed
+ unsigned long           numa_faults_locality[3];
+ //统计线程迁移了多少个页,仅做调试时展示使用
+ unsigned long           numa_pages_migrated;
+}
+

mm_struct

struct mm_struct {
+        //下一次允许扫描地址空间的时间
+        unsigned long numa_next_scan;
+  //下一次扫描的起始位置,整个扫描是顺序循环的
+        unsigned long numa_scan_offset;
+        //用来防止同一个进程中多线程并发扫描地址空间
+        int numa_scan_seq;
+ }
+

numa_group

8c8a743c5087 引入了numa_group, 缺页异常中将 cpu/pid 的部分信息放到了page flags中,将有共享页行为的线程放到一个group中。接下来如果是不同的PID访问这个page,那么这两个任务共享这个页,可以尝试将task迁移到这个group中。

struct numa_group {
+ //引用计数,内核常用方式,当refcount为0时进行释放
+    atomic_t refcount;
+ //保护并发读写操作
+    spinlock_t lock; /* nr_tasks, tasks */
+    //当前group中task数量
+    int nr_tasks;
+    //创建时task的gid,在将多个task组织到一个group中时
+    pid_t gid;
+    //当group中共享的内存分布在不同节点上时,并不认为所有的node都是active的,
+    //只有当前node 缺页访问数量超过max_faults_cpu 1/3时才会认为是active,
+    //对于缺页访问较少的node应该将这些页积极的迁移到active node上,达到页面汇聚的目的
+    int active_nodes;
+
+    struct rcu_head rcu;
+ //group中发生缺页的历史统计
+    unsigned long total_faults;
+    //多个节点共享时,发生缺页最多的node上的数量
+    unsigned long max_faults_cpu;
+ //每个节点上有一组统计数据,统计数据包括share/private的数量
+    unsigned long *faults_cpu;
+    //group中所有task->numa_faults之和
+    unsigned long faults[0];
+};
+
  • 在缺页统计时从两个角度出发:
    1. task发生缺页时访问的是否是本节点,分为 local/remote, 一个窗口中统计缺页时 页的节点和当前运行节点的关系,保存在 p->numa_faults_locality 中。当local占比超过70%时,适当延长当前的扫描时间
    2. 页面是否被共享,分为share/private, 在page->flags中 编码了部分的cpu和pid信息,每次缺页时都会将本次的cpu/pid更新到page->flags中,比较两次中的pid,如果相同则是私有的,如果不同则是shared.当私有占比70%时,适当延长当前的扫描时间。

cpu的share/private的意义:一个场景是jvm中的垃圾回收线程,它会访问大量的内存但是并不会实际使用它。所以在实际过程中会根据CPU运行时间进行加权运算

具体实现

在系统启动阶段,会根据node是否大于1来动态选择是否开启numa balance功能,不需要担心在PC这种单节点的机器上有额外的消耗。

static void __init check_numabalancing_enable(void){
+    if (num_online_nodes() > 1 && !numabalancing_override) {      //对于单节点并不会开启numa balance扫描
+        pr_info("%s automatic NUMA balancing. Configure with numa_balancing= or the kernel.numa_balancing sysctl\\n",
+            numabalancing_default ? "Enabling" : "Disabling");
+        set_numabalancing_state(numabalancing_default);
+    }
+}
+

周期性扫描地址空间

每个task都有自己的扫描时间戳,task->node_stamp和task->numa_scan_period,每个线程首先根据自己的时间戳来检测是否应该扫描;而多线程共享一个mm_struct, 他们不能同时扫描 mm->numa_next_scan,开始扫描时根据当前task更新下一个阶段的numa_next_scan。 线程之间共享同一个地址空间,扫描时修改的是同一个地址空间,所以其中一个线程做就OK了。但是因为线程可能是idle的或者根本没访问多少内存,所以不能指定某个线程开始做,而是所有线程都可以尝试,但是最后只有一个才真的能够开始修改地址空间。

task_tick_fair  //周期性更新
+ task_tick_numa
+  init_task_work(work, task_numa_work);
+  task_work_add(curr, work, true);
+

系统会发起周期性的timer中断,即tick,在tick中更新系统状态和任务抢占,numa balance将其任务插入这个流程中,一个是这个任务的精度不需要特别精准,其次不需要单独的线程或中断来发起,总体而言放在tick中消耗最小。而且numa balance并没有将任务真正的放在tick中,只是向task 中挂上一个work。

何时执行work? 它的处理时机类似于sighandler,在 从kernel退出到userspace,或者task退出时或者stop时 处理这个work: task_work_run。

代码中被调用的位置:

exit_task_work
+ptrace_notify
+get_signal
+

task_numa_work都干了什么?

task_numa_work
+ start = mm->numa_scan_offset;
+ vma = find_vma(mm, start);
+ for (; vma; vma = vma->vm_next) {
+  change_prot_numa(vma, start, end); 
+ }
+
+change_prot_numa(struct vm_area_struct *vma,
+            unsigned long addr, unsigned long end) {
+   nr_updated = change_protection(vma, addr, end, PAGE_NONE, 0, 1);    //扫描start - end 之间的页表,修改页表权限为PAGE_NONE
+ }
+
  1. 多线程共享mm_struct, 他们扫描的地址空间都是同一个,所以多线程可以并发task_numa_work执行,但是最终只有一个才会实际进行扫描。 在实际修改mm->numa_next_scan,采用cmpxchg操作,只会有一个修改成功
  2. 实际完成的事就是将change_prot_numa,将pte修改成PAGE_NONE,没有读/写/执行权限,再次访问时会触发缺页异常。

缺页异常处理

handle_mm_fault
+ __handle_mm_fault
+  handle_pte_fault
+   do_numa_page
+
+do_numa_page {
+    pte = pte_modify(pte, vma->vm_page_prot);  //修改页表为原始权限,在下次扫描到该页时访问不再发生异常
+    //判断页是否符合node的policy设置。应用程序可以通过mbind对某块地址设置不同的策略,例如当bind到某个node时就不能迁移到其他节点。
+    //返回值就是应该迁移的node,如果是-1则不应该迁移
+ target_nid = numa_migrate_prep(page, vma, vmf->address, page_nid, &flags);
+ //迁移错误放置的page到target node上
+    migrated = migrate_misplaced_page(page, vma, target_nid);
+    //更新当前的缺页统计情况
+    if (page_nid != -1)
+        task_numa_fault(last_cpupid, page_nid, 1, flags);
+}
+

numa_migrate_prep除了会根据mbind设置的策略决定目标node,在可迁移的情况下还会根据numa balance当前缺页统计来决定是否迁移。

numa_migrate_prep
+ mpol_misplaced
+ should_numa_migrate_memory    //衡量是否需要迁移到当前节点
+
+bool should_numa_migrate_memory(struct task_struct *p, struct page * page, 
+                int src_nid, int dst_cpu)                                                                                                                                                                                                     
+{
+    struct numa_group *ng = deref_curr_numa_group(p);
+    int dst_nid = cpu_to_node(dst_cpu);
+    int last_cpupid, this_cpupid;
+ //cpupid由8bit的cpu和8bit的pid组成,他要放在page->flags中,而page毕竟数据结构比较敏感。
+ //所以最终截取了部分的cpu/pid信息组成,所以后面根据cpupid来查找上一次存在误判的可能,特别是
+ //根据cpupid将不同的task组织到一个numa_group中时,有可能会误判。
+    this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid);
+    //更新page->flags中的cpupid并返回上一次页被访问的cpupid信息
+    last_cpupid = page_cpupid_xchg_last(page, this_cpupid);
+
+     //1. 对于page->flags中还没有设置过的即第一次发生page fault,没有历史信息进行判断时,那就迁移
+     //2. 对于上个周期和本周期都是同一个cpu/pid访问的,大概率是private类型的,那就内存向该CPU汇聚
+    if ((p->numa_preferred_nid == -1 || p->numa_scan_seq <= 4) && 
+        (cpupid_pid_unset(last_cpupid) || cpupid_match_pid(p, last_cpupid)))
+        return true; 
+ //如果上次访问该页时的cpu所在node和本次不同,说明task还没决定在哪长期执行或者两个task不在同一节点上,那就暂时不迁,等任务稳定下来再迁
+    if (!cpupid_pid_unset(last_cpupid) &&
+                cpupid_to_nid(last_cpupid) != dst_nid)
+        return false;
+
+ //如果上次访问该页时的cpu所在node和本次相同,说明这个是私有内存。而且经过上面的判断,task可能是长期在该Node上运行了,那就迁
+    if (cpupid_match_pid(p, last_cpupid))
+        return true; 
+
+ //既然上面的条件都不满足,那这个page应该是被多个task共享,并且两个task在同一节点上,尝试迁移
+ //迁移依赖于numa_group的统计,既然还没有汇聚,暂时不迁
+    if (!ng) 
+        return true; 
+
+    //目标node上发生缺页异常的数量远大于本节点上的数量,那就都汇聚到目标node上
+    if (group_faults_cpu(ng, dst_nid) > group_faults_cpu(ng, src_nid) *
+                    ACTIVE_NODE_FRACTION)
+        return true;
+
+    /* 如果目标节点上最近page fault数量的3/4 大于 源节点,通过一定的阈值差避免ping-pong迁移
+     * Distribute memory according to CPU & memory use on each node,
+     * with 3/4 hysteresis to avoid unnecessary memory migrations:
+     *
+     * faults_cpu(dst)   3   faults_cpu(src)
+     * --------------- * - > ---------------
+     * faults_mem(dst)   4   faults_mem(src)
+     */
+    return group_faults_cpu(ng, dst_nid) * group_faults(p, src_nid) * 3 >
+           group_faults_cpu(ng, src_nid) * group_faults(p, dst_nid) * 4;
+}
+

上面也提到,在共享内存的情况下需要根据numa_group的历史信息来决定是否迁移,这部分的信息主要在task_numa_fault 中完成的。

task_numa_fault {
+ //根据page->flags中cpupid来检查是否是私有访问的,它不同于mmap中的PRIVATE属性,而是表示是否多线程访问。
+ priv = cpupid_match_pid(p, last_cpupid); 
+ //如果是共享访问的,则尝试将共享访问的task组知道一个group中
+ if (!priv && !(flags & TNF_NO_GROUP))
+  task_numa_group(p, last_cpupid, flags, &priv); 
+ //周期性的检查是否应该迁移task到目标node上
+ if (time_after(jiffies, p->numa_migrate_retry)) {
+  task_numa_placement(p);
+  numa_migrate_preferred(p);
+ }
+
+ // 更新p->numa_faults中统计数据
+ if (migrated)
+  p->numa_pages_migrated += pages;
+ p->numa_faults[task_faults_idx(NUMA_MEMBUF, mem_node, priv)] += pages;
+ p->numa_faults[task_faults_idx(NUMA_CPUBUF, cpu_node, priv)] += pages;
+ p->numa_faults_locality[local] += pages;
+}
+

task_numa_fault主要完成task级别的信息统计,并且会周期性的检查是否应该迁移任务到目标节点上。统计信息主要分为页是私有访问还是多线程共享的,而实际使用这些信息的地方主要位于task_numa_placement。

下面先看如何将有共享页行为的多个task组织到一个group中。它主要是通过page->flags中的cpupid信息找到上次访问该页的task,之后尝试合并到numa_group中。

static void task_numa_group(struct task_struct *p, int cpupid, int flags, int *priv)  //注意cpupid是上次访问的
+{
+    struct numa_group *grp, *my_grp;
+    struct task_struct *tsk;
+    bool join = false;
+    int cpu = cpupid_to_cpu(cpupid);
+    int i;
+
+    rcu_read_lock();
+    //尝试找出上次访问page的task,这个完全凭缘分,必须task还在那个cpu上正在运行
+    //如果task不是正在运行或者换cpu了,那就找不到了
+    tsk = READ_ONCE(cpu_rq(cpu)->curr);
+  //cpu和pid都是只用了低8bit,所以不是完全匹配,有小概率会匹配失误
+    if (!cpupid_match_pid(tsk, cpupid))
+        goto no_join;
+
+    grp = rcu_dereference(tsk->numa_group);
+    my_grp = deref_curr_numa_group(p);
+ //汇聚成更大的group而不是拆分成小group,更大的group可以更好地完成内存和cpu汇聚
+ //如果当前group大于对方group时,不做汇聚,汇聚过程中需要操作对方task->numa_faults,这是对方私有的
+    if (my_grp->nr_tasks > grp->nr_tasks)
+        goto no_join;
+
+     //这个就比较搞笑了,双方一样的时候那就用地址决胜负,最终还是期望共享行为的task汇聚到一个group中的
+    if (my_grp->nr_tasks == grp->nr_tasks && my_grp > grp)
+        goto no_join;
+ //进程内的任务存在共享页行为,理所当然地应该汇聚
+    if (tsk->mm == current->mm)
+        join = true;
+  //对于进程间共享页地行为,它也可以汇聚到一起。
+  //在do_numa_page中根据vma的vm_flags中是否是进程间共享来标记,例如mmap中MAP_SHARED的影响
+    if (flags & TNF_SHARED)
+        join = true;
+
+    rcu_read_unlock();
+    if (!join)
+        return;
+ //根据地址来决定先锁哪一个,对于任意的锁都适用,nice
+    double_lock_irq(&my_grp->lock, &grp->lock);
+ //将task合并到目标group中,减去源group中该task的统计信息并增加到目标group中
+    for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++) {
+        my_grp->faults[i] -= p->numa_faults[i];
+        grp->faults[i] += p->numa_faults[i];
+    }
+    my_grp->total_faults -= p->total_numa_faults;
+    grp->total_faults += p->total_numa_faults;
+    my_grp->nr_tasks--;
+    grp->nr_tasks++;
+    spin_unlock(&my_grp->lock);
+    spin_unlock_irq(&grp->lock);
+
+    rcu_assign_pointer(p->numa_group, grp);
+
+    put_numa_group(my_grp);
+    return;
+
+no_join:
+    rcu_read_unlock();
+    return;
+}
+

之后周期性检查是否应该迁移任务到目标node:task_numa_placement,它主要就是根据当前周期内它访问的页主要位于哪个节点上。

static void task_numa_placement(struct task_struct *p)
+{
+ //窗口时间内总的缺页数量,包括所有node上share/privated的页
+    total_faults = p->numa_faults_locality[0] +
+               p->numa_faults_locality[1];
+    runtime = numa_get_avg_runtime(p, &period);
+
+    //找出哪个node上发生缺页数量最多
+    for_each_online_node(nid) {
+        /* Keep track of the offsets in numa_faults array */
+        int mem_idx, membuf_idx, cpu_idx, cpubuf_idx;
+        unsigned long faults = 0, group_faults = 0;
+        int priv;
+
+        for (priv = 0; priv < NR_NUMA_HINT_FAULT_TYPES; priv++) {
+            long diff, f_diff, f_weight;
+            //numa_faults有4个,两组统计信息
+            //NUMA_MEM是缺页历史总和的统计信息,NUMA_MEMBUF是当前窗口的缺页的数量
+            //NUMA_CPU是缺页历史总和的统计信息(带CPU运行时间系数),NUMA_CPUBUF是当前窗口缺页的数量(带CPU运行时间系数)
+            mem_idx = task_faults_idx(NUMA_MEM, nid, priv);
+            membuf_idx = task_faults_idx(NUMA_MEMBUF, nid, priv);
+            cpu_idx = task_faults_idx(NUMA_CPU, nid, priv);
+            cpubuf_idx = task_faults_idx(NUMA_CPUBUF, nid, priv);
+
+            /* Decay existing window, copy faults since last scan */
+   //当前窗口的数量-历史值的一半进行衰减,类似于系统load的计算,避免短时间内大量的访问引起task的迁移,更新到统计信息中
+   //如果历史统计值较大,则diff可能为负数,统计数量会下降。如果历史值较小,对当前统计值进行微调整。
+            diff = p->numa_faults[membuf_idx] - p->numa_faults[mem_idx] / 2;
+            //统计private/share的数据量
+            fault_types[priv] += p->numa_faults[membuf_idx];
+            //清空当前窗口的统计数据量
+            p->numa_faults[membuf_idx] = 0;
+            
+            //根据窗口内运行时间比进行加权,运行时间越短的对结果影响越小
+            f_weight = div64_u64(runtime << 16, period + 1);
+            //此时cpubuf_idx和membuf_idx中的值没什么区别,当前窗口内该节点在总缺页中的占比
+            f_weight = (f_weight * p->numa_faults[cpubuf_idx]) /
+                   (total_faults + 1);
+            //根据历史统计信息衰减
+            f_diff = f_weight - p->numa_faults[cpu_idx] / 2;
+            //清空当前窗口中
+            p->numa_faults[cpubuf_idx] = 0;
+   //更新两组统计信息
+            p->numa_faults[mem_idx] += diff;
+            p->numa_faults[cpu_idx] += f_diff;
+            //faults只是和当前缺页数量有关
+            faults += p->numa_faults[mem_idx];
+            //更新任务的历史缺页数量
+            p->total_numa_faults += diff;
+            if (ng) {
+    //更新group中node上信息
+                ng->faults[mem_idx] += diff;
+                ng->faults_cpu[mem_idx] += f_diff;
+                ng->total_faults += diff;
+                group_faults += ng->faults[mem_idx];
+            }
+        }
+  //该node上发生的缺页异常信息已经全部统计过了,找出最多的node
+        if (!ng) {
+            if (faults > max_faults) {
+                max_faults = faults;
+                max_nid = nid;
+            }
+        } else if (group_faults > max_faults) {
+            max_faults = group_faults;
+            max_nid = nid;
+        }
+    }
+
+    if (ng) {
+     //更新active node信息,发生少量缺页的node并不认为是active的
+        numa_group_count_active_nodes(ng);
+        spin_unlock_irq(group_lock);
+        max_nid = preferred_group_nid(p, max_nid);
+    }
+    if (max_faults) {
+        //为当前task设置新的prefer node
+        if (max_nid != p->numa_preferred_nid)
+            sched_setnuma(p, max_nid);
+    }
+ //调整task的扫描周期
+    update_task_scan_period(p, fault_types[0], fault_types[1]);
+}
+

update_task_scan_period会根据系统设定的 kernel.numa_balancing_scan_period_min_ms 和 kernel.numa_balancing_scan_period_max_ms 范围进行调整,如果大部分的内存已经是 local 或者 和其他线程在共享,扫描时间设置的更长一些,减少扫描的频率,反之则增加扫描频率。

static void update_task_scan_period(struct task_struct *p, unsigned long shared, unsigned long private)
+{
+    unsigned int period_slot;
+    int lr_ratio, ps_ratio;
+    int diff;
+
+    unsigned long remote = p->numa_faults_locality[0];
+    unsigned long local = p->numa_faults_locality[1];
+
+     //如果没有发生缺页行为或者该窗口内迁移失败了,则增加扫描时间。
+    if (local + shared == 0 || p->numa_faults_locality[2]) {
+        p->numa_scan_period = min(p->numa_scan_period_max,
+            p->numa_scan_period << 1);
+  //调整整个地址的扫描时间
+        p->mm->numa_next_scan = jiffies +
+            msecs_to_jiffies(p->numa_scan_period);
+        return;
+    }
+
+    /*
+     * Prepare to scale scan period relative to the current period.
+     *   == NUMA_PERIOD_THRESHOLD scan period stays the same
+     *       <  NUMA_PERIOD_THRESHOLD scan period decreases (scan faster)
+     *   >= NUMA_PERIOD_THRESHOLD scan period increases (scan slower)
+     */
+    //将整个扫描周期分成10份
+    period_slot = DIV_ROUND_UP(p->numa_scan_period, NUMA_PERIOD_SLOTS);
+    lr_ratio = (local * NUMA_PERIOD_SLOTS) / (local + remote);
+    ps_ratio = (private * NUMA_PERIOD_SLOTS) / (private + shared);
+
+    if (ps_ratio >= NUMA_PERIOD_THRESHOLD) {
+     //私有访问已经占到70%,减少扫描周期。这时候应该已经将task和内存统一放到一个节点上了,慢点扫
+        int slot = ps_ratio - NUMA_PERIOD_THRESHOLD;
+        if (!slot)
+            slot = 1;
+        diff = slot * period_slot;
+    } else if (lr_ratio >= NUMA_PERIOD_THRESHOLD) {
+        //本节点访问已经占到70%,起码这个task已经完成它的目标了,慢点扫
+        int slot = lr_ratio - NUMA_PERIOD_THRESHOLD;
+        if (!slot)
+            slot = 1;
+        diff = slot * period_slot;
+    } else {
+  //和70%目标差的越远,diff越小(负数)
+        int ratio = max(lr_ratio, ps_ratio);
+        diff = -(NUMA_PERIOD_THRESHOLD - ratio) * period_slot;
+    }
+
+    p->numa_scan_period = clamp(p->numa_scan_period + diff,
+            task_scan_min(p), task_scan_max(p));
+    //清空这个窗口内的统计信息
+    memset(p->numa_faults_locality, 0, sizeof(p->numa_faults_locality));
+

最后一个,将任务迁移到prefered node上

/* Attempt to migrate a task to a CPU on the preferred node. */
+static void numa_migrate_preferred(struct task_struct *p)
+{
+    unsigned long interval = HZ;
+
+    /* This task has no NUMA fault statistics yet */
+    if (unlikely(p->numa_preferred_nid == -1 || !p->numa_faults))
+        return;
+
+    /* Periodically retry migrating the task to the preferred node */
+    interval = min(interval, msecs_to_jiffies(p->numa_scan_period) / 16);
+    p->numa_migrate_retry = jiffies + interval;
+
+    /* Success if task is already running on preferred CPU */
+    if (task_node(p) == p->numa_preferred_nid)
+        return;
+
+    /* Otherwise, try migrate to a CPU on the preferred node */
+    task_numa_migrate(p);
+}
+

观测工具

需要打开CONFIG_SCHED_DEBUG宏之后,内核才会提供接口,应用可以通过 proc 接口来获取内核的统计数据。

/proc/vmstat接口

# cat /proc/vmstat|grep numa
+numa_pte_updates 343288          //系统范围内总共被标记PAGE_NONE的页数量
+numa_huge_pte_updates 119        //系统范围内总共被标记PAGE_NONE的大页数量,加上numa_pte_updates就是全部被标记的页数量
+numa_hint_faults 84534           //因为被标记PAGE_NONE而产生的page fault
+numa_hint_faults_local 78400     //page fault发生在本地的数量。numa_hint_faults_local/numa_hint_faults是有效迁移的比例
+numa_pages_migrated 49394        //因为被标记PAGE_NONE而迁移页的数量
+

线程的/proc/…/sched 接口

#cat /proc/9817/sched
+cat (9817, \\#threads: 1)
+-------------------------------------------------------------------
+mm->numa_scan_seq                            :                    0
+numa_pages_migrated                          :                    0
+numa_preferred_nid                           :                   -1
+total_numa_faults                            :                    0
+current_node=0, numa_group_id=0
+numa_faults node=0 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=1 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=2 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=3 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=4 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=5 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=6 task_private=0 task_shared=0 group_private=0 group_shared=0
+numa_faults node=7 task_private=0 task_shared=0 group_private=0 group_shared=0
+

参考

`,60),m={href:"https://elixir.bootlin.com/linux/v4.19.237/source",target:"_blank",rel:"noopener noreferrer"},v=n("li",null,"commit: 8c8a743c5087bac9caac8155b8f3b367e75cdd0b引入了numa_group, 当访问一个page时将cpu/pid的部分信息放到了page flags中,具体见cpu_pid_to_cpupid。接下来如果是不同的PID访问这个page,那么这两个任务共享这个页,可以尝试将task迁移到这个group中。",-1),_=n("li",null,"commit:37355bdc5a129899f6b245900a8eb944a092f7fd进程启动早期迁移page,使用stream测试会有提升。对于进程启动阶段就做大量工作的任务比较好。",-1),b=n("li",null,"commit:10f39042711ba21773763f267b4943a2c66c8bef解释了should_numa_migrate_memory的目标:1. 线程的私有内存保持本地性,对于private的数据无条件迁移; 2. 避免大量的page迁移; 3.对于共享内存分布到不同的节点上,这样可以最大的利用带宽。它标记了当前的active_nodes,对于page在active_nodes之外的迁移无条件进来,而在active_nodes中的,哪个node中发生page fault过多的时候迁移page到发生比较少的节点,这样将数据平均分布到不同节点上可以最大化利用带宽。",-1);function g(f,h){const a=e("ExternalLinkIcon");return o(),c("div",null,[u,n("p",null,[s("转载于"),n("a",r,[s("numa balance实现浅析"),p(a)]),s(",原作者为"),n("a",k,[s("wjx5210 "),p(a)]),s(",遵循 CC 4.0 BY 版权协议")]),d,n("ol",null,[n("li",null,[s("linux kernel source: "),n("a",m,[s("https://elixir.bootlin.com/linux/v4.19.237/source"),p(a)])]),v,_,b])])}const x=t(i,[["render",g],["__file","NUMA Balance实现浅析.html.vue"]]);export{x as default}; diff --git a/assets/NUMA Balancing.html-96ea11b1.js b/assets/NUMA Balancing.html-5c0deb83.js similarity index 96% rename from assets/NUMA Balancing.html-96ea11b1.js rename to assets/NUMA Balancing.html-5c0deb83.js index 90bd58215..503a89f51 100644 --- a/assets/NUMA Balancing.html-96ea11b1.js +++ b/assets/NUMA Balancing.html-5c0deb83.js @@ -1 +1 @@ -import{_ as s}from"./plugin-vue_export-helper-c27b6911.js";import{r as t,o as i,c as o,a as e,b as a,d as c,e as r}from"./app-75cd46e5.js";const d={},m={id:"numa-balancing-in-kernel-doc",tabindex:"-1"},l=e("a",{class:"header-anchor",href:"#numa-balancing-in-kernel-doc","aria-hidden":"true"},"#",-1),h={href:"https://www.kernel.org/doc/Documentation/sysctl/kernel.txt",target:"_blank",rel:"noopener noreferrer"},p=r("

Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often.

Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node.

The unmapping of pages and trapping faults incur additional overhead that ideally is offset by improved memory locality but there is no universal guarantee. If the target workload is already bound to NUMA nodes then this feature should be disabled. Otherwise, if the system overhead from the feature is too high then the rate the kernel samples for NUMA hinting faults may be controlled by the numa_balancing_scan_period_min_ms, numa_balancing_scan_delay_ms, numa_balancing_scan_period_max_ms, numa_balancing_scan_size_mb, and numa_balancing_settle_count sysctls.


numa_balancing_scan_period_min_ms, numa_balancing_scan_delay_ms, numa_balancing_scan_period_max_ms, numa_balancing_scan_size_mb

Automatic NUMA balancing scans tasks address space and unmaps pages to detect if pages are properly placed or if the data should be migrated to a memory node local to where the task is running. Every scan delay the task scans the next scan size number of pages in its address space. When the end of the address space is reached the scanner restarts from the beginning.

In combination, the scan delay and scan size determine the scan rate. When scan delay decreases, the scan rate increases. The scan delay and hence the scan rate of every task is adaptive and depends on historical behaviour. If pages are properly placed then the scan delay increases, otherwise the scan delay decreases. The scan size is not adaptive but the higher the scan size, the higher the scan rate.

Higher scan rates incur higher system overhead as page faults must be trapped and potentially data must be migrated. However, the higher the scan rate, the more quickly a tasks memory is migrated to a local node if the workload pattern changes and minimises performance impact due to remote memory accesses. These sysctls control the thresholds for scan delays and the number of pages scanned.

numa_balancing_scan_period_min_ms is the minimum time in milliseconds to scan a tasks virtual memory. It effectively controls the maximum scanning rate for each task.

numa_balancing_scan_delay_ms is the starting scan delay used for a task when it initially forks.

numa_balancing_scan_period_max_ms is the maximum time in milliseconds to scan a tasks virtual memory. It effectively controls the minimum scanning rate for each task.

numa_balancing_scan_size_mb is how many megabytes worth of pages are scanned for a given scan.

",12);function _(u,g){const n=t("ExternalLinkIcon");return i(),o("div",null,[e("h2",m,[l,a(),e("a",h,[a("numa_balancing in kernel doc"),c(n)])]),p])}const y=s(d,[["render",_],["__file","NUMA Balancing.html.vue"]]);export{y as default}; +import{_ as s}from"./plugin-vue_export-helper-c27b6911.js";import{r as t,o as i,c as o,a as e,b as a,d as c,e as r}from"./app-9d555359.js";const d={},m={id:"numa-balancing-in-kernel-doc",tabindex:"-1"},l=e("a",{class:"header-anchor",href:"#numa-balancing-in-kernel-doc","aria-hidden":"true"},"#",-1),h={href:"https://www.kernel.org/doc/Documentation/sysctl/kernel.txt",target:"_blank",rel:"noopener noreferrer"},p=r("

Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often.

Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node.

The unmapping of pages and trapping faults incur additional overhead that ideally is offset by improved memory locality but there is no universal guarantee. If the target workload is already bound to NUMA nodes then this feature should be disabled. Otherwise, if the system overhead from the feature is too high then the rate the kernel samples for NUMA hinting faults may be controlled by the numa_balancing_scan_period_min_ms, numa_balancing_scan_delay_ms, numa_balancing_scan_period_max_ms, numa_balancing_scan_size_mb, and numa_balancing_settle_count sysctls.


numa_balancing_scan_period_min_ms, numa_balancing_scan_delay_ms, numa_balancing_scan_period_max_ms, numa_balancing_scan_size_mb

Automatic NUMA balancing scans tasks address space and unmaps pages to detect if pages are properly placed or if the data should be migrated to a memory node local to where the task is running. Every scan delay the task scans the next scan size number of pages in its address space. When the end of the address space is reached the scanner restarts from the beginning.

In combination, the scan delay and scan size determine the scan rate. When scan delay decreases, the scan rate increases. The scan delay and hence the scan rate of every task is adaptive and depends on historical behaviour. If pages are properly placed then the scan delay increases, otherwise the scan delay decreases. The scan size is not adaptive but the higher the scan size, the higher the scan rate.

Higher scan rates incur higher system overhead as page faults must be trapped and potentially data must be migrated. However, the higher the scan rate, the more quickly a tasks memory is migrated to a local node if the workload pattern changes and minimises performance impact due to remote memory accesses. These sysctls control the thresholds for scan delays and the number of pages scanned.

numa_balancing_scan_period_min_ms is the minimum time in milliseconds to scan a tasks virtual memory. It effectively controls the maximum scanning rate for each task.

numa_balancing_scan_delay_ms is the starting scan delay used for a task when it initially forks.

numa_balancing_scan_period_max_ms is the maximum time in milliseconds to scan a tasks virtual memory. It effectively controls the minimum scanning rate for each task.

numa_balancing_scan_size_mb is how many megabytes worth of pages are scanned for a given scan.

",12);function _(u,g){const n=t("ExternalLinkIcon");return i(),o("div",null,[e("h2",m,[l,a(),e("a",h,[a("numa_balancing in kernel doc"),c(n)])]),p])}const y=s(d,[["render",_],["__file","NUMA Balancing.html.vue"]]);export{y as default}; diff --git a/assets/NUMA Balancing.html-06b349f4.js b/assets/NUMA Balancing.html-9ab2efe0.js similarity index 65% rename from assets/NUMA Balancing.html-06b349f4.js rename to assets/NUMA Balancing.html-9ab2efe0.js index cd9f1d2c7..cb6397d36 100644 --- a/assets/NUMA Balancing.html-06b349f4.js +++ b/assets/NUMA Balancing.html-9ab2efe0.js @@ -1 +1 @@ -const e=JSON.parse(`{"key":"v-3e42db3e","path":"/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balancing.html","title":"NUMA Balancing","lang":"zh-CN","frontmatter":{"title":"NUMA Balancing","icon":"page","order":1,"author":"ChiChen","date":"2023-10-17T00:00:00.000Z","category":["笔记","Linux 内核"],"tag":["Linux 内核","NUMA"],"sticky":false,"star":false,"footer":null,"copyright":"转载请注明出处","description":"numa_balancing in kernel doc Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often. Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node.","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balancing.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"NUMA Balancing"}],["meta",{"property":"og:description","content":"numa_balancing in kernel doc Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often. Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-10-28T16:44:53.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"Linux 内核"}],["meta",{"property":"article:tag","content":"NUMA"}],["meta",{"property":"article:published_time","content":"2023-10-17T00:00:00.000Z"}],["meta",{"property":"article:modified_time","content":"2023-10-28T16:44:53.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"NUMA Balancing\\",\\"image\\":[\\"\\"],\\"datePublished\\":\\"2023-10-17T00:00:00.000Z\\",\\"dateModified\\":\\"2023-10-28T16:44:53.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[{"level":2,"title":"numa_balancing in kernel doc","slug":"numa-balancing-in-kernel-doc","link":"#numa-balancing-in-kernel-doc","children":[]}],"git":{"createdTime":1698511493000,"updatedTime":1698511493000,"contributors":[{"name":"ChiChen","email":"2531693734@qq.com","commits":1}]},"readingTime":{"minutes":1.61,"words":484},"filePathRelative":"posts/Linux内核/NUMA Balancing.md","localizedDate":"2023年10月17日","excerpt":"

numa_balancing in kernel doc

\\n

Enables/disables automatic page fault based NUMA memory\\nbalancing. Memory is moved automatically to nodes\\nthat access it often.

\\n

Enables/disables automatic NUMA memory balancing. On NUMA machines, there\\nis a performance penalty if remote memory is accessed by a CPU. When this\\nfeature is enabled the kernel samples what task thread is accessing memory\\nby periodically unmapping pages and later trapping a page fault. At the\\ntime of the page fault, it is determined if the data being accessed should\\nbe migrated to a local memory node.

","autoDesc":true}`);export{e as data}; +const e=JSON.parse(`{"key":"v-3e42db3e","path":"/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balancing.html","title":"NUMA Balancing","lang":"zh-CN","frontmatter":{"title":"NUMA Balancing","icon":"page","order":1,"author":"ChiChen","date":"2023-10-17T00:00:00.000Z","category":["笔记","Linux 内核"],"tag":["Linux 内核","NUMA"],"sticky":false,"star":false,"footer":null,"copyright":"转载请注明出处","description":"numa_balancing in kernel doc Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often. Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node.","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/Linux%E5%86%85%E6%A0%B8/NUMA%20Balancing.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"NUMA Balancing"}],["meta",{"property":"og:description","content":"numa_balancing in kernel doc Enables/disables automatic page fault based NUMA memory balancing. Memory is moved automatically to nodes that access it often. Enables/disables automatic NUMA memory balancing. On NUMA machines, there is a performance penalty if remote memory is accessed by a CPU. When this feature is enabled the kernel samples what task thread is accessing memory by periodically unmapping pages and later trapping a page fault. At the time of the page fault, it is determined if the data being accessed should be migrated to a local memory node."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-10-29T13:56:28.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"Linux 内核"}],["meta",{"property":"article:tag","content":"NUMA"}],["meta",{"property":"article:published_time","content":"2023-10-17T00:00:00.000Z"}],["meta",{"property":"article:modified_time","content":"2023-10-29T13:56:28.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"NUMA Balancing\\",\\"image\\":[\\"\\"],\\"datePublished\\":\\"2023-10-17T00:00:00.000Z\\",\\"dateModified\\":\\"2023-10-29T13:56:28.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[{"level":2,"title":"numa_balancing in kernel doc","slug":"numa-balancing-in-kernel-doc","link":"#numa-balancing-in-kernel-doc","children":[]}],"git":{"createdTime":1698511493000,"updatedTime":1698587788000,"contributors":[{"name":"ChiChen","email":"2531693734@qq.com","commits":1},{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":1.61,"words":484},"filePathRelative":"posts/Linux内核/NUMA Balancing.md","localizedDate":"2023年10月17日","excerpt":"

numa_balancing in kernel doc

\\n

Enables/disables automatic page fault based NUMA memory\\nbalancing. Memory is moved automatically to nodes\\nthat access it often.

\\n

Enables/disables automatic NUMA memory balancing. On NUMA machines, there\\nis a performance penalty if remote memory is accessed by a CPU. When this\\nfeature is enabled the kernel samples what task thread is accessing memory\\nby periodically unmapping pages and later trapping a page fault. At the\\ntime of the page fault, it is determined if the data being accessed should\\nbe migrated to a local memory node.

","autoDesc":true}`);export{e as data}; diff --git a/assets/VuePlayground-85e71be7.js b/assets/VuePlayground-ed3c50f0.js similarity index 82% rename from assets/VuePlayground-85e71be7.js rename to assets/VuePlayground-ed3c50f0.js index f585c7795..63cc97aee 100644 --- a/assets/VuePlayground-85e71be7.js +++ b/assets/VuePlayground-ed3c50f0.js @@ -1 +1 @@ -import{f as p,i as v,g as c,s as n,h as f,j as g,k as m,l as a,m as y,_ as w}from"./app-75cd46e5.js";const R=e=>JSON.parse(decodeURIComponent(e));var h=p({name:"VuePlayground",props:{title:{type:String,default:""},files:{type:String,required:!0},settings:{type:String,default:"{}"}},setup(e){const i=v(),o=c(!0),t=n(),l=n(),s=f(()=>g({},i,R(e.settings))),u=async()=>{const{ReplStore:r,Repl:d}=await w(()=>import("./vue-repl-984a4f62.js"),["assets/vue-repl-984a4f62.js","assets/app-75cd46e5.js","assets/commonjs-dynamic-modules-302442b1.js","assets/commonjsHelpers-042e6b4d.js"]);t.value=d,l.value=new r({serializedState:decodeURIComponent(e.files)}),s.value.vueVersion&&await l.value.setVueVersion(s.value.vueVersion)};return m(async()=>{await u(),o.value=!1}),()=>[a("div",{class:"vue-playground-wrapper"},[e.title?a("div",{class:"header"},decodeURIComponent(e.title)):null,a("div",{class:"repl-container"},[o.value?a(y,{class:"preview-loading",height:192}):null,t.value?a(t.value,{store:l.value,autoResize:!0,...s.value,layout:"horizontal"}):null])])]}});export{h as default}; +import{f as p,i as v,g as c,s as n,h as f,j as g,k as m,l as a,m as y,_ as w}from"./app-9d555359.js";const R=e=>JSON.parse(decodeURIComponent(e));var h=p({name:"VuePlayground",props:{title:{type:String,default:""},files:{type:String,required:!0},settings:{type:String,default:"{}"}},setup(e){const i=v(),o=c(!0),t=n(),l=n(),s=f(()=>g({},i,R(e.settings))),u=async()=>{const{ReplStore:r,Repl:d}=await w(()=>import("./vue-repl-3eea39ad.js"),["assets/vue-repl-3eea39ad.js","assets/app-9d555359.js","assets/commonjs-dynamic-modules-302442b1.js","assets/commonjsHelpers-042e6b4d.js"]);t.value=d,l.value=new r({serializedState:decodeURIComponent(e.files)}),s.value.vueVersion&&await l.value.setVueVersion(s.value.vueVersion)};return m(async()=>{await u(),o.value=!1}),()=>[a("div",{class:"vue-playground-wrapper"},[e.title?a("div",{class:"header"},decodeURIComponent(e.title)):null,a("div",{class:"repl-container"},[o.value?a(y,{class:"preview-loading",height:192}):null,t.value?a(t.value,{store:l.value,autoResize:!0,...s.value,layout:"horizontal"}):null])])]}});export{h as default}; diff --git a/assets/app-75cd46e5.js b/assets/app-75cd46e5.js deleted file mode 100644 index 511552fc2..000000000 --- a/assets/app-75cd46e5.js +++ /dev/null @@ -1,113 +0,0 @@ -const w2="modulepreload",x2=function(e){return"/"+e},Ta={},T=function(t,n,l){if(!n||n.length===0)return t();const r=document.getElementsByTagName("link");return Promise.all(n.map(o=>{if(o=x2(o),o in Ta)return;Ta[o]=!0;const a=o.endsWith(".css"),i=a?'[rel="stylesheet"]':"";if(!!l)for(let d=r.length-1;d>=0;d--){const f=r[d];if(f.href===o&&(!a||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${i}`))return;const u=document.createElement("link");if(u.rel=a?"stylesheet":w2,a||(u.as="script",u.crossOrigin=""),u.href=o,document.head.appendChild(u),a)return new Promise((d,f)=>{u.addEventListener("load",d),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>t())};function Co(e,t){const n=Object.create(null),l=e.split(",");for(let r=0;r!!n[r.toLowerCase()]:r=>!!n[r]}const Ae={},Cn=[],vt=()=>{},C2=()=>!1,A2=/^on[^a-z]/,yl=e=>A2.test(e),Ao=e=>e.startsWith("onUpdate:"),Le=Object.assign,ko=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},k2=Object.prototype.hasOwnProperty,fe=(e,t)=>k2.call(e,t),Q=Array.isArray,An=e=>ur(e)==="[object Map]",ni=e=>ur(e)==="[object Set]",te=e=>typeof e=="function",pe=e=>typeof e=="string",To=e=>typeof e=="symbol",Ce=e=>e!==null&&typeof e=="object",li=e=>Ce(e)&&te(e.then)&&te(e.catch),ri=Object.prototype.toString,ur=e=>ri.call(e),T2=e=>ur(e).slice(8,-1),oi=e=>ur(e)==="[object Object]",Lo=e=>pe(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,el=Co(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),dr=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},L2=/-(\w)/g,st=dr(e=>e.replace(L2,(t,n)=>n?n.toUpperCase():"")),S2=/\B([A-Z])/g,pn=dr(e=>e.replace(S2,"-$1").toLowerCase()),bl=dr(e=>e.charAt(0).toUpperCase()+e.slice(1)),Lr=dr(e=>e?`on${bl(e)}`:""),il=(e,t)=>!Object.is(e,t),Yl=(e,t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},Yr=e=>{const t=parseFloat(e);return isNaN(t)?e:t},P2=e=>{const t=pe(e)?Number(e):NaN;return isNaN(t)?e:t};let La;const Jr=()=>La||(La=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function So(e){if(Q(e)){const t={};for(let n=0;n{if(n){const l=n.split(M2);l.length>1&&(t[l[0].trim()]=l[1].trim())}}),t}function Po(e){let t="";if(pe(e))t=e;else if(Q(e))for(let n=0;npe(e)?e:e==null?"":Q(e)||Ce(e)&&(e.toString===ri||!te(e.toString))?JSON.stringify(e,si,2):String(e),si=(e,t)=>t&&t.__v_isRef?si(e,t.value):An(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[l,r])=>(n[`${l} =>`]=r,n),{})}:ni(t)?{[`Set(${t.size})`]:[...t.values()]}:Ce(t)&&!Q(t)&&!oi(t)?String(t):t;let Ze;class R2{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=Ze,!t&&Ze&&(this.index=(Ze.scopes||(Ze.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const n=Ze;try{return Ze=this,t()}finally{Ze=n}}}on(){Ze=this}off(){Ze=this.parent}stop(t){if(this._active){let n,l;for(n=0,l=this.effects.length;n{const t=new Set(e);return t.w=0,t.n=0,t},ci=e=>(e.w&Ut)>0,ui=e=>(e.n&Ut)>0,N2=({deps:e})=>{if(e.length)for(let t=0;t{const{deps:t}=e;if(t.length){let n=0;for(let l=0;l{(d==="length"||d>=c)&&i.push(u)})}else switch(n!==void 0&&i.push(a.get(n)),t){case"add":Q(e)?Lo(n)&&i.push(a.get("length")):(i.push(a.get(an)),An(e)&&i.push(a.get(Zr)));break;case"delete":Q(e)||(i.push(a.get(an)),An(e)&&i.push(a.get(Zr)));break;case"set":An(e)&&i.push(a.get(an));break}if(i.length===1)i[0]&&Xr(i[0]);else{const c=[];for(const u of i)u&&c.push(...u);Xr(Oo(c))}}function Xr(e,t){const n=Q(e)?e:[...e];for(const l of n)l.computed&&Pa(l);for(const l of n)l.computed||Pa(l)}function Pa(e,t){(e!==pt||e.allowRecurse)&&(e.scheduler?e.scheduler():e.run())}function H2(e,t){var n;return(n=Zl.get(e))==null?void 0:n.get(t)}const j2=Co("__proto__,__v_isRef,__isVue"),pi=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(To)),q2=$o(),U2=$o(!1,!0),G2=$o(!0),Oa=W2();function W2(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...n){const l=ie(this);for(let o=0,a=this.length;o{e[t]=function(...n){Nn();const l=ie(this)[t].apply(this,n);return Vn(),l}}),e}function K2(e){const t=ie(this);return We(t,"has",e),t.hasOwnProperty(e)}function $o(e=!1,t=!1){return function(l,r,o){if(r==="__v_isReactive")return!e;if(r==="__v_isReadonly")return e;if(r==="__v_isShallow")return t;if(r==="__v_raw"&&o===(e?t?uu:yi:t?gi:mi).get(l))return l;const a=Q(l);if(!e){if(a&&fe(Oa,r))return Reflect.get(Oa,r,o);if(r==="hasOwnProperty")return K2}const i=Reflect.get(l,r,o);return(To(r)?pi.has(r):j2(r))||(e||We(l,"get",r),t)?i:De(i)?a&&Lo(r)?i:i.value:Ce(i)?e?hn(i):Hn(i):i}}const Y2=hi(),J2=hi(!0);function hi(e=!1){return function(n,l,r,o){let a=n[l];if($n(a)&&De(a)&&!De(r))return!1;if(!e&&(!Xl(r)&&!$n(r)&&(a=ie(a),r=ie(r)),!Q(n)&&De(a)&&!De(r)))return a.value=r,!0;const i=Q(n)&&Lo(l)?Number(l)e,fr=e=>Reflect.getPrototypeOf(e);function Il(e,t,n=!1,l=!1){e=e.__v_raw;const r=ie(e),o=ie(t);n||(t!==o&&We(r,"get",t),We(r,"get",o));const{has:a}=fr(r),i=l?Bo:n?Ro:cl;if(a.call(r,t))return i(e.get(t));if(a.call(r,o))return i(e.get(o));e!==r&&e.get(t)}function Dl(e,t=!1){const n=this.__v_raw,l=ie(n),r=ie(e);return t||(e!==r&&We(l,"has",e),We(l,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function Rl(e,t=!1){return e=e.__v_raw,!t&&We(ie(e),"iterate",an),Reflect.get(e,"size",e)}function Ma(e){e=ie(e);const t=ie(this);return fr(t).has.call(t,e)||(t.add(e),$t(t,"add",e,e)),this}function $a(e,t){t=ie(t);const n=ie(this),{has:l,get:r}=fr(n);let o=l.call(n,e);o||(e=ie(e),o=l.call(n,e));const a=r.call(n,e);return n.set(e,t),o?il(t,a)&&$t(n,"set",e,t):$t(n,"add",e,t),this}function Ba(e){const t=ie(this),{has:n,get:l}=fr(t);let r=n.call(t,e);r||(e=ie(e),r=n.call(t,e)),l&&l.call(t,e);const o=t.delete(e);return r&&$t(t,"delete",e,void 0),o}function Ia(){const e=ie(this),t=e.size!==0,n=e.clear();return t&&$t(e,"clear",void 0,void 0),n}function zl(e,t){return function(l,r){const o=this,a=o.__v_raw,i=ie(a),c=t?Bo:e?Ro:cl;return!e&&We(i,"iterate",an),a.forEach((u,d)=>l.call(r,c(u),c(d),o))}}function Fl(e,t,n){return function(...l){const r=this.__v_raw,o=ie(r),a=An(o),i=e==="entries"||e===Symbol.iterator&&a,c=e==="keys"&&a,u=r[e](...l),d=n?Bo:t?Ro:cl;return!t&&We(o,"iterate",c?Zr:an),{next(){const{value:f,done:p}=u.next();return p?{value:f,done:p}:{value:i?[d(f[0]),d(f[1])]:d(f),done:p}},[Symbol.iterator](){return this}}}}function It(e){return function(...t){return e==="delete"?!1:this}}function nu(){const e={get(o){return Il(this,o)},get size(){return Rl(this)},has:Dl,add:Ma,set:$a,delete:Ba,clear:Ia,forEach:zl(!1,!1)},t={get(o){return Il(this,o,!1,!0)},get size(){return Rl(this)},has:Dl,add:Ma,set:$a,delete:Ba,clear:Ia,forEach:zl(!1,!0)},n={get(o){return Il(this,o,!0)},get size(){return Rl(this,!0)},has(o){return Dl.call(this,o,!0)},add:It("add"),set:It("set"),delete:It("delete"),clear:It("clear"),forEach:zl(!0,!1)},l={get(o){return Il(this,o,!0,!0)},get size(){return Rl(this,!0)},has(o){return Dl.call(this,o,!0)},add:It("add"),set:It("set"),delete:It("delete"),clear:It("clear"),forEach:zl(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{e[o]=Fl(o,!1,!1),n[o]=Fl(o,!0,!1),t[o]=Fl(o,!1,!0),l[o]=Fl(o,!0,!0)}),[e,n,t,l]}const[lu,ru,ou,au]=nu();function Io(e,t){const n=t?e?au:ou:e?ru:lu;return(l,r,o)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?l:Reflect.get(fe(n,r)&&r in l?n:l,r,o)}const su={get:Io(!1,!1)},iu={get:Io(!1,!0)},cu={get:Io(!0,!1)},mi=new WeakMap,gi=new WeakMap,yi=new WeakMap,uu=new WeakMap;function du(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function fu(e){return e.__v_skip||!Object.isExtensible(e)?0:du(T2(e))}function Hn(e){return $n(e)?e:Do(e,!1,vi,su,mi)}function pu(e){return Do(e,!1,tu,iu,gi)}function hn(e){return Do(e,!0,eu,cu,yi)}function Do(e,t,n,l,r){if(!Ce(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const o=r.get(e);if(o)return o;const a=fu(e);if(a===0)return e;const i=new Proxy(e,a===2?l:n);return r.set(e,i),i}function kn(e){return $n(e)?kn(e.__v_raw):!!(e&&e.__v_isReactive)}function $n(e){return!!(e&&e.__v_isReadonly)}function Xl(e){return!!(e&&e.__v_isShallow)}function bi(e){return kn(e)||$n(e)}function ie(e){const t=e&&e.__v_raw;return t?ie(t):e}function Ei(e){return Ql(e,"__v_skip",!0),e}const cl=e=>Ce(e)?Hn(e):e,Ro=e=>Ce(e)?hn(e):e;function zo(e){jt&&pt&&(e=ie(e),fi(e.dep||(e.dep=Oo())))}function Fo(e,t){e=ie(e);const n=e.dep;n&&Xr(n)}function De(e){return!!(e&&e.__v_isRef===!0)}function V(e){return _i(e,!1)}function Se(e){return _i(e,!0)}function _i(e,t){return De(e)?e:new hu(e,t)}class hu{constructor(t,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?t:ie(t),this._value=n?t:cl(t)}get value(){return zo(this),this._value}set value(t){const n=this.__v_isShallow||Xl(t)||$n(t);t=n?t:ie(t),il(t,this._rawValue)&&(this._rawValue=t,this._value=n?t:cl(t),Fo(this))}}function sn(e){return De(e)?e.value:e}const vu={get:(e,t,n)=>sn(Reflect.get(e,t,n)),set:(e,t,n,l)=>{const r=e[t];return De(r)&&!De(n)?(r.value=n,!0):Reflect.set(e,t,n,l)}};function wi(e){return kn(e)?e:new Proxy(e,vu)}class mu{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:n,set:l}=t(()=>zo(this),()=>Fo(this));this._get=n,this._set=l}get value(){return this._get()}set value(t){this._set(t)}}function gu(e){return new mu(e)}class yu{constructor(t,n,l){this._object=t,this._key=n,this._defaultValue=l,this.__v_isRef=!0}get value(){const t=this._object[this._key];return t===void 0?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return H2(ie(this._object),this._key)}}class bu{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function jn(e,t,n){return De(e)?e:te(e)?new bu(e):Ce(e)&&arguments.length>1?Eu(e,t,n):V(e)}function Eu(e,t,n){const l=e[t];return De(l)?l:new yu(e,t,n)}class _u{constructor(t,n,l,r){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new Mo(t,()=>{this._dirty||(this._dirty=!0,Fo(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!r,this.__v_isReadonly=l}get value(){const t=ie(this);return zo(t),(t._dirty||!t._cacheable)&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function wu(e,t,n=!1){let l,r;const o=te(e);return o?(l=e,r=vt):(l=e.get,r=e.set),new _u(l,r,o||!r,n)}function qt(e,t,n,l){let r;try{r=l?e(...l):e()}catch(o){El(o,t,n)}return r}function at(e,t,n,l){if(te(e)){const o=qt(e,t,n,l);return o&&li(o)&&o.catch(a=>{El(a,t,n)}),o}const r=[];for(let o=0;o>>1;dl(Fe[l])At&&Fe.splice(t,1)}function ku(e){Q(e)?Tn.push(...e):(!Mt||!Mt.includes(e,e.allowRecurse?tn+1:tn))&&Tn.push(e),Ci()}function Da(e,t=ul?At+1:0){for(;tdl(n)-dl(l)),tn=0;tne.id==null?1/0:e.id,Tu=(e,t)=>{const n=dl(e)-dl(t);if(n===0){if(e.pre&&!t.pre)return-1;if(t.pre&&!e.pre)return 1}return n};function Ai(e){eo=!1,ul=!0,Fe.sort(Tu);const t=vt;try{for(At=0;Atpe(h)?h.trim():h)),f&&(r=n.map(Yr))}let i,c=l[i=Lr(t)]||l[i=Lr(st(t))];!c&&o&&(c=l[i=Lr(pn(t))]),c&&at(c,e,6,r);const u=l[i+"Once"];if(u){if(!e.emitted)e.emitted={};else if(e.emitted[i])return;e.emitted[i]=!0,at(u,e,6,r)}}function ki(e,t,n=!1){const l=t.emitsCache,r=l.get(e);if(r!==void 0)return r;const o=e.emits;let a={},i=!1;if(!te(e)){const c=u=>{const d=ki(u,t,!0);d&&(i=!0,Le(a,d))};!n&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!o&&!i?(Ce(e)&&l.set(e,null),null):(Q(o)?o.forEach(c=>a[c]=null):Le(a,o),Ce(e)&&l.set(e,a),a)}function hr(e,t){return!e||!yl(t)?!1:(t=t.slice(2).replace(/Once$/,""),fe(e,t[0].toLowerCase()+t.slice(1))||fe(e,pn(t))||fe(e,t))}let ze=null,vr=null;function tr(e){const t=ze;return ze=e,vr=e&&e.type.__scopeId||null,t}function Hf(e){vr=e}function jf(){vr=null}function Su(e,t=ze,n){if(!t||e._n)return e;const l=(...r)=>{l._d&&Ka(-1);const o=tr(t);let a;try{a=e(...r)}finally{tr(o),l._d&&Ka(1)}return a};return l._n=!0,l._c=!0,l._d=!0,l}function Sr(e){const{type:t,vnode:n,proxy:l,withProxy:r,props:o,propsOptions:[a],slots:i,attrs:c,emit:u,render:d,renderCache:f,data:p,setupState:h,ctx:y,inheritAttrs:w}=e;let x,m;const b=tr(e);try{if(n.shapeFlag&4){const $=r||l;x=ft(d.call($,$,f,o,h,p,y)),m=c}else{const $=t;x=ft($.length>1?$(o,{attrs:c,slots:i,emit:u}):$(o,null)),m=t.props?c:Pu(c)}}catch($){ll.length=0,El($,e,1),x=Te(tt)}let M=x;if(m&&w!==!1){const $=Object.keys(m),{shapeFlag:q}=M;$.length&&q&7&&(a&&$.some(Ao)&&(m=Ou(m,a)),M=Gt(M,m))}return n.dirs&&(M=Gt(M),M.dirs=M.dirs?M.dirs.concat(n.dirs):n.dirs),n.transition&&(M.transition=n.transition),x=M,tr(b),x}const Pu=e=>{let t;for(const n in e)(n==="class"||n==="style"||yl(n))&&((t||(t={}))[n]=e[n]);return t},Ou=(e,t)=>{const n={};for(const l in e)(!Ao(l)||!(l.slice(9)in t))&&(n[l]=e[l]);return n};function Mu(e,t,n){const{props:l,children:r,component:o}=e,{props:a,children:i,patchFlag:c}=t,u=o.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return l?Ra(l,a,u):!!a;if(c&8){const d=t.dynamicProps;for(let f=0;fe.__isSuspense;function Ti(e,t){t&&t.pendingBranch?Q(e)?t.effects.push(...e):t.effects.push(e):ku(e)}function Iu(e,t){return Vo(e,null,t)}const Nl={};function se(e,t,n){return Vo(e,t,n)}function Vo(e,t,{immediate:n,deep:l,flush:r,onTrack:o,onTrigger:a}=Ae){var i;const c=ii()===((i=Ie)==null?void 0:i.scope)?Ie:null;let u,d=!1,f=!1;if(De(e)?(u=()=>e.value,d=Xl(e)):kn(e)?(u=()=>e,l=!0):Q(e)?(f=!0,d=e.some($=>kn($)||Xl($)),u=()=>e.map($=>{if(De($))return $.value;if(kn($))return rn($);if(te($))return qt($,c,2)})):te(e)?t?u=()=>qt(e,c,2):u=()=>{if(!(c&&c.isUnmounted))return p&&p(),at(e,c,3,[h])}:u=vt,t&&l){const $=u;u=()=>rn($())}let p,h=$=>{p=b.onStop=()=>{qt($,c,4)}},y;if(Dn)if(h=vt,t?n&&at(t,c,3,[u(),f?[]:void 0,h]):u(),r==="sync"){const $=L0();y=$.__watcherHandles||($.__watcherHandles=[])}else return vt;let w=f?new Array(e.length).fill(Nl):Nl;const x=()=>{if(b.active)if(t){const $=b.run();(l||d||(f?$.some((q,P)=>il(q,w[P])):il($,w)))&&(p&&p(),at(t,c,3,[$,w===Nl?void 0:f&&w[0]===Nl?[]:w,h]),w=$)}else b.run()};x.allowRecurse=!!t;let m;r==="sync"?m=x:r==="post"?m=()=>Ue(x,c&&c.suspense):(x.pre=!0,c&&(x.id=c.uid),m=()=>pr(x));const b=new Mo(u,m);t?n?x():w=b.run():r==="post"?Ue(b.run.bind(b),c&&c.suspense):b.run();const M=()=>{b.stop(),c&&c.scope&&ko(c.scope.effects,b)};return y&&y.push(M),M}function Du(e,t,n){const l=this.proxy,r=pe(e)?e.includes(".")?Li(l,e):()=>l[e]:e.bind(l,l);let o;te(t)?o=t:(o=t.handler,n=t);const a=Ie;In(this);const i=Vo(r,o.bind(l),n);return a?In(a):cn(),i}function Li(e,t){const n=t.split(".");return()=>{let l=e;for(let r=0;r{rn(n,t)});else if(oi(e))for(const n in e)rn(e[n],t);return e}function qf(e,t){const n=ze;if(n===null)return e;const l=yr(n)||n.proxy,r=e.dirs||(e.dirs=[]);for(let o=0;o{e.isMounted=!0}),jo(()=>{e.isUnmounting=!0}),e}const rt=[Function,Array],Pi={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:rt,onEnter:rt,onAfterEnter:rt,onEnterCancelled:rt,onBeforeLeave:rt,onLeave:rt,onAfterLeave:rt,onLeaveCancelled:rt,onBeforeAppear:rt,onAppear:rt,onAfterAppear:rt,onAppearCancelled:rt},Ru={name:"BaseTransition",props:Pi,setup(e,{slots:t}){const n=Gn(),l=Si();let r;return()=>{const o=t.default&&Ho(t.default(),!0);if(!o||!o.length)return;let a=o[0];if(o.length>1){for(const w of o)if(w.type!==tt){a=w;break}}const i=ie(e),{mode:c}=i;if(l.isLeaving)return Pr(a);const u=za(a);if(!u)return Pr(a);const d=fl(u,i,l,n);pl(u,d);const f=n.subTree,p=f&&za(f);let h=!1;const{getTransitionKey:y}=u.type;if(y){const w=y();r===void 0?r=w:w!==r&&(r=w,h=!0)}if(p&&p.type!==tt&&(!nn(u,p)||h)){const w=fl(p,i,l,n);if(pl(p,w),c==="out-in")return l.isLeaving=!0,w.afterLeave=()=>{l.isLeaving=!1,n.update.active!==!1&&n.update()},Pr(a);c==="in-out"&&u.type!==tt&&(w.delayLeave=(x,m,b)=>{const M=Oi(l,p);M[String(p.key)]=p,x._leaveCb=()=>{m(),x._leaveCb=void 0,delete d.delayedLeave},d.delayedLeave=b})}return a}}},zu=Ru;function Oi(e,t){const{leavingVNodes:n}=e;let l=n.get(t.type);return l||(l=Object.create(null),n.set(t.type,l)),l}function fl(e,t,n,l){const{appear:r,mode:o,persisted:a=!1,onBeforeEnter:i,onEnter:c,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:f,onLeave:p,onAfterLeave:h,onLeaveCancelled:y,onBeforeAppear:w,onAppear:x,onAfterAppear:m,onAppearCancelled:b}=t,M=String(e.key),$=Oi(n,e),q=(A,H)=>{A&&at(A,l,9,H)},P=(A,H)=>{const K=H[1];q(A,H),Q(A)?A.every(le=>le.length<=1)&&K():A.length<=1&&K()},G={mode:o,persisted:a,beforeEnter(A){let H=i;if(!n.isMounted)if(r)H=w||i;else return;A._leaveCb&&A._leaveCb(!0);const K=$[M];K&&nn(e,K)&&K.el._leaveCb&&K.el._leaveCb(),q(H,[A])},enter(A){let H=c,K=u,le=d;if(!n.isMounted)if(r)H=x||c,K=m||u,le=b||d;else return;let N=!1;const Z=A._enterCb=j=>{N||(N=!0,j?q(le,[A]):q(K,[A]),G.delayedLeave&&G.delayedLeave(),A._enterCb=void 0)};H?P(H,[A,Z]):Z()},leave(A,H){const K=String(e.key);if(A._enterCb&&A._enterCb(!0),n.isUnmounting)return H();q(f,[A]);let le=!1;const N=A._leaveCb=Z=>{le||(le=!0,H(),Z?q(y,[A]):q(h,[A]),A._leaveCb=void 0,$[K]===e&&delete $[K])};$[K]=e,p?P(p,[A,N]):N()},clone(A){return fl(A,t,n,l)}};return G}function Pr(e){if(_l(e))return e=Gt(e),e.children=null,e}function za(e){return _l(e)?e.children?e.children[0]:void 0:e}function pl(e,t){e.shapeFlag&6&&e.component?pl(e.component.subTree,t):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function Ho(e,t=!1,n){let l=[],r=0;for(let o=0;o1)for(let o=0;oLe({name:e.name},t,{setup:e}))():e}const Ln=e=>!!e.type.__asyncLoader;function X(e){te(e)&&(e={loader:e});const{loader:t,loadingComponent:n,errorComponent:l,delay:r=200,timeout:o,suspensible:a=!0,onError:i}=e;let c=null,u,d=0;const f=()=>(d++,c=null,p()),p=()=>{let h;return c||(h=c=t().catch(y=>{if(y=y instanceof Error?y:new Error(String(y)),i)return new Promise((w,x)=>{i(y,()=>w(f()),()=>x(y),d+1)});throw y}).then(y=>h!==c&&c?c:(y&&(y.__esModule||y[Symbol.toStringTag]==="Module")&&(y=y.default),u=y,y)))};return B({name:"AsyncComponentWrapper",__asyncLoader:p,get __asyncResolved(){return u},setup(){const h=Ie;if(u)return()=>Or(u,h);const y=b=>{c=null,El(b,h,13,!l)};if(a&&h.suspense||Dn)return p().then(b=>()=>Or(b,h)).catch(b=>(y(b),()=>l?Te(l,{error:b}):null));const w=V(!1),x=V(),m=V(!!r);return r&&setTimeout(()=>{m.value=!1},r),o!=null&&setTimeout(()=>{if(!w.value&&!x.value){const b=new Error(`Async component timed out after ${o}ms.`);y(b),x.value=b}},o),p().then(()=>{w.value=!0,h.parent&&_l(h.parent.vnode)&&pr(h.parent.update)}).catch(b=>{y(b),x.value=b}),()=>{if(w.value&&u)return Or(u,h);if(x.value&&l)return Te(l,{error:x.value});if(n&&!m.value)return Te(n)}}})}function Or(e,t){const{ref:n,props:l,children:r,ce:o}=t.vnode,a=Te(e,l,r);return a.ref=n,a.ce=o,delete t.vnode.ce,a}const _l=e=>e.type.__isKeepAlive;function Fu(e,t){Mi(e,"a",t)}function Nu(e,t){Mi(e,"da",t)}function Mi(e,t,n=Ie){const l=e.__wdc||(e.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(mr(t,l,n),n){let r=n.parent;for(;r&&r.parent;)_l(r.parent.vnode)&&Vu(l,t,n,r),r=r.parent}}function Vu(e,t,n,l){const r=mr(t,e,l,!0);Un(()=>{ko(l[t],r)},n)}function mr(e,t,n=Ie,l=!1){if(n){const r=n[e]||(n[e]=[]),o=t.__weh||(t.__weh=(...a)=>{if(n.isUnmounted)return;Nn(),In(n);const i=at(t,n,e,a);return cn(),Vn(),i});return l?r.unshift(o):r.push(o),o}}const Bt=e=>(t,n=Ie)=>(!Dn||e==="sp")&&mr(e,(...l)=>t(...l),n),Hu=Bt("bm"),me=Bt("m"),ju=Bt("bu"),$i=Bt("u"),jo=Bt("bum"),Un=Bt("um"),qu=Bt("sp"),Uu=Bt("rtg"),Gu=Bt("rtc");function Wu(e,t=Ie){mr("ec",e,t)}const Bi="components";function et(e,t){return Yu(Bi,e,!0,t)||e}const Ku=Symbol.for("v-ndc");function Yu(e,t,n=!0,l=!1){const r=ze||Ie;if(r){const o=r.type;if(e===Bi){const i=A0(o,!1);if(i&&(i===t||i===st(t)||i===bl(st(t))))return o}const a=Fa(r[e]||o[e],t)||Fa(r.appContext[e],t);return!a&&l?o:a}}function Fa(e,t){return e&&(e[t]||e[st(t)]||e[bl(st(t))])}function Uf(e,t,n,l){let r;const o=n&&n[l];if(Q(e)||pe(e)){r=new Array(e.length);for(let a=0,i=e.length;at(a,i,void 0,o&&o[i]));else{const a=Object.keys(e);r=new Array(a.length);for(let i=0,c=a.length;ior(t)?!(t.type===tt||t.type===je&&!Ii(t.children)):!0)?e:null}const to=e=>e?Ji(e)?yr(e)||e.proxy:to(e.parent):null,tl=Le(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>to(e.parent),$root:e=>to(e.root),$emit:e=>e.emit,$options:e=>qo(e),$forceUpdate:e=>e.f||(e.f=()=>pr(e.update)),$nextTick:e=>e.n||(e.n=qn.bind(e.proxy)),$watch:e=>Du.bind(e)}),Mr=(e,t)=>e!==Ae&&!e.__isScriptSetup&&fe(e,t),Ju={get({_:e},t){const{ctx:n,setupState:l,data:r,props:o,accessCache:a,type:i,appContext:c}=e;let u;if(t[0]!=="$"){const h=a[t];if(h!==void 0)switch(h){case 1:return l[t];case 2:return r[t];case 4:return n[t];case 3:return o[t]}else{if(Mr(l,t))return a[t]=1,l[t];if(r!==Ae&&fe(r,t))return a[t]=2,r[t];if((u=e.propsOptions[0])&&fe(u,t))return a[t]=3,o[t];if(n!==Ae&&fe(n,t))return a[t]=4,n[t];no&&(a[t]=0)}}const d=tl[t];let f,p;if(d)return t==="$attrs"&&We(e,"get",t),d(e);if((f=i.__cssModules)&&(f=f[t]))return f;if(n!==Ae&&fe(n,t))return a[t]=4,n[t];if(p=c.config.globalProperties,fe(p,t))return p[t]},set({_:e},t,n){const{data:l,setupState:r,ctx:o}=e;return Mr(r,t)?(r[t]=n,!0):l!==Ae&&fe(l,t)?(l[t]=n,!0):fe(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(o[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:l,appContext:r,propsOptions:o}},a){let i;return!!n[a]||e!==Ae&&fe(e,a)||Mr(t,a)||(i=o[0])&&fe(i,a)||fe(l,a)||fe(tl,a)||fe(r.config.globalProperties,a)},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:fe(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function Na(e){return Q(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let no=!0;function Qu(e){const t=qo(e),n=e.proxy,l=e.ctx;no=!1,t.beforeCreate&&Va(t.beforeCreate,e,"bc");const{data:r,computed:o,methods:a,watch:i,provide:c,inject:u,created:d,beforeMount:f,mounted:p,beforeUpdate:h,updated:y,activated:w,deactivated:x,beforeDestroy:m,beforeUnmount:b,destroyed:M,unmounted:$,render:q,renderTracked:P,renderTriggered:G,errorCaptured:A,serverPrefetch:H,expose:K,inheritAttrs:le,components:N,directives:Z,filters:j}=t;if(u&&Zu(u,l,null),a)for(const ye in a){const he=a[ye];te(he)&&(l[ye]=he.bind(n))}if(r){const ye=r.call(n,n);Ce(ye)&&(e.data=Hn(ye))}if(no=!0,o)for(const ye in o){const he=o[ye],Ye=te(he)?he.bind(n,n):te(he.get)?he.get.bind(n,n):vt,Ve=!te(he)&&te(he.set)?he.set.bind(n):vt,Je=_({get:Ye,set:Ve});Object.defineProperty(l,ye,{enumerable:!0,configurable:!0,get:()=>Je.value,set:Oe=>Je.value=Oe})}if(i)for(const ye in i)Di(i[ye],l,n,ye);if(c){const ye=te(c)?c.call(n):c;Reflect.ownKeys(ye).forEach(he=>{mt(he,ye[he])})}d&&Va(d,e,"c");function ne(ye,he){Q(he)?he.forEach(Ye=>ye(Ye.bind(n))):he&&ye(he.bind(n))}if(ne(Hu,f),ne(me,p),ne(ju,h),ne($i,y),ne(Fu,w),ne(Nu,x),ne(Wu,A),ne(Gu,P),ne(Uu,G),ne(jo,b),ne(Un,$),ne(qu,H),Q(K))if(K.length){const ye=e.exposed||(e.exposed={});K.forEach(he=>{Object.defineProperty(ye,he,{get:()=>n[he],set:Ye=>n[he]=Ye})})}else e.exposed||(e.exposed={});q&&e.render===vt&&(e.render=q),le!=null&&(e.inheritAttrs=le),N&&(e.components=N),Z&&(e.directives=Z)}function Zu(e,t,n=vt){Q(e)&&(e=lo(e));for(const l in e){const r=e[l];let o;Ce(r)?"default"in r?o=ce(r.from||l,r.default,!0):o=ce(r.from||l):o=ce(r),De(o)?Object.defineProperty(t,l,{enumerable:!0,configurable:!0,get:()=>o.value,set:a=>o.value=a}):t[l]=o}}function Va(e,t,n){at(Q(e)?e.map(l=>l.bind(t.proxy)):e.bind(t.proxy),t,n)}function Di(e,t,n,l){const r=l.includes(".")?Li(n,l):()=>n[l];if(pe(e)){const o=t[e];te(o)&&se(r,o)}else if(te(e))se(r,e.bind(n));else if(Ce(e))if(Q(e))e.forEach(o=>Di(o,t,n,l));else{const o=te(e.handler)?e.handler.bind(n):t[e.handler];te(o)&&se(r,o,e)}}function qo(e){const t=e.type,{mixins:n,extends:l}=t,{mixins:r,optionsCache:o,config:{optionMergeStrategies:a}}=e.appContext,i=o.get(t);let c;return i?c=i:!r.length&&!n&&!l?c=t:(c={},r.length&&r.forEach(u=>nr(c,u,a,!0)),nr(c,t,a)),Ce(t)&&o.set(t,c),c}function nr(e,t,n,l=!1){const{mixins:r,extends:o}=t;o&&nr(e,o,n,!0),r&&r.forEach(a=>nr(e,a,n,!0));for(const a in t)if(!(l&&a==="expose")){const i=Xu[a]||n&&n[a];e[a]=i?i(e[a],t[a]):t[a]}return e}const Xu={data:Ha,props:ja,emits:ja,methods:Xn,computed:Xn,beforeCreate:He,created:He,beforeMount:He,mounted:He,beforeUpdate:He,updated:He,beforeDestroy:He,beforeUnmount:He,destroyed:He,unmounted:He,activated:He,deactivated:He,errorCaptured:He,serverPrefetch:He,components:Xn,directives:Xn,watch:t0,provide:Ha,inject:e0};function Ha(e,t){return t?e?function(){return Le(te(e)?e.call(this,this):e,te(t)?t.call(this,this):t)}:t:e}function e0(e,t){return Xn(lo(e),lo(t))}function lo(e){if(Q(e)){const t={};for(let n=0;n1)return n&&te(t)?t.call(l&&l.proxy):t}}function r0(e,t,n,l=!1){const r={},o={};Ql(o,gr,1),e.propsDefaults=Object.create(null),zi(e,t,r,o);for(const a in e.propsOptions[0])a in r||(r[a]=void 0);n?e.props=l?r:pu(r):e.type.props?e.props=r:e.props=o,e.attrs=o}function o0(e,t,n,l){const{props:r,attrs:o,vnode:{patchFlag:a}}=e,i=ie(r),[c]=e.propsOptions;let u=!1;if((l||a>0)&&!(a&16)){if(a&8){const d=e.vnode.dynamicProps;for(let f=0;f{c=!0;const[p,h]=Fi(f,t,!0);Le(a,p),h&&i.push(...h)};!n&&t.mixins.length&&t.mixins.forEach(d),e.extends&&d(e.extends),e.mixins&&e.mixins.forEach(d)}if(!o&&!c)return Ce(e)&&l.set(e,Cn),Cn;if(Q(o))for(let d=0;d-1,h[1]=w<0||y-1||fe(h,"default"))&&i.push(f)}}}const u=[a,i];return Ce(e)&&l.set(e,u),u}function qa(e){return e[0]!=="$"}function Ua(e){const t=e&&e.toString().match(/^\s*(function|class) (\w+)/);return t?t[2]:e===null?"null":""}function Ga(e,t){return Ua(e)===Ua(t)}function Wa(e,t){return Q(t)?t.findIndex(n=>Ga(n,e)):te(t)&&Ga(t,e)?0:-1}const Ni=e=>e[0]==="_"||e==="$stable",Uo=e=>Q(e)?e.map(ft):[ft(e)],a0=(e,t,n)=>{if(t._n)return t;const l=Su((...r)=>Uo(t(...r)),n);return l._c=!1,l},Vi=(e,t,n)=>{const l=e._ctx;for(const r in e){if(Ni(r))continue;const o=e[r];if(te(o))t[r]=a0(r,o,l);else if(o!=null){const a=Uo(o);t[r]=()=>a}}},Hi=(e,t)=>{const n=Uo(t);e.slots.default=()=>n},s0=(e,t)=>{if(e.vnode.shapeFlag&32){const n=t._;n?(e.slots=ie(t),Ql(t,"_",n)):Vi(t,e.slots={})}else e.slots={},t&&Hi(e,t);Ql(e.slots,gr,1)},i0=(e,t,n)=>{const{vnode:l,slots:r}=e;let o=!0,a=Ae;if(l.shapeFlag&32){const i=t._;i?n&&i===1?o=!1:(Le(r,t),!n&&i===1&&delete r._):(o=!t.$stable,Vi(t,r)),a=t}else t&&(Hi(e,t),a={default:1});if(o)for(const i in r)!Ni(i)&&!(i in a)&&delete r[i]};function rr(e,t,n,l,r=!1){if(Q(e)){e.forEach((p,h)=>rr(p,t&&(Q(t)?t[h]:t),n,l,r));return}if(Ln(l)&&!r)return;const o=l.shapeFlag&4?yr(l.component)||l.component.proxy:l.el,a=r?null:o,{i,r:c}=e,u=t&&t.r,d=i.refs===Ae?i.refs={}:i.refs,f=i.setupState;if(u!=null&&u!==c&&(pe(u)?(d[u]=null,fe(f,u)&&(f[u]=null)):De(u)&&(u.value=null)),te(c))qt(c,i,12,[a,d]);else{const p=pe(c),h=De(c);if(p||h){const y=()=>{if(e.f){const w=p?fe(f,c)?f[c]:d[c]:c.value;r?Q(w)&&ko(w,o):Q(w)?w.includes(o)||w.push(o):p?(d[c]=[o],fe(f,c)&&(f[c]=d[c])):(c.value=[o],e.k&&(d[e.k]=c.value))}else p?(d[c]=a,fe(f,c)&&(f[c]=a)):h&&(c.value=a,e.k&&(d[e.k]=a))};a?(y.id=-1,Ue(y,n)):y()}}}let Dt=!1;const Vl=e=>/svg/.test(e.namespaceURI)&&e.tagName!=="foreignObject",Hl=e=>e.nodeType===8;function c0(e){const{mt:t,p:n,o:{patchProp:l,createText:r,nextSibling:o,parentNode:a,remove:i,insert:c,createComment:u}}=e,d=(m,b)=>{if(!b.hasChildNodes()){n(null,m,b),er(),b._vnode=m;return}Dt=!1,f(b.firstChild,m,null,null,null),er(),b._vnode=m,Dt&&console.error("Hydration completed but contains mismatches.")},f=(m,b,M,$,q,P=!1)=>{const G=Hl(m)&&m.data==="[",A=()=>w(m,b,M,$,q,G),{type:H,ref:K,shapeFlag:le,patchFlag:N}=b;let Z=m.nodeType;b.el=m,N===-2&&(P=!1,b.dynamicChildren=null);let j=null;switch(H){case Bn:Z!==3?b.children===""?(c(b.el=r(""),a(m),m),j=m):j=A():(m.data!==b.children&&(Dt=!0,m.data=b.children),j=o(m));break;case tt:Z!==8||G?j=A():j=o(m);break;case nl:if(G&&(m=o(m),Z=m.nodeType),Z===1||Z===3){j=m;const Pe=!b.children.length;for(let ne=0;ne{P=P||!!b.dynamicChildren;const{type:G,props:A,patchFlag:H,shapeFlag:K,dirs:le}=b,N=G==="input"&&le||G==="option";if(N||H!==-1){if(le&&Ct(b,null,M,"created"),A)if(N||!P||H&48)for(const j in A)(N&&j.endsWith("value")||yl(j)&&!el(j))&&l(m,j,null,A[j],!1,void 0,M);else A.onClick&&l(m,"onClick",null,A.onClick,!1,void 0,M);let Z;if((Z=A&&A.onVnodeBeforeMount)&&ot(Z,M,b),le&&Ct(b,null,M,"beforeMount"),((Z=A&&A.onVnodeMounted)||le)&&Ti(()=>{Z&&ot(Z,M,b),le&&Ct(b,null,M,"mounted")},$),K&16&&!(A&&(A.innerHTML||A.textContent))){let j=h(m.firstChild,b,m,M,$,q,P);for(;j;){Dt=!0;const Pe=j;j=j.nextSibling,i(Pe)}}else K&8&&m.textContent!==b.children&&(Dt=!0,m.textContent=b.children)}return m.nextSibling},h=(m,b,M,$,q,P,G)=>{G=G||!!b.dynamicChildren;const A=b.children,H=A.length;for(let K=0;K{const{slotScopeIds:G}=b;G&&(q=q?q.concat(G):G);const A=a(m),H=h(o(m),b,A,M,$,q,P);return H&&Hl(H)&&H.data==="]"?o(b.anchor=H):(Dt=!0,c(b.anchor=u("]"),A,H),H)},w=(m,b,M,$,q,P)=>{if(Dt=!0,b.el=null,P){const H=x(m);for(;;){const K=o(m);if(K&&K!==H)i(K);else break}}const G=o(m),A=a(m);return i(m),n(null,b,A,G,M,$,Vl(A),q),G},x=m=>{let b=0;for(;m;)if(m=o(m),m&&Hl(m)&&(m.data==="["&&b++,m.data==="]")){if(b===0)return o(m);b--}return m};return[d,f]}const Ue=Ti;function u0(e){return d0(e,c0)}function d0(e,t){const n=Jr();n.__VUE__=!0;const{insert:l,remove:r,patchProp:o,createElement:a,createText:i,createComment:c,setText:u,setElementText:d,parentNode:f,nextSibling:p,setScopeId:h=vt,insertStaticContent:y}=e,w=(v,g,E,C=null,L=null,S=null,z=!1,I=null,D=!!g.dynamicChildren)=>{if(v===g)return;v&&!nn(v,g)&&(C=k(v),Oe(v,L,S,!0),v=null),g.patchFlag===-2&&(D=!1,g.dynamicChildren=null);const{type:O,ref:Y,shapeFlag:U}=g;switch(O){case Bn:x(v,g,E,C);break;case tt:m(v,g,E,C);break;case nl:v==null&&b(g,E,C,z);break;case je:N(v,g,E,C,L,S,z,I,D);break;default:U&1?q(v,g,E,C,L,S,z,I,D):U&6?Z(v,g,E,C,L,S,z,I,D):(U&64||U&128)&&O.process(v,g,E,C,L,S,z,I,D,R)}Y!=null&&L&&rr(Y,v&&v.ref,S,g||v,!g)},x=(v,g,E,C)=>{if(v==null)l(g.el=i(g.children),E,C);else{const L=g.el=v.el;g.children!==v.children&&u(L,g.children)}},m=(v,g,E,C)=>{v==null?l(g.el=c(g.children||""),E,C):g.el=v.el},b=(v,g,E,C)=>{[v.el,v.anchor]=y(v.children,g,E,C,v.el,v.anchor)},M=({el:v,anchor:g},E,C)=>{let L;for(;v&&v!==g;)L=p(v),l(v,E,C),v=L;l(g,E,C)},$=({el:v,anchor:g})=>{let E;for(;v&&v!==g;)E=p(v),r(v),v=E;r(g)},q=(v,g,E,C,L,S,z,I,D)=>{z=z||g.type==="svg",v==null?P(g,E,C,L,S,z,I,D):H(v,g,L,S,z,I,D)},P=(v,g,E,C,L,S,z,I)=>{let D,O;const{type:Y,props:U,shapeFlag:J,transition:ee,dirs:re}=v;if(D=v.el=a(v.type,S,U&&U.is,U),J&8?d(D,v.children):J&16&&A(v.children,D,null,C,L,S&&Y!=="foreignObject",z,I),re&&Ct(v,null,C,"created"),G(D,v,v.scopeId,z,C),U){for(const Ee in U)Ee!=="value"&&!el(Ee)&&o(D,Ee,null,U[Ee],S,v.children,C,L,Be);"value"in U&&o(D,"value",null,U.value),(O=U.onVnodeBeforeMount)&&ot(O,C,v)}re&&Ct(v,null,C,"beforeMount");const xe=(!L||L&&!L.pendingBranch)&&ee&&!ee.persisted;xe&&ee.beforeEnter(D),l(D,g,E),((O=U&&U.onVnodeMounted)||xe||re)&&Ue(()=>{O&&ot(O,C,v),xe&&ee.enter(D),re&&Ct(v,null,C,"mounted")},L)},G=(v,g,E,C,L)=>{if(E&&h(v,E),C)for(let S=0;S{for(let O=D;O{const I=g.el=v.el;let{patchFlag:D,dynamicChildren:O,dirs:Y}=g;D|=v.patchFlag&16;const U=v.props||Ae,J=g.props||Ae;let ee;E&&Xt(E,!1),(ee=J.onVnodeBeforeUpdate)&&ot(ee,E,g,v),Y&&Ct(g,v,E,"beforeUpdate"),E&&Xt(E,!0);const re=L&&g.type!=="foreignObject";if(O?K(v.dynamicChildren,O,I,E,C,re,S):z||he(v,g,I,null,E,C,re,S,!1),D>0){if(D&16)le(I,g,U,J,E,C,L);else if(D&2&&U.class!==J.class&&o(I,"class",null,J.class,L),D&4&&o(I,"style",U.style,J.style,L),D&8){const xe=g.dynamicProps;for(let Ee=0;Ee{ee&&ot(ee,E,g,v),Y&&Ct(g,v,E,"updated")},C)},K=(v,g,E,C,L,S,z)=>{for(let I=0;I{if(E!==C){if(E!==Ae)for(const I in E)!el(I)&&!(I in C)&&o(v,I,E[I],null,z,g.children,L,S,Be);for(const I in C){if(el(I))continue;const D=C[I],O=E[I];D!==O&&I!=="value"&&o(v,I,O,D,z,g.children,L,S,Be)}"value"in C&&o(v,"value",E.value,C.value)}},N=(v,g,E,C,L,S,z,I,D)=>{const O=g.el=v?v.el:i(""),Y=g.anchor=v?v.anchor:i("");let{patchFlag:U,dynamicChildren:J,slotScopeIds:ee}=g;ee&&(I=I?I.concat(ee):ee),v==null?(l(O,E,C),l(Y,E,C),A(g.children,E,Y,L,S,z,I,D)):U>0&&U&64&&J&&v.dynamicChildren?(K(v.dynamicChildren,J,E,L,S,z,I),(g.key!=null||L&&g===L.subTree)&&ji(v,g,!0)):he(v,g,E,Y,L,S,z,I,D)},Z=(v,g,E,C,L,S,z,I,D)=>{g.slotScopeIds=I,v==null?g.shapeFlag&512?L.ctx.activate(g,E,C,z,D):j(g,E,C,L,S,z,D):Pe(v,g,D)},j=(v,g,E,C,L,S,z)=>{const I=v.component=E0(v,C,L);if(_l(v)&&(I.ctx.renderer=R),_0(I),I.asyncDep){if(L&&L.registerDep(I,ne),!v.el){const D=I.subTree=Te(tt);m(null,D,g,E)}return}ne(I,v,g,E,L,S,z)},Pe=(v,g,E)=>{const C=g.component=v.component;if(Mu(v,g,E))if(C.asyncDep&&!C.asyncResolved){ye(C,g,E);return}else C.next=g,Au(C.update),C.update();else g.el=v.el,C.vnode=g},ne=(v,g,E,C,L,S,z)=>{const I=()=>{if(v.isMounted){let{next:Y,bu:U,u:J,parent:ee,vnode:re}=v,xe=Y,Ee;Xt(v,!1),Y?(Y.el=re.el,ye(v,Y,z)):Y=re,U&&Yl(U),(Ee=Y.props&&Y.props.onVnodeBeforeUpdate)&&ot(Ee,ee,Y,re),Xt(v,!0);const Me=Sr(v),ct=v.subTree;v.subTree=Me,w(ct,Me,f(ct.el),k(ct),v,L,S),Y.el=Me.el,xe===null&&$u(v,Me.el),J&&Ue(J,L),(Ee=Y.props&&Y.props.onVnodeUpdated)&&Ue(()=>ot(Ee,ee,Y,re),L)}else{let Y;const{el:U,props:J}=g,{bm:ee,m:re,parent:xe}=v,Ee=Ln(g);if(Xt(v,!1),ee&&Yl(ee),!Ee&&(Y=J&&J.onVnodeBeforeMount)&&ot(Y,xe,g),Xt(v,!0),U&&ge){const Me=()=>{v.subTree=Sr(v),ge(U,v.subTree,v,L,null)};Ee?g.type.__asyncLoader().then(()=>!v.isUnmounted&&Me()):Me()}else{const Me=v.subTree=Sr(v);w(null,Me,E,C,v,L,S),g.el=Me.el}if(re&&Ue(re,L),!Ee&&(Y=J&&J.onVnodeMounted)){const Me=g;Ue(()=>ot(Y,xe,Me),L)}(g.shapeFlag&256||xe&&Ln(xe.vnode)&&xe.vnode.shapeFlag&256)&&v.a&&Ue(v.a,L),v.isMounted=!0,g=E=C=null}},D=v.effect=new Mo(I,()=>pr(O),v.scope),O=v.update=()=>D.run();O.id=v.uid,Xt(v,!0),O()},ye=(v,g,E)=>{g.component=v;const C=v.vnode.props;v.vnode=g,v.next=null,o0(v,g.props,C,E),i0(v,g.children,E),Nn(),Da(),Vn()},he=(v,g,E,C,L,S,z,I,D=!1)=>{const O=v&&v.children,Y=v?v.shapeFlag:0,U=g.children,{patchFlag:J,shapeFlag:ee}=g;if(J>0){if(J&128){Ve(O,U,E,C,L,S,z,I,D);return}else if(J&256){Ye(O,U,E,C,L,S,z,I,D);return}}ee&8?(Y&16&&Be(O,L,S),U!==O&&d(E,U)):Y&16?ee&16?Ve(O,U,E,C,L,S,z,I,D):Be(O,L,S,!0):(Y&8&&d(E,""),ee&16&&A(U,E,C,L,S,z,I,D))},Ye=(v,g,E,C,L,S,z,I,D)=>{v=v||Cn,g=g||Cn;const O=v.length,Y=g.length,U=Math.min(O,Y);let J;for(J=0;JY?Be(v,L,S,!0,!1,U):A(g,E,C,L,S,z,I,D,U)},Ve=(v,g,E,C,L,S,z,I,D)=>{let O=0;const Y=g.length;let U=v.length-1,J=Y-1;for(;O<=U&&O<=J;){const ee=v[O],re=g[O]=D?Nt(g[O]):ft(g[O]);if(nn(ee,re))w(ee,re,E,null,L,S,z,I,D);else break;O++}for(;O<=U&&O<=J;){const ee=v[U],re=g[J]=D?Nt(g[J]):ft(g[J]);if(nn(ee,re))w(ee,re,E,null,L,S,z,I,D);else break;U--,J--}if(O>U){if(O<=J){const ee=J+1,re=eeJ)for(;O<=U;)Oe(v[O],L,S,!0),O++;else{const ee=O,re=O,xe=new Map;for(O=re;O<=J;O++){const Qe=g[O]=D?Nt(g[O]):ft(g[O]);Qe.key!=null&&xe.set(Qe.key,O)}let Ee,Me=0;const ct=J-re+1;let gn=!1,Ca=0;const Kn=new Array(ct);for(O=0;O=ct){Oe(Qe,L,S,!0);continue}let xt;if(Qe.key!=null)xt=xe.get(Qe.key);else for(Ee=re;Ee<=J;Ee++)if(Kn[Ee-re]===0&&nn(Qe,g[Ee])){xt=Ee;break}xt===void 0?Oe(Qe,L,S,!0):(Kn[xt-re]=O+1,xt>=Ca?Ca=xt:gn=!0,w(Qe,g[xt],E,null,L,S,z,I,D),Me++)}const Aa=gn?f0(Kn):Cn;for(Ee=Aa.length-1,O=ct-1;O>=0;O--){const Qe=re+O,xt=g[Qe],ka=Qe+1{const{el:S,type:z,transition:I,children:D,shapeFlag:O}=v;if(O&6){Je(v.component.subTree,g,E,C);return}if(O&128){v.suspense.move(g,E,C);return}if(O&64){z.move(v,g,E,R);return}if(z===je){l(S,g,E);for(let U=0;UI.enter(S),L);else{const{leave:U,delayLeave:J,afterLeave:ee}=I,re=()=>l(S,g,E),xe=()=>{U(S,()=>{re(),ee&&ee()})};J?J(S,re,xe):xe()}else l(S,g,E)},Oe=(v,g,E,C=!1,L=!1)=>{const{type:S,props:z,ref:I,children:D,dynamicChildren:O,shapeFlag:Y,patchFlag:U,dirs:J}=v;if(I!=null&&rr(I,null,E,v,!0),Y&256){g.ctx.deactivate(v);return}const ee=Y&1&&J,re=!Ln(v);let xe;if(re&&(xe=z&&z.onVnodeBeforeUnmount)&&ot(xe,g,v),Y&6)Zt(v.component,E,C);else{if(Y&128){v.suspense.unmount(E,C);return}ee&&Ct(v,null,g,"beforeUnmount"),Y&64?v.type.remove(v,g,E,L,R,C):O&&(S!==je||U>0&&U&64)?Be(O,g,E,!1,!0):(S===je&&U&384||!L&&Y&16)&&Be(D,g,E),C&&_t(v)}(re&&(xe=z&&z.onVnodeUnmounted)||ee)&&Ue(()=>{xe&&ot(xe,g,v),ee&&Ct(v,null,g,"unmounted")},E)},_t=v=>{const{type:g,el:E,anchor:C,transition:L}=v;if(g===je){wt(E,C);return}if(g===nl){$(v);return}const S=()=>{r(E),L&&!L.persisted&&L.afterLeave&&L.afterLeave()};if(v.shapeFlag&1&&L&&!L.persisted){const{leave:z,delayLeave:I}=L,D=()=>z(E,S);I?I(v.el,S,D):D()}else S()},wt=(v,g)=>{let E;for(;v!==g;)E=p(v),r(v),v=E;r(g)},Zt=(v,g,E)=>{const{bum:C,scope:L,update:S,subTree:z,um:I}=v;C&&Yl(C),L.stop(),S&&(S.active=!1,Oe(z,v,g,E)),I&&Ue(I,g),Ue(()=>{v.isUnmounted=!0},g),g&&g.pendingBranch&&!g.isUnmounted&&v.asyncDep&&!v.asyncResolved&&v.suspenseId===g.pendingId&&(g.deps--,g.deps===0&&g.resolve())},Be=(v,g,E,C=!1,L=!1,S=0)=>{for(let z=S;zv.shapeFlag&6?k(v.component.subTree):v.shapeFlag&128?v.suspense.next():p(v.anchor||v.el),F=(v,g,E)=>{v==null?g._vnode&&Oe(g._vnode,null,null,!0):w(g._vnode||null,v,g,null,null,null,E),Da(),er(),g._vnode=v},R={p:w,um:Oe,m:Je,r:_t,mt:j,mc:A,pc:he,pbc:K,n:k,o:e};let W,ge;return t&&([W,ge]=t(R)),{render:F,hydrate:W,createApp:l0(F,W)}}function Xt({effect:e,update:t},n){e.allowRecurse=t.allowRecurse=n}function ji(e,t,n=!1){const l=e.children,r=t.children;if(Q(l)&&Q(r))for(let o=0;o>1,e[n[i]]0&&(t[l]=n[o-1]),n[o]=l)}}for(o=n.length,a=n[o-1];o-- >0;)n[o]=a,a=t[a];return n}const p0=e=>e.__isTeleport,je=Symbol.for("v-fgt"),Bn=Symbol.for("v-txt"),tt=Symbol.for("v-cmt"),nl=Symbol.for("v-stc"),ll=[];let ht=null;function qi(e=!1){ll.push(ht=e?null:[])}function h0(){ll.pop(),ht=ll[ll.length-1]||null}let hl=1;function Ka(e){hl+=e}function Ui(e){return e.dynamicChildren=hl>0?ht||Cn:null,h0(),hl>0&&ht&&ht.push(e),e}function Wf(e,t,n,l,r,o){return Ui(Ki(e,t,n,l,r,o,!0))}function Gi(e,t,n,l,r){return Ui(Te(e,t,n,l,r,!0))}function or(e){return e?e.__v_isVNode===!0:!1}function nn(e,t){return e.type===t.type&&e.key===t.key}const gr="__vInternal",Wi=({key:e})=>e??null,Jl=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?pe(e)||De(e)||te(e)?{i:ze,r:e,k:t,f:!!n}:e:null);function Ki(e,t=null,n=null,l=0,r=null,o=e===je?0:1,a=!1,i=!1){const c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Wi(t),ref:t&&Jl(t),scopeId:vr,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:o,patchFlag:l,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:ze};return i?(Go(c,n),o&128&&e.normalize(c)):n&&(c.shapeFlag|=pe(n)?8:16),hl>0&&!a&&ht&&(c.patchFlag>0||o&6)&&c.patchFlag!==32&&ht.push(c),c}const Te=v0;function v0(e,t=null,n=null,l=0,r=null,o=!1){if((!e||e===Ku)&&(e=tt),or(e)){const i=Gt(e,t,!0);return n&&Go(i,n),hl>0&&!o&&ht&&(i.shapeFlag&6?ht[ht.indexOf(e)]=i:ht.push(i)),i.patchFlag|=-2,i}if(k0(e)&&(e=e.__vccOpts),t){t=m0(t);let{class:i,style:c}=t;i&&!pe(i)&&(t.class=Po(i)),Ce(c)&&(bi(c)&&!Q(c)&&(c=Le({},c)),t.style=So(c))}const a=pe(e)?1:Bu(e)?128:p0(e)?64:Ce(e)?4:te(e)?2:0;return Ki(e,t,n,l,r,a,o,!0)}function m0(e){return e?bi(e)||gr in e?Le({},e):e:null}function Gt(e,t,n=!1){const{props:l,ref:r,patchFlag:o,children:a}=e,i=t?g0(l||{},t):l;return{__v_isVNode:!0,__v_skip:!0,type:e.type,props:i,key:i&&Wi(i),ref:t&&t.ref?n&&r?Q(r)?r.concat(Jl(t)):[r,Jl(t)]:Jl(t):r,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:a,target:e.target,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==je?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:e.transition,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&Gt(e.ssContent),ssFallback:e.ssFallback&&Gt(e.ssFallback),el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce}}function Yi(e=" ",t=0){return Te(Bn,null,e,t)}function Kf(e,t){const n=Te(nl,null,e);return n.staticCount=t,n}function Yf(e="",t=!1){return t?(qi(),Gi(tt,null,e)):Te(tt,null,e)}function ft(e){return e==null||typeof e=="boolean"?Te(tt):Q(e)?Te(je,null,e.slice()):typeof e=="object"?Nt(e):Te(Bn,null,String(e))}function Nt(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:Gt(e)}function Go(e,t){let n=0;const{shapeFlag:l}=e;if(t==null)t=null;else if(Q(t))n=16;else if(typeof t=="object")if(l&65){const r=t.default;r&&(r._c&&(r._d=!1),Go(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!(gr in t)?t._ctx=ze:r===3&&ze&&(ze.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else te(t)?(t={default:t,_ctx:ze},n=32):(t=String(t),l&64?(n=16,t=[Yi(t)]):n=8);e.children=t,e.shapeFlag|=n}function g0(...e){const t={};for(let n=0;nIe||ze;let Wo,yn,Ya="__VUE_INSTANCE_SETTERS__";(yn=Jr()[Ya])||(yn=Jr()[Ya]=[]),yn.push(e=>Ie=e),Wo=e=>{yn.length>1?yn.forEach(t=>t(e)):yn[0](e)};const In=e=>{Wo(e),e.scope.on()},cn=()=>{Ie&&Ie.scope.off(),Wo(null)};function Ji(e){return e.vnode.shapeFlag&4}let Dn=!1;function _0(e,t=!1){Dn=t;const{props:n,children:l}=e.vnode,r=Ji(e);r0(e,n,r,t),s0(e,l);const o=r?w0(e,t):void 0;return Dn=!1,o}function w0(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=Ei(new Proxy(e.ctx,Ju));const{setup:l}=n;if(l){const r=e.setupContext=l.length>1?C0(e):null;In(e),Nn();const o=qt(l,e,0,[e.props,r]);if(Vn(),cn(),li(o)){if(o.then(cn,cn),t)return o.then(a=>{Ja(e,a,t)}).catch(a=>{El(a,e,0)});e.asyncDep=o}else Ja(e,o,t)}else Qi(e,t)}function Ja(e,t,n){te(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:Ce(t)&&(e.setupState=wi(t)),Qi(e,n)}let Qa;function Qi(e,t,n){const l=e.type;if(!e.render){if(!t&&Qa&&!l.render){const r=l.template||qo(e).template;if(r){const{isCustomElement:o,compilerOptions:a}=e.appContext.config,{delimiters:i,compilerOptions:c}=l,u=Le(Le({isCustomElement:o,delimiters:i},a),c);l.render=Qa(r,u)}}e.render=l.render||vt}In(e),Nn(),Qu(e),Vn(),cn()}function x0(e){return e.attrsProxy||(e.attrsProxy=new Proxy(e.attrs,{get(t,n){return We(e,"get","$attrs"),t[n]}}))}function C0(e){const t=n=>{e.exposed=n||{}};return{get attrs(){return x0(e)},slots:e.slots,emit:e.emit,expose:t}}function yr(e){if(e.exposed)return e.exposeProxy||(e.exposeProxy=new Proxy(wi(Ei(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in tl)return tl[n](e)},has(t,n){return n in t||n in tl}}))}function A0(e,t=!0){return te(e)?e.displayName||e.name:e.name||t&&e.__name}function k0(e){return te(e)&&"__vccOpts"in e}const _=(e,t)=>wu(e,t,Dn);function s(e,t,n){const l=arguments.length;return l===2?Ce(t)&&!Q(t)?or(t)?Te(e,null,[t]):Te(e,t):Te(e,null,t):(l>3?n=Array.prototype.slice.call(arguments,2):l===3&&or(n)&&(n=[n]),Te(e,t,n))}const T0=Symbol.for("v-scx"),L0=()=>ce(T0),S0="3.3.2",P0="http://www.w3.org/2000/svg",ln=typeof document<"u"?document:null,Za=ln&&ln.createElement("template"),O0={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,l)=>{const r=t?ln.createElementNS(P0,e):ln.createElement(e,n?{is:n}:void 0);return e==="select"&&l&&l.multiple!=null&&r.setAttribute("multiple",l.multiple),r},createText:e=>ln.createTextNode(e),createComment:e=>ln.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>ln.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,l,r,o){const a=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===o||!(r=r.nextSibling)););else{Za.innerHTML=l?`${e}`:e;const i=Za.content;if(l){const c=i.firstChild;for(;c.firstChild;)i.appendChild(c.firstChild);i.removeChild(c)}t.insertBefore(i,n)}return[a?a.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}};function M0(e,t,n){const l=e._vtc;l&&(t=(t?[t,...l]:[...l]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}function $0(e,t,n){const l=e.style,r=pe(n);if(n&&!r){if(t&&!pe(t))for(const o in t)n[o]==null&&oo(l,o,"");for(const o in n)oo(l,o,n[o])}else{const o=l.display;r?t!==n&&(l.cssText=n):t&&e.removeAttribute("style"),"_vod"in e&&(l.display=o)}}const Xa=/\s*!important$/;function oo(e,t,n){if(Q(n))n.forEach(l=>oo(e,t,l));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const l=B0(e,t);Xa.test(n)?e.setProperty(pn(l),n.replace(Xa,""),"important"):e[l]=n}}const es=["Webkit","Moz","ms"],$r={};function B0(e,t){const n=$r[t];if(n)return n;let l=st(t);if(l!=="filter"&&l in e)return $r[t]=l;l=bl(l);for(let r=0;rBr||(N0.then(()=>Br=0),Br=Date.now());function H0(e,t){const n=l=>{if(!l._vts)l._vts=Date.now();else if(l._vts<=n.attached)return;at(j0(l,n.value),t,5,[l])};return n.value=e,n.attached=V0(),n}function j0(e,t){if(Q(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(l=>r=>!r._stopped&&l&&l(r))}else return t}const ls=/^on[a-z]/,q0=(e,t,n,l,r=!1,o,a,i,c)=>{t==="class"?M0(e,l,r):t==="style"?$0(e,n,l):yl(t)?Ao(t)||z0(e,t,n,l,a):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):U0(e,t,l,r))?D0(e,t,l,o,a,i,c):(t==="true-value"?e._trueValue=l:t==="false-value"&&(e._falseValue=l),I0(e,t,l,r))};function U0(e,t,n,l){return l?!!(t==="innerHTML"||t==="textContent"||t in e&&ls.test(t)&&te(n)):t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA"||ls.test(t)&&pe(n)?!1:t in e}const Rt="transition",Yn="animation",Wt=(e,{slots:t})=>s(zu,Xi(e),t);Wt.displayName="Transition";const Zi={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},G0=Wt.props=Le({},Pi,Zi),en=(e,t=[])=>{Q(e)?e.forEach(n=>n(...t)):e&&e(...t)},rs=e=>e?Q(e)?e.some(t=>t.length>1):e.length>1:!1;function Xi(e){const t={};for(const N in e)N in Zi||(t[N]=e[N]);if(e.css===!1)return t;const{name:n="v",type:l,duration:r,enterFromClass:o=`${n}-enter-from`,enterActiveClass:a=`${n}-enter-active`,enterToClass:i=`${n}-enter-to`,appearFromClass:c=o,appearActiveClass:u=a,appearToClass:d=i,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:h=`${n}-leave-to`}=e,y=W0(r),w=y&&y[0],x=y&&y[1],{onBeforeEnter:m,onEnter:b,onEnterCancelled:M,onLeave:$,onLeaveCancelled:q,onBeforeAppear:P=m,onAppear:G=b,onAppearCancelled:A=M}=t,H=(N,Z,j)=>{Ft(N,Z?d:i),Ft(N,Z?u:a),j&&j()},K=(N,Z)=>{N._isLeaving=!1,Ft(N,f),Ft(N,h),Ft(N,p),Z&&Z()},le=N=>(Z,j)=>{const Pe=N?G:b,ne=()=>H(Z,N,j);en(Pe,[Z,ne]),os(()=>{Ft(Z,N?c:o),St(Z,N?d:i),rs(Pe)||as(Z,l,w,ne)})};return Le(t,{onBeforeEnter(N){en(m,[N]),St(N,o),St(N,a)},onBeforeAppear(N){en(P,[N]),St(N,c),St(N,u)},onEnter:le(!1),onAppear:le(!0),onLeave(N,Z){N._isLeaving=!0;const j=()=>K(N,Z);St(N,f),t1(),St(N,p),os(()=>{N._isLeaving&&(Ft(N,f),St(N,h),rs($)||as(N,l,x,j))}),en($,[N,j])},onEnterCancelled(N){H(N,!1),en(M,[N])},onAppearCancelled(N){H(N,!0),en(A,[N])},onLeaveCancelled(N){K(N),en(q,[N])}})}function W0(e){if(e==null)return null;if(Ce(e))return[Ir(e.enter),Ir(e.leave)];{const t=Ir(e);return[t,t]}}function Ir(e){return P2(e)}function St(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e._vtc||(e._vtc=new Set)).add(t)}function Ft(e,t){t.split(/\s+/).forEach(l=>l&&e.classList.remove(l));const{_vtc:n}=e;n&&(n.delete(t),n.size||(e._vtc=void 0))}function os(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let K0=0;function as(e,t,n,l){const r=e._endId=++K0,o=()=>{r===e._endId&&l()};if(n)return setTimeout(o,n);const{type:a,timeout:i,propCount:c}=e1(e,t);if(!a)return l();const u=a+"end";let d=0;const f=()=>{e.removeEventListener(u,p),o()},p=h=>{h.target===e&&++d>=c&&f()};setTimeout(()=>{d(n[y]||"").split(", "),r=l(`${Rt}Delay`),o=l(`${Rt}Duration`),a=ss(r,o),i=l(`${Yn}Delay`),c=l(`${Yn}Duration`),u=ss(i,c);let d=null,f=0,p=0;t===Rt?a>0&&(d=Rt,f=a,p=o.length):t===Yn?u>0&&(d=Yn,f=u,p=c.length):(f=Math.max(a,u),d=f>0?a>u?Rt:Yn:null,p=d?d===Rt?o.length:c.length:0);const h=d===Rt&&/\b(transform|all)(,|$)/.test(l(`${Rt}Property`).toString());return{type:d,timeout:f,propCount:p,hasTransform:h}}function ss(e,t){for(;e.lengthis(n)+is(e[l])))}function is(e){return Number(e.slice(0,-1).replace(",","."))*1e3}function t1(){return document.body.offsetHeight}const n1=new WeakMap,l1=new WeakMap,r1={name:"TransitionGroup",props:Le({},G0,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=Gn(),l=Si();let r,o;return $i(()=>{if(!r.length)return;const a=e.moveClass||`${e.name||"v"}-move`;if(!e4(r[0].el,n.vnode.el,a))return;r.forEach(Q0),r.forEach(Z0);const i=r.filter(X0);t1(),i.forEach(c=>{const u=c.el,d=u.style;St(u,a),d.transform=d.webkitTransform=d.transitionDuration="";const f=u._moveCb=p=>{p&&p.target!==u||(!p||/transform$/.test(p.propertyName))&&(u.removeEventListener("transitionend",f),u._moveCb=null,Ft(u,a))};u.addEventListener("transitionend",f)})}),()=>{const a=ie(e),i=Xi(a);let c=a.tag||je;r=o,o=t.default?Ho(t.default()):[];for(let u=0;udelete e.mode;r1.props;const J0=r1;function Q0(e){const t=e.el;t._moveCb&&t._moveCb(),t._enterCb&&t._enterCb()}function Z0(e){l1.set(e,e.el.getBoundingClientRect())}function X0(e){const t=n1.get(e),n=l1.get(e),l=t.left-n.left,r=t.top-n.top;if(l||r){const o=e.el.style;return o.transform=o.webkitTransform=`translate(${l}px,${r}px)`,o.transitionDuration="0s",e}}function e4(e,t,n){const l=e.cloneNode();e._vtc&&e._vtc.forEach(a=>{a.split(/\s+/).forEach(i=>i&&l.classList.remove(i))}),n.split(/\s+/).forEach(a=>a&&l.classList.add(a)),l.style.display="none";const r=t.nodeType===1?t:t.parentNode;r.appendChild(l);const{hasTransform:o}=e1(l);return r.removeChild(l),o}const cs=e=>{const t=e.props["onUpdate:modelValue"]||!1;return Q(t)?n=>Yl(t,n):t};function t4(e){e.target.composing=!0}function us(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const Jf={created(e,{modifiers:{lazy:t,trim:n,number:l}},r){e._assign=cs(r);const o=l||r.props&&r.props.type==="number";_n(e,t?"change":"input",a=>{if(a.target.composing)return;let i=e.value;n&&(i=i.trim()),o&&(i=Yr(i)),e._assign(i)}),n&&_n(e,"change",()=>{e.value=e.value.trim()}),t||(_n(e,"compositionstart",t4),_n(e,"compositionend",us),_n(e,"change",us))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,modifiers:{lazy:n,trim:l,number:r}},o){if(e._assign=cs(o),e.composing||document.activeElement===e&&e.type!=="range"&&(n||l&&e.value.trim()===t||(r||e.type==="number")&&Yr(e.value)===t))return;const a=t??"";e.value!==a&&(e.value=a)}},n4=["ctrl","shift","alt","meta"],l4={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>n4.some(n=>e[`${n}Key`]&&!t.includes(n))},Qf=(e,t)=>(n,...l)=>{for(let r=0;rn=>{if(!("key"in n))return;const l=pn(n.key);if(t.some(r=>r===l||r4[r]===l))return e(n)},Xf={beforeMount(e,{value:t},{transition:n}){e._vod=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Jn(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:l}){!t!=!n&&(l?t?(l.beforeEnter(e),Jn(e,!0),l.enter(e)):l.leave(e,()=>{Jn(e,!1)}):Jn(e,t))},beforeUnmount(e,{value:t}){Jn(e,t)}};function Jn(e,t){e.style.display=t?e._vod:"none"}const o4=Le({patchProp:q0},O0);let Dr,ds=!1;function a4(){return Dr=ds?Dr:u0(o4),ds=!0,Dr}const s4=(...e)=>{const t=a4().createApp(...e),{mount:n}=t;return t.mount=l=>{const r=i4(l);if(r)return n(r,!0,r instanceof SVGElement)},t};function i4(e){return pe(e)?document.querySelector(e):e}const c4={"v-8daa1a0e":()=>T(()=>import("./index.html-ea49af00.js"),[]).then(({data:e})=>e),"v-184f4da6":()=>T(()=>import("./intro.html-643bf0e3.js"),[]).then(({data:e})=>e),"v-2d0a870d":()=>T(()=>import("./index.html-f97f352c.js"),[]).then(({data:e})=>e),"v-5aa3d8ba":()=>T(()=>import("./intro.html-1c32b3c0.js"),[]).then(({data:e})=>e),"v-e8a3586c":()=>T(()=>import("./template.html-5d9fb92e.js"),[]).then(({data:e})=>e),"v-c3fa0194":()=>T(()=>import("./template.html-62758aef.js"),[]).then(({data:e})=>e),"v-3e42db3e":()=>T(()=>import("./NUMA Balancing.html-06b349f4.js"),[]).then(({data:e})=>e),"v-1f37d83d":()=>T(()=>import("./vscode qemu开发Linux内核.html-c2360532.js"),[]).then(({data:e})=>e),"v-fa5bbd4e":()=>T(()=>import("./Chapter0 前言.html-ee62ed45.js"),[]).then(({data:e})=>e),"v-40a655de":()=>T(()=>import("./Chapter1 编译器组成.html-2def8ff5.js"),[]).then(({data:e})=>e),"v-e2bd5838":()=>T(()=>import("./Chapter2 词法分析.html-54374521.js"),[]).then(({data:e})=>e),"v-4f5ffb7c":()=>T(()=>import("./Chapter3 语法分析.html-d25d9caf.js"),[]).then(({data:e})=>e),"v-a7388c80":()=>T(()=>import("./Chapter4 语义分析.html-9577457a.js"),[]).then(({data:e})=>e),"v-0fc134f8":()=>T(()=>import("./Chapter5 代码生成.html-5189a489.js"),[]).then(({data:e})=>e),"v-11f1c650":()=>T(()=>import("./could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-6b63758f.js"),[]).then(({data:e})=>e),"v-69ae52f9":()=>T(()=>import("./记一次 GP Debug 的心路历程.html-c07c20a5.js"),[]).then(({data:e})=>e),"v-384e46cc":()=>T(()=>import("./震惊!1等于0.html-d0e44dc9.js"),[]).then(({data:e})=>e),"v-3706649a":()=>T(()=>import("./404.html-343b11af.js"),[]).then(({data:e})=>e),"v-e1e3da16":()=>T(()=>import("./index.html-711d919a.js"),[]).then(({data:e})=>e),"v-c8296fee":()=>T(()=>import("./index.html-8f53b261.js"),[]).then(({data:e})=>e),"v-c35f20b2":()=>T(()=>import("./index.html-953b207f.js"),[]).then(({data:e})=>e),"v-1800c499":()=>T(()=>import("./index.html-bfbc86b1.js"),[]).then(({data:e})=>e),"v-2948e7ec":()=>T(()=>import("./index.html-6ffd81d9.js"),[]).then(({data:e})=>e),"v-ffa8c116":()=>T(()=>import("./index.html-456987a2.js"),[]).then(({data:e})=>e),"v-36e4471e":()=>T(()=>import("./index.html-7da15133.js"),[]).then(({data:e})=>e),"v-5bc93818":()=>T(()=>import("./index.html-f4dcdfc9.js"),[]).then(({data:e})=>e),"v-744d024e":()=>T(()=>import("./index.html-75dd72ef.js"),[]).then(({data:e})=>e),"v-e52c881c":()=>T(()=>import("./index.html-516a49e5.js"),[]).then(({data:e})=>e),"v-154dc4c4":()=>T(()=>import("./index.html-1084c80f.js"),[]).then(({data:e})=>e),"v-01560935":()=>T(()=>import("./index.html-3356e63f.js"),[]).then(({data:e})=>e),"v-49425445":()=>T(()=>import("./index.html-83aa3e19.js"),[]).then(({data:e})=>e),"v-0943d7c2":()=>T(()=>import("./index.html-a929cebb.js"),[]).then(({data:e})=>e),"v-506407f4":()=>T(()=>import("./index.html-b70aeab0.js"),[]).then(({data:e})=>e),"v-37a8c5a0":()=>T(()=>import("./index.html-cb4b1e76.js"),[]).then(({data:e})=>e),"v-0379cba1":()=>T(()=>import("./index.html-cea8bfff.js"),[]).then(({data:e})=>e),"v-a9d9d4d6":()=>T(()=>import("./index.html-b9c4000b.js"),[]).then(({data:e})=>e),"v-28e32c66":()=>T(()=>import("./index.html-0498e73d.js"),[]).then(({data:e})=>e),"v-4aa6ad1c":()=>T(()=>import("./index.html-f53b9083.js"),[]).then(({data:e})=>e),"v-a704b744":()=>T(()=>import("./index.html-4aa1210b.js"),[]).then(({data:e})=>e),"v-1007819b":()=>T(()=>import("./index.html-eeadde59.js"),[]).then(({data:e})=>e),"v-4446a48e":()=>T(()=>import("./index.html-69415dfb.js"),[]).then(({data:e})=>e),"v-d2dd3922":()=>T(()=>import("./index.html-6c8afb2c.js"),[]).then(({data:e})=>e),"v-3ce877ec":()=>T(()=>import("./index.html-a875e273.js"),[]).then(({data:e})=>e),"v-5decfa84":()=>T(()=>import("./index.html-2fe3384a.js"),[]).then(({data:e})=>e),"v-5731fdb6":()=>T(()=>import("./index.html-7348225e.js"),[]).then(({data:e})=>e),"v-897763fa":()=>T(()=>import("./index.html-9b3c1776.js"),[]).then(({data:e})=>e),"v-1d543380":()=>T(()=>import("./index.html-df58015a.js"),[]).then(({data:e})=>e),"v-075c6c62":()=>T(()=>import("./index.html-a697b5d9.js"),[]).then(({data:e})=>e)},u4=JSON.parse(`{"base":"/","lang":"en-US","title":"","description":"","head":[],"locales":{"/":{"lang":"zh-CN","title":"ChiChen's Blog","description":"vuepress-theme-hope 的博客演示"},"/en/":{"lang":"en-US","title":"ChiChen's Blog","description":"A blog of a"}}}`);var d4=([e,t,n])=>e==="meta"&&t.name?`${e}.${t.name}`:["title","base"].includes(e)?e:e==="template"&&t.id?`${e}.${t.id}`:JSON.stringify([e,t,n]),f4=e=>{const t=new Set,n=[];return e.forEach(l=>{const r=d4(l);t.has(r)||(t.add(r),n.push(l))}),n},p4=e=>e[e.length-1]==="/"||e.endsWith(".html")?e:`${e}/`,h4=e=>e.startsWith("ftp://"),vn=e=>/^(https?:)?\/\//.test(e),v4=/.md((\?|#).*)?$/,ar=(e,t="/")=>!!(vn(e)||h4(e)||e.startsWith("/")&&!e.startsWith(t)&&!v4.test(e)),o1=e=>/^mailto:/.test(e),m4=e=>/^tel:/.test(e),br=e=>Object.prototype.toString.call(e)==="[object Object]",Ko=e=>e[e.length-1]==="/"?e.slice(0,-1):e,a1=e=>e[0]==="/"?e.slice(1):e,g4=(e,t)=>{const n=Object.keys(e).sort((l,r)=>{const o=r.split("/").length-l.split("/").length;return o!==0?o:r.length-l.length});for(const l of n)if(t.startsWith(l))return l;return"/"};const s1={"v-8daa1a0e":X(()=>T(()=>import("./index.html-b4876bb6.js"),["assets/index.html-b4876bb6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-184f4da6":X(()=>T(()=>import("./intro.html-00f5a6f1.js"),["assets/intro.html-00f5a6f1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-2d0a870d":X(()=>T(()=>import("./index.html-28e4abec.js"),["assets/index.html-28e4abec.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5aa3d8ba":X(()=>T(()=>import("./intro.html-6ba33697.js"),["assets/intro.html-6ba33697.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e8a3586c":X(()=>T(()=>import("./template.html-56cb88e1.js"),["assets/template.html-56cb88e1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c3fa0194":X(()=>T(()=>import("./template.html-5ea4a409.js"),["assets/template.html-5ea4a409.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3e42db3e":X(()=>T(()=>import("./NUMA Balancing.html-96ea11b1.js"),["assets/NUMA Balancing.html-96ea11b1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1f37d83d":X(()=>T(()=>import("./vscode qemu开发Linux内核.html-26e761e6.js"),["assets/vscode qemu开发Linux内核.html-26e761e6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-fa5bbd4e":X(()=>T(()=>import("./Chapter0 前言.html-064c4e9e.js"),["assets/Chapter0 前言.html-064c4e9e.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-40a655de":X(()=>T(()=>import("./Chapter1 编译器组成.html-5882819b.js"),["assets/Chapter1 编译器组成.html-5882819b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e2bd5838":X(()=>T(()=>import("./Chapter2 词法分析.html-120fdf7e.js"),["assets/Chapter2 词法分析.html-120fdf7e.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4f5ffb7c":X(()=>T(()=>import("./Chapter3 语法分析.html-bfc131b7.js"),["assets/Chapter3 语法分析.html-bfc131b7.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a7388c80":X(()=>T(()=>import("./Chapter4 语义分析.html-753ca7bc.js"),["assets/Chapter4 语义分析.html-753ca7bc.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0fc134f8":X(()=>T(()=>import("./Chapter5 代码生成.html-5ee35076.js"),["assets/Chapter5 代码生成.html-5ee35076.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-11f1c650":X(()=>T(()=>import("./could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-bef046d9.js"),["assets/could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-bef046d9.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-69ae52f9":X(()=>T(()=>import("./记一次 GP Debug 的心路历程.html-8f823989.js"),["assets/记一次 GP Debug 的心路历程.html-8f823989.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-384e46cc":X(()=>T(()=>import("./震惊!1等于0.html-0a0bb0f1.js"),["assets/震惊!1等于0.html-0a0bb0f1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3706649a":X(()=>T(()=>import("./404.html-e490506a.js"),["assets/404.html-e490506a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e1e3da16":X(()=>T(()=>import("./index.html-30259c6f.js"),["assets/index.html-30259c6f.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c8296fee":X(()=>T(()=>import("./index.html-fe625065.js"),["assets/index.html-fe625065.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c35f20b2":X(()=>T(()=>import("./index.html-53ccdd64.js"),["assets/index.html-53ccdd64.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1800c499":X(()=>T(()=>import("./index.html-8f4ebba6.js"),["assets/index.html-8f4ebba6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-2948e7ec":X(()=>T(()=>import("./index.html-c83dd7e0.js"),["assets/index.html-c83dd7e0.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-ffa8c116":X(()=>T(()=>import("./index.html-e8b6977a.js"),["assets/index.html-e8b6977a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-36e4471e":X(()=>T(()=>import("./index.html-01aa8480.js"),["assets/index.html-01aa8480.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5bc93818":X(()=>T(()=>import("./index.html-639b07ee.js"),["assets/index.html-639b07ee.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-744d024e":X(()=>T(()=>import("./index.html-f8230654.js"),["assets/index.html-f8230654.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e52c881c":X(()=>T(()=>import("./index.html-a3a50fb1.js"),["assets/index.html-a3a50fb1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-154dc4c4":X(()=>T(()=>import("./index.html-cf76b276.js"),["assets/index.html-cf76b276.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-01560935":X(()=>T(()=>import("./index.html-7412be96.js"),["assets/index.html-7412be96.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-49425445":X(()=>T(()=>import("./index.html-31fd21d7.js"),["assets/index.html-31fd21d7.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0943d7c2":X(()=>T(()=>import("./index.html-3a0af3e4.js"),["assets/index.html-3a0af3e4.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-506407f4":X(()=>T(()=>import("./index.html-bcd70c5b.js"),["assets/index.html-bcd70c5b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-37a8c5a0":X(()=>T(()=>import("./index.html-c39b6a66.js"),["assets/index.html-c39b6a66.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0379cba1":X(()=>T(()=>import("./index.html-7e863065.js"),["assets/index.html-7e863065.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a9d9d4d6":X(()=>T(()=>import("./index.html-b0004409.js"),["assets/index.html-b0004409.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-28e32c66":X(()=>T(()=>import("./index.html-83c68f85.js"),["assets/index.html-83c68f85.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4aa6ad1c":X(()=>T(()=>import("./index.html-2b599605.js"),["assets/index.html-2b599605.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a704b744":X(()=>T(()=>import("./index.html-c4401dc6.js"),["assets/index.html-c4401dc6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1007819b":X(()=>T(()=>import("./index.html-311d3356.js"),["assets/index.html-311d3356.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4446a48e":X(()=>T(()=>import("./index.html-4f26a2dc.js"),["assets/index.html-4f26a2dc.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-d2dd3922":X(()=>T(()=>import("./index.html-9c2e126f.js"),["assets/index.html-9c2e126f.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3ce877ec":X(()=>T(()=>import("./index.html-ce53da98.js"),["assets/index.html-ce53da98.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5decfa84":X(()=>T(()=>import("./index.html-f5af7e48.js"),["assets/index.html-f5af7e48.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5731fdb6":X(()=>T(()=>import("./index.html-434508b4.js"),["assets/index.html-434508b4.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-897763fa":X(()=>T(()=>import("./index.html-72508e82.js"),["assets/index.html-72508e82.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1d543380":X(()=>T(()=>import("./index.html-b2407657.js"),["assets/index.html-b2407657.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-075c6c62":X(()=>T(()=>import("./index.html-6b2b910a.js"),["assets/index.html-6b2b910a.js","assets/plugin-vue_export-helper-c27b6911.js"]))};var y4=Symbol(""),b4=V(c4),i1=hn({key:"",path:"",title:"",lang:"",frontmatter:{},headers:[]}),Vt=V(i1),ue=()=>Vt,c1=Symbol(""),we=()=>{const e=ce(c1);if(!e)throw new Error("usePageFrontmatter() is called without provider.");return e},u1=Symbol(""),E4=()=>{const e=ce(u1);if(!e)throw new Error("usePageHead() is called without provider.");return e},d1=Symbol(""),_4=()=>{const e=ce(d1);if(!e)throw new Error("usePageHeadTitle() is called without provider.");return e},f1=Symbol(""),Yo=()=>{const e=ce(f1);if(!e)throw new Error("usePageLang() is called without provider.");return e},p1=Symbol(""),w4=()=>{const e=ce(p1);if(!e)throw new Error("usePageLayout() is called without provider.");return e},Jo=Symbol(""),Tt=()=>{const e=ce(Jo);if(!e)throw new Error("useRouteLocale() is called without provider.");return e},xn=V(u4),h1=()=>xn,v1=Symbol(""),wl=()=>{const e=ce(v1);if(!e)throw new Error("useSiteLocaleData() is called without provider.");return e},x4=Symbol(""),C4="Layout",A4="NotFound",Pt=Hn({resolveLayouts:e=>e.reduce((t,n)=>({...t,...n.layouts}),{}),resolvePageData:async e=>{const t=b4.value[e];return await(t==null?void 0:t())??i1},resolvePageFrontmatter:e=>e.frontmatter,resolvePageHead:(e,t,n)=>{const l=pe(t.description)?t.description:n.description,r=[...Q(t.head)?t.head:[],...n.head,["title",{},e],["meta",{name:"description",content:l}]];return f4(r)},resolvePageHeadTitle:(e,t)=>[e.title,t.title].filter(n=>!!n).join(" | "),resolvePageLang:e=>e.lang||"en",resolvePageLayout:(e,t)=>{let n;if(e.path){const l=e.frontmatter.layout;pe(l)?n=l:n=C4}else n=A4;return t[n]},resolveRouteLocale:(e,t)=>g4(e,t),resolveSiteLocaleData:(e,t)=>({...e,...e.locales[t]})}),Er=B({name:"ClientOnly",setup(e,t){const n=V(!1);return me(()=>{n.value=!0}),()=>{var l,r;return n.value?(r=(l=t.slots).default)==null?void 0:r.call(l):null}}}),Qo=B({name:"Content",props:{pageKey:{type:String,required:!1,default:""}},setup(e){const t=ue(),n=_(()=>s1[e.pageKey||t.value.key]);return()=>n.value?s(n.value):s("div","404 Not Found")}}),bt=(e={})=>e,Ne=e=>vn(e)?e:`/${a1(e)}`;const k4={};var qe=Uint8Array,on=Uint16Array,m1=Uint32Array,g1=new qe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),y1=new qe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),T4=new qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),b1=function(e,t){for(var n=new on(31),l=0;l<31;++l)n[l]=t+=1<>>1|(ke&21845)<<1;zt=(zt&52428)>>>2|(zt&13107)<<2,zt=(zt&61680)>>>4|(zt&3855)<<4,ao[ke]=((zt&65280)>>>8|(zt&255)<<8)>>>1}var rl=function(e,t,n){for(var l=e.length,r=0,o=new on(t);r>>c]=u}else for(i=new on(l),r=0;r>>15-e[r]);return i},xl=new qe(288);for(var ke=0;ke<144;++ke)xl[ke]=8;for(var ke=144;ke<256;++ke)xl[ke]=9;for(var ke=256;ke<280;++ke)xl[ke]=7;for(var ke=280;ke<288;++ke)xl[ke]=8;var w1=new qe(32);for(var ke=0;ke<32;++ke)w1[ke]=5;var O4=rl(xl,9,1),M4=rl(w1,5,1),Rr=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},ut=function(e,t,n){var l=t/8|0;return(e[l]|e[l+1]<<8)>>(t&7)&n},zr=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},$4=function(e){return(e+7)/8|0},Zo=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var l=new(e.BYTES_PER_ELEMENT==2?on:e.BYTES_PER_ELEMENT==4?m1:qe)(n-t);return l.set(e.subarray(t,n)),l},B4=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],dt=function(e,t,n){var l=new Error(t||B4[e]);if(l.code=e,Error.captureStackTrace&&Error.captureStackTrace(l,dt),!n)throw l;return l},I4=function(e,t,n){var l=e.length;if(!l||n&&n.f&&!n.l)return t||new qe(0);var r=!t||n,o=!n||n.i;n||(n={}),t||(t=new qe(l*3));var a=function(Be){var k=t.length;if(Be>k){var F=new qe(Math.max(k*2,Be));F.set(t),t=F}},i=n.f||0,c=n.p||0,u=n.b||0,d=n.l,f=n.d,p=n.m,h=n.n,y=l*8;do{if(!d){i=ut(e,c,1);var w=ut(e,c+1,3);if(c+=3,w)if(w==1)d=O4,f=M4,p=9,h=5;else if(w==2){var M=ut(e,c,31)+257,$=ut(e,c+10,15)+4,q=M+ut(e,c+5,31)+1;c+=14;for(var P=new qe(q),G=new qe(19),A=0;A<$;++A)G[T4[A]]=ut(e,c+A*3,7);c+=$*3;for(var H=Rr(G),K=(1<>>4;if(x<16)P[A++]=x;else{var Z=0,j=0;for(x==16?(j=3+ut(e,c,3),c+=2,Z=P[A-1]):x==17?(j=3+ut(e,c,7),c+=3):x==18&&(j=11+ut(e,c,127),c+=7);j--;)P[A++]=Z}}var Pe=P.subarray(0,M),ne=P.subarray(M);p=Rr(Pe),h=Rr(ne),d=rl(Pe,p,1),f=rl(ne,h,1)}else dt(1);else{var x=$4(c)+4,m=e[x-4]|e[x-3]<<8,b=x+m;if(b>l){o&&dt(0);break}r&&a(u+m),t.set(e.subarray(x,b),u),n.b=u+=m,n.p=c=b*8,n.f=i;continue}if(c>y){o&&dt(0);break}}r&&a(u+131072);for(var ye=(1<>>4;if(c+=Z&15,c>y){o&&dt(0);break}if(Z||dt(2),Ve<256)t[u++]=Ve;else if(Ve==256){Ye=c,d=null;break}else{var Je=Ve-254;if(Ve>264){var A=Ve-257,Oe=g1[A];Je=ut(e,c,(1<>>4;_t||dt(3),c+=_t&15;var ne=P4[wt];if(wt>3){var Oe=y1[wt];ne+=zr(e,c)&(1<y){o&&dt(0);break}r&&a(u+131072);for(var Zt=u+Je;u>>4>7||(e[0]<<8|e[1])%31)&&dt(6,"invalid zlib data"),e[1]&32&&dt(6,"invalid zlib data: preset dictionaries not supported")};function z4(e,t){return I4((R4(e),e.subarray(2,-4)),t)}var fs=typeof TextEncoder<"u"&&new TextEncoder,so=typeof TextDecoder<"u"&&new TextDecoder,F4=0;try{so.decode(D4,{stream:!0}),F4=1}catch{}var N4=function(e){for(var t="",n=0;;){var l=e[n++],r=(l>127)+(l>223)+(l>239);if(n+r>e.length)return[t,Zo(e,n-1)];r?r==3?(l=((l&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|l>>10,56320|l&1023)):r&1?t+=String.fromCharCode((l&31)<<6|e[n++]&63):t+=String.fromCharCode((l&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(l)}};function V4(e,t){if(t){for(var n=new qe(e.length),l=0;l>1)),a=0,i=function(d){o[a++]=d},l=0;lo.length){var c=new qe(a+8+(r-l<<1));c.set(o),o=c}var u=e.charCodeAt(l);u<128||t?i(u):u<2048?(i(192|u>>6),i(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|e.charCodeAt(++l)&1023,i(240|u>>18),i(128|u>>12&63),i(128|u>>6&63),i(128|u&63)):(i(224|u>>12),i(128|u>>6&63),i(128|u&63))}return Zo(o,0,a)}function H4(e,t){if(t){for(var n="",l=0;l{var l;return s("svg",{xmlns:"http://www.w3.org/2000/svg",class:["icon",`${e}-icon`],viewBox:"0 0 1024 1024",fill:t,"aria-label":`${e} icon`},(l=n.default)==null?void 0:l.call(n))};oe.displayName="IconBase";const Kt=({size:e=48,stroke:t=4,wrapper:n=!0,height:l=2*e})=>{const r=s("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,preserveAspectRatio:"xMidYMid",viewBox:"25 25 50 50"},[s("animateTransform",{attributeName:"transform",type:"rotate",dur:"2s",keyTimes:"0;1",repeatCount:"indefinite",values:"0;360"}),s("circle",{cx:"50",cy:"50",r:"20",fill:"none",stroke:"currentColor","stroke-width":t,"stroke-linecap":"round"},[s("animate",{attributeName:"stroke-dasharray",dur:"1.5s",keyTimes:"0;0.5;1",repeatCount:"indefinite",values:"1,200;90,200;1,200"}),s("animate",{attributeName:"stroke-dashoffset",dur:"1.5s",keyTimes:"0;0.5;1",repeatCount:"indefinite",values:"0;-35px;-125px"})])]);return n?s("div",{class:"loading-icon-wrapper",style:`display:flex;align-items:center;justify-content:center;height:${l}px`},r):r};Kt.displayName="LoadingIcon";const x1=(e,{slots:t})=>{var n;return(n=t.default)==null?void 0:n.call(t)},C1=()=>s(oe,{name:"github"},()=>s("path",{d:"M511.957 21.333C241.024 21.333 21.333 240.981 21.333 512c0 216.832 140.544 400.725 335.574 465.664 24.49 4.395 32.256-10.07 32.256-23.083 0-11.69.256-44.245 0-85.205-136.448 29.61-164.736-64.64-164.736-64.64-22.315-56.704-54.4-71.765-54.4-71.765-44.587-30.464 3.285-29.824 3.285-29.824 49.195 3.413 75.179 50.517 75.179 50.517 43.776 75.008 114.816 53.333 142.762 40.79 4.523-31.66 17.152-53.377 31.19-65.537-108.971-12.458-223.488-54.485-223.488-242.602 0-53.547 19.114-97.323 50.517-131.67-5.035-12.33-21.93-62.293 4.779-129.834 0 0 41.258-13.184 134.912 50.346a469.803 469.803 0 0 1 122.88-16.554c41.642.213 83.626 5.632 122.88 16.554 93.653-63.488 134.784-50.346 134.784-50.346 26.752 67.541 9.898 117.504 4.864 129.834 31.402 34.347 50.474 78.123 50.474 131.67 0 188.586-114.73 230.016-224.042 242.09 17.578 15.232 33.578 44.672 33.578 90.454v135.85c0 13.142 7.936 27.606 32.854 22.87C862.25 912.597 1002.667 728.747 1002.667 512c0-271.019-219.648-490.667-490.71-490.667z"}));C1.displayName="GitHubIcon";const A1=()=>s(oe,{name:"gitlab"},()=>s("path",{d:"M229.333 78.688C223.52 62 199.895 62 193.895 78.688L87.958 406.438h247.5c-.188 0-106.125-327.75-106.125-327.75zM33.77 571.438c-4.875 15 .563 31.687 13.313 41.25l464.812 345L87.77 406.438zm301.5-165 176.813 551.25 176.812-551.25zm655.125 165-54-165-424.312 551.25 464.812-345c12.938-9.563 18.188-26.25 13.5-41.25zM830.27 78.688c-5.812-16.688-29.437-16.688-35.437 0l-106.125 327.75h247.5z"}));A1.displayName="GitLabIcon";const k1=()=>s(oe,{name:"gitee"},()=>s("path",{d:"M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm242.97-533.34H482.39a23.7 23.7 0 0 0-23.7 23.7l-.03 59.28c0 13.08 10.59 23.7 23.7 23.7h165.96a23.7 23.7 0 0 1 23.7 23.7v11.85a71.1 71.1 0 0 1-71.1 71.1H375.71a23.7 23.7 0 0 1-23.7-23.7V423.11a71.1 71.1 0 0 1 71.1-71.1h331.8a23.7 23.7 0 0 0 23.7-23.7l.06-59.25a23.73 23.73 0 0 0-23.7-23.73H423.11a177.78 177.78 0 0 0-177.78 177.75v331.83c0 13.08 10.62 23.7 23.7 23.7h349.62a159.99 159.99 0 0 0 159.99-159.99V482.33a23.7 23.7 0 0 0-23.7-23.7z"}));k1.displayName="GiteeIcon";const T1=()=>s(oe,{name:"bitbucket"},()=>s("path",{d:"M575.256 490.862c6.29 47.981-52.005 85.723-92.563 61.147-45.714-20.004-45.714-92.562-1.133-113.152 38.29-23.442 93.696 7.424 93.696 52.005zm63.451-11.996c-10.276-81.152-102.29-134.839-177.152-101.156-47.433 21.138-79.433 71.424-77.129 124.562 2.853 69.705 69.157 126.866 138.862 120.576S647.3 548.571 638.708 478.83zm136.558-309.723c-25.161-33.134-67.986-38.839-105.728-45.13-106.862-17.151-216.576-17.7-323.438 1.134-35.438 5.706-75.447 11.996-97.719 43.996 36.572 34.304 88.576 39.424 135.424 45.129 84.553 10.862 171.447 11.447 256 .585 47.433-5.705 99.987-10.276 135.424-45.714zm32.585 591.433c-16.018 55.99-6.839 131.438-66.304 163.986-102.29 56.576-226.304 62.867-338.87 42.862-59.43-10.862-129.135-29.696-161.72-85.723-14.3-54.858-23.442-110.848-32.585-166.84l3.438-9.142 10.276-5.157c170.277 112.567 408.576 112.567 579.438 0 26.844 8.01 6.84 40.558 6.29 60.014zm103.424-549.157c-19.42 125.148-41.728 249.71-63.415 374.272-6.29 36.572-41.728 57.162-71.424 72.558-106.862 53.724-231.424 62.866-348.562 50.286-79.433-8.558-160.585-29.696-225.134-79.433-30.28-23.443-30.28-63.415-35.986-97.134-20.005-117.138-42.862-234.277-57.161-352.585 6.839-51.42 64.585-73.728 107.447-89.71 57.16-21.138 118.272-30.866 178.87-36.571 129.134-12.58 261.157-8.01 386.304 28.562 44.581 13.13 92.563 31.415 122.844 69.705 13.714 17.7 9.143 40.01 6.29 60.014z"}));T1.displayName="BitbucketIcon";const L1=()=>s(oe,{name:"source"},()=>s("path",{d:"M601.92 475.2c0 76.428-8.91 83.754-28.512 99.594-14.652 11.88-43.956 14.058-78.012 16.434-18.81 1.386-40.392 2.97-62.172 6.534-18.612 2.97-36.432 9.306-53.064 17.424V299.772c37.818-21.978 63.36-62.766 63.36-109.692 0-69.894-56.826-126.72-126.72-126.72S190.08 120.186 190.08 190.08c0 46.926 25.542 87.714 63.36 109.692v414.216c-37.818 21.978-63.36 62.766-63.36 109.692 0 69.894 56.826 126.72 126.72 126.72s126.72-56.826 126.72-126.72c0-31.086-11.286-59.598-29.7-81.576 13.266-9.504 27.522-17.226 39.996-19.206 16.038-2.574 32.868-3.762 50.688-5.148 48.312-3.366 103.158-7.326 148.896-44.55 61.182-49.698 74.25-103.158 75.24-187.902V475.2h-126.72zM316.8 126.72c34.848 0 63.36 28.512 63.36 63.36s-28.512 63.36-63.36 63.36-63.36-28.512-63.36-63.36 28.512-63.36 63.36-63.36zm0 760.32c-34.848 0-63.36-28.512-63.36-63.36s28.512-63.36 63.36-63.36 63.36 28.512 63.36 63.36-28.512 63.36-63.36 63.36zM823.68 158.4h-95.04V63.36h-126.72v95.04h-95.04v126.72h95.04v95.04h126.72v-95.04h95.04z"}));L1.displayName="SourceIcon";const Xo=Array.isArray,j4=e=>typeof e=="function",q4=e=>typeof e=="string";var S1=e=>/^(https?:)?\/\//.test(e),ol=e=>Object.prototype.toString.call(e)==="[object Object]";const gt=(e,t)=>{const n=t?t._instance:Gn();return ol(n==null?void 0:n.appContext.components)&&(e in n.appContext.components||st(e)in n.appContext.components||bl(st(e))in n.appContext.components)};function U4(){const e=V(!1);return Gn()&&me(()=>{e.value=!0}),e}function G4(e){return U4(),_(()=>!!e())}const W4=()=>G4(()=>typeof window<"u"&&window.navigator&&"userAgent"in window.navigator),K4=()=>{const e=W4();return _(()=>e.value&&/\b(?:Android|iPhone)/i.test(navigator.userAgent))},Cl=e=>{const t=Tt();return _(()=>e[t.value])},ea=(e="")=>{if(e){if(typeof e=="number")return new Date(e);const t=Date.parse(e.toString());if(!Number.isNaN(t))return new Date(t)}return null},_r=(e,t)=>{let n=1;for(let l=0;l>6;return n+=n<<3,n^=n>>11,n%t},un=e=>typeof e=="string",vl=(e,t)=>un(e)&&e.startsWith(t),bn=(e,t)=>un(e)&&e.endsWith(t),mn=Object.entries,Y4=Object.fromEntries,nt=Object.keys,ps=(e,...t)=>{if(t.length===0)return e;const n=t.shift()||null;return n&&mn(n).forEach(([l,r])=>{l==="__proto__"||l==="constructor"||(ol(e[l])&&ol(r)?ps(e[l],r):Xo(r)?e[l]=[...r]:ol(r)?e[l]={...r}:e[l]=n[l])}),ps(e,...t)},hs=e=>ol(e)&&un(e.name),ml=(e,t=!1)=>e?Xo(e)?e.map(n=>un(n)?{name:n}:hs(n)?n:null).filter(n=>n!==null):un(e)?[{name:e}]:hs(e)?[e]:(console.error(`Expect "author" to be \`AuthorInfo[] | AuthorInfo | string[] | string ${t?"":"| false"} | undefined\`, but got`,e),[]):[],P1=(e,t)=>{if(e){if(Xo(e)&&e.every(un))return e;if(un(e))return[e];console.error(`Expect ${t||"value"} to be \`string[] | string | undefined\`, but got`,e)}return[]},O1=e=>P1(e,"category"),M1=e=>P1(e,"tag"),wr=e=>vl(e,"/");let J4=class{constructor(){this.messageElements={};const t="message-container",n=document.getElementById(t);n?this.containerElement=n:(this.containerElement=document.createElement("div"),this.containerElement.id=t,document.body.appendChild(this.containerElement))}pop(t,n=2e3){const l=document.createElement("div"),r=Date.now();return l.className="message move-in",l.innerHTML=t,this.containerElement.appendChild(l),this.messageElements[r]=l,n>0&&setTimeout(()=>{this.close(r)},n),r}close(t){if(t){const n=this.messageElements[t];n.classList.remove("move-in"),n.classList.add("move-out"),n.addEventListener("animationend",()=>{n.remove(),delete this.messageElements[t]})}else nt(this.messageElements).forEach(n=>this.close(Number(n)))}destroy(){document.body.removeChild(this.containerElement)}};const $1=/#.*$/u,Q4=e=>{const t=$1.exec(e);return t?t[0]:""},vs=e=>decodeURI(e).replace($1,"").replace(/(index)?\.(md|html)$/,""),ta=(e,t)=>{if(t===void 0)return!1;const n=vs(e.path),l=vs(t),r=Q4(t);return r?r===e.hash&&(!l||n===l):n===l},dn=e=>{const t=atob(e);return H4(z4(V4(t,!0)))},Z4=e=>S1(e)?e:`https://github.com/${e}`,B1=e=>!S1(e)||/github\.com/.test(e)?"GitHub":/bitbucket\.org/.test(e)?"Bitbucket":/gitlab\.com/.test(e)?"GitLab":/gitee\.com/.test(e)?"Gitee":null,Al=(e,...t)=>{const n=e.resolve(...t),l=n.matched[n.matched.length-1];if(!(l!=null&&l.redirect))return n;const{redirect:r}=l,o=j4(r)?r(n):r,a=q4(o)?{path:o}:o;return Al(e,{hash:n.hash,query:n.query,params:n.params,...a})};function Yt(e){return ii()?(F2(e),!0):!1}function it(e){return typeof e=="function"?e():sn(e)}const kl=typeof window<"u",fn=()=>{},io=X4();function X4(){var e;return kl&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent)}function na(e,t){function n(...l){return new Promise((r,o)=>{Promise.resolve(e(()=>t.apply(this,l),{fn:t,thisArg:this,args:l})).then(r).catch(o)})}return n}const I1=e=>e();function e3(e,t={}){let n,l,r=fn;const o=i=>{clearTimeout(i),r(),r=fn};return i=>{const c=it(e),u=it(t.maxWait);return n&&o(n),c<=0||u!==void 0&&u<=0?(l&&(o(l),l=null),Promise.resolve(i())):new Promise((d,f)=>{r=t.rejectOnCancel?f:d,u&&!l&&(l=setTimeout(()=>{n&&o(n),l=null,d(i())},u)),n=setTimeout(()=>{l&&o(l),l=null,d(i())},c)})}}function t3(e,t=!0,n=!0,l=!1){let r=0,o,a=!0,i=fn,c;const u=()=>{o&&(clearTimeout(o),o=void 0,i(),i=fn)};return f=>{const p=it(e),h=Date.now()-r,y=()=>c=f();return u(),p<=0?(r=Date.now(),y()):(h>p&&(n||!a)?(r=Date.now(),y()):t&&(c=new Promise((w,x)=>{i=l?x:w,o=setTimeout(()=>{r=Date.now(),a=!0,w(y()),u()},Math.max(0,p-h))})),!n&&!o&&(o=setTimeout(()=>a=!0,p)),a=!1,c)}}function n3(e=I1){const t=V(!0);function n(){t.value=!1}function l(){t.value=!0}const r=(...o)=>{t.value&&e(...o)};return{isActive:hn(t),pause:n,resume:l,eventFilter:r}}function D1(...e){if(e.length!==1)return jn(...e);const t=e[0];return typeof t=="function"?hn(gu(()=>({get:t,set:fn}))):V(t)}function R1(e,t=200,n={}){return na(e3(t,n),e)}function l3(e,t=200,n=!1,l=!0,r=!1){return na(t3(t,n,l,r),e)}function z1(e,t=!0){Gn()?me(e):t?e():qn(e)}function r3(e,t,n={}){const{immediate:l=!0}=n,r=V(!1);let o=null;function a(){o&&(clearTimeout(o),o=null)}function i(){r.value=!1,a()}function c(...u){a(),r.value=!0,o=setTimeout(()=>{r.value=!1,o=null,e(...u)},it(t))}return l&&(r.value=!0,kl&&c()),Yt(i),{isPending:hn(r),start:c,stop:i}}function co(e=!1,t={}){const{truthyValue:n=!0,falsyValue:l=!1}=t,r=De(e),o=V(e);function a(i){if(arguments.length)return o.value=i,o.value;{const c=it(n);return o.value=o.value===c?it(l):c,o.value}}return r?a:[o,a]}var ms=Object.getOwnPropertySymbols,o3=Object.prototype.hasOwnProperty,a3=Object.prototype.propertyIsEnumerable,s3=(e,t)=>{var n={};for(var l in e)o3.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&ms)for(var l of ms(e))t.indexOf(l)<0&&a3.call(e,l)&&(n[l]=e[l]);return n};function i3(e,t,n={}){const l=n,{eventFilter:r=I1}=l,o=s3(l,["eventFilter"]);return se(e,na(r,t),o)}var c3=Object.defineProperty,u3=Object.defineProperties,d3=Object.getOwnPropertyDescriptors,sr=Object.getOwnPropertySymbols,F1=Object.prototype.hasOwnProperty,N1=Object.prototype.propertyIsEnumerable,gs=(e,t,n)=>t in e?c3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f3=(e,t)=>{for(var n in t||(t={}))F1.call(t,n)&&gs(e,n,t[n]);if(sr)for(var n of sr(t))N1.call(t,n)&&gs(e,n,t[n]);return e},p3=(e,t)=>u3(e,d3(t)),h3=(e,t)=>{var n={};for(var l in e)F1.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&sr)for(var l of sr(e))t.indexOf(l)<0&&N1.call(e,l)&&(n[l]=e[l]);return n};function v3(e,t,n={}){const l=n,{eventFilter:r}=l,o=h3(l,["eventFilter"]),{eventFilter:a,pause:i,resume:c,isActive:u}=n3(r);return{stop:i3(e,t,p3(f3({},o),{eventFilter:a})),pause:i,resume:c,isActive:u}}function Xe(e){var t;const n=it(e);return(t=n==null?void 0:n.$el)!=null?t:n}const kt=kl?window:void 0,V1=kl?window.document:void 0,m3=kl?window.navigator:void 0;function Re(...e){let t,n,l,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,l,r]=e,t=kt):[t,n,l,r]=e,!t)return fn;Array.isArray(n)||(n=[n]),Array.isArray(l)||(l=[l]);const o=[],a=()=>{o.forEach(d=>d()),o.length=0},i=(d,f,p,h)=>(d.addEventListener(f,p,h),()=>d.removeEventListener(f,p,h)),c=se(()=>[Xe(t),it(r)],([d,f])=>{a(),d&&o.push(...n.flatMap(p=>l.map(h=>i(d,p,h,f))))},{immediate:!0,flush:"post"}),u=()=>{c(),a()};return Yt(u),u}let ys=!1;function g3(e,t,n={}){const{window:l=kt,ignore:r=[],capture:o=!0,detectIframe:a=!1}=n;if(!l)return;io&&!ys&&(ys=!0,Array.from(l.document.body.children).forEach(p=>p.addEventListener("click",fn)));let i=!0;const c=p=>r.some(h=>{if(typeof h=="string")return Array.from(l.document.querySelectorAll(h)).some(y=>y===p.target||p.composedPath().includes(y));{const y=Xe(h);return y&&(p.target===y||p.composedPath().includes(y))}}),d=[Re(l,"click",p=>{const h=Xe(e);if(!(!h||h===p.target||p.composedPath().includes(h))){if(p.detail===0&&(i=!c(p)),!i){i=!0;return}t(p)}},{passive:!0,capture:o}),Re(l,"pointerdown",p=>{const h=Xe(e);h&&(i=!p.composedPath().includes(h)&&!c(p))},{passive:!0}),a&&Re(l,"blur",p=>{var h;const y=Xe(e);((h=l.document.activeElement)==null?void 0:h.tagName)==="IFRAME"&&!(y!=null&&y.contains(l.document.activeElement))&&t(p)})].filter(Boolean);return()=>d.forEach(p=>p())}function y3(){const e=V(!1);return Gn()&&me(()=>{e.value=!0}),e}function Tl(e){const t=y3();return _(()=>(t.value,!!e()))}function H1(e,t={}){const{window:n=kt}=t,l=Tl(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let r;const o=V(!1),a=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",i):r.removeListener(i))},i=()=>{l.value&&(a(),r=n.matchMedia(D1(e).value),o.value=!!(r!=null&&r.matches),r&&("addEventListener"in r?r.addEventListener("change",i):r.addListener(i)))};return Iu(i),Yt(()=>a()),o}function b3(e={}){const{navigator:t=m3,read:n=!1,source:l,copiedDuring:r=1500,legacy:o=!1}=e,a=["copy","cut"],i=Tl(()=>t&&"clipboard"in t),c=_(()=>i.value||o),u=V(""),d=V(!1),f=r3(()=>d.value=!1,r);function p(){i.value?t.clipboard.readText().then(x=>{u.value=x}):u.value=w()}if(c.value&&n)for(const x of a)Re(x,p);async function h(x=it(l)){c.value&&x!=null&&(i.value?await t.clipboard.writeText(x):y(x),u.value=x,d.value=!0,f.start())}function y(x){const m=document.createElement("textarea");m.value=x??"",m.style.position="absolute",m.style.opacity="0",document.body.appendChild(m),m.select(),document.execCommand("copy"),m.remove()}function w(){var x,m,b;return(b=(m=(x=document==null?void 0:document.getSelection)==null?void 0:x.call(document))==null?void 0:m.toString())!=null?b:""}return{isSupported:c,text:u,copied:d,copy:h}}const jl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ql="__vueuse_ssr_handlers__",E3=_3();function _3(){return ql in jl||(jl[ql]=jl[ql]||{}),jl[ql]}function w3(e,t){return E3[e]||t}function x3(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}var C3=Object.defineProperty,bs=Object.getOwnPropertySymbols,A3=Object.prototype.hasOwnProperty,k3=Object.prototype.propertyIsEnumerable,Es=(e,t,n)=>t in e?C3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_s=(e,t)=>{for(var n in t||(t={}))A3.call(t,n)&&Es(e,n,t[n]);if(bs)for(var n of bs(t))k3.call(t,n)&&Es(e,n,t[n]);return e};const T3={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},ws="vueuse-storage";function la(e,t,n,l={}){var r;const{flush:o="pre",deep:a=!0,listenToStorageChanges:i=!0,writeDefaults:c=!0,mergeDefaults:u=!1,shallow:d,window:f=kt,eventFilter:p,onError:h=A=>{console.error(A)}}=l,y=(d?Se:V)(t);if(!n)try{n=w3("getDefaultStorage",()=>{var A;return(A=kt)==null?void 0:A.localStorage})()}catch(A){h(A)}if(!n)return y;const w=it(t),x=x3(w),m=(r=l.serializer)!=null?r:T3[x],{pause:b,resume:M}=v3(y,()=>$(y.value),{flush:o,deep:a,eventFilter:p});return f&&i&&(Re(f,"storage",G),Re(f,ws,P)),G(),y;function $(A){try{if(A==null)n.removeItem(e);else{const H=m.write(A),K=n.getItem(e);K!==H&&(n.setItem(e,H),f&&f.dispatchEvent(new CustomEvent(ws,{detail:{key:e,oldValue:K,newValue:H,storageArea:n}})))}}catch(H){h(H)}}function q(A){const H=A?A.newValue:n.getItem(e);if(H==null)return c&&w!==null&&n.setItem(e,m.write(w)),w;if(!A&&u){const K=m.read(H);return typeof u=="function"?u(K,w):x==="object"&&!Array.isArray(K)?_s(_s({},w),K):K}else return typeof H!="string"?H:m.read(H)}function P(A){G(A.detail)}function G(A){if(!(A&&A.storageArea!==n)){if(A&&A.key==null){y.value=w;return}if(!(A&&A.key!==e)){b();try{y.value=q(A)}catch(H){h(H)}finally{A?qn(M):M()}}}}}function L3(e){return H1("(prefers-color-scheme: dark)",e)}var xs=Object.getOwnPropertySymbols,S3=Object.prototype.hasOwnProperty,P3=Object.prototype.propertyIsEnumerable,O3=(e,t)=>{var n={};for(var l in e)S3.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&xs)for(var l of xs(e))t.indexOf(l)<0&&P3.call(e,l)&&(n[l]=e[l]);return n};function M3(e,t,n={}){const l=n,{window:r=kt}=l,o=O3(l,["window"]);let a;const i=Tl(()=>r&&"MutationObserver"in r),c=()=>{a&&(a.disconnect(),a=void 0)},u=se(()=>Xe(e),f=>{c(),i.value&&r&&f&&(a=new MutationObserver(t),a.observe(f,o))},{immediate:!0}),d=()=>{c(),u()};return Yt(d),{isSupported:i,stop:d}}var Cs=Object.getOwnPropertySymbols,$3=Object.prototype.hasOwnProperty,B3=Object.prototype.propertyIsEnumerable,I3=(e,t)=>{var n={};for(var l in e)$3.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&Cs)for(var l of Cs(e))t.indexOf(l)<0&&B3.call(e,l)&&(n[l]=e[l]);return n};function D3(e,t,n={}){const l=n,{window:r=kt}=l,o=I3(l,["window"]);let a;const i=Tl(()=>r&&"ResizeObserver"in r),c=()=>{a&&(a.disconnect(),a=void 0)},u=_(()=>Array.isArray(e)?e.map(p=>Xe(p)):[Xe(e)]),d=se(u,p=>{if(c(),i.value&&r){a=new ResizeObserver(t);for(const h of p)h&&a.observe(h,o)}},{immediate:!0,flush:"post",deep:!0}),f=()=>{c(),d()};return Yt(f),{isSupported:i,stop:f}}function R3(e,t={width:0,height:0},n={}){const{window:l=kt,box:r="content-box"}=n,o=_(()=>{var c,u;return(u=(c=Xe(e))==null?void 0:c.namespaceURI)==null?void 0:u.includes("svg")}),a=V(t.width),i=V(t.height);return D3(e,([c])=>{const u=r==="border-box"?c.borderBoxSize:r==="content-box"?c.contentBoxSize:c.devicePixelContentBoxSize;if(l&&o.value){const d=Xe(e);if(d){const f=l.getComputedStyle(d);a.value=parseFloat(f.width),i.value=parseFloat(f.height)}}else if(u){const d=Array.isArray(u)?u:[u];a.value=d.reduce((f,{inlineSize:p})=>f+p,0),i.value=d.reduce((f,{blockSize:p})=>f+p,0)}else a.value=c.contentRect.width,i.value=c.contentRect.height},n),se(()=>Xe(e),c=>{a.value=c?t.width:0,i.value=c?t.height:0}),{width:a,height:i}}const As=["fullscreenchange","webkitfullscreenchange","webkitendfullscreen","mozfullscreenchange","MSFullscreenChange"];function ra(e,t={}){const{document:n=V1,autoExit:l=!1}=t,r=_(()=>{var m;return(m=Xe(e))!=null?m:n==null?void 0:n.querySelector("html")}),o=V(!1),a=_(()=>["requestFullscreen","webkitRequestFullscreen","webkitEnterFullscreen","webkitEnterFullScreen","webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen"].find(m=>n&&m in n||r.value&&m in r.value)),i=_(()=>["exitFullscreen","webkitExitFullscreen","webkitExitFullScreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen"].find(m=>n&&m in n||r.value&&m in r.value)),c=_(()=>["fullScreen","webkitIsFullScreen","webkitDisplayingFullscreen","mozFullScreen","msFullscreenElement"].find(m=>n&&m in n||r.value&&m in r.value)),u=["fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement"].find(m=>n&&m in n),d=Tl(()=>r.value&&n&&a.value!==void 0&&i.value!==void 0&&c.value!==void 0),f=()=>u?(n==null?void 0:n[u])===r.value:!1,p=()=>{if(c.value){if(n&&n[c.value]!=null)return n[c.value];{const m=r.value;if((m==null?void 0:m[c.value])!=null)return!!m[c.value]}}return!1};async function h(){if(d.value){if(i.value)if((n==null?void 0:n[i.value])!=null)await n[i.value]();else{const m=r.value;(m==null?void 0:m[i.value])!=null&&await m[i.value]()}o.value=!1}}async function y(){if(!d.value)return;p()&&await h();const m=r.value;a.value&&(m==null?void 0:m[a.value])!=null&&(await m[a.value](),o.value=!0)}async function w(){await(o.value?h():y())}const x=()=>{const m=p();(!m||m&&f())&&(o.value=m)};return Re(n,As,x,!1),Re(()=>Xe(r),As,x,!1),l&&Yt(h),{isSupported:d,isFullscreen:o,enter:y,exit:h,toggle:w}}function j1(e){const t=window.getComputedStyle(e);if(t.overflowX==="scroll"||t.overflowY==="scroll"||t.overflowX==="auto"&&e.clientHeight1?!0:(t.preventDefault&&t.preventDefault(),!1)}function q1(e,t=!1){const n=V(t);let l=null,r;se(D1(e),i=>{if(i){const c=i;r=c.style.overflow,n.value&&(c.style.overflow="hidden")}},{immediate:!0});const o=()=>{const i=it(e);!i||n.value||(io&&(l=Re(i,"touchmove",c=>{z3(c)},{passive:!1})),i.style.overflow="hidden",n.value=!0)},a=()=>{const i=it(e);!i||!n.value||(io&&(l==null||l()),i.style.overflow=r,n.value=!1)};return Yt(a),_({get(){return n.value},set(i){i?o():a()}})}let F3=0;function N3(e,t={}){const n=V(!1),{document:l=V1,immediate:r=!0,manual:o=!1,id:a=`vueuse_styletag_${++F3}`}=t,i=V(e);let c=()=>{};const u=()=>{if(!l)return;const f=l.getElementById(a)||l.createElement("style");f.isConnected||(f.type="text/css",f.id=a,t.media&&(f.media=t.media),l.head.appendChild(f)),!n.value&&(c=se(i,p=>{f.textContent=p},{immediate:!0}),n.value=!0)},d=()=>{!l||!n.value||(c(),l.head.removeChild(l.getElementById(a)),n.value=!1)};return r&&!o&&z1(u),o||Yt(d),{id:a,css:i,unload:d,load:u,isLoaded:hn(n)}}function V3({window:e=kt}={}){if(!e)return{x:V(0),y:V(0)};const t=V(e.scrollX),n=V(e.scrollY);return Re(e,"scroll",()=>{t.value=e.scrollX,n.value=e.scrollY},{capture:!1,passive:!0}),{x:t,y:n}}function H3(e={}){const{window:t=kt,initialWidth:n=1/0,initialHeight:l=1/0,listenOrientation:r=!0,includeScrollbar:o=!0}=e,a=V(n),i=V(l),c=()=>{t&&(o?(a.value=t.innerWidth,i.value=t.innerHeight):(a.value=t.document.documentElement.clientWidth,i.value=t.document.documentElement.clientHeight))};if(c(),z1(c),Re("resize",c,{passive:!0}),r){const u=H1("(orientation: portrait)");se(u,()=>c())}return{width:a,height:i}}const U1=({type:e="info",text:t="",vertical:n="top",color:l},{slots:r})=>{var o;return s("span",{class:["badge",e,{diy:l}],style:{verticalAlign:n,...l?{backgroundColor:l}:{}}},((o=r.default)==null?void 0:o.call(r))||t)};U1.displayName="Badge";var j3=B({name:"FontIcon",props:{icon:{type:String,default:""},color:{type:String,default:""},size:{type:[String,Number],default:""}},setup(e){const t=_(()=>{const l=["font-icon icon"],r=`iconfont icon-${e.icon}`;return l.push(r),l}),n=_(()=>{const l={};return e.color&&(l.color=e.color),e.size&&(l["font-size"]=Number.isNaN(Number(e.size))?e.size:`${e.size}px`),nt(l).length?l:null});return()=>e.icon?s("span",{key:e.icon,class:t.value,style:n.value}):null}});const G1=()=>s(oe,{name:"back-to-top"},()=>[s("path",{d:"M512 843.2c-36.2 0-66.4-13.6-85.8-21.8-10.8-4.6-22.6 3.6-21.8 15.2l7 102c.4 6.2 7.6 9.4 12.6 5.6l29-22c3.6-2.8 9-1.8 11.4 2l41 64.2c3 4.8 10.2 4.8 13.2 0l41-64.2c2.4-3.8 7.8-4.8 11.4-2l29 22c5 3.8 12.2.6 12.6-5.6l7-102c.8-11.6-11-20-21.8-15.2-19.6 8.2-49.6 21.8-85.8 21.8z"}),s("path",{d:"m795.4 586.2-96-98.2C699.4 172 513 32 513 32S324.8 172 324.8 488l-96 98.2c-3.6 3.6-5.2 9-4.4 14.2L261.2 824c1.8 11.4 14.2 17 23.6 10.8L419 744s41.4 40 94.2 40c52.8 0 92.2-40 92.2-40l134.2 90.8c9.2 6.2 21.6.6 23.6-10.8l37-223.8c.4-5.2-1.2-10.4-4.8-14zM513 384c-34 0-61.4-28.6-61.4-64s27.6-64 61.4-64c34 0 61.4 28.6 61.4 64S547 384 513 384z"})]);G1.displayName="BackToTopIcon";var q3=B({name:"BackToTop",props:{threshold:{type:Number,default:100},noProgress:Boolean},setup(e){const t=we(),n=Cl({"/en/":{backToTop:"Back to top"},"/":{backToTop:"返回顶部"}}),l=Se(),{height:r}=R3(l),{height:o}=H3(),{y:a}=V3(),i=_(()=>t.value.backToTop!==!1&&a.value>e.threshold),c=_(()=>a.value/(r.value-o.value));return me(()=>{l.value=document.body}),()=>s(Wt,{name:"fade"},()=>i.value?s("button",{type:"button",class:"back-to-top","aria-label":n.value.backToTop,"data-balloon-pos":"left",onClick:()=>{window.scrollTo({top:0,behavior:"smooth"})}},[e.noProgress?null:s("svg",{class:"scroll-progress"},s("circle",{cx:"50%",cy:"50%",style:{"stroke-dasharray":`calc(${Math.PI*c.value*100}% - ${4*Math.PI}px) calc(${Math.PI*100}% - ${4*Math.PI}px)`}})),s(G1)]):null)}});const U3=bt({enhance:({app:e})=>{gt("Badge")||e.component("Badge",U1),gt("FontIcon")||e.component("FontIcon",j3)},setup:()=>{N3(` @import url("https://at.alicdn.com/t/c/font_2410206_5vb9zlyghj.css"); - `)},rootComponents:[()=>s(q3,{})]});function G3(e,t,n){var l,r,o;t===void 0&&(t=50),n===void 0&&(n={});var a=(l=n.isImmediate)!=null&&l,i=(r=n.callback)!=null&&r,c=n.maxWait,u=Date.now(),d=[];function f(){if(c!==void 0){var h=Date.now()-u;if(h+t>=c)return c-h}return t}var p=function(){var h=[].slice.call(arguments),y=this;return new Promise(function(w,x){var m=a&&o===void 0;if(o!==void 0&&clearTimeout(o),o=setTimeout(function(){if(o=void 0,u=Date.now(),!a){var M=e.apply(y,h);i&&i(M),d.forEach(function($){return(0,$.resolve)(M)}),d=[]}},f()),m){var b=e.apply(y,h);return i&&i(b),w(b)}d.push({resolve:w,reject:x})})};return p.cancel=function(h){o!==void 0&&clearTimeout(o),d.forEach(function(y){return(0,y.reject)(h)}),d=[]},p}/*! - * vue-router v4.2.0 - * (c) 2023 Eduardo San Martin Morote - * @license MIT - */const wn=typeof window<"u";function W3(e){return e.__esModule||e[Symbol.toStringTag]==="Module"}const be=Object.assign;function Fr(e,t){const n={};for(const l in t){const r=t[l];n[l]=yt(r)?r.map(e):e(r)}return n}const al=()=>{},yt=Array.isArray,K3=/\/$/,Y3=e=>e.replace(K3,"");function Nr(e,t,n="/"){let l,r={},o="",a="";const i=t.indexOf("#");let c=t.indexOf("?");return i=0&&(c=-1),c>-1&&(l=t.slice(0,c),o=t.slice(c+1,i>-1?i:t.length),r=e(o)),i>-1&&(l=l||t.slice(0,i),a=t.slice(i,t.length)),l=X3(l??t,n),{fullPath:l+(o&&"?")+o+a,path:l,query:r,hash:a}}function J3(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function ks(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function Q3(e,t,n){const l=t.matched.length-1,r=n.matched.length-1;return l>-1&&l===r&&Rn(t.matched[l],n.matched[r])&&W1(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Rn(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function W1(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!Z3(e[n],t[n]))return!1;return!0}function Z3(e,t){return yt(e)?Ts(e,t):yt(t)?Ts(t,e):e===t}function Ts(e,t){return yt(t)?e.length===t.length&&e.every((n,l)=>n===t[l]):e.length===1&&e[0]===t}function X3(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),l=e.split("/"),r=l[l.length-1];(r===".."||r===".")&&l.push("");let o=n.length-1,a,i;for(a=0;a1&&o--;else break;return n.slice(0,o).join("/")+"/"+l.slice(a-(a===l.length?1:0)).join("/")}var gl;(function(e){e.pop="pop",e.push="push"})(gl||(gl={}));var sl;(function(e){e.back="back",e.forward="forward",e.unknown=""})(sl||(sl={}));function e6(e){if(!e)if(wn){const t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return e[0]!=="/"&&e[0]!=="#"&&(e="/"+e),Y3(e)}const t6=/^[^#]+#/;function n6(e,t){return e.replace(t6,"#")+t}function l6(e,t){const n=document.documentElement.getBoundingClientRect(),l=e.getBoundingClientRect();return{behavior:t.behavior,left:l.left-n.left-(t.left||0),top:l.top-n.top-(t.top||0)}}const xr=()=>({left:window.pageXOffset,top:window.pageYOffset});function r6(e){let t;if("el"in e){const n=e.el,l=typeof n=="string"&&n.startsWith("#"),r=typeof n=="string"?l?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!r)return;t=l6(r,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.pageXOffset,t.top!=null?t.top:window.pageYOffset)}function Ls(e,t){return(history.state?history.state.position-t:-1)+e}const uo=new Map;function o6(e,t){uo.set(e,t)}function a6(e){const t=uo.get(e);return uo.delete(e),t}let s6=()=>location.protocol+"//"+location.host;function K1(e,t){const{pathname:n,search:l,hash:r}=t,o=e.indexOf("#");if(o>-1){let i=r.includes(e.slice(o))?e.slice(o).length:1,c=r.slice(i);return c[0]!=="/"&&(c="/"+c),ks(c,"")}return ks(n,e)+l+r}function i6(e,t,n,l){let r=[],o=[],a=null;const i=({state:p})=>{const h=K1(e,location),y=n.value,w=t.value;let x=0;if(p){if(n.value=h,t.value=p,a&&a===y){a=null;return}x=w?p.position-w.position:0}else l(h);r.forEach(m=>{m(n.value,y,{delta:x,type:gl.pop,direction:x?x>0?sl.forward:sl.back:sl.unknown})})};function c(){a=n.value}function u(p){r.push(p);const h=()=>{const y=r.indexOf(p);y>-1&&r.splice(y,1)};return o.push(h),h}function d(){const{history:p}=window;p.state&&p.replaceState(be({},p.state,{scroll:xr()}),"")}function f(){for(const p of o)p();o=[],window.removeEventListener("popstate",i),window.removeEventListener("beforeunload",d)}return window.addEventListener("popstate",i),window.addEventListener("beforeunload",d,{passive:!0}),{pauseListeners:c,listen:u,destroy:f}}function Ss(e,t,n,l=!1,r=!1){return{back:e,current:t,forward:n,replaced:l,position:window.history.length,scroll:r?xr():null}}function c6(e){const{history:t,location:n}=window,l={value:K1(e,n)},r={value:t.state};r.value||o(l.value,{back:null,current:l.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function o(c,u,d){const f=e.indexOf("#"),p=f>-1?(n.host&&document.querySelector("base")?e:e.slice(f))+c:s6()+e+c;try{t[d?"replaceState":"pushState"](u,"",p),r.value=u}catch(h){console.error(h),n[d?"replace":"assign"](p)}}function a(c,u){const d=be({},t.state,Ss(r.value.back,c,r.value.forward,!0),u,{position:r.value.position});o(c,d,!0),l.value=c}function i(c,u){const d=be({},r.value,t.state,{forward:c,scroll:xr()});o(d.current,d,!0);const f=be({},Ss(l.value,c,null),{position:d.position+1},u);o(c,f,!1),l.value=c}return{location:l,state:r,push:i,replace:a}}function u6(e){e=e6(e);const t=c6(e),n=i6(e,t.state,t.location,t.replace);function l(o,a=!0){a||n.pauseListeners(),history.go(o)}const r=be({location:"",base:e,go:l,createHref:n6.bind(null,e)},t,n);return Object.defineProperty(r,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(r,"state",{enumerable:!0,get:()=>t.state.value}),r}function d6(e){return typeof e=="string"||e&&typeof e=="object"}function Y1(e){return typeof e=="string"||typeof e=="symbol"}const Ot={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},J1=Symbol("");var Ps;(function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"})(Ps||(Ps={}));function zn(e,t){return be(new Error,{type:e,[J1]:!0},t)}function Lt(e,t){return e instanceof Error&&J1 in e&&(t==null||!!(e.type&t))}const Os="[^/]+?",f6={sensitive:!1,strict:!1,start:!0,end:!0},p6=/[.+*?^${}()[\]/\\]/g;function h6(e,t){const n=be({},f6,t),l=[];let r=n.start?"^":"";const o=[];for(const u of e){const d=u.length?[]:[90];n.strict&&!u.length&&(r+="/");for(let f=0;ft.length?t.length===1&&t[0]===40+40?1:-1:0}function m6(e,t){let n=0;const l=e.score,r=t.score;for(;n0&&t[t.length-1]<0}const g6={type:0,value:""},y6=/[a-zA-Z0-9_]/;function b6(e){if(!e)return[[]];if(e==="/")return[[g6]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(h){throw new Error(`ERR (${n})/"${u}": ${h}`)}let n=0,l=n;const r=[];let o;function a(){o&&r.push(o),o=[]}let i=0,c,u="",d="";function f(){u&&(n===0?o.push({type:0,value:u}):n===1||n===2||n===3?(o.length>1&&(c==="*"||c==="+")&&t(`A repeatable param (${u}) must be alone in its segment. eg: '/:ids+.`),o.push({type:1,value:u,regexp:d,repeatable:c==="*"||c==="+",optional:c==="*"||c==="?"})):t("Invalid state to consume buffer"),u="")}function p(){u+=c}for(;i{a(b)}:al}function a(d){if(Y1(d)){const f=l.get(d);f&&(l.delete(d),n.splice(n.indexOf(f),1),f.children.forEach(a),f.alias.forEach(a))}else{const f=n.indexOf(d);f>-1&&(n.splice(f,1),d.record.name&&l.delete(d.record.name),d.children.forEach(a),d.alias.forEach(a))}}function i(){return n}function c(d){let f=0;for(;f=0&&(d.record.path!==n[f].record.path||!Q1(d,n[f]));)f++;n.splice(f,0,d),d.record.name&&!Bs(d)&&l.set(d.record.name,d)}function u(d,f){let p,h={},y,w;if("name"in d&&d.name){if(p=l.get(d.name),!p)throw zn(1,{location:d});w=p.record.name,h=be($s(f.params,p.keys.filter(b=>!b.optional).map(b=>b.name)),d.params&&$s(d.params,p.keys.map(b=>b.name))),y=p.stringify(h)}else if("path"in d)y=d.path,p=n.find(b=>b.re.test(y)),p&&(h=p.parse(y),w=p.record.name);else{if(p=f.name?l.get(f.name):n.find(b=>b.re.test(f.path)),!p)throw zn(1,{location:d,currentLocation:f});w=p.record.name,h=be({},f.params,d.params),y=p.stringify(h)}const x=[];let m=p;for(;m;)x.unshift(m.record),m=m.parent;return{name:w,path:y,params:h,matched:x,meta:C6(x)}}return e.forEach(d=>o(d)),{addRoute:o,resolve:u,removeRoute:a,getRoutes:i,getRecordMatcher:r}}function $s(e,t){const n={};for(const l of t)l in e&&(n[l]=e[l]);return n}function w6(e){return{path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:void 0,beforeEnter:e.beforeEnter,props:x6(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}}}function x6(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const l in e.components)t[l]=typeof n=="boolean"?n:n[l];return t}function Bs(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function C6(e){return e.reduce((t,n)=>be(t,n.meta),{})}function Is(e,t){const n={};for(const l in e)n[l]=l in t?t[l]:e[l];return n}function Q1(e,t){return t.children.some(n=>n===e||Q1(e,n))}const Z1=/#/g,A6=/&/g,k6=/\//g,T6=/=/g,L6=/\?/g,X1=/\+/g,S6=/%5B/g,P6=/%5D/g,ec=/%5E/g,O6=/%60/g,tc=/%7B/g,M6=/%7C/g,nc=/%7D/g,$6=/%20/g;function oa(e){return encodeURI(""+e).replace(M6,"|").replace(S6,"[").replace(P6,"]")}function B6(e){return oa(e).replace(tc,"{").replace(nc,"}").replace(ec,"^")}function fo(e){return oa(e).replace(X1,"%2B").replace($6,"+").replace(Z1,"%23").replace(A6,"%26").replace(O6,"`").replace(tc,"{").replace(nc,"}").replace(ec,"^")}function I6(e){return fo(e).replace(T6,"%3D")}function D6(e){return oa(e).replace(Z1,"%23").replace(L6,"%3F")}function R6(e){return e==null?"":D6(e).replace(k6,"%2F")}function ir(e){try{return decodeURIComponent(""+e)}catch{}return""+e}function z6(e){const t={};if(e===""||e==="?")return t;const l=(e[0]==="?"?e.slice(1):e).split("&");for(let r=0;ro&&fo(o)):[l&&fo(l)]).forEach(o=>{o!==void 0&&(t+=(t.length?"&":"")+n,o!=null&&(t+="="+o))})}return t}function F6(e){const t={};for(const n in e){const l=e[n];l!==void 0&&(t[n]=yt(l)?l.map(r=>r==null?null:""+r):l==null?l:""+l)}return t}const N6=Symbol(""),Rs=Symbol(""),Cr=Symbol(""),aa=Symbol(""),po=Symbol("");function Qn(){let e=[];function t(l){return e.push(l),()=>{const r=e.indexOf(l);r>-1&&e.splice(r,1)}}function n(){e=[]}return{add:t,list:()=>e,reset:n}}function Ht(e,t,n,l,r){const o=l&&(l.enterCallbacks[r]=l.enterCallbacks[r]||[]);return()=>new Promise((a,i)=>{const c=f=>{f===!1?i(zn(4,{from:n,to:t})):f instanceof Error?i(f):d6(f)?i(zn(2,{from:t,to:f})):(o&&l.enterCallbacks[r]===o&&typeof f=="function"&&o.push(f),a())},u=e.call(l&&l.instances[r],t,n,c);let d=Promise.resolve(u);e.length<3&&(d=d.then(c)),d.catch(f=>i(f))})}function Vr(e,t,n,l){const r=[];for(const o of e)for(const a in o.components){let i=o.components[a];if(!(t!=="beforeRouteEnter"&&!o.instances[a]))if(V6(i)){const u=(i.__vccOpts||i)[t];u&&r.push(Ht(u,n,l,o,a))}else{let c=i();r.push(()=>c.then(u=>{if(!u)return Promise.reject(new Error(`Couldn't resolve component "${a}" at "${o.path}"`));const d=W3(u)?u.default:u;o.components[a]=d;const p=(d.__vccOpts||d)[t];return p&&Ht(p,n,l,o,a)()}))}}return r}function V6(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function ho(e){const t=ce(Cr),n=ce(aa),l=_(()=>t.resolve(sn(e.to))),r=_(()=>{const{matched:c}=l.value,{length:u}=c,d=c[u-1],f=n.matched;if(!d||!f.length)return-1;const p=f.findIndex(Rn.bind(null,d));if(p>-1)return p;const h=zs(c[u-2]);return u>1&&zs(d)===h&&f[f.length-1].path!==h?f.findIndex(Rn.bind(null,c[u-2])):p}),o=_(()=>r.value>-1&&q6(n.params,l.value.params)),a=_(()=>r.value>-1&&r.value===n.matched.length-1&&W1(n.params,l.value.params));function i(c={}){return j6(c)?t[sn(e.replace)?"replace":"push"](sn(e.to)).catch(al):Promise.resolve()}return{route:l,href:_(()=>l.value.href),isActive:o,isExactActive:a,navigate:i}}const H6=B({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:ho,setup(e,{slots:t}){const n=Hn(ho(e)),{options:l}=ce(Cr),r=_(()=>({[Fs(e.activeClass,l.linkActiveClass,"router-link-active")]:n.isActive,[Fs(e.exactActiveClass,l.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const o=t.default&&t.default(n);return e.custom?o:s("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:r.value},o)}}}),$e=H6;function j6(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function q6(e,t){for(const n in t){const l=t[n],r=e[n];if(typeof l=="string"){if(l!==r)return!1}else if(!yt(r)||r.length!==l.length||l.some((o,a)=>o!==r[a]))return!1}return!0}function zs(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const Fs=(e,t,n)=>e??t??n,U6=B({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const l=ce(po),r=_(()=>e.route||l.value),o=ce(Rs,0),a=_(()=>{let u=sn(o);const{matched:d}=r.value;let f;for(;(f=d[u])&&!f.components;)u++;return u}),i=_(()=>r.value.matched[a.value]);mt(Rs,_(()=>a.value+1)),mt(N6,i),mt(po,r);const c=V();return se(()=>[c.value,i.value,e.name],([u,d,f],[p,h,y])=>{d&&(d.instances[f]=u,h&&h!==d&&u&&u===p&&(d.leaveGuards.size||(d.leaveGuards=h.leaveGuards),d.updateGuards.size||(d.updateGuards=h.updateGuards))),u&&d&&(!h||!Rn(d,h)||!p)&&(d.enterCallbacks[f]||[]).forEach(w=>w(u))},{flush:"post"}),()=>{const u=r.value,d=e.name,f=i.value,p=f&&f.components[d];if(!p)return Ns(n.default,{Component:p,route:u});const h=f.props[d],y=h?h===!0?u.params:typeof h=="function"?h(u):h:null,x=s(p,be({},y,t,{onVnodeUnmounted:m=>{m.component.isUnmounted&&(f.instances[d]=null)},ref:c}));return Ns(n.default,{Component:x,route:u})||x}}});function Ns(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const lc=U6;function G6(e){const t=_6(e.routes,e),n=e.parseQuery||z6,l=e.stringifyQuery||Ds,r=e.history,o=Qn(),a=Qn(),i=Qn(),c=Se(Ot);let u=Ot;wn&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const d=Fr.bind(null,k=>""+k),f=Fr.bind(null,R6),p=Fr.bind(null,ir);function h(k,F){let R,W;return Y1(k)?(R=t.getRecordMatcher(k),W=F):W=k,t.addRoute(W,R)}function y(k){const F=t.getRecordMatcher(k);F&&t.removeRoute(F)}function w(){return t.getRoutes().map(k=>k.record)}function x(k){return!!t.getRecordMatcher(k)}function m(k,F){if(F=be({},F||c.value),typeof k=="string"){const E=Nr(n,k,F.path),C=t.resolve({path:E.path},F),L=r.createHref(E.fullPath);return be(E,C,{params:p(C.params),hash:ir(E.hash),redirectedFrom:void 0,href:L})}let R;if("path"in k)R=be({},k,{path:Nr(n,k.path,F.path).path});else{const E=be({},k.params);for(const C in E)E[C]==null&&delete E[C];R=be({},k,{params:f(E)}),F.params=f(F.params)}const W=t.resolve(R,F),ge=k.hash||"";W.params=d(p(W.params));const v=J3(l,be({},k,{hash:B6(ge),path:W.path})),g=r.createHref(v);return be({fullPath:v,hash:ge,query:l===Ds?F6(k.query):k.query||{}},W,{redirectedFrom:void 0,href:g})}function b(k){return typeof k=="string"?Nr(n,k,c.value.path):be({},k)}function M(k,F){if(u!==k)return zn(8,{from:F,to:k})}function $(k){return G(k)}function q(k){return $(be(b(k),{replace:!0}))}function P(k){const F=k.matched[k.matched.length-1];if(F&&F.redirect){const{redirect:R}=F;let W=typeof R=="function"?R(k):R;return typeof W=="string"&&(W=W.includes("?")||W.includes("#")?W=b(W):{path:W},W.params={}),be({query:k.query,hash:k.hash,params:"path"in W?{}:k.params},W)}}function G(k,F){const R=u=m(k),W=c.value,ge=k.state,v=k.force,g=k.replace===!0,E=P(R);if(E)return G(be(b(E),{state:typeof E=="object"?be({},ge,E.state):ge,force:v,replace:g}),F||R);const C=R;C.redirectedFrom=F;let L;return!v&&Q3(l,W,R)&&(L=zn(16,{to:C,from:W}),Je(W,W,!0,!1)),(L?Promise.resolve(L):K(C,W)).catch(S=>Lt(S)?Lt(S,2)?S:Ve(S):he(S,C,W)).then(S=>{if(S){if(Lt(S,2))return G(be({replace:g},b(S.to),{state:typeof S.to=="object"?be({},ge,S.to.state):ge,force:v}),F||C)}else S=N(C,W,!0,g,ge);return le(C,W,S),S})}function A(k,F){const R=M(k,F);return R?Promise.reject(R):Promise.resolve()}function H(k){const F=wt.values().next().value;return F&&typeof F.runWithContext=="function"?F.runWithContext(k):k()}function K(k,F){let R;const[W,ge,v]=W6(k,F);R=Vr(W.reverse(),"beforeRouteLeave",k,F);for(const E of W)E.leaveGuards.forEach(C=>{R.push(Ht(C,k,F))});const g=A.bind(null,k,F);return R.push(g),Be(R).then(()=>{R=[];for(const E of o.list())R.push(Ht(E,k,F));return R.push(g),Be(R)}).then(()=>{R=Vr(ge,"beforeRouteUpdate",k,F);for(const E of ge)E.updateGuards.forEach(C=>{R.push(Ht(C,k,F))});return R.push(g),Be(R)}).then(()=>{R=[];for(const E of k.matched)if(E.beforeEnter&&!F.matched.includes(E))if(yt(E.beforeEnter))for(const C of E.beforeEnter)R.push(Ht(C,k,F));else R.push(Ht(E.beforeEnter,k,F));return R.push(g),Be(R)}).then(()=>(k.matched.forEach(E=>E.enterCallbacks={}),R=Vr(v,"beforeRouteEnter",k,F),R.push(g),Be(R))).then(()=>{R=[];for(const E of a.list())R.push(Ht(E,k,F));return R.push(g),Be(R)}).catch(E=>Lt(E,8)?E:Promise.reject(E))}function le(k,F,R){for(const W of i.list())H(()=>W(k,F,R))}function N(k,F,R,W,ge){const v=M(k,F);if(v)return v;const g=F===Ot,E=wn?history.state:{};R&&(W||g?r.replace(k.fullPath,be({scroll:g&&E&&E.scroll},ge)):r.push(k.fullPath,ge)),c.value=k,Je(k,F,R,g),Ve()}let Z;function j(){Z||(Z=r.listen((k,F,R)=>{if(!Zt.listening)return;const W=m(k),ge=P(W);if(ge){G(be(ge,{replace:!0}),W).catch(al);return}u=W;const v=c.value;wn&&o6(Ls(v.fullPath,R.delta),xr()),K(W,v).catch(g=>Lt(g,12)?g:Lt(g,2)?(G(g.to,W).then(E=>{Lt(E,20)&&!R.delta&&R.type===gl.pop&&r.go(-1,!1)}).catch(al),Promise.reject()):(R.delta&&r.go(-R.delta,!1),he(g,W,v))).then(g=>{g=g||N(W,v,!1),g&&(R.delta&&!Lt(g,8)?r.go(-R.delta,!1):R.type===gl.pop&&Lt(g,20)&&r.go(-1,!1)),le(W,v,g)}).catch(al)}))}let Pe=Qn(),ne=Qn(),ye;function he(k,F,R){Ve(k);const W=ne.list();return W.length?W.forEach(ge=>ge(k,F,R)):console.error(k),Promise.reject(k)}function Ye(){return ye&&c.value!==Ot?Promise.resolve():new Promise((k,F)=>{Pe.add([k,F])})}function Ve(k){return ye||(ye=!k,j(),Pe.list().forEach(([F,R])=>k?R(k):F()),Pe.reset()),k}function Je(k,F,R,W){const{scrollBehavior:ge}=e;if(!wn||!ge)return Promise.resolve();const v=!R&&a6(Ls(k.fullPath,0))||(W||!R)&&history.state&&history.state.scroll||null;return qn().then(()=>ge(k,F,v)).then(g=>g&&r6(g)).catch(g=>he(g,k,F))}const Oe=k=>r.go(k);let _t;const wt=new Set,Zt={currentRoute:c,listening:!0,addRoute:h,removeRoute:y,hasRoute:x,getRoutes:w,resolve:m,options:e,push:$,replace:q,go:Oe,back:()=>Oe(-1),forward:()=>Oe(1),beforeEach:o.add,beforeResolve:a.add,afterEach:i.add,onError:ne.add,isReady:Ye,install(k){const F=this;k.component("RouterLink",$e),k.component("RouterView",lc),k.config.globalProperties.$router=F,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>sn(c)}),wn&&!_t&&c.value===Ot&&(_t=!0,$(r.location).catch(ge=>{}));const R={};for(const ge in Ot)R[ge]=_(()=>c.value[ge]);k.provide(Cr,F),k.provide(aa,Hn(R)),k.provide(po,c);const W=k.unmount;wt.add(k),k.unmount=function(){wt.delete(k),wt.size<1&&(u=Ot,Z&&Z(),Z=null,c.value=Ot,_t=!1,ye=!1),W()}}};function Be(k){return k.reduce((F,R)=>F.then(()=>H(R)),Promise.resolve())}return Zt}function W6(e,t){const n=[],l=[],r=[],o=Math.max(t.matched.length,e.matched.length);for(let a=0;aRn(u,i))?l.push(i):n.push(i));const c=e.matched[a];c&&(t.matched.find(u=>Rn(u,c))||r.push(c))}return[n,l,r]}function Ke(){return ce(Cr)}function Et(){return ce(aa)}const K6=({headerLinkSelector:e,headerAnchorSelector:t,delay:n,offset:l=5})=>{const r=Ke(),a=G3(()=>{var w,x;const i=Math.max(window.scrollY,document.documentElement.scrollTop,document.body.scrollTop);if(Math.abs(i-0)p.some(b=>b.hash===m.hash));for(let m=0;m=(((w=b.parentElement)==null?void 0:w.offsetTop)??0)-l,q=!M||i<(((x=M.parentElement)==null?void 0:x.offsetTop)??0)-l;if(!($&&q))continue;const G=decodeURIComponent(r.currentRoute.value.hash),A=decodeURIComponent(b.hash);if(G===A)return;if(f){for(let H=m+1;H{window.addEventListener("scroll",a)}),jo(()=>{window.removeEventListener("scroll",a)})},Vs=async(e,t)=>{const{scrollBehavior:n}=e.options;e.options.scrollBehavior=void 0,await e.replace({query:e.currentRoute.value.query,hash:t,force:!0}).finally(()=>e.options.scrollBehavior=n)},Y6=".sidebar-link, .toc-link",J6=".header-anchor",Q6=200,Z6=5,X6=bt({setup(){K6({headerLinkSelector:Y6,headerAnchorSelector:J6,delay:Q6,offset:Z6})}});let rc=()=>null;const oc=Symbol(""),e8=e=>{rc=e},t8=()=>ce(oc),n8=e=>{e.provide(oc,rc)};var l8=B({name:"AutoCatalog",props:{base:{type:String,default:""},level:{type:Number,default:3},index:Boolean},setup(e){const t=t8(),n=Cl({"/en/":{title:"Catalog"},"/":{title:"目录"}}),l=ue(),r=Ke(),o=h1(),a=u=>{const d=u.I;return typeof d>"u"||d},i=()=>{const u=e.base||l.value.path.replace(/\/[^/]+$/,"/"),d=r.getRoutes(),f=[];return d.filter(({meta:p,path:h})=>{if(!vl(h,u)||h===u)return!1;if(u==="/"){const y=nt(o.value.locales).filter(w=>w!=="/");if(h==="/404.html"||y.some(w=>vl(h,w)))return!1}return(bn(h,".html")&&!bn(h,"/index.html")||bn(h,"/"))&&a(p)}).map(({path:p,meta:h})=>{const y=p.substring(u.length).split("/").length;return{title:h.t||"",icon:h.i,base:p.replace(/\/[^/]+\/?$/,"/"),order:h.O||null,level:bn(p,"/")?y-1:y,path:p}}).filter(({title:p,level:h})=>typeof p=="string"&&p&&h<=e.level).sort(({title:p,level:h,path:y,order:w},{title:x,level:m,path:b,order:M})=>h-m||(bn(y,"/index.html")?-1:bn(b,"/index.html")?1:w===null?M===null?p.localeCompare(x):M:M===null?w:w>0?M>0?w-M:-1:M<0?w-M:1)).forEach(p=>{var h;const{base:y,level:w}=p;switch(w){case 1:f.push(p);break;case 2:{const x=f.find(m=>m.path===y);x&&(x.children??(x.children=[])).push(p);break}default:{const x=f.find(m=>m.path===y.replace(/\/[^/]+\/$/,"/"));if(x){const m=(h=x.children)==null?void 0:h.find(b=>b.path===y);m&&(m.children??(m.children=[])).push(p)}}}}),f},c=_(()=>i());return()=>s("div",{class:"auto-catalog-wrapper"},[s("h2",{class:"main-title"},n.value.title),c.value.map(({children:u=[],icon:d,path:f,title:p},h)=>[s("h3",{id:p,class:["child-title",{"has-children":u.length}]},[s("a",{href:`#${p}`,class:"header-anchor"},"#"),s($e,{class:"catalog-title",to:f},()=>[e.index?`${h+1}.`:null,d&&t?s(t,{icon:d}):null,p||"Unknown"])]),u.length?s("ul",{class:"child-catalog-wrapper"},u.map(({children:y=[],icon:w,path:x,title:m},b)=>s("li",{class:"child-catalog-item"},[s("div",{class:["sub-title",{"has-children":y.length}]},[s("a",{href:`#${m}`,class:"header-anchor"},"#"),s($e,{class:"catalog-title",to:x},()=>[e.index?`${h+1}.${b+1}`:null,w&&t?s(t,{icon:w}):null,m||"Unknown"])]),y.length?s("div",{class:"sub-catalog-wrapper"},y.map(({icon:M,path:$,title:q},P)=>s($e,{class:"sub-catalog-item",to:$},()=>[e.index?`${h+1}.${b+1}.${P+1}`:null,M&&t?s(t,{icon:M}):null,q||"Unknown"]))):null]))):null])])}}),r8=bt({enhance:({app:e})=>{n8(e),gt("AutoCatalog",e)||e.component("AutoCatalog",l8)}});const o8=s("svg",{class:"external-link-icon",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false",x:"0px",y:"0px",viewBox:"0 0 100 100",width:"15",height:"15"},[s("path",{fill:"currentColor",d:"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"}),s("polygon",{fill:"currentColor",points:"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"})]),ac=B({name:"ExternalLinkIcon",props:{locales:{type:Object,required:!1,default:()=>({})}},setup(e){const t=Tt(),n=_(()=>e.locales[t.value]??{openInNewWindow:"open in new window"});return()=>s("span",[o8,s("span",{class:"external-link-icon-sr-only"},n.value.openInNewWindow)])}}),a8={},s8=bt({enhance({app:e}){e.component("ExternalLinkIcon",s(ac,{locales:a8}))}});/** - * NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress - * @license MIT - */const de={settings:{minimum:.08,easing:"ease",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,barSelector:'[role="bar"]',parent:"body",template:'
'},status:null,set:e=>{const t=de.isStarted();e=Hr(e,de.settings.minimum,1),de.status=e===1?null:e;const n=de.render(!t),l=n.querySelector(de.settings.barSelector),r=de.settings.speed,o=de.settings.easing;return n.offsetWidth,i8(a=>{Ul(l,{transform:"translate3d("+Hs(e)+"%,0,0)",transition:"all "+r+"ms "+o}),e===1?(Ul(n,{transition:"none",opacity:"1"}),n.offsetWidth,setTimeout(function(){Ul(n,{transition:"all "+r+"ms linear",opacity:"0"}),setTimeout(function(){de.remove(),a()},r)},r)):setTimeout(()=>a(),r)}),de},isStarted:()=>typeof de.status=="number",start:()=>{de.status||de.set(0);const e=()=>{setTimeout(()=>{de.status&&(de.trickle(),e())},de.settings.trickleSpeed)};return de.settings.trickle&&e(),de},done:e=>!e&&!de.status?de:de.inc(.3+.5*Math.random()).set(1),inc:e=>{let t=de.status;return t?(typeof e!="number"&&(e=(1-t)*Hr(Math.random()*t,.1,.95)),t=Hr(t+e,0,.994),de.set(t)):de.start()},trickle:()=>de.inc(Math.random()*de.settings.trickleRate),render:e=>{if(de.isRendered())return document.getElementById("nprogress");js(document.documentElement,"nprogress-busy");const t=document.createElement("div");t.id="nprogress",t.innerHTML=de.settings.template;const n=t.querySelector(de.settings.barSelector),l=e?"-100":Hs(de.status||0),r=document.querySelector(de.settings.parent);return Ul(n,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r!==document.body&&js(r,"nprogress-custom-parent"),r==null||r.appendChild(t),t},remove:()=>{qs(document.documentElement,"nprogress-busy"),qs(document.querySelector(de.settings.parent),"nprogress-custom-parent");const e=document.getElementById("nprogress");e&&c8(e)},isRendered:()=>!!document.getElementById("nprogress")},Hr=(e,t,n)=>en?n:e,Hs=e=>(-1+e)*100,i8=function(){const e=[];function t(){const n=e.shift();n&&n(t)}return function(n){e.push(n),e.length===1&&t()}}(),Ul=function(){const e=["Webkit","O","Moz","ms"],t={};function n(a){return a.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(i,c){return c.toUpperCase()})}function l(a){const i=document.body.style;if(a in i)return a;let c=e.length;const u=a.charAt(0).toUpperCase()+a.slice(1);let d;for(;c--;)if(d=e[c]+u,d in i)return d;return a}function r(a){return a=n(a),t[a]??(t[a]=l(a))}function o(a,i,c){i=r(i),a.style[i]=c}return function(a,i){for(const c in i){const u=i[c];u!==void 0&&Object.prototype.hasOwnProperty.call(i,c)&&o(a,c,u)}}}(),sc=(e,t)=>(typeof e=="string"?e:sa(e)).indexOf(" "+t+" ")>=0,js=(e,t)=>{const n=sa(e),l=n+t;sc(n,t)||(e.className=l.substring(1))},qs=(e,t)=>{const n=sa(e);if(!sc(e,t))return;const l=n.replace(" "+t+" "," ");e.className=l.substring(1,l.length-1)},sa=e=>(" "+(e.className||"")+" ").replace(/\s+/gi," "),c8=e=>{e&&e.parentNode&&e.parentNode.removeChild(e)};const u8=()=>{me(()=>{const e=Ke(),t=new Set;t.add(e.currentRoute.value.path),e.beforeEach(n=>{t.has(n.path)||de.start()}),e.afterEach(n=>{t.add(n.path),de.done()})})},d8=bt({setup(){u8()}}),f8=JSON.parse(`{"encrypt":{},"author":{"name":"Chi"},"logo":"/logo.svg","repo":"vuepress-theme-hope/vuepress-theme-hope","docsDir":"docs","blog":{"medias":{"Baidu":"https://example.com","BiliBili":"https://example.com","Bitbucket":"https://example.com","Dingding":"https://example.com","Discord":"https://example.com","Dribbble":"https://example.com","Email":"mailto:info@example.com","Evernote":"https://example.com","Facebook":"https://example.com","Flipboard":"https://example.com","Gitee":"https://example.com","GitHub":"https://example.com","Gitlab":"https://example.com","Gmail":"mailto:info@example.com","Instagram":"https://example.com","Lark":"https://example.com","Lines":"https://example.com","Linkedin":"https://example.com","Pinterest":"https://example.com","Pocket":"https://example.com","QQ":"https://example.com","Qzone":"https://example.com","Reddit":"https://example.com","Rss":"https://example.com","Steam":"https://example.com","Twitter":"https://example.com","Wechat":"https://example.com","Weibo":"https://example.com","Whatsapp":"https://example.com","Youtube":"https://example.com","Zhihu":"https://example.com","MrHope":"https://mrhope.site"}},"locales":{"/en/":{"lang":"en-US","navbarLocales":{"langName":"English","selectLangAriaLabel":"Select language"},"metaLocales":{"author":"Author","date":"Writing Date","origin":"Original","views":"Page views","category":"Category","tag":"Tag","readingTime":"Reading Time","words":"Words","toc":"On This Page","prev":"Prev","next":"Next","lastUpdated":"Last update","contributors":"Contributors","editLink":"Edit this page on GitHub","print":"Print"},"blogLocales":{"article":"Articles","articleList":"Article List","category":"Category","tag":"Tag","timeline":"Timeline","timelineTitle":"Yesterday Once More!","all":"All","intro":"Personal Intro","star":"Star"},"paginationLocales":{"prev":"Prev","next":"Next","navigate":"Jump to","action":"Go","errorText":"Please enter a number between 1 and $page !"},"outlookLocales":{"themeColor":"Theme Color","darkmode":"Theme Mode","fullscreen":"Full Screen"},"routeLocales":{"skipToContent":"Skip to main content","notFoundTitle":"Page not found","notFoundMsg":["There’s nothing here.","How did we get here?","That’s a Four-Oh-Four.","Looks like we've got some broken links."],"back":"Go back","home":"Take me home","openInNewWindow":"Open in new window"},"navbar":["/en/",{"text":"Posts","icon":"edit","prefix":"/en/posts/","children":[]}],"sidebar":{"/en/":["",{"text":"Articles","icon":"note","prefix":"posts/","children":"structure"},"intro"]},"footer":"Default footer","displayFooter":true,"blog":{"description":"A FrontEnd programmer","intro":"/en/intro.html"}},"/":{"lang":"zh-CN","navbarLocales":{"langName":"简体中文","selectLangAriaLabel":"选择语言"},"metaLocales":{"author":"作者","date":"写作日期","origin":"原创","views":"访问量","category":"分类","tag":"标签","readingTime":"阅读时间","words":"字数","toc":"此页内容","prev":"上一页","next":"下一页","lastUpdated":"上次编辑于","contributors":"贡献者","editLink":"在 GitHub 上编辑此页","print":"打印"},"blogLocales":{"article":"文章","articleList":"文章列表","category":"分类","tag":"标签","timeline":"时间轴","timelineTitle":"昨日不在","all":"全部","intro":"个人介绍","star":"收藏"},"paginationLocales":{"prev":"上一页","next":"下一页","navigate":"跳转到","action":"前往","errorText":"请输入 1 到 $page 之前的页码!"},"outlookLocales":{"themeColor":"主题色","darkmode":"外观","fullscreen":"全屏"},"routeLocales":{"skipToContent":"跳至主要內容","notFoundTitle":"页面不存在","notFoundMsg":["这里什么也没有","我们是怎么来到这儿的?","这 是 四 零 四 !","看起来你访问了一个失效的链接"],"back":"返回上一页","home":"带我回家","openInNewWindow":"Open in new window"},"navbar":["/",{"text":"博文","icon":"edit","prefix":"/posts/","children":[{"text":"编译原理","icon":"edit","prefix":"编译原理/","children":[{"text":"Chapter1 编译器组成","icon":"edit","link":"Chapter1 编译器组成"},{"text":"Chapter2 词法分析","icon":"edit","link":"Chapter2 词法分析"},{"text":"Chapter3 语法分析","icon":"edit","link":"Chapter3 语法分析"},{"text":"Chapter4 语义分析","icon":"edit","link":"Chapter4 语义分析"},{"text":"Chapter5 代码生成","icon":"edit","link":"Chapter5 代码生成"}]},{"text":"Linux内核","icon":"edit","prefix":"Linux内核/","children":[{"text":"VsCode+Qemu开发Linux内核","icon":"edit","link":"vscode qemu开发Linux内核"},{"text":"Linux内核Numa实现细节","icon":"edit","link":"NUMA Balancing"}]},{"text":"杂谈","icon":"edit","prefix":"杂谈/","children":[{"text":"震惊!!1=0","icon":"page","link":"编程杂谈/震惊!1等于0.md"},{"text":"记一次 GP Debug 的心路历程","icon":"page","link":"Debug杂谈/记一次 GP Debug 的心路历程.md"}]}]},{"text":"V2 文档","icon":"note","link":"https://theme-hope.vuejs.press/zh/"}],"sidebar":{"/":["",{"text":"文章","icon":"note","prefix":"posts/","children":"structure"},"intro"]},"footer":"默认页脚","displayFooter":true,"blog":{"description":"一个前端开发者","intro":"/intro.html"}}}}`),p8=V(f8),ic=()=>p8,cc=Symbol(""),h8=()=>{const e=ce(cc);if(!e)throw new Error("useThemeLocaleData() is called without provider.");return e},v8=(e,t)=>{const{locales:n,...l}=e;return{...l,...n==null?void 0:n[t]}},m8=bt({enhance({app:e}){const t=ic(),n=e._context.provides[Jo],l=_(()=>v8(t.value,n.value));e.provide(cc,l),Object.defineProperties(e.config.globalProperties,{$theme:{get(){return t.value}},$themeLocale:{get(){return l.value}}})}});const g8={provider:"Giscus",lightTheme:"https://unpkg.com/vuepress-theme-hope@2.0.0-beta.211/templates/giscus/light.css",darkTheme:"https://unpkg.com/vuepress-theme-hope@2.0.0-beta.211/templates/giscus/dark.css",repo:"Chiichen/Chiichen.github.io",repoId:"R_kgDOKevcoA",category:"Announcements",categoryId:"DIC_kwDOKevcoM4CaDrF",mapping:"title"};let y8=g8;const uc=Symbol(""),dc=()=>ce(uc),b8=dc,E8=e=>{e.provide(uc,y8)},Us=["ar","de","gsw","en","es","fa","fr","id","it","ja","ko","nl","pl","pt","ro","ru","th","tr","uk","vi","zh-CN","zh-TW"];var _8=B({name:"GiscusComment",props:{darkmode:Boolean},setup(e){const t=b8(),n=ue(),l=!!(t.repo&&t.repoId&&t.category&&t.categoryId),{repo:r,repoId:o,category:a,categoryId:i}=t,c=V(!1),u=_(()=>{const f=Yo().value;if(Us.includes(f))return f;const p=f.split("-")[0];return Us.includes(p)?p:"en"}),d=_(()=>({repo:r,repoId:o,category:a,categoryId:i,lang:u.value,theme:e.darkmode?t.darkTheme||"dark":t.lightTheme||"light",mapping:t.mapping||"pathname",term:Ne(n.value.path),inputPosition:t.inputPosition||"top",reactionsEnabled:t.reactionsEnabled===!1?"0":"1",strict:t.strict===!1?"0":"1",loading:t.lazyLoading===!1?"eager":"lazy",emitMetadata:"0"}));return me(async()=>{await T(()=>import("./giscus-52604b1e.js"),[]),c.value=!0}),()=>l?s("div",{class:["giscus-wrapper",{"input-top":t.inputPosition!=="bottom"}],id:"comment"},c.value?s("giscus-widget",d.value):s(Kt)):null}}),w8=B({name:"CommentService",props:{darkmode:Boolean},setup(e){const t=dc(),n=we(),l=t.comment!==!1,r=_(()=>n.value.comment||l&&n.value.comment!==!1);return()=>s(_8,{darkmode:e.darkmode,style:{display:r.value?"block":"none"}})}}),x8=bt({enhance:({app:e})=>{E8(e),e.component("CommentService",w8)}});const C8=800,A8=2e3,k8={"/en/":{copy:"Copy code",copied:"Copied",hint:"Copied successfully"},"/":{copy:"复制代码",copied:"已复制",hint:"复制成功"}},T8=!1,L8=['.theme-hope-content div[class*="language-"] pre'],Gs=!1,jr=new Map,S8=()=>{const{copy:e}=b3({legacy:!0}),t=Cl(k8),n=ue(),l=K4(),r=i=>{if(!i.hasAttribute("copy-code-registered")){const c=document.createElement("button");c.type="button",c.classList.add("copy-code-button"),c.innerHTML='
',c.setAttribute("aria-label",t.value.copy),c.setAttribute("data-copied",t.value.copied),i.parentElement&&i.parentElement.insertBefore(c,i),i.setAttribute("copy-code-registered","")}},o=()=>qn().then(()=>new Promise(i=>{setTimeout(()=>{L8.forEach(c=>{document.querySelectorAll(c).forEach(r)}),i()},C8)})),a=(i,c,u)=>{let{innerText:d=""}=c;/language-(shellscript|shell|bash|sh|zsh)/.test(i.classList.toString())&&(d=d.replace(/^ *(\$|>) /gm,"")),e(d).then(()=>{u.classList.add("copied"),clearTimeout(jr.get(u));const f=setTimeout(()=>{u.classList.remove("copied"),u.blur(),jr.delete(u)},A8);jr.set(u,f)})};me(()=>{(!l.value||Gs)&&o(),Re("click",i=>{const c=i.target;if(c.matches('div[class*="language-"] > button.copy')){const u=c.parentElement,d=c.nextElementSibling;d&&a(u,d,c)}else if(c.matches('div[class*="language-"] div.copy-icon')){const u=c.parentElement,d=u.parentElement,f=u.nextElementSibling;f&&a(d,f,u)}}),se(()=>n.value.path,()=>{(!l.value||Gs)&&o()})})};var P8=bt({setup:()=>{S8()}});const O8=(e,t)=>t==="json"?JSON.parse(e):new Function(`let config,__chart_js_config__; -{ -${e} -__chart_js_config__=config; -} -return __chart_js_config__;`)();var M8=B({name:"ChartJS",props:{config:{type:String,required:!0},id:{type:String,required:!0},title:{type:String,default:""},type:{type:String,default:"json"}},setup(e){const t=Se(),n=Se(),l=V(!0);return me(async()=>{const[{default:r}]=await Promise.all([T(()=>import("./auto-fa8841cf.js"),[]),new Promise(i=>setTimeout(i,800))]);r.defaults.maintainAspectRatio=!1;const o=O8(dn(e.config),e.type),a=n.value.getContext("2d");new r(a,o),l.value=!1}),()=>[e.title?s("div",{class:"chart-title"},decodeURIComponent(e.title)):null,l.value?s(Kt,{class:"chart-loading",height:192}):null,s("div",{ref:t,class:"chart-wrapper",id:e.id,style:{display:l.value?"none":"block"}},s("canvas",{ref:n,height:400}))]}});const Gl=la("VUEPRESS_CODE_TAB_STORE",{});var $8=B({name:"CodeTabs",props:{active:{type:Number,default:0},data:{type:Array,required:!0},id:{type:String,required:!0},tabId:{type:String,default:""}},slots:Object,setup(e,{slots:t}){const n=V(e.active),l=Se([]),r=()=>{if(e.tabId){const{title:u,id:d=u}=e.data[n.value];Gl.value[e.tabId]=d}},o=(u=n.value)=>{n.value=u{n.value=u>0?u-1:l.value.length-1,l.value[n.value].focus()},i=(u,d)=>{if(u.key===" "||u.key==="Enter"?(u.preventDefault(),n.value=d):u.key==="ArrowRight"?(u.preventDefault(),o()):u.key==="ArrowLeft"&&(u.preventDefault(),a()),e.tabId){const{title:f,id:p=f}=e.data[n.value];Gl.value[e.tabId]=p}},c=()=>{if(e.tabId){const u=e.data.findIndex(({title:d,id:f=d})=>Gl.value[e.tabId]===f);if(u!==-1)return u}return e.active};return me(()=>{n.value=c(),se(()=>Gl.value[e.tabId],(u,d)=>{if(e.tabId&&u!==d){const f=e.data.findIndex(({title:p,id:h=p})=>h===u);f!==-1&&(n.value=f)}})}),()=>e.data.length?s("div",{class:"code-tabs"},[s("div",{class:"code-tabs-nav",role:"tablist"},e.data.map(({title:u},d)=>{const f=d===n.value;return s("button",{type:"button",ref:p=>{p&&(l.value[d]=p)},class:["code-tabs-nav-tab",{active:f}],role:"tab","aria-controls":`codetab-${e.id}-${d}`,"aria-selected":f,onClick:()=>{n.value=d,r()},onKeydown:p=>i(p,d)},u)})),e.data.map(({title:u,id:d=u},f)=>{const p=f===n.value;return s("div",{class:["code-tab",{active:p}],id:`codetab-${e.id}-${f}`,role:"tabpanel","aria-expanded":p},t[`tab${f}`]({title:u,value:d,isActive:p}))})]):null}});const fc=({active:e=!1},{slots:t})=>{var n;return s("div",{class:["code-group-item",{active:e}],"aria-selected":e},(n=t.default)==null?void 0:n.call(t))};fc.displayName="CodeGroupItem";const B8=B({name:"CodeGroup",slots:Object,setup(e,{slots:t}){const n=V(-1),l=Se([]),r=(i=n.value)=>{n.value=i{n.value=i>0?i-1:l.value.length-1,l.value[n.value].focus()},a=(i,c)=>{i.key===" "||i.key==="Enter"?(i.preventDefault(),n.value=c):i.key==="ArrowRight"?(i.preventDefault(),r(c)):i.key==="ArrowLeft"&&(i.preventDefault(),o(c))};return()=>{var i;const c=(((i=t.default)==null?void 0:i.call(t))||[]).filter(u=>u.type.name==="CodeGroupItem").map(u=>(u.props===null&&(u.props={}),u));return c.length===0?null:(n.value<0||n.value>c.length-1?(n.value=c.findIndex(u=>"active"in u.props),n.value===-1&&(n.value=0)):c.forEach((u,d)=>{u.props.active=d===n.value}),s("div",{class:"code-group"},[s("div",{class:"code-group-nav"},c.map((u,d)=>{const f=d===n.value;return s("button",{type:"button",ref:p=>{p&&(l.value[d]=p)},class:["code-group-nav-tab",{active:f}],"aria-pressed":f,"aria-expanded":f,onClick:()=>{n.value=d},onKeydown:p=>a(p,d)},u.props.title)})),c]))}}});const I8=()=>s(oe,{name:"back"},()=>s("path",{d:"M1014.749 449.156v125.688H260.626l345.64 345.64-89.239 89.237L19.307 512l497.72-497.721 89.238 89.238-345.64 345.64h754.124z"})),D8=()=>s(oe,{name:"home"},()=>s("path",{d:"M780.106 420.978L506.994 147.866 233.882 420.978h.045v455.11H780.06v-455.11h.046zm90.977 90.976V876.09a91.022 91.022 0 01-91.023 91.022H233.927a91.022 91.022 0 01-91.022-91.022V511.954l-67.22 67.175-64.307-64.307 431.309-431.31c35.498-35.498 93.115-35.498 128.614 0l431.309 431.31-64.307 64.307L871.083 512z"})),R8='',z8='',F8='';const qr={useBabel:!1,jsLib:[],cssLib:[],codepenLayout:"left",codepenEditors:"101",babel:"https://unpkg.com/@babel/standalone/babel.min.js",vue:"https://unpkg.com/vue/dist/vue.global.prod.js",react:"https://unpkg.com/react/umd/react.production.min.js",reactDOM:"https://unpkg.com/react-dom/umd/react-dom.production.min.js"},Ws={html:{types:["html","slim","haml","md","markdown","vue"],map:{html:"none",vue:"none",md:"markdown"}},js:{types:["js","javascript","coffee","coffeescript","ts","typescript","ls","livescript"],map:{js:"none",javascript:"none",coffee:"coffeescript",ls:"livescript",ts:"typescript"}},css:{types:["css","less","sass","scss","stylus","styl"],map:{css:"none",styl:"stylus"}}},N8=(e,t,n)=>{const l=document.createElement(e);return br(t)&&nt(t).forEach(r=>{if(r.indexOf("data"))l[r]=t[r];else{const o=r.replace("data","");l.dataset[o]=t[r]}}),n&&n.forEach(r=>{l.appendChild(r)}),l},ia=e=>({...qr,...e,jsLib:Array.from(new Set([...qr.jsLib||[],...e.jsLib||[]])),cssLib:Array.from(new Set([...qr.cssLib||[],...e.cssLib||[]]))}),Sn=(e,t)=>{if(e[t]!==void 0)return e[t];const n=new Promise(l=>{var r;const o=document.createElement("script");o.src=t,(r=document.querySelector("body"))==null||r.appendChild(o),o.onload=()=>{l()}});return e[t]=n,n},V8=(e,t)=>{if(t.css&&Array.from(e.childNodes).every(n=>n.nodeName!=="STYLE")){const n=N8("style",{innerHTML:t.css});e.appendChild(n)}},H8=(e,t,n)=>{const l=n.getScript();if(l&&Array.from(t.childNodes).every(r=>r.nodeName!=="SCRIPT")){const r=document.createElement("script");r.appendChild(document.createTextNode(`{const document=window.document.querySelector('#${e} .code-demo-container').shadowRoot; -${l}}`)),t.appendChild(r)}},j8=e=>{const t=nt(e),n={html:[],js:[],css:[],isLegal:!1};return["html","js","css"].forEach(l=>{const r=t.filter(o=>Ws[l].types.includes(o));if(r.length){const o=r[0];n[l]=[e[o].replace(/^\n|\n$/g,""),Ws[l].map[o]||o]}}),n.isLegal=(!n.html.length||n.html[1]==="none")&&(!n.js.length||n.js[1]==="none")&&(!n.css.length||n.css[1]==="none"),n},pc=e=>e.replace(/
/g,"
").replace(/<((\S+)[^<]*?)\s+\/>/g,"<$1>"),hc=e=>`
-${pc(e)} -
`,q8=e=>`${e.replace("export default ","const $reactApp = ").replace(/App\.__style__(\s*)=(\s*)`([\s\S]*)?`/,"")}; -ReactDOM.createRoot(document.getElementById("app")).render(React.createElement($reactApp))`,U8=e=>e.replace(/export\s+default\s*\{(\n*[\s\S]*)\n*\}\s*;?$/u,"Vue.createApp({$1}).mount('#app')").replace(/export\s+default\s*define(Async)?Component\s*\(\s*\{(\n*[\s\S]*)\n*\}\s*\)\s*;?$/u,"Vue.createApp({$1}).mount('#app')").trim(),vc=e=>`(function(exports){var module={};module.exports=exports;${e};return module.exports.__esModule?module.exports.default:module.exports;})({})`,G8=(e,t)=>{const n=ia(t),l=e.js[0]||"";return{...n,html:pc(e.html[0]||""),js:l,css:e.css[0]||"",isLegal:e.isLegal,getScript:()=>{var r;return n.useBabel?((r=window.Babel.transform(l,{presets:["es2015"]}))==null?void 0:r.code)||"":l}}},W8=/