CSCE 222 Lecture 27
Jump to navigation
Jump to search
« previous | Monday, April 11, 2011 | next »
Chomsky's Classification of Grammars
4 types of production rules:
- Type 0. no restrictions on production rules
- Type 1. "context-sensitive grammar" Productions are of the form lAr → lwr, where A ∈ N, l,r ∈ V*, and w ∈ V* (≠ λ)
- Type 2. "context-free languages" Productions are of the form A → w when A ∈ N
- Type 3. "regular languages" Productions are of the form A → aB when A,B ∈ N and A → a when a ∈ T
Example 1
Give a grammar that generates the set , where exponents represents the number of repeated occurrences
Solution:
This is a "Type 2 (context-free) language"
Example 2
Give a grammar that generates the set .
Solution:
Type 3 Language
Example 3
Give a grammar that generates the set .
This is a context-sensitive language (cannot be generated by any context-free language
Parsing Languages
2 ways:
- Top-down: Start with start symbol and use production rules to produce the desired output
- Bottom-up: Start with desired output and reverse-engineer to a start symbol
Backus Naur Form
When non-terminal symbols can be replaced by many options, Backus Naur form combines them:
becomes