sap*_*Pro 8 language-agnostic compiler-construction parsing
请帮助我了解什么叫Left Most Derivation第二个L在LL Parser.
用一个最简单的例子来解释它.
我看到下面的图片解释了左派的推导,但我不明白:
Inf*_*ies 10
语法规则显示在左侧,带有非终结符号和终端符号.非终结符号应为大写字母,其他所有符号通常为终结符号.在示例中,N和D是非终结的,0-9是终端.左派最左派总是使最左边的非终结符合语法规则.尝试格式化下面的示例.
N
=> N D --Replaces the first/left most/only (which is "N") with the N => N D rule
=> N D D --Replaces the first/left most nonterminal (which is "N") with the N => N D rule
=> D D D --Replaces the first nonterminal (which is "N") with the N => D rule
=> 1 D D --Replaces the first nonterminal ("D") with the D => 1 rule(our first terminal character!)
=> 1 2 D --Replaces the first nonterminal ("D") with the D => 2 rule
=> 1 2 3 --Replaces the first nonterminal ("D") with the D => 3 rule
-- Only terminal characters remain, derivation/reduction is complete.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6162 次 |
| 最近记录: |