Key5 - 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

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 DocumentRight 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)
Background image of page 3

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

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

This note was uploaded on 11/18/2010 for the course CS 488 taught by Professor Wilson,l during the Spring '08 term at Old Dominion.

Page1 / 5

Key5 - 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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online