8
Left Most Derivation
の意味は、L
のLL Parser
にあります。左からの派生は何を意味していますか?
最も簡単な例で説明してください。
私は左端の導出を説明する以下の写真を見たが、私はそれを理解していない:
Left Most Derivation
の意味は、L
のLL Parser
にあります。左からの派生は何を意味していますか?
最も簡単な例で説明してください。
私は左端の導出を説明する以下の写真を見たが、私はそれを理解していない:
文法規則は、非終端記号と終端記号で左側に表示されます。非終端記号は大文字でなければならず、その他の記号は通常は終端記号です。この例では、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.
ほとんどの派生は、あなたが適用できる最も左の場所に常にルール#を適用することを意味します。だから私はちょうど 'ルールN - > N D'と言うことができ、あなたができる最も左の場所にそれを適用することを知っています。それがRRパーサーであれば、それは可能な限り右の場所に適用されます。 – Patashu