This preview shows pages 1–8. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 ContextFree Grammars Formalism Derivations BackusNaur Form Left and Rightmost Derivations 2 Informal Comments A contextfree grammar is a notation for describing languages. It is more powerful than finite automata or REs, but still cannot define all possible languages. Useful for nested structures, e.g., parentheses in programming languages. 3 Informal Comments (2) Basic idea is to use variables to stand for sets of strings (i.e., languages). These variables are defined recursively, in terms of one another. Recursive rules (productions) involve only concatenation. Alternative rules for a variable allow union. 4 Example : CFG for { 0 n 1 n  n > 1} Productions: S > 01 S > 0S1 Basis : 01 is in the language. Induction : if w is in the language, then so is 0w1. 5 CFG Formalism Terminals = symbols of the alphabet of the language being defined. Variables = nonterminals = a finite set of other symbols, each of which represents a language. Start symbol = the variable whose language is the one being defined. 6 Productions A production has the form variable > string of variables and terminals . Convention : A, B, C, are variables. a, b, c, are terminals. , X, Y, Z are either terminals or variables. , w, x, y, z are strings of terminals only. , , , are strings of terminals and/or variables. 7 Example : Formal CFG Here is a formal CFG for { 0 n 1 n  n > 1}....
View
Full
Document
 Spring '08
 Motwani,R

Click to edit the document details