@@ -286,11 +286,11 @@ void next() {
286
286
287
287
## String Literals
288
288
289
- If we found any string literal, we need to store it into the ` data segment `
290
- that we introduced in previous chapter and return the address. Another issue
289
+ If we find any string literal, we need to store it into the ` data segment `
290
+ that we introduced in a previous chapter and return the address. Another issue
291
291
is we need to care about escaped characters such as ` \n ` to represent newline
292
292
character. But we don't support escaped characters other than ` \n ` like ` \t `
293
- or ` \r ` because we aims at bootstrapping only. Note that we still support
293
+ or ` \r ` because we aim at bootstrapping only. Note that we still support
294
294
syntax that ` \x ` to be character ` x ` itself.
295
295
296
296
Our lexer will analyze single character (e.g. ` 'a' ` ) at the same time. Once
@@ -361,20 +361,20 @@ Now we'll introduce the concept: `lookahead`. In the above code we see that
361
361
for source code starting with character ` / ` , either 'comment' or ` /(Div) ` may
362
362
be encountered.
363
363
364
- Sometimes we cannot decide which token to generate by only looking at current
365
- character(such as the above example about divide and comment), thus we need to
366
- check the next character(called ` lookahead ` ) in order to determine. In our
364
+ Sometimes we cannot decide which token to generate by only looking at the current
365
+ character (such as the above example about divide and comment), thus we need to
366
+ check the next character (called ` lookahead ` ) in order to determine. In our
367
367
example, if it is another slash ` / ` , then we've encountered a comment line,
368
368
otherwise it is a divide operator.
369
369
370
- Like we've said that lexer and parser are inherently some kind of compiler,
371
- ` lookahead ` also exists in parser . However parser will look ahead for "token"
370
+ Like we've said that a lexer and a parser are inherently a kind of compiler,
371
+ ` lookahead ` also exists in parsers . However parsers will look ahead for "token"
372
372
instead of "character". The ` k ` in ` LL(k) ` of compiler theory is the amount of
373
373
tokens a parser needs to look ahead.
374
374
375
- Also if we don't split compiler into lexer and parser, the compiler will have
375
+ Also if we don't split the compiler into a lexer and a parser, the compiler will have
376
376
to look ahead a lot of character to decide what to do next. So we can say that
377
- lexer reduced the amount of lookahead a compiler need to check.
377
+ a lexer reduces the amount of lookahead a compiler needs to check.
378
378
379
379
## Others
380
380
@@ -508,9 +508,9 @@ because the special meanings in it. There are two ways to deal with it:
508
508
509
509
We choose the second way: add corresponding identifers into symbol table in
510
510
advance and set the needed properties(e.g. the ` Token ` type we mentioned). So
511
- that when keywords are encountered in the source code, they will be interpret
512
- as identifiers, but since they already exists in the symbol table we can know
513
- that they are different with normal identifiers.
511
+ that when keywords are encountered in the source code, they will be interpreted
512
+ as identifiers, but since they already exist in the symbol table we can know
513
+ that they are different from normal identifiers.
514
514
515
515
Builtin function are similar. They are only different in the internal
516
516
information. In the main function, add the following:
0 commit comments