Skip to content

Commit 90f8fdd

Browse files
rossberggumb0
authored andcommitted
[spec] Fix grammar for fractions (WebAssembly#1178)
1 parent 70fafef commit 90f8fdd

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

document/core/text/values.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,26 @@ Floating-Point
8888
.. math::
8989
\begin{array}{llclll@{\qquad\qquad}l}
9090
\production{decimal floating-point fraction} & \Tfrac &::=&
91-
\epsilon &\Rightarrow& 0 \\ &&|&
92-
d{:}\Tdigit~~q{:}\Tfrac &\Rightarrow& (d+q)/10 \\ &&|&
93-
d{:}\Tdigit~~\text{\_}~~p{:}\Tdigit~~q{:}\Tfrac &\Rightarrow& (d+(p+q)/10)/10 \\
91+
d{:}\Tdigit &\Rightarrow& d/10 \\ &&|&
92+
d{:}\Tdigit~~\text{\_}^?~~p{:}\Tfrac &\Rightarrow& (d+p/10)/10 \\
9493
\production{hexadecimal floating-point fraction} & \Thexfrac &::=&
95-
\epsilon &\Rightarrow& 0 \\ &&|&
96-
h{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+q)/16 \\ &&|&
97-
h{:}\Thexdigit~~\text{\_}~~~~p{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+(p+q)/16)/16 \\
94+
h{:}\Thexdigit &\Rightarrow& h/16 \\ &&|&
95+
h{:}\Thexdigit~~\text{\_}^?~~p{:}\Thexfrac &\Rightarrow& (h+p/16)/16 \\
9896
\production{decimal floating-point number} & \Tfloat &::=&
99-
p{:}\Tnum
97+
p{:}\Tnum~\text{.}^?
10098
&\Rightarrow& p \\ &&|&
10199
p{:}\Tnum~\text{.}~q{:}\Tfrac
102100
&\Rightarrow& p+q \\ &&|&
103-
p{:}\Tnum~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
101+
p{:}\Tnum~\text{.}^?~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
104102
&\Rightarrow& p\cdot 10^{\pm e} \\ &&|&
105103
p{:}\Tnum~\text{.}~q{:}\Tfrac~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
106104
&\Rightarrow& (p+q)\cdot 10^{\pm e} \\
107105
\production{hexadecimal floating-point number} & \Thexfloat &::=&
108-
\text{0x}~p{:}\Thexnum
106+
\text{0x}~p{:}\Thexnum~\text{.}^?
109107
&\Rightarrow& p \\ &&|&
110108
\text{0x}~p{:}\Thexnum~\text{.}~q{:}\Thexfrac
111109
&\Rightarrow& p+q \\ &&|&
112-
\text{0x}~p{:}\Thexnum~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
110+
\text{0x}~p{:}\Thexnum~\text{.}^?~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
113111
&\Rightarrow& p\cdot 2^{\pm e} \\ &&|&
114112
\text{0x}~p{:}\Thexnum~\text{.}~q{:}\Thexfrac~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
115113
&\Rightarrow& (p+q)\cdot 2^{\pm e}

test/core/const.wast

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@
154154
(module (func (f64.const 0123456789.0123456789e019) drop))
155155
(module (func (f64.const 0123456789.0123456789e+019) drop))
156156
(module (func (f64.const 0123456789.0123456789e-019) drop))
157+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9) drop))
158+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.) drop))
159+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.0_1_2_3_4_5_6_7_8_9) drop))
160+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9e+0_1_9) drop))
161+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.e+0_1_9) drop))
162+
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.0_1_2_3_4_5_6_7_8_9e0_1_9) drop))
163+
157164
(module (func (f64.const 0x0123456789ABCDEFabcdef) drop))
158165
(module (func (f64.const 0x0123456789ABCDEFabcdefp019) drop))
159166
(module (func (f64.const 0x0123456789ABCDEFabcdefp+019) drop))
@@ -166,6 +173,14 @@
166173
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp019) drop))
167174
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp+019) drop))
168175
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp-019) drop))
176+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f) drop))
177+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f.) drop))
178+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f.0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f) drop))
179+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_fp0_1_9) drop))
180+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f.p0_1_9) drop))
181+
(module (func (f64.const 0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_f.0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F_a_b_c_d_e_fp0_1_9) drop))
182+
183+
169184
(assert_malformed
170185
(module quote "(func (f64.const) drop)")
171186
"unexpected token"

0 commit comments

Comments
 (0)