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.

compiler.js 387B

1234567891011121314151617181920212223
  1. const AST = require('./ast')
  2. module.exports = class Compiler {
  3. compile(tree) {
  4. let output = ''
  5. tree.forEach(node => {
  6. output += this.compileNode(node)
  7. })
  8. return output
  9. }
  10. compileNode(node) {
  11. switch (node.constructor) {
  12. case AST.Number:
  13. case AST.String:
  14. return node.value
  15. case AST.Lambda:
  16. return '<lambda>'
  17. }
  18. }
  19. }