2

A simple Translator

What you will learn in this chapter

  • Grammar of a simple high level language
  • A lexical analyzer for that language
  • A Recursive-descent Parser
  • Intermediate code
  • How to generate code for a target machine?
  • A target virtual machine
  • Need for optimization
  • Simulator for the virtual machine

Key Words

simple, Scanner, parser, RDP, intermediate code, virtual machine, simulator, optimization

In this chapter, we discuss a very simple C-like language called simple and its compiler. Though due to pedagogic necessity the language is kept as simple as possible, it will illustrate all the significant issues of a compiler construction. Concentration will be on exposing the compiler writing steps rather than power of the language being ...

Get Compilers: Principles and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.