rust-analyzer / rowan

Apache License 2.0
677 stars 57 forks source link

Clarify how Rowan could be used with a GLR parser #152

Open TzviPM opened 1 year ago

TzviPM commented 1 year ago

If I understand correctly, Rowan's use in rust-analyzer relies on a recursive descent parser that emits events for nodes beginning or ending and those events are converted by a TreeSink into calls to GreenNodeBuilder's start_node and finish_node.

I'm wondering if it could make sense to use Rowan's syntax tree abstraction with a different sort of parser, say GLR for example, which uses a shift-reduce mechanism for constructing trees and may even fork at some point to attempt multiple non-deterministic branches of the grammar in parallel. In such an algorithm, the context may not be known in advance, so nodes would have to be combined differently.

Can you clarify how I might accomplish this? Would I just make a different Builder abstraction?