上下文无关语法
Context-Free Grammars
Palindrome Language
回文语言
递归定义
递归的定义
上下文无关语法的定义
上下文无关语言定义
Parse Tree Let G = ( V,T , S, P ) be a CFG. A tree is a parse tree for G if : 1. Each interior node is labeled by a variable in V 2. Each leaf is labeled by a symbol in T{}. Any labeled leaf is the only child of its parent. 3. If an interior node is labeled A, and its children (from left to right) labeled x1,x2, ,xk, Then A x1,x2, ,xk P .
语法树的定义
1。每个内部节点由V 中的变量标记。每个叶子用T{}中的符号标记。 任何标记的叶子是其父亲的唯一子。 3.如果内部节点标记为A,其子节点(从左到右)标记为x1,x2,,xk,则为Ax1,x2,,xkP。
Inherent Ambiguity 模糊继承
模糊性的例子
Simplification of CFG
上下文无关语法的简化
Eliminating -productions
Eliminating unit productions
Eliminating useless productions
乔布斯及标准范式
Pushdown Automata(PDA)
下推自动机
下推自动机图
正式的定义
转移函数和有限自动机不同,并且多了栈的状态符号集合,多了栈的初始状态。F为接受状态的集合。
Definition of DPDA
决定性的下推自动机
Instantaneous Description(ID)
瞬时描述
cc语言ifelse的例子
自动机等价性
前缀特性语言
prefix property of language There are no two distinct string x and y in the language such that x is a prefix of y . yes : wcwR . no : 0*
如果一个语言被有限自动机接受,那么它一定也会被确定性下推自动机接受
下推自动机和上下文无关语法上下文无关语言是等价的
上下文无关语法与下推自动机可以相互转化
Properties of CFL
2. Closure properties
3. Pumping lemma for CFL
上下文无关语言的特性
也是泵引理和封闭特性
字符串长度要大于n。和正则语言泵引理类似,但是多出了
注意相交并不封闭
和正则语言相交是封闭的
以上为第二章内容,主要了解上下文无关语言语法以及下推自动机的图表。