|
1 |
| -We have to concept in C: statement and expression. Basically statements won't |
| 1 | +We have two concepts in C: statement and expression. Basically statements won't |
2 | 2 | have a value as its result while expressions do. That means you cannot assign
|
3 |
| -an statement to a variable. |
| 3 | +a statement to a variable. |
4 | 4 |
|
5 | 5 | We have 6 statements in our interpreter:
|
6 | 6 |
|
@@ -34,8 +34,8 @@ if (...) <statement> [else <statement>]
|
34 | 34 | The flow of assembly code is:
|
35 | 35 |
|
36 | 36 | 1. execute `<cond>`.
|
37 |
| -2. If the condition fail, jump to positino `a`, i.e. `else` statement. |
38 |
| -3. Cause assembly is executed sequentially, if `<true_statement>` is executed, |
| 37 | +2. If the condition fails, jump to position `a`, i.e. `else` statement. |
| 38 | +3. Because assembly is executed sequentially, if `<true_statement>` is executed, |
39 | 39 | we need to skip `<false_statement>`, thus a jump to `b` is needed.
|
40 | 40 |
|
41 | 41 | Corresponding C code:
|
@@ -104,7 +104,7 @@ Nothing worth mention. C code:
|
104 | 104 |
|
105 | 105 | ## Return
|
106 | 106 |
|
107 |
| -Once we met `return`, it means the function is about to end, thus `LEV` is |
| 107 | +Once we meet `return`, it means the function is about to end, thus `LEV` is |
108 | 108 | needed to indicate the exit.
|
109 | 109 |
|
110 | 110 | ```c
|
@@ -165,7 +165,7 @@ functions. You can challange yourself to fill them out first.
|
165 | 165 |
|
166 | 166 | As you can see, implementing parsing for an interpreter is not hard at all.
|
167 | 167 | But it did seems complicated because we need to gather enough knowledge during
|
168 |
| -parsing in order to generate target code(assembly in our case). You see, that |
| 168 | +parsing in order to generate target code (assembly in our case). You see, that |
169 | 169 | is one big obstacle for beginner to start implementation. So instead of
|
170 | 170 | "programming knowledge", "domain knowledge" is also required to actually
|
171 | 171 | achieve something.
|
|
0 commit comments