mirror of
https://github.com/jamiebuilds/the-super-tiny-compiler.git
synced 2025-06-07 01:44:27 +00:00
Merge a4b38d76e3
into d8d4013045
This commit is contained in:
commit
151cf1f208
@ -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.
|
||||||
@ -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: '(' },
|
||||||
@ -865,8 +865,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