精華區beta ACMCLUB 關於我們 聯絡資訊
This problem is mainly parsing a contex free grammer. First you should notice that white space and newline characters can be any where in the input, so every white space and newline should be ignored. Then write a function for each rules in the grammer. If a rule contains another rule(may be itself), it recursively calls that function for that rule. In this grammer, whenever their is a choice in one rule, you can always distinguish by their starting symbols, except the rule <cond>, which has a right recursion. Next you can build a parsing tree for each input (like a compiler). Or you can do the parsing everytime when needed (like a interpreter). -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: linux9