Question: Programming Assignment: DPDA Simulation Write a program that allows a user to enter a description of a deterministic pushdown automaton followed by a sequence of

Programming Assignment: DPDA Simulation

Write a program that allows a user to enter a description of a deterministic pushdown automaton followed by a sequence of input symbols. After each input symbol the program will display the current state and the contents of the stack. At the end of input, the program will indicate whether the dpda ended in an accepting state.

Details

The states for your PDA will be labeled with the integers 0, 1, 2, ..., n. State 0 will be the start state. The alphabet will consist of single printable ASCII characters other than the period character. Input consists first of an integer specifying the number of states, white space, and then a string containing the alphabet symbols for the dpda. The stack alphabet will be defined implicitly by the transition function with dollar sign, '$', as the initial symbol on the stack. The transition function is coded on a series of lines as follows. Each line contains the arguments and results for one evaluation of the transition function. Each entry consists of five components, the current state, the input symbol, the symbol on top of the stack, the new state, and the string of symbols to push onto the stack, separated by white space. If the nothing is to be pushed onto the stack, the entry is the period, '.'. The entries may be coded in any order. Omitted entries lead to a trap state. A line containing -1 indicates the end of the transition function entries. The transition function values are followed by a line with a list of numbers specifying the final states ending with -1 as a sentinel.

.Sample DPDA description for an bn

4 number of states = 4

ab alphabet, {a, b}

0 a $ 1 A$ transition ? (0,a,$) = (1,"A$")

1 a A 1 aA transition ? (1,a,A) = (1,"aA")

1 a a 1 aa transition ? (1,a,a) = (1,"aa")

1 b a 2 . transition ? (1,b,a) = (2, ?)

1 b A 3 . transition ? (1,b,A) = (3, ?)

2 b a 2 . transition ? (2,b,a) = (2, ?)

2 b A 3 . transition ? (2,b,A) = (3, ?)

-1 end of transition function

1 3 - 1 final states: {1, 3}

Execution

After the DPDA description has been entered, the program will display the start state and initial stack. The program will then repeatedly prompt for an input character and display the new current state followed by the contents of the stack as a string. This process continues until end of input or until the DPDA gets stuck. At this point print a message indicating whether the string was accepted or not

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!