MCPcopy Create free account
hub / github.com/cst/cst / parse

Method parse

src/Parser.js:137–158  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

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;

Callers 15

parseAndGetProgramFunction · 0.95
parseAndGetStatementFunction · 0.95
parseAndGetExpressionFunction · 0.95
parseAndGetPatternFunction · 0.95
parseAndGetClassMemberFunction · 0.95
parseAndGetObjectKeyFunction · 0.95
parseAndGetSuperFunction · 0.95

Calls 6

_parseAstMethod · 0.95
_processTokensMethod · 0.95
buildElementTreeFunction · 0.90
_acceptPluginsMethod · 0.80
createApiForProgramMethod · 0.45
getPluginNameMethod · 0.45

Tested by

no test coverage detected