Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Basics of Compiler Design

Basics of Compiler Design

Ratings:

5.0

(2)
|Views: 82 |Likes:
Published by api-3714781
Basics of Compiler Design
Basics of Compiler Design

More info:

Published by: api-3714781 on Oct 19, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Basics of Compiler Design
Torben \u00c6gidius Mogensen
DIKU
University of Copenhagen
Publishing address:

DIKU
University of Copenhagen
Universitetsparken 1
DK-2100 Copenhagen
DENMARK

c
\ue000Torben \u00c6gidius Mogensen 2000 \u2013 2007
torbenm@diku.dk
Book homepage:
http://www.diku.dk/\u02dctorbenm/Basics
First published 2000
This edition: April 10, 2007
Contents
1 Introduction
13

1.1 What is a compiler?. . . . . . . . . . . . . . . . . . . . . . . . . 13 1.2 The phases of a compiler. . . . . . . . . . . . . . . . . . . . . . 14 1.3 Interpreters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.4 Why learn about compilers?. . . . . . . . . . . . . . . . . . . . 16 1.5 The structure of this book. . . . . . . . . . . . . . . . . . . . . . 17 1.6 To the lecturer. . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.7 Acknowledgements. . . . . . . . . . . . . . . . . . . . . . . . . 19 1.8 Permission to use. . . . . . . . . . . . . . . . . . . . . . . . . . 19

2 LexicalAnalysis
21
2.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.2 Regularexpressions. . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2.1 Shorthands. . . . . . . . . . . . . . . . . . . . . . . . . 24 2.2.2 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.3 Nondeterministic \ufb01nite automata. . . . . . . . . . . . . . . . . . 27
2.4 Converting a regular expression to an NFA. . . . . . . . . . . . . 30

2.4.1 Optimisations. . . . . . . . . . . . . . . . . . . . . . . . 30 2.5 Deterministic \ufb01nite automata. . . . . . . . . . . . . . . . . . . . 32 2.6 Converting an NFA to a DFA. . . . . . . . . . . . . . . . . . . . 34

2.6.1 Solving set equations. . . . . . . . . . . . . . . . . . . . 35
2.6.2 The subset construction. . . . . . . . . . . . . . . . . . . 37
2.7 Size versus speed. . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.8 Minimisation of DFAs. . . . . . . . . . . . . . . . . . . . . . . 41

2.8.1 Example. . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.8.2 Deadstates. . . . . . . . . . . . . . . . . . . . . . . . . 45
2.9 Lexers and lexer generators. . . . . . . . . . . . . . . . . . . . . 46
2.9.1 Lexergenerators. . . . . . . . . . . . . . . . . . . . . . 51

2.10 Properties of regular languages. . . . . . . . . . . . . . . . . . . 52 2.10.1 Relative expressive power. . . . . . . . . . . . . . . . . 53 2.10.2 Limits to expressive power. . . . . . . . . . . . . . . . . 54

3

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->