HOLY SHIFT! Linda Zheng
Roadmap You are here My Shift Introduction Shift AST Experience Overview with Shift
What is the Shift Project?
Abstract Syntax Tree (AST) Binary Expression Identifier Identifier PLUS a + b “a” “b”
Shift Parser
The Shift AST ● ~100 nodes ● Full support for ES6 features ● Complies with ECMAScript Standard
Example Use Case ● So much JS code… ● So much math... ● Uh oh... ● Replace all “+” with “*”
Text Find-and-Replace Problems // ToDo: replace “+” with “*” // ToDo: replace “*” with “*”
Text Find-and-Replace Problems for (i = 0; i < 10; i++) { … } for (i = 0; i < 10; i**) { … }
Text Find-and-Replace Problems var pattern = /a+/ var pattern = /a*/
Solution with Shift AST Binary Expression Identifier Identifier PLUS MUL Expression Expression “a” “b”
Next Step: Code Generator
Where Shift AST Shines ● Transformations ● Analysis
Roadmap (again) You are here My Shift Introduction Shift AST Experience Overview with Shift
Contributions to Shift ● Generate Shift AST nodes ● Parser ● Reducer (single state) ● Code Generator ● Fuzzer ● AST Validator ● Serializer / Deserializer
Node Expression Statement “orphans” ➢ LiteralNumeric ➢ If ➢ BindingIdentifier ➢ Array ➢ ForIn ➢ FunctionBody StaticMember Break ClassDeclaration ➢ ➢ ➢ Binary TryCatchFinally Super ➢ ➢ ➢ ➢ LiteralString ➢ Return ➢ Script ➢ This ➢ Block ➢ Module … … … ➢ ➢ ➢
Function Class Function Function Class Class Declaration Expression Declaration Expression Expression Super Expression Super
ParseObject “{“ ObjectExpression ObjectBinding Has “=” “({x, y})” “({x, y}=0)” (Expression (Orphans Transform Destructuring Family) Family) No “=” Return Return Expression Binding Either <Expression, Binding>
ParseArray “[“ ArrayExpression ArrayBinding Has “=” “[x, y]” “[x, y]=0” (Expression (Orphans Transform Destructuring Family) Family) No “=” Return Return Expression Binding Either <Expression, Binding>
Roadmap (final) You are here!!! My Shift Introduction Shift AST Experience Overview with Shift
Check out these Links! Shift Website http://shift-ast.org/ Shape Github Repo https://github.com/shapesecurity
Recommend
More recommend