Andrea Lattuada, Gabriele Petronella - Building startups on Scala
Gabriele Petronella - Mythical trees and where to find them - Codemotion Milan 2017
-
Upload
codemotion -
Category
Technology
-
view
50 -
download
4
Transcript of Gabriele Petronella - Mythical trees and where to find them - Codemotion Milan 2017
Tokens const answer = 42 ;// | | | | | | | | | |// \_'const'_/ \_name_/ \_'='_/ \_num_/ \_';'_/
@gabro27 - Codemotion 11/11/2017
Grammar const answer = 42 ;// | | | | ||// | \_Identifier__/ \_NumericLiteral_/|// | | |// | \_________VariableDeclarator________/// | |// \____________VariableDeclaration____________/
@gabro27 - Codemotion 11/11/2017
Why Abstract?const answer = 42;
const answer = 42
const answer = 42
const answer = 42
@gabro27 - Codemotion 11/11/2017
AST? ASTs!
parser AST ES2017 ES next
acorn ESTree ✅ only stage-4
babylon Babylon AST ✅ ✅
espree ESTree ✅ same as acorn
esprima ESTree ✅ ❌
flow ESTree + custom ✅ ✅
TypeScript TypeScript AST ✅ ✅
@gabro27 - Codemotion 11/11/2017
demo: literal transformation
@gabro27 - Codemotion 11/11/2017
codemod tools» recast
» jscodeshift
@gabro27 - Codemotion 11/11/2017
demo: no-console-log
@gabro27 - Codemotion 11/11/2017
// MyContainer.js
import t from 'tcomb';import container from 'buildo-react-container';import MyComponent from './MyComponent';
export default container(MyComponent, { connect: { isFlag: t.Boolean, name: t.String, label: t.maybe(t.String) }});@gabro27 - Codemotion 11/11/2017
// state.js
export default { isFlag: t.Boolean, name: t.String, label: t.maybe(t.String)}
@gabro27 - Codemotion 11/11/2017
// MyContainer.js
import t from 'tcomb';import container from 'buildo-react-container';import MyComponent from './MyComponent';
export default container(MyComponent, { connect: ['isFlag', 'name', 'label']});
@gabro27 - Codemotion 11/11/2017
DEMO@gabro27 - Codemotion 11/11/2017
Some resources» astexplorer.net
» Babel Handbook
@gabro27 - Codemotion 11/11/2017