Road to soft test (5) --- concepts of compilation principles

Source: Internet
Author: User
Tags uppercase letter

From the composition principle to the compilation principle, are interrelated, and all the learning knowledge is progressing at different layers. The the successful Successful completion of the entire soft test knowledge can be developed from computer (composition principle) ---> Software Development (software project) ---> Software Algorithm Design (Data Structure) --> advanced language writing system ---> recognition on computer (Compilation Principle) ---> support for data behind various systems ---> (database) ----> --- application of network knowledge ----> network basics ......, The ability to concatenate all the soft exam textbooks is an indispensable condition for enriching the world today.

Of course, the machine language consists of 0 and 1, which is hard to read. Therefore, an assembly language is developed based on the machine language. Since assembly languages are still very difficult to use, advanced languages are developed. Today's programs and systems written in advanced languages are all compiled by computers to understand translation operations.


Compilation principles



Lexical

By basic characters (A, B ......) Rules for writing composed symbols (words)
Core: Whether words are correctly spelled


Syntax

A set of rules that consist of the basic symbols of the program language.
Core: Focus on Sentence Structure


Semantics

The meaning of the sentence according to the meaning of each syntax component (sentence), followed by the meaning of the sentence
Core: static, found during compilation
Dynamic, found during execution

Pragmatic


The design context is not suitable for use here.



Grammar Concept

The formal rules that describe the syntax structure of the narrative language are called grammar. (Language-based rules)

Basic Format:

α → β

Terminator (a, B, c ,.....)) Non-terminator (A, BC, D ,....) :

Terminator is atomic and cannot be divided. Non-Terminator, which can be further divided.

Non-terminator (Program)-> terminator (statement)

Terminator cannot appear in Alpha alone;

Grammar G is a four-tuple that can be expressed as G (Vt, vn, S, P)

Vt (terminal symbol) is a non-null finite set. Each element is called a Terminator.

Vn (nonterminal symbol) is a non-null finite set. Each element is called a non-Terminator and cannot be left alone.

S is a non-Terminator, called the start symbol. It must appear as the left part of at least one production formula.

P is a generative set (limited ).



Grammar Classification


0 grammar (phrase grammar, equivalent to a Turing machine)

Example: A → A, AA → A, AA →

Self-understanding: there must be at least one uppercase letter on the left and any letter on the right.

Type 1 grammar (contextual grammar)

Example: A → A, A → AB, AA → Bac (at least one uppercase letter on the left and the length on the left is less than or equal to the length on the right)

Note: α → ε also meets the requirements of type 1 grammar.

Self-understanding: the number of letters on the right of the generative expression must be greater than or equal to the number of letters on the left.

Type 2 Grammar (contextual grammar) -----> Grammar Analysis

Example: A → A, A → AB, a → Bac (uppercase letters must be left on the premise of type 1 grammar)

Self-understanding: the left side of the generative expression must contain uppercase letters.

Type 3 grammar (regular)

Self-understanding: that is, the right side of all production types either has no upper-case letters, and it is assumed that all production types must be on the right or left of lower-case letters, that is, they must be linearly consistent.



Example 1: A → A, A → AB, B → A, B → CB.

Precautions for inferring triplicate Syntax:

(1) In a grammar, either the left or the right are linear. The two rules cannot appear in the current syntax at the same time.


(2) There is only one non-terminator launched by a production formula. In a grammar, all non-terminologies are either on the right or on the right.


Self-active machine

NFA is not sure about the limited status of its own active machine

DFA determines the limited status of the Active Server

Differences between the two:
I personally think the biggest difference is that NFA has a null generative formula, and each symbol can have many generative formulas. However, the number of generative Formulas Required for each symbol in DFA is that there are several letters in the alphabet, the number of formulas in each State can only be less than or equal to the number of letters in the alphabet. And there cannot be a production formula with null values.


NDA ---> DFA conversion (can be shared next time)


Regular Expression: the regular expression that describes words in the program language.


① ε is a regular expression, which indicates the set L (ε) = {ε }.
② If A is a character on Σ, A is a regular expression, which represents the regular set L (A) = {}.
③ If the formal formula R and S respectively represent the formal set L (R) = L (s), then
(A) r | S is a regular expression, indicating the set L (r) ∪ L (s );
(B) R · S is a regular expression, indicating the set L (r) L (s );
(C) R * is a regular expression, indicating a set (L (r ))*;
(D) (R) is a regular expression that represents the set L (r ).


Conversion between generative and formal forms:


Self-understanding: this is a perfect combination of our mathematical formulas.


Summary

The compiled grammar is a standard. According to the standard, we only need to follow their standard. All things in time have certain rules. Of course, each language has its own standard standards, and the interconnectivity between knowledge makes the problem simple, become familiar, and become more interested in learning, more dynamic.


Next we will share with you the examples of key test sites ......



Road to soft test (5) --- concepts of compilation principles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.