1 / 14

CS 3240: Languages and Computation

CS 3240: Languages and Computation. Context-Free Languages. Context-Free Languages. A single step derivation “ ” consist of the substitution of a variable by a string according to a substitution rule in R

velika
Download Presentation

CS 3240: Languages and Computation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 3240: Languages and Computation Context-Free Languages

  2. Context-Free Languages • A single step derivation “” consist of the substitution of a variable by a string according to a substitution rule in R • Note that rules use single arrows “”, while derivations themselves use double arrows “” • A sequence of several derivations (or none) is indicated by “ * ” • Previous example: “S * aabbaa” • L is a Context Free Language if and only if there is a context free grammar G=(V, Σ, P, S) such that L = L(G) = { w | w Σ * and S * w }

  3. The language generated by a grammar

  4. Some Remarks • The language L(G) = { w | w Σ* and S * w } contains only strings of terminals, not variables. • Notation: We can agglomerate several rules for one variable:A  B A  01 by A  B | 01 | AAA  AA • What is the CFG ({S},{(,)},P, S) that produces the language of correct parentheses like (), (()), or ()(())? • Answer: S→ (S) | SS | 

  5. Parse trees

  6. Yield of a parse tree

  7. From tree to derivation

  8. From derivations to recursive inference

  9. ambiguity

  10. Removing ambiguity

  11. Ambiguity and leftmost derivations

  12. Inherent ambiguity

More Related