A templating language that looks like Lisp and compiles to HTML
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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. }