(code: string)
| 135 | } |
| 136 | |
| 137 | parse(code: string): Program { |
| 138 | let ast = this._parseAst(code); |
| 139 | let tokens = this._processTokens(ast, code); |
| 140 | let program = buildElementTree(ast, tokens); |
| 141 | let programPlugins = {}; |
| 142 | let plugins = this._options.plugins; |
| 143 | for (let plugin of plugins) { |
| 144 | let api = plugin.createApiForProgram(program); |
| 145 | if (api) { |
| 146 | let pluginName = plugin.getPluginName(); |
| 147 | if (pluginName in programPlugins) { |
| 148 | throw new Error(`Plugin "${pluginName}" was already registered.`); |
| 149 | } else { |
| 150 | programPlugins[pluginName] = api; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | program._acceptPlugins(programPlugins); |
| 156 | |
| 157 | return program; |
| 158 | } |
| 159 | |
| 160 | _parseAst(code: string): Program { |
| 161 | let options = this._options; |
no test coverage detected