What Is a Compilation Error?

Compilation (compilation) 1. The process of generating a target program from a source program written in a source language using a compiler. 2. Use the compiler to generate the action of the target program. Compiling is to change the high-level language into a binary language that the computer can recognize. The computer only knows 1 and 0. The compiler changes the familiar language to binary. The working process of a compiler translating a source program into a target program is divided into five stages: lexical analysis; syntax analysis; semantic checking and intermediate code generation; code optimization; and target code generation. It is mainly used for lexical analysis and grammatical analysis, also known as source program analysis. Syntax errors are found during analysis, and prompt information is given.

Compilation (compilation) 1. The process of generating a target program from a source program written in a source language using a compiler. 2. Use the compiler to generate the action of the target program. Compiling is to change the high-level language into a binary language that the computer can recognize. The computer only knows 1 and 0. The compiler changes the familiar language to binary. The working process of a compiler translating a source program into a target program is divided into five stages: lexical analysis; syntax analysis; semantic checking and intermediate code generation; code optimization; and target code generation. It is mainly used for lexical analysis and grammatical analysis, also known as source program analysis. Syntax errors are found during analysis, and prompt information is given.
A compiled language is a programming language implemented with a compiler. It is not like a literal language, the interpreter runs the code line by line, but uses a compiler to compile the code to machine code before running it. In theory, any programming language can be compiled or literal. The difference between them is only related to the application of the program.
Chinese name
Compile
Foreign name
compilation
Subject
computer science
Use
Compile the program
Explanation
The process of writing a source program to produce a target program
Field
Compilation principle

Compile the compiler

A program that translates a program written in one programming language into an equivalent program in another language is called a compiler. [1]

Compiled lexical analysis

The task of lexical analysis is to process words composed of characters, scan the source program character by character from left to right, generate word symbols one by one, and transform the source program as a string into an intermediate program of word symbol strings. The program that performs lexical analysis is called a lexical analysis program or scanner.
The word symbols in the source program are analyzed by the scanner and generally produce a binary form: the word type; the value of the word itself. The word type is usually encoded using integers. If a type contains only one word symbol, then the word code for the word symbol completely represents its own value. If a species contains many word symbols, then for each of its word symbols, in addition to the species code, its own value should be given.
Lexical analyzers are generally constructed in two ways: manually and automatically. Manual construction can work with state diagrams, and automatic generation is achieved using a finite finite automaton. [2]

Compile parsing

The compiler's parser takes word symbols as input, analyzes whether the word symbol strings form grammatical units that conform to grammatical rules, such as expressions, assignments, loops, etc., and finally sees whether it constitutes a program that meets the requirements. Rule analysis checks whether each statement has the correct logical structure, and the program is the final grammatical unit. The syntax rules of the compiler can be described by context-free grammar.
There are two methods of grammatical analysis: top-down analysis and bottom-up analysis. From the top down, it starts from the beginning symbol of the grammar, deduces downward, and pushes out the sentence. The bottom-up analysis method uses the shift-in reduction method. The basic idea is to use a registered symbol to move out of the stack and move the input symbol one by one into the stack. When the top of the stack forms a production one In the candidate formula, this part of the top of the stack is reduced to the left neighbor symbol of the production.

Compile the intermediate code

Intermediate code is an internal representation of a source program, or intermediate language. The role of the intermediate code is to make the structure of the compiler more logical and clear. In particular, it can make the optimization of the target code easier to implement the intermediate code, that is, the intermediate language program. The complexity of the intermediate language lies between the source language and the Between machine languages. Intermediate languages come in many forms. Common ones are inverse Polish notation, quaternion, ternary, and tree.

Compile code optimization

Code optimization refers to performing multiple equivalent transformations on a program, so that starting from the transformed program, more efficient target code can be generated. The so-called equivalence means that the running result of the program is not changed. The so-called effective mainly refers to the shorter running time of the object code and the smaller storage space. This transformation is called optimization.
There are two types of optimization: one is to optimize the intermediate code after parsing, which does not depend on the specific computer; the other is to perform the target code generation, which is largely dependent on the specific computer. For the former type of optimization, it can be divided into three different levels of local optimization, loop optimization, and global optimization according to the scope of the program it involves.

Compile object code

Object code generation is the last stage of compilation. The object code generator transforms the parsed or optimized intermediate code into object code. The object code has three forms:
Machine language code that can be executed immediately, all addresses are relocated;
Machine language modules to be assembled. When they need to be executed, the connection loader connects them with some running programs and converts them into executable machine language codes.
Assembly language code must be compiled by the assembler to become executable machine language code.
The target code generation phase should consider three issues that directly affect the speed of the target code: one is how to generate shorter target code; the other is how to make full use of the registers in the computer to reduce the number of times the target code accesses the storage unit; Take advantage of the characteristics of the computer instruction system to improve the quality of the object code.

Compile form management

Various information of the source program is kept in various forms during the compilation process, and the work of each stage of compilation involves constructing, searching, or updating the relevant tables.
The common auxiliary part of the compiler. The various quantities in the source program are managed and registered in the corresponding form. The compiler obtains the required information by looking up the table during processing. [1]

Compile error handling

If an error is found in the source program during compilation, the compiler should report the nature of the error and the location of the error, and limit the impact of the error to the smallest possible extent so that the rest of the source program can continue to be compiled Going forward, some compilers can also automatically correct errors, which are done by error handlers.
It should be noted that, in general, the compiler only performs syntax checking and simplest semantic checking, and does not check the logic of the program.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?