BasicsofCompilerDesignAnniversaryeditionTorben Ægidius MogensenDEPARTMENT OF COMPUTER SCIENCEUNIVERSITY OF COPENHAGENPublished throughlulu.com.c Torben Ægidius Mogensen 2000 – 2010torbenm@diku.dkDepartment of Computer ScienceUniversity of CopenhagenUniversitetsparken 1DK-2100 CopenhagenDENMARKBook homepage:http://www.diku.dk/torbenm/BasicsFirst published 2000This edition: August 20, 2010ISBN 978-87-993154-0-6Contents1 Introduction 11.1 What is a compiler? . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 The phases of a compiler . . . . . . . . . . . . . . . . . . . . . . 21.3 Interpreters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Why learn about compilers? . . . . . . . . . . . . . . . . . . . . 41.5 The structure of this book . . . . . . . . . . . . . . . . . . . . . . 51.6 To the lecturer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.7 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 71.8 Permission to use . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Lexical Analysis 92.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.1 Shorthands . . . . . . . . . . . . . . . . . . . . . . . . . 132.2.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 142.3 Nondeterministic finite automata . . . . . . . . . . . . . . . . . . 152.4 Converting a regular expression to an ...