简体   繁体   中英

Converting a Context-Free Grammar to a PDA

I am attempting to convert the following CFG to a pushdown automaton:

S → AS | A
A → 0A | 1B | 1
B → 0B | 0

I'm not really sure how to approach this problem, or the problem of CFG->PDA in general.

You may use JFlap application to do it for you. http://www.jflap.org/ Beyond this there are several other interesting functionalyties in that application that will help you study formal languages. I've been using it for about two weeks and I'm loving it.

Conversation of Context free grammar to Pushdown automata: Steps to convert CFG to Pushdown automata: Step-1:The first symbol on R.HS production must be a terminal symbol.

Step-2:Convert the given productions of CFG into GNF.

Step-3:The PDA will only have one state {q}.

Step-4:The initial symbol of CFG will be the initial symbol in the PDA.

Step-5:For non-terminal symbol, add the following rule: δ(q, ε, A) = (q, α)
Where the production rule is A → α.

Step-6:For each terminal symbols, add the following rule: δ(q, a, a) = (q, ε) for every terminal symbol

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM