Skip to content

Instantly share code, notes, and snippets.

@MinimumViablePerson
Last active April 14, 2019 09:01
Show Gist options
  • Save MinimumViablePerson/f965303299c7a32c89e6e219c023a45c to your computer and use it in GitHub Desktop.
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.
// 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