1234567891011121314151617181920212223 |
- const AST = require('./ast')
-
- module.exports = class Compiler {
- constructor() {
- this.result = ''
- }
-
- compile(tree) {
- tree.forEach(node => {
- this.result += this.compileNode(node)
- })
-
- return this.result
- }
-
- compileNode(node) {
- switch (node.constructor) {
- case AST.Number:
- case AST.String:
- return node.value
- }
- }
- }
|