estraverse icon indicating copy to clipboard operation
estraverse copied to clipboard

backward traversal

Open drom opened this issue 10 years ago • 1 comments

First, thank you for very elegant, concise, and useful tool. I use both tools: estraverse and recently shift-traverse for my projects.

One thing that I am missing is backward AST traversal. IMHO It will be useful for the static code analysis algorithms like lazy SSA construction or definition search.

What do you think?

drom avatar Jan 31 '15 21:01 drom

Hey, @drom, I see, you're in theme, but I am a novice. do you know also, are there backward AST generation algorithms?

I build AST locally backward and forward from the point on target node in large (and possibly not correct at all) source code file.

e.g.:

var c conosle.log.bind(console); // far away mistaken statement
... // about 100 sloc
foo({ bar:1, baz: 2, qux: 42 });
//                        ^ Starts AST-generation here for ObjectExpression

I use acorn.parseExpressionAt and some heuristics for that.

a-x- avatar Jul 08 '16 09:07 a-x-