A configurable simulator for Deterministic Pushdown Automaton.
To configure the automaton you have to write a configuration txt file following this syntax:
beginT
startingState readChar readStackChar writeStackChar endingState
startingState1 readChar1 readStackChar1 writeStackChar1 endingState1
endT
beginAcc
acceptingState1
endAcc
string1
string2
string3
$
I.E:
- To move from state 0 to 1 while reading a from input, Z from stack and write ZA on stack you should write: 0 a Z ZA 1
- To move from state 1 to 1 while reading a from input, A from stack and delete top character from stack you should write: 1 a A | 1
Some examples can be seen in test files.
Additional informations:
- 0 is always the starting state.
- States is identified only by number.
- input0.txt contains PDA recognizing L = {a^nb^n | n>=1},
- input1.txt contains PDA recognizing L = {w2w'2 | where w is generated from (0,1)* and w' is w reversed},
- input2.txt contains well parenthesized language.
Code was written and compiled using WSL.
You can compile it yourself (I.E: gcc main.c -o PDA
) and use following command to test it (use your paths):
./PDA < ./inputs/yourTest.txt > ./outputs/outputOfYourTest.txt
.
To run it in verbose mode run: ./PDA -v < ./inputs/yourTest.txt > ./outputs/outputOfYourTest.txt
.
You can compile and test automatically by running bash test.sh
when in the project folder.
Due to the fact that this automaton is deterministic, it doesn't support epsilon transition (pay attention during PDA creation).