Last active
April 14, 2019 09:01
-
-
Save MinimumViablePerson/f965303299c7a32c89e6e219c023a45c to your computer and use it in GitHub Desktop.
A little AST for Jordan Scales' evaluator exercise that evaluates to `PenPinappleApplePen!`, with `Pen`, `Pinapple` and `Apple` stored in variables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check out this article to write your own evaluator for it! http://thatjdanisso.cool/programming-languages/ | |
const ppap = { | |
type: 'Let', | |
name: 'p', | |
value: { | |
type: 'String', | |
content: 'Pen' | |
}, | |
expression: { | |
type: 'Let', | |
name: 'p2', | |
value: { | |
type: 'String', | |
content: 'Pineapple' | |
}, | |
expression: { | |
type: 'Let', | |
name: 'a', | |
value: { | |
type: 'String', | |
content: 'Apple' | |
}, | |
expression: { | |
type: 'Append', | |
first: { | |
type: 'Append', | |
first: { | |
type: 'Variable', | |
name: 'p' | |
}, | |
second: { | |
type: 'Variable', | |
name: 'p2' | |
} | |
}, | |
second: { | |
type: 'Append', | |
first: { | |
type: 'Variable', | |
name: 'a' | |
}, | |
second: { | |
type: 'Excite', | |
expression: { | |
type: 'Variable', | |
name: 'p' | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment