5. LALRPOP Tutorial LALRPOP 教程
https://lalrpop.github.io/lalrpop/tutorial/index.html
This is a tutorial for how to write a complete parser for a simple calculator using LALRPOP.
If you are unfamiliar with what a parser generator is, you should read Crash course on parsers first.
gpt --- 如果你不熟悉什么是语法分析器生成器,建议你先阅读《语法分析器速成课程》。
ms --- 如果您不熟悉解析器生成器是什么,您应该先阅读解析器速成课程。
Adding LALRPOP to your project
Parsing parenthesized numbers
Type inference
Handling full expressions
Building ASTs
Macros
Fallible actions
Error recovery
Passing state parameter
This tutorial is still incomplete. There are a few example grammars in the doc section of the repository.
gpt --- 这个教程仍然不完整。仓库的文档部分有一些示例文法,你可以参考这些示例。
ms --- 本教程仍未完成。存储库的 doc 部分有一些示例语法。
Here are some topics that I aim to cover when I get time to write about them:
gpt --- 以下是我计划在有时间时编写的主题:
ms --- 以下是我有时间写它们时打算涵盖的一些主题:
- Advice for resolving shift-reduce and reduce-reduce conflicts
gpt --- 解决移进-归约和归约-归约冲突的建议:
ms --- 解决 shift-reduce 和 reduce-reduce 冲突的建议
- Passing state and type/lifetime parameters to your action code (see e.g. this test invoked from here).
gpt --- 将状态和类型/生命周期参数传递给你的动作代码(例如,参见从这里调用的此测试)。
ms --- 将 state 和 type/lifetime 参数传递给你的操作代码(例如,请参阅从这里调用的这个测试)。
- Conditional macros (no good test to point you at yet, sorry)
gpt --- 条件宏(抱歉,目前没有合适的测试可以提供给你)。
ms --- 条件宏(抱歉,还没有好的测试可以指向您)
- Converting to use LALR(1) instead of LR(1) (see e.g. this test invoked from here).
gpt --- 将使用 LR(1) 转换为使用 LALR(1)(例如,参见从这里调用的此测试)。
ms --- 转换为使用 LALR(1) 而不是 LR(1)(例如,请参阅从此处调用的此测试)。
- Plans for future features
gpt --- 未来功能的计划
ms --- 未来功能的计划