注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 用了十年的QQ号,第二次被..
 帮助

A hierarchy of grammars


2007-02-21 07:09:04
 标签:A of hierarchy grammars   [推送到技术圈]

 
Type 0: free or unrestricted grammars
These are the most general. Productions are of the form u –> v where both u and v are arbitrary strings of symbols in V, with u non-null. There are no restrictions on what appears on the left or right-hand side other than the left-hand side must be non-empty.
Type 1: context-sensitive grammars
Productions are of the form uXw –> uvw where u , v and w are arbitrary strings of symbols in V, with v non-null, and X a single nonterminal. In other words, X may be
replaced by v but only when it is surrounded by u and w . (i.e. in a particular context).
 
Type 2: context-free grammars
Productions are of the form X–> v where v is an arbitrary string of symbols in V, and X is a single nonterminal. Wherever you find X, you can replace with v (regardless of context).
Type 3: regular grammars
Productions are of the form X–> a or X–> aY where X and Y are nonterminals and a is a terminal. That is the left-hand side must be a single nonterminal and the right-hand side can be either a single terminal by itself or with a single nonterminal. These grammars are the most limited in terms of expressive power.
 
通过对产生式施加不同的限制,Chomsky将文法分为四种类型:
0型文法:对任一产生式α→β,都有α∈(VN∪VT)+, β∈(VN∪VT)*
1型文法:对任一产生式α→β,都有|β|≥|α|, 仅仅 S→ε除外
2型文法:对任一产生式α→β,都有α∈VN β∈(VN∪VT)*
3型文法:任一产生式α→β的形式都为A→aBA→a,其中A∈VN ,B∈VN ,a∈VT


上一篇 What are Derivations  下一篇 句型



    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: