Chapter 4

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 219-221
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 8 of 27)

  1. What are three reasons why syntax analyzers are based on grammars? (Number 1)
    First : Grammars are clear and concise.
    Second : The grammar description can be use as a direct basis for  the  analyzer.
    Third : Grammar are modular / easy to maintain.
  2. Explain three reasons why lexical analysis is separated from syntax analysis. (Number 2)
    Simplicity, Techniques for lexical analysis are less complex than those required for syntax analysis. Efficiency, Although it pays to optimize the lexical analyzer, because lexical analysis requires a significant portion of total compilation time. Portability, Because the lexical analyzer reads input program files and often includes buffering of that input, it is somewhat platform dependent.
  3. Define lexeme and token. (Number 3)
    A Lexeme is a string of characters that is a lowest-level syntatic unit in the programming language. These are the “words” and punctuation of the programming language. A Token is a syntactic category that forms a class of lexemes. These are the “nouns”, “verbs”, and other parts of speech for the programming language.
  4. What is a state transition diagram? (Number 6)
    State transition diagrams have been used right from the beginning in object-oriented modeling. The basic idea is to define a machine that has a number of states (hence the term finite state machine).
  5. What are the two distinct goals of syntax analysis? (Number 8)
    To detect syntax errors in a given program, and to produce a parse tree or possibly the information required to build such a tree for a given program.
  6. Describe the pairwise disjointness test. (Number 17)
    The pairwise test try to test whether a parsing subprogram can determine which RHS is being parsed on the basis of the next token of input.
  7. What is left factoring? (Number 18)
    Left factoring is the action taken when a grammar leads backtracking while marking parsing or syntax tree.
  8. Describe three advantages of LR parsers. (Number 23)
    They can be built for all programming languages. They can detect syntax errors as soon as it possible in a left-to-right scan. The LR class of grammars is a proper superset of the class parsable by LL parsers.
Advertisements
This entry was posted in KBP. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s