2011年8月27日星期六

Grammar

Help edit Baike card

[phonetic]: wén fǎ [Interpretation]: 1. Rule of decree; regulations. 2 articles practices. 3. Syntax. Languages ​​are structured. Including alterations in terms of combination and union of phrases and sentences.

directory

microcomputer science in the fashion of syntax linguistics grammar grammar type rules of category type detailing describes one example computer science language grammar grammar namely each sentence can be strictly defined rules to build . namely used in compilers and language processing and other fields, such as compilers, along to some specified rules to decide the syntax of programming languages, in array to accomplish the compiler features. For example there is a grammar E -> T + E | TE | T T -> F * T | F / T | F F -> (E) | i can derive whichever of the above enumeration expression, such for such an statement (i + i) * i, can be shoved to obtain the following grammar: E => T => F * T => (E) * T => (T + E) * T => (F + E) * T => (i + E) * T => (i + T) * T => (i + F) * T => (i + i) * T => (i + i) * F => (i + i) * i in the grammatical fashion of the type of grammar in computer science, elementary principles of grammar is compiled, is to describe a programming language and compiler to effect its method. Grammar description of multi-BNF (BNF), and dissimilar momentous concept: the regular statement is another fashion of grammar. Classification since the Chomsky grammar (Chomsky) in 1956 since the establishment of a formal language description, prim language methodology has amplified rapidly. This methodology of computer science have a profound shock, primarily on programming language devise, compilation methods, and additional appearances of computational complexity is extra meaningful character. Chomsky grammar is divided into the 4 types, is type 0, type 1, type 2 and 3. Grammatical difference between these types lies in the product impose assorted restrictions. Most programming languages ​​can use the word grammar alternatively formal grammar to depict the type 3 grammar. Type 3 grammar G = (VN, VT, P, S) the rules of P in two forms: one is the formerly defined form, ie: A → aB or A → a in which A, B ∈ VN, a ∈ VT *, another form: A → Ba, or A → a, the sometime is called right-linear grammar, which is known as left-linear grammar. Grammar is described in VT * on normal sets. Four grammar class is defined as increasing restrictions, so each regular grammar is context-free, and every context-free grammar is context-sensitive, and context-sensitive grammar are each 0-type grammars. Type of grammar that generates the language 0 0 based language. Context-sensitive grammar, context-free grammar and the grammar generates the language are known as context-sensitive languages, context-free language and formal language. Type Description Let G = (VN, VT, P,iamseoer.com, S), if each of its product α → β is a structure: α ∈ (VN ∪ VT) * and by least one nonterminal, and β ∈ (VN ∪ VT) *, then G is a type 0 grammar. Type 0 grammars, likewise known phrase grammar. A very momentous theoretical outcome is the ability to type 0 grammar is equivalent to Turing machines (Turing). Or, anybody type 0 language is recursively enumerable; the other hand, recursively enumerable set have to be a type 0 language. Grammar of type 0 in the form of production for definite restrictions, to give 1, 2 and 3 grammar elucidation. Let G = (VN, VT, P, S) is a grammar, whether P in each production α → β are to meet the | β | ≥ | α |, besides for equitable S → ε, then the grammar G is type 1 or context-sensitive. In some literature to the definition of the context-sensitive generative grammar in the form described as α1Aα2 → α1βα2, comprising α1, α2 and β in (VN ∪ VT) * (ie in the V * in), β ≠ ε, in A in VN. This definition is equivalent to the definition of the front. But it better reflect the Let G = (VN, VT, P, S), if P each to meet production α → β: α is a non-terminal, β ∈ (VN ∪ VT) * usage is called type 2 of the treatise or context-independent. Sometimes type 2 grammar production is expressed as the form: A → β which A ∈ VN, ie with β replaced nonterminal A, and A where the context-free, so named for the context-free grammar. Example 4.1 and Example 4.2 are context-free grammar in the emulating, we repeatedly give an instance (Example 4.4), for instance in the grammar G is context-free grammar,nikkaconsulting.com, G language is the same number of components a and b are of a, b * the string. Let G = (VN, VT, P, S), if P in the form of each production is A → aB or A → a, where A and B are nonterminal, a is the terminator, then G is Type 3 grammar or regular grammar. Grammar G is defined as a tuple (VN, VT, P, S) which VN: nonterminal (or grammatical thing, or variable) set; VT: end of the character set; P: a set of rules; VN, VT and P non- Empty finite set. S: shriek identifier or the beginning of a nonterminal symbol, at fewest in a production as the Department was left. VN and VT does not involve prevalent factors, that, VN ∩ VT = φ with V for VN ∪ VT, known as the grammar G of the alphabet or vocabulary chart rules, also called rewrite rules, production or generation neatness, is shaped favor a  →  or  ∷ =  the (, ) ordered couple, where  is the alphabet V, V + is the closure of a symbol,  is V * of a symbol.  is called the left portion of the rules,  called the right of the rule. Rules describe the programming language accustom in several types of words described in the following rules: → l | l → l | d | l | d → d | d → +|-|*|/|=|<< equal> |> ... ... → = → ,|;|(|)| ... ... which l is a ~ z in any letter, d for 0 to 9 in any numbers. Keyword (reserved word) is a word, the general keywords (reserved words) are constituted by the letters, it's also very cozy to describe, in truth, keyword (reserved word) accumulation is a subset of the collection identifier. The most complicated class of words to be a real number is unsigned, such as 25.55e +5 and 2.1, they can be described by the following rules. Example 4.6 → d |. | e → d |. | e | ε → d → e | d | ε → d | s → d → d | ε where s indicates a assured or negative No. (+,-), d represents 0 to 9 in any numbers. Example Example: Type 1 (context-sensitive) grammar grammar G [S]: S → CD Ab → bA C → aCA Ba → aB C → bCB Bb → bB AD → aD C → ε BD → bD D → ε Aa → bD L (G) = {ww | w ∈ a, b *} Example: 2 (context free) grammar grammar G [S]: S → 0A | 1B | 0 A → 0A | 1B | 0S B → 1B | 1 | 0 Example: Defining identifier type 3 (regular) grammar grammar G [I]: I → lT I → l T → lT T → dT T → l T → d where l indicates a ~ z in any letters , d for 0 to 9 in any numbers. Open Category: computer science, compiler theory, compiler,

没有评论:

发表评论