Skip to content

Commit ab0d381

Browse files
committed
Fix issue 19070 - some octal literals are actually allowed. Also cleaned
up some other numeric grammar issues.
1 parent d9bf60f commit ab0d381

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

spec/lex.dd

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,15 @@ $(GNAME IntegerSuffix):
660660
$(B UL)
661661

662662
$(GNAME DecimalInteger):
663-
$(B 0)
663+
$(GLINK ZeroDigits)
664+
$(GLINK ZeroDigits) $(GLINK OctalDigit)
664665
$(GLINK NonZeroDigit)
665666
$(GLINK NonZeroDigit) $(GLINK DecimalDigitsUS)
666667

668+
$(GNAME ZeroDigits):
669+
$(B 0)
670+
$(B 0) $(GSELF ZeroDigits)
671+
667672
$(GNAME BinaryInteger):
668673
$(GLINK BinPrefix) $(GLINK BinaryDigitsNoSingleUS)
669674

@@ -787,7 +792,8 @@ $(GNAME HexLetter):
787792
)
788793

789794
$(P C-style octal integer notation was deemed too easy to mix up with decimal notation;
790-
it is only fully supported in string literals.
795+
it is only fully supported in string literals or when the decimal interpretation would be equivalent
796+
(e.g. $(D 007) is accepted)
791797
D still supports octal integer literals interpreted at compile time through the $(REF octal, std,conv)
792798
template, as in $(D octal!167).)
793799
$(P Hexadecimal integers are a sequence of hexadecimal digits preceded
@@ -861,12 +867,12 @@ $(GNAME Float):
861867
$(GLINK HexFloat)
862868

863869
$(GNAME DecimalFloat):
864-
$(GLINK LeadingDecimal) $(B .)
865-
$(GLINK LeadingDecimal) $(B .) $(GLINK DecimalDigits)
866-
$(GLINK DecimalDigits) $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
867-
$(B .) $(GLINK DecimalInteger)
868-
$(B .) $(GLINK DecimalInteger) $(GLINK DecimalExponent)
869-
$(GLINK LeadingDecimal) $(GLINK DecimalExponent)
870+
$(GLINK DecimalDigitsNoStartingUS) $(B .)
871+
$(GLINK DecimalDigitsNoStartingUS) $(B .) $(GLINK DecimalDigitsNoStartingUS)
872+
$(GLINK DecimalDigitsNoStartingUS) $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
873+
$(B .) $(GLINK DecimalDigitsNoStartingUS)
874+
$(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
875+
$(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
870876

871877
$(GNAME DecimalExponent):
872878
$(GLINK DecimalExponentStart) $(GLINK DecimalDigitsNoSingleUS)
@@ -889,7 +895,7 @@ $(GNAME HexPrefix):
889895
$(B 0X)
890896

891897
$(GNAME HexExponent):
892-
$(GLINK HexExponentStart) $(GLINK DecimalDigitsNoSingleUS)
898+
$(GLINK HexExponentStart) $(GLINK HexDigitsNoSingleUS)
893899

894900
$(GNAME HexExponentStart):
895901
$(B p)
@@ -916,10 +922,6 @@ $(GNAME RealSuffix):
916922

917923
$(GNAME ImaginarySuffix):
918924
$(B i)
919-
920-
$(GNAME LeadingDecimal):
921-
$(GLINK DecimalInteger)
922-
$(B 0) $(GLINK DecimalDigitsNoSingleUS)
923925
)
924926

925927
$(P Floats can be in decimal or hexadecimal format.)

0 commit comments

Comments
 (0)