Stream: t-compiler/rust-analyzer

Topic: ungrammar and rowan


Yoshua Wuyts (Mar 02 2021 at 12:00, on Zulip):

Heya! -- I'm trying to get more familiar with Rust's parser infastructure, and one thing I'm unclear about is what the role of rowan is and what the role of ungrammar is. Both seem to be used within Rust-Analyzer -- and it seems I might be missing a bit of understanding what each of these is best suited for?

matklad (Mar 02 2021 at 12:04, on Zulip):

Rowan is a data structure for a concrete syntax tree. The parser, the code that turns text into a rowan tree, is the parser inside rust-analyzer.

Concrete syntax tree is dynamically typed (think serde_json::Value), ungrammar is tool we used to layer typed access methods over the underlying tree.

Laurențiu (Mar 02 2021 at 12:05, on Zulip):

Also https://rust-analyzer.github.io/blog/2020/10/24/introducing-ungrammar.html

Yoshua Wuyts (Mar 02 2021 at 12:06, on Zulip):

ohh, yes okay that makes sense

Yoshua Wuyts (Mar 02 2021 at 12:06, on Zulip):

thank you

Yoshua Wuyts (Mar 02 2021 at 12:07, on Zulip):

@Laurențiu Nicola hehe, yeah I've been combing over that article for the past day -- I had some trouble getting the relationship between the various components click

Laurențiu (Mar 02 2021 at 12:08, on Zulip):

There's also a bunch of notes and links in https://github.com/KirillOsenkov/Bliki/wiki/Roslyn-Immutable-Trees

Yoshua Wuyts (Mar 02 2021 at 12:09, on Zulip):

oh! -- I've heard of Roslyn, will check it out -- thank you!

Laurențiu (Mar 02 2021 at 12:10, on Zulip):

I don't remember much of the details, but I think Roslyn was the first implementation (for C#), libsyntax took a similar approach, but doesn't rely as much on a GC, and rowan is still evolving.

Laurențiu (Mar 02 2021 at 12:11, on Zulip):

matklad can surely say more :)

Yoshua Wuyts (Mar 02 2021 at 12:11, on Zulip):

hmm, question: I believe Rust-Analyzer is considering moving to mutable trees at some point in the future? - would that deviate much from how Rust-Analyzer's components work today?

Yoshua Wuyts (Mar 02 2021 at 12:12, on Zulip):

/me realizes they should read the mutable tree RFC more closely

Last update: Jul 27 2021 at 22:00UTC