A templating language that looks like Lisp and compiles to HTML
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

env.js 469B

1234567891011121314151617181920212223242526
  1. module.exports = class Env {
  2. constructor(parent = null) {
  3. if (parent) {
  4. this.data = parent.data
  5. } else {
  6. this.data = {
  7. '+': (a, b) => a + b,
  8. '-': (a, b) => a - b,
  9. '*': (a, b) => a * b,
  10. '/': (a, b) => a / b,
  11. }
  12. }
  13. }
  14. get(symbol) {
  15. if (this.data[symbol]) {
  16. return this.data[symbol]
  17. }
  18. throw `Symbol ${symbol} is not bound`
  19. }
  20. set(symbol, value) {
  21. this.data[symbol] = value
  22. }
  23. }