Kamis, 23 Oktober 2014

Asignment CHAPTER 4

REVIEW QUESTION 
11. Describe the parsing problem for a bottom-up parser.
      Answer :bottom up parser only can identifies and processes the text's lowest-level details before processes middle level structures and leaving the highest level overall structure to last


12. Explain why compilers use parsing algorithms that work on only a subset of all grammars.
      Answer :because compiler can use one parsing compiler that work on only subset of all grammars


13. Why are named constants used, rather than numbers, for token codes?
      Answer :
      - for the sake of readability of lexical and syntax analyzers.


14. Describe how a recursive-descent parsing subprogram is written for a rule with a single RHS.
      Answer :
     -A recursive-descent subprogram for a rule with a single RHS is relatively
      simple. For each terminal symbol in the RHS, that terminal symbol is compared
      with nextToken. If they do not match, it is a syntax error. If they match,
      the lexical analyzer is called to get the next input token. For each non terminal,
      the parsing subprogram for that nonterminal is called.


15. Explain the two grammar characteristics that prohibit them from being used as the basis for a      top-down parser.
      Answer : Two grammar characteristics that prohibit top-down parsing:
                      Direct or indirect Left Recursion.
     

Tidak ada komentar:

Posting Komentar

Entri Populer