In computer science a right regular grammar is a formal grammar (N, Σ, P, S) such that all the production rules in P are of one of the following forms:
In a left regular grammar, all rules obey the forms
An example of a right regular grammar G with N = {S, A}, Σ = {a, b, c}, P consists of the following rules
A regular grammar is a left regular or right regular grammar.
The regular grammars describe exactly all regular languages and are in that sense equivalent to finite state automata and regular expressions. Moreover, the right regular grammars by themselves are also equivalent to the regular languages, as are the left regular grammars.
Every regular grammar is a context-free grammar.
Every context-free grammar can be easily rewritten into a form in which only a combination of left regular and right regular rules is used. Therefore, such grammars can express all context-free languages. Regular grammars, which use either left-regular or right-regular rules but not both, can only express a smaller set of languages, called the regular languages. In that sense they are equivalent with finite state automata and regular expressions. (for illustration: the paradigmatic context-free language with strings of the form is generated by the grammar G with N = {S, A}, Σ = {a, b}, P with the rules
Some textbooks and articles disallow empty production rules, and assume that the empty string is not present in languages.
Regulární gramatika | Gramática regular | Grammatica regolare | 正規文法 | Gramatyka regularna | Gramática regular | 正则文法
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Regular grammar".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world