I'm writing the C-test for AI22-0144-1.
This is the RM sytax excerpt for integer literals.
Syntax of integer literal:
2.4(1) ...; an integer literal is a numeric_literal without a point.
2.4(2) numeric_literal ::= decimal_literal | based_literal
2.4.1(2) decimal_literal ::= numeral [exponent]
2.4.1(3) numeral ::= digit {[underline] digit}
2.4.1(4) exponent ::= E [+] numeral | E – numeral
2.4.1(4.1/2) digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
2.4.1(5) An exponent for an integer literal shall not have a minus sign.
2.4.1(5.a) Ramification: Although this rule is in this subclause,
it applies also to the next subclause.
2.4.2(2) based_literal ::= base # based_numeral # [exponent]
2.4.2(3) base ::= numeral
2.4.2(4) based_numeral ::= extended_digit {[underline] extended_digit}
2.4.2(5) extended_digit ::= digit | A | B | C | D | E | F
A.10.8(8) If the value of the parameter Width is zero, skips any leading
blanks, line terminators, or page terminators, then reads a
plus sign if present or (for a signed type only) a minus sign
if present, then reads the longest possible sequence of
characters matching the syntax of a numeric literal without
a point, or a prefix of such syntax... (Text of AI22-0144-1)
Rule 2.4.1(2) and 2.4.2(2) have been adapted to integer literal according
to 2.4(1) by omitting the part with the dot. This is correct since reading
stops when a dot is encountered in the input string, leaving the dot in the
input string, for instance reading "1.0" stops after '1' and returns the
integer 1; it does not raise Data_Error.
2.4.2(6) is a legality rule which is applied after reading the literal has
ended. It talks about the base range 2 .. 16 and the maximum value of an
extended digit.
Problem 1
Now there is a problem with 2.4.1(4). The old Ada 83 CE3704F "legacy test"
has "10E-2X" as input stream and the reading stops before 'X'. Rule 2.4.1(5)
being a syntax rule (it's under the headline Syntax), not a legality rule,
reading must stop after the exponent 'E' before '-', leaving "-2X" in the
input stream.
Because test CE3704F is a legacy test, insisting on my interpretation of
the RM rules would mean that each and every still existing Ada compiler
would have to change if it wants to comply tho the ACVC.
I do not deem this a viable option. So I propose to insert a new headline
Legality Rules before 2.4.1(5) and 2.4.1(5.a).
With this change, the old interpretation leaving only 'X' in the input
stream when reading "10E-2X" is still correct.
Problem 2
Reading exactly Width=10 characters of "12#11B0# X", what is the result?
Data_Error because of trailing blanks or the integer value 12#11B0#?
A.10.8(8) ... If a nonzero value of Width is supplied, then exactly
Width characters are input, or the characters (possibly
none) up to a line terminator, whichever comes first; any
skipped leading blanks are included in the count.
Attribute 'Value ignores leading and trailing blanks.
Reading from String returns the position of the last character read.
Reading with Width=0 stops upon blanks.
"12#11B0# X" (note: 'X' at position 10) will raise Data_Error, the whole
sequence will be evaluated and a blank inside is illegal.
"12#11B0# X" (note: 'X' at position 11, not read) IMHO will also raise
Data_Error. Contrary to the 'Value case, there is nowhere
a statement that trailing blanks are ignored when reading
from a file. They always stop reading.
There is no ACVC test for this case (at least, I didn't find one).
GNAT does not raise Data_Error.
Which interpretation is correct?
I'm writing the C-test for AI22-0144-1.
This is the RM sytax excerpt for integer literals.
Rule 2.4.1(2) and 2.4.2(2) have been adapted to integer literal according
to 2.4(1) by omitting the part with the dot. This is correct since reading
stops when a dot is encountered in the input string, leaving the dot in the
input string, for instance reading "1.0" stops after '1' and returns the
integer 1; it does not raise Data_Error.
2.4.2(6) is a legality rule which is applied after reading the literal has
ended. It talks about the base range 2 .. 16 and the maximum value of an
extended digit.
Problem 1
Now there is a problem with 2.4.1(4). The old Ada 83 CE3704F "legacy test"
has "10E-2X" as input stream and the reading stops before 'X'. Rule 2.4.1(5)
being a syntax rule (it's under the headline Syntax), not a legality rule,
reading must stop after the exponent 'E' before '-', leaving "-2X" in the
input stream.
Because test CE3704F is a legacy test, insisting on my interpretation of
the RM rules would mean that each and every still existing Ada compiler
would have to change if it wants to comply tho the ACVC.
I do not deem this a viable option. So I propose to insert a new headline
Legality Rules before 2.4.1(5) and 2.4.1(5.a).
With this change, the old interpretation leaving only 'X' in the input
stream when reading "10E-2X" is still correct.
Problem 2
Reading exactly Width=10 characters of "12#11B0# X", what is the result?
Data_Error because of trailing blanks or the integer value 12#11B0#?
Attribute 'Value ignores leading and trailing blanks.
Reading from String returns the position of the last character read.
Reading with Width=0 stops upon blanks.
There is no ACVC test for this case (at least, I didn't find one).
GNAT does not raise Data_Error.
Which interpretation is correct?