- Source: Greibach normal form
In formal language theory, a context-free grammar is in Greibach normal form (GNF) if the right-hand sides of all production rules start with a terminal symbol, optionally followed by some variables. A non-strict form allows one exception to this format restriction for allowing the empty word (epsilon, ε) to be a member of the described language. The normal form was established by Sheila Greibach and it bears her name.
More precisely, a context-free grammar is in Greibach normal form, if all production rules are of the form:
A
→
a
A
1
A
2
⋯
A
n
{\displaystyle A\to aA_{1}A_{2}\cdots A_{n}}
where
A
{\displaystyle A}
is a nonterminal symbol,
a
{\displaystyle a}
is a terminal symbol, and
A
1
A
2
…
A
n
{\displaystyle A_{1}A_{2}\ldots A_{n}}
is a (possibly empty) sequence of nonterminal symbols.
Observe that the grammar does not have left recursions.
Every context-free grammar can be transformed into an equivalent grammar in Greibach normal form. Various constructions exist. Some do not permit the second form of rule and cannot transform context-free grammars that can generate the empty word. For one such construction the size of the constructed grammar is O(n4) in the general case and O(n3) if no derivation of the original grammar consists of a single nonterminal symbol, where n is the size of the original grammar. This conversion can be used to prove that every context-free language can be accepted by a real-time (non-deterministic) pushdown automaton, i.e., the automaton reads a letter from its input every step.
Given a grammar in GNF and a derivable string in the grammar with length n, any top-down parser will halt at depth n.
See also
Backus–Naur form
Chomsky normal form
Kuroda normal form
References
Alexander Meduna (6 December 2012). Automata and Languages: Theory and Applications. Springer Science & Business Media. ISBN 978-1-4471-0501-5.
György E. Révész (17 March 2015). Introduction to Formal Languages. Courier Corporation. ISBN 978-0-486-16937-8.
Kata Kunci Pencarian:
- Daftar istilah komputer
- Greibach normal form
- Normal form
- Sheila Greibach
- Chomsky normal form
- Kuroda normal form
- Categorial grammar
- LL grammar
- Index of computing articles
- Context-free grammar
- Pushdown automaton