Lec05B - CFG & CNF Notes Written By: Thomas Meeks...

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

View Full Document Right Arrow Icon
Written By: Thomas Meeks Context-Free Grammar of Regular Languages DFA -> CFG S -> 0A | 1S A -> 0C | 1B | E B -> 1C | 0A C -> 0S | 1B | E q 0 = S, q 1 = A, q 2 = B, q 3 = C Rules of Conversion: (q 0 , 0) => q 2 to CFG: q 2 = q 0 0 (q i , a) => q j to CFG: q j = q i a or q i = aq j if q i is an accept state, also include q i = E For Example 011010 Trace in DFA: (q 0 , 0) -> (q 1 , 1) -> (q 2 , 1) -> (q 3 , 0) -> (q 0 , 1) -> (q 0 , 0) -> (q 1 , E) Trace in CFG: S -> 0A -> 01B -> 011C -> 0110S -> 01101S -> 011010A -> 011010 Ambigious Grammars A grammar in which the same string can be created using two different parse trees. Example E -> E + E | E * E | E | a a + a * a Derivation 1: E -> E + E -> E + E * E -> a + a * a Derivation 2: E -> E * E -> E + E * E -> a + a * a q 0 q 1 q 3 q 2 1 0 1 0 1 0 1 0
Background image of page 1

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

View Full DocumentRight Arrow Icon
Written By: Thomas Meeks 1 2 Programming languages must be unambiguous. In an ambigious language strings that look the same may have different meanings. This example can be made unambiguous:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/16/2011 for the course COT 4210 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 3

Lec05B - CFG & CNF Notes Written By: Thomas Meeks...

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

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