SlideShare a Scribd company logo
AST for JavaScript
developers
I am Bohdan Liashenko
and I work at awesome company @zero-plus-x
You can find me at:
@bliashenko
AST for JavaScript developers
Abstract Syntax Tree
Wh-why?
AST
Plan for today
js2flowchart
Visualization library to
convert any JavaScript
code into beautiful
SVG flowchart
What is AST?
Lexical analysis;
Syntax analysis;
Babylon;
...
Use cases
Babel ;
JSCodeshift;
Prettier;
...
Abstract Syntax Tree
Wh-what?
AST for JavaScript developers
...simplified example
How to get AST from
plain code?
Scratch the surface of compiler
HLL
Code
Lexical
analyzer
Syntax
analyzer
Semantic
analyzer
Intermediate
code generator
Machine independent
code optimiser
Code
generato
r
Machine dependent
code optimiser
0101
0111
AST
Lexical analyzer (scanner)
Takes a string of code and splits it into a list of
tokens
Longest Match Rule
c
c
o n s t _ a
c
o o
n
c
o
n
s
c
o
n
s
t
c
o
n
s
t
...
const keyword
... ...
Language Dictionary
Syntax analyzer (parser)
Takes a list of tokens and turns it into an AST
representation
Lexical
analyzer
Syntax
analyzer
Want to learn more about
compilers?
the-super-tiny-
compiler
Compile some lisp-like
function calls into some
C-like function calls.
https://github.com/jamiebuilds/the-super-
tiny-compiler
LangSandbox
Project to illustrate how
to build a programming
language
https://github.com/ftomassetti/LangSandbox
Can I just use a library?
AST Explorer
Choose one
https://astexplorer.net/
Babylon
Babylon is a JavaScript
parser used in Babel.
Support for JSX, Flow,
Typescript.
Use case:
Code transpiling. Babel.
“Babel is not a ‘tool for having ES6
support’. Well, it is, but it is far not
only what it is about.
JavaScript compiler, specifically
a source-to-source compiler,
often called a "transpiler".
Babel
parse transform generate
AST for JavaScript developers
Babel plugin
… in fact, you only need to transform AST
babel-handbook
A guided handbook on
how to use Babel and how
to create plugins for
Babel
https://github.com/jamiebuilds/babel-handbook
Use case:
Code refactoring. JSCodeshift.
Clean my code in one click
jscodeshift & codemods
jscodeshift is a toolkit for running
“codemods”.
A “codemod” is a code which describes
what transformation should be made
to AST
… boring, show me some code
Some code
React updates/migrations
Replace PropTypes to prop-types
across entire app
Try yourself
https://github.com/facebook/jscod
eshift
https://github.com/reactjs/react-
codemod
Use case:
Code formatting. Prettier.
Make my code great again
IR - Intermediate representation
(also known as a Doc), describes
how AST nodes can be formatted.
Prettier
Code AST IR Code
A prettier printer
Book which explains a
magic behind code
formatting
http://homepages.inf.ed.ac.uk/wadler/pape
rs/prettier/prettier.pdf
js2flowchart
What?
Why?
Automation!
And it was fun.
https://github.com/Bogdan-Lyashenko/js-code-to-
svg-flowchart
Use case
▷ explain/document your code by flowcharts
▷ learn others code by visual understanding
▷ create flowcharts for any process simply
described by valid JS syntax
Paste code -
download SVG.
Live editor
https://bogdan-lyashenko.github.io/js-code-to-svg-flowchart/docs/live-editor/index.html
▷ From code:
▷ CLI: js2flowchart yourFile.js
▷ VS Code extension (built by @LucasBadico)
Or, you can use it:
Features
▷ Abstractions levels
▷ Presentation generator
▷ Flow tree modifiers
▷ Colour themes support
▷ etc...
Abstractions levels
Tree modifiers
FT - Flow tree
ST - ShapesTree
How it works?
Code AST FT ST SVG
Try it out
Docs &
Examples
provided
Thanks!
Any questions?
https://github.com/jamiebuilds/the-super-tiny-compiler
https://github.com/ftomassetti/LangSandbox
https://astexplorer.net/
https://github.com/jamiebuilds/babel-handbook
https://github.com/facebook/jscodeshift
https://github.com/reactjs/react-codemod
http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart
https://bogdan-lyashenko.github.io/js-code-to-svg-flowchart/docs/live-editor/index.html
https://marketplace.visualstudio.com/items?itemName=lucasbadico.code-flowchart
Links

More Related Content

PDF
Redis trouble shooting
PDF
挫折しないRedmine
PPTX
Cvim saisentan 半精度浮動小数点数 half
PDF
GitHubの機能を活用したGitHub Flowによる開発の進め方
PDF
デキるプログラマだけが知っているコードレビュー7つの秘訣
PDF
Mask Material only in Early Z-passの効果と仕組み
PDF
CXL_説明_公開用.pdf
PPTX
ret2dl resolve
Redis trouble shooting
挫折しないRedmine
Cvim saisentan 半精度浮動小数点数 half
GitHubの機能を活用したGitHub Flowによる開発の進め方
デキるプログラマだけが知っているコードレビュー7つの秘訣
Mask Material only in Early Z-passの効果と仕組み
CXL_説明_公開用.pdf
ret2dl resolve

What's hot (20)

PDF
Node.jsアプリの開発をモダン化するために取り組んできたこと
PDF
詳説データベース輪読会: 分散合意その2
PPTX
FOSS4G 2014 Hokkaidoハンズオン - PostGIS入門
PDF
New VIdeo CODEC AV1
PDF
継承やめろマジやめろ。 なぜイケないのか 解説する
PDF
ぐるぐるDDD/Scrum - モデリングと実装のうずまきをまわそう
PDF
Gitはじめの一歩
PDF
Plan 9のお話
PDF
[UE4]マテリアルの注意すべきこと!~テクスチャロードとSwitch~
PDF
Archmodels vol 31
PDF
Shougoの開発環境
PDF
はじめる! Redmine (2017)
PDF
カスタムメモリマネージャと高速なメモリアロケータについて
PDF
UnityによるAR/VR/MR 開発体験講座
PPTX
[CEDEC2018] UE4アニメーションシステム総おさらい
PDF
実践的なHDR出力対応 ~レンダリングパイプラインの構築~
PDF
Git flowの活用事例
PDF
ゲーム開発を知らない人にも分かるKLabのゲーム開発運営
PPTX
GitHub ActionsでiOSのCIを実現しよう
PDF
Obsのプラグイン作ってみた
Node.jsアプリの開発をモダン化するために取り組んできたこと
詳説データベース輪読会: 分散合意その2
FOSS4G 2014 Hokkaidoハンズオン - PostGIS入門
New VIdeo CODEC AV1
継承やめろマジやめろ。 なぜイケないのか 解説する
ぐるぐるDDD/Scrum - モデリングと実装のうずまきをまわそう
Gitはじめの一歩
Plan 9のお話
[UE4]マテリアルの注意すべきこと!~テクスチャロードとSwitch~
Archmodels vol 31
Shougoの開発環境
はじめる! Redmine (2017)
カスタムメモリマネージャと高速なメモリアロケータについて
UnityによるAR/VR/MR 開発体験講座
[CEDEC2018] UE4アニメーションシステム総おさらい
実践的なHDR出力対応 ~レンダリングパイプラインの構築~
Git flowの活用事例
ゲーム開発を知らない人にも分かるKLabのゲーム開発運営
GitHub ActionsでiOSのCIを実現しよう
Obsのプラグイン作ってみた
Ad

Similar to AST for JavaScript developers (7)

PDF
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
PPTX
Don't Be Afraid of Abstract Syntax Trees
PDF
Gabriele Petronella - Mythical trees and where to find them - Codemotion Mila...
PPTX
AST - the only true tool for building JavaScript
PDF
JavaScript and the AST
ODP
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
PDF
Your code is not a string
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Don't Be Afraid of Abstract Syntax Trees
Gabriele Petronella - Mythical trees and where to find them - Codemotion Mila...
AST - the only true tool for building JavaScript
JavaScript and the AST
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
Your code is not a string
Ad

Recently uploaded (20)

PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Digital Strategies for Manufacturing Companies
PPTX
ai tools demonstartion for schools and inter college
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
System and Network Administration Chapter 2
PPTX
history of c programming in notes for students .pptx
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
top salesforce developer skills in 2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Digital Strategies for Manufacturing Companies
ai tools demonstartion for schools and inter college
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How to Migrate SBCGlobal Email to Yahoo Easily
Reimagine Home Health with the Power of Agentic AI​
Operating system designcfffgfgggggggvggggggggg
Digital Systems & Binary Numbers (comprehensive )
Designing Intelligence for the Shop Floor.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
System and Network Administration Chapter 2
history of c programming in notes for students .pptx
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Upgrade and Innovation Strategies for SAP ERP Customers
top salesforce developer skills in 2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf

AST for JavaScript developers