The attached patch adds support for floating-point literals with an integer significand, such as 1E-5.
While the standard stipulates the significand should be decimal, this seems like a somewhat arbitrary restriction, considering many other languages allow integer significands.
The solution is good, idea interesting. But I'm unsure if we should do this.
Can you please check other compiler's manuals? If they have this extension we add it for compatibility purposes.
In any case I'd like to have this only with a new config setting and don't set this in default.conf - in the current implementation it even can break existing source as 1E-5 is a valid COBOL word (vars, sections, ...).
Therefore the scanner.l has to lookup the setting and unput everything if the setting isn't active.
No other compilers appear to have this extension.
That's a good point. I doubt many people will be willing to take the (small) risk of breaking their code.
Attached is version 2, which makes integer-significand support dependent on the config option
integer-significands
.Any further thoughts? If we don't want to add integer significands, I'll like to commit most of this patch anyway so that there's a more helpful error message ("Integer significands are not permitted" instead of "Unexpected identifier").
While the patch got better: What happens if a var or section is called 1E6? It's a rare issue but one we should consider.
In any case: it's enough to have one test for most compiler and runtime configuration options - one to three test progs and multiple AT_CHECK with different options.
Simon
Version 3
Changes:
I did briefly consider making literals with integer significands context-sensitive, but I think ambiguities like these are unsolvable: