News for hackers. Stuff that matters.
Re:Difftastic: Syntax-aware structured diff tool by runeks on Thursday July 08, 2021 @12:21PM (#27774141)
It's a great idea, but I don't think defining the syntax of a programming language as a syntax.toml file will work for enough programming languages for this to be useful. You're basically rewriting the parser of your language in a DSL that isn't as expressive as the language the parser is written in.

I think you'd need another parser/syntax interface for this to work. E.g. running a binary that you can submit source code to which responds with a JSON file containing the parsed tokens. That way you can reuse the compiler's parser.

Re:Difftastic: Syntax-aware structured diff tool by Wilfred on Thursday July 08, 2021 @01:10PM (#27774941)
Yeah, so it's basically a lexer with an extremely simplistic parser.

Compiler parsers aren't a great fit for difftastic. They discard comments, they may not give you output if there are syntax errors, and they're usually tied to a specific language version.

Since this format works well for Comby (Rijnard's talk is excellent: https://www.youtube.com/watch?v=JMZLBB_BFNg ) I'm hopeful it's an adequate solution for Difftastic.

It will also users to add their own custom syntax/config formats.

That said, using tree-sitter might be an option. It's more forgiving than compiler parsers.

Re:Difftastic: Syntax-aware structured diff tool by zhengyi13 on Thursday July 08, 2021 @05:29PM (#27777817)
FWIW, as soon as I saw this project, I wondered specifically about Treesitter's applicability to this problem, and I found https://github.com/afnanenayet/diffsitter.

Maybe there's something to be learned there?

Re:Difftastic: Syntax-aware structured diff tool by affyboi on Sunday July 11, 2021 @11:56PM (#27806865)
Author of diffsitter here

I think some of the issues are alleviated because tree sitter was made with text editors in mind, so you're not really getting a compiler parser as editors still care about comments and whatnot. It's also fast, which was a big motivation to use it.