Parsing JS code into ASTs and tools to query and transform these trees.
npm install lively.astParsing JS code into ASTs and tools to query and transform these trees.
- ast.printAst
- ast.compareAst
- ast.pathToNode
- ast.stringify
- ast.parse
- ast.parseFunction
- ast.fuzzyParse
- ast.nodesAt
- ast.withMozillaAstDo
- ast.MozillaAST.BaseVisitor
- ast.MozillaAST.PrinterVisitor
- ast.MozillaAST.ComparisonVisitor
- ast.MozillaAST.ScopeVisitor
- ast.query.knownGlobals
- ast.query.scopes
- ast.query.nodesAtIndex
- ast.query.scopesAtIndex
- ast.query.scopeAtIndex
- ast.query.scopesAtPos
- ast.query.nodesInScopeOf
- ast.query.topLevelDeclsAndRefs
- ast.query.findGlobalVarRefs
- ast.query.findNodesIncludingLines
- ast.query.findReferencesAndDeclsInScope
- ast.query.findDeclarationClosestToIndex
- ast.transform.replace
- ast.transform.replaceTopLevelVarDeclAndUsageForCapturing
- ast.transform.oneDeclaratorPerVarDecl
- ast.transform.oneDeclaratorForVarsInDestructoring
- ast.transform.returnLastStatement
- ast.transform.wrapInFunction
- ast.comments.extractComments
- ast.codeCategorizer.findDecls
``js`
var ast = require('lively.ast'),
parsed = ast.parse("1 + 2");
ast.printAst(parsed);
// =>
// :Program
// \-.body[0]:ExpressionStatement
// \-.body[0].expression:BinaryExpression
// |-.body[0].expression.left:Literal
// \-.body[0].expression.right:Literal
...
HTML:
JS: like above
npm run build
npm test`
MIT