Skip to content

Commit 4a7cdca

Browse files
authored
Merge pull request #20 from krupan/grammar-fixes
some grammar fixes for lesson 3
2 parents 7f8aa68 + d069de1 commit 4a7cdca

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tutorial/en/3-Lexer.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ void next() {
286286

287287
## String Literals
288288

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
291291
is we need to care about escaped characters such as `\n` to represent newline
292292
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
294294
syntax that `\x` to be character `x` itself.
295295

296296
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
361361
for source code starting with character `/`, either 'comment' or `/(Div)` may
362362
be encountered.
363363

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
367367
example, if it is another slash `/`, then we've encountered a comment line,
368368
otherwise it is a divide operator.
369369

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"
372372
instead of "character". The `k` in `LL(k)` of compiler theory is the amount of
373373
tokens a parser needs to look ahead.
374374

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
376376
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.
378378

379379
## Others
380380

@@ -508,9 +508,9 @@ because the special meanings in it. There are two ways to deal with it:
508508

509509
We choose the second way: add corresponding identifers into symbol table in
510510
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.
514514

515515
Builtin function are similar. They are only different in the internal
516516
information. In the main function, add the following:

0 commit comments

Comments
 (0)