Concepts of Programming Languages

(Sean Pound) #1

200 Chapter 4 Lexical and Syntax Analysis



  1. What is a phrase of a sentential form?

  2. What is a simple phrase of a sentential form?

  3. What is the handle of a sentential form?

  4. What is the mathematical machine on which both top-down and
    bottom-up parsers are based?

  5. Describe three advantages of LR parsers.

  6. What was Knuth’s insight in developing the LR parsing technique?

  7. Describe the purpose of the ACTION table of an LR parser.

  8. Describe the purpose of the GOTO table of an LR parser.

  9. Is left recursion a problem for LR parsers?


PROBLEM SET



  1. Perform the pairwise disjointness test for the following grammar rules.


a. A→aB  b  cBB


b. B→aB  bA  aBb


c. C→aaA  b  caB



  1. Perform the pairwise disjointness test for the following grammar rules.


a. S→aSb  bAA


b. A→b{aB}  a


c. B→aB  a



  1. Show a trace of the recursive descent parser given in Section 4.4.1 for
    the string a + b * c.

  2. Show a trace of the recursive descent parser given in Section 4.4.1 for
    the string a * (b + c).

  3. Given the following grammar and the right sentential form, draw a parse
    tree and show the phrases and simple phrases, as well as the handle.
    S→aAb  bBA A→ab  aAB B→aB  b


a. aaAbb


b. bBab


c. aaAbBb



  1. Given the following grammar and the right sentential form, draw a parse
    tree and show the phrases and simple phrases, as well as the handle.
    S→AbB  bAc A→Ab  aBB B→Ac  cBb  c


a. aAcccbbc


b. AbcaBccb


c. baBcBbbc

Free download pdf