Compilation principle (HIT) 1

Compilation: The process of translating a high-level language into assembly language or machine language.

Source program-preprocessor-preprocessed source program-compiler-assembly language program-assembler-relocatable Machine code --- linker / loader ------ target machine code.

 

 SDT Grammar-Guided Translation

Zero, language and grammar

 1. the alphabet

Positive closure

Klin closure

string

Operation on the string-connection, power operation

2. Definition of grammar

G=(Vt,Vn,P,S)

Terminator, non-terminator, production set, start symbol

 

 

 

 

 

 3. Definition of language

Derivation:

Statute:

Sentence pattern: A sentence pattern can contain both terminal symbols, non-terminal symbols, and empty strings.

Sentence: a sentence pattern that does not contain non-terminal symbols.

Language (L (G)): The set of all sentences derived from the start symbol S of the grammar G is called the language generated by the grammar G, and is denoted as L (G).

4. Classification of grammar

Chomsky

Context-free grammar (CFG)

Regular grammar (RG): left linear grammar, right linear grammar

5. Analysis tree of CFG

The graphical representation of the derivation.

Phrase: Given a sentence pattern, the edge of each subtree of its analysis tree is called a phrase of the sentence pattern.

Direct phrase: If the subtree has only two nodes of father and son, then the edge of the subtree is called a direct phrase of the sentence pattern.

1. Lexical analysis

Main task: Scan the characters of the source program line by line from left to right, identify each word, and determine the type of word. Convert the recognized words into a unified in-machine representation-lexical unit (token) form.

token: <category code, attribute value>

 

Guess you like

Origin www.cnblogs.com/kmxojer/p/12750196.html