http://wwwc.moex.gov.tw/ExamQuesFiles/Question/094/035335200.pdf
第四題~寫出字串所有的剖析樹
字串 if a then if b then goto x else if c then goto y else goto z
我簡化一下 if(1) if(2) else(A) if(3) else(B)
我的參考書是2013胡世雄的程式語言 他只畫了兩棵樹
第一組 2搭A和3搭B
第二組 1搭A和3搭B
但我自己可以畫出第三組 1搭B和2搭A
<stm>
<if stm>
(1) (B)
if <bexp> then <stm> else <stm>
| | |
a <if stm> goto z
| | | | | |
if <bexp> then <stm> else <stm>
(2) | | (A) |
b goto x <if stm>
| | | |
if <bexp> then <stm>
| |
c goto y
http://wwwc.moex.gov.tw/ExamQuesFiles/Question/100/100060_34430.pdf
第六題的第一小題 要寫出符合語法且長度不超過3的所有句子
書上給的答案是 a,#a,a!a,a@a 但為什麼##a不行?
因為是一元運算子?但符合語法不是嗎?
感謝解答