4 ms·
This is a surprisingly difficult problem and yet not as common an issue as you might anticipate. For most use cases you can rely on the filename or extension.
by boyter 6y ago
This is a surprisingly difficult problem and yet not as common an issue as you might anticipate. For most use cases you can rely on the filename or extension.
I wrote scc and it eventually reached enough people I needed to add some basic checks to determine the difference between coq and verilog. It’s primitive mostly because I try to prioritise speed without losing accuracy. Another code counter tokei does not do this at all and only uses extensions. The number of people unhappy with this decision is surprisingly small.
But you could easily get away with just remapping as I doubt they occur in the same repo very often.
That said I’m looking at improving this sort of thing because of the number of C with C++ code bases.
Oh I should also mention there is no universal list of extension and name to language mapping anywhere online. Each tool builds it’s own. I’d love someone to take this on and have some sort of standard for everyone to follow and build against.
- ducktective 6y agoFor enry, there is a `alias.go` file in the tree that contains the extention_to_language mappings. Yeah, I've also found that there is no standard for this. Anyway, I've reformatted that file as json: https://dpaste.com/APYDEJPKJ https://dpaste.com/APYDEJPKJ