Skip to content

Commit 802ce67

Browse files
committed
JP 04: [lex.icon] Consistently order descriptions of integer literals in
increasing radix order. Fixes #368.
1 parent f761e41 commit 802ce67

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

source/lex.tex

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -799,16 +799,17 @@
799799
\indextext{literal!integer}%
800800
\begin{bnf}
801801
\nontermdef{integer-literal}\br
802-
decimal-literal integer-suffix\opt\br
802+
binary-literal integer-suffix\opt\br
803803
octal-literal integer-suffix\opt\br
804-
hexadecimal-literal integer-suffix\opt\br
805-
binary-literal integer-suffix\opt
804+
decimal-literal integer-suffix\opt\br
805+
hexadecimal-literal integer-suffix\opt
806806
\end{bnf}
807807

808808
\begin{bnf}
809-
\nontermdef{decimal-literal}\br
810-
nonzero-digit\br
811-
decimal-literal \terminal{'}\opt digit
809+
\nontermdef{binary-literal}\br
810+
\terminal{0b} binary-digit\br
811+
\terminal{0B} binary-digit\br
812+
binary-literal \terminal{'}\opt binary-digit
812813
\end{bnf}
813814

814815
\begin{bnf}
@@ -817,6 +818,12 @@
817818
octal-literal \terminal{'}\opt octal-digit
818819
\end{bnf}
819820

821+
\begin{bnf}
822+
\nontermdef{decimal-literal}\br
823+
nonzero-digit\br
824+
decimal-literal \terminal{'}\opt digit
825+
\end{bnf}
826+
820827
\begin{bnf}
821828
\nontermdef{hexadecimal-literal}\br
822829
\terminal{0x} hexadecimal-digit\br
@@ -825,20 +832,19 @@
825832
\end{bnf}
826833

827834
\begin{bnf}
828-
\nontermdef{binary-literal}\br
829-
\terminal{0b} binary-digit\br
830-
\terminal{0B} binary-digit\br
831-
binary-literal \terminal{'}\opt binary-digit
835+
\nontermdef{binary-digit}\br
836+
\terminal{0}\br
837+
\terminal{1}
832838
\end{bnf}
833839

834840
\begin{bnf}
835-
\nontermdef{nonzero-digit} \textnormal{one of}\br
836-
\terminal{1 2 3 4 5 6 7 8 9}
841+
\nontermdef{octal-digit} \textnormal{one of}\br
842+
\terminal{0 1 2 3 4 5 6 7}
837843
\end{bnf}
838844

839845
\begin{bnf}
840-
\nontermdef{octal-digit} \textnormal{one of}\br
841-
\terminal{0 1 2 3 4 5 6 7}
846+
\nontermdef{nonzero-digit} \textnormal{one of}\br
847+
\terminal{1 2 3 4 5 6 7 8 9}
842848
\end{bnf}
843849

844850
\begin{bnf}
@@ -848,12 +854,6 @@
848854
\terminal{A B C D E F}
849855
\end{bnf}
850856

851-
\begin{bnf}
852-
\nontermdef{binary-digit}\br
853-
\terminal{0}\br
854-
\terminal{1}
855-
\end{bnf}
856-
857857
\begin{bnf}
858858
\nontermdef{integer-suffix}\br
859859
unsigned-suffix long-suffix\opt \br
@@ -881,26 +881,29 @@
881881
\indextext{literal!\idxcode{unsigned}}%
882882
\indextext{literal!\idxcode{long}}%
883883
\indextext{literal!integer}%
884-
\indextext{literal!hexadecimal}%
884+
\indextext{literal!binary}%
885885
\indextext{literal!octal}%
886886
\indextext{literal!decimal}%
887-
\indextext{literal!binary}%
887+
\indextext{literal!hexadecimal}%
888888
\indextext{literal!base~of integer}%
889889
An \term{integer literal} is a sequence of digits that has no period
890890
or exponent part, with optional separating single quotes that are ignored
891891
when determining its value. An integer literal may have a prefix that specifies
892892
its base and a suffix that specifies its type. The lexically first digit
893-
of the sequence of digits is the most significant. A \term{decimal}
894-
integer literal (base ten) begins with a digit other than \tcode{0} and
895-
consists of a sequence of decimal digits. An \term{octal} integer
893+
of the sequence of digits is the most significant.
894+
A \term{binary} integer literal (base two) begins with
895+
\tcode{0b} or \tcode{0B} and consists of a sequence of binary digits.
896+
An \term{octal} integer
896897
literal (base eight) begins with the digit \tcode{0} and consists of a
897898
sequence of octal digits.\footnote{The digits \tcode{8} and \tcode{9} are not octal digits. }
899+
A \term{decimal}
900+
integer literal (base ten) begins with a digit other than \tcode{0} and
901+
consists of a sequence of decimal digits.
898902
A \term{hexadecimal} integer literal (base sixteen) begins with
899903
\tcode{0x} or \tcode{0X} and consists of a sequence of hexadecimal
900904
digits, which include the decimal digits and the letters \tcode{a}
901905
through \tcode{f} and \tcode{A} through \tcode{F} with decimal values
902-
ten through fifteen. A \term{binary} integer literal (base two) begins with
903-
\tcode{0b} or \tcode{0B} and consists of a sequence of binary digits.
906+
ten through fifteen.
904907
\enterexample The number twelve can be written \tcode{12}, \tcode{014},
905908
\tcode{0XC}, or \tcode{0b1100}. The literals \tcode{1048576},
906909
\tcode{1'048'576}, \tcode{0X100000}, \tcode{0x10'0000}, and

0 commit comments

Comments
 (0)