{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

key5 - Key for HW 5 Thanks to Siun-Wai Seow His submission...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Key for HW 5 : Thanks to Siun-Wai Seow. His submission was used as the basis for this key. I have modified some solutions for pedagogical reasons. Larry W. Each problem is worth 5 pts.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3.5.1 Describe how to make the following modifications to the lex program of Fig 3.23: a) Add the keyword while. …. %% {ws} { } if {return(IF)} then {return(THEN)} else {return(ELSE)} while {return(WHILE)} %% …. 4.2.2 Repeat Exercise 4.2.1 for each of the following grammars and strings: a) S -> 0 S 1 | 0 1with strings 000111 a) Give a leftmost derivation for the string. S -> 0 S 1 => 0 0 S 1 1 => 0 0 0 1 1 1 b) Give a rightmost derivation for the string S -> 0 S 1 => 0 0 S 1 1 => 0 0 0 1 1 1
Background image of page 2
c) Give a parse tree for the string d) Is the grammar ambiguous or unambiguous? Justify your answer. Grammar is unambiguous. Non terminal S can only occur one time after each expansion, hence there is no room for ambiguity (only one parse tree). e) Describe the language generated by this grammar.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}