HOLY SHIFT! Linda Zheng Roadmap You are here My Shift - - PowerPoint PPT Presentation
HOLY SHIFT! Linda Zheng Roadmap You are here My Shift - - PowerPoint PPT Presentation
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
Roadmap
Introduction Shift Overview Shift AST My Experience with Shift
You are here
What is the Shift Project?
Abstract Syntax Tree (AST)
Binary Expression Identifier PLUS “a” Identifier “b”
a + b
Shift Parser
- ~100 nodes
- Full support for ES6 features
- Complies with ECMAScript Standard
The Shift AST
- So much JS code…
- So much math...
- Uh oh...
- Replace all “+” with “*”
Example Use Case
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 Expression PLUS “a” Identifier Expression “b” MUL
Next Step: Code Generator
- Transformations
- Analysis
Where Shift AST Shines
Roadmap (again)
Introduction Shift Overview Shift AST My Experience with Shift
You are here
Contributions to Shift
- Generate Shift AST nodes
- Parser
- Reducer (single state)
- Code Generator
- Fuzzer
- AST Validator
- Serializer / Deserializer
Node Statement
Expression
“orphans”
➢ LiteralNumeric ➢ Array ➢ StaticMember ➢ Binary ➢ LiteralString ➢ This ➢ … ➢ If ➢ ForIn ➢ Break ➢ TryCatchFinally ➢ Return ➢ Block ➢ … ➢ BindingIdentifier ➢ FunctionBody ➢ ClassDeclaration ➢ Super ➢ Script ➢ Module ➢ …
Function Declaration Function Expression Class Expression Class Declaration Function Expression Super Class Expression Super
“{“ ObjectBinding “({x, y}=0)” (Orphans Family) ObjectExpression “({x, y})” (Expression Family) Either <Expression, Binding> Has “=” Return Expression Return Binding No “=” Transform Destructuring
ParseObject
“[“ ArrayBinding “[x, y]=0” (Orphans Family) ArrayExpression “[x, y]” (Expression Family) Either <Expression, Binding> Has “=” Return Expression Return Binding No “=” Transform Destructuring
ParseArray
Roadmap (final)
Introduction Shift Overview Shift AST My Experience with Shift
You are here!!!