作者Sunofgod ( )
看板Examination
标题[考题] 程式语言考古题
时间Wed Feb 25 19:45:50 2015
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不行?
因为是一元运算子?但符合语法不是吗?
感谢解答
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.254.101.133
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Examination/M.1424864752.A.A69.html
1F:推 alair99: 开始符号是S ##a是用开始符号w来导的吧 02/25 20:17
2F:→ Sunofgod: S->T,T>W,W>#W,#W>##W,##W>##a 02/25 20:31
3F:推 claudia4096: 这两题我支持你,只能说别尽信书罗 02/25 20:50
4F:→ APE36: 画出第三组 1搭B和2搭A?? 怎配出来?第一个不是A? 02/25 21:02
※ 编辑: Sunofgod (111.254.101.133), 02/25/2015 21:54:28
5F:→ Sunofgod: BBS上画这样是我极限了...请多包涵 02/25 21:55
6F:推 alair99: 对耶 我倒是没想到 你是对的 02/26 17:01