070_Problem_Set_1

070_Problem_Set_1 - CS143 Summer2011 Handout07 June24th,2011

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

View Full Document Right Arrow Icon
CS143 Handout 07 Summer 2011 June 24 th , 2011 Written Set 1: Lexical Analysis In this first written assignment, you'll get the chance to play around with the various  constructions that come up when doing lexical analysis.  This problem set will start off  by reviewing those constructions, then ask you to think critically about them.  You'll be  considering different algorithms for lexical analysis, along with some of the limitations  of what we presented in class.  In particular, you'll explore the various algorithms for  generating automaton-driven scanners and for resolving conflicts that might arise in  them. This assignment is due on July 6, so you have plenty of time to work on it.  However, I'd  suggest starting early while the material is still fresh in your mind.  Feel free to email us  with questions or to drop by office hours. Overall, this assignment is worth 10% of your total grade in the course.  Each problem is  weighted equally. Best of luck! Due: July 6 th  at 5 p.m. Problem One: Converting Regular Expressions Using   the   regular-expression-to-NFA   algorithm   we   covered   in   class,   convert   the  following regular expressions into NFAs.   In what follows, recall that * has highest  precedence,   then   concatenation,   then   |.     For   example,   ab|abc*   is   interpreted   as  (ab) | (ab(c*)).  Similarly, a|b* is (a) | (b*). i. ab*c ii. a|(b|c) iii. (a| )(bc*) ε
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem Two: Subset Construction Use the subset construction to convert the following NFAs into DFAs.  You can assume  that the alphabet is just the two letters  a  and  b . i. start a a, b b a ii. start a a b b b a iii. start a ε b a, b ε a a a
Background image of page 2
Problem Three: Maximal Munch Given the following tokens and their associated regular expressions, show what output  is produced when this  flex  scanner is run over the following strings: * %% a*b printf("1"); (a|b)*b printf("2"); c* printf("3"); i. aaabccabbb ii. cbbbbac iii. cbabc Problem Four: The Limits of Conflict Resolution In class we discussed one particular means for resolving conflicts that occur when using  regular expressions to scan an input.   Our approach was to use maximal-munch to  always choose the longest possible match at any point, then to break ties based on the  priorities of the regular expressions.  However, this is not the only way that we could  have resolved conflicts.   Recall from lecture our example with two types of regular  expressions: an expression for the keyword  for  and an expression for identifiers:
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 document was uploaded on 07/18/2011.

Page1 / 6

070_Problem_Set_1 - CS143 Summer2011 Handout07 June24th,2011

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