Docsity

Finite Automata Interpreter - Organization Programming Language | CMSC 330, Study Guides, Projects, Research of Programming Languages

Partial preview of the text

Download Finite Automata Interpreter - Organization Programming Language | CMSC 330 and more Study Guides, Projects, Research Programming Languages in PDF only on Docsity!

CMSC 330: Organization ofProgramming Languages Project 2 – Finite Automata Interpreter

CMSC 330^

Overview •^ Write Ruby program to implement finite automata^ – Compose automata representing NFAs^ • Concatenate• Union• Closure^ – Convert automata representing NFAs to onesrepresenting DFAs^ • Subset construction^ – Minimize automata representing DFAs^ • Hopcroft reduction

CMSC 330^

Starting Ruby Code – fa.rb •^ Interpreter and stack^ – Reads commands, operates on stack^ def interpreterdfaStack = [ ]loop do

case wordwhen /SIZE/

// SIZE command f = dfaStack.last

// look at top automata on stack puts f.num_stateswhen /DFA/^

// DFA command f = dfaStack.pop

// take top automata on stack f2 = f.toDFA

// make it into DFA dfaStack.push f

// push result back on stack

  • You need to implement functions called by interpreter

CMSC 330^

Input Format •^ Commands to interpreter^ – Consisting of^ • Symbols in alphabet

  • A, b, c • Operators –^. | * • Commands to interpreter – SIZE, DFA, PRINT, MINIMIZE, DONE • Input strings to be tested – Example • a a a |. DFA PRINT "" "a" "aa" "aaa" DONE

CMSC 330^

Example Session •^ Input^ – a a a |. DFA PRINT "" "a" "aa" "aaa" DONE •^ Output^ % Start 8% Final { 10 }% States { 8 9 10 }% Alphabet { a }% Transitions {% (8 a 9)% (9 a 10)% }RejectReject aAccept aaReject aaa

CMSC 330^

Administration •^ Project description & files^ – Download from class web page •^ Due midnight Thursday, Mar 12

th

– 10% penalty for 1 day late • Submit fa.rb to submit server – submit.cs.umd.edu • Public test cases – Sample inputs & outputs available