REVIEW QUESTION
Tugas pak Tri Joko
11. Describe the parsing problem for a bottom-up parser.
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.
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?
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.
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.
14. Describe how a recursive-descent parsing subprogram is written for a rule with a single RHS.
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.
Two grammar characteristics that prohibit top-down parsing:
Direct or indirect Left Recursion.
Tidak ada komentar:
Posting Komentar