CS 370 Lab #2: (F)lex and Finite Automata

Name: ____________________________________________________

This lab is practice with regular expressions and finite automata in order to prepare you to do the main lexical analysis assignment. Do as much as you can during the lab; when you have a solution bring it up and the TA or I will look it over. Print a hard copy of this page. Fill in the blanks. Turn it in to the Dr. J or the TA along with a printed listing of the flex .l file you write for that part of the lab. Due: before next week's lab.

1. Flex Basics

2. Flex your assignment #1 away

3. Finite Automata

1. Draw the transition diagram for the finite automaton described below. Does the automaton below accept the string "abba"?
States: {S0, S1, S2, S3, S4}
Alphabet: {a, b, c, d}
Start State: S0
Final States: {S2, S4}
Move Function:
	move(S0, a) : S1
	move(S0, b): S2
	move(S0, c): S2
	move(S1, b): S2
	move(S1, d): S4
	move(S2, a): S0
	move(S2, b): S3
	move(S2, d): S4
	move(S3, a): S3
	move(S3, b): S3
	move(S3, c): S3
	move(S3, d): S3
	move(S4, b): S4

4. Draw a nondeterministic finite automata for...

C strings? (consider \n, \t, etc)





C float (real) number literals?






Problems (5) and (6) were deferred to lab #3, they are here for reference