1 / 14

Chapter 5 Context-Free Languages

Chapter 5 Context-Free Languages. Regular language are effective in describing certain simple patterns. But it is not enough to describe programming languages. Context-Free languages cover more complicated languages. Context free. Linear grammars. It is not a linear grammar. S. a. A.

dixie
Download Presentation

Chapter 5 Context-Free Languages

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. Chapter 5 Context-Free Languages • Regular language are effective in describing certain simple patterns. But it is not enough to describe programming languages. • Context-Free languages cover more complicated languages. Context free

  2. Linear grammars

  3. It is not a linear grammar.

  4. S a A B b b B B b b Leftmost and Rightmost Derivations Definition5.2 A derivation is said to be leftmost if in each step the leftmost variable in the sentential form is replaced. If in each step the rightmost variable is replaced, we call the derivation rightmost.

  5. S The root is labeled S. a A B Each interior vertex has a label from V. b b B B b b Definition 5.3 Let G=(V,T,S,P) be a context-free grammar. An ordered tree is a derivation tree for G if and only if it has the following properties:

  6. To check if w is a member of L(G), we use the exhaustive search parsing method. It is a form of top-down. 5.2Parsing and Ambiguity Parsing and Membership

  7. S S S a a a a S S S S b b b b Ambiguity in grammars and languages S

  8. E E E * E E + E I I E E * + E E a b a c I I I I c b

  9. Example if-then-else statement can be defined by context-free grammar as <if_statement>::=If<expression><then_clause><else_clase>. 5.3 Context-free Grammars and Programming Languages Why we learn the theory of formal languages?----We use the theory to design programming languages and to design the interpreters and compiles for them. A programming language has two aspects: syntax and semantics. Related to context-free grammar.

  10. Initial state Initial state Finite Automata Stack Input file Input file … … Control unit (transition function δ) Control unit (transition function δ) Chapter 7 Pushdown Automata Pushdown Automata

  11. Definition 7.1 A nondeterministic pushdown accepter or npda is defined by the septuple

  12. * Context-free Language and Pushdown Automata Theorem 7.1 For any context-free language L, there is an npda M such that L = L(M).

More Related