Created
July 22, 2015 10:12
-
-
Save javierarilos/0d9a0d0fe82a642acb53 to your computer and use it in GitHub Desktop.
Javascript simplest parsing with Esprima
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var esprima = require('esprima'); | |
var fs = require('fs'); | |
var jscode = fs.readFileSync('./src/index.js').toString('utf8'); | |
jscode = jscode.replace(/#!.*\n/,''); //remove shebang (executable js files) | |
console.log(jscode); | |
var tree = esprima.parse(jscode); | |
console.log(util.inspect(tree, {depth: 15, colors: true})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment