Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spec] Fix grammar for fractions #1178

Merged
merged 3 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions document/core/text/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ Floating-Point
.. math::
\begin{array}{llclll@{\qquad\qquad}l}
\production{decimal floating-point fraction} & \Tfrac &::=&
\epsilon &\Rightarrow& 0 \\ &&|&
d{:}\Tdigit~~q{:}\Tfrac &\Rightarrow& (d+q)/10 \\ &&|&
d{:}\Tdigit~~\text{\_}~~p{:}\Tdigit~~q{:}\Tfrac &\Rightarrow& (d+(p+q)/10)/10 \\
d{:}\Tdigit &\Rightarrow& d/10 \\ &&|&
d{:}\Tdigit~~\text{\_}^?~~p{:}\Tfrac &\Rightarrow& (d+p/10)/10 \\
\production{hexadecimal floating-point fraction} & \Thexfrac &::=&
\epsilon &\Rightarrow& 0 \\ &&|&
h{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+q)/16 \\ &&|&
h{:}\Thexdigit~~\text{\_}~~~~p{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+(p+q)/16)/16 \\
h{:}\Thexdigit &\Rightarrow& h/16 \\ &&|&
h{:}\Thexdigit~~\text{\_}^?~~p{:}\Thexfrac &\Rightarrow& (h+p/16)/16 \\
\production{decimal floating-point number} & \Tfloat &::=&
p{:}\Tnum
p{:}\Tnum~\text{.}^?
&\Rightarrow& p \\ &&|&
p{:}\Tnum~\text{.}~q{:}\Tfrac
&\Rightarrow& p+q \\ &&|&
Expand All @@ -105,11 +103,11 @@ Floating-Point
p{:}\Tnum~\text{.}~q{:}\Tfrac~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
&\Rightarrow& (p+q)\cdot 10^{\pm e} \\
\production{hexadecimal floating-point number} & \Thexfloat &::=&
\text{0x}~p{:}\Thexnum
\text{0x}~p{:}\Thexnum~\text{.}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot should be optional here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fixed.

&\Rightarrow& p \\ &&|&
\text{0x}~p{:}\Thexnum~\text{.}~q{:}\Thexfrac
&\Rightarrow& p+q \\ &&|&
\text{0x}~p{:}\Thexnum~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
\text{0x}~p{:}\Thexnum~\text{.}^?~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change for decimal floats above? (line 101)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

&\Rightarrow& p\cdot 2^{\pm e} \\ &&|&
\text{0x}~p{:}\Thexnum~\text{.}~q{:}\Thexfrac~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum
&\Rightarrow& (p+q)\cdot 2^{\pm e}
Expand Down
15 changes: 15 additions & 0 deletions test/core/const.wast
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@
(module (func (f64.const 0123456789.0123456789e019) drop))
(module (func (f64.const 0123456789.0123456789e+019) drop))
(module (func (f64.const 0123456789.0123456789e-019) drop))
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9) drop))
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.) drop))
(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))
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9e+0_1_9) drop))
(module (func (f64.const 0_1_2_3_4_5_6_7_8_9.e+0_1_9) drop))
(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))

(module (func (f64.const 0x0123456789ABCDEFabcdef) drop))
(module (func (f64.const 0x0123456789ABCDEFabcdefp019) drop))
(module (func (f64.const 0x0123456789ABCDEFabcdefp+019) drop))
Expand All @@ -166,6 +173,14 @@
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp019) drop))
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp+019) drop))
(module (func (f64.const 0x0123456789ABCDEFabcdef.0123456789ABCDEFabcdefp-019) drop))
(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))
(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))
(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))
(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))
(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))
(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))


(assert_malformed
(module quote "(func (f64.const) drop)")
"unexpected token"
Expand Down