HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

"Tree-sitter - a new parsing system for programming tools" by Max Brunsfeld

Strange Loop Conference4 HN recommenders · recommended in 4 months, 2018-2024
YouTube
63K views · 8 years ago · talk · evergreen

Max Brunsfeld introduces Tree-sitter, a parsing system for developer tools that offers incremental parsing and robust error recovery through a uniform C API. The talk explains the design, based on LR extended to GLR parsing.

HN points to it as the best explanation of tree-sitter's design choices and as an accessible introduction to parser generators.

Compilers, interpreters & program analysisTesting, debugging & developer tools#tree-sitter#parsing#glr#errorrecovery#developertools#editors

5 comments from Hacker News

@ievans2024 · in “Difftastic, a structural diff tool that understands syntax”

Absolutely agreed, and copying from a comment I wrote last year: I think the fact that tree-sitter is dependency-free is worth highlighting. For context, some of my teammates maintain the OCaml tree-sitter bindings and often contribute to grammars as part of our work on Semgrep (Semgrep uses tree-sitter for searching code and parsing queries that are code snippets themselves into AST matchers). Often when writing a linter, you need to bring along the runtime of the language you're targeting. E.g., in python if you're writing a parser using the builtin `ast` module, you need to match the language version & features. So you can't parse Python 3 code with Pylint running on Python 2.7, for instance. This ends up being more obnoxious than you'd think at first, especially if you're targeting multiple languages. Before tree-sitter, using a language's built-in AST tooling was often the best approach because it is guaranteed to keep up with the latest syntax. IMO the genius of tree-sitter is that it's made it way easier than with traditional grammars to keep the language parsers updated. Highly recommend Max Brunsfield's strange loop talk if you want to learn more about the design choices behind tree-sitter: ▶ this video And this has resulted in a bunch of new tools built off on tree-sitter, off the top of my head in addition to difftastic: neovim, Zed, Semgrep, and Github code search!

Strongly recommendsView on HN
@AlexErrant2023 · in “Lessons from building GitHub code search [video]”

I also enjoyed the Treesitter talk from 5 years ago by Max Brunsfeld ▶ this video I'm currently building a query language whose grammar is very much inspired by Github's search syntax. I'm using Lezer, which is a GLR like Treesitter, so this talk learned me some parser generators (I've no formal CS education). Here's my grammar, a playground, and an example search query if anyone wants to play with it link link -(a) spider-man -a b -c -"(quote\"d) str" OR "l o l" OR a b c ((a "c") b) tag:what -deck:"x y" I just converted the syntax tree to an abstract syntax tree so I can do De Morgan's law transformations. Literally the only time in my professional life where I feel like I'm solving a leetcode-style problem.

RecommendsView on HN
@throwaway_pdp092020 · in “Advanced Compilers: Self-Guided Online Course”

Parsing (use of rather than theory) matters as it affects my work. So I followed up. See ▶ this video Tree sitter is based on LR parsing (see 23:30 in above video) extended to GLR parsing (see 38:30). I've had enough of fools on HN posting unverified crap to make themselves feel cool and knowledgeable (and don't kid yourself that you helped me find the right answer by posting the wrong one). Time I withdrew. Goodbye HN.

CitesView on HN
@rtsao2020 · in “Introducing Semgrep and r2c”

It's great to see more tools adopting tree-sitter [1]. Having a (fast) single tool that can accurately parse most commonly used programming languages is incredibly useful, but it requires the maintenance of dozens of grammars, which is difficult without a large community effort. Hopefully increased adoption means more accurate parsers and support for even more languages. Tree-sitter powers syntax highlighting on GitHub.com and (soon) neovim and OniVim 2. Hopefully regex-based syntax highlighting is a thing of the past soon. If you haven't seen the Strange Loop conference talk on tree-sitter [2] yet, it's worth a watch. I think a Prettier-like code formatter using tree-sitter would be cool, both in terms of potentially broader language support and native performance. [1]: link [2]: ▶ this video

RecommendsView on HN
@lemming2018 · in “Owl: Parser generator for visibly pushdown languages”

For a really nice solution to the error message problem, see this recent strangeloop talk: ▶ this video Basically it uses the parse tree disambiguation from the GLR parser to look for the most likely mistake the user made - it's very clever.

RecommendsView on HN
Tree-sitter: a new parsing system for programming tools - GitHub Universe 201743:00

Tree-sitter: a new parsing system for programming tools - GitHub Universe 2017

GitHub
24K views • 8 years ago
Saša Jurić - Parsing from first principles - WebCamp Zagreb 20191:10:16

Saša Jurić - Parsing from first principles - WebCamp Zagreb 2019

WebCamp Zagreb
6K views • 6 years ago
High-performance Tree Wrangling, the APL Way // Aaron Hsu // Dyalog '1830:37

High-performance Tree Wrangling, the APL Way // Aaron Hsu // Dyalog '18

Dyalog User Meetings
6K views • 7 years ago
Parsing with Derivatives1:13:10

Parsing with Derivatives

Stanford
13K views • 15 years ago
Lexical Scanning in Go - Rob Pike51:18

Lexical Scanning in Go - Rob Pike

GoogleFOSSSydney
162K views • 15 years ago
Episode 1: A basic expression evaluator1:38:36

Episode 1: A basic expression evaluator

Immo Landwerth (terrajobst)
284K views • 8 years ago
Lecture 7A: Metacircular Evaluator, Part 11:24:38

Lecture 7A: Metacircular Evaluator, Part 1

MIT OpenCourseWare
32K views • 7 years ago
"Programming Should Eat Itself" by Nada Amin47:41

"Programming Should Eat Itself" by Nada Amin

Strange Loop Conference
43K views • 12 years ago
Barliman: trying the halting problem backwards, blindfolded - William Byrd, Greg Rosenblatt36:14

Barliman: trying the halting problem backwards, blindfolded - William Byrd, Greg Rosenblatt

ClojureTV
8K views • 9 years ago
Building Your Own Dynamic Language1:14:32

Building Your Own Dynamic Language

Stanford
21K views • 18 years ago
"Stop Writing Dead Programs" by Jack Rusher (Strange Loop 2022)43:04

"Stop Writing Dead Programs" by Jack Rusher (Strange Loop 2022)

Strange Loop Conference
468K views • 4 years ago
Kilim: Fast, lightweight, cheap message passing in Java.45:11

Kilim: Fast, lightweight, cheap message passing in Java.

Google TechTalks
33K views • 18 years ago
"Shen: A Sufficiently Advanced Lisp" by Aditya Siram40:20

"Shen: A Sufficiently Advanced Lisp" by Aditya Siram

Strange Loop Conference
26K views • 12 years ago
"Pixie - A Lightweight Lisp with 'Magical' Powers" by Timothy Baldridge33:13

"Pixie - A Lightweight Lisp with 'Magical' Powers" by Timothy Baldridge

Strange Loop Conference
30K views • 11 years ago
Parsing JSON Really Quickly: Lessons Learned47:52

Parsing JSON Really Quickly: Lessons Learned

InfoQ
86K views • 6 years ago
"Datafun: a functional query language" by Michael Arntzenius42:31

"Datafun: a functional query language" by Michael Arntzenius

Strange Loop Conference
9K views • 9 years ago
"Outperforming Imperative with Pure Functional Languages" by Richard Feldman34:55

"Outperforming Imperative with Pure Functional Languages" by Richard Feldman

Strange Loop Conference
98K views • 5 years ago
Practical Common Lisp1:12:10

Practical Common Lisp

Google TechTalks
98K views • 19 years ago
Lecture 7A | MIT 6.001 Structure and Interpretation, 19861:24:38

Lecture 7A | MIT 6.001 Structure and Interpretation, 1986

MIT OpenCourseWare
35K views • 17 years ago
Brian Goetz - Stewardship: the Sobering Parts1:03:31

Brian Goetz - Stewardship: the Sobering Parts

ClojureTV
39K views • 11 years ago