简体   繁体   English

将上下文无关语法转换为 PDA

[英]Converting a Context-Free Grammar to a PDA

I am attempting to convert the following CFG to a pushdown automaton:我正在尝试将以下 CFG 转换为下推自动机:

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.我不太确定如何解决这个问题,或者一般来说 CFG->PDA 的问题。

You may use JFlap application to do it for you. 您可以使用JFlap应用程序为您完成此操作。 http://www.jflap.org/ Beyond this there are several other interesting functionalyties in that application that will help you study formal languages. http://www.jflap.org/除此之外,该应用程序还具有其他一些有趣的功能,可以帮助您学习形式语言。 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.上下文无关语法与下推自动机的对话:将 CFG 转换为下推自动机的步骤: 步骤 1:R.HS 产生式上的第一个符号必须是终端符号。

Step-2:Convert the given productions of CFG into GNF.步骤 2:将给定的 CFG 产生式转换为 GNF。

Step-3:The PDA will only have one state {q}.步骤 3:PDA 将只有一个 state {q}。

Step-4:The initial symbol of CFG will be the initial symbol in the PDA. Step-4:CFG的初始符号将是PDA中的初始符号。

Step-5:For non-terminal symbol, add the following rule: δ(q, ε, A) = (q, α) Step-5:对于非终结符号,添加以下规则:δ(q, ε, A) = (q, α)
Where the production rule is A → α.其中生产规则是 A → α。

Step-6:For each terminal symbols, add the following rule: δ(q, a, a) = (q, ε) for every terminal symbol Step-6:对于每个终端符号,添加以下规则:对于每个终端符号,δ(q, a, a) = (q, ε)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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