From 8760c9d638bd92ee20eaeb237d4bd7bc396a94ff Mon Sep 17 00:00:00 2001 From: Chiichen <39649411+Chiichen@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:28:08 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Chiichen?= =?UTF-8?q?/Chiichen.github.io@b68295a18a90ce7659575ce5ceb91a99785e042f=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 6 +- article/index.html | 58 +----- ....html-dfc0710a.js => 404.html-a6f70d40.js} | 2 +- ...\345\211\215\350\250\200.html-6eed63af.js" | 2 +- ...\345\211\215\350\250\200.html-2d5eb814.js" | 1 + ...\345\211\215\350\250\200.html-96fa2a51.js" | 1 + ...=> Chapter1 Introduction.html-77562d6d.js} | 2 +- ...\347\273\204\346\210\220.html-c1a28162.js" | 2 +- ...5\231\250\344\271\213Nom.html-3ca5aab5.js" | 1 + ...5\231\250\344\271\213Nom.html-59f03779.js" | 1 + ...\345\210\206\346\236\220.html-8db905f1.js" | 2 +- ...\345\210\206\346\236\220.html-9f47c9de.js" | 2 +- ...\345\210\206\346\236\220.html-971deb22.js" | 2 +- ...\347\224\237\346\210\220.html-844a1f3b.js" | 2 +- assets/HelloWorld.html-7f084ba3.js | 1 - assets/HelloWorld.html-b68c6228.js | 1 + ...63cf3f6.js => HelloWorld.html-cd96bdbf.js} | 2 +- ...\345\271\263\350\241\241.html-80c506d1.js" | 2 +- ...\346\265\205\346\236\220.html-2bd5abd0.js" | 2 +- ...843.js => NUMA Balancing.html-4fc47f58.js} | 2 +- ...-48f7a9a5.js => VuePlayground-00742e25.js} | 2 +- assets/app-c4602178.js | 166 ----------------- assets/app-f2ef9b44.js | 169 ++++++++++++++++++ assets/{arc-9265186d.js => arc-74303648.js} | 2 +- ...26c2.js => c4Diagram-44c43e89-7c26314c.js} | 2 +- ...7.js => classDiagram-634fc78b-4e80a29f.js} | 2 +- ...s => classDiagram-v2-72bddc41-78f21632.js} | 2 +- ...rer-api.127-0-0-1.nip.io.html-6ef93aeb.js} | 2 +- ...856.js => createText-1f5f8f92-6351667b.js} | 2 +- ...670e6051.js => edges-2e77835f-23a9134c.js} | 2 +- ...d144.js => erDiagram-20cc9db4-d3575c0d.js} | 2 +- ...d3996ca.js => flowDb-52e24d17-439ef241.js} | 2 +- ...36.js => flowDiagram-46a15f6f-dd684e6f.js} | 2 +- assets/flowDiagram-v2-8e52592d-12eceb29.js | 1 + assets/flowDiagram-v2-8e52592d-fb166d46.js | 1 - ...chart-elk-definition-a44a74cb-19f06239.js} | 2 +- ...3.js => ganttDiagram-04e74c0a-cf53126e.js} | 2 +- ...s => gitGraphDiagram-0a645df6-bf4bf57f.js} | 2 +- ...5d56f1a8.js => index-5219d011-413823eb.js} | 2 +- ...tml-160052c7.js => index.html-0759a1f4.js} | 2 +- ...tml-0fbadab6.js => index.html-08ac3477.js} | 2 +- ...tml-082744a3.js => index.html-0a53cfd4.js} | 2 +- ...tml-08c23b60.js => index.html-0cb1bccf.js} | 2 +- assets/index.html-0edf8807.js | 1 + ...tml-2843565e.js => index.html-10dced9b.js} | 2 +- assets/index.html-16642f6e.js | 1 - ...tml-0f8b9808.js => index.html-189b7980.js} | 2 +- ...tml-30779509.js => index.html-1c6fa72e.js} | 2 +- assets/index.html-1db9bb27.js | 1 - assets/index.html-1dbbc9ad.js | 1 + ...tml-78978260.js => index.html-23e74c78.js} | 2 +- assets/index.html-247da3a8.js | 1 - assets/index.html-281d41f5.js | 1 + assets/index.html-2d98bd2c.js | 1 + assets/index.html-301e34ea.js | 1 + assets/index.html-30d133a5.js | 1 - assets/index.html-3b2da730.js | 1 + assets/index.html-3b2f539c.js | 1 + assets/index.html-3b675d43.js | 1 + assets/index.html-3c4c02a5.js | 1 - assets/index.html-456e6a8a.js | 1 - assets/index.html-47abf748.js | 1 + assets/index.html-4d13ac8c.js | 1 - ...tml-3e5bf64a.js => index.html-5018dac0.js} | 2 +- assets/index.html-586f6093.js | 1 - assets/index.html-59fafeab.js | 1 - assets/index.html-5b89acc2.js | 1 + assets/index.html-5b989571.js | 1 + assets/index.html-5cc286c9.js | 1 + assets/index.html-615c61e2.js | 1 + assets/index.html-63d5d3bc.js | 1 - assets/index.html-651e322a.js | 1 - assets/index.html-6d6ad933.js | 1 + assets/index.html-72f53bc5.js | 1 - assets/index.html-7426e7ff.js | 1 + assets/index.html-763af2c9.js | 1 + assets/index.html-77f9ea8f.js | 1 + assets/index.html-78a5b38b.js | 1 - assets/index.html-7ae4dc3f.js | 1 + assets/index.html-7cf360ae.js | 1 + assets/index.html-804e18aa.js | 1 + assets/index.html-878f9764.js | 1 + assets/index.html-a031b045.js | 1 + assets/index.html-a383a4e9.js | 1 - assets/index.html-a3ad4ea7.js | 1 - assets/index.html-a5c41f87.js | 1 - assets/index.html-a9b03920.js | 1 - assets/index.html-ad30fe95.js | 1 - assets/index.html-b9e932f8.js | 1 + assets/index.html-ba783360.js | 1 + assets/index.html-c8a3dd9e.js | 1 + assets/index.html-cc73a3e6.js | 1 - assets/index.html-cd4c3b05.js | 1 + assets/index.html-ce797aca.js | 1 - assets/index.html-d17c0205.js | 1 + assets/index.html-d39c7da3.js | 1 + assets/index.html-d5d71038.js | 1 - assets/index.html-d6325281.js | 1 - assets/index.html-dc55b67c.js | 1 - assets/index.html-df539570.js | 1 - assets/index.html-e3c533d1.js | 1 - assets/index.html-e55b5dd4.js | 1 + assets/index.html-e85672fc.js | 1 + assets/index.html-e9b0f9dc.js | 1 + assets/index.html-ea8be64f.js | 1 + assets/index.html-ebede5dc.js | 1 + assets/index.html-eef1f5bd.js | 1 - assets/index.html-f0f0bda9.js | 1 - assets/index.html-fd6b2109.js | 1 - assets/index.html-ff8832ad.js | 1 - assets/index.html-ffa44b9c.js | 1 - assets/index.html-fffb2e1c.js | 1 - ...96.js => infoDiagram-69ec1a58-a874f3fc.js} | 2 +- ...tml-e2551cbc.js => intro.html-4282e8bd.js} | 2 +- ...tml-3495a78b.js => intro.html-c604c23a.js} | 2 +- ...s_dark-9c739825.js => is_dark-5eb1bc8c.js} | 2 +- ...js => journeyDiagram-d38aa57d-d19e000f.js} | 2 +- ...{layout-d9377737.js => layout-9144a336.js} | 2 +- assets/{line-0891244e.js => line-3b8b3d20.js} | 2 +- ...e-7ffc8b2d.js => mermaid.core-9b6717f3.js} | 6 +- ...> mindmap-definition-65b51176-67c99a95.js} | 2 +- ...4f7.js => pieDiagram-db1a8a21-63e47a59.js} | 2 +- ...> requirementDiagram-b9649942-8506097f.js} | 2 +- ...tAll-274245ca.js => selectAll-90b01b65.js} | 2 +- ...s => sequenceDiagram-446df3e4-f424be9b.js} | 2 +- ...a.js => stateDiagram-d53d2428-d29e88ea.js} | 2 +- ...s => stateDiagram-v2-9765461d-7d603a9d.js} | 2 +- ...9e3d830.js => styles-16907e1b-fa02baca.js} | 2 +- ...12f330a.js => styles-26373982-60dcb4ac.js} | 2 +- ...0ab747a.js => styles-47a825a5-de2442d0.js} | 2 +- ...728082.js => svgDraw-2526cba0-3fe1c9d9.js} | 2 +- ...-3b33e5dc.js => template.html-0badbdea.js} | 2 +- ...-6d4d5791.js => template.html-df9f521b.js} | 2 +- ... timeline-definition-de69aca6-7004f7c4.js} | 2 +- ...\345\206\205\346\240\270.html-c6de6d61.js" | 2 +- ...-repl-98286ccf.js => vue-repl-70f53f6e.js} | 2 +- ...\345\216\206\347\250\213.html-f2cbd1a3.js" | 2 +- ...347\255\211\344\272\2160.html-7690a6c8.js" | 2 +- .../debug\346\235\202\350\260\210/index.html" | 8 +- category/index.html | 6 +- .../index.html" | 8 +- .../\346\235\202\350\260\210/index.html" | 8 +- .../\347\254\224\350\256\260/index.html" | 58 +----- .../index.html" | 11 +- .../index.html" | 8 +- en/article/index.html | 4 +- en/category/index.html | 4 +- en/index.html | 4 +- en/intro.html | 4 +- en/posts/index.html | 4 +- en/posts/template.html | 4 +- en/star/index.html | 4 +- en/tag/index.html | 4 +- en/timeline/index.html | 4 +- index.html | 56 +----- intro.html | 6 +- ...\347\216\260\346\265\205\346\236\220.html" | 6 +- .../NUMA Balancing.html" | 6 +- ...\241\214NUMA\345\271\263\350\241\241.html" | 6 +- .../Patch\350\247\243\350\257\273/index.html" | 6 +- .../Linux\345\206\205\346\240\270/index.html" | 6 +- ...217\221Linux\345\206\205\346\240\270.html" | 6 +- posts/index.html | 6 +- posts/rcc/HelloWorld.html | 92 ---------- posts/rcc/index.html | 40 ----- .../Chapter0\345\211\215\350\250\200.html" | 40 +++++ ...6\236\220\345\231\250\344\271\213Nom.html" | 40 +++++ .../HelloWorld.html" | 92 ++++++++++ .../index.html" | 40 +++++ posts/template.html | 6 +- .../Chapter1 Introduction.html" | 6 +- .../index.html" | 6 +- ...dpoint 'orderer-api.127-0-0-1.nip.io.html" | 6 +- .../Debug\346\235\202\350\260\210/index.html" | 6 +- ...\350\267\257\345\216\206\347\250\213.html" | 6 +- "posts/\346\235\202\350\260\210/index.html" | 6 +- .../index.html" | 6 +- ...6\203\212!1\347\255\211\344\272\2160.html" | 6 +- .../Chapter0 \345\211\215\350\250\200.html" | 6 +- ...\345\231\250\347\273\204\346\210\220.html" | 6 +- ...\346\263\225\345\210\206\346\236\220.html" | 6 +- ...\346\263\225\345\210\206\346\236\220.html" | 6 +- ...\344\271\211\345\210\206\346\236\220.html" | 6 +- ...\347\240\201\347\224\237\346\210\220.html" | 6 +- .../index.html" | 6 +- sitemap.xml | 2 +- star/index.html | 8 +- tag/debug/index.html | 8 +- tag/general-protection/index.html | 8 +- tag/index.html | 6 +- .../index.html" | 8 +- tag/numa/index.html | 8 +- .../index.html" | 8 +- .../index.html" | 8 +- .../index.html" | 8 +- .../index.html" | 8 +- .../index.html" | 8 +- .../index.html" | 11 +- .../index.html" | 8 +- .../index.html" | 40 +++++ timeline/index.html | 6 +- 201 files changed, 721 insertions(+), 718 deletions(-) rename assets/{404.html-dfc0710a.js => 404.html-a6f70d40.js} (71%) rename "assets/Chapter0 \345\211\215\350\250\200.html-09af125b.js" => "assets/Chapter0 \345\211\215\350\250\200.html-6eed63af.js" (97%) create mode 100644 "assets/Chapter0\345\211\215\350\250\200.html-2d5eb814.js" create mode 100644 "assets/Chapter0\345\211\215\350\250\200.html-96fa2a51.js" rename assets/{Chapter1 Introduction.html-96927c54.js => Chapter1 Introduction.html-77562d6d.js} (99%) rename "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-06252c86.js" => "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c1a28162.js" (99%) create mode 100644 "assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-3ca5aab5.js" create mode 100644 "assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-59f03779.js" rename "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-697f1885.js" => "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-8db905f1.js" (99%) rename "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6240be15.js" => "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-9f47c9de.js" (99%) rename "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-cf12c29b.js" => "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-971deb22.js" (99%) rename "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-ca59a43d.js" => "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-844a1f3b.js" (99%) delete mode 100644 assets/HelloWorld.html-7f084ba3.js create mode 100644 assets/HelloWorld.html-b68c6228.js rename assets/{HelloWorld.html-f63cf3f6.js => HelloWorld.html-cd96bdbf.js} (99%) rename "assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-f57b16d9.js" => "assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-80c506d1.js" (98%) rename "assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-423bb93d.js" => "assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-2bd5abd0.js" (99%) rename assets/{NUMA Balancing.html-6466c843.js => NUMA Balancing.html-4fc47f58.js} (96%) rename assets/{VuePlayground-48f7a9a5.js => VuePlayground-00742e25.js} (82%) delete mode 100644 assets/app-c4602178.js create mode 100644 assets/app-f2ef9b44.js rename assets/{arc-9265186d.js => arc-74303648.js} (98%) rename assets/{c4Diagram-44c43e89-edf226c2.js => c4Diagram-44c43e89-7c26314c.js} (99%) rename assets/{classDiagram-634fc78b-4c5efd27.js => classDiagram-634fc78b-4e80a29f.js} (92%) rename assets/{classDiagram-v2-72bddc41-48c11e6e.js => classDiagram-v2-72bddc41-78f21632.js} (90%) rename assets/{could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-68f0cb65.js => could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-6ef93aeb.js} (98%) rename assets/{createText-1f5f8f92-4a434856.js => createText-1f5f8f92-6351667b.js} (99%) rename assets/{edges-2e77835f-670e6051.js => edges-2e77835f-23a9134c.js} (99%) rename assets/{erDiagram-20cc9db4-23f2d144.js => erDiagram-20cc9db4-d3575c0d.js} (99%) rename assets/{flowDb-52e24d17-4d3996ca.js => flowDb-52e24d17-439ef241.js} (99%) rename assets/{flowDiagram-46a15f6f-b3f63136.js => flowDiagram-46a15f6f-dd684e6f.js} (97%) create mode 100644 assets/flowDiagram-v2-8e52592d-12eceb29.js delete mode 100644 assets/flowDiagram-v2-8e52592d-fb166d46.js rename assets/{flowchart-elk-definition-a44a74cb-72adc39b.js => flowchart-elk-definition-a44a74cb-19f06239.js} (99%) rename assets/{ganttDiagram-04e74c0a-029cc603.js => ganttDiagram-04e74c0a-cf53126e.js} (99%) rename assets/{gitGraphDiagram-0a645df6-fe95d0e0.js => gitGraphDiagram-0a645df6-bf4bf57f.js} (99%) rename assets/{index-5219d011-5d56f1a8.js => index-5219d011-413823eb.js} (97%) rename assets/{index.html-160052c7.js => index.html-0759a1f4.js} (76%) rename assets/{index.html-0fbadab6.js => index.html-08ac3477.js} (71%) rename assets/{index.html-082744a3.js => index.html-0a53cfd4.js} (71%) rename assets/{index.html-08c23b60.js => index.html-0cb1bccf.js} (71%) create mode 100644 assets/index.html-0edf8807.js rename assets/{index.html-2843565e.js => index.html-10dced9b.js} (76%) delete mode 100644 assets/index.html-16642f6e.js rename assets/{index.html-0f8b9808.js => index.html-189b7980.js} (71%) rename assets/{index.html-30779509.js => index.html-1c6fa72e.js} (76%) delete mode 100644 assets/index.html-1db9bb27.js create mode 100644 assets/index.html-1dbbc9ad.js rename assets/{index.html-78978260.js => index.html-23e74c78.js} (91%) delete mode 100644 assets/index.html-247da3a8.js create mode 100644 assets/index.html-281d41f5.js create mode 100644 assets/index.html-2d98bd2c.js create mode 100644 assets/index.html-301e34ea.js delete mode 100644 assets/index.html-30d133a5.js create mode 100644 assets/index.html-3b2da730.js create mode 100644 assets/index.html-3b2f539c.js create mode 100644 assets/index.html-3b675d43.js delete mode 100644 assets/index.html-3c4c02a5.js delete mode 100644 assets/index.html-456e6a8a.js create mode 100644 assets/index.html-47abf748.js delete mode 100644 assets/index.html-4d13ac8c.js rename assets/{index.html-3e5bf64a.js => index.html-5018dac0.js} (76%) delete mode 100644 assets/index.html-586f6093.js delete mode 100644 assets/index.html-59fafeab.js create mode 100644 assets/index.html-5b89acc2.js create mode 100644 assets/index.html-5b989571.js create mode 100644 assets/index.html-5cc286c9.js create mode 100644 assets/index.html-615c61e2.js delete mode 100644 assets/index.html-63d5d3bc.js delete mode 100644 assets/index.html-651e322a.js create mode 100644 assets/index.html-6d6ad933.js delete mode 100644 assets/index.html-72f53bc5.js create mode 100644 assets/index.html-7426e7ff.js create mode 100644 assets/index.html-763af2c9.js create mode 100644 assets/index.html-77f9ea8f.js delete mode 100644 assets/index.html-78a5b38b.js create mode 100644 assets/index.html-7ae4dc3f.js create mode 100644 assets/index.html-7cf360ae.js create mode 100644 assets/index.html-804e18aa.js create mode 100644 assets/index.html-878f9764.js create mode 100644 assets/index.html-a031b045.js delete mode 100644 assets/index.html-a383a4e9.js delete mode 100644 assets/index.html-a3ad4ea7.js delete mode 100644 assets/index.html-a5c41f87.js delete mode 100644 assets/index.html-a9b03920.js delete mode 100644 assets/index.html-ad30fe95.js create mode 100644 assets/index.html-b9e932f8.js create mode 100644 assets/index.html-ba783360.js create mode 100644 assets/index.html-c8a3dd9e.js delete mode 100644 assets/index.html-cc73a3e6.js create mode 100644 assets/index.html-cd4c3b05.js delete mode 100644 assets/index.html-ce797aca.js create mode 100644 assets/index.html-d17c0205.js create mode 100644 assets/index.html-d39c7da3.js delete mode 100644 assets/index.html-d5d71038.js delete mode 100644 assets/index.html-d6325281.js delete mode 100644 assets/index.html-dc55b67c.js delete mode 100644 assets/index.html-df539570.js delete mode 100644 assets/index.html-e3c533d1.js create mode 100644 assets/index.html-e55b5dd4.js create mode 100644 assets/index.html-e85672fc.js create mode 100644 assets/index.html-e9b0f9dc.js create mode 100644 assets/index.html-ea8be64f.js create mode 100644 assets/index.html-ebede5dc.js delete mode 100644 assets/index.html-eef1f5bd.js delete mode 100644 assets/index.html-f0f0bda9.js delete mode 100644 assets/index.html-fd6b2109.js delete mode 100644 assets/index.html-ff8832ad.js delete mode 100644 assets/index.html-ffa44b9c.js delete mode 100644 assets/index.html-fffb2e1c.js rename assets/{infoDiagram-69ec1a58-4b66eb96.js => infoDiagram-69ec1a58-a874f3fc.js} (98%) rename assets/{intro.html-e2551cbc.js => intro.html-4282e8bd.js} (85%) rename assets/{intro.html-3495a78b.js => intro.html-c604c23a.js} (85%) rename assets/{is_dark-9c739825.js => is_dark-5eb1bc8c.js} (75%) rename assets/{journeyDiagram-d38aa57d-be56a6dd.js => journeyDiagram-d38aa57d-d19e000f.js} (99%) rename assets/{layout-d9377737.js => layout-9144a336.js} (99%) rename assets/{line-0891244e.js => line-3b8b3d20.js} (93%) rename assets/{mermaid.core-7ffc8b2d.js => mermaid.core-9b6717f3.js} (97%) rename assets/{mindmap-definition-65b51176-7686b406.js => mindmap-definition-65b51176-67c99a95.js} (99%) rename assets/{pieDiagram-db1a8a21-df96f4f7.js => pieDiagram-db1a8a21-63e47a59.js} (98%) rename assets/{requirementDiagram-b9649942-9396fd03.js => requirementDiagram-b9649942-8506097f.js} (99%) rename assets/{selectAll-274245ca.js => selectAll-90b01b65.js} (68%) rename assets/{sequenceDiagram-446df3e4-9a1e7cd1.js => sequenceDiagram-446df3e4-f424be9b.js} (99%) rename assets/{stateDiagram-d53d2428-0cf59a2a.js => stateDiagram-d53d2428-d29e88ea.js} (97%) rename assets/{stateDiagram-v2-9765461d-06da038d.js => stateDiagram-v2-9765461d-7d603a9d.js} (91%) rename assets/{styles-16907e1b-69e3d830.js => styles-16907e1b-fa02baca.js} (99%) rename assets/{styles-26373982-b12f330a.js => styles-26373982-60dcb4ac.js} (97%) rename assets/{styles-47a825a5-20ab747a.js => styles-47a825a5-de2442d0.js} (99%) rename assets/{svgDraw-2526cba0-99728082.js => svgDraw-2526cba0-3fe1c9d9.js} (98%) rename assets/{template.html-3b33e5dc.js => template.html-0badbdea.js} (71%) rename assets/{template.html-6d4d5791.js => template.html-df9f521b.js} (71%) rename assets/{timeline-definition-de69aca6-3b4fe182.js => timeline-definition-de69aca6-7004f7c4.js} (99%) rename "assets/vscode qemu\345\274\200\345\217\221Linux\345\206\205\346\240\270.html-27da18b7.js" => "assets/vscode qemu\345\274\200\345\217\221Linux\345\206\205\346\240\270.html-c6de6d61.js" (98%) rename assets/{vue-repl-98286ccf.js => vue-repl-70f53f6e.js} (99%) rename "assets/\350\256\260\344\270\200\346\254\241 GP Debug \347\232\204\345\277\203\350\267\257\345\216\206\347\250\213.html-5182ce0a.js" => "assets/\350\256\260\344\270\200\346\254\241 GP Debug \347\232\204\345\277\203\350\267\257\345\216\206\347\250\213.html-f2cbd1a3.js" (99%) rename "assets/\351\234\207\346\203\212!1\347\255\211\344\272\2160.html-e049d2d4.js" => "assets/\351\234\207\346\203\212!1\347\255\211\344\272\2160.html-7690a6c8.js" (98%) delete mode 100644 posts/rcc/HelloWorld.html delete mode 100644 posts/rcc/index.html create mode 100644 "posts/rcc\347\274\226\350\257\221\345\231\250/Chapter0\345\211\215\350\250\200.html" create mode 100644 "posts/rcc\347\274\226\350\257\221\345\231\250/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html" create mode 100644 "posts/rcc\347\274\226\350\257\221\345\231\250/HelloWorld.html" create mode 100644 "posts/rcc\347\274\226\350\257\221\345\231\250/index.html" create mode 100644 "tag/\350\257\215\346\263\225\345\210\206\346\236\220/index.html" diff --git a/404.html b/404.html index 054bbd753..60ae11b4c 100644 --- a/404.html +++ b/404.html @@ -31,10 +31,10 @@ } - + -

404

页面不存在

这 是 四 零 四 !

- +

404

页面不存在

这里什么也没有

+ diff --git a/article/index.html b/article/index.html index edb1fba3a..7eacb7495 100644 --- a/article/index.html +++ b/article/index.html @@ -31,10 +31,10 @@ } - + -
NUMA Balance实现浅析

参考资料

+
template
sudo apt-get -y install clang curl llvm-14.0.0-dev
-

ChiChen原创大约 1 分钟笔记编译器编译器
Chapter1 Introduction

Database Management System (DBMS)

-
    -
  • DBMS 包括: -
      -
    1. 相关数据的集合
    2. -
    3. 访问数据的程序集
    4. -
    5. 一个既方便又高效的使用环境
    6. -
    -
  • -
-

文件系统存储数据的缺点

-
    -
  • -

    数据冗余和不一致:多种文件格式,不同文件中的信息重复

    -
  • -
  • -

    访问数据困难:需要编写新程序来执行每项新任务

    -
  • -
  • -

    数据隔离——多个文件和格式

    -
  • -
  • -

    完整性问题 :

    -
      -
    • 完整性约束(例如,帐户余额 > 0)被“隐藏”在程序代码中,而不是明确声明
    • -
    • 很难添加新的约束或更改现有的约束
    • -
    -
  • -
  • -

    更新的原子性

    -
      -
    • 故障可能会使数据库处于与执行的部分更新不一致的状态
    • -
    • 示例:资金从一个账户转移到另一个账户要么完成,要么根本不发生
    • -
    -
  • -
  • -

    多用户并发访问

    -
      -
    • 并发访问以提高性能
    • -
    • 不受控制的并发访问可能会导致不一致
    • -
    • 示例:两个人同时读取余额(例如 100)并通过提款(例如每人 50)来更新余额
    • -
    -
  • -
  • -

    安全问题 难以向用户提供对部分(但不是全部)数据的访问权限

    -
  • -

ChiChen原创大约 5 分钟笔记笔记/数据库
2
- +

运算


ChiChen原创大约 8 分钟笔记笔记/编译原理
Chapter0 前言

开端

+

本笔记是本人研究编译器开发rcc的思考笔记,涵盖了在开发过程中的思考和记录,希望有助于其它学生/开发者

+

语言计划

+

希望结合 go 语言的指针+gc的特性和 rust 的错误处理、枚举类型等语法特性,实现一个类似于用 gc+指针 替换掉所有权机制的 rust 语言(r门),面向非系统场景下的编程。当然这是一个非常初步的目标(写于项目开始2023/11/03),可能将来会有所改变,但这是初步的目标,以此为勉励吧


ChiChen原创小于 1 分钟笔记编译器编译器
2
+ diff --git a/assets/404.html-dfc0710a.js b/assets/404.html-a6f70d40.js similarity index 71% rename from assets/404.html-dfc0710a.js rename to assets/404.html-a6f70d40.js index 257e0606d..1225ff2ca 100644 --- a/assets/404.html-dfc0710a.js +++ b/assets/404.html-a6f70d40.js @@ -1 +1 @@ -import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as t,c}from"./app-c4602178.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-f2ef9b44.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-09af125b.js" "b/assets/Chapter0 \345\211\215\350\250\200.html-6eed63af.js" similarity index 97% rename from "assets/Chapter0 \345\211\215\350\250\200.html-09af125b.js" rename to "assets/Chapter0 \345\211\215\350\250\200.html-6eed63af.js" index 6262b89d0..185985129 100644 --- "a/assets/Chapter0 \345\211\215\350\250\200.html-09af125b.js" +++ "b/assets/Chapter0 \345\211\215\350\250\200.html-6eed63af.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-c4602178.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-f2ef9b44.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/Chapter0\345\211\215\350\250\200.html-2d5eb814.js" "b/assets/Chapter0\345\211\215\350\250\200.html-2d5eb814.js" new file mode 100644 index 000000000..44b7f9034 --- /dev/null +++ "b/assets/Chapter0\345\211\215\350\250\200.html-2d5eb814.js" @@ -0,0 +1 @@ +import{_ as o}from"./plugin-vue_export-helper-c27b6911.js";import{r as n,o as a,c,a as e,b as r,d as s}from"./app-f2ef9b44.js";const _={},d=e("h2",{id:"开端",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#开端","aria-hidden":"true"},"#"),r(" 开端")],-1),h={href:"https://github.com/RccCommunity/rcc",target:"_blank",rel:"noopener noreferrer"},i=e("h2",{id:"语言计划",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#语言计划","aria-hidden":"true"},"#"),r(" 语言计划")],-1),l=e("p",null,"希望结合 go 语言的指针+gc的特性和 rust 的错误处理、枚举类型等语法特性,实现一个类似于用 gc+指针 替换掉所有权机制的 rust 语言(r门),面向非系统场景下的编程。当然这是一个非常初步的目标(写于项目开始2023/11/03),可能将来会有所改变,但这是初步的目标,以此为勉励吧",-1);function m(p,u){const t=n("ExternalLinkIcon");return a(),c("div",null,[d,e("p",null,[r("本笔记是本人研究编译器开发"),e("a",h,[r("rcc"),s(t)]),r("的思考笔记,涵盖了在开发过程中的思考和记录,希望有助于其它学生/开发者")]),i,l])}const b=o(_,[["render",m],["__file","Chapter0前言.html.vue"]]);export{b as default}; diff --git "a/assets/Chapter0\345\211\215\350\250\200.html-96fa2a51.js" "b/assets/Chapter0\345\211\215\350\250\200.html-96fa2a51.js" new file mode 100644 index 000000000..1c3dc2ae6 --- /dev/null +++ "b/assets/Chapter0\345\211\215\350\250\200.html-96fa2a51.js" @@ -0,0 +1 @@ +const t=JSON.parse(`{"key":"v-0c52d085","path":"/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/Chapter0%E5%89%8D%E8%A8%80.html","title":"Chapter0 前言","lang":"zh-CN","frontmatter":{"title":"Chapter0 前言","icon":"page","order":1,"author":"ChiChen","category":["笔记","编译器"],"tag":["编译器"],"sticky":false,"star":false,"footer":null,"isOriginal":true,"copyright":"转载请注明出处","description":"开端 本笔记是本人研究编译器开发rcc的思考笔记,涵盖了在开发过程中的思考和记录,希望有助于其它学生/开发者 语言计划 希望结合 go 语言的指针+gc的特性和 rust 的错误处理、枚举类型等语法特性,实现一个类似于用 gc+指针 替换掉所有权机制的 rust 语言(r门),面向非系统场景下的编程。当然这是一个非常初步的目标(写于项目开始2023/11/03),可能将来会有所改变,但这是初步的目标,以此为勉励吧","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/Chapter0%E5%89%8D%E8%A8%80.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"Chapter0 前言"}],["meta",{"property":"og:description","content":"开端 本笔记是本人研究编译器开发rcc的思考笔记,涵盖了在开发过程中的思考和记录,希望有助于其它学生/开发者 语言计划 希望结合 go 语言的指针+gc的特性和 rust 的错误处理、枚举类型等语法特性,实现一个类似于用 gc+指针 替换掉所有权机制的 rust 语言(r门),面向非系统场景下的编程。当然这是一个非常初步的目标(写于项目开始2023/11/03),可能将来会有所改变,但这是初步的目标,以此为勉励吧"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-11-03T15:26:51.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"编译器"}],["meta",{"property":"article:modified_time","content":"2023-11-03T15:26:51.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"Chapter0 前言\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2023-11-03T15:26:51.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[{"level":2,"title":"开端","slug":"开端","link":"#开端","children":[]},{"level":2,"title":"语言计划","slug":"语言计划","link":"#语言计划","children":[]}],"git":{"createdTime":1699025211000,"updatedTime":1699025211000,"contributors":[{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":0.74,"words":221},"filePathRelative":"posts/rcc编译器/Chapter0前言.md","localizedDate":"2023年11月3日","excerpt":"

开端

\\n

本笔记是本人研究编译器开发rcc的思考笔记,涵盖了在开发过程中的思考和记录,希望有助于其它学生/开发者

\\n

语言计划

\\n

希望结合 go 语言的指针+gc的特性和 rust 的错误处理、枚举类型等语法特性,实现一个类似于用 gc+指针 替换掉所有权机制的 rust 语言(r门),面向非系统场景下的编程。当然这是一个非常初步的目标(写于项目开始2023/11/03),可能将来会有所改变,但这是初步的目标,以此为勉励吧

","autoDesc":true}`);export{t as data}; diff --git a/assets/Chapter1 Introduction.html-96927c54.js b/assets/Chapter1 Introduction.html-77562d6d.js similarity index 99% rename from assets/Chapter1 Introduction.html-96927c54.js rename to assets/Chapter1 Introduction.html-77562d6d.js index b83ca1ae8..924b856ae 100644 --- a/assets/Chapter1 Introduction.html-96927c54.js +++ b/assets/Chapter1 Introduction.html-77562d6d.js @@ -1,4 +1,4 @@ -import{_ as a}from"./plugin-vue_export-helper-c27b6911.js";import{o as i,c as n,e as l}from"./app-c4602178.js";const e="/assets/20231030152526-cc0617c8.png",s="/assets/20231030170439-b3bc8541.png",t="/assets/20231030170724-0659fe22.png",r="/assets/20231030172452-89463292.png",c="/assets/20231030172520-34a2e0a0.png",d={},u=l(`

Database Management System (DBMS)

文件系统存储数据的缺点

抽象层级

物理层(Physical level)

逻辑层(Logical level)

  type instructor = record{
+import{_ as a}from"./plugin-vue_export-helper-c27b6911.js";import{o as i,c as n,e as l}from"./app-f2ef9b44.js";const e="/assets/20231030152526-cc0617c8.png",s="/assets/20231030170439-b3bc8541.png",t="/assets/20231030170724-0659fe22.png",r="/assets/20231030172452-89463292.png",c="/assets/20231030172520-34a2e0a0.png",d={},u=l(`

Database Management System (DBMS)

  • DBMS 包括:
    1. 相关数据的集合
    2. 访问数据的程序集
    3. 一个既方便又高效的使用环境

文件系统存储数据的缺点

  • 数据冗余和不一致:多种文件格式,不同文件中的信息重复

  • 访问数据困难:需要编写新程序来执行每项新任务

  • 数据隔离——多个文件和格式

  • 完整性问题 :

    • 完整性约束(例如,帐户余额 > 0)被“隐藏”在程序代码中,而不是明确声明
    • 很难添加新的约束或更改现有的约束
  • 更新的原子性

    • 故障可能会使数据库处于与执行的部分更新不一致的状态
    • 示例:资金从一个账户转移到另一个账户要么完成,要么根本不发生
  • 多用户并发访问

    • 并发访问以提高性能
    • 不受控制的并发访问可能会导致不一致
    • 示例:两个人同时读取余额(例如 100)并通过提款(例如每人 50)来更新余额
  • 安全问题 难以向用户提供对部分(但不是全部)数据的访问权限

抽象层级

物理层(Physical level)

  • 描述一条记录(record)是如何被存储的

逻辑层(Logical level)

  • 描述数据库中存储的记录和数据之间的关系
  type instructor = record{
      ID : string;  
      name : string;  
      dept_name : string;  
diff --git "a/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-06252c86.js" "b/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c1a28162.js"
similarity index 99%
rename from "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-06252c86.js"
rename to "assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c1a28162.js"
index 8eedacb94..f3458fb86 100644
--- "a/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-06252c86.js"	
+++ "b/assets/Chapter1 \347\274\226\350\257\221\345\231\250\347\273\204\346\210\220.html-c1a28162.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-c4602178.js";const e={},r=l('

Chapter1 编译器组成

编译器的结构

  • 词法分析Lexical analysis (Scanning)
  • 语法分析Syntax analysis (Parsing)
  • 语义分析 Semantic analysis

相关信息

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

  • 中间代码生成 IR Generation
  • 中间代码优化 IR Optimization
  • 最终代码生成 Generation
  • 最终代码优化 Optimization
',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('

语法分析

  • 就是将一个token序列表示为一棵语法树

语义分析

  • 就是将语法分析得到的语法树转化为一个带注解(annotated)的语法树

中间代码生成

  • 从语法树生成通用的中间代码
',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-f2ef9b44.js";const e={},r=l('

Chapter1 编译器组成

编译器的结构

  • 词法分析Lexical analysis (Scanning)
  • 语法分析Syntax analysis (Parsing)
  • 语义分析 Semantic analysis

相关信息

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

  • 中间代码生成 IR Generation
  • 中间代码优化 IR Optimization
  • 最终代码生成 Generation
  • 最终代码优化 Optimization
',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('

语法分析

  • 就是将一个token序列表示为一棵语法树

语义分析

  • 就是将语法分析得到的语法树转化为一个带注解(annotated)的语法树

中间代码生成

  • 从语法树生成通用的中间代码
',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/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-3ca5aab5.js" "b/assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-3ca5aab5.js" new file mode 100644 index 000000000..3ef6bc843 --- /dev/null +++ "b/assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-3ca5aab5.js" @@ -0,0 +1 @@ +import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{o as _,c as t}from"./app-f2ef9b44.js";const o={};function r(c,a){return _(),t("div")}const s=e(o,[["render",r],["__file","Chapter1词法分析器之Nom.html.vue"]]);export{s as default}; diff --git "a/assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-59f03779.js" "b/assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-59f03779.js" new file mode 100644 index 000000000..eea205fb7 --- /dev/null +++ "b/assets/Chapter1\350\257\215\346\263\225\345\210\206\346\236\220\345\231\250\344\271\213Nom.html-59f03779.js" @@ -0,0 +1 @@ +const t=JSON.parse(`{"key":"v-5f817ed8","path":"/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/Chapter1%E8%AF%8D%E6%B3%95%E5%88%86%E6%9E%90%E5%99%A8%E4%B9%8BNom.html","title":"Chapter1 词法分析器之Nom","lang":"zh-CN","frontmatter":{"title":"Chapter1 词法分析器之Nom","icon":"page","order":1,"author":"ChiChen","category":["笔记","编译器"],"tag":["编译器","词法分析"],"sticky":false,"star":false,"footer":null,"isOriginal":true,"copyright":"转载请注明出处","description":"","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/Chapter1%E8%AF%8D%E6%B3%95%E5%88%86%E6%9E%90%E5%99%A8%E4%B9%8BNom.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"Chapter1 词法分析器之Nom"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-11-03T15:26:51.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"编译器"}],["meta",{"property":"article:tag","content":"词法分析"}],["meta",{"property":"article:modified_time","content":"2023-11-03T15:26:51.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"Chapter1 词法分析器之Nom\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2023-11-03T15:26:51.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[],"git":{"createdTime":1699025211000,"updatedTime":1699025211000,"contributors":[{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":0.22,"words":66},"filePathRelative":"posts/rcc编译器/Chapter1词法分析器之Nom.md","localizedDate":"2023年11月3日","excerpt":"","autoDesc":true}`);export{t as data}; diff --git "a/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-697f1885.js" "b/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-8db905f1.js" similarity index 99% rename from "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-697f1885.js" rename to "assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-8db905f1.js" index b4d8b7d2e..cca04240c 100644 --- "a/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-697f1885.js" +++ "b/assets/Chapter2 \350\257\215\346\263\225\345\210\206\346\236\220.html-8db905f1.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-c4602178.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) 
+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-f2ef9b44.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-6240be15.js" "b/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-9f47c9de.js"
similarity index 99%
rename from "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6240be15.js"
rename to "assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-9f47c9de.js"
index 686ff2c09..025579460 100644
--- "a/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-6240be15.js"	
+++ "b/assets/Chapter3 \350\257\255\346\263\225\345\210\206\346\236\220.html-9f47c9de.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-c4602178.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-f2ef9b44.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-cf12c29b.js" "b/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-971deb22.js"
similarity index 99%
rename from "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-cf12c29b.js"
rename to "assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-971deb22.js"
index 527a230d2..f01d9de0a 100644
--- "a/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-cf12c29b.js"	
+++ "b/assets/Chapter4 \350\257\255\344\271\211\345\210\206\346\236\220.html-971deb22.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-c4602178.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-f2ef9b44.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-ca59a43d.js" "b/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-844a1f3b.js"
similarity index 99%
rename from "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-ca59a43d.js"
rename to "assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-844a1f3b.js"
index 30012c774..8f6ec8e1a 100644
--- "a/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-ca59a43d.js"	
+++ "b/assets/Chapter5 \344\273\243\347\240\201\347\224\237\346\210\220.html-844a1f3b.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-c4602178.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-f2ef9b44.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/HelloWorld.html-7f084ba3.js b/assets/HelloWorld.html-7f084ba3.js deleted file mode 100644 index 5b3375259..000000000 --- a/assets/HelloWorld.html-7f084ba3.js +++ /dev/null @@ -1 +0,0 @@ -const e=JSON.parse(`{"key":"v-6de84607","path":"/posts/rcc/HelloWorld.html","title":"template","lang":"zh-CN","frontmatter":{"title":"template","icon":"page","order":1,"author":"ChiChen","category":["笔记","编译器"],"tag":["编译器"],"sticky":false,"star":false,"footer":null,"isOriginal":true,"copyright":"转载请注明出处","description":"sudo apt-get -y install clang curl llvm-14.0.0-dev","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/rcc/HelloWorld.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"template"}],["meta",{"property":"og:description","content":"sudo apt-get -y install clang curl llvm-14.0.0-dev"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-11-01T12:52:37.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"编译器"}],["meta",{"property":"article:modified_time","content":"2023-11-01T12:52:37.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"template\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2023-11-01T12:52:37.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[],"git":{"createdTime":1698843157000,"updatedTime":1698843157000,"contributors":[{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":1.05,"words":316},"filePathRelative":"posts/rcc/HelloWorld.md","localizedDate":"2023年11月1日","excerpt":"
sudo apt-get -y install clang curl llvm-14.0.0-dev\\n
","autoDesc":true}`);export{e as data}; diff --git a/assets/HelloWorld.html-b68c6228.js b/assets/HelloWorld.html-b68c6228.js new file mode 100644 index 000000000..e4e15fba9 --- /dev/null +++ b/assets/HelloWorld.html-b68c6228.js @@ -0,0 +1 @@ +const e=JSON.parse(`{"key":"v-0f8c08c1","path":"/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/HelloWorld.html","title":"template","lang":"zh-CN","frontmatter":{"title":"template","icon":"page","order":1,"author":"ChiChen","category":["笔记","编译器"],"tag":["编译器"],"sticky":false,"star":false,"footer":null,"isOriginal":true,"copyright":"转载请注明出处","description":"sudo apt-get -y install clang curl llvm-14.0.0-dev","head":[["meta",{"property":"og:url","content":"https://chiichen.github.io/posts/rcc%E7%BC%96%E8%AF%91%E5%99%A8/HelloWorld.html"}],["meta",{"property":"og:site_name","content":"ChiChen's Blog"}],["meta",{"property":"og:title","content":"template"}],["meta",{"property":"og:description","content":"sudo apt-get -y install clang curl llvm-14.0.0-dev"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2023-11-03T15:26:51.000Z"}],["meta",{"property":"article:author","content":"ChiChen"}],["meta",{"property":"article:tag","content":"编译器"}],["meta",{"property":"article:modified_time","content":"2023-11-03T15:26:51.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"template\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2023-11-03T15:26:51.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"ChiChen\\"}]}"]]},"headers":[],"git":{"createdTime":1699025211000,"updatedTime":1699025211000,"contributors":[{"name":"ChiChen","email":"chiichen@qq.com","commits":1}]},"readingTime":{"minutes":1.05,"words":316},"filePathRelative":"posts/rcc编译器/HelloWorld.md","localizedDate":"2023年11月3日","excerpt":"
sudo apt-get -y install clang curl llvm-14.0.0-dev\\n
","autoDesc":true}`);export{e as data}; diff --git a/assets/HelloWorld.html-f63cf3f6.js b/assets/HelloWorld.html-cd96bdbf.js similarity index 99% rename from assets/HelloWorld.html-f63cf3f6.js rename to assets/HelloWorld.html-cd96bdbf.js index 0b2f398e5..e7656afc8 100644 --- a/assets/HelloWorld.html-f63cf3f6.js +++ b/assets/HelloWorld.html-cd96bdbf.js @@ -1,4 +1,4 @@ -import{_ as n}from"./plugin-vue_export-helper-c27b6911.js";import{o as s,c as a,e as t}from"./app-c4602178.js";const e={},p=t(`
sudo apt-get -y install clang curl llvm-14.0.0-dev
+import{_ as n}from"./plugin-vue_export-helper-c27b6911.js";import{o as s,c as a,e as t}from"./app-f2ef9b44.js";const e={},p=t(`
sudo apt-get -y install clang curl llvm-14.0.0-dev
 
sudo ln -s /usr/bin/llvm-config-14.0.0 /usr/bin/llvm-config
 #如果llvm-config已存在,先删除一下再创建软链接
 sudo rm -f /usr/bin/llvm-config
diff --git "a/assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-f57b16d9.js" "b/assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-80c506d1.js"
similarity index 98%
rename from "assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-f57b16d9.js"
rename to "assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-80c506d1.js"
index 328c6d525..1c3eb6742 100644
--- "a/assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-f57b16d9.js"
+++ "b/assets/LWN\351\222\210\345\257\271\345\244\232\345\261\202\345\206\205\345\255\230\347\263\273\347\273\237\351\207\215\346\226\260\350\277\233\350\241\214NUMA\345\271\263\350\241\241.html-80c506d1.js"
@@ -1,2 +1,2 @@
-import{_ as i}from"./plugin-vue_export-helper-c27b6911.js";import{r as n,o,c as p,a as e,b as a,d as r,e as s}from"./app-c4602178.js";const c={},d=e("h2",{id:"参考",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#参考","aria-hidden":"true"},"#"),a(" 参考")],-1),m={href:"https://mp.weixin.qq.com/s?__biz=Mzg2MjE0NDE5OA==&mid=2247486608&idx=1&sn=51eb34edabfbcc6f730dd9c0efb1c0c6&chksm=ce0d1f39f97a962f20b3501bdbc6684ba043b88f924ba8db52aa77710b91899d7a2e069c0d95&scene=126&&sessionid=0",target:"_blank",rel:"noopener noreferrer"},g=e("h2",{id:"numa-rebalancing-on-tiered-memory-systems",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#numa-rebalancing-on-tiered-memory-systems","aria-hidden":"true"},"#"),a(" NUMA rebalancing on tiered-memory systems")],-1),h={class:"hint-container info"},l=e("p",{class:"hint-container-title"},"相关信息",-1),_={href:"https://lwn.net/Articles/893024/",target:"_blank",rel:"noopener noreferrer"},u=s(`

传统的 NUMA 架构是围绕 node (节点)建立的,每个节点都包含一组 CPU 和一些本地内存,所有的节点或多或少都是平等的。但最近,"tiered-memory (分层内存)" 的 NUMA 系统开始出现,其中包括无 CPU 的节点,也就是只包含持久性内存(persistent memory),而不是(更快但更昂贵的)DRAM。这种内存的一个可能用途就是保存不经常使用的 page,而不是强行把这些 page 换出到后备存储设备上。不过,在这个使用案例中出现了一个有趣的问题:内核如何管理 page 在较快和较慢内存之间的移动?最近的几个 patch set 对这些系统上的内存再平衡问题采取了不同的方法。

Migration and reclaim

内核使用一种叫做 "NUMA hint-faulting" 的技术来检测确定某一个 page 是否需要被迁移。某个 task 的地址空间范围会被周期性地取消映射(unmap),这样今后对该范围内的 page 的访问就会触发一个 page fault。当 page fault 发生时,内存管理子系统就可以使用触发 page fault 的 CPU 的位置来确定该 page 是否需要被迁移到包含该 CPU 的节点去。完全没有 fault 的话就说明该 page 正在受到冷遇,并可能在 reclaim 的时候被迁移到一个慢层(slow-tier)节点。随着工作负载的运行和访问模式的改变,page 在常用与不常用(hot and cold)之间经常转换,也就会相应地在快速和慢速 NUMA 节点之间迁移了。

内存回收(memory reclaim)是由一个 "watermark" 系统驱动的,该系统试图至少保持最低数量的 free page 可供使用。当请求分配内存时,内核会将正在进行分配的节点中的可用 page 数量与 zone watermark threshold 进行比较。如果分配后节点中的空闲页数低于 watermark 所说的阈值,那么 kswapd 内核线程就会被唤醒来异步地扫描并从节点中回收内存 page。这就可以在节点的内存压力导致分配被阻塞从而发生 direct reclaim 之前就预先释放内存。

内核中的 zone watermark 是根据 host 的内存情况来静态地决定 size 的。内存较少的系统中 zone watermark 会比较低,而内存较大的系统的 watermark 会较高。从直觉来说,这种差异化是有必要的。如果你有一台拥有大量内存的机器,那么比起拥有很少内存的机器来说,reclaim 会更早触发,因为预期在拥有更多内存的系统上应用程序会更积极地申请内存。然而,使用静态的阈值也有缺点。在 tiered-memory 系统之中,如果一个节点的阈值太低,快速节点可能不会积极地 reclaim 回收内存,也就没有空间可以把慢速节点上的 hot page 提级迁移过来。

Optimizing reclaim and demotion

Huang Ying 最近的一个 patch 就是针对性地解决这个问题的。这项工作的基础前提是,在具有多种内存类型的系统上,工作负载的 working-set (工作集,也就是各个工作者的集合)size 经常会超过系统中快速 DRAM 的总量。这是有道理的。如果一个系统没有 overcommit (也就是承诺了比真实内存容量还多的 DRAM),那么就完全没有必要使用其他类型的内存了。

这一点就说明,在 tiered-memory 系统中,当应用程序访问时,内存 page 会在快慢内存节点之间不断迁移。如果快速节点接近容量上限了,内核就无法在 rebalancing 过程中把全局性的 hot page 提级到这些快速节点上了;由于 hot page 一直驻留在慢速节点上,导致访问延迟变高了,这是不太合适的。因此,这里的诀窍在于需要确保能够从快速节点回收到足够的 page,这样除了为未来的分配腾出空间外,快速节点也有足够的空间来把慢速节点的 hot page 迁移过来。

Ying 的 patch set 通过引入一个新的 WMARK_PROMO watermark 来解决这个需求,这个 watermark 比(以前最高的)WMARK_HIGH 限值还要高。当一个 page 由于内存压力原因而无法被迁移到更快的节点时,kswapd 会被唤醒来回收内存,确保达到这个新加入的 WMARK_PROMO 阈值。这种稍显激进的回收策略能更好地确保有足够的空间将 hot page 从慢速内存节点提级迁移到快速内存节点,从而更好地适应 tiered memory 系统中常见的 working set。

The controversy of statically sized watermarks

虽然添加 WMARK_PROMO watermark 提高了快速节点上有足够空间把较慢节点上的 hot page 迁移过来的机会,但人们不得不怀疑是否应该重新审视静态 watermark 这个概念。如果所选择的 watermark 阈值足够高,能确保 page 可以被提级迁移到快速节点,那么一个高于必要值的阈值也会使一些 DRAM 未被使用,从而让应用程序的性能受到负面影响。这里需要一个新的 watermark 的事实就表明了问题的性质,也就是很大程度上需要取决于系统本身的特点,以及它所运行的工作负载。

在对该补丁的 review 中讨论了使用静态 watermark 的弊端。例如,在 Ying 的补丁的早期版本中,硬性规定了 reclaim 时所需的额外 page 数量应该是比 WMARK_HIGH 大 10MB,Zi Yan 质疑这样的数值是否合理:

为什么是 10MB?10MB 大到足以避免对快速内存造成内存压力吗?这个数字似乎像是个临时方案,可能只在你的测试机器上有效果。
+import{_ as i}from"./plugin-vue_export-helper-c27b6911.js";import{r as n,o,c as p,a as e,b as a,d as r,e as s}from"./app-f2ef9b44.js";const c={},d=e("h2",{id:"参考",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#参考","aria-hidden":"true"},"#"),a(" 参考")],-1),m={href:"https://mp.weixin.qq.com/s?__biz=Mzg2MjE0NDE5OA==&mid=2247486608&idx=1&sn=51eb34edabfbcc6f730dd9c0efb1c0c6&chksm=ce0d1f39f97a962f20b3501bdbc6684ba043b88f924ba8db52aa77710b91899d7a2e069c0d95&scene=126&&sessionid=0",target:"_blank",rel:"noopener noreferrer"},g=e("h2",{id:"numa-rebalancing-on-tiered-memory-systems",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#numa-rebalancing-on-tiered-memory-systems","aria-hidden":"true"},"#"),a(" NUMA rebalancing on tiered-memory systems")],-1),h={class:"hint-container info"},l=e("p",{class:"hint-container-title"},"相关信息",-1),_={href:"https://lwn.net/Articles/893024/",target:"_blank",rel:"noopener noreferrer"},u=s(`

传统的 NUMA 架构是围绕 node (节点)建立的,每个节点都包含一组 CPU 和一些本地内存,所有的节点或多或少都是平等的。但最近,"tiered-memory (分层内存)" 的 NUMA 系统开始出现,其中包括无 CPU 的节点,也就是只包含持久性内存(persistent memory),而不是(更快但更昂贵的)DRAM。这种内存的一个可能用途就是保存不经常使用的 page,而不是强行把这些 page 换出到后备存储设备上。不过,在这个使用案例中出现了一个有趣的问题:内核如何管理 page 在较快和较慢内存之间的移动?最近的几个 patch set 对这些系统上的内存再平衡问题采取了不同的方法。

Migration and reclaim

内核使用一种叫做 "NUMA hint-faulting" 的技术来检测确定某一个 page 是否需要被迁移。某个 task 的地址空间范围会被周期性地取消映射(unmap),这样今后对该范围内的 page 的访问就会触发一个 page fault。当 page fault 发生时,内存管理子系统就可以使用触发 page fault 的 CPU 的位置来确定该 page 是否需要被迁移到包含该 CPU 的节点去。完全没有 fault 的话就说明该 page 正在受到冷遇,并可能在 reclaim 的时候被迁移到一个慢层(slow-tier)节点。随着工作负载的运行和访问模式的改变,page 在常用与不常用(hot and cold)之间经常转换,也就会相应地在快速和慢速 NUMA 节点之间迁移了。

内存回收(memory reclaim)是由一个 "watermark" 系统驱动的,该系统试图至少保持最低数量的 free page 可供使用。当请求分配内存时,内核会将正在进行分配的节点中的可用 page 数量与 zone watermark threshold 进行比较。如果分配后节点中的空闲页数低于 watermark 所说的阈值,那么 kswapd 内核线程就会被唤醒来异步地扫描并从节点中回收内存 page。这就可以在节点的内存压力导致分配被阻塞从而发生 direct reclaim 之前就预先释放内存。

内核中的 zone watermark 是根据 host 的内存情况来静态地决定 size 的。内存较少的系统中 zone watermark 会比较低,而内存较大的系统的 watermark 会较高。从直觉来说,这种差异化是有必要的。如果你有一台拥有大量内存的机器,那么比起拥有很少内存的机器来说,reclaim 会更早触发,因为预期在拥有更多内存的系统上应用程序会更积极地申请内存。然而,使用静态的阈值也有缺点。在 tiered-memory 系统之中,如果一个节点的阈值太低,快速节点可能不会积极地 reclaim 回收内存,也就没有空间可以把慢速节点上的 hot page 提级迁移过来。

Optimizing reclaim and demotion

Huang Ying 最近的一个 patch 就是针对性地解决这个问题的。这项工作的基础前提是,在具有多种内存类型的系统上,工作负载的 working-set (工作集,也就是各个工作者的集合)size 经常会超过系统中快速 DRAM 的总量。这是有道理的。如果一个系统没有 overcommit (也就是承诺了比真实内存容量还多的 DRAM),那么就完全没有必要使用其他类型的内存了。

这一点就说明,在 tiered-memory 系统中,当应用程序访问时,内存 page 会在快慢内存节点之间不断迁移。如果快速节点接近容量上限了,内核就无法在 rebalancing 过程中把全局性的 hot page 提级到这些快速节点上了;由于 hot page 一直驻留在慢速节点上,导致访问延迟变高了,这是不太合适的。因此,这里的诀窍在于需要确保能够从快速节点回收到足够的 page,这样除了为未来的分配腾出空间外,快速节点也有足够的空间来把慢速节点的 hot page 迁移过来。

Ying 的 patch set 通过引入一个新的 WMARK_PROMO watermark 来解决这个需求,这个 watermark 比(以前最高的)WMARK_HIGH 限值还要高。当一个 page 由于内存压力原因而无法被迁移到更快的节点时,kswapd 会被唤醒来回收内存,确保达到这个新加入的 WMARK_PROMO 阈值。这种稍显激进的回收策略能更好地确保有足够的空间将 hot page 从慢速内存节点提级迁移到快速内存节点,从而更好地适应 tiered memory 系统中常见的 working set。

The controversy of statically sized watermarks

虽然添加 WMARK_PROMO watermark 提高了快速节点上有足够空间把较慢节点上的 hot page 迁移过来的机会,但人们不得不怀疑是否应该重新审视静态 watermark 这个概念。如果所选择的 watermark 阈值足够高,能确保 page 可以被提级迁移到快速节点,那么一个高于必要值的阈值也会使一些 DRAM 未被使用,从而让应用程序的性能受到负面影响。这里需要一个新的 watermark 的事实就表明了问题的性质,也就是很大程度上需要取决于系统本身的特点,以及它所运行的工作负载。

在对该补丁的 review 中讨论了使用静态 watermark 的弊端。例如,在 Ying 的补丁的早期版本中,硬性规定了 reclaim 时所需的额外 page 数量应该是比 WMARK_HIGH 大 10MB,Zi Yan 质疑这样的数值是否合理:

为什么是 10MB?10MB 大到足以避免对快速内存造成内存压力吗?这个数字似乎像是个临时方案,可能只在你的测试机器上有效果。
 

Ying 承认,10MB 的数值很难证实是合理的,而且在目前的实现之外还有改进的余地。根据 Johannes Weiner 的建议,这个阈值后来被改为单独的 WMARK_PROMO 水位线,他还指出,有另一个选择是让提级迁移的动作来动态地按需提高 kswapd watermark。这就能避免 DRAM 未被充分利用的问题,当然这也是以增加复杂性为代价的。

渐进式的修改当然没有错,尽量坚持使用最简单的方法(在必须要实现复杂方案之前)也没有错。然而,我们关心的是,内核最终是否需要一个更加动态和灵活的框架来进行 page reclaim 以及 page migration 决策。

Avoiding page ping-pong

除了要求快速节点有足够的空间用于把其他 page 提级迁移过来之外,还有一个问题是分层内存系统所特有的。在传统的 NUMA 设置中,应用程序 working set 的大小通常是适合于运行在一个或多个节点上的。一旦应用程序达到稳定状态,并且大多数(或者所有的)page 都正确地位于它们本地访问的节点上,那么迁移就会逐渐减少。不过,tiered memory 系统上的应用并不是这样的,因为它们的 working set 可能无法完全在它们所运行的 NUMA 节点放得下。当应用程序访问这些 page 时,它们并没有达到一个稳定的状态,而是不断地在慢速和快速的 NUMA 节点之间来回切换。

这也是一个相关问题,但与 Ying 的 patch set 所解决的问题不同。新的 watermark 可以确保快速节点上有足够的空间让 hot page 从慢速节点上迁移过来,但并没有阻止 page 在慢速节点和快速节点之间不断地、过于积极地进行迁移。如果执行迁移的开销超过了把 page 放在在本地 DRAM 节点上的访问延迟变小而获得的性能优势,那么 page 迁移的速度显然就需要调整了。对于如何解决这个问题,已经有很多建议。

Ying 提出的一个建议是记录慢速内存中的一个 page 被 unmap 来产生 NUMA hint fault 和在内存访问中实际观察到该 fault 之间的时间差。该 page 被 unmap 之后的时间越短,那么这个 page 就越有可能是 hot 状态。该时间可以跟一些阈值(可由系统管理员调整)进行比较,只有当时间差在该阈值内时,该 page 才会被提升。

虽然访问以来的时间感觉是量化页面热度的一种自然方式,但这种方法也相当复杂,需要添加大量的新代码。定义一个页面被认为是 "热 "的阈值应该是什么,这个问题也不清楚;可能需要由系统管理员进行调整。一个后续的补丁提出了一种根据迁移量动态调整阈值的方法,但它也相当复杂。

Hasan Al Maruf 在一个 patch 中提出了另一个方法。当一个 page 被降级时,会从 active LRU list 中移除掉,并放到 inactive LRU list 中。Al Maruf 的 patch 更新了 NUMA hint fault 处理程序(handler),来检查某个 page 是否处于这种 inactive 状态,如果是,则将其移至 active 状态,并推迟到后续 fault 发生时再进行提级迁移。如果该 page 再次被访问到,那么看起来它就是在 active LRU 上,然后就会发生提级迁移。这个解决方案的优点是,它使用了内核中现有的机制来跟踪 page 的 hot 程度。随着内存压力的增加以及有更多的 page 被回收,会有更多的 page 被移到 inactive LRU list 中,从而导致 page 提级迁移会按比例被抑制。

目前还没有就选择哪种解决方案达成共识,不过 Al Maruf 的 patch set 很可能会被接受,因为它很简单,而且使用了现有的机制来跟踪 page 的 hot 程度。虽然预计该解决方案不会引起争议,但最近会有 Linux Storage, Filesystems, and Memory-Management Summit 就要召开了,开发人员可以在那里来面对面地讨论每种方法的优点了。

`,22);function f(M,k){const t=n("ExternalLinkIcon");return o(),p("div",null,[d,e("p",null,[a("转载自 "),e("a",m,[a("LWN:针对多层内存系统重新进行NUMA平衡!"),r(t)]),a(",作者为公众号:Linux News搬运工,原文创作时间为 2022-05-17")]),g,e("div",h,[l,e("p",null,[a("May 2, 2022 This article was contributed by David Vernet DeepL assisted translation "),e("a",_,[a("https://lwn.net/Articles/893024/"),r(t)])])]),u])}const b=i(c,[["render",f],["__file","LWN针对多层内存系统重新进行NUMA平衡.html.vue"]]);export{b as default}; diff --git "a/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-423bb93d.js" "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-2bd5abd0.js" similarity index 99% rename from "assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-423bb93d.js" rename to "assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-2bd5abd0.js" index 50420a528..a073f4c7f 100644 --- "a/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-423bb93d.js" +++ "b/assets/NUMA Balance\345\256\236\347\216\260\346\265\205\346\236\220.html-2bd5abd0.js" @@ -1,4 +1,4 @@ -import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{r as o,o as c,c as l,a as n,b as s,d as p,e as t}from"./app-c4602178.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=t(`

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
+import{_ as e}from"./plugin-vue_export-helper-c27b6911.js";import{r as o,o as c,c as l,a as n,b as s,d as p,e as t}from"./app-f2ef9b44.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=t(`

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
diff --git a/assets/NUMA Balancing.html-6466c843.js b/assets/NUMA Balancing.html-4fc47f58.js
similarity index 96%
rename from assets/NUMA Balancing.html-6466c843.js
rename to assets/NUMA Balancing.html-4fc47f58.js
index 9062f0f91..9e8167455 100644
--- a/assets/NUMA Balancing.html-6466c843.js	
+++ b/assets/NUMA Balancing.html-4fc47f58.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-c4602178.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-f2ef9b44.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/VuePlayground-48f7a9a5.js b/assets/VuePlayground-00742e25.js similarity index 82% rename from assets/VuePlayground-48f7a9a5.js rename to assets/VuePlayground-00742e25.js index 8b8779186..6bf7a2162 100644 --- a/assets/VuePlayground-48f7a9a5.js +++ b/assets/VuePlayground-00742e25.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-c4602178.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-98286ccf.js"),["assets/vue-repl-98286ccf.js","assets/app-c4602178.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-f2ef9b44.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-70f53f6e.js"),["assets/vue-repl-70f53f6e.js","assets/app-f2ef9b44.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-c4602178.js b/assets/app-c4602178.js deleted file mode 100644 index 6e7bfcf40..000000000 --- a/assets/app-c4602178.js +++ /dev/null @@ -1,166 +0,0 @@ -const w2="modulepreload",x2=function(e){return"/"+e},ka={},A=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 ka)return;ka[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 Ao(e,t){const n=Object.create(null),l=e.split(",");for(let r=0;r!!n[r.toLowerCase()]:r=>!!n[r]}const Ce={},An=[],vt=()=>{},A2=()=>!1,C2=/^on[^a-z]/,yl=e=>C2.test(e),Co=e=>e.startsWith("onUpdate:"),Te=Object.assign,Lo=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},L2=Object.prototype.hasOwnProperty,fe=(e,t)=>L2.call(e,t),Z=Array.isArray,Cn=e=>ur(e)==="[object Map]",ni=e=>ur(e)==="[object Set]",te=e=>typeof e=="function",pe=e=>typeof e=="string",ko=e=>typeof e=="symbol",Ae=e=>e!==null&&typeof e=="object",li=e=>Ae(e)&&te(e.then)&&te(e.catch),ri=Object.prototype.toString,ur=e=>ri.call(e),k2=e=>ur(e).slice(8,-1),oi=e=>ur(e)==="[object Object]",To=e=>pe(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,el=Ao(",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))},T2=/-(\w)/g,st=dr(e=>e.replace(T2,(t,n)=>n?n.toUpperCase():"")),B2=/\B([A-Z])/g,pn=dr(e=>e.replace(B2,"-$1").toLowerCase()),bl=dr(e=>e.charAt(0).toUpperCase()+e.slice(1)),Tr=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 Ta;const Jr=()=>Ta||(Ta=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Bo(e){if(Z(e)){const t={};for(let n=0;n{if(n){const l=n.split(O2);l.length>1&&(t[l[0].trim()]=l[1].trim())}}),t}function Po(e){let t="";if(pe(e))t=e;else if(Z(e))for(let n=0;npe(e)?e:e==null?"":Z(e)||Ae(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):Cn(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[l,r])=>(n[`${l} =>`]=r,n),{})}:ni(t)?{[`Set(${t.size})`]:[...t.values()]}:Ae(t)&&!Z(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&qt)>0,ui=e=>(e.n&qt)>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":Z(e)?To(n)&&i.push(a.get("length")):(i.push(a.get(an)),Cn(e)&&i.push(a.get(Zr)));break;case"delete":Z(e)||(i.push(a.get(an)),Cn(e)&&i.push(a.get(Zr)));break;case"set":Cn(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(So(c))}}function Xr(e,t){const n=Z(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=Ao("__proto__,__v_isRef,__isVue"),pi=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(ko)),U2=Mo(),q2=Mo(!1,!0),W2=Mo(!0),Sa=G2();function G2(){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 Ge(t,"has",e),t.hasOwnProperty(e)}function Mo(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=Z(l);if(!e){if(a&&fe(Sa,r))return Reflect.get(Sa,r,o);if(r==="hasOwnProperty")return K2}const i=Reflect.get(l,r,o);return(ko(r)?pi.has(r):j2(r))||(e||Ge(l,"get",r),t)?i:$e(i)?a&&To(r)?i:i.value:Ae(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(Mn(a)&&$e(a)&&!$e(r))return!1;if(!e&&(!Xl(r)&&!Mn(r)&&(a=ie(a),r=ie(r)),!Z(n)&&$e(a)&&!$e(r)))return a.value=r,!0;const i=Z(n)&&To(l)?Number(l)e,fr=e=>Reflect.getPrototypeOf(e);function Dl(e,t,n=!1,l=!1){e=e.__v_raw;const r=ie(e),o=ie(t);n||(t!==o&&Ge(r,"get",t),Ge(r,"get",o));const{has:a}=fr(r),i=l?Io: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 $l(e,t=!1){const n=this.__v_raw,l=ie(n),r=ie(e);return t||(e!==r&&Ge(l,"has",e),Ge(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&&Ge(ie(e),"iterate",an),Reflect.get(e,"size",e)}function Oa(e){e=ie(e);const t=ie(this);return fr(t).has.call(t,e)||(t.add(e),Mt(t,"add",e,e)),this}function Ma(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)&&Mt(n,"set",e,t):Mt(n,"add",e,t),this}function Ia(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&&Mt(t,"delete",e,void 0),o}function Da(){const e=ie(this),t=e.size!==0,n=e.clear();return t&&Mt(e,"clear",void 0,void 0),n}function Fl(e,t){return function(l,r){const o=this,a=o.__v_raw,i=ie(a),c=t?Io:e?Ro:cl;return!e&&Ge(i,"iterate",an),a.forEach((u,d)=>l.call(r,c(u),c(d),o))}}function zl(e,t,n){return function(...l){const r=this.__v_raw,o=ie(r),a=Cn(o),i=e==="entries"||e===Symbol.iterator&&a,c=e==="keys"&&a,u=r[e](...l),d=n?Io:t?Ro:cl;return!t&&Ge(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 Dt(e){return function(...t){return e==="delete"?!1:this}}function nu(){const e={get(o){return Dl(this,o)},get size(){return Rl(this)},has:$l,add:Oa,set:Ma,delete:Ia,clear:Da,forEach:Fl(!1,!1)},t={get(o){return Dl(this,o,!1,!0)},get size(){return Rl(this)},has:$l,add:Oa,set:Ma,delete:Ia,clear:Da,forEach:Fl(!1,!0)},n={get(o){return Dl(this,o,!0)},get size(){return Rl(this,!0)},has(o){return $l.call(this,o,!0)},add:Dt("add"),set:Dt("set"),delete:Dt("delete"),clear:Dt("clear"),forEach:Fl(!0,!1)},l={get(o){return Dl(this,o,!0,!0)},get size(){return Rl(this,!0)},has(o){return $l.call(this,o,!0)},add:Dt("add"),set:Dt("set"),delete:Dt("delete"),clear:Dt("clear"),forEach:Fl(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{e[o]=zl(o,!1,!1),n[o]=zl(o,!0,!1),t[o]=zl(o,!1,!0),l[o]=zl(o,!0,!0)}),[e,n,t,l]}const[lu,ru,ou,au]=nu();function Do(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:Do(!1,!1)},iu={get:Do(!1,!0)},cu={get:Do(!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(k2(e))}function Hn(e){return Mn(e)?e:$o(e,!1,vi,su,mi)}function pu(e){return $o(e,!1,tu,iu,gi)}function hn(e){return $o(e,!0,eu,cu,yi)}function $o(e,t,n,l,r){if(!Ae(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 Ln(e){return Mn(e)?Ln(e.__v_raw):!!(e&&e.__v_isReactive)}function Mn(e){return!!(e&&e.__v_isReadonly)}function Xl(e){return!!(e&&e.__v_isShallow)}function bi(e){return Ln(e)||Mn(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=>Ae(e)?Hn(e):e,Ro=e=>Ae(e)?hn(e):e;function Fo(e){jt&&pt&&(e=ie(e),fi(e.dep||(e.dep=So())))}function zo(e,t){e=ie(e);const n=e.dep;n&&Xr(n)}function $e(e){return!!(e&&e.__v_isRef===!0)}function V(e){return _i(e,!1)}function Be(e){return _i(e,!0)}function _i(e,t){return $e(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 Fo(this),this._value}set value(t){const n=this.__v_isShallow||Xl(t)||Mn(t);t=n?t:ie(t),il(t,this._rawValue)&&(this._rawValue=t,this._value=n?t:cl(t),zo(this))}}function sn(e){return $e(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 $e(r)&&!$e(n)?(r.value=n,!0):Reflect.set(e,t,n,l)}};function wi(e){return Ln(e)?e:new Proxy(e,vu)}class mu{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:n,set:l}=t(()=>Fo(this),()=>zo(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 $e(e)?e:te(e)?new bu(e):Ae(e)&&arguments.length>1?Eu(e,t,n):V(e)}function Eu(e,t,n){const l=e[t];return $e(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 Oo(t,()=>{this._dirty||(this._dirty=!0,zo(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!r,this.__v_isReadonly=l}get value(){const t=ie(this);return Fo(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 Ut(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=Ut(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(ze[l])Ct&&ze.splice(t,1)}function Lu(e){Z(e)?kn.push(...e):(!Ot||!Ot.includes(e,e.allowRecurse?tn+1:tn))&&kn.push(e),Ai()}function $a(e,t=ul?Ct+1:0){for(;tdl(n)-dl(l)),tn=0;tne.id==null?1/0:e.id,ku=(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 Ci(e){eo=!1,ul=!0,ze.sort(ku);const t=vt;try{for(Ct=0;Ctpe(h)?h.trim():h)),f&&(r=n.map(Yr))}let i,c=l[i=Tr(t)]||l[i=Tr(st(t))];!c&&o&&(c=l[i=Tr(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 Li(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=Li(u,t,!0);d&&(i=!0,Te(a,d))};!n&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!o&&!i?(Ae(e)&&l.set(e,null),null):(Z(o)?o.forEach(c=>a[c]=null):Te(a,o),Ae(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 Fe=null,vr=null;function tr(e){const t=Fe;return Fe=e,vr=e&&e.type.__scopeId||null,t}function Hf(e){vr=e}function jf(){vr=null}function Bu(e,t=Fe,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 Br(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 M=r||l;x=ft(d.call(M,M,f,o,h,p,y)),m=c}else{const M=t;x=ft(M.length>1?M(o,{attrs:c,slots:i,emit:u}):M(o,null)),m=t.props?c:Pu(c)}}catch(M){ll.length=0,El(M,e,1),x=ke(tt)}let O=x;if(m&&w!==!1){const M=Object.keys(m),{shapeFlag:U}=O;M.length&&U&7&&(a&&M.some(Co)&&(m=Su(m,a)),O=Wt(O,m))}return n.dirs&&(O=Wt(O),O.dirs=O.dirs?O.dirs.concat(n.dirs):n.dirs),n.transition&&(O.transition=n.transition),x=O,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},Su=(e,t)=>{const n={};for(const l in e)(!Co(l)||!(l.slice(9)in t))&&(n[l]=e[l]);return n};function Ou(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 ki(e,t){t&&t.pendingBranch?Z(e)?t.effects.push(...e):t.effects.push(e):Lu(e)}function Du(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}=Ce){var i;const c=ii()===((i=De)==null?void 0:i.scope)?De:null;let u,d=!1,f=!1;if($e(e)?(u=()=>e.value,d=Xl(e)):Ln(e)?(u=()=>e,l=!0):Z(e)?(f=!0,d=e.some(M=>Ln(M)||Xl(M)),u=()=>e.map(M=>{if($e(M))return M.value;if(Ln(M))return rn(M);if(te(M))return Ut(M,c,2)})):te(e)?t?u=()=>Ut(e,c,2):u=()=>{if(!(c&&c.isUnmounted))return p&&p(),at(e,c,3,[h])}:u=vt,t&&l){const M=u;u=()=>rn(M())}let p,h=M=>{p=b.onStop=()=>{Ut(M,c,4)}},y;if($n)if(h=vt,t?n&&at(t,c,3,[u(),f?[]:void 0,h]):u(),r==="sync"){const M=T0();y=M.__watcherHandles||(M.__watcherHandles=[])}else return vt;let w=f?new Array(e.length).fill(Nl):Nl;const x=()=>{if(b.active)if(t){const M=b.run();(l||d||(f?M.some((U,P)=>il(U,w[P])):il(M,w)))&&(p&&p(),at(t,c,3,[M,w===Nl?void 0:f&&w[0]===Nl?[]:w,h]),w=M)}else b.run()};x.allowRecurse=!!t;let m;r==="sync"?m=x:r==="post"?m=()=>qe(x,c&&c.suspense):(x.pre=!0,c&&(x.id=c.uid),m=()=>pr(x));const b=new Oo(u,m);t?n?x():w=b.run():r==="post"?qe(b.run.bind(b),c&&c.suspense):b.run();const O=()=>{b.stop(),c&&c.scope&&Lo(c.scope.effects,b)};return y&&y.push(O),O}function $u(e,t,n){const l=this.proxy,r=pe(e)?e.includes(".")?Ti(l,e):()=>l[e]:e.bind(l,l);let o;te(t)?o=t:(o=t.handler,n=t);const a=De;Dn(this);const i=Vo(r,o.bind(l),n);return a?Dn(a):cn(),i}function Ti(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 Uf(e,t){const n=Fe;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=Wn(),l=Bi();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=Fa(a);if(!u)return Pr(a);const d=fl(u,i,l,n);pl(u,d);const f=n.subTree,p=f&&Fa(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 O=Si(l,p);O[String(p.key)]=p,x._leaveCb=()=>{m(),x._leaveCb=void 0,delete d.delayedLeave},d.delayedLeave=b})}return a}}},Fu=Ru;function Si(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,O=String(e.key),M=Si(n,e),U=(L,H)=>{L&&at(L,l,9,H)},P=(L,H)=>{const Y=H[1];U(L,H),Z(L)?L.every(le=>le.length<=1)&&Y():L.length<=1&&Y()},G={mode:o,persisted:a,beforeEnter(L){let H=i;if(!n.isMounted)if(r)H=w||i;else return;L._leaveCb&&L._leaveCb(!0);const Y=M[O];Y&&nn(e,Y)&&Y.el._leaveCb&&Y.el._leaveCb(),U(H,[L])},enter(L){let H=c,Y=u,le=d;if(!n.isMounted)if(r)H=x||c,Y=m||u,le=b||d;else return;let N=!1;const X=L._enterCb=j=>{N||(N=!0,j?U(le,[L]):U(Y,[L]),G.delayedLeave&&G.delayedLeave(),L._enterCb=void 0)};H?P(H,[L,X]):X()},leave(L,H){const Y=String(e.key);if(L._enterCb&&L._enterCb(!0),n.isUnmounting)return H();U(f,[L]);let le=!1;const N=L._leaveCb=X=>{le||(le=!0,H(),X?U(y,[L]):U(h,[L]),L._leaveCb=void 0,M[Y]===e&&delete M[Y])};M[Y]=e,p?P(p,[L,N]):N()},clone(L){return fl(L,t,n,l)}};return G}function Pr(e){if(_l(e))return e=Wt(e),e.children=null,e}function Fa(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;oTe({name:e.name},t,{setup:e}))():e}const Tn=e=>!!e.type.__asyncLoader;function W(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 I({name:"AsyncComponentWrapper",__asyncLoader:p,get __asyncResolved(){return u},setup(){const h=De;if(u)return()=>Sr(u,h);const y=b=>{c=null,El(b,h,13,!l)};if(a&&h.suspense||$n)return p().then(b=>()=>Sr(b,h)).catch(b=>(y(b),()=>l?ke(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 Sr(u,h);if(x.value&&l)return ke(l,{error:x.value});if(n&&!m.value)return ke(n)}}})}function Sr(e,t){const{ref:n,props:l,children:r,ce:o}=t.vnode,a=ke(e,l,r);return a.ref=n,a.ce=o,delete t.vnode.ce,a}const _l=e=>e.type.__isKeepAlive;function zu(e,t){Oi(e,"a",t)}function Nu(e,t){Oi(e,"da",t)}function Oi(e,t,n=De){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);qn(()=>{Lo(l[t],r)},n)}function mr(e,t,n=De,l=!1){if(n){const r=n[e]||(n[e]=[]),o=t.__weh||(t.__weh=(...a)=>{if(n.isUnmounted)return;Nn(),Dn(n);const i=at(t,n,e,a);return cn(),Vn(),i});return l?r.unshift(o):r.push(o),o}}const It=e=>(t,n=De)=>(!$n||e==="sp")&&mr(e,(...l)=>t(...l),n),Hu=It("bm"),me=It("m"),ju=It("bu"),Mi=It("u"),jo=It("bum"),qn=It("um"),Uu=It("sp"),qu=It("rtg"),Wu=It("rtc");function Gu(e,t=De){mr("ec",e,t)}const Ii="components";function et(e,t){return Yu(Ii,e,!0,t)||e}const Ku=Symbol.for("v-ndc");function Yu(e,t,n=!0,l=!1){const r=Fe||De;if(r){const o=r.type;if(e===Ii){const i=C0(o,!1);if(i&&(i===t||i===st(t)||i===bl(st(t))))return o}const a=za(r[e]||o[e],t)||za(r.appContext[e],t);return!a&&l?o:a}}function za(e,t){return e&&(e[t]||e[st(t)]||e[bl(st(t))])}function qf(e,t,n,l){let r;const o=n&&n[l];if(Z(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&&!Di(t.children)):!0)?e:null}const to=e=>e?Ji(e)?yr(e)||e.proxy:to(e.parent):null,tl=Te(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=>Uo(e),$forceUpdate:e=>e.f||(e.f=()=>pr(e.update)),$nextTick:e=>e.n||(e.n=Un.bind(e.proxy)),$watch:e=>$u.bind(e)}),Or=(e,t)=>e!==Ce&&!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(Or(l,t))return a[t]=1,l[t];if(r!==Ce&&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!==Ce&&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"&&Ge(e,"get",t),d(e);if((f=i.__cssModules)&&(f=f[t]))return f;if(n!==Ce&&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 Or(r,t)?(r[t]=n,!0):l!==Ce&&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!==Ce&&fe(e,a)||Or(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 Z(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let no=!0;function Qu(e){const t=Uo(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:O,unmounted:M,render:U,renderTracked:P,renderTriggered:G,errorCaptured:L,serverPrefetch:H,expose:Y,inheritAttrs:le,components:N,directives:X,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);Ae(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:Se=>Je.value=Se})}if(i)for(const ye in i)$i(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){Z(he)?he.forEach(Ye=>ye(Ye.bind(n))):he&&ye(he.bind(n))}if(ne(Hu,f),ne(me,p),ne(ju,h),ne(Mi,y),ne(zu,w),ne(Nu,x),ne(Gu,L),ne(Wu,P),ne(qu,G),ne(jo,b),ne(qn,M),ne(Uu,H),Z(Y))if(Y.length){const ye=e.exposed||(e.exposed={});Y.forEach(he=>{Object.defineProperty(ye,he,{get:()=>n[he],set:Ye=>n[he]=Ye})})}else e.exposed||(e.exposed={});U&&e.render===vt&&(e.render=U),le!=null&&(e.inheritAttrs=le),N&&(e.components=N),X&&(e.directives=X)}function Zu(e,t,n=vt){Z(e)&&(e=lo(e));for(const l in e){const r=e[l];let o;Ae(r)?"default"in r?o=ce(r.from||l,r.default,!0):o=ce(r.from||l):o=ce(r),$e(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(Z(e)?e.map(l=>l.bind(t.proxy)):e.bind(t.proxy),t,n)}function $i(e,t,n,l){const r=l.includes(".")?Ti(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(Ae(e))if(Z(e))e.forEach(o=>$i(o,t,n,l));else{const o=te(e.handler)?e.handler.bind(n):t[e.handler];te(o)&&se(r,o,e)}}function Uo(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)),Ae(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 Te(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(Z(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),Fi(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]=zi(f,t,!0);Te(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 Ae(e)&&l.set(e,An),An;if(Z(o))for(let d=0;d-1,h[1]=w<0||y-1||fe(h,"default"))&&i.push(f)}}}const u=[a,i];return Ae(e)&&l.set(e,u),u}function Ua(e){return e[0]!=="$"}function qa(e){const t=e&&e.toString().match(/^\s*(function|class) (\w+)/);return t?t[2]:e===null?"null":""}function Wa(e,t){return qa(e)===qa(t)}function Ga(e,t){return Z(t)?t.findIndex(n=>Wa(n,e)):te(t)&&Wa(t,e)?0:-1}const Ni=e=>e[0]==="_"||e==="$stable",qo=e=>Z(e)?e.map(ft):[ft(e)],a0=(e,t,n)=>{if(t._n)return t;const l=Bu((...r)=>qo(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=qo(o);t[r]=()=>a}}},Hi=(e,t)=>{const n=qo(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=Ce;if(l.shapeFlag&32){const i=t._;i?n&&i===1?o=!1:(Te(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(Z(e)){e.forEach((p,h)=>rr(p,t&&(Z(t)?t[h]:t),n,l,r));return}if(Tn(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===Ce?i.refs={}:i.refs,f=i.setupState;if(u!=null&&u!==c&&(pe(u)?(d[u]=null,fe(f,u)&&(f[u]=null)):$e(u)&&(u.value=null)),te(c))Ut(c,i,12,[a,d]);else{const p=pe(c),h=$e(c);if(p||h){const y=()=>{if(e.f){const w=p?fe(f,c)?f[c]:d[c]:c.value;r?Z(w)&&Lo(w,o):Z(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,qe(y,n)):y()}}}let $t=!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}$t=!1,f(b.firstChild,m,null,null,null),er(),b._vnode=m,$t&&console.error("Hydration completed but contains mismatches.")},f=(m,b,O,M,U,P=!1)=>{const G=Hl(m)&&m.data==="[",L=()=>w(m,b,O,M,U,G),{type:H,ref:Y,shapeFlag:le,patchFlag:N}=b;let X=m.nodeType;b.el=m,N===-2&&(P=!1,b.dynamicChildren=null);let j=null;switch(H){case In:X!==3?b.children===""?(c(b.el=r(""),a(m),m),j=m):j=L():(m.data!==b.children&&($t=!0,m.data=b.children),j=o(m));break;case tt:X!==8||G?j=L():j=o(m);break;case nl:if(G&&(m=o(m),X=m.nodeType),X===1||X===3){j=m;const Pe=!b.children.length;for(let ne=0;ne{P=P||!!b.dynamicChildren;const{type:G,props:L,patchFlag:H,shapeFlag:Y,dirs:le}=b,N=G==="input"&&le||G==="option";if(N||H!==-1){if(le&&At(b,null,O,"created"),L)if(N||!P||H&48)for(const j in L)(N&&j.endsWith("value")||yl(j)&&!el(j))&&l(m,j,null,L[j],!1,void 0,O);else L.onClick&&l(m,"onClick",null,L.onClick,!1,void 0,O);let X;if((X=L&&L.onVnodeBeforeMount)&&ot(X,O,b),le&&At(b,null,O,"beforeMount"),((X=L&&L.onVnodeMounted)||le)&&ki(()=>{X&&ot(X,O,b),le&&At(b,null,O,"mounted")},M),Y&16&&!(L&&(L.innerHTML||L.textContent))){let j=h(m.firstChild,b,m,O,M,U,P);for(;j;){$t=!0;const Pe=j;j=j.nextSibling,i(Pe)}}else Y&8&&m.textContent!==b.children&&($t=!0,m.textContent=b.children)}return m.nextSibling},h=(m,b,O,M,U,P,G)=>{G=G||!!b.dynamicChildren;const L=b.children,H=L.length;for(let Y=0;Y{const{slotScopeIds:G}=b;G&&(U=U?U.concat(G):G);const L=a(m),H=h(o(m),b,L,O,M,U,P);return H&&Hl(H)&&H.data==="]"?o(b.anchor=H):($t=!0,c(b.anchor=u("]"),L,H),H)},w=(m,b,O,M,U,P)=>{if($t=!0,b.el=null,P){const H=x(m);for(;;){const Y=o(m);if(Y&&Y!==H)i(Y);else break}}const G=o(m),L=a(m);return i(m),n(null,b,L,G,O,M,Vl(L),U),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 qe=ki;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,T=null,B=null,F=!1,D=null,$=!!g.dynamicChildren)=>{if(v===g)return;v&&!nn(v,g)&&(C=k(v),Se(v,T,B,!0),v=null),g.patchFlag===-2&&($=!1,g.dynamicChildren=null);const{type:S,ref:J,shapeFlag:q}=g;switch(S){case In:x(v,g,E,C);break;case tt:m(v,g,E,C);break;case nl:v==null&&b(g,E,C,F);break;case je:N(v,g,E,C,T,B,F,D,$);break;default:q&1?U(v,g,E,C,T,B,F,D,$):q&6?X(v,g,E,C,T,B,F,D,$):(q&64||q&128)&&S.process(v,g,E,C,T,B,F,D,$,R)}J!=null&&T&&rr(J,v&&v.ref,B,g||v,!g)},x=(v,g,E,C)=>{if(v==null)l(g.el=i(g.children),E,C);else{const T=g.el=v.el;g.children!==v.children&&u(T,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)},O=({el:v,anchor:g},E,C)=>{let T;for(;v&&v!==g;)T=p(v),l(v,E,C),v=T;l(g,E,C)},M=({el:v,anchor:g})=>{let E;for(;v&&v!==g;)E=p(v),r(v),v=E;r(g)},U=(v,g,E,C,T,B,F,D,$)=>{F=F||g.type==="svg",v==null?P(g,E,C,T,B,F,D,$):H(v,g,T,B,F,D,$)},P=(v,g,E,C,T,B,F,D)=>{let $,S;const{type:J,props:q,shapeFlag:Q,transition:ee,dirs:re}=v;if($=v.el=a(v.type,B,q&&q.is,q),Q&8?d($,v.children):Q&16&&L(v.children,$,null,C,T,B&&J!=="foreignObject",F,D),re&&At(v,null,C,"created"),G($,v,v.scopeId,F,C),q){for(const Ee in q)Ee!=="value"&&!el(Ee)&&o($,Ee,null,q[Ee],B,v.children,C,T,Ie);"value"in q&&o($,"value",null,q.value),(S=q.onVnodeBeforeMount)&&ot(S,C,v)}re&&At(v,null,C,"beforeMount");const xe=(!T||T&&!T.pendingBranch)&&ee&&!ee.persisted;xe&&ee.beforeEnter($),l($,g,E),((S=q&&q.onVnodeMounted)||xe||re)&&qe(()=>{S&&ot(S,C,v),xe&&ee.enter($),re&&At(v,null,C,"mounted")},T)},G=(v,g,E,C,T)=>{if(E&&h(v,E),C)for(let B=0;B{for(let S=$;S{const D=g.el=v.el;let{patchFlag:$,dynamicChildren:S,dirs:J}=g;$|=v.patchFlag&16;const q=v.props||Ce,Q=g.props||Ce;let ee;E&&Xt(E,!1),(ee=Q.onVnodeBeforeUpdate)&&ot(ee,E,g,v),J&&At(g,v,E,"beforeUpdate"),E&&Xt(E,!0);const re=T&&g.type!=="foreignObject";if(S?Y(v.dynamicChildren,S,D,E,C,re,B):F||he(v,g,D,null,E,C,re,B,!1),$>0){if($&16)le(D,g,q,Q,E,C,T);else if($&2&&q.class!==Q.class&&o(D,"class",null,Q.class,T),$&4&&o(D,"style",q.style,Q.style,T),$&8){const xe=g.dynamicProps;for(let Ee=0;Ee{ee&&ot(ee,E,g,v),J&&At(g,v,E,"updated")},C)},Y=(v,g,E,C,T,B,F)=>{for(let D=0;D{if(E!==C){if(E!==Ce)for(const D in E)!el(D)&&!(D in C)&&o(v,D,E[D],null,F,g.children,T,B,Ie);for(const D in C){if(el(D))continue;const $=C[D],S=E[D];$!==S&&D!=="value"&&o(v,D,S,$,F,g.children,T,B,Ie)}"value"in C&&o(v,"value",E.value,C.value)}},N=(v,g,E,C,T,B,F,D,$)=>{const S=g.el=v?v.el:i(""),J=g.anchor=v?v.anchor:i("");let{patchFlag:q,dynamicChildren:Q,slotScopeIds:ee}=g;ee&&(D=D?D.concat(ee):ee),v==null?(l(S,E,C),l(J,E,C),L(g.children,E,J,T,B,F,D,$)):q>0&&q&64&&Q&&v.dynamicChildren?(Y(v.dynamicChildren,Q,E,T,B,F,D),(g.key!=null||T&&g===T.subTree)&&ji(v,g,!0)):he(v,g,E,J,T,B,F,D,$)},X=(v,g,E,C,T,B,F,D,$)=>{g.slotScopeIds=D,v==null?g.shapeFlag&512?T.ctx.activate(g,E,C,F,$):j(g,E,C,T,B,F,$):Pe(v,g,$)},j=(v,g,E,C,T,B,F)=>{const D=v.component=E0(v,C,T);if(_l(v)&&(D.ctx.renderer=R),_0(D),D.asyncDep){if(T&&T.registerDep(D,ne),!v.el){const $=D.subTree=ke(tt);m(null,$,g,E)}return}ne(D,v,g,E,T,B,F)},Pe=(v,g,E)=>{const C=g.component=v.component;if(Ou(v,g,E))if(C.asyncDep&&!C.asyncResolved){ye(C,g,E);return}else C.next=g,Cu(C.update),C.update();else g.el=v.el,C.vnode=g},ne=(v,g,E,C,T,B,F)=>{const D=()=>{if(v.isMounted){let{next:J,bu:q,u:Q,parent:ee,vnode:re}=v,xe=J,Ee;Xt(v,!1),J?(J.el=re.el,ye(v,J,F)):J=re,q&&Yl(q),(Ee=J.props&&J.props.onVnodeBeforeUpdate)&&ot(Ee,ee,J,re),Xt(v,!0);const Oe=Br(v),ct=v.subTree;v.subTree=Oe,w(ct,Oe,f(ct.el),k(ct),v,T,B),J.el=Oe.el,xe===null&&Mu(v,Oe.el),Q&&qe(Q,T),(Ee=J.props&&J.props.onVnodeUpdated)&&qe(()=>ot(Ee,ee,J,re),T)}else{let J;const{el:q,props:Q}=g,{bm:ee,m:re,parent:xe}=v,Ee=Tn(g);if(Xt(v,!1),ee&&Yl(ee),!Ee&&(J=Q&&Q.onVnodeBeforeMount)&&ot(J,xe,g),Xt(v,!0),q&&ge){const Oe=()=>{v.subTree=Br(v),ge(q,v.subTree,v,T,null)};Ee?g.type.__asyncLoader().then(()=>!v.isUnmounted&&Oe()):Oe()}else{const Oe=v.subTree=Br(v);w(null,Oe,E,C,v,T,B),g.el=Oe.el}if(re&&qe(re,T),!Ee&&(J=Q&&Q.onVnodeMounted)){const Oe=g;qe(()=>ot(J,xe,Oe),T)}(g.shapeFlag&256||xe&&Tn(xe.vnode)&&xe.vnode.shapeFlag&256)&&v.a&&qe(v.a,T),v.isMounted=!0,g=E=C=null}},$=v.effect=new Oo(D,()=>pr(S),v.scope),S=v.update=()=>$.run();S.id=v.uid,Xt(v,!0),S()},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(),$a(),Vn()},he=(v,g,E,C,T,B,F,D,$=!1)=>{const S=v&&v.children,J=v?v.shapeFlag:0,q=g.children,{patchFlag:Q,shapeFlag:ee}=g;if(Q>0){if(Q&128){Ve(S,q,E,C,T,B,F,D,$);return}else if(Q&256){Ye(S,q,E,C,T,B,F,D,$);return}}ee&8?(J&16&&Ie(S,T,B),q!==S&&d(E,q)):J&16?ee&16?Ve(S,q,E,C,T,B,F,D,$):Ie(S,T,B,!0):(J&8&&d(E,""),ee&16&&L(q,E,C,T,B,F,D,$))},Ye=(v,g,E,C,T,B,F,D,$)=>{v=v||An,g=g||An;const S=v.length,J=g.length,q=Math.min(S,J);let Q;for(Q=0;QJ?Ie(v,T,B,!0,!1,q):L(g,E,C,T,B,F,D,$,q)},Ve=(v,g,E,C,T,B,F,D,$)=>{let S=0;const J=g.length;let q=v.length-1,Q=J-1;for(;S<=q&&S<=Q;){const ee=v[S],re=g[S]=$?Nt(g[S]):ft(g[S]);if(nn(ee,re))w(ee,re,E,null,T,B,F,D,$);else break;S++}for(;S<=q&&S<=Q;){const ee=v[q],re=g[Q]=$?Nt(g[Q]):ft(g[Q]);if(nn(ee,re))w(ee,re,E,null,T,B,F,D,$);else break;q--,Q--}if(S>q){if(S<=Q){const ee=Q+1,re=eeQ)for(;S<=q;)Se(v[S],T,B,!0),S++;else{const ee=S,re=S,xe=new Map;for(S=re;S<=Q;S++){const Qe=g[S]=$?Nt(g[S]):ft(g[S]);Qe.key!=null&&xe.set(Qe.key,S)}let Ee,Oe=0;const ct=Q-re+1;let gn=!1,Aa=0;const Kn=new Array(ct);for(S=0;S=ct){Se(Qe,T,B,!0);continue}let xt;if(Qe.key!=null)xt=xe.get(Qe.key);else for(Ee=re;Ee<=Q;Ee++)if(Kn[Ee-re]===0&&nn(Qe,g[Ee])){xt=Ee;break}xt===void 0?Se(Qe,T,B,!0):(Kn[xt-re]=S+1,xt>=Aa?Aa=xt:gn=!0,w(Qe,g[xt],E,null,T,B,F,D,$),Oe++)}const Ca=gn?f0(Kn):An;for(Ee=Ca.length-1,S=ct-1;S>=0;S--){const Qe=re+S,xt=g[Qe],La=Qe+1{const{el:B,type:F,transition:D,children:$,shapeFlag:S}=v;if(S&6){Je(v.component.subTree,g,E,C);return}if(S&128){v.suspense.move(g,E,C);return}if(S&64){F.move(v,g,E,R);return}if(F===je){l(B,g,E);for(let q=0;q<$.length;q++)Je($[q],g,E,C);l(v.anchor,g,E);return}if(F===nl){O(v,g,E);return}if(C!==2&&S&1&&D)if(C===0)D.beforeEnter(B),l(B,g,E),qe(()=>D.enter(B),T);else{const{leave:q,delayLeave:Q,afterLeave:ee}=D,re=()=>l(B,g,E),xe=()=>{q(B,()=>{re(),ee&&ee()})};Q?Q(B,re,xe):xe()}else l(B,g,E)},Se=(v,g,E,C=!1,T=!1)=>{const{type:B,props:F,ref:D,children:$,dynamicChildren:S,shapeFlag:J,patchFlag:q,dirs:Q}=v;if(D!=null&&rr(D,null,E,v,!0),J&256){g.ctx.deactivate(v);return}const ee=J&1&&Q,re=!Tn(v);let xe;if(re&&(xe=F&&F.onVnodeBeforeUnmount)&&ot(xe,g,v),J&6)Zt(v.component,E,C);else{if(J&128){v.suspense.unmount(E,C);return}ee&&At(v,null,g,"beforeUnmount"),J&64?v.type.remove(v,g,E,T,R,C):S&&(B!==je||q>0&&q&64)?Ie(S,g,E,!1,!0):(B===je&&q&384||!T&&J&16)&&Ie($,g,E),C&&_t(v)}(re&&(xe=F&&F.onVnodeUnmounted)||ee)&&qe(()=>{xe&&ot(xe,g,v),ee&&At(v,null,g,"unmounted")},E)},_t=v=>{const{type:g,el:E,anchor:C,transition:T}=v;if(g===je){wt(E,C);return}if(g===nl){M(v);return}const B=()=>{r(E),T&&!T.persisted&&T.afterLeave&&T.afterLeave()};if(v.shapeFlag&1&&T&&!T.persisted){const{leave:F,delayLeave:D}=T,$=()=>F(E,B);D?D(v.el,B,$):$()}else B()},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:T,update:B,subTree:F,um:D}=v;C&&Yl(C),T.stop(),B&&(B.active=!1,Se(F,v,g,E)),D&&qe(D,g),qe(()=>{v.isUnmounted=!0},g),g&&g.pendingBranch&&!g.isUnmounted&&v.asyncDep&&!v.asyncResolved&&v.suspenseId===g.pendingId&&(g.deps--,g.deps===0&&g.resolve())},Ie=(v,g,E,C=!1,T=!1,B=0)=>{for(let F=B;Fv.shapeFlag&6?k(v.component.subTree):v.shapeFlag&128?v.suspense.next():p(v.anchor||v.el),z=(v,g,E)=>{v==null?g._vnode&&Se(g._vnode,null,null,!0):w(g._vnode||null,v,g,null,null,null,E),$a(),er(),g._vnode=v},R={p:w,um:Se,m:Je,r:_t,mt:j,mc:L,pc:he,pbc:Y,n:k,o:e};let K,ge;return t&&([K,ge]=t(R)),{render:z,hydrate:K,createApp:l0(z,K)}}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(Z(l)&&Z(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"),In=Symbol.for("v-txt"),tt=Symbol.for("v-cmt"),nl=Symbol.for("v-stc"),ll=[];let ht=null;function Ui(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 qi(e){return e.dynamicChildren=hl>0?ht||An:null,h0(),hl>0&&ht&&ht.push(e),e}function Gf(e,t,n,l,r,o){return qi(Ki(e,t,n,l,r,o,!0))}function Wi(e,t,n,l,r){return qi(ke(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",Gi=({key:e})=>e??null,Jl=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?pe(e)||$e(e)||te(e)?{i:Fe,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&&Gi(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:Fe};return i?(Wo(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 ke=v0;function v0(e,t=null,n=null,l=0,r=null,o=!1){if((!e||e===Ku)&&(e=tt),or(e)){const i=Wt(e,t,!0);return n&&Wo(i,n),hl>0&&!o&&ht&&(i.shapeFlag&6?ht[ht.indexOf(e)]=i:ht.push(i)),i.patchFlag|=-2,i}if(L0(e)&&(e=e.__vccOpts),t){t=m0(t);let{class:i,style:c}=t;i&&!pe(i)&&(t.class=Po(i)),Ae(c)&&(bi(c)&&!Z(c)&&(c=Te({},c)),t.style=Bo(c))}const a=pe(e)?1:Iu(e)?128:p0(e)?64:Ae(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?Te({},e):e:null}function Wt(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&&Gi(i),ref:t&&t.ref?n&&r?Z(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&&Wt(e.ssContent),ssFallback:e.ssFallback&&Wt(e.ssFallback),el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce}}function Yi(e=" ",t=0){return ke(In,null,e,t)}function Kf(e,t){const n=ke(nl,null,e);return n.staticCount=t,n}function Yf(e="",t=!1){return t?(Ui(),Wi(tt,null,e)):ke(tt,null,e)}function ft(e){return e==null||typeof e=="boolean"?ke(tt):Z(e)?ke(je,null,e.slice()):typeof e=="object"?Nt(e):ke(In,null,String(e))}function Nt(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:Wt(e)}function Wo(e,t){let n=0;const{shapeFlag:l}=e;if(t==null)t=null;else if(Z(t))n=16;else if(typeof t=="object")if(l&65){const r=t.default;r&&(r._c&&(r._d=!1),Wo(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!(gr in t)?t._ctx=Fe:r===3&&Fe&&(Fe.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else te(t)?(t={default:t,_ctx:Fe},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;nDe||Fe;let Go,yn,Ya="__VUE_INSTANCE_SETTERS__";(yn=Jr()[Ya])||(yn=Jr()[Ya]=[]),yn.push(e=>De=e),Go=e=>{yn.length>1?yn.forEach(t=>t(e)):yn[0](e)};const Dn=e=>{Go(e),e.scope.on()},cn=()=>{De&&De.scope.off(),Go(null)};function Ji(e){return e.vnode.shapeFlag&4}let $n=!1;function _0(e,t=!1){$n=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 $n=!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?A0(e):null;Dn(e),Nn();const o=Ut(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:Ae(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||Uo(e).template;if(r){const{isCustomElement:o,compilerOptions:a}=e.appContext.config,{delimiters:i,compilerOptions:c}=l,u=Te(Te({isCustomElement:o,delimiters:i},a),c);l.render=Qa(r,u)}}e.render=l.render||vt}Dn(e),Nn(),Qu(e),Vn(),cn()}function x0(e){return e.attrsProxy||(e.attrsProxy=new Proxy(e.attrs,{get(t,n){return Ge(e,"get","$attrs"),t[n]}}))}function A0(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 C0(e,t=!0){return te(e)?e.displayName||e.name:e.name||t&&e.__name}function L0(e){return te(e)&&"__vccOpts"in e}const _=(e,t)=>wu(e,t,$n);function s(e,t,n){const l=arguments.length;return l===2?Ae(t)&&!Z(t)?or(t)?ke(e,null,[t]):ke(e,t):ke(e,null,t):(l>3?n=Array.prototype.slice.call(arguments,2):l===3&&or(n)&&(n=[n]),ke(e,t,n))}const k0=Symbol.for("v-scx"),T0=()=>ce(k0),B0="3.3.2",P0="http://www.w3.org/2000/svg",ln=typeof document<"u"?document:null,Za=ln&&ln.createElement("template"),S0={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 O0(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 M0(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(Z(n))n.forEach(l=>oo(e,t,l));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const l=I0(e,t);Xa.test(n)?e.setProperty(pn(l),n.replace(Xa,""),"important"):e[l]=n}}const es=["Webkit","Moz","ms"],Mr={};function I0(e,t){const n=Mr[t];if(n)return n;let l=st(t);if(l!=="filter"&&l in e)return Mr[t]=l;l=bl(l);for(let r=0;rIr||(N0.then(()=>Ir=0),Ir=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(Z(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]/,U0=(e,t,n,l,r=!1,o,a,i,c)=>{t==="class"?O0(e,l,r):t==="style"?M0(e,n,l):yl(t)?Co(t)||F0(e,t,n,l,a):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):q0(e,t,l,r))?$0(e,t,l,o,a,i,c):(t==="true-value"?e._trueValue=l:t==="false-value"&&(e._falseValue=l),D0(e,t,l,r))};function q0(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",Gt=(e,{slots:t})=>s(Fu,Xi(e),t);Gt.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},W0=Gt.props=Te({},Pi,Zi),en=(e,t=[])=>{Z(e)?e.forEach(n=>n(...t)):e&&e(...t)},rs=e=>e?Z(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=G0(r),w=y&&y[0],x=y&&y[1],{onBeforeEnter:m,onEnter:b,onEnterCancelled:O,onLeave:M,onLeaveCancelled:U,onBeforeAppear:P=m,onAppear:G=b,onAppearCancelled:L=O}=t,H=(N,X,j)=>{zt(N,X?d:i),zt(N,X?u:a),j&&j()},Y=(N,X)=>{N._isLeaving=!1,zt(N,f),zt(N,h),zt(N,p),X&&X()},le=N=>(X,j)=>{const Pe=N?G:b,ne=()=>H(X,N,j);en(Pe,[X,ne]),os(()=>{zt(X,N?c:o),Bt(X,N?d:i),rs(Pe)||as(X,l,w,ne)})};return Te(t,{onBeforeEnter(N){en(m,[N]),Bt(N,o),Bt(N,a)},onBeforeAppear(N){en(P,[N]),Bt(N,c),Bt(N,u)},onEnter:le(!1),onAppear:le(!0),onLeave(N,X){N._isLeaving=!0;const j=()=>Y(N,X);Bt(N,f),t1(),Bt(N,p),os(()=>{N._isLeaving&&(zt(N,f),Bt(N,h),rs(M)||as(N,l,x,j))}),en(M,[N,j])},onEnterCancelled(N){H(N,!1),en(O,[N])},onAppearCancelled(N){H(N,!0),en(L,[N])},onLeaveCancelled(N){Y(N),en(U,[N])}})}function G0(e){if(e==null)return null;if(Ae(e))return[Dr(e.enter),Dr(e.leave)];{const t=Dr(e);return[t,t]}}function Dr(e){return P2(e)}function Bt(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e._vtc||(e._vtc=new Set)).add(t)}function zt(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:Te({},W0,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=Wn(),l=Bi();let r,o;return Mi(()=>{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;Bt(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,zt(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 Z(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=Te({patchProp:U0},S0);let $r,ds=!1;function a4(){return $r=ds?$r:u0(o4),ds=!0,$r}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":()=>A(()=>import("./index.html-ea49af00.js"),[]).then(({data:e})=>e),"v-184f4da6":()=>A(()=>import("./intro.html-643bf0e3.js"),[]).then(({data:e})=>e),"v-2d0a870d":()=>A(()=>import("./index.html-f97f352c.js"),[]).then(({data:e})=>e),"v-5aa3d8ba":()=>A(()=>import("./intro.html-1c32b3c0.js"),[]).then(({data:e})=>e),"v-e8a3586c":()=>A(()=>import("./template.html-5d9fb92e.js"),[]).then(({data:e})=>e),"v-c3fa0194":()=>A(()=>import("./template.html-62758aef.js"),[]).then(({data:e})=>e),"v-0feda2e2":()=>A(()=>import("./NUMA Balance实现浅析.html-6c9b7910.js"),[]).then(({data:e})=>e),"v-3e42db3e":()=>A(()=>import("./NUMA Balancing.html-9ab2efe0.js"),[]).then(({data:e})=>e),"v-1f37d83d":()=>A(()=>import("./vscode qemu开发Linux内核.html-02caaa21.js"),[]).then(({data:e})=>e),"v-6de84607":()=>A(()=>import("./HelloWorld.html-7f084ba3.js"),[]).then(({data:e})=>e),"v-5fbbe44c":()=>A(()=>import("./Chapter1 Introduction.html-c01ef3b8.js"),[]).then(({data:e})=>e),"v-fa5bbd4e":()=>A(()=>import("./Chapter0 前言.html-d77c06d0.js"),[]).then(({data:e})=>e),"v-40a655de":()=>A(()=>import("./Chapter1 编译器组成.html-2def8ff5.js"),[]).then(({data:e})=>e),"v-e2bd5838":()=>A(()=>import("./Chapter2 词法分析.html-54374521.js"),[]).then(({data:e})=>e),"v-4f5ffb7c":()=>A(()=>import("./Chapter3 语法分析.html-d25d9caf.js"),[]).then(({data:e})=>e),"v-a7388c80":()=>A(()=>import("./Chapter4 语义分析.html-9577457a.js"),[]).then(({data:e})=>e),"v-0fc134f8":()=>A(()=>import("./Chapter5 代码生成.html-5189a489.js"),[]).then(({data:e})=>e),"v-274329b2":()=>A(()=>import("./LWN针对多层内存系统重新进行NUMA平衡.html-37798d4f.js"),[]).then(({data:e})=>e),"v-11f1c650":()=>A(()=>import("./could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-6b63758f.js"),[]).then(({data:e})=>e),"v-69ae52f9":()=>A(()=>import("./记一次 GP Debug 的心路历程.html-c07c20a5.js"),[]).then(({data:e})=>e),"v-384e46cc":()=>A(()=>import("./震惊!1等于0.html-d0e44dc9.js"),[]).then(({data:e})=>e),"v-3706649a":()=>A(()=>import("./404.html-343b11af.js"),[]).then(({data:e})=>e),"v-e1e3da16":()=>A(()=>import("./index.html-711d919a.js"),[]).then(({data:e})=>e),"v-c8296fee":()=>A(()=>import("./index.html-8f53b261.js"),[]).then(({data:e})=>e),"v-c35f20b2":()=>A(()=>import("./index.html-953b207f.js"),[]).then(({data:e})=>e),"v-6366e292":()=>A(()=>import("./index.html-30d133a5.js"),[]).then(({data:e})=>e),"v-75dd7f1a":()=>A(()=>import("./index.html-c1bbdab4.js"),[]).then(({data:e})=>e),"v-1800c499":()=>A(()=>import("./index.html-bfbc86b1.js"),[]).then(({data:e})=>e),"v-1e91694f":()=>A(()=>import("./index.html-48c972a4.js"),[]).then(({data:e})=>e),"v-2948e7ec":()=>A(()=>import("./index.html-6ffd81d9.js"),[]).then(({data:e})=>e),"v-ffa8c116":()=>A(()=>import("./index.html-456987a2.js"),[]).then(({data:e})=>e),"v-36e4471e":()=>A(()=>import("./index.html-7da15133.js"),[]).then(({data:e})=>e),"v-5bc93818":()=>A(()=>import("./index.html-f4dcdfc9.js"),[]).then(({data:e})=>e),"v-744d024e":()=>A(()=>import("./index.html-75dd72ef.js"),[]).then(({data:e})=>e),"v-e52c881c":()=>A(()=>import("./index.html-516a49e5.js"),[]).then(({data:e})=>e),"v-154dc4c4":()=>A(()=>import("./index.html-1084c80f.js"),[]).then(({data:e})=>e),"v-01560935":()=>A(()=>import("./index.html-3356e63f.js"),[]).then(({data:e})=>e),"v-49425445":()=>A(()=>import("./index.html-83aa3e19.js"),[]).then(({data:e})=>e),"v-0943d7c2":()=>A(()=>import("./index.html-a929cebb.js"),[]).then(({data:e})=>e),"v-506407f4":()=>A(()=>import("./index.html-b70aeab0.js"),[]).then(({data:e})=>e),"v-37a8c5a0":()=>A(()=>import("./index.html-cb4b1e76.js"),[]).then(({data:e})=>e),"v-0379cba1":()=>A(()=>import("./index.html-cea8bfff.js"),[]).then(({data:e})=>e),"v-a9d9d4d6":()=>A(()=>import("./index.html-b9c4000b.js"),[]).then(({data:e})=>e),"v-1190a5ee":()=>A(()=>import("./index.html-5c401711.js"),[]).then(({data:e})=>e),"v-34bba11a":()=>A(()=>import("./index.html-347098b6.js"),[]).then(({data:e})=>e),"v-28e32c66":()=>A(()=>import("./index.html-0498e73d.js"),[]).then(({data:e})=>e),"v-4aa6ad1c":()=>A(()=>import("./index.html-f53b9083.js"),[]).then(({data:e})=>e),"v-a704b744":()=>A(()=>import("./index.html-4aa1210b.js"),[]).then(({data:e})=>e),"v-1007819b":()=>A(()=>import("./index.html-eeadde59.js"),[]).then(({data:e})=>e),"v-a665a6ae":()=>A(()=>import("./index.html-fe3fd30f.js"),[]).then(({data:e})=>e),"v-d2dd3922":()=>A(()=>import("./index.html-6c8afb2c.js"),[]).then(({data:e})=>e),"v-494230f6":()=>A(()=>import("./index.html-50290763.js"),[]).then(({data:e})=>e),"v-5decfa84":()=>A(()=>import("./index.html-2fe3384a.js"),[]).then(({data:e})=>e),"v-4446a48e":()=>A(()=>import("./index.html-69415dfb.js"),[]).then(({data:e})=>e),"v-3ce877ec":()=>A(()=>import("./index.html-a875e273.js"),[]).then(({data:e})=>e),"v-5731fdb6":()=>A(()=>import("./index.html-7348225e.js"),[]).then(({data:e})=>e),"v-897763fa":()=>A(()=>import("./index.html-9b3c1776.js"),[]).then(({data:e})=>e),"v-1d543380":()=>A(()=>import("./index.html-df58015a.js"),[]).then(({data:e})=>e),"v-075c6c62":()=>A(()=>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":W(()=>A(()=>import("./index.html-f0f0bda9.js"),["assets/index.html-f0f0bda9.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-184f4da6":W(()=>A(()=>import("./intro.html-e2551cbc.js"),["assets/intro.html-e2551cbc.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-2d0a870d":W(()=>A(()=>import("./index.html-78978260.js"),["assets/index.html-78978260.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5aa3d8ba":W(()=>A(()=>import("./intro.html-3495a78b.js"),["assets/intro.html-3495a78b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e8a3586c":W(()=>A(()=>import("./template.html-6d4d5791.js"),["assets/template.html-6d4d5791.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c3fa0194":W(()=>A(()=>import("./template.html-3b33e5dc.js"),["assets/template.html-3b33e5dc.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0feda2e2":W(()=>A(()=>import("./NUMA Balance实现浅析.html-423bb93d.js"),["assets/NUMA Balance实现浅析.html-423bb93d.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3e42db3e":W(()=>A(()=>import("./NUMA Balancing.html-6466c843.js"),["assets/NUMA Balancing.html-6466c843.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1f37d83d":W(()=>A(()=>import("./vscode qemu开发Linux内核.html-27da18b7.js"),["assets/vscode qemu开发Linux内核.html-27da18b7.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-6de84607":W(()=>A(()=>import("./HelloWorld.html-f63cf3f6.js"),["assets/HelloWorld.html-f63cf3f6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5fbbe44c":W(()=>A(()=>import("./Chapter1 Introduction.html-96927c54.js"),["assets/Chapter1 Introduction.html-96927c54.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-fa5bbd4e":W(()=>A(()=>import("./Chapter0 前言.html-09af125b.js"),["assets/Chapter0 前言.html-09af125b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-40a655de":W(()=>A(()=>import("./Chapter1 编译器组成.html-06252c86.js"),["assets/Chapter1 编译器组成.html-06252c86.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e2bd5838":W(()=>A(()=>import("./Chapter2 词法分析.html-697f1885.js"),["assets/Chapter2 词法分析.html-697f1885.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4f5ffb7c":W(()=>A(()=>import("./Chapter3 语法分析.html-6240be15.js"),["assets/Chapter3 语法分析.html-6240be15.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a7388c80":W(()=>A(()=>import("./Chapter4 语义分析.html-cf12c29b.js"),["assets/Chapter4 语义分析.html-cf12c29b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0fc134f8":W(()=>A(()=>import("./Chapter5 代码生成.html-ca59a43d.js"),["assets/Chapter5 代码生成.html-ca59a43d.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-274329b2":W(()=>A(()=>import("./LWN针对多层内存系统重新进行NUMA平衡.html-f57b16d9.js"),["assets/LWN针对多层内存系统重新进行NUMA平衡.html-f57b16d9.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-11f1c650":W(()=>A(()=>import("./could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-68f0cb65.js"),["assets/could not dial endpoint 'orderer-api.127-0-0-1.nip.io.html-68f0cb65.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-69ae52f9":W(()=>A(()=>import("./记一次 GP Debug 的心路历程.html-5182ce0a.js"),["assets/记一次 GP Debug 的心路历程.html-5182ce0a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-384e46cc":W(()=>A(()=>import("./震惊!1等于0.html-e049d2d4.js"),["assets/震惊!1等于0.html-e049d2d4.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3706649a":W(()=>A(()=>import("./404.html-dfc0710a.js"),["assets/404.html-dfc0710a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e1e3da16":W(()=>A(()=>import("./index.html-3e5bf64a.js"),["assets/index.html-3e5bf64a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c8296fee":W(()=>A(()=>import("./index.html-30779509.js"),["assets/index.html-30779509.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-c35f20b2":W(()=>A(()=>import("./index.html-fffb2e1c.js"),["assets/index.html-fffb2e1c.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-6366e292":W(()=>A(()=>import("./index.html-df539570.js"),["assets/index.html-df539570.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-75dd7f1a":W(()=>A(()=>import("./index.html-78a5b38b.js"),["assets/index.html-78a5b38b.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1800c499":W(()=>A(()=>import("./index.html-d6325281.js"),["assets/index.html-d6325281.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1e91694f":W(()=>A(()=>import("./index.html-eef1f5bd.js"),["assets/index.html-eef1f5bd.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-2948e7ec":W(()=>A(()=>import("./index.html-a3ad4ea7.js"),["assets/index.html-a3ad4ea7.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-ffa8c116":W(()=>A(()=>import("./index.html-2843565e.js"),["assets/index.html-2843565e.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-36e4471e":W(()=>A(()=>import("./index.html-160052c7.js"),["assets/index.html-160052c7.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5bc93818":W(()=>A(()=>import("./index.html-a9b03920.js"),["assets/index.html-a9b03920.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-744d024e":W(()=>A(()=>import("./index.html-63d5d3bc.js"),["assets/index.html-63d5d3bc.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-e52c881c":W(()=>A(()=>import("./index.html-72f53bc5.js"),["assets/index.html-72f53bc5.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-154dc4c4":W(()=>A(()=>import("./index.html-247da3a8.js"),["assets/index.html-247da3a8.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-01560935":W(()=>A(()=>import("./index.html-fd6b2109.js"),["assets/index.html-fd6b2109.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-49425445":W(()=>A(()=>import("./index.html-4d13ac8c.js"),["assets/index.html-4d13ac8c.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0943d7c2":W(()=>A(()=>import("./index.html-a383a4e9.js"),["assets/index.html-a383a4e9.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-506407f4":W(()=>A(()=>import("./index.html-1db9bb27.js"),["assets/index.html-1db9bb27.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-37a8c5a0":W(()=>A(()=>import("./index.html-0f8b9808.js"),["assets/index.html-0f8b9808.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-0379cba1":W(()=>A(()=>import("./index.html-651e322a.js"),["assets/index.html-651e322a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a9d9d4d6":W(()=>A(()=>import("./index.html-586f6093.js"),["assets/index.html-586f6093.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1190a5ee":W(()=>A(()=>import("./index.html-59fafeab.js"),["assets/index.html-59fafeab.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-34bba11a":W(()=>A(()=>import("./index.html-3c4c02a5.js"),["assets/index.html-3c4c02a5.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-28e32c66":W(()=>A(()=>import("./index.html-e3c533d1.js"),["assets/index.html-e3c533d1.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4aa6ad1c":W(()=>A(()=>import("./index.html-0fbadab6.js"),["assets/index.html-0fbadab6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a704b744":W(()=>A(()=>import("./index.html-dc55b67c.js"),["assets/index.html-dc55b67c.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1007819b":W(()=>A(()=>import("./index.html-16642f6e.js"),["assets/index.html-16642f6e.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-a665a6ae":W(()=>A(()=>import("./index.html-456e6a8a.js"),["assets/index.html-456e6a8a.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-d2dd3922":W(()=>A(()=>import("./index.html-ff8832ad.js"),["assets/index.html-ff8832ad.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-494230f6":W(()=>A(()=>import("./index.html-d5d71038.js"),["assets/index.html-d5d71038.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5decfa84":W(()=>A(()=>import("./index.html-cc73a3e6.js"),["assets/index.html-cc73a3e6.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-4446a48e":W(()=>A(()=>import("./index.html-ffa44b9c.js"),["assets/index.html-ffa44b9c.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-3ce877ec":W(()=>A(()=>import("./index.html-ce797aca.js"),["assets/index.html-ce797aca.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-5731fdb6":W(()=>A(()=>import("./index.html-a5c41f87.js"),["assets/index.html-a5c41f87.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-897763fa":W(()=>A(()=>import("./index.html-ad30fe95.js"),["assets/index.html-ad30fe95.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-1d543380":W(()=>A(()=>import("./index.html-082744a3.js"),["assets/index.html-082744a3.js","assets/plugin-vue_export-helper-c27b6911.js"])),"v-075c6c62":W(()=>A(()=>import("./index.html-08c23b60.js"),["assets/index.html-08c23b60.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(""),kt=()=>{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(""),A4="Layout",C4="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=[...Z(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=A4}else n=C4;return t[n]},resolveRouteLocale:(e,t)=>g4(e,t),resolveSiteLocaleData:(e,t)=>({...e,...e.locales[t]})}),Er=I({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=I({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 L4={};var Ue=Uint8Array,on=Uint16Array,m1=Uint32Array,g1=new Ue([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 Ue([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]),k4=new Ue([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|(Le&21845)<<1;Ft=(Ft&52428)>>>2|(Ft&13107)<<2,Ft=(Ft&61680)>>>4|(Ft&3855)<<4,ao[Le]=((Ft&65280)>>>8|(Ft&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 Ue(288);for(var Le=0;Le<144;++Le)xl[Le]=8;for(var Le=144;Le<256;++Le)xl[Le]=9;for(var Le=256;Le<280;++Le)xl[Le]=7;for(var Le=280;Le<288;++Le)xl[Le]=8;var w1=new Ue(32);for(var Le=0;Le<32;++Le)w1[Le]=5;var S4=rl(xl,9,1),O4=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},Fr=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},M4=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:Ue)(n-t);return l.set(e.subarray(t,n)),l},I4=["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||I4[e]);if(l.code=e,Error.captureStackTrace&&Error.captureStackTrace(l,dt),!n)throw l;return l},D4=function(e,t,n){var l=e.length;if(!l||n&&n.f&&!n.l)return t||new Ue(0);var r=!t||n,o=!n||n.i;n||(n={}),t||(t=new Ue(l*3));var a=function(Ie){var k=t.length;if(Ie>k){var z=new Ue(Math.max(k*2,Ie));z.set(t),t=z}},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=S4,f=O4,p=9,h=5;else if(w==2){var O=ut(e,c,31)+257,M=ut(e,c+10,15)+4,U=O+ut(e,c+5,31)+1;c+=14;for(var P=new Ue(U),G=new Ue(19),L=0;L>>4;if(x<16)P[L++]=x;else{var X=0,j=0;for(x==16?(j=3+ut(e,c,3),c+=2,X=P[L-1]):x==17?(j=3+ut(e,c,7),c+=3):x==18&&(j=11+ut(e,c,127),c+=7);j--;)P[L++]=X}}var Pe=P.subarray(0,O),ne=P.subarray(O);p=Rr(Pe),h=Rr(ne),d=rl(Pe,p,1),f=rl(ne,h,1)}else dt(1);else{var x=M4(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+=X&15,c>y){o&&dt(0);break}if(X||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 L=Ve-257,Se=g1[L];Je=ut(e,c,(1<>>4;_t||dt(3),c+=_t&15;var ne=P4[wt];if(wt>3){var Se=y1[wt];ne+=Fr(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 F4(e,t){return D4((R4(e),e.subarray(2,-4)),t)}var fs=typeof TextEncoder<"u"&&new TextEncoder,so=typeof TextDecoder<"u"&&new TextDecoder,z4=0;try{so.decode($4,{stream:!0}),z4=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 Ue(e.length),l=0;l>1)),a=0,i=function(d){o[a++]=d},l=0;lo.length){var c=new Ue(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)},A1=()=>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"}));A1.displayName="GitHubIcon";const C1=()=>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"}));C1.displayName="GitLabIcon";const L1=()=>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"}));L1.displayName="GiteeIcon";const k1=()=>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"}));k1.displayName="BitbucketIcon";const T1=()=>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"}));T1.displayName="SourceIcon";const Xo=Array.isArray,j4=e=>typeof e=="function",U4=e=>typeof e=="string";var B1=e=>/^(https?:)?\/\//.test(e),ol=e=>Object.prototype.toString.call(e)==="[object Object]";const gt=(e,t)=>{const n=t?t._instance:Wn();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 q4(){const e=V(!1);return Wn()&&me(()=>{e.value=!0}),e}function W4(e){return q4(),_(()=>!!e())}const G4=()=>W4(()=>typeof window<"u"&&window.navigator&&"userAgent"in window.navigator),K4=()=>{const e=G4();return _(()=>e.value&&/\b(?:Android|iPhone)/i.test(navigator.userAgent))},Al=e=>{const t=kt();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[]},S1=e=>P1(e,"category"),O1=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 M1=/#.*$/u,Q4=e=>{const t=M1.exec(e);return t?t[0]:""},vs=e=>decodeURI(e).replace(M1,"").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(F4(V4(t,!0)))},Z4=e=>B1(e)?e:`https://github.com/${e}`,I1=e=>!B1(e)||/github\.com/.test(e)?"GitHub":/bitbucket\.org/.test(e)?"Bitbucket":/gitlab\.com/.test(e)?"GitLab":/gitee\.com/.test(e)?"Gitee":null,Cl=(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=U4(o)?{path:o}:o;return Cl(e,{hash:n.hash,query:n.query,params:n.params,...a})};function Yt(e){return ii()?(z2(e),!0):!1}function it(e){return typeof e=="function"?e():sn(e)}const Ll=typeof window<"u",fn=()=>{},io=X4();function X4(){var e;return Ll&&((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 D1=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=D1){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 $1(...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 F1(e,t=!0){Wn()?me(e):t?e():Un(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,Ll&&c()),Yt(i),{isPending:hn(r),start:c,stop:i}}function co(e=!1,t={}){const{truthyValue:n=!0,falsyValue:l=!1}=t,r=$e(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=D1}=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,z1=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={}))z1.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)z1.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 Lt=Ll?window:void 0,V1=Ll?window.document:void 0,m3=Ll?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=Lt):[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=Lt,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 Wn()&&me(()=>{e.value=!0}),e}function kl(e){const t=y3();return _(()=>(t.value,!!e()))}function H1(e,t={}){const{window:n=Lt}=t,l=kl(()=>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($1(e).value),o.value=!!(r!=null&&r.matches),r&&("addEventListener"in r?r.addEventListener("change",i):r.addListener(i)))};return Du(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=kl(()=>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:{},Ul="__vueuse_ssr_handlers__",E3=_3();function _3(){return Ul in jl||(jl[Ul]=jl[Ul]||{}),jl[Ul]}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 A3=Object.defineProperty,bs=Object.getOwnPropertySymbols,C3=Object.prototype.hasOwnProperty,L3=Object.prototype.propertyIsEnumerable,Es=(e,t,n)=>t in e?A3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_s=(e,t)=>{for(var n in t||(t={}))C3.call(t,n)&&Es(e,n,t[n]);if(bs)for(var n of bs(t))L3.call(t,n)&&Es(e,n,t[n]);return e};const k3={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=Lt,eventFilter:p,onError:h=L=>{console.error(L)}}=l,y=(d?Be:V)(t);if(!n)try{n=w3("getDefaultStorage",()=>{var L;return(L=Lt)==null?void 0:L.localStorage})()}catch(L){h(L)}if(!n)return y;const w=it(t),x=x3(w),m=(r=l.serializer)!=null?r:k3[x],{pause:b,resume:O}=v3(y,()=>M(y.value),{flush:o,deep:a,eventFilter:p});return f&&i&&(Re(f,"storage",G),Re(f,ws,P)),G(),y;function M(L){try{if(L==null)n.removeItem(e);else{const H=m.write(L),Y=n.getItem(e);Y!==H&&(n.setItem(e,H),f&&f.dispatchEvent(new CustomEvent(ws,{detail:{key:e,oldValue:Y,newValue:H,storageArea:n}})))}}catch(H){h(H)}}function U(L){const H=L?L.newValue:n.getItem(e);if(H==null)return c&&w!==null&&n.setItem(e,m.write(w)),w;if(!L&&u){const Y=m.read(H);return typeof u=="function"?u(Y,w):x==="object"&&!Array.isArray(Y)?_s(_s({},w),Y):Y}else return typeof H!="string"?H:m.read(H)}function P(L){G(L.detail)}function G(L){if(!(L&&L.storageArea!==n)){if(L&&L.key==null){y.value=w;return}if(!(L&&L.key!==e)){b();try{y.value=U(L)}catch(H){h(H)}finally{L?Un(O):O()}}}}}function T3(e){return H1("(prefers-color-scheme: dark)",e)}var xs=Object.getOwnPropertySymbols,B3=Object.prototype.hasOwnProperty,P3=Object.prototype.propertyIsEnumerable,S3=(e,t)=>{var n={};for(var l in e)B3.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 O3(e,t,n={}){const l=n,{window:r=Lt}=l,o=S3(l,["window"]);let a;const i=kl(()=>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 As=Object.getOwnPropertySymbols,M3=Object.prototype.hasOwnProperty,I3=Object.prototype.propertyIsEnumerable,D3=(e,t)=>{var n={};for(var l in e)M3.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&As)for(var l of As(e))t.indexOf(l)<0&&I3.call(e,l)&&(n[l]=e[l]);return n};function $3(e,t,n={}){const l=n,{window:r=Lt}=l,o=D3(l,["window"]);let a;const i=kl(()=>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=Lt,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 $3(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 Cs=["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=kl(()=>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,Cs,x,!1),Re(()=>Xe(r),Cs,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 U1(e,t=!1){const n=V(t);let l=null,r;se($1(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=>{F3(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 z3=0;function N3(e,t={}){const n=V(!1),{document:l=V1,immediate:r=!0,manual:o=!1,id:a=`vueuse_styletag_${++z3}`}=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&&F1(u),o||Yt(d),{id:a,css:i,unload:d,load:u,isLoaded:hn(n)}}function V3({window:e=Lt}={}){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=Lt,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(),F1(c),Re("resize",c,{passive:!0}),r){const u=H1("(orientation: portrait)");se(u,()=>c())}return{width:a,height:i}}const q1=({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)};q1.displayName="Badge";var j3=I({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 W1=()=>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"})]);W1.displayName="BackToTopIcon";var U3=I({name:"BackToTop",props:{threshold:{type:Number,default:100},noProgress:Boolean},setup(e){const t=we(),n=Al({"/en/":{backToTop:"Back to top"},"/":{backToTop:"返回顶部"}}),l=Be(),{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(Gt,{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(W1)]):null)}});const q3=bt({enhance:({app:e})=>{gt("Badge")||e.component("Badge",q1),gt("FontIcon")||e.component("FontIcon",j3)},setup:()=>{N3(` @import url("https://at.alicdn.com/t/c/font_2410206_5vb9zlyghj.css"); - `)},rootComponents:[()=>s(U3,{})]});function W3(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 O=e.apply(y,h);i&&i(O),d.forEach(function(M){return(0,M.resolve)(O)}),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 G3(e){return e.__esModule||e[Symbol.toStringTag]==="Module"}const be=Object.assign;function zr(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 Ls(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])&&G1(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 G1(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)?ks(e,t):yt(t)?ks(t,e):e===t}function ks(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 Ts(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),Ls(c,"")}return Ls(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 Bs(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,Bs(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({},Bs(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 St={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 Fn(e,t){return be(new Error,{type:e,[J1]:!0},t)}function Tt(e,t){return e instanceof Error&&J1 in e&&(t==null||!!(e.type&t))}const Ss="[^/]+?",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&&!Is(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 Fn(1,{location:d});w=p.record.name,h=be(Ms(f.params,p.keys.filter(b=>!b.optional).map(b=>b.name)),d.params&&Ms(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 Fn(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:A6(x)}}return e.forEach(d=>o(d)),{addRoute:o,resolve:u,removeRoute:a,getRoutes:i,getRecordMatcher:r}}function Ms(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 Is(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function A6(e){return e.reduce((t,n)=>be(t,n.meta),{})}function Ds(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,C6=/&/g,L6=/\//g,k6=/=/g,T6=/\?/g,X1=/\+/g,B6=/%5B/g,P6=/%5D/g,ec=/%5E/g,S6=/%60/g,tc=/%7B/g,O6=/%7C/g,nc=/%7D/g,M6=/%20/g;function oa(e){return encodeURI(""+e).replace(O6,"|").replace(B6,"[").replace(P6,"]")}function I6(e){return oa(e).replace(tc,"{").replace(nc,"}").replace(ec,"^")}function fo(e){return oa(e).replace(X1,"%2B").replace(M6,"+").replace(Z1,"%23").replace(C6,"%26").replace(S6,"`").replace(tc,"{").replace(nc,"}").replace(ec,"^")}function D6(e){return fo(e).replace(k6,"%3D")}function $6(e){return oa(e).replace(Z1,"%23").replace(T6,"%3F")}function R6(e){return e==null?"":$6(e).replace(L6,"%2F")}function ir(e){try{return decodeURIComponent(""+e)}catch{}return""+e}function F6(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 z6(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(""),Ar=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(Fn(4,{from:n,to:t})):f instanceof Error?i(f):d6(f)?i(Fn(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=G3(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(Ar),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=Fs(c[u-2]);return u>1&&Fs(d)===h&&f[f.length-1].path!==h?f.findIndex(Rn.bind(null,c[u-2])):p}),o=_(()=>r.value>-1&&U6(n.params,l.value.params)),a=_(()=>r.value>-1&&r.value===n.matched.length-1&&G1(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=I({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(Ar),r=_(()=>({[zs(e.activeClass,l.linkActiveClass,"router-link-active")]:n.isActive,[zs(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)}}}),Me=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 U6(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 Fs(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const zs=(e,t,n)=>e??t??n,q6=I({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=q6;function W6(e){const t=_6(e.routes,e),n=e.parseQuery||F6,l=e.stringifyQuery||$s,r=e.history,o=Qn(),a=Qn(),i=Qn(),c=Be(St);let u=St;wn&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const d=zr.bind(null,k=>""+k),f=zr.bind(null,R6),p=zr.bind(null,ir);function h(k,z){let R,K;return Y1(k)?(R=t.getRecordMatcher(k),K=z):K=k,t.addRoute(K,R)}function y(k){const z=t.getRecordMatcher(k);z&&t.removeRoute(z)}function w(){return t.getRoutes().map(k=>k.record)}function x(k){return!!t.getRecordMatcher(k)}function m(k,z){if(z=be({},z||c.value),typeof k=="string"){const E=Nr(n,k,z.path),C=t.resolve({path:E.path},z),T=r.createHref(E.fullPath);return be(E,C,{params:p(C.params),hash:ir(E.hash),redirectedFrom:void 0,href:T})}let R;if("path"in k)R=be({},k,{path:Nr(n,k.path,z.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)}),z.params=f(z.params)}const K=t.resolve(R,z),ge=k.hash||"";K.params=d(p(K.params));const v=J3(l,be({},k,{hash:I6(ge),path:K.path})),g=r.createHref(v);return be({fullPath:v,hash:ge,query:l===$s?z6(k.query):k.query||{}},K,{redirectedFrom:void 0,href:g})}function b(k){return typeof k=="string"?Nr(n,k,c.value.path):be({},k)}function O(k,z){if(u!==k)return Fn(8,{from:z,to:k})}function M(k){return G(k)}function U(k){return M(be(b(k),{replace:!0}))}function P(k){const z=k.matched[k.matched.length-1];if(z&&z.redirect){const{redirect:R}=z;let K=typeof R=="function"?R(k):R;return typeof K=="string"&&(K=K.includes("?")||K.includes("#")?K=b(K):{path:K},K.params={}),be({query:k.query,hash:k.hash,params:"path"in K?{}:k.params},K)}}function G(k,z){const R=u=m(k),K=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}),z||R);const C=R;C.redirectedFrom=z;let T;return!v&&Q3(l,K,R)&&(T=Fn(16,{to:C,from:K}),Je(K,K,!0,!1)),(T?Promise.resolve(T):Y(C,K)).catch(B=>Tt(B)?Tt(B,2)?B:Ve(B):he(B,C,K)).then(B=>{if(B){if(Tt(B,2))return G(be({replace:g},b(B.to),{state:typeof B.to=="object"?be({},ge,B.to.state):ge,force:v}),z||C)}else B=N(C,K,!0,g,ge);return le(C,K,B),B})}function L(k,z){const R=O(k,z);return R?Promise.reject(R):Promise.resolve()}function H(k){const z=wt.values().next().value;return z&&typeof z.runWithContext=="function"?z.runWithContext(k):k()}function Y(k,z){let R;const[K,ge,v]=G6(k,z);R=Vr(K.reverse(),"beforeRouteLeave",k,z);for(const E of K)E.leaveGuards.forEach(C=>{R.push(Ht(C,k,z))});const g=L.bind(null,k,z);return R.push(g),Ie(R).then(()=>{R=[];for(const E of o.list())R.push(Ht(E,k,z));return R.push(g),Ie(R)}).then(()=>{R=Vr(ge,"beforeRouteUpdate",k,z);for(const E of ge)E.updateGuards.forEach(C=>{R.push(Ht(C,k,z))});return R.push(g),Ie(R)}).then(()=>{R=[];for(const E of k.matched)if(E.beforeEnter&&!z.matched.includes(E))if(yt(E.beforeEnter))for(const C of E.beforeEnter)R.push(Ht(C,k,z));else R.push(Ht(E.beforeEnter,k,z));return R.push(g),Ie(R)}).then(()=>(k.matched.forEach(E=>E.enterCallbacks={}),R=Vr(v,"beforeRouteEnter",k,z),R.push(g),Ie(R))).then(()=>{R=[];for(const E of a.list())R.push(Ht(E,k,z));return R.push(g),Ie(R)}).catch(E=>Tt(E,8)?E:Promise.reject(E))}function le(k,z,R){for(const K of i.list())H(()=>K(k,z,R))}function N(k,z,R,K,ge){const v=O(k,z);if(v)return v;const g=z===St,E=wn?history.state:{};R&&(K||g?r.replace(k.fullPath,be({scroll:g&&E&&E.scroll},ge)):r.push(k.fullPath,ge)),c.value=k,Je(k,z,R,g),Ve()}let X;function j(){X||(X=r.listen((k,z,R)=>{if(!Zt.listening)return;const K=m(k),ge=P(K);if(ge){G(be(ge,{replace:!0}),K).catch(al);return}u=K;const v=c.value;wn&&o6(Ts(v.fullPath,R.delta),xr()),Y(K,v).catch(g=>Tt(g,12)?g:Tt(g,2)?(G(g.to,K).then(E=>{Tt(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,K,v))).then(g=>{g=g||N(K,v,!1),g&&(R.delta&&!Tt(g,8)?r.go(-R.delta,!1):R.type===gl.pop&&Tt(g,20)&&r.go(-1,!1)),le(K,v,g)}).catch(al)}))}let Pe=Qn(),ne=Qn(),ye;function he(k,z,R){Ve(k);const K=ne.list();return K.length?K.forEach(ge=>ge(k,z,R)):console.error(k),Promise.reject(k)}function Ye(){return ye&&c.value!==St?Promise.resolve():new Promise((k,z)=>{Pe.add([k,z])})}function Ve(k){return ye||(ye=!k,j(),Pe.list().forEach(([z,R])=>k?R(k):z()),Pe.reset()),k}function Je(k,z,R,K){const{scrollBehavior:ge}=e;if(!wn||!ge)return Promise.resolve();const v=!R&&a6(Ts(k.fullPath,0))||(K||!R)&&history.state&&history.state.scroll||null;return Un().then(()=>ge(k,z,v)).then(g=>g&&r6(g)).catch(g=>he(g,k,z))}const Se=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:M,replace:U,go:Se,back:()=>Se(-1),forward:()=>Se(1),beforeEach:o.add,beforeResolve:a.add,afterEach:i.add,onError:ne.add,isReady:Ye,install(k){const z=this;k.component("RouterLink",Me),k.component("RouterView",lc),k.config.globalProperties.$router=z,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>sn(c)}),wn&&!_t&&c.value===St&&(_t=!0,M(r.location).catch(ge=>{}));const R={};for(const ge in St)R[ge]=_(()=>c.value[ge]);k.provide(Ar,z),k.provide(aa,Hn(R)),k.provide(po,c);const K=k.unmount;wt.add(k),k.unmount=function(){wt.delete(k),wt.size<1&&(u=St,X&&X(),X=null,c.value=St,_t=!1,ye=!1),K()}}};function Ie(k){return k.reduce((z,R)=>z.then(()=>H(R)),Promise.resolve())}return Zt}function G6(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(Ar)}function Et(){return ce(aa)}const K6=({headerLinkSelector:e,headerAnchorSelector:t,delay:n,offset:l=5})=>{const r=Ke(),a=W3(()=>{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,U=!O||i<(((x=O.parentElement)==null?void 0:x.offsetTop)??0)-l;if(!(M&&U))continue;const G=decodeURIComponent(r.currentRoute.value.hash),L=decodeURIComponent(b.hash);if(G===L)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=I({name:"AutoCatalog",props:{base:{type:String,default:""},level:{type:Number,default:3},index:Boolean},setup(e){const t=t8(),n=Al({"/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:O})=>h-m||(bn(y,"/index.html")?-1:bn(b,"/index.html")?1:w===null?O===null?p.localeCompare(x):O:O===null?w:w>0?O>0?w-O:-1:O<0?w-O: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(Me,{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(Me,{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:O,path:M,title:U},P)=>s(Me,{class:"sub-catalog-item",to:M},()=>[e.index?`${h+1}.${b+1}.${P+1}`:null,O&&t?s(t,{icon:O}):null,U||"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=I({name:"ExternalLinkIcon",props:{locales:{type:Object,required:!1,default:()=>({})}},setup(e){const t=kt(),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=>{ql(l,{transform:"translate3d("+Hs(e)+"%,0,0)",transition:"all "+r+"ms "+o}),e===1?(ql(n,{transition:"none",opacity:"1"}),n.offsetWidth,setTimeout(function(){ql(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 ql(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:()=>{Us(document.documentElement,"nprogress-busy"),Us(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()}}(),ql=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))},Us=(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":"编译原理笔记","icon":"edit","link":"Chapter0 前言"}]},{"text":"数据库","icon":"edit","prefix":"数据库/","children":[{"text":"数据库笔记","icon":"edit","link":"Chapter1 Introduction"}]},{"text":"Linux内核","icon":"edit","prefix":"Linux内核/","children":[{"text":"VsCode+Qemu开发Linux内核","icon":"edit","link":"vscode qemu开发Linux内核"},{"text":"Linux内核Numa实现细节","icon":"edit","link":"NUMA Balance实现浅析"},{"text":"Patch:多层内存Numa Balancing","icon":"edit","link":"Patch解读/LWN针对多层内存系统重新进行NUMA平衡"}]},{"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)},qs=["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=I({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(qs.includes(f))return f;const p=f.split("-")[0];return qs.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 A(()=>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=I({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 A8=800,C8=2e3,L8={"/en/":{copy:"Copy code",copied:"Copied",hint:"Copied successfully"},"/":{copy:"复制代码",copied:"已复制",hint:"复制成功"}},k8=!1,T8=['.theme-hope-content div[class*="language-"] pre'],Ws=!1,jr=new Map,B8=()=>{const{copy:e}=b3({legacy:!0}),t=Al(L8),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=()=>Un().then(()=>new Promise(i=>{setTimeout(()=>{T8.forEach(c=>{document.querySelectorAll(c).forEach(r)}),i()},A8)})),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)},C8);jr.set(u,f)})};me(()=>{(!l.value||Ws)&&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||Ws)&&o()})})};var P8=bt({setup:()=>{B8()}});const S8=(e,t)=>t==="json"?JSON.parse(e):new Function(`let config,__chart_js_config__; -{ -${e} -__chart_js_config__=config; -} -return __chart_js_config__;`)();var O8=I({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=Be(),n=Be(),l=V(!0);return me(async()=>{const[{default:r}]=await Promise.all([A(()=>import("./auto-fa8841cf.js"),[]),new Promise(i=>setTimeout(i,800))]);r.defaults.maintainAspectRatio=!1;const o=S8(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 Wl=la("VUEPRESS_CODE_TAB_STORE",{});var M8=I({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=Be([]),r=()=>{if(e.tabId){const{title:u,id:d=u}=e.data[n.value];Wl.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];Wl.value[e.tabId]=p}},c=()=>{if(e.tabId){const u=e.data.findIndex(({title:d,id:f=d})=>Wl.value[e.tabId]===f);if(u!==-1)return u}return e.active};return me(()=>{n.value=c(),se(()=>Wl.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 I8=I({name:"CodeGroup",slots:Object,setup(e,{slots:t}){const n=V(-1),l=Be([]),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 D8=()=>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"})),$8=()=>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='',F8='',z8='';const Ur={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"},Gs={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=>({...Ur,...e,jsLib:Array.from(new Set([...Ur.jsLib||[],...e.jsLib||[]])),cssLib:Array.from(new Set([...Ur.cssLib||[],...e.cssLib||[]]))}),Bn=(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=>Gs[l].types.includes(o));if(r.length){const o=r[0];n[l]=[e[o].replace(/^\n|\n$/g,""),Gs[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)} -
`,U8=e=>`${e.replace("export default ","const $reactApp = ").replace(/App\.__style__(\s*)=(\s*)`([\s\S]*)?`/,"")}; -ReactDOM.createRoot(document.getElementById("app")).render(React.createElement($reactApp))`,q8=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;})({})`,W8=(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}}},G8=/