- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
10-PD
2009-2010第一学期 西安交通大学《编译原理》课件 Yinliang Zhao (赵银亮) Pushdown Automata Yinliang Zhao Xi’an Jiaotong University 2013 Pushdown Automata A PDA is an automaton equivalent to the CFG in language-defining power. Only the nondeterministic PDA defines all possible CFL’s. But the deterministic version models parsers. Most programming languages have deterministic PDA’s. Intuition: PDA Think of an ?-NFA with the additional power that it can manipulate a stack. Its moves are determined by: The current state (of its “NFA”), The current input symbol (or ?), and The current symbol on top of its stack. Intuition: PDA – (2) Being nondeterministic, the PDA can have a choice of next moves. In each choice, the PDA can: Change state, and also Replace the top symbol on the stack by a sequence of zero or more symbols. Zero symbols = “ pop.” Many symbols = one “ pop” and then sequence of “pushes.” PDA Formalism A PDA is described by: A finite set of states (Q, typically). An input alphabet (?, typically). A stack alphabet (?, typically). A transition function (?, typically). A start state (q0, in Q, typically). A start symbol (Z0, in ?, typically). A set of final states (F ? Q, typically). Conventions a, b, … are input symbols. But sometimes we allow ? as a possible value. …, X, Y, Z are stack symbols. …, w, x, y, z are strings of input symbols. ?, ?,… are strings of stack symbols. The Transition Function Takes three arguments: A state, in Q. An input, which is either a symbol in ? or ?. A stack symbol in ?. ?(q, a, Z) is a set of zero or more actions of the form (p, ?). p is a state; ? is a string of stack symbols. Actions of the PDA If ?(q, a, Z) contains (p, ?) among its actions, then one thing the PDA can do in state q, with a at the front of the input, and Z on top of the stack is: Change the state to p. Remove a from the front of the input (but a may be ?). Replace Z on the top of the stack by ?. Example: PDA Design a PDA to accept {0n1n | n 1}. The states: q = start state. W
文档评论(0)