Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑这个表达式:
3 + 2 + 2 * 2 = ?
会是14吗?
不,这就是你在从左到右的评估中得到的。LL 解析器将构建与 LR 解析器相同的解析树,
+ / \ 3 + / \ 2 * / \ 2 2
并将其评估为
(+ 3 (+ 2 (* 2 2))
如您所料,这是 9。
LL 解析器的特别之处在于,对于受限制的语法,它们总是可以从左到右进行有限的前瞻。这使它们易于描述和解析;一些 Pascal 是最常见的语言之一,即 LL。
您可以查看有关最左派生的 Wiki文章。