Preliminary study on the principles of the avenue

zhaozj2021-02-16  37

This text is written for lazy people. The lazy person always wants to use a program to learn China's effort like NEO, huh, I also want. Have fun, you will want to learn, so I hope to write the words that can cause lazy fun, the whole body will go to build the fun, will there be an interested interest in study, right? I am such a lazy person.

Ok, let's talk about compilation. Compile is a language translation process, that is, translating the programming language into a machine language process. It is necessary to generate these major processes through lexical analysis, grammar analysis, semantic analysis, and code. In fact, it is very good to understand, just like the process of usually knowing the language, my name is neo. When you hear this sentence, you will first look at the words of this sentence, you are not recognized, if Name is NOME, you will I don't know this word, then you will pay attention to its syntax is wrong, if you are my neo name is, you will be able to scratch. Finally, when you recognize the words and syntax, you will understand this sentence means telling you that the other's name is NEO (semantic analysis). Suppose you are a Chinese translation, you will tell Chinese friends at this time, which foreigner is called NEO (code generation). The compiled process is also the same, such as translation C language: count = 3 compile, advance row words, press the word table recognition, then analyze the syntax according to the syntax table, and learn that it is the semantics 3 Store in a variable. Finally, according to the platform to generate machine instructions, MOV R1, 3, and complete the compilation.

It looks like this, it seems that it is not difficult: P

Next, let's talk about the example of writing a calculator with Lex, Yacc

转载请注明原文地址:https://www.9cbs.com/read-21724.html

New Post(0)