Is this really something no human should undertake?
Answering your question literally, it is something humans have undertaken and may well have to undertake again. But more importantly, should you do it? Or perhaps, when should you do it?
You've proposed wanting to reject formats that the existing implementation would accept. In practice this isn't an issue, because the rejection of tokens which are invalid according to your language's lexical syntax, is something that should happen before you call out to a third-party library to determine the meaning of those tokens. That is, your language's lexer should already be rejecting invalid number literals. Likewise, if you're parsing numbers dynamically at runtime (i.e. your standard library's parsing function, rather than your language's lexer), then you can check the string's format before calling out to the library. So this isn't a reason to avoid an existing implementation.
As you say, you may need to transform the string into a format accepted by the existing implementation, e.g. if your syntax allows underscores within number literals and the existing implementation doesn't accept them, then you'll need to strip them out first. But this is easy to do*, and not a reason to avoid the existing implementation.
One reason I can think of to implement your own conversion from decimal strings to binary fractional numbers, is if you need to support a different binary representation than standard floating-point. For example, your language might have a built-in arbitrary-precision number type, and allow literals of that type, in which case parsing as a fixed-width floating-point type isn't going to cut it. However, even in this case it would still make more sense to use an existing library, if there is an acceptable one for your host language.
On the other hand, there are two very good reasons to avoid "rolling your own" solution when an existing, tried and tested solution is available:
- Your code could have a bug which gives incorrect parses in a rare case, and this would be hard to spot particularly if the error in the resulting value is small.
- Your code could have a bug causing an infinite loop in a rare case, like this one in PHP. Because the same parsing function was being used at runtime, the fallout of that bug was that almost any web application written in PHP was vulnerable to a denial of service attack, simply by the user entering the string
2.2250738585072011e-308 anywhere a number was expected.
Given the stakes of getting this wrong, then, you should only attempt this both when no existing battle-tested implementation could meet your needs, and also when you have the capability to verify the correctness of your implementation to a very high degree of confidence (e.g. formal verification or fuzz-testing).
*In the comments it's been noted that this is not, in fact, easy for Python (source link), since a transformation is required to convert a string into the locale expected by strtod. But the same logic applies: prefer a tried-and-tested existing library that already does this (or doesn't need to), and only write your own as a last resort.
strtodaccepting formats you prefer to reject presents a problem; you’re only going to feed valid tokens of the language into it, which by definition are in formats you do want to accept. $\endgroup$strtodaccepting formats you prefer to reject, isn’t it? I don’t think that single-pass token construction is generally a concern for a typical language, in any case, so it would probably be good to outline the circumstances that will make it a necessity for this one. The real-world answer is almost certainly “usestrtod” (e.g. Python here, which is still doing work around it), but there could still be situations where that’s available but unsuitable. $\endgroup$strtodnumber (including locale concerns) by which time you almost might as well just finish the job. This suggests thatstrtodis the wrong abstraction: too "stringly-typed" in a sense for how e.g. Python wishes to represent numbers. $\endgroup$