質問

Im talking about Context Free Languages(CFG).

Why is left most derevation is so usuful?
What can it do better than just 'regular derevations'? (Which are less common in the text books..)

役に立ちましたか?

解決

Before anyone sends you away saying this is not a programming question, the answer does have programming significance.

The leftmost derivation is important because it is the one effectively constructed by a top-down parser (e.g. LL recursive descent or deterministic pushdown automaton with lookahead).

The other reason it's helpful is that for any resulting parse tree, the leftmost derivation is always unique. For an unambiguous grammar, therefore, the leftmost derivation is also unique for any sentence derivable by the grammar.

Uniqueness is in general a very useful tool for proving things. In this case it helps you reason about grammars, how to manipulate them (i.e. remove ambiguity, left factor, remove left recursion, and other transformations useful for producing top-down parsers) and convince yourself the manipulations are correct for your purpose.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top