LARA

Why Study Lexical Analysis

Lexical analysis is one of the simplest aspects of compilers

Almost never a problem in practice

Why do we need to study it?

Reason 1: It is also the first phase of a compiler

So we study it first.

Reason 2: 'Drunk under the lamppost' effect

lamppost = a metal post supporting an outdoor lamp (such as a streetlight)

Lamppost

What are you doing?

  • Searching for my Camipro card…

Where did you lose it?

  • Over there, near 'le Vinci'

Then why are you looking for it here and not there?

  • Because it's dark there, and here I have the light!

Lexical Analysis is under the Lamppost

The problem can be described using finite state machines

  • very well understood
  • have very good properties, can manipulate them well

Automated lexical analysis techniques are easier to understand

  • preparation for parsing