Re:Difftastic, a structural diff tool that understands syntax
by TeMPOraL on Friday March 22, 2024 @05:36AM
(#39788876)
Okay, but how does that work with language versions? Like, if I get a "C++ parser" for tree-sitter, how do I know if it's C++03, C++17, C++21 or what? Last time I checked (which was months ago, to be fair), this wasn't documented anywhere, nor were there apparent any mechanisms to support langauge versions and variants.
[ Parent
| on HN ]
Re:Difftastic, a structural diff tool that understands syntax
by pfdietz on Friday March 22, 2024 @09:48AM
(#39790736)
And then there's all the variants of SQL...
Re:Difftastic, a structural diff tool that understands syntax
by MathMonkeyMan on Friday March 22, 2024 @01:07PM
(#39792731)
You can probably rely on backward compatibility of the language and use the "latest." The question is, which version is the grammar written against?
Re:Difftastic, a structural diff tool that understands syntax
by Arech on Friday March 22, 2024 @02:59PM
(#39793691)
That's what I was looking at in the very beginning. Here's how it unfolds:
Grammar page (https://github.com/tree-sitter/tree-sitter-cpp) reference two documents at the very end:
- Hyperlinked C++ BNF Grammar (https://alx71hub.github.io/hcb/)
- EBNF Syntax: C++ (ISO/IEC 14882:1998(E)) https://www.externsoft.ch/download/cpp-iso.html
The second doc has a year in the title, so it's ancient af. The first one has multiple `C++0x` red marks (whatever that mean, afair that's how C++11 was named before standardization). It mentions `constexpr`, but doesn't know `consteval`, for example. And doesn't even mention any of C++11 attributes, such as [[noreturn]], so despite the "Last updated: 10-Aug-2021", it's likely pre-C++11 and is also ancient af and have no use in a real world.
Who might have thought. /s