This action might not be possible to undo. Are you sure you want to continue?

Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY

**FORMAL LANGUAGE & AUTOMATA THEORY
**

Recommend 2.6k

Chapters

Home Topics Chapter 1 : Formal Languages and Thier Classification Chapter 2 : Regular Expressions and Finite Automata (Part 1) Chapter 2 : Part 2 Chapter 3 : Context Free Grammars and Their Normal Forms (Part 1) Chapter 3 : Part 2 Chapter 3 : Part 3 Chapter 4 : An Introduction to Push Down Automata Chapter 5 : Turing Machines (Part 1) Chapter 5 : Part 2 Chapter 6 : LL(K) and LR (K) Grammars Chapter 7 : Linear Grammars, Cellular Automata and Rewriting Systems

Home

Chapter 6 : LL(K) and LR (K) Grammars

Q.1 Write the definitions of LL (k) Grammar. Ans. “A context free grammar is called LL (k) for left to right scan, producing a leftmost derivation with k symbol look ahead if we can always make a correct decision by checking at most the first k symbols of W.”

Q.2 Write the definition of LR (k) grammar. Ans. LR (k) is a grammar in which purser scans the input from left to right and generate the reverse rightmost derivation, and it can take a decision about reduction by looking next k symbol only. That is why; it is called LR (k) grammar.

Q. 3. Explain the Closure properties of Language Classes. Ans. Various properties of languages. are:

Q .4 What are LR (k) grammars Explain with examples and also state some properties. Ans LR (k) grammars are used in syntax analysis phase of a compiler LR (k) grammars reduce the given string w to start symbol S by reducing. It scans the string from left to right and while reduction it gives reverse rightmost derivation of the string.

ptucse.loremate.com/flat/node/9

Properties of LR (k) grammars: 1. Every LR (k) grammar C is unambiguous. 2. If C is an LR (k) grammar there exists pushdown automata A accepting L (G). 1 3. If A is a deterministic pushdown automata A there exists an LR (1.) grammar G such that L (C) = N (A) V

1/7

2. LL (k) grammars are used in top down porsing. 5. A context free language is generated by an LR (0) grammar if and only if it is accepted by deterministic PDA and has prefix property. If A is a deterministic pushdown Automata A. 1 A context free grammar is LL (k) grammar if by scanning n input string left to right we can get a left most derivation by looking k symbols ahead 2. there exists an LR (1) grammar C such that L (G) = N (A). LL (k) grammars’ are weak as compared to LR (k). 6. there exist deterministic pushdown automata A accepting L (C). 3. Every LR (k) grammar is unambiguous. The class of deterministic languages can be denoted by LdCnl is closed under complementation but not under union and intersection 6. Explain in brief the properties of LR (k) grammars. Q. various properties of LR (k) grammars are as follows: 1.com/flat/node/9 2/7 . Q. Every LL (k) grammar is non-ambiguous. various closure properties of languages are: Where.) grammar G such that L (C) = N (A) V 4 The class of deterministic language is said to be proper subclass of the class of context free languages. Write closure properties of Languages. V 5. LL (1) grammars are successfully being used in compilers. Ans. 3. 7. If C is an LR (k) grammar. 4.loremate. Ans. Explain in brief the properties of LL (k) grammers Ans. ptucse.10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY LR (1. 7 There is an algo to decide whether a given context free grammar is LR (k) for a given natural number k Q 5.

with k symbol look ahead. for left to right scan. the necessary and sufficient condition is W: k meaning the k letters long initial segment of W. A context free grammar is called LL (k). Ans. Write short notes on any two: (a) Derivation languages. if we can always make a correct decision by checking at most the first k symbols of w. ptucse. Explain the properties of LL (k) and LR (k) grammars.loremate. producing a leftmost derivation.10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY Q. (b) Cellular Automata. 8. that is A context free grammar 18 LL (k) if and only if for every pair of left most derivation of the form Q. 10.com/flat/node/9 3/7 .” Formal properties of LL (k) grammar For a grammar to be LL (1). (c) Syntax Analysis.

Loremate.loremate. Parsing algorithms are of two types ptucse. They consist of a lattice of discrete identical sites. “Cellular Automata are by definition dynamical systems which are discrete in space and time.” “Cellular automata may be considered as discrete idealization of the partial differential equations after used to describe natural system. operate on a uniform regular. can be generated by the grammar for the source language and for this a parser either attempts to derive a string w from start symbol S or the reduce string w to S. A parser obtaining a string of to hens from the lexical analyzer string of tokens and checks whether whether the string is valid construct of the same language parser performs this task by verifying whether the string of to hens obtained from the lexical analyzer.com/flat/node/9 4/7 .10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY (c) Syntax Analysis. The values of the sites evolve in discrete time steps according to deterministic roles that specify the value of each site in terms up the value of neighbouring sites. C hebii G unjan Er A kash Dereck F acebook social plugin G aurav (b) Cellular Automata : Cellular automata are simple mathematical idealization of natural system. lattice and are characterized by local interaction.com on Facebook Like 2. (c) Syntax Analysis: Syntax analysis is performed by a special program.681 people like Loremate. called syntax analyzer or parser.” Their discrete nature also allows an important analogy with digital computer: cellular automata may be viewed as parallel processing computers of simple construction. each site taking on a finite set of any integer values.com.

Q. It obtains a string of to hens from lexical analyzer and check whether the string is valid for the language or not. Ans. (a) Closure properties of languages: (b) Syntax analysis: Syntax analysis is performed by a special program known as syntax analyzer or passes. Bottom op parsing takes place from leaf of parser tree into its root.10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY 2. (b) Syntax Analysis. (c) Kusoda Normal Form. LL (k) —‘ denotes left to right scan of string product. Various types of grammars used by syntax analysis are LL (k) and LR (k). (d) Pushdown Automata. Here top-down and bottom up denotes ways of constructing the derivation tree which represents either leftmost derivation in case of top-down construction whereas it produces a rightmost derivation in reverse order for bottomup construction.loremate. The parsing algorithms are divided into 2 categories (a) top down parsing (b) bottom up parsing. LR (k) —‘ denotes left to right scan of string producing reverse rightmost derivation by looking ahead k symbols of string for making decisions. left most derivation by looking ahead k symbols of string for making the decision. Ans. Consider previous grammar.com/flat/node/9 5/7 . 12. (c) Kuroda normal form A length increasing grimmer is said to be in kuroda normal from if each of its rules has any of the following four forms: ptucse. Bottom op parsing: We generate start symbol S from string w by performing reduction. Write short notes on the following: (a) Closure properties of languages. 11. Write the closure properties of Languages. Q.

Every LR (k) grammar C is unambiguous. If G is an LR (k) grimmer there exists deterministic pushdown automata A accepting Z (C). there exists an LR (1) grammar C such that L (G) = N (A). A push down automata is a system which is mathematically defined as ‘follows: form ptucse.10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY of the following four forms: (d) Pushdown Automata: A pushdown automata is a computational model used for recognizing the strings of next free languages.loremate. 3. A pushdown automata uses the input tape of fixed length for input string and stack (linear data structure) for memory. 2. The class of deterministic languages is a proper subclass of 6/7 . 4.com/flat/node/9 Formal properties of LR (k) grammar as follows: 1. If A is a deterministic pushdown automata A.

(Deterministic context free languages) is closed under complementation but not under union and intersection.com/flat/node/9 7/7 . 6. The class of deterministic languages is a proper subclass of the class of context free languages. ptucse. 5.loremate. There is an algorithm to decide whether a given CFG is LR (k) for a given Natural number k. A CFL is generated by LR (0) grammar iff it is accepted by deterministic PDA and has prefix property. 7.10/26/12 Chapter 6 : LL(K) and LR (K) Grammars | FORMAL LANGUAGE & AUTOMATA THEORY 4.

- Mid-Term_Report_format
- Greibach Normal Form
- Ptuas.loremate.com Environmental Science 6
- Ptuas.loremate.com Environmental Science 5
- Ptuas.loremate.com Environmental Science 3
- Ptuas.loremate.com Environmental Science 4
- Ptuas.loremate.com Environmental Science 7
- Ptuas.loremate.com Environmental Science 1
- Theory of Computation
- B TECH Syllabus
- Lecture 18 - Pushdown Automata - Examples
- 113211687 Chapter 6 Ll k and Lr k Grammars Formal Language Automata Theory
- Ss Lab Viva Questions
- Lecture 06 Context-Free Grammars
- research_paper(1).ppt
- Formal cases
- Part 2 - Syntax
- Lec 4
- Unit2-JSK
- Experiment 6 - SyntaxAnalysis
- Syntax Analysis
- 4regexp_grammars
- SP Question Bank
- Compiler Design Questions
- Ch4E
- lec5
- top down parsing example
- History 6
- grammar free
- LR Parsing - Aho
- Chapter 6 _ Ll(k) and Lr (k) Grammars _ Formal Language & Automata Theory

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd