Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
简介
#247
指定 parser 解析模式为
PredictionMode.SLL
,以获得更好的性能。SLL 拥有更好的性能的同时,也对语法文件有更高的要求,它要求
主要变更
PredictionMode.SLL
性能变化
环境信息
npx envinfo --system --binaries
antlr4ts 运行时
迁移到 antlr4ng 运行时,并使用默认模式解析
antlr4ng 指定解析模式为 LL 模式
antlr4ng 指定解析模式为 SLL 模式
语法文件优化纪要
SLL 模式与 LL 模式相比,拥有更快的解析速度,但是相应的 SLL模式在遇到某些情况时,可能无法正确的处理,这主要集中在
左递归
即一个规则直接或间接地引用自身作为其可能的第一个元素,此问题可能通过重写语法解决
具有相似前缀的选择
这种情况可以通过合并前缀相似的备选分支来解决,但是某些情况下,合并备选分支会降低准确性,这种情况很难处理。
高度模糊的语法
此时
a_expr.a_expr.a_expr
可能全部被匹配为expr_list
从而导致报错。此问题可以通过重写语法解决