lect8-cfl1

lect8-cfl1 - 1 Context-Free Grammars Formalism Derivations...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Context-Free Grammars Formalism Derivations Backus-Naur Form Left- and Rightmost Derivations 2 Informal Comments A context-free 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

Page1 / 28

lect8-cfl1 - 1 Context-Free Grammars Formalism Derivations...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online