Is there a tree-sitter parser for purescript grammar?

Hello nice people ^^

I am a newbie. My editor uses tree-sitter to parse source files. For lack of a purescript grammar on the published list , they replaced it with the haskell grammar !

Do you think this is somewhat ok ?
Do you think this is totally outrageous for purescript-lang ?

1 Like

The two languages are similar in their syntax, so it’s probably fine for 80% of use cases.

1 Like

That will hopefully cover 100% of newbie code

In fact, the ACE editor used in uses ACE’s Haskell grammar for PureScript syntax highlighting, so you’re in good company. The only times I even notice the difference is when it specially highlights function names that are in the Haskell prelude but missing, or named differently, in the PureScript prelude/core libraries. (No idea if Tree-sitter’s grammars do the same sort of thing, but I suspect they are unlikely to fail in a more annoying way than that.)

Grammars in editors like ace usually just lexeme based (or very simple state machines), where tree-sitter is meant to parse a full concrete syntax. I think the grammars are sufficiently different that you would never have a fully parsed document. For just highlighting, this may be ok depending on how fine grained the error recovery is, but if it’s used for any other feedback it’s probably unusable, unfortunately.

1 Like

For whomever see fit, I use helix editor written in Rust.

It’s ready to go in one curl command (zero conf, language-servers work out of the box) and has no latency + a modal interface (à la vim).

For now, they pull the haskell grammar (from tree-sitter repo). They use it to navigate, not from word to word or goto, but jump around over the AST.

Tree-sitter produces error tolerant and robust syntax trees, which enables better syntax highlighting, indent calculation and code navigation.

1 Like

I wish I could dig into it but at my current newbie level I am unable to contribute. It’s the “bootstrap community member” problem ^-^.

No worry, I can switch back to neovim if it severely fails.