In formal language theory, a context-free grammar (CFG) is a formal grammar in which every production rule is of the form
- V → w
where V is a single nonterminal symbol, and w is a string of terminals and/or nonterminals (w can be empty).
The languages generated by context-free grammars are known as the context-free languages.
A formal grammar is considered "context free" when its production rules can be applied regardless of the context of a nonterminal.
Context-free grammars are important in linguistics for describing the structure of sentences and words in natural language, and in computer science for describing the structure of programming languages and other formal languages.
In linguistics, some authors use the term phrase structure grammar to refer to context-free grammars, whereby phrase structure grammars are distinct from dependency grammars. In computer science, a popular notation for context-free grammars is Backus–Naur Form, or BNF.
Read more about Context-free Grammar: Background, Formal Definitions, Normal Forms, Undecidable Problems, Extensions, Subclasses, Linguistic Applications
Famous quotes containing the word grammar:
“Grammar is a tricky, inconsistent thing. Being the backbone of speech and writing, it should, we think, be eminently logical, make perfect sense, like the human skeleton. But, of course, the skeleton is arbitrary, too. Why twelve pairs of ribs rather than eleven or thirteen? Why thirty-two teeth? It has something to do with evolution and functionalismbut only sometimes, not always. So there are aspects of grammar that make good, logical sense, and others that do not.”
—John Simon (b. 1925)