@webwriter/automaton
Version:
Build, visualize, and interact with different kinds of automata (DFA, NFA, PDA).
20 lines (17 loc) • 517 B
text/typescript
import { StackOperation } from 'automata';
import { NFA } from '../../automata/nfa';
import { PDA } from '../../automata/pda';
export function NFAtoPDA(a: NFA) {
const pda = new PDA(
a.nodes.get(),
a.transitions.get().map((t) => {
return {
...t,
stackOperations: t.symbols.map(() => {
return { symbol: '', operation: 'none', condition: '' } as StackOperation;
}),
};
})
);
return pda;
}