Context- free grammar - Wikipedia, the free encyclopedia. A context- free grammar (CFG) is a term used in formal language theory to describe a certain type of formal grammar. A context- free grammar is a set of production rules that describe all possible strings in a given formal language. Production rules are simple replacements. For example, the rule. A . There can be multiple replacement rules for any given value. These rules can be applied regardless of context. The left- hand side of the production rule is also always a nonterminal symbol. This means that the symbol does not appear in the resulting formal language. So in our case, our language contains the letters . We can then apply one of the two later rules. For example, if we apply A . This same process can be used, applying the second two rules in different orders in order to get all possible strings within our simple context- free grammar. Languages generated by context- free grammars are known as context- free languages (CFL). Different context- free grammars can generate the same context- free language. It is important to distinguish properties of the language (intrinsic properties) from properties of a particular grammar (extrinsic properties). The language equality question (do two given context- free grammars generate the same language?) is undecidable. Context- free grammars arise in linguistics where they are used to describe the structure of sentences and words in natural language, and they were in fact invented by the linguist Noam Chomsky for this purpose, but have not really lived up to their original expectation. By contrast, in computer science, as the use of recursively- defined concepts increased, they were used more and more. In an early application, grammars are used to describe the structure of programming languages. In a newer application, they are used in an essential part of the Extensible Markup Language (XML) called the Document Type Definition. In computer science, a popular notation for context- free grammars is Backus. An essential property of these block structures is that logical units never overlap. For example, the sentence: John, whose blue car was in the garage, walked to the grocery store. John, ((whose blue car) (was (in the garage))), (walked (to (the grocery store)))). A context- free grammar provides a simple and mathematically precise mechanism for describing the methods by which phrases in some natural language are built from smaller blocks, capturing the . Its simplicity makes the formalism amenable to rigorous mathematical study. Important features of natural language syntax such as agreement and reference are not part of the context- free grammar, but the basic recursive structure of sentences, the way in which clauses nest inside other clauses, and the way in which lists of adjectives and adverbs are swallowed by nouns and verbs, is described exactly. The formalism of context- free grammars was developed in the mid- 1. The default configuration file is named PDFtoHTML.cfg. The password required to open a password-protected PDF. This article shows how to convert a text file to PDF. This article also presents a sample application to.
Noam Chomsky. In Chomsky's generative grammar framework, the syntax of natural language was described by context- free rules combined with transformation rules. Block structure was introduced into computer programming languages by the Algol project (1. This became a standard feature of computer languages, and the notation for grammars used in concrete descriptions of computer languages came to be known as Backus- Naur Form, after two members of the Algol language design committee. Why is MVB Bank acquiring CFG Community Bank?Formal constraints not captured by the grammar are then considered to be part of the . An Earley parser is an example of such an algorithm, while the widely used LR and LL parsers are simpler algorithms that deal only with more restrictive subsets of context- free grammars. Formal definitions. Each variable represents a different type of phrase or clause in the sentence. Variables are also sometimes called syntactic categories. Each variable defines a sub- language of the language defined by G. The set of terminals is the alphabet of the language defined by the grammar G. R is a finite relation from V to (V. The members of R are called the (rewrite) rules or productions of the grammar. It must be an element of V. Production rule notation. Thus, v is a result of applying the rule (. It is not proper since it includes an . A typical derivation in this grammar is. S . The language is context- free, however it can be proved that it is not regular. Examples. There are two terminal symbols . The production rules are. S . The following context- free grammar, however, is also regular. S . The language described is all nonempty strings of a. The simplest example: S . By changing the above grammar to. S . This differs only in that it contains the empty string while the original grammar did not. Algebraic expressions. These choices look quite arbitrary. As a matter of fact, they are, in the sense that the string finally generated is always the same. For example, the second and third rewrites. Changing the choices made and not only the order they were made in usually affects which terminal string comes out at the end. Let's look at this in more detail. Consider the parse tree of this derivation. Picking a different order of expansion will produce a different derivation, but the same parse tree. The parse tree will only change if we pick a different rule to apply at some position in the tree. But can a different parse tree still produce the same terminal string, which is ( x + y ) * x - z * y / ( x + x ) in this case? Yes, for this particular grammar, this is possible. Grammars with this property are called ambiguous. For example, x + y * z can be produced with these two different parse trees. S S. . This alternative grammar will produce x + y * z with a parse tree similar to the left one above, i. More elaborate, unambiguous and context- free grammars can be constructed that produce parse trees that obey all desired operator precedence and associativity rules. Further examples. Omitting the third alternative in the rule for U and V doesn't restrict the grammar's language. Example 2. It is context- free as it can be generated by the following context- free grammar: S . A derivation proves that the string belongs to the grammar's language. A derivation is fully determined by giving, for each step: the rule applied in that stepthe occurrence of its left hand side to which it is applied. For clarity, the intermediate string is usually given as well. For instance, with the grammar. S . For instance, the leftmost derivation. Therefore, it is important to know whether the parser determines a leftmost or a rightmost derivation because this determines the order in which the pieces of code will be executed. See for an example LL parsers and LR parsers. A derivation also imposes in some sense a hierarchical structure on the string that is derived. For example, if the string . This hierarchy can also be seen as a tree. In this case the presented leftmost and the rightmost derivations define the same parse tree; however, there is another (rightmost) derivation of the same string. S . Such grammars are usually hard to parse because the parser cannot always decide which grammar rule it has to apply. Usually, ambiguity is a feature of the grammar, not the language, and an unambiguous grammar can be found that generates the same context- free language. However, there are certain languages that can only be generated by ambiguous grammars; such languages are called inherently ambiguous languages. Normal forms. If a grammar does generate the empty string, it will be necessary to include the rule S. Every context- free grammar with no . For instance, given a context- free grammar, one can use the Chomsky Normal Form to construct a polynomial- time algorithm that decides whether a given string is in the language represented by that grammar or not (the CYK algorithm). Closure properties. Examples are: Universality. The reduction uses the concept of a computation history, a string describing an entire computation of a Turing machine. A CFG can be constructed that generates all strings that are not accepting computation histories for a particular Turing machine on a particular input, and thus it will accept all strings only if the machine doesn't accept that input. Language equality. This allows natural language features such as agreement and reference, and programming language analogs such as the correct use and definition of identifiers, to be expressed in a natural way. In computer science, examples of this approach include affix grammars, attribute grammars, indexed grammars, and Van Wijngaarden two- level grammars. Similar extensions exist in linguistics. An extended context- free grammar (or regular right part grammar) is one in which the right- hand side of the production rules is allowed to be a regular expression over the grammar's terminals and nonterminals. Extended context- free grammars describe exactly the context- free languages. This produces the formalism of context- sensitive grammars. Subclasses. On LL grammars and LR grammars, it essentially performs LL parsing and LR parsing, respectively, while on nondeterministic grammars, it is as efficient as can be expected. Although GLR parsing was developed in the 1. LL, LALR or LR parsing up to the present day. Linguistic applications. Much of generative grammar has been devoted to finding ways of refining the descriptive mechanisms of phrase- structure grammar and transformation rules such that exactly the kinds of things can be expressed that natural language actually allows. Allowing arbitrary transformations doesn't meet that goal: they are much too powerful, being Turing complete unless significant restrictions are added (e. Hopcroft, Rajeen Motwani, Jeffrey D. Ullman, Addison Wesley, 2. Hopcroft & Ullman (1. Chomsky, Noam (Sep 1. Hopcroft & Ullman (1. Hopcroft & Ullman (1. ISBN 3- 5. 40- 1. MR 5. 90. 04. 7 .^Hopcroft & Ullman (1. Lemma 4. 1^Hopcroft & Ullman (1. Lemma 4. 2^This is a consequence of the unit- production elimination theorem in Hopcroft & Ullman (1. Returns several nodes. If the. specified filename includes an extension, then the extension is appended. The directory for other parts of the. For example, if you specify a filename of . The node for the options must. You can specify an. The relative path is relative. Setting. this parameter may override the remaining options.< page- by- page> Default value: false. Specify true to select a different default configuration. XHTML document per page with absolute positioning. Page indices start at zero. Page indices start at zero. Using true produces better. PDF is annotated; using false produces. Documents consisting of. For page- by- page conversion, the problem with reflowing. Setting this parameter to. PDF because it. was covered by something else. Setting this parameter to. The maximum is. 1. Any XML markup. must be escaped. For example: < p> PAGE START< /p> < page- end> Default value: none. Boilerplate text inserted at the end of every page. XML markup must be. XML markup. must be escaped. XML markup must. be escaped. Typically there will be.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
April 2017
Categories |