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.

evaluator.js 531B

123456789101112131415161718192021222324252627
  1. const AST = require('./ast')
  2. const Env = require('./env')
  3. module.exports = class Evaluator {
  4. eval(tree, env) {
  5. let evaluatedTree = []
  6. tree.forEach(node => {
  7. evaluatedTree.push(this.evalNode(node, env))
  8. })
  9. return evaluatedTree
  10. }
  11. evalNode(node, env) {
  12. switch (node.constructor) {
  13. case AST.Application:
  14. switch (node.function.constructor) {
  15. case AST.Identifier:
  16. node.function = env.get(node.function.name)
  17. break
  18. }
  19. }
  20. return node
  21. }
  22. }