I haven't written a blog for a long time. I'm a lazy person, and I haven't done anything I think I can share recently. In the past few days, I just picked up a Compiler class library that has been intended but not done. I have accumulated a little experience. I have already posted some articles on Github and posted some sporadic articles on Weibo, but I finally realized that if I do not write a detailed document, others cannot learn, understand, and use it easily. I may even forget the little results I have made this study. Therefore, you must make up your mind to make up for your blog.
This is the first part of the series. First of all, I will introduce the purpose of this series. Compiler Technology has been the foundation of computer science for a long time. I think the importance of programming languages in software development is self-evident. So, why do we need to understand the internal principles of the compiler? There are many reasons: First, the compilation principle is a theory that has been well-developed for a long time. It covers many algorithms and is a very classic algorithm. From the front-end to the back-end, many algorithms designed by the compiler are powerful and fast. For example, we often use regular expressions to parse strings. By learning the compilation principles, you can deeply understand and apply these algorithms. For example, you can understand the language that a regular expression can represent, the language that it cannot represent, the best performance, and the poor performance, so that you can adopt it more scientifically in practice. Secondly, we are in an era of programming language explosion. every version of the language we are familiar with has new features, let alone the endless stream of new languages, scripts, DSL, and other formatted text-based protocols. Mastering some compilation principles can make us more active in this era. As we all know, Lao Zhao's recently developed Jscex introduces a beautiful asynchronous programming model to javascript. I believe that everyone not only wants to worship Lao Zhao, but also wants to know why he can develop such innovative technologies? In fact, a lot of knowledge comes from the compilation principle. Finally, I want to explain my learning objectives. As we all know recently, C #5 is coming soon. While lamenting the rapid changes, are there any regrets, that is, does the language feature not appear in C #5? I believe that some people are interested in the development of programming languages, so do not stay at the beginning of the article on the characteristics of each language. Let's start with your thoughts! Only by practice can you know whether your thoughts are correct or valuable. Practice is the best way to learn. I think you have learned the Compilation Principle Course at least during your college career, but there are still many practical problems worth the challenge. For example, the source files in C # and VB support Chinese, even variables and functions can use Chinese. How can we support Chinese in programming languages? When I was studying at a university, I may not have processed object-oriented languages. What is the difference between object-oriented languages? When there are many overload methods, how do I select the most appropriate one? Even further, how can we implement a programming language that supports generics? Lambda expressions capture variables and so on. As for the compiler backend, it is a broad topic. The technologies involved may help you to go deep into the operating system and hardware.
In most people's eyes, the compilation principle is a relatively difficult theoretical system. First of all, we must acknowledge that the compiler involves a wide range of technologies, each of which can be very in-depth and indeed like a bottomless pit. So this time I used a practical example to compile a simple programming language with basic functions. In this process, I learned about the technology one by one. In this way, you can learn and practice. It is recommended that you be interested in the practice and enjoy it. I will not fully repeat the theory in the compilation principles book, but will discuss the actual problems in modern compilers. I want my series to have high practical value.
This series will focus on VBF. Compilers, a compiler development library developed by me. This library involves the tools required by the front-end of the compiler, such as the construction of lexical analyzer and syntax analyzer, as well as auxiliary facilities for reading source files and recording compilation errors. It is developed by me. Some may ask why I don't need some ready-made tools, such as anlr? First, these ready-made tools have some minor faults and cannot satisfy me completely. Second, my VBF is a pure class library, unlike these tools, you only need to reference it in VB or C #, and then write it in the VB or C # syntax to write various compiler modules. I prefer the form of class libraries than relying on a bunch of tool frameworks. In addition, my class library also contains some of my small innovations, hoping to bring convenience to compiler development. In this series, I will take into account the implementation principles and usage of VBF. Compilers. If you want to practice it quickly, you can directly use my class library. If you do not like my class library, you can implement it yourself or use other methods instead. In short, you are interested in it. As an example, I will implement miniSharp, an extremely small subset of the C # language, in this series. I am not familiar with the syntax of miniSharp. If you are interested, you can expand it at will.
VBF. Compilers class library and example source code has been uploaded to Github: https://github.com/Ninputer/VBF please use git to download the latest code. (Note, don't worry. Although it is called "VBF", actually 100% is developed by C ......). In addition, you are welcome to pay attention to my micro blog: http://weibo.com/ninputer I will often broadcast on the development status, there are many other rich information ~
Well, let's look forward to my series of articles.