当前位置:网站首页>费曼学习法(符号表)
费曼学习法(符号表)
2022-07-29 01:25:00 【每天告诉自己要努力】
符号表是编译过程中收集标识符信息的一种数据结构,一般有数组、链表、哈希表、二叉搜索树等等。相同的标识符会组织到一起,形成常量表、变量名表、函数名表等等。编译阶段会不断的生成符号表,不断使用符号表去进行解析,这也是编译过程最主要的一个开销。
符号表最主要的作用有三个:
①词法解析阶段:编译器会根据空格把一个一个标识符识别出来,然后在同一个作用域内,按照符号属性分类,记录到符号表中,每个标识符都和它的数据类型、作用域、名称、在内存中的地址等信息绑定到一起。主要就是收集符号的属性。
②语法解析阶段:通过收集到的符号表,进行语法树的建立,主要是为了检查上下文的合法性。比如说在同一个作用域内,搜集到相同名称的变量时,会报错,错误原因是重复定义变量。再比如说,在一个新作用域内,会生成一个新的符号表进行收集信息,那么假如又出现了一个内部作用域,就会再生成一个新的符号表进行收集,并且这个内部作用域对应的符号表会有一个指针,指向上一层外部作用域所对应的符号表,当需要解析这个标识符时,如果在当前作用域的符号表内找不到,就要顺着指针到上一层作用域对应的符号表中查找,如果一直到最外层作用域的符号表中都还是找不到,就会报错,错误信息是使用未声明的变量。主要的作用其实就是检验上下文的合法性。
③代码经过预处理、编译、汇编之后,生成的是目标文件,在linux下就是.O文件,这种文件携带有很多符号表,那么需要经过链接器,把这些.O文件打包,链接,生成最终的可执行二进制文件。那么这个过程就需要符号表,确定标识符在最终二进制文件中的相对地址和所在的内存布局区域。
边栏推荐
- Jetpack--了解ViewModel和LiveData的使用
- [the road of Exile - Chapter 5]
- Large scale web crawling of e-commerce websites (Ultimate Guide)
- IDEA 连接 数据库
- 数学建模——红酒品质分类
- What is browser fingerprint recognition
- 什么是作用域和作用域链
- 【ONE·Data || 链式二叉树】
- [MySQL] SQL aliases the table
- The solution of reducing the sharpness of pictures after inserting into word documents
猜你喜欢

(CVPR-2019)选择性的内核网络

Using local cache + global cache to realize user rights management of small systems

Wonderful use of data analysis

Planning mathematics final simulation exam I

JetPack--Navigation实现页面跳转

Establish an engineering template based on STM32 in keil -- detailed steps

Verilog procedure assignment statements: blocking & non blocking

Web crawler API Quick Start Guide

为什么 BI 软件都搞不定关联分析

Mysql存储json格式数据
随机推荐
Mathematical modeling -- heat conduction of subgrade on Permafrost
Covering access to 2w+ traffic monitoring equipment, EMQ creates a new engine for the digitalization of all elements of traffic in Shenzhen
Promise解决异步
The basic concept of transaction and the implementation principle of MySQL transaction
What is browser fingerprint recognition
试着换个角度理解低代码平台设计的本质
Qt源码分析--QObject(4)
Using local cache + global cache to realize user rights management of small systems
Leetcode/ and continuous shortest subarray greater than or equal to target
Planning mathematics final exam simulation II
Mathematical modeling -- the laying of water pipes
[the road of Exile - Chapter 2]
关于字符串处理的相关函数记录(长期更新)
JVM内存溢出在线分析Dump文件以及在线分析打开.hprof文件得出JVM运行报告jvisualvm怎么在线分析
Jetpack--了解ViewModel和LiveData的使用
Large scale web crawling of e-commerce websites (Ultimate Guide)
Number of consecutive subarrays with leetcode/ and K
Understand the working principle of timer in STM32 in simple terms
Mathematical modeling -- bus scheduling optimization
Lm13 morphological quantification momentum period analysis