Slide 2.2: The Chomsky hierarchy Slide 2.4: Context-free grammars vs regular grammars Home |
<A> ::= α
”, such as
<S> ::= a <S> | a <S> b <S> | ε
<thing> b ::= b <thing>Equivalently, context-sensitive grammars can be built using only productions of the form “
α <B> γ ::= αβγ
”.
These rules are called context-sensitive because the replacement of a nonterminal by its definition depends on the surrounding symbols.
The language generated by this grammar consists of strings having equal number a 's, b 's, and c 's in that order—namely, the set { abc , aabbcc , aaabbbccc , ... }.
|
|
<thing>
, the terminal symbol following the nonterminal determines which rule can be applied.
This causes the grammar to be context-sensitive.
In fact, a result in computation theory asserts that no context-free grammar produces this language.
α ::= β
”—for example,
a <thing> b ::= b <another thing>