高普考題庫
98 年 098年公務人員高等考試三級考試暨普通考試・程式語言
申論 4考慮下列的BNF 法則:〈conditional statement〉 ::= if 〈condition〉 then 〈statement〉| if 〈condition〉 then 〈statement〉 else 〈statement〉〈statement〉 ::= 〈assignment statement〉 | 〈conditional statement〉㈠假設C1 和C2 是由〈condition〉展開的程式碼,S1 和S2 是由〈statement〉展開的程式碼,畫出〈conditional statement〉:if C1 then if C2 then S1 else S2的語法樹(或稱剖析樹,parse tree),並解釋何謂「搖擺else 問題」(danglingelse problem)。(10 分)㈡舉出兩個方法,解釋程式語言如何在設計、實作、或使用時解決「搖擺else 問題」。(10 分)