Summer 2018 CS320 Midterm 4
Section A – Multiple Choice & True/False ( 6pts )
1)Which form of grammar checking do we perform during compilation/interpretation?
a.Context Free Grammar
b.Parsed Grammar Checking
c.Tokenization
d.Infix to Postfix
2)Which mechanism do we use to create OOP in Lua?
a.Dictionaries.
b.Aggregation.
c.Metatables.
d.Metalogic.
3)Which kind of parsing can take a very long time for a computer?
a.Bottom Up Parsing.
b.Shift Reduce Parsing.
c.Left Right Parsing.
d.Top Down Parsing.
Section B – Short Answer (25 words or less for each) ( 15pts )
1)Why do we perform Grammar checking on expressions in programming languages?
2)What does left and right recursion refer to when considering CFGs?
3)Which OOP mechanisms does Lua lack by default? (Without implementing a Metafunction)
4)Briefly describe what the Left and Right mean in Left-Right parsing?
5)How do we overcome potential ambiguity of parsing in bottom up parsers?
Section C – True/False ( 10pts/2pts each )
1)Given the following grammar, which of the following sentences are valid?
Rule 1) E -> 1E1
Rule 2) E -> 0EE
Rule 3) E -> E1
Rule 4) E -> eps
I.101001 TRUE FALSE
II.110111 TRUE FALSE
III.010011 TRUE FALSE
IV.0101 TRUE FALSE
V.110 TRUE FALSE
VI.001 TRUE FALSE
Section D – Program ( 10 pts )
Given the following Lua code, write the equivalent C++ code.
1)function F(a)
local b = a / 3
return a + b
end
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。