Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program for a deterministic push-down automata simulator. In this case,

ID: 645483 • Letter: W

Question

Write a program for a deterministic push-down automata simulator. In this case, though, your simulator should include a stack that follows the rules of a push-down automata. Keep in mind that you will need to change your input file so that the transitions are of the kind , I want this to be as general as possible, with the machine defined in an external text file. The output of this can be the same as the DFSM simulator. Simply indicate whether the machine accepts or rejects each input string. In java .

Explanation / Answer

hope it may helps you...

As the simulator is built in Java, a Java runtime environment is needed to run the simulator. To run the simulator type "java main" at the command prompt under the directory in which the class files are stored.

At this point you shall see the initial frame as shown in figure 1. At this point you have two options : you can either choose to load a PDA, or to load a context free grammar. If you click on the "Load PDA" button, you shall see a File chooser dialog ( figure 2), which shall ask you to choose a PDA description file (extension ".pda"). Or if you click on the "Load CFG" button, a File chooser dialog shall appear which shall ask you to choose a CFG description file (extension ".cfg"). It shall then load the CFG and build an equivalent PDA.

You select and open the appropriate file. The format for the file is described later. The simulator will load and display the states of the machine and the transitions between the states (see figure 3). A near-optimal heuristic is used to distribute the states in the drawing area. The start state is drawn in red and the final state(s) is/are drawn with two concentric circles. The stack is initialized with the start stack symbol. The title of the description file (typically describing the language is shown at the head of the frame).

Now, you enter an input string in the text box. If you do not enter anything, the input string shall be taken to be the empty string. Now you have an option to press the following two buttons :

The "Retrace" button allows you to view the deterministically, the path taken by the PDA to accept a string. At any point, the current state, current stack top and the current input head position are colored blue. (figure 5) The "Reset" button resets the state of the PDA back to its starting state( including stack and input tape). Then you can input another string and simulate

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote