mirror of
https://github.com/jamiebuilds/the-super-tiny-compiler.git
synced 2024-10-27 20:34:08 +00:00
Minor typo fixes
This commit is contained in:
parent
386d1efd5b
commit
a4b38d76e3
@ -107,8 +107,8 @@
|
|||||||
* 1. *Parsing* is taking raw code and turning it into a more abstract
|
* 1. *Parsing* is taking raw code and turning it into a more abstract
|
||||||
* representation of the code.
|
* representation of the code.
|
||||||
*
|
*
|
||||||
* 2. *Transformation* takes this abstract representation and manipulates to do
|
* 2. *Transformation* takes this abstract representation and manipulates it to
|
||||||
* whatever the compiler wants it to.
|
* do whatever the compiler wants it to.
|
||||||
*
|
*
|
||||||
* 3. *Code Generation* takes the transformed representation of the code and
|
* 3. *Code Generation* takes the transformed representation of the code and
|
||||||
* turns it into new code.
|
* turns it into new code.
|
||||||
@ -333,7 +333,7 @@
|
|||||||
*
|
*
|
||||||
* Code generators work several different ways, some compilers will reuse the
|
* Code generators work several different ways, some compilers will reuse the
|
||||||
* tokens from earlier, others will have created a separate representation of
|
* tokens from earlier, others will have created a separate representation of
|
||||||
* the code so that they can print node linearly, but from what I can tell most
|
* the code so that they can print nodes linearly, but from what I can tell most
|
||||||
* will use the same AST we just created, which is what we’re going to focus on.
|
* will use the same AST we just created, which is what we’re going to focus on.
|
||||||
*
|
*
|
||||||
* Effectively our code generator will know how to “print” all of the different
|
* Effectively our code generator will know how to “print” all of the different
|
||||||
@ -629,7 +629,7 @@ function parser(tokens) {
|
|||||||
// (add 2 (subtract 4 2))
|
// (add 2 (subtract 4 2))
|
||||||
//
|
//
|
||||||
// You'll also notice that in our tokens array we have multiple closing
|
// You'll also notice that in our tokens array we have multiple closing
|
||||||
// parenthesis.
|
// parentheses.
|
||||||
//
|
//
|
||||||
// [
|
// [
|
||||||
// { type: 'paren', value: '(' },
|
// { type: 'paren', value: '(' },
|
||||||
@ -850,8 +850,8 @@ function transformer(ast) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Next I'm going to cheat a little and create a bit of a hack. We're going to
|
// Next I'm going to cheat a little and create a bit of a hack. We're going to
|
||||||
// use a property named `context` on our parent nodes that we're going to push
|
// use a property named `context` on our parent nodes that we're going to use
|
||||||
// nodes to their parent's `context`. Normally you would have a better
|
// to push nodes to their parent's `context`. Normally you would have a better
|
||||||
// abstraction than this, but for our purposes this keeps things simple.
|
// abstraction than this, but for our purposes this keeps things simple.
|
||||||
//
|
//
|
||||||
// Just take note that the context is a reference *from* the old ast *to* the
|
// Just take note that the context is a reference *from* the old ast *to* the
|
||||||
|
Loading…
Reference in New Issue
Block a user