CFG (Context-free Phrase Structure Grammar)
A context-free phrase structure grammar consists of a set of rules and a lexicon. The lexicon consists of a list of words associated with their grammatical categories. The rules describe in what ways the words can be combined. The phrase structure grammar is called 'context-free' because the rules apply regardless of the linguistic context, i.e. a rule applies to a linguistic entity (see below), and the linguistic units that are adjacent to or nearby this entity are irrelevant.
The following is a simple example of a context-free phrase structure grammar, where S stands for Sentence, N for Noun, D for Determiner, V for Verb, A for Adjective, NP for Noun Phrase, and VP for Verb Phrase:
The arrow in these rules can be read as 'consists of'. For example, the rule NP -> D N means: A noun phrase consists of a determiner and a noun, in that order. Or alternatively, one could say that constructions of the type NP have as their immediate constituents constructions of the type D and N, combined in that order. The rule can be associated with the following tree:
The lexicon and the above mentioned rules form a grammatical structure which licenses the following sentences to be a grammatical one. Moreover, it assigns each sentence that generates a structural description.
A linguist writes a grammar. A grammar writes a linguist.
By using parentheses, a category can be marked as optional. The rule above for NP could be changed into the following rule, which says that the N could optionally be preceded by an A:
As a result this grammar can generate all the sentences above, as well as the following sentences:
A linguist writes a large grammar. A grammar writes a large linguist.