From 1798d51da67835618079f034d0b552be342af5d2 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 25 Nov 2018 11:35:38 -0500 Subject: [PATCH 1/6] Add grammar for {f32,f64}::from_str, mention known bug. - Original bug about documenting grammar - https://github.com/rust-lang/rust/issues/32243 - Known bug with parsing - https://github.com/rust-lang/rust/issues/31407 --- src/libcore/num/dec2flt/mod.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index f93564c2849f5..64ac69946d10d 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -122,11 +122,35 @@ macro_rules! from_str_float_impl { /// * '2.5E10', or equivalently, '2.5e10' /// * '2.5E-10' /// * '5.' - /// * '.5', or, equivalently, '0.5' + /// * '.5', or, equivalently, '0.5' /// * 'inf', '-inf', 'NaN' /// /// Leading and trailing whitespace represent an error. /// + /// # Grammar + /// + /// All strings that adhere to the following regular expression + /// will result in an [`Ok`] being returned: + /// + /// ```txt + /// (\+|-)? + /// (inf| + /// NaN| + /// ([0-9]+| + /// [0-9]+\.[0-9]*| + /// [0-9]*\.[0-9]+) + /// ((e|E) + /// (\+|-)? + /// [0-9]+)?) + /// ``` + /// + /// # Known bugs + /// + /// * [#31407]: Some strings that adhere to the regular expression + /// above will incorrectly return an [`Err`]. + /// + /// [#31407]: https://github.com/rust-lang/rust/issues/31407 + /// /// # Arguments /// /// * src - A string From 694b18d973e3c45d0dcc0221813fd0daefaf367f Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 3 Dec 2018 12:28:56 -0800 Subject: [PATCH 2/6] tweak 'known issues' wording --- src/libcore/num/dec2flt/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 64ac69946d10d..759c2e8c953e0 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -146,8 +146,8 @@ macro_rules! from_str_float_impl { /// /// # Known bugs /// - /// * [#31407]: Some strings that adhere to the regular expression - /// above will incorrectly return an [`Err`]. + /// In some situations, some strings that should create a valid float + /// instead return an error. See [issue #31407] for details. /// /// [#31407]: https://github.com/rust-lang/rust/issues/31407 /// From 15f79d890522028e88a60992b76c0fce26024a8f Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 3 Dec 2018 12:29:28 -0800 Subject: [PATCH 3/6] ...and fix a link --- src/libcore/num/dec2flt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 759c2e8c953e0..1926d84d0439f 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -149,7 +149,7 @@ macro_rules! from_str_float_impl { /// In some situations, some strings that should create a valid float /// instead return an error. See [issue #31407] for details. /// - /// [#31407]: https://github.com/rust-lang/rust/issues/31407 + /// [issue #31407]: https://github.com/rust-lang/rust/issues/31407 /// /// # Arguments /// From 1027dc16b941e04611213c7b7e2a6e9de523868a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 22 Dec 2018 09:34:22 -0500 Subject: [PATCH 4/6] Update regex to EBNF --- src/libcore/num/dec2flt/mod.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 1926d84d0439f..804e5f5e52158 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -129,19 +129,17 @@ macro_rules! from_str_float_impl { /// /// # Grammar /// - /// All strings that adhere to the following regular expression + /// All strings that adhere to the following EBNF grammar /// will result in an [`Ok`] being returned: /// /// ```txt - /// (\+|-)? - /// (inf| - /// NaN| - /// ([0-9]+| - /// [0-9]+\.[0-9]*| - /// [0-9]*\.[0-9]+) - /// ((e|E) - /// (\+|-)? - /// [0-9]+)?) + /// Float ::= Sign? ( 'inf' | 'NaN' | Number ) + /// Number ::= ( Digit+ | + /// Digit+ '.' Digit* | + /// Digit* '.' Digit+ ) Exp? + /// Exp ::= [eE] Sign? Digit+ + /// Sign ::= [+-] + /// Digit ::= [0-9] /// ``` /// /// # Known bugs From 55be692eb8c2facf78892cdafbb898c375be0b94 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 22 Dec 2018 09:43:47 -0500 Subject: [PATCH 5/6] Update src/libcore/num/dec2flt/mod.rs Co-Authored-By: frewsxcv --- src/libcore/num/dec2flt/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 804e5f5e52158..8bde41fefd5b1 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -129,7 +129,9 @@ macro_rules! from_str_float_impl { /// /// # Grammar /// - /// All strings that adhere to the following EBNF grammar + /// [EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation + /// + /// All strings that adhere to the following [EBNF] grammar /// will result in an [`Ok`] being returned: /// /// ```txt From 8af02faab8434d63b6eedb7b5e8f47d0ff0b5e6c Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 22 Jan 2019 22:51:33 -0500 Subject: [PATCH 6/6] reposition markdown hyperlink reference --- src/libcore/num/dec2flt/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 8bde41fefd5b1..c137986e684a5 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -129,8 +129,6 @@ macro_rules! from_str_float_impl { /// /// # Grammar /// - /// [EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation - /// /// All strings that adhere to the following [EBNF] grammar /// will result in an [`Ok`] being returned: /// @@ -144,6 +142,8 @@ macro_rules! from_str_float_impl { /// Digit ::= [0-9] /// ``` /// + /// [EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation + /// /// # Known bugs /// /// In some situations, some strings that should create a valid float