Skip to content

Scanning

Introduction

The first step in writing a compiler is to write a scanner. A scanner is a program that reads the source code and breaks it into tokens. A token is a sequence of characters that have some meaning and make up the language's grammer.

Chapter overview

By the end of this chapter, we will have a scanner that can take a string of Lox source code as input and produce a list of tokens as output. We will also start building the CLI for our Lox interpreter.