1
1
In this chapter we are going to use EBNF to describe the grammer of our C
2
- interpreter, and add the support of variable .
2
+ interpreter, and add the support of variables .
3
3
4
- Parser is more complicated than lexer, thus we will split it into 3 parts:
4
+ The parser is more complicated than the lexer, thus we will split it into 3 parts:
5
5
variables, functions and expressions.
6
6
7
7
## EBNF grammar
@@ -11,7 +11,7 @@ We've talked about BNF in the previous chapter,
11
11
Extended-BNF. If you are familiar with regular expression, you should feel
12
12
right at home. Personally I think it is more powerful and straightforward than
13
13
BNF. Here is the EBNF grammar of our C interpreter, feel free to skip it if
14
- you feel too hard to understand.
14
+ you feel it's too hard to understand.
15
15
16
16
```
17
17
program ::= {global_declaration}+
@@ -61,15 +61,15 @@ void program() {
61
61
```
62
62
63
63
I know that we havn't defined ` global_declaration ` , sometimes we need wishful
64
- thinking that maybe someone(say Bob) will implement that for you. So you can
64
+ thinking that maybe someone (say Bob) will implement that for you. So you can
65
65
focus on the big picture at first instead of drill down into all the details.
66
66
That's the essence of top-down thinking.
67
67
68
68
## global_declaration()
69
69
70
- Now it is our duty(not Bob's) to implement ` global_declaration ` . It will try
71
- to parse variable definition , type definition (only enum is supported) and
72
- function definition :
70
+ Now it is our duty (not Bob's) to implement ` global_declaration ` . It will try
71
+ to parse variable definitions , type definitions (only enum is supported) and
72
+ function definitions :
73
73
74
74
``` c
75
75
int basetype; // the type of a declaration, make it global for convenience
0 commit comments