10-PDA.ppt

上传人:99****p 文档编号:1434876 上传时间:2019-02-27 格式:PPT 页数:43 大小:483KB
下载 相关 举报
10-PDA.ppt_第1页
第1页 / 共43页
10-PDA.ppt_第2页
第2页 / 共43页
10-PDA.ppt_第3页
第3页 / 共43页
10-PDA.ppt_第4页
第4页 / 共43页
10-PDA.ppt_第5页
第5页 / 共43页
点击查看更多>>
资源描述

1、Yinliang ZhaoXian Jiaotong University2013Pushdown Automata* 1Pushdown Automata A PDA is an automaton equivalent to the CFG in language-defining power. Only the nondeterministic PDA defines all possible CFLs. But the deterministic version models parsers. Most programming languages have deterministic

2、PDAs.Date 2Intuition: PDA Think of an -NFA with the additional power that it can manipulate a stack. Its moves are determined by:uThe current state (of its “NFA”),uThe current input symbol (or ), and uThe current symbol on top of its stack.Date 3Intuition: PDA (2) Being nondeterministic, the PDA can

3、 have a choice of next moves. In each choice, the PDA can:uChange state, and alsouReplace the top symbol on the stack by a sequence of zero or more symbols.uZero symbols = “ pop.”uMany symbols = one “ pop” and then sequence of “pushes.”Date 4PDA Formalism A PDA is described by: A finite set of state

4、s (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).Date 5Conventions a, b, are input symbols. But sometimes we allow a

5、s a possible value. , X, Y, Z are stack symbols. , w, x, y, z are strings of input symbols. , , are strings of stack symbols.Date 6The 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 o

6、f the form (p, ). p is a state; is a string of stack symbols.Date 7Actions 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:uChange the state to p.uRemove a from the front of the input (

7、but a may be ).uReplace Z on the top of the stack by .Date 8Example: PDA Design a PDA to accept 0n1n | n 1. The states: q = start state. We are in state q if we have seen only 0s so far. p = weve seen at least one 1 and may now proceed only if the inputs are 1s. f = final state; accept.Date 9Example: PDA (2) The stack symbols: Z0 = start symbol. Also marks the bottom of the stack, so we know when we have counted the same number of 1s as 0s. X = marker, used to count the number of 0s seen on the input.Date 10

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 课件讲义

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。