Chapter 5: Semantic Analysis

Beyond syntax analysis

  • Parser cannot catch all the program errors
  • There is a level of correctness that is deeper than syntax analysis
  • Some language features cannot be modeled using context free grammar formalism

- Whether an identifier has been declared before use

- This problem is of identifying a language {w α w | w ε Σ *}

- This language is not context free

A parser has its own limitations in catching program errors related to semantics, something that is deeper than syntax analysis. Typical features of semantic analysis cannot be modeled using context free grammar formalism. If one tries to incorporate those features in the definition of a language then that language doesn't remain context free anymore.