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,4 +1,3 @@
1
-const util = require('util')
2 1
 const selfClosingTags = require('./util/selfClosingTags')
3 2
 
4 3
 module.exports = class Compiler {
@@ -7,17 +6,6 @@ module.exports = class Compiler {
7 6
     this.context = context
8 7
     this.pos = 0
9 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 11
   compile() {
@@ -26,12 +14,12 @@ module.exports = class Compiler {
26 14
         case 'Application':
27 15
           this.result += this.application(node)
28 16
           break;
29
-        case 'String':
30
-          this.result += node.value;
31
-          break;
32 17
         case 'Identifier':
33 18
           this.result += this.lookup(node)
34 19
           break;
20
+        case 'String':
21
+          this.result += node.value;
22
+          break;
35 23
       }
36 24
     })
37 25
 
@@ -39,14 +27,6 @@ module.exports = class Compiler {
39 27
   }
40 28
 
41 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 30
     let result = `<${node.functionName.name}`
51 31
 
52 32
     node.args.filter(arg => arg.constructor.name === 'Attribute').forEach(arg => {
@@ -83,8 +63,4 @@ module.exports = class Compiler {
83 63
 
84 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,8 +2,6 @@ const Lexer = require('./lexer')
2 2
 const Parser = require('./parser')
3 3
 const Compiler = require('./compiler')
4 4
 
5
-const util = require('util')
6
-
7 5
 module.exports = function oslo(source, context) {
8 6
   const lexer = new Lexer()
9 7
   const tokens = lexer.scan(source)

Loading…
Cancel
Save