Zulip Chat Archive

Stream: lean4

Topic: Description of the parser?


Tanner Swett (Aug 03 2023 at 10:17):

Is there a document that describes how the Lean 4 parser works? I know that the parser prefers longer parses, and that the default associativity is... uh, I forget. But I have no idea what the algorithm actually does in order to obtain a parse tree.

Mac Malone (Aug 03 2023 at 13:36):

@Tanner Swett The header of Lean.Parser.Basic gives a high-level overview of the parser and docs#Lean.Parser.prattParser explains how specifically the precedence works.

Tanner Swett (Aug 03 2023 at 21:44):

Very nice, thank you!

It looks like the idea behind the parser is... neither terribly simple nor terribly complicated. I could probably get a good understanding of it given a few hours to puzzle stuff out.


Last updated: Dec 20 2023 at 11:08 UTC