A templating language that looks like Lisp and compiles to HTML
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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