Home Common Problem What is the system software that can process high-level language source programs into target programs?

What is the system software that can process high-level language source programs into target programs?

Jul 26, 2022 pm 02:58 PM
high level language Source program target program

The system software that processes high-level language source programs into target programs is the "compiler". A compiler refers to a translation program that translates a source program written in a high-level programming language into an equivalent target program in machine language format. The work process of a compiler translating a source program into a target program is divided into five stages: lexical analysis; syntax analysis; intermediate code generation; code optimization; target code generation; mainly lexical analysis and syntax analysis, also known as source program Analysis, if any grammatical errors are found during the analysis, a prompt message will be given.

What is the system software that can process high-level language source programs into target programs?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

System software that can process a source program written in a high-level language into a target program is a "compiler".

Compiler, compiling program, also called a compiler, refers to a translation program that translates a source program written in a high-level programming language into an equivalent target program in machine language format. . Compilers are translation programs implemented using a generative implementation approach. It takes a source program written in a high-level programming language as input, and a target program expressed in assembly language or machine language as output. The compiled target program usually also goes through a running stage in order to run with the support of the running program, process the initial data, and calculate the required calculation results.

The compiler must analyze the source program and then synthesize it into the target program. First, check the correctness of the source program and decompose it into several basic components; secondly, establish corresponding equivalent target program parts based on these basic components. In order to complete these tasks, the compiler must create some tables during the analysis phase and transform the source program into an intermediate language form so that it can be easily referenced and processed during analysis and synthesis.

Characteristics of the compiler:

The compiler must analyze the source program and then synthesize it into the target program. First, check the correctness of the source program and decompose it into several basic components; secondly, establish corresponding equivalent target program parts based on these basic components. In order to complete these tasks, the compiler must create some tables during the analysis phase and transform the source program into an intermediate language form so that it can be easily referenced and processed during analysis and synthesis.

The main data structures used in data structure analysis and synthesis include symbol tables, constant tables and intermediate language programs. The symbol table consists of the identifiers used in the source program together with their attributes, which include types (such as variables, arrays, structures, functions, procedures, etc.), types (such as integers, real types, strings, complex types, labels) etc.), and other information required by the target program. The constant table consists of the constants used in the source program, including the machine representation of the constants, and the target program addresses assigned to them. An intermediate language program is an intermediate form of program introduced before translating the source program into the target program. The choice of its representation depends on how the compiler will use and process it later. Commonly used intermediate language forms include Polish representation, triples, quadruples, and indirect triples.

Analysis of part of the source program is achieved through three steps: lexical analysis, syntax analysis and semantic analysis. Lexical analysis is completed by a lexical analysis program (also called a scanner), whose task is to identify words (i.e. identifiers, constants, reserved words, and various operators, punctuation marks, etc.), create symbol tables and constant tables, and convert The source program is converted into an internal form that is easy to analyze and process by the compiler. The syntax analyzer is the core part of the compiler. Its main task is to check whether the source program is grammatical according to the grammatical rules of the language. If it is not grammatical, a syntax error message will be output; if it is grammatical, the grammatical structure of the source program will be decomposed and an internal program in the form of intermediate language will be constructed. The purpose of grammatical analysis is to understand how words form sentences and how statements form programs. The semantic analysis program further checks the semantic correctness of legal program structures. Its purpose is to ensure the correct use of identifiers and constants, collect and save necessary information into symbol tables or intermediate language programs, and perform corresponding semantic processing.

The working process of a compiler

A compiler is also called a compilation system, which translates process-oriented source programs written in high-level languages ​​into The target program's language processor. The compiler's process of translating a source program into a target program is divided into five stages: lexical analysis; syntax analysis; intermediate code generation; code optimization; and target code generation. It mainly performs lexical analysis and syntax analysis, also known as source program analysis. During the analysis process, grammatical errors are found and prompt information is given.

(1) Lexical analysis

The task of lexical analysis is to process words composed of characters and 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. A program that performs lexical analysis is called a lexer or scanner.

The word symbols in the source program are analyzed by the scanner and generally produce binary formulas: word category; the value of the word itself. Word categories are usually encoded with integers. If a category contains only one word symbol, then for this word symbol, the category encoding completely represents its own value. If a category contains many word symbols, then for each of its word symbols, in addition to the category code, its own value should also be given.

Lexical analyzers are generally constructed in two ways: manual construction and automatic generation. Manual construction can work using state diagrams, automatic generation can be implemented using deterministic finite automata.

(2) Syntax analysis

The syntax analyzer of the compiler takes word symbols as input and analyzes whether the word symbol string forms a grammatical unit that conforms to grammatical rules, such as expression Formulas, assignments, loops, etc., and finally see if it constitutes a program that meets the requirements. Analyze and check whether each statement has the correct logical structure according to the grammatical rules used in the language. The program is the final grammatical unit. The grammatical rules of a compiler can be characterized by a context-free grammar.

There are two methods of syntax analysis: top-down analysis and bottom-up analysis. Top-down means starting from the starting symbol of the grammar and deducing downward to derive the sentence. The bottom-up analysis method uses the shift-in reduction method. The basic idea is: use a registered symbol first-in-last pop-out to move the input symbols into the stack one by one. When the top of the stack forms a production of a certain When selecting a candidate expression, the top part of the stack is reduced to the left-neighboring symbol of the production.

(3) Intermediate code generation

Intermediate code is an internal representation of the source program, or intermediate language. The function of the intermediate code is to make the structure of the compiled program logically simpler and clearer, especially to make the optimization of the target code easier to implement. The intermediate code is the intermediate language program, and the complexity of the intermediate language is between the source program language and the machine language. There are many forms of intermediate language, common ones are reverse Polish notation, tetragrams, ternary forms and trees.

(4) Code optimization

Code optimization refers to performing multiple equivalent transformations on the program so that starting from the transformed program, more effective goals can be generated code. The so-called equivalence means that the running results of the program are not changed. The so-called effective mainly refers to the short running time of the target code and the small storage space occupied. This transformation is called optimization.

There are two types of optimization: one is to optimize the intermediate code after syntax analysis, which does not depend on the specific computer; the other is to perform when generating the target code, which is to a large extent Depends on specific computer. For the former type of optimization, it can be divided into three different levels: local optimization, loop optimization and global optimization according to the scope of the program involved.

(5) Target code generation

Target code generation is the last stage of compilation. The target code generator converts the syntactically analyzed or optimized intermediate code into target code. There are three forms of target code:

① Machine language code that can be executed immediately, all addresses are relocated;

② Machine language module to be assembled, which is loaded by the connection when it needs to be executed The program connects them with certain running programs and converts them into executable machine language codes;

③ Assembly language codes must be compiled by an assembler to become executable machine language codes.

The target code generation stage should consider three issues that directly affect the speed of the target code: first, how to generate shorter target code; second, how to make full use of the registers in the computer and reduce the time for the target code to access the storage unit. times; the third is how to make full use of the characteristics of the computer instruction system to improve the quality of the target code.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What is the system software that can process high-level language source programs into target programs?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the characteristics of machine language, assembly language, and high-level language? What are the characteristics of machine language, assembly language, and high-level language? Apr 22, 2021 pm 04:00 PM

Characteristics of machine language: difficult to learn, understand, and understand; not universal; requires manual allocation of memory; and runs fastest. The characteristics of assembly language: the execution efficiency of the program is very high, it takes up little storage space, and it runs fast; it lacks versatility and the program is not easy to transplant. Characteristics of high-level languages: easy, certain versatility, and cannot be directly recognized and executed by computers.

What is the system software that can translate source programs written in high-level languages ​​into target programs? What is the system software that can translate source programs written in high-level languages ​​into target programs? Jan 22, 2021 pm 05:36 PM

System software that can translate source programs written in high-level languages ​​into target programs is a "compiler". A compiler is a translation program implemented using a generative implementation approach; it takes a source program written in a high-level programming language as input, and uses a target program expressed in assembly language or machine language as output.

Is assembly language a high-level language? Is assembly language a high-level language? Jan 30, 2023 pm 03:14 PM

Assembly language is not a high-level language; it is a low-level language like machine language. The difference between assembly language and high-level language: 1. The programming efficiency of assembly language is not high, while the programming efficiency of high-level language is higher than that of assembly language; 2. The readability of high-level language is higher than that of assembly language; 3. Assembly language is a Machine language, while high-level language is simplified and close to human natural language.

Is machine language a high-level language? Is machine language a high-level language? Aug 22, 2023 pm 05:13 PM

Machine language is not a high-level language. It is a low-level language used for computer hardware. It interacts directly with the underlying hardware of the computer. Machine language uses binary encoding to represent instructions and data. Each instruction corresponds to an operation or function of the computer hardware. , High-level language is a programming language that is closer to human language, providing higher abstraction capabilities and development efficiency. Machine language and high-level language play different roles in programming, each with their own advantages and applicable scenarios.

Released the world's first open source Hongmeng-based humanoid robot that supports JS/ArkTS high-level language Released the world's first open source Hongmeng-based humanoid robot that supports JS/ArkTS high-level language Nov 17, 2023 pm 08:07 PM

Kuai Technology reported on November 17 that this morning, Shenzhen Kaihong announced that the first KaihongOS humanoid robot based on the open source Hongmeng, jointly developed by it and Leju Robot, was officially released. According to the official introduction, this is an all-things intelligent teaching system equipped with KaihongOS and using robots as the carrier, covering multiple scenarios such as industry and services. This robot is equipped with a blood oxygen heart rate sensor, temperature and humidity sensor, infrared temperature sensor, human body induction sensor, NFC, OLED display, and LED lights. Through multiple joint sensing, it can intelligently execute decisions. At the same time, the robot can also be interconnected with mobile phones, tablets, computers and other devices in real time, getting rid of the traditional wire harness connection method and improving teaching efficiency. At the same time, this robot also has 17

What is the location of the main function in the c source program? What is the location of the main function in the c source program? Nov 19, 2020 am 11:06 AM

C language stipulates that in a source program, the position of the main function can be arbitrary; when executing a program written in C language, the main function is equivalent to the entrance to the execution program; regardless of the position of the main function in the entire process , a C program always starts execution from the mam function.

Feature analysis of Go language: Is it a high-level language? Feature analysis of Go language: Is it a high-level language? Mar 23, 2024 pm 04:00 PM

Feature analysis of Go language: Is it a high-level language? Go language is a statically strongly typed programming language developed by Google. It is designed to be simple, easy to read and write, and has efficient concurrency features. So, according to the definition of high-level language, let's analyze whether Go language is a high-level language. Definition of high-level language A high-level language is a programming language that is closer to human language than machine language. It has the characteristics of concise syntax, easy to read and write, and high level of abstraction, which allows programmers to focus more on solving the problem itself.

What is the program written in called source program? What is the program written in called source program? Aug 29, 2022 pm 04:47 PM

A program written in a "programming language" is called a source program. Source code refers to an uncompiled text file written according to certain programming language specifications. It refers to a series of human-readable computer language instructions, usually written in a high-level language. The ultimate goal of a computer source program is to translate human-readable text into binary instructions that a computer can execute. This process is called compilation and is completed through a compiler.