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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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)* ) *
Background image of page 2
- 3 - How Does Lex Work? FLEX Regular Expressions C code Some kind of DFAs and NFAs stuff going on inside
Background image of page 3

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight 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
Background 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
Background image of page 7

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

View Full DocumentRight 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
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/06/2011 for the course CIS 332 taught by Professor Jin during the Spring '11 term at Shaw University.

Page1 / 24

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

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

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