Browse Source

Clean up unused stuff

master
Dylan Baker 5 years ago
parent
commit
681a88a755
2 changed files with 3 additions and 29 deletions
  1. 3
    27
      src/compiler.js
  2. 0
    2
      src/index.js

+ 3
- 27
src/compiler.js View File

1
-const util = require('util')
2
 const selfClosingTags = require('./util/selfClosingTags')
1
 const selfClosingTags = require('./util/selfClosingTags')
3
 
2
 
4
 module.exports = class Compiler {
3
 module.exports = class Compiler {
7
     this.context = context
6
     this.context = context
8
     this.pos = 0
7
     this.pos = 0
9
     this.result = ''
8
     this.result = ''
10
-    this.standardLibrary = {
11
-      cond: function(predicate, left, right) {
12
-        if (predicate) {
13
-          let compiler = new Compiler([left], this.context)
14
-          return compiler.compile()
15
-        } else {
16
-          let compiler = new Compiler([right], this.context)
17
-          return compiler.compile()
18
-        }
19
-      },
20
-    }
21
   }
9
   }
22
 
10
 
23
   compile() {
11
   compile() {
26
         case 'Application':
14
         case 'Application':
27
           this.result += this.application(node)
15
           this.result += this.application(node)
28
           break;
16
           break;
29
-        case 'String':
30
-          this.result += node.value;
31
-          break;
32
         case 'Identifier':
17
         case 'Identifier':
33
           this.result += this.lookup(node)
18
           this.result += this.lookup(node)
34
           break;
19
           break;
20
+        case 'String':
21
+          this.result += node.value;
22
+          break;
35
       }
23
       }
36
     })
24
     })
37
 
25
 
39
   }
27
   }
40
 
28
 
41
   application(node) {
29
   application(node) {
42
-    if (this.standardLibrary[node.functionName.name]) {
43
-      return this.standardLibrary[node.functionName.name](...node.args)
44
-    }
45
-
46
-    return this.htmlElement(node)
47
-  }
48
-
49
-  htmlElement(node) {
50
     let result = `<${node.functionName.name}`
30
     let result = `<${node.functionName.name}`
51
 
31
 
52
     node.args.filter(arg => arg.constructor.name === 'Attribute').forEach(arg => {
32
     node.args.filter(arg => arg.constructor.name === 'Attribute').forEach(arg => {
83
 
63
 
84
     return result
64
     return result
85
   }
65
   }
86
-
87
-  currentNode() {
88
-    return this.tree[this.pos]
89
-  }
90
 }
66
 }

+ 0
- 2
src/index.js View File

2
 const Parser = require('./parser')
2
 const Parser = require('./parser')
3
 const Compiler = require('./compiler')
3
 const Compiler = require('./compiler')
4
 
4
 
5
-const util = require('util')
6
-
7
 module.exports = function oslo(source, context) {
5
 module.exports = function oslo(source, context) {
8
   const lexer = new Lexer()
6
   const lexer = new Lexer()
9
   const tokens = lexer.scan(source)
7
   const tokens = lexer.scan(source)

Loading…
Cancel
Save