{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect3_lex2 - Lexical Analysis Part II CSC 435 Department of...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Lexical Analysis – Part II CSC 435 Department of CIS Shaw University
Image of page 1

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

View Full Document Right Arrow Icon
- 2 - Class Problem From Last Time q0 q2 q3 q1 1 1 1 1 0 0 0 0 Is this a DFA or NFA? What strings does it recognize? RE: ( (11)* 1 (00)* 0 (11)* 1 (00)* 0 ) | (00)* 0 (11)* 1 (00)* 0 (11)* 1 | (1 (0 (1 (00)* 1)* 0)* 1)* | (0 (1 (0 (11)* 0)* 1)* 0)* ) *
Image of page 2
- 3 - How Does Lex Work? FLEX Regular Expressions C code Some kind of DFAs and NFAs stuff going on inside
Image of page 3

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

View Full Document Right Arrow Icon
- 4 - RE NFA NFA DFA Optimize DFA DFA Simulation How Does Lex Work? Character Stream REs for Tokens Token stream (and errors) Flex
Image of page 4
- 5 - Regular Expression to NFA It’s possible to construct an NFA from a regular expression Thompson’s construction algorithm » Build the NFA inductively » Define rules for each base RE » Combine for more complex RE’s s f E general machine
Image of page 5

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

View Full Document Right Arrow Icon
- 6 - Thompson Construction S F ε empty string transition S F x alphabet symbol transition S F E1 A E2 Concatenation: (E1 E2) ε ε ε ε New start state S ε-transition to the start state of E1 ε-transition from final/accepting state of E1 to A, ε-transition from A to start state of E2 ε-transitions from the final/accepting state E2 to the new final state F
Image of page 6
- 7 - Thompson Construction - Continued S F E ε ε ε ε Closure: (E*) A S F E1 E2 ε ε ε ε Alteration: (E1 | E2) New start state S ε-transitions to the start states of E1 and E2 ε-transitions from the final/accepting states of E1 and E2 to the new final state F
Image of page 7

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

View Full Document Right Arrow Icon
- 8 - Thompson Construction - Example A F ε ε ε ε Develop an NFA for the RE: (x | y)* B C D E x y First create NFA for (x | y) A H ε ε ε ε B C D E x y S F G ε ε ε ε Then add in the closure operator
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern