filmov
tv
Context-Free Grammar to Pushdown Automaton Conversion (CFG to PDA)
![preview_player](https://i.ytimg.com/vi/ZImtQBMSW_Y/maxresdefault.jpg)
Показать описание
Here we show how to convert any CFG (context-free grammar) into a PDA (pushdown automaton). The key idea is to simulate the derivation of some string in the CFG on the stack itself of the PDA. The construction involves building 4 "base" states, and then self loops on the third state for each terminal. Initially push on a $, then the start variable, and pop the $ going to the 4th state. Then, add a series of transitions for every rule, popping the LHS variable, and then pushing on the RHS in reverse order.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
▶ADDITIONAL QUESTIONS◀
1. What would the PDA look like if the CFG were in Chomsky Normal Form?
2. What if the grammar were a regular grammar?
▶ABOUT ME◀
I am a professor of Computer Science, and am passionate about CS theory. I have taught over 12 courses at Arizona State University, as well as Colgate University, including several sections of undergraduate theory.
Комментарии