How to use the parseScript function from esprima
Find comprehensive JavaScript esprima.parseScript code examples handpicked from public code repositorys.
GitHub: joshlarsen/driftbot
221 222 223 224 225 226 227 228 229 230
tolerant: true } logger.log(`[ast] analyzing script path=${path}`) esprima.parseScript(source, opts, function(node) { if (_isSuspiciousCall(host, node, path)) { if (results.suspicious_script_hosts.indexOf(host) < 0) { results.suspicious_script_hosts.push(host) }
1
11
0
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
} } if (_.isString(this.caps[capName])) { try { esprima.parseScript(this.caps[capName]) debug(`Loaded Capability ${capName} function as javascript`) return (container, browser) => { debug(`Running ${capName} function from inline javascript ...`)
5
4
0
GitHub: brave/sugarcoat
569 570 571 572 573 574 575 576 577 578 579
}; const rewrite = (mocksMap, recipesMap, scriptName, scriptSrc, trace, policy = null) => { let script; try { script = esprima.parseScript(scriptSrc, { loc: true, range: true, source: scriptName }); } catch { console.log(`Parse error for script ${scriptName}! Ignoring...`) return null; }
4
34
0
GitHub: Dejavu333/wok.js
308 309 310 311 312 313 314 315 316 317
}); //---------------------------------------------- // Lexical analysis, Parsing to AST //---------------------------------------------- const ast = esprisma.parseScript(G.script).body out("AST----------------------------------AST") out(ast); //----------------------------------------------
0
2
0
GitHub: anvbis/trivialize
33 34 35 36 37 38 39 40 41 42 43 44 45
console.log('Trivialize v0.0.1 (c) Anvbis'); console.log('https://github.com/anvbis/trivialize'); let script = fs.readFileSync(options.script, 'utf-8'); let tree = esprima.parseScript(script); let executor = new Executor(options.executable); let minimizer = new Minimizer(tree, executor);
0
1
0
182 183 184 185 186 187 188 189 190 191 192 193 194
const TRANSLATOR_COMMENT_REGEX = /^\s*translator:\s?(.*)$/i; for (const path of JS_FILES) { const file = fs.readFileSync(path).toString(); const script = esprima.parseScript(file, { range: true, comment: true }); const translatableStrings = script.body .map(findTranslationCalls) .flat()
0
1
0
GitHub: beatterr/Pixel-Master
56 57 58 59 60 61 62 63 64 65
PO.load(pofile, (error, pofile) => { if (error) { callback(error); } else { let contents = file.contents.toString(); const script = esprima.parseScript(contents, { range: true }); const translationCalls = script.body .map(findTranslationCalls) .flat() .sort((a, b) => a.range.start - b.range.start);
0
1
0
228 229 230 231 232 233 234 235 236 237
return [tokens, inferred_type, word_index]; } } function ignoredElements(file_name) { var contents = readfile(file_name); let parsed = es.parseScript(contents, { range: true, tokens: true }); let tokens = parsed.tokens; for (let i = 0; i < tokens.length; i++) { checkElement(tokens[i], i, tokens); }
0
0
0
+ 2 other calls in file
GitHub: xuan085/zzx-monorepo
3 4 5 6 7 8 9 10 11 12 13
const esprima = require('esprima') const estraverse = require('estraverse') const escodegen = require('escodegen') let code = 'const a = 1' const ast = esprima.parseScript(code) estraverse.traverse(ast, { enter: function (node) { node.kind = 'var' },
0
0
0
esprima.parse is the most popular function in esprima (58 examples)