Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the features of high-level language

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the characteristics of high-level language". The content of the explanation is simple and clear, and it is easy to learn and understand. let's follow the editor's train of thought to study and learn "what are the characteristics of high-level language"!

I. definition of programming language

In order to translate the program correctly, the compiler must first accurately define and describe the programming language itself. The description of language is considered in three aspects (to put it succinctly):

Grammar: a definition of the structure of a language (what kind of symbol sequence is legal); formal rules that define the morphology and grammar of a language

Semantics: describes the meaning of the language; defines the meaning of the words, symbols and grammatical units of the language

Pragmatics: to describe the language from the perspective of use. Define programming techniques and the use of language components that relate the basic concepts of a language to the outside world of the language, such as mathematical concepts or computer objects and operations.

For example, the informal description of the assignment statement s = 2 * 3.1416 * r * (r + h) is as follows:

Syntax: the assignment statement consists of a variable, followed by the assignment sign "=", followed by an expression

Semantics: first evaluate the value of the right expression of the statement, and then feed the result into the left variable

Pragmatics: assignment statements can be used to evaluate and save the value of an expression.

The definition of programming language is the basis of the implementation of language compiler and the user's manual of language users. Programming language is a symbolic language, that is, a notation system, which is mainly defined in three aspects: grammar, semantics and pragmatics.

1. Grammar

Any language program can be regarded as a string (finite sequence) on a certain character set (alphabet).

The grammatical rules of a language define the formal structure of a program. Grammatical rules refer to a set of rules that can be used to form and produce a formatted (legal) program. Some of these rules are called lexical rules, and the other part is called grammatical rules (or generation rules).

The alphabet is a limited character set, the characters in the character set are the characters that may appear in the language program, and they are part of the words of the language program.

Lexical rules define the rules for the formation of word symbols in language programs. That is, what kind of string is a legal word. The rules for the formation of words such as identifiers, numeric constants, operators, etc. The effective tools for describing lexical rules and lexical analysis are normal form, regular grammar and finite state automaton theory.

Grammar rules define the rules for the formation of grammar units in language programs. The grammatical units of a general language are expressions, statements, subprograms, functions, procedures, programs and so on. An effective tool for describing grammar rules and parsing is `context-free grammar.

Grammatical rules and lexical rules define the formal structure of the program, and the meaning of defining grammatical units belongs to semantic problems.

two。 Semantic meaning

For a language, it is not only necessary to give its lexical and grammatical rules, but also to define the meaning of its word symbols and grammatical units. This is the semantic problem. Without semantics, language is nothing more than a collection of symbols.

The semantics of language refers to a set of rules that can be used to define the meaning of a program. These rules are called semantic rules.

Each component (grammatical category) of a program language has two meanings: abstract logic and computer implementation. The former describes the logical meaning in mathematics, while the latter pays attention to the possibility and efficiency of its representation and implementation in the computer.

There are two ways to describe semantics. One is natural language description, but it has the defects of hidden errors, ambiguity and incompleteness. The other is formal description.

Formal semantics has many branches, such as operational semantics, algebraic semantics, axiomatic semantics, referential semantics and so on. they use different formal systems to describe semantic problems, but there is not a recognized formal system at present. therefore, there is no practical automatic semantic analysis method.

At present, the commonly used method of semantic analysis in compilers is a grammar-guided translation based on attribute grammar.

That is to say, the semantic analysis and translation of the identified grammatical units are carried out at the same time of grammatical analysis, and their attribute calculation rules are added to the defined grammatical category while describing the grammar. attributes can be the type, address, value, execution action and other information of the grammatical category.

However, in the undergraduate stage, the compilation principle does not involve too much formal semantics, but attribute grammar needs to be learned. Other contents may need to be studied at the graduate level.

II. General characteristics of high-level languages

1. Classification of high-level languages

High-level languages can be divided into the following categories:

First, mandatory language (Imperative Language), also known as procedural language, is characterized by command-driven and sentence-oriented. For example, C and pascal belong to this kind of language.

Second, applied language (Applicative Language), also known as functional, pays attention to the functions expressed by the program. The development process of the program is to construct more complex functions from the existing functions, and the execution of the program is the nesting or recursive call of the functions. For example, LISP and ML belong to this kind of language.

Rule-based language (Rule-based Language) is also called logical programming language. The execution process of the program is to check certain conditions (predicate logical expressions) and perform appropriate actions when the conditions are met. For example, Prolog belongs to this kind of language.

Fourth, object-oriented language (Object-Oriented Language) is characterized by supporting abstraction, encapsulation, inheritance, polymorphism and dynamic binding. The method of programming is to encapsulate data and operations together to form objects, expand and inherit simple objects to construct more complex objects, and get the execution of actions by sending messages to objects. Such as C++, Java, C# belong to this kind of language.

2. Data types and operations

A data type usually consists of the following three elements:

Properties used to distinguish types of data objects

The values that this type of data object can have

Operations that can act on data objects of type.

Programming languages from initial to complex:

Elementary data type

Numeric data, logical data (Boolean type), character data, pointer type.

Data structure

Array: an n-dimensional rectangular structure consisting of the same type of data. It can be divided into a definite array and a variable array; the inner information vectors of the array include: first address, dimension, upper and lower bounds of each dimension and element type.

Record: a structure consisting of data of known types (which can be different). The OFFSET of each domain in the record is its address displacement relative to the first address of the record.

Strings, tables, stacks, and queues: access-restricted composite structures for arrays or combinations of records.

About identifiers and names:

Although names and identifiers are often difficult to distinguish in form, the two concepts are essentially different. For example, for 'PI', we sometimes say it is a name and sometimes we say it is an identifier. An identifier is a meaningless sequence of characters, but a name has a clear meaning and attributes. PI as an identifier is nothing more than the juxtaposition of two letters, but PI, as a name, is often used to represent pi. The terms "local name" and "global name" are often used in other-level languages, but there are few "local identifiers" and "global identifiers".

3. Sentence and control structure

In addition to providing data representation, construction and operation mechanisms, programming languages also have executable statements. The control structure defines the execution order of statements, and the collection of control structures provided by the language has a great impact on the writing of readable and maintainable software.

(1) expression

Expressions are made up of operands and operators. Operands, also known as operands, can be data references or function calls; operators include arithmetic operators, logical operators, relational operators, etc., and there is a prescribed priority and association law between operators.

(2) statement

1. Assignment sentence: variable name = expression.

2. Control statements: unconditional transfer statements, conditional statements, loop statements, procedure call statements, return statements.

3. Description statement: used to define the nature of the name.

4. Simple sentences and complex sentences: sentence 1; statement 2; sentence 3; …...

Thank you for your reading. the above is the content of "what are the characteristics of high-level language". After the study of this article, I believe you have a deeper understanding of the characteristics of high-level language. the specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report