(まず第一に、これはハードウェアではありません。私はすべての答えを持っています)
私は単純な BNF 文法を持っています
<UNIT> ::= ( <CLAUSE> ) | a | b | c
<ITEM> ::= not <UNIT> | <UNIT>
<CLAUSE> ::= <CLAUSE> and <PHRASE> | <PHRASE>
<PHRASE> ::= <ITEM> | <ITEM> or <PHRASE>
and
演算子は左結合 (左再帰)
or
演算子は右結合 (今回は右再帰)
式 が与えられたときc and b or not a and ( not b or c )
、解析ツリーで一番右の「and」が上位にあるのはなぜですか?
ちなみに、c **and** b or not a and ( not b or c )
一番左が解析ツリーの上位にあるはずです。
私たちの教授はこの答えを提供しました:
Lispy 表記の解析ツリーを次に示します。
(clause (clause (clause (phrase (item (unit 'c'))))
'and'
(phrase (item (unit 'b'))
'or'
(phrase (item 'not'
(unit 'a')))))
**'and'** // is higher in parse tree
(phrase (item (unit '('
(clause (phrase (item 'not’(unit 'b'))
'or'
(phrase (item (unit 'c')))))
')' ))))