2 Star 0 Fork 0

mirrors_jsantell / 2013.cascadiajs.com

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
editing-large-codebases-with-an-ast_dahjelle.md 1.78 KB
一键复制 编辑 原始数据 按行查看 历史

#Editing Large Legacy Codebases with an Abstract Syntax Tree

##Abstract

I recently had to make changes across 100+ legacy Javascript files that could not be made via regexp search-and-replace [1]. To make this faster(?) and less typo-prone, I used Node.js and Rocambole to extract an abstract syntax tree (AST), edit it (and the associated token stream), and output the result. In this talk, I'll discuss what an AST is, my particular code transformation, how to edit code with a tool like Rocambole, and even implement a micro-Javascript interpreter.

While I don't do anything particularly novel or unique with the AST, I found the technique useful and enlightening — and, if you've never looked at an AST before, I think you will, too.

[1] For instance, I had to change code from (you'll see why it had to get changed…)

var a = "index.php?new=" + b.c;
eval( "my_iframe.location = '" + a + "'" );

to

io.frameGET( "index.php", {
    "new": b.c
}, document.getElementById( "my_iframe" ) );

##Speaker Bio

dahjelle

I've been developing professionally for the web for four years, but have programmed in my spare time for many more. I currently work at Icon Systems, Inc., where I am lead developer on IconCMO: software to track membership, contributions, and accounting for churches and other non-profits. I love creating tools that enrich and help the lives of everyday people.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_jsantell/mirrors_jsantell_2013.cascadiajs.com.git
git@gitee.com:mirrors_jsantell/mirrors_jsantell_2013.cascadiajs.com.git
mirrors_jsantell
mirrors_jsantell_2013.cascadiajs.com
2013.cascadiajs.com
master

搜索帮助