Compilers--Introduction

Introduction

compilers & interpreters

  • compilers:输入程序,输出执行文件。offline

  • interpreters:输入程序和数据,输出结果。online

five aspects

  • lexical analysis: divides program text into "words" or "tokens"

  • parsing: understand the program structrue

  • semantic analysis: perform limited semantic analysis to catch inconsistencies; should define strict rules to avoid ambiguties

  • optimization: like editing, to run faster and use less memory; x = y*0 == x = 0(x is int)

  • code generation: produces assembly code(usually)