1
- This series of articles is a tutorial of building a C compiler from scratch.
1
+ This series of articles is a tutorial for building a C compiler from scratch.
2
2
3
3
I lied a little in the above sentence: it is actually an _ interpreter_ instead
4
4
of _ compiler_ . I lied because what the hell is a "C interpreter"? You will
5
- however, understand compiler better by building an interpreter.
5
+ however, understand compilers better by building an interpreter.
6
6
7
7
Yeah, I wish you can get a basic understanding of how a compiler is
8
8
constructed, and realize it is not that hard to build one. Good Luck!
@@ -11,7 +11,7 @@ Finally, this series is written in Chinese in the first place, feel free to
11
11
correct me if you are confused by my English. And I would like it very much if
12
12
you could teach me some "native" English :)
13
13
14
- We won't write any code in this chapter, feel free to skip if you are
14
+ We won't write any code in this chapter, feel free to skip it if you are
15
15
desperate to see some code...
16
16
17
17
## Why you should care about compiler theory?
@@ -20,10 +20,10 @@ Because it is **COOL**!
20
20
21
21
And it is very useful. Programs are built to do something for us, when they
22
22
are used to translate some forms of data into another form, we can call them
23
- compiler. Thus by learning some compiler theory we are trying to master a very
23
+ a compiler. Thus by learning some compiler theory we are trying to master a very
24
24
powerful technique of solving problems. Isn't that cool enough to you?
25
25
26
- People used to say understanding how compiler works would help you to write
26
+ People used to say understanding how a compiler works would help you to write
27
27
better code. Some would argue that modern compilers are so good at
28
28
optimization that you should not care any more. Well, that's true, most people
29
29
don't need to learn compiler theory only to improve the efficency of the code.
@@ -34,7 +34,7 @@ And by most people, I mean you!
34
34
I have always been in awe of compiler theory because that's what makes
35
35
programing easy. Anyway can you imaging building a web browser in only
36
36
assembly language? So when I got a chance to learn compiler theory in college,
37
- I was so exciting ! And then... I quit, not understanding what that it.
37
+ I was so excited ! And then... I quit, not understanding what that it.
38
38
39
39
Normally a course of compiler will cover:
40
40
@@ -46,21 +46,21 @@ Normally a course of compiler will cover:
46
46
5 . Code generation.
47
47
6 . Code optimization.
48
48
49
- Perhaps more than 90% students will not care anything beyond parser, and
50
- what's more, we still don't know how to build a compiler! Even after all these
51
- efforts learning the theories. Well the main reason is that what "Compiler
49
+ Perhaps more than 90% students will not care anything beyond the parser, and
50
+ what's more, we still don't know how to build a compiler! Even after all the
51
+ effort learning the theories. Well the main reason is that what "Compiler
52
52
Thoery" trys to teach is "How to build a parser generator", namely a tool that
53
53
consumes syntax gramer and generates a compiler for you. lex/yacc or
54
54
flex/bison or things like that.
55
55
56
- These theories try to taught us how to solve a general problems of generating
57
- compilers automatically. That means once you've master them, you are able to
56
+ These theories try to teach us how to solve the general problems of generating
57
+ compilers automatically. That means once you've mastered them, you are able to
58
58
deal with all kinds of grammars. They are indeed useful in industry.
59
- Nevertheless they are too powerful and too complicate for students and most
59
+ Nevertheless they are too powerful and too complicated for students and most
60
60
programmers. You will understand that if you try to read lex/yacc's source
61
61
code.
62
62
63
- Good news is building a compiler can be much simpler than you'd ever imagined.
63
+ Good news is building a compiler can be much simpler than you ever imagined.
64
64
I won't lie, not easy, but definitely not hard.
65
65
66
66
## Birth of this project
0 commit comments