My Little Parser: Tooling is Magic
summary
Explains how parsing source to an AST plus CSS‑like selectors lets you find and rewrite real code patterns, not just grep text. Uses esprima/acorn for parsing and falafel plus the module casauron to match nodes; demos include locating HTML concatenation inside BinaryExpression literals to spot XSS and a Rewrite‑JS pipeline that replaces require('tape') with require('assert'), maps test.end to done and tape.equal to strictEqual across a repo. Runs over whole codebases and emits rewritten files.
AI-written summary · about
chapters (8)
- 0:00Code as text vs structure
- 2:06Understanding the AST
- 5:55Tools for AST manipulation
- 8:55CSS selectors on trees
- 12:27CSSauron and JS tools
- 15:18Practical code analysis
- 21:04Automated refactoring
- 25:18The future of AST tools
related talks
27mParsing, Compiling, and Static Metaprogramming
44mJavaScript AST programming: Introduction and beyond
28mAutomating the Automator
29mAST: the Secret Weapon to Transform a Codebase
27mAbusing Preprocessor ASTs
43mMachine Powered Refactoring: Leverage AST's to Push Your Legacy Code (& the Web) Forward
31mAdvanced JavaScript code search: Abstract Syntax Tree analysis
16mVisual statical analysis tool
