This is a simple simulator for Turing Machines (TM) and Pushdown Automata (PDA).
Use the following command to compile the code:
cmake -S . -B build
cmake --build buildto compile.
The binary file will be in the bin/ directory.
./bin/fla <path_to_grammar_file> input_stringUsing
#Q = {q0, q1, q2, ...}to define the set of states.
Using
#S = {a, b, c, ...}to define the set of input symbols.
Using
#G = {a, b, c, ...}to define the set of stack symbols.
Using
#q0 = q_initto define the initial state.
Using
#z0 = zto define the stack start symbol.
Using
#F = {q_accept, q_reject}to define the set of final states.
Taking
q 0 Z q1 XXZas an example, the transition function is defined as follows:
- The first symbol is the current state, which is
qin this case. - The second symbol is the current input symbol, which is
0in this case. - The third symbol is the current stack symbol, which is
Zin this case. - The fourth symbol is the next state, which is
q1in this case. - The fifth symbol is the stack symbol to be pushed to the stack, which means the top of the stack would be
XXZin this case.
If the input symbol is
$\epsilon$ use_to represent it.
The line starting with ; will be ignored.
./bin/fla <path_to_to_grammar_file> input_stringIf you want to use the verbose mode, you can add the -v option:
./bin/fla -v <path_to_grammar_file> input_stringThe verbose mode will print the current state, the current input symbol, the current tape status, and the current head position.
Using
#Q = {q0, q1, q2, ...}to define the set of states.
Using
#S = {a, b, c, ...}to define the set of input symbols.
Using
#G = {a, b, c, ...}to define the set of tape symbols.
Using
#q0 = q_initto define the initial state.
Using
#B = _to define the blank symbol. The symbol _ refers to blank
Using
#N = 2to define the number of tapes.
Using
#F = {q_accept, q_reject}to define the set of final states.
Taking
q 01 __ rl rejectas an example, the transition function is defined as follows:
- The first symbol is the current state, which is
qin this case. - The second symbol is the current tape symbols , which means the first tape has
0and the second tape has1. - The third symbol is the tape symbols afterwards, which means the first tape has
_and the second tape has_. - The fourth symbol is the direction of the head, which is
rlin this case. The first head will move to the right and the second head will move to the left. - The fifth symbol is the next state, which is
rejectin this case.
If the input symbol is
$\epsilon$ use_to represent it. You can use*to represent any symbol in the tape alphabet.
The line starting with ; will be ignored.