Consider the following BNF grammar that describes some of the \"technical electi
ID: 3749519 • Letter: C
Question
Consider the following BNF grammar that describes some of the "technical elective" courses allowed by the CS degree plan. <tech-electives> -> <tech-courses> <tech-courses> -> <tech-course> | <tech-course> <tech-courses> <tech-course> -> CS4390 | CS4371 | CS4373 | CS4330 | CS4317 | CS4339 | CS4342 You need to take at least five technical elective courses. However, no more than two courses of CS4390 (Special Topics), CS4371 (Independent Studies) and CS4373 (Internship) in any combination can count for technical electives. CS4390 CS4330 CS4317 CS4339 CS4342 -- ok: one special course CS4390 CS4390 CS4317 CS4339 CS4342 -- ok: two CS4390 CS4371 CS4317 CS4339 CS4342 -- ok: two CS4390 CS4390 CS4390 CS4330 CS4317 CS4339 -- ok: why? CS4390 CS4330 CS4317 -- not okay: < five CS4390 CS4390 CS4373 CS4330 CS4342 -- not okay: three Extend the given BNF grammar to an attribute grammar to specify the above rules.
Explanation / Answer
The Backus-Naur Form is a way of defining syntax. It consists of
• a set of terminal symbols
• a set of non-terminal symbols
• a set of production rules of the form
LHS = RHS.
LHS-> left hand side , RHS -> Right hand side.
The meaning of the production rule is that the non-terminal on the left hand side may be replaced by the expression on the right hand side.
According to the production rule, we can also right the above expression as follow
<tech-electives> ::= <tech-courses>
<tech-courses> ::=<tech-course> | <tech-course> <tech-courses>
<tech-course> ::= CS4390 | CS4371 | CS4373
| CS4330 | CS4317 | CS4339 | CS4342
<case-statement> ::=case <select five tech-course> of <course-list> | {; <course-list>} end
<select five tech-course> ::= if((CS4390<=2) and (CS4371) and (CS4373))
<course-list>::=<one special-courses> |<two-course> | <two-courses> |<Why particular-courses> |<Less than five-courses> |<Three-courses>
<one special-courses> :: = 'CS4390' | 'CS4330' | 'CS4317' | 'CS4339' | 'CS4342'
<two-course>:: = 'CS4390' | 'CS4390' | 'CS4317' | 'CS4339' | 'CS4342'
<two-courses>:: = 'CS4390' | 'CS4371' | 'CS4317' | 'CS4339' | 'CS4342'
<Why particular-courses>:: = 'CS4390' | 'CS4390' | 'CS4390' | 'CS4330' | 'CS4317'| 'CS4339'
<Less than five-courses>:: = 'CS4390' | 'CS4330' | 'CS4317'
<Three-courses>:: = 'CS4390' | 'CS4390' | 'CS4373' | 'CS4330' | 'CS4342'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.