《CPython Internals》阅读笔记:p118-p150

《CPython Internals》学习第 8 天,p118-p150 总结,总计 33 页。

一、技术总结

补充一些本人整理的关于 Context-Free Grammar(CFG) 的知识。

1.symbol(符号)

A mathematical symbol is a figure or a combination of figures that is used to represent a mathematical object(符号是一个数字或数字的组合,用来表示一个数学对象)。

symbols也称为character(字符), letter(字母),范围比较广,可以是 deciamal digits(十进制数,0,1,2,3,4,5,6,7,8,9), 也可以是letters(a,...,z, A,...,Z),还可以是 >, <, =, !等。

2.alphabet(字母表)

2.1.定义

An alphabet is a finite, nonempty set of symbols. Conventionally, we use the symbol ∑(sigma) for an alphabet.

2.2.示例

{0, 1},{a, ..., z}。

3.string(串)

3.1. 定义

A string (or sometimes 01ì) is a finite sequence of symbols chosen from some alphabet.

3.2. 示例

For example, 01101 is a string from the binary alphabet Σ = {0, 1}. The string 111 is another string chosen from this alphabet.

3.3.empty string(空串)

The empty string is the string with zero occurrences of symbols. This string, denoted ϵ, is a string that may be chosen from any alphabet whatsoever.

3.4. length of string

4.language(语言)

4.1. 定义

A set of strings all of which are chosen from some alphabet, where Σ is a particular alphabet, is called a language.

注:language 是 string 的集合。

4.2. 示例

{10, 11, 101, 111, 1011,...}

5. grammar(文法)

全称为 Context-Free grammar(上下文无关文法),简写为grammar(文法)。

G=(V, T, P, S)

注:G 是 grammar 的首字母。(V, T, P, S)称为四元组(及有四个元素的元组)。集合里面的元素是无序的,元组里面的元素是有序的——示例: {1, 2, 3, 4} 和 {4, 3, 2, 1}可以是相等的,但是 (V, T, P, S) 和 (S, P, T, V)是不相等的,因为顺序不一样。

5.1. V

V is a finite set of variables, also called sometimes nonterminals(非终结符) or syntactic categories(语法范畴).

5.2. T

T is a finite set of symbols that form the strings of the language being defined. We call this alphabet the terminals(终结符), or terminal symbols(终结符号).

5.3. P

P is a finite set of productions(产生式) or rules that represent the recursive definition of a language.

There is a finite set of productions or rules that represent the recursive definition of a language. Each production consists of:

(a) A variable that is being (partially) defined by the production. This variable is often called the head of the- production.

(b) The production symbol →.

(c) A string of zero or more terminals and variables. This string, called the body of the production, represents one way to form strings in the language of the variable of the head. In so doing, we leave terminals unchanged and substitute for each variable of the body any string that is known to be in the language of that variable.

5.4. S

One of the variables represents the language being defined; it is called the start symbol(开始符号).

二、英语总结(生词:0)

无。

关于英语的注解同步更新汇总到 https://github.com/codists/English-In-CS-Books 仓库。

三、其它

The Compiler章节简评:今日不想评。

四、参考资料

1. 编程

(1) Anthony Shaw,《CPython Internals》:https://book.douban.com/subject/35405785/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,122评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,070评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,491评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,636评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,676评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,541评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,292评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,211评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,655评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,846评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,965评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,684评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,295评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,894评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,012评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,126评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,914评论 2 355

推荐阅读更多精彩内容