当前位置:网站首页>Programming language exercises (I)
Programming language exercises (I)
2022-07-24 16:46:00 【SakamataZ】
Can be in here Download Books, notes and answers .
welcome star/fork To participate in My compiler project
1.1
With C++ Language as an example :
a. Lexical errors
int a=$; //$ Report errors
b. Grammar mistakes
int c = .+ a; //. Wrong number
c. Static semantic error
int a=1;
int c=a+b;//b No definition
d. Dynamic semantic error
Access rights error , You may not report an error , But actually C++:“ Generate some code , Perform appropriate checks at runtime … The implementation of some rules may bring high 、 An unacceptable price , The implementation of language may not check them at all ”, in other words , This procedure " It's simply the wrong program "
The compiler is just as far as possible , Some dynamic semantic errors are detected , Static semantic errors can be detected . How much can be detected , It depends on the implementation of the language .
class Object
{
public:
int a;
};
int main() {
Object *b = (Object*)new Object;
delete(b);
cout << (*b).a;
}
e. Errors that violate language definitions
such , Instead of calling destructors, just free memory , The result will be an error that violates the language definition without the compiler running and reporting an error .
class Object
{
public:
int a;
};
int main() {
Object *b = (Object*)new Object;
free(b);
cout << (*b).a;
}
1.2
Compiled and interpreted languages have their own advantages . Interpretive languages have better performance , Compiled languages can bring more flexibility , And it can make a better diagnosis of the program .
1.3

1.4
Pascal division algorithm 
The time complexity is more reduced and higher .
1.5
make Dependency management will lead to some unnecessary compilation
such as :
Modification of local variables ; Local symbol table changes but does not affect other documents ; Character changes but no word changes, etc
1.6
lint Check C Potential errors in the program , Include ( But not limited to, ) Suspicious type combinations 、 Unused variables 、 Unreachable code and non portable code .lint It will produce a series of diagnostic information that programmers need to read carefully from beginning to end . Use lint Are the benefits of :1. It can check for errors that have been missed by the compiler ; 2. You can associate many files for error checking and code analysis , It has strong flexibility
1.8
I hope c++ Of static Assignment can be more convenient
But because c++ Of static Shared by all objects , Can only assign values outside the class
If you assign a value in the class , It is equivalent to changing this value every time you create a new object , It will definitely increase the complexity
1.9
Report errors
No,
If the semantic check of array out of bounds is added , Will increase O(n) Time complexity of .
1.11
Because we have to judge grammar , semantics , Whether it is right , Also check the boundary and access rights .
What can be found is abnormal errors , Cross the border, for example , Null pointer , overflow ; And logical errors cannot be found .
边栏推荐
- TCP protocol debugging tool tcpengine v1.3.0 tutorial
- 会议OA项目进度(一)
- 剑指 Offer 48. 最长不含重复字符的子字符串
- ZCMU--5023: 家庭划分(C语言)
- Interview question 01.02. determine whether it is character rearrangement
- Zcmu--5023: family division (C language)
- Concept of IP, classification of IP, IP multiplexing technology
- Simply use MySQL index
- MODIS data WGet Download
- regular expression
猜你喜欢

jvm类加载子系统

Jupyter uses tips

Thinkphp3.2.5 cannot jump to external links

Development dynamics | stonedb 2022 release milestone

剑指 Offer 22. 链表中倒数第k个节点

Axi protocol (3): handshake mechanism and implementation details of Axi architecture

EF LINQ Miscellany

EMQ Yingyun technology was listed on the 2022 "cutting edge 100" list of Chinese entrepreneurs
[redis] -1. two ways of setting up environment based on docker

我们为什么要推出Getaverse?
随机推荐
QT generation connection Library
1184. Distance between bus stops
工信安全中心牵头搭建数据流通平台 蚂蚁集团等厂商提供技术支持
Xxx.pro learning in QT
[LeetCode]75.颜色分类——题解(执行用时击败90% ,内存消耗击败 78%)
1024 happy holidays
会议OA项目进度(一)
804. Unique Morse code word
期盼已久全平台支持-开源IM项目OpenIM之uniapp更新
JS to implement a promise of promises/a+ specification
为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?
JUC源码学习笔记3——AQS等待队列和CyclicBarrier,BlockingQueue
【技术】uniapp之聊天室 demo
剑指 Offer 25. 合并两个排序的链表
Educational codeforces round 100 (rated for Div. 2) B. find the array solution
1163: SongGe's score splitting (C language)
ZCMU--5083: ly的数对(C语言)
EventLoop event loop mechanism
[leetcode]38. counting - problem solving (execution time beat 91%, memory consumption beat 97%)
AXI协议(1):AMBA总线介绍,AXI概念与背景介绍,AXI协议特点与功能