comparison doc/compiler.rst @ 300:158068af716c

yafm
author Windel Bouwman
date Tue, 03 Dec 2013 18:00:22 +0100
parents 674789d9ff37
children 6753763d3bec
comparison
equal deleted inserted replaced
299:674789d9ff37 300:158068af716c
2 2
3 Compiler 3 Compiler
4 ======== 4 ========
5 5
6 This chapter describes the design of the compiler. 6 This chapter describes the design of the compiler.
7
8
9 Overview
10 --------
11
12 The compiler consists a frontend, mid-end and back-end. The frontend deals with 7 The compiler consists a frontend, mid-end and back-end. The frontend deals with
13 source file parsing and semantics checking. The mid-end performs optimizations. 8 source file parsing and semantics checking. The mid-end performs optimizations.
14 This is optional. The back-end generates machine code. The front-end produces 9 This is optional. The back-end generates machine code. The front-end produces
15 intermediate code. This is a simple representation of the source. The back-end 10 intermediate code. This is a simple representation of the source. The back-end
16 can accept this kind of representation. This way the compiler is portable and 11 can accept this kind of representation.
17 a front end can be constructed without having to do the rest.
18 12
19 .. graphviz:: 13 .. graphviz::
20 14
21 digraph x { 15 digraph x {
22 rankdir="LR" 16 rankdir="LR"
36 } 30 }
37 31
38 32
39 IR-code 33 IR-code
40 ------- 34 -------
35
41 The intermediate representation (IR) of a program de-couples the front end 36 The intermediate representation (IR) of a program de-couples the front end
42 from the backend of the compiler. 37 from the backend of the compiler.
43 38
44 See ir for details about all the available instructions. 39 See ir for details about all the available instructions.
45 40
51 This is a subset of the C language with some additional features. 46 This is a subset of the C language with some additional features.
52 47
53 .. graphviz:: 48 .. graphviz::
54 49
55 digraph c3 { 50 digraph c3 {
51 rankdir="LR"
56 1 [label="source text"] 52 1 [label="source text"]
57 10 [label="lexer" ] 53 10 [label="lexer" ]
58 20 [label="parser" ] 54 20 [label="parser" ]
59 30 [label="semantic checks" ] 55 30 [label="semantic checks" ]
60 40 [label="code generation"] 56 40 [label="code generation"]