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 371B

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