Trying to find best solution for some syntax that can set and get variables.
$a = 1 + 1
Internally can keep track of variables already set with a simple object..
const store = {
$a: '1',
$b: '$a + 2',
$c: '$b + 10'
}
$a
// looks up $a, expands to 1
$b
// looks up $b, finds $a + 2, looks up $a and expands to 1 + 2
$c
// looks up $c, finds $b + 10, looks up $b and finds $a + 2, looks up $a and expands
So would need to be able to recursively (or loop) look up variables. Is this something PegJS would be good for?