The formal rules that describe the syntax structure of a language are called grammar. A grammar is a four-key pair.
There are a total of four types of grammar. If the syntax G = (VN, VT, P, S), each generative α → β has α (VN 1_vt )*, G is called the 0 grammar. The following syntax is obtained by extending the type 0 grammar:
Type 1 grammar: Any generative α → β (except S → ε) of G satisfies the number of symbols in the left Chinese method less than that in the right grammar, also known as context-related grammar, this means that the context must be considered for replacement of non-terminologies (eg: production formula such as α AB → Β CB). Assume that the production formula conforms to the production formula of type 1 grammar, the non-terminator A can be converted to C only when the left side is α and the right side is B ).
Type 2 Syntax: Any production formula of G, such as A → β, where a, vn, β, (VN 1_vt) *, context-independent syntax;
Type 3 Syntax: Any production formula of G, such as A → α or a → α B, where A, B, vn, A, VT, regular.
Derivation/reduction
The derivation is to start with the symbol S of the grammar and use the production formula (p) repeatedly to replace the non-terminator in the left part of the production formula with the text-sending symbol sequence in the right part, know the sequence location where a Terminator is generated. If α → βε p, γ, λ ε v *, then γ α λ => γ β λ is called a direct derivation of grammar G, it is also said that gamma α λ can be directly derived from gamma β λ, and vice versa is a direct reduction (inverse process of derivation ). If α 0 => α 1 =>... => α n, α 0 => α n.
Sentence/sentence/Language
If the start symbol of grammar G is s, that is, the string derived from S is a sentence pattern. If X is a sentence of S, and X is Vt *, X is a sentence of grammar G. A sentence contains only Terminator. Starting from the starting symbol of grammar g, all sentences that can be deduced become languages and are recorded as L (g ). If l (G1) = L (G2), G1 = G2.
Grammar Analysis notes