lexical_util/
feature_format.rs

1//! Configuration options for parsing and formatting numbers.
2//!
3//! This comprises 2 parts: a low-level API for generating packed structs
4//! containing enumerating for number formats (both syntax and lexer).
5//!
6//! # Syntax Format
7//!
8//! The syntax format defines **which** numeric string are valid.
9//! For example, if exponent notation is required or not
10//! allowed.
11//!
12//! # Control Format
13//!
14//! The control format defines what characters are valid, that is, which
15//! characters should be consider valid to continue tokenization.
16
17#![cfg(feature = "format")]
18
19// Sample test code for each language used:
20//
21//  Rust
22//  ----
23//
24//  Setup:
25//      Save to `main.rs` and run `rustc main.rs -o main`.
26//
27//  Code:
28//      ```text
29//      pub fn main() {
30//          println!("{:?}", 3_.0f32);
31//          println!("{:?}", "3_.0".parse::<f32>());
32//      }
33//      ```
34//
35// Python
36// ------
37//
38//  Setup:
39//      Run `python` to enter the interpreter.
40//
41//  Code:
42//      ```text
43//      print(3_.0)
44//      print(float("3_.0"))
45//      ```
46//
47//  C++
48//  ---
49//
50//  Setup:
51//      Save to `main.cc` and run `g++ main.cc -o main -std=c++XX`,
52//      where XX is one of the following values:
53//          - 98
54//          - 03
55//          - 11
56//          - 14
57//          - 17
58//
59//  Code:
60//      ```text
61//      #include <cstdlib>
62//      #include <cstring>
63//      #include <iostream>
64//      #include <iterator>
65//      #include <stdexcept>
66//
67//      double parse(const char* string) {
68//          char* end;
69//          double result = strtod(string, &end);
70//          auto endp = reinterpret_cast<const char*>(end);
71//          if (std::distance(string, endp) != strlen(string)) {
72//              throw std::invalid_argument("did not consume entire string.");
73//          }
74//          return result;
75//      }
76//
77//      int main() {
78//          std::cout << 3'.0 << std::endl;
79//          std::cout << parse("3'.0") << std::endl;
80//      }
81//      ```
82//
83//  C
84//  -
85//
86//  Setup:
87//      Save to `main.c` and run `gcc main.c -o main -std=cXX`,
88//      where XX is one of the following values:
89//          - 89
90//          - 90
91//          - 99
92//          - 11
93//          - 18
94//
95//  Code:
96//      ```text
97//      #include <stdint.h>
98//      #include <stdlib.h>
99//      #include <string.h>
100//      #include <stdio.h>
101//
102//      size_t distance(const char* first, const char* last) {
103//          uintptr_t x = (uintptr_t) first;
104//          uintptr_t y = (uintptr_t) last;
105//          return (size_t) (y - x);
106//      }
107//
108//      double parse(const char* string) {
109//          char* end;
110//          double result = strtod(string, &end);
111//          if (distance(string, (const char*) end) != strlen(string)) {
112//              abort();
113//          }
114//          return result;
115//      }
116//
117//      int main() {
118//          printf("%f\n", 3'.);
119//          printf("%f\n", parse("3'."));
120//      }
121//      ```
122//
123// Ruby
124// ----
125//
126//  Setup:
127//      Run `irb` to enter the interpreter.
128//
129//  Code:
130//      ```text
131//      puts 3.0_1;
132//      puts "3.0_1".to_f;
133//      ```
134// Swift
135// -----
136//
137//  Setup:
138//      Run `swift` to enter the interpreter.
139//
140//  Code:
141//      ```text
142//      print(3.0);
143//      print(Float("3.0"));
144//      ```
145// Golang
146// ------
147//
148// Setup:
149//      Save to `main.go` and run `go run main.go`
150//
151// Code:
152//      ```text
153//      package main
154//
155//      import (
156//          "fmt"
157//          "strconv"
158//      )
159//
160//      func main() {
161//          fmt.Println(3.0)
162//          fmt.Println(strconv.ParseFloat("3.0", 64))
163//      }
164//      ```
165//
166// Haskell
167// -------
168//
169// Setup:
170//      Run `ghci` to enter the interpreter.
171//
172// Code:
173//      ```text
174//      :m Numeric
175//      showFloat 3.0 ""
176//      let x = "3.0"
177//      read x :: Float
178//      ```
179//
180// Javascript
181// ----------
182//
183// Setup:
184//      Run `nodejs` (or `node`) to enter the interpreter.
185//
186// Code:
187//      ```text
188//          console.log(3.0)
189//          console.log(parseFloat("3.0"))
190//      ```
191//
192// Perl
193// ----
194//
195// Setup:
196//      Run `perl -de1` to enter the interpret.
197//
198// Code:
199//      ```text
200//      print 3.01;
201//      print '3.01' * 1;
202//      ```
203//
204// PHP
205// ---
206//
207// Setup:
208//      Run `php -a` to enter the interpret.
209//
210// Code:
211//      ```text
212//      printf("%f\n", 3.0);
213//      printf("%f\n", floatval("3.0"));
214//      ```
215//
216// Java
217// ----
218//
219// Setup:
220//      Save to `main.java` and run `javac main.java`, then run `java Main`.
221//
222// Code:
223//      ```text
224//      class Main {
225//          public static void main(String args[]) {
226//              System.out.println(3.0);
227//              System.out.println(Float.parseFloat("3.0"));
228//          }
229//      }
230//      ```
231//
232// R
233// -
234//
235// Setup:
236//      Run `R` to enter the interpret.
237//
238// Code:
239//      ```text
240//      print(3.0);
241//      print(as.numeric("3.0"));
242//      ```
243//
244// Kotlin
245// ------
246//
247// Setup:
248//      Save file to `main.kt` and run `kotlinc main.kt -d main.jar`,
249//      then run `java -jar main.jar`.
250//
251// Code:
252//      ```text
253//      fun main() {
254//          println(3.0)
255//          println("3.0".toDouble())
256//      }
257//      ```
258//
259// Julia
260// -----
261//
262// Setup:
263//      Run `julia` to enter the interpret.
264//
265// Code:
266//      ```text
267//      print(3.0);
268//      print(parse(Float64, "3.0"));
269//      ```
270//
271// C#
272// --
273//
274// Note:
275//      Mono accepts both integer and fraction decimal separators, Mono is
276//      just buggy, see https://github.com/dotnet/csharplang/issues/55#issuecomment-574902516.
277//
278// Setup:
279//      Run `csharp -langversion:X` to enter the interpret,
280//      where XX is one of the following values:
281//          - ISO-1
282//          - ISO-2
283//          - 3
284//          - 4
285//          - 5
286//          - 6
287//          - 7
288//
289// Code:
290//      ```text
291//      Console.WriteLine("{0}", 3.0);
292//      Console.WriteLine("{0}", float.Parse("3.0"));
293//      ```
294//
295// Kawa
296// ----
297//
298// Setup:
299//      Run `kawa` to enter the interpreter.
300//
301// Code:
302//      ```text
303//      3.0
304//      (string->number "3.0")
305//      ```
306//
307// Gambit-C
308// --------
309//
310// Setup:
311//      Run `gsc` to enter the interpreter.
312//
313// Code:
314//      ```text
315//      3.0
316//      (string->number "3.0")
317//      ```
318//
319// Guile
320// -----
321//
322// Setup:
323//      Run `guile` to enter the interpreter.
324//
325// Code:
326//      ```text
327//      3.0
328//      (string->number "3.0")
329//      ```
330//
331// Clojure
332// -------
333//
334// Setup:
335//      Run `clojure` to enter the interpreter.
336//
337// Code:
338//      ```text
339//      3.0
340//      (Float/parseFloat "3.0")
341//      ```
342//
343// Erlang
344// ------
345//
346// Setup:
347//      Run `erl` to enter the interpreter.
348//
349// Code:
350//      ```text
351//      io:format("~p~n", [3.0]).
352//      string:to_float("3.0").
353//      ```
354//
355// Elm
356// ---
357//
358// Setup:
359//      Run `elm repl` to enter the interpreter.
360//
361// Code:
362//      ```text
363//      3.0
364//      String.toFloat "3.0"
365//      ```
366//
367// Scala
368// -----
369//
370// Setup:
371//      Run `scala` to enter the interpreter.
372//
373// Code:
374//      ```text
375//      3.0
376//      "3.0".toFloat
377//      ```
378//
379// Elixir
380// ------
381//
382// Setup:
383//      Run `iex` to enter the interpreter.
384//
385// Code:
386//      ```text
387//      3.0;
388//      String.to_float("3.0");
389//      ```
390//
391// FORTRAN
392// -------
393//
394// Setup:
395//      Save to `main.f90` and run `gfortran -o main main.f90`
396//
397// Code:
398//      ```text
399//      program main
400//        real :: x
401//        character (len=30) :: word
402//        word = "3."
403//        read(word, *) x
404//        print *, 3.
405//        print *, x
406//      end program main
407//      ```
408//
409// D
410// -
411//
412// Setup:
413//      Save to `main.d` and run `dmd -run main.d`
414//
415// Code:
416//      ```text
417//      import std.conv;
418//      import std.stdio;
419//
420//      void main()
421//      {
422//          writeln(3.0);
423//          writeln(to!double("3.0"));
424//      }
425//      ```
426//
427// Coffeescript
428// ------------
429//
430// Setup:
431//      Run `coffee` to enter the interpreter.
432//
433// Code:
434//      ```text
435//      3.0;
436//      parseFloat("3.0");
437//      ```
438//
439// Cobol
440// -----
441//
442// Setup:
443//      Save to `main.cbl` and run `cobc main.cbl` then `cobcrun main`.
444//
445// Code:
446//      ```text
447//                IDENTIFICATION DIVISION.
448//                PROGRAM-ID. main.
449//
450//                DATA DIVISION.
451//                   WORKING-STORAGE SECTION.
452//                   01 R PIC X(20)   VALUE "3.0".
453//                   01 TOTAL        USAGE IS COMP-2.
454//
455//                PROCEDURE DIVISION.
456//                   COMPUTE TOTAL = FUNCTION NUMVAL(R).
457//                   Display 3.0.
458//                   Display TOTAL.
459//                   STOP RUN.
460//      ```
461//
462// F#
463// --
464//
465// Setup:
466//      Run `dotnet fsi` to enter the interpreter.
467//
468// Code:
469//      ```text
470//      printfn "%f" 3.0;;
471//      let f = float "3.0";;
472//      printfn "%f" f;;
473//      ```
474//
475// Visual Basic
476// ------------
477//
478// Setup:
479//      Save to `main.vb` and run `vbnc main.vb`.
480//
481// Code:
482//      ```text
483//      Imports System
484//
485//      Module Module1
486//          Sub Main()
487//              Console.WriteLine(Format$(3.0, "0.0000000000000"))
488//              Console.WriteLine(Format$(CDbl("3.0"), "0.0000000000000"))
489//          End Sub
490//      End Module
491//      ```
492//
493// OCaml
494// -----
495//
496// Setup:
497//      Save to `main.ml` and run `ocamlc -o main main.ml`.
498//
499// Code:
500//      ```text
501//      Printf.printf "%f\n" 3.0
502//      let () =
503//          let f = float_of_string "3.0" in
504//          Printf.printf "%f\n" f
505//      ```
506//
507// Objective-C
508// -----------
509//
510// Setup:
511//      Save to `main.m` and run `gcc -o main -lobjc -lgnustep-base main.m
512// -fconstant-string-class=NSConstantString`.
513//
514// Code:
515//      ```text
516//      #import <Foundation/Foundation.h>
517//      #import <stdio.h>
518//
519//      int main(int argv, char* argc[])
520//      {
521//          printf("%f\n", 3.0);
522//          NSString *s = @"3.0";
523//          double f = [s doubleValue];
524//          printf("%f\n", f);
525//      }
526//      ```
527//
528// ReasonML
529// --------
530//
531// Setup:
532//      Run `rtop` to enter the interpreter.
533//
534// Code:
535//      ```text
536//      Printf.printf("%f\n", 3.0);
537//      Printf.printf("%f\n", float_of_string("3.0"));
538//      ```
539//
540// Zig
541// ---
542//
543// Setup:
544//      Save to `main.zig` and run `zig build-exe main.zig`
545//
546// Code:
547//      ```text
548//      const std = @import("std");
549//
550//      pub fn main() void {
551//          const f: f64 = 3.0;
552//          std.debug.warn("{}\n", f);
553//          const x: f64 = std.fmt.parseFloat(f64, "3.0") catch unreachable;
554//          std.debug.warn("{}\n", x);
555//      }
556//      ```
557//
558//
559// Octave (and Matlab)
560// -------------------
561//
562// Setup:
563//      Run `octave` to enter the interpreter, or
564//      run `octave --traditional` to enter the Matlab interpret.
565//
566// Code:
567//      ```text
568//      3.0
569//      str2double("3.0")
570//      ```
571//
572// Sage
573// ----
574//
575// Setup:
576//      Run `sage` to enter the interpreter.
577//
578// Code:
579//      ```text
580//      3.0
581//      float("3.0")
582//      ```
583//
584// JSON
585// ----
586//
587// Setup:
588//      Run `node` (or `nodejs`) to enter the JS interpreter.
589//
590// Code:
591//      ```text
592//      JSON.parse("3.0")
593//      ```
594//
595// TOML
596// ----
597//
598// Setup:
599//      Run `python` to enter the Python interpreter.
600//
601// Code:
602//      ```text
603//      import tomlkit
604//      tomlkit.parse("a = 3.0")
605//      ```
606//
607// XML
608// ---
609//
610// Setup:
611//      Run `python` to enter the Python interpreter.
612//
613// Code:
614//      ```text
615//      from lxml import etree
616//
617//      def validate_xml(xsd, xml):
618//          '''Validate XML file against schema'''
619//
620//          schema = etree.fromstring(xsd)
621//          doc = etree.fromstring(xml)
622//          xmlschema = etree.XMLSchema(schema)
623//
624//          return xmlschema.validate(doc)
625//
626//
627//      xsd = b'''<?xml version="1.0" encoding="UTF-8"?>
628//      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
629//          <xs:element name="prize" type="xs:float"/>
630//      </xs:schema>'''
631//
632//      xml = b'''<?xml version="1.0" encoding="UTF-8"?>
633//      <prize>3.0</prize>
634//      '''
635//
636//      validate_xml(xsd, xml)
637//      ```
638//
639// SQLite
640// ------
641//
642// Setup:
643//      Run `sqlite3 :memory:` to enter the sqlite3 interpreter
644//      with an in-memory database.
645//
646// Code:
647//      ```text
648//      CREATE TABLE stocks (price real);
649//      INSERT INTO stocks VALUES (3.0);
650//      SELECT * FROM stocks;
651//      ```
652//
653// PostgreSQL
654// ----------
655//
656// Setup:
657//      Run `initdb -D db` to create a database data direction,
658//      then run `pg_ctl -D db start` to start the server, then run
659//      `createdb` to create a user database and `psql` to start the
660//      interpreter.
661//
662// Code:
663//      ```text
664//      CREATE TABLE stocks (price real);
665//      INSERT INTO stocks VALUES (3.0);
666//      SELECT * FROM stocks;
667//      ```
668//
669// MySQL
670// -----
671//
672// Setup:
673//      Run `mysqld` to start the server, then run `mysql` to start the
674//      interpreter.
675//
676// Code:
677//      ```text
678//      USE mysql;
679//      CREATE TABLE stocks (price real);
680//      INSERT INTO stocks VALUES (3.0);
681//      SELECT * FROM stocks;
682//      ```
683//
684// MongoDB
685// -------
686//
687// Setup:
688//      Run `mongod --dbpath data/db` to start the server, then run
689//      `mongo` to start the interpreter.
690//
691// Code:
692//      ```text
693//      use mydb
694//      db.movie.insert({"name": 3.0})
695//      db.movie.find()
696//      ```
697
698use core::num;
699
700use static_assertions::const_assert;
701
702use crate::error::Error;
703use crate::format_builder::NumberFormatBuilder;
704use crate::format_flags as flags;
705
706/// Add multiple flags to `SyntaxFormat`.
707macro_rules! from_flag {
708    ($format:ident, $flag:ident) => {{
709        $format & flags::$flag != 0
710    }};
711}
712
713/// Wrapper for the 128-bit packed struct.
714///
715/// See `NumberFormatBuilder` for the `FORMAT` fields
716/// for the packed struct.
717#[doc(hidden)]
718pub struct NumberFormat<const FORMAT: u128>;
719
720#[rustfmt::skip]
721impl<const FORMAT: u128> NumberFormat<FORMAT> {
722    // CONSTRUCTORS
723
724    /// Create new instance (for methods and validation).
725    pub const fn new() -> Self {
726        Self {}
727    }
728
729    // VALIDATION
730
731    /// Determine if the number format is valid.
732    pub const fn is_valid(&self) -> bool {
733        self.error().is_success()
734    }
735
736    /// Get the error type from the format.
737    #[allow(clippy::if_same_then_else)] // reason="all are different logic conditions"
738    pub const fn error(&self) -> Error {
739        if !flags::is_valid_radix(self.mantissa_radix()) {
740            Error::InvalidMantissaRadix
741        } else if !flags::is_valid_radix(self.exponent_base()) {
742            Error::InvalidExponentBase
743        } else if !flags::is_valid_radix(self.exponent_radix()) {
744            Error::InvalidExponentRadix
745        } else if !flags::is_valid_digit_separator(FORMAT) {
746            Error::InvalidDigitSeparator
747        } else if !flags::is_valid_base_prefix(FORMAT) {
748            Error::InvalidBasePrefix
749        } else if !flags::is_valid_base_suffix(FORMAT) {
750            Error::InvalidBaseSuffix
751        } else if !flags::is_valid_punctuation(FORMAT) {
752            Error::InvalidPunctuation
753        } else if !flags::is_valid_exponent_flags(FORMAT) {
754            Error::InvalidExponentFlags
755        } else if self.no_positive_mantissa_sign() && self.required_mantissa_sign() {
756            Error::InvalidMantissaSign
757        } else if self.no_positive_exponent_sign() && self.required_exponent_sign() {
758            Error::InvalidExponentSign
759        } else if self.no_special() && self.case_sensitive_special() {
760            Error::InvalidSpecial
761        } else if self.no_special() && self.special_digit_separator() {
762            Error::InvalidSpecial
763        } else if self.integer_digit_separator_flags() == flags::INTEGER_CONSECUTIVE_DIGIT_SEPARATOR {
764            Error::InvalidConsecutiveIntegerDigitSeparator
765        } else if self.fraction_digit_separator_flags() == flags::FRACTION_CONSECUTIVE_DIGIT_SEPARATOR {
766            Error::InvalidConsecutiveFractionDigitSeparator
767        } else if self.exponent_digit_separator_flags() == flags::EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR {
768            Error::InvalidConsecutiveExponentDigitSeparator
769        } else {
770            Error::Success
771        }
772    }
773
774    // NON-DIGIT SEPARATOR FLAGS & MASKS
775
776    /// If digits are required before the decimal point.
777    pub const REQUIRED_INTEGER_DIGITS: bool = from_flag!(FORMAT, REQUIRED_INTEGER_DIGITS);
778
779    /// Get if digits are required before the decimal point.
780    #[inline(always)]
781    pub const fn required_integer_digits(&self) -> bool {
782        Self::REQUIRED_INTEGER_DIGITS
783    }
784
785    /// If digits are required after the decimal point.
786    pub const REQUIRED_FRACTION_DIGITS: bool = from_flag!(FORMAT, REQUIRED_FRACTION_DIGITS);
787
788    /// Get if digits are required after the decimal point.
789    #[inline(always)]
790    pub const fn required_fraction_digits(&self) -> bool {
791        Self::REQUIRED_FRACTION_DIGITS
792    }
793
794    /// If digits are required after the exponent character.
795    pub const REQUIRED_EXPONENT_DIGITS: bool = from_flag!(FORMAT, REQUIRED_EXPONENT_DIGITS);
796
797    /// Get if digits are required after the exponent character.
798    #[inline(always)]
799    pub const fn required_exponent_digits(&self) -> bool {
800        Self::REQUIRED_EXPONENT_DIGITS
801    }
802
803    /// If significant digits are required.
804    pub const REQUIRED_MANTISSA_DIGITS: bool = from_flag!(FORMAT, REQUIRED_MANTISSA_DIGITS);
805
806    /// Get if significant digits are required.
807    #[inline(always)]
808    pub const fn required_mantissa_digits(&self) -> bool {
809        Self::REQUIRED_MANTISSA_DIGITS
810    }
811
812    /// If at least 1 digit in the number is required.
813    pub const REQUIRED_DIGITS: bool = from_flag!(FORMAT, REQUIRED_DIGITS);
814
815    /// Get if at least 1 digit in the number is required.
816    #[inline(always)]
817    pub const fn required_digits(&self) -> bool {
818        Self::REQUIRED_DIGITS
819    }
820
821    /// If a positive sign before the mantissa is not allowed.
822    pub const NO_POSITIVE_MANTISSA_SIGN: bool = from_flag!(FORMAT, NO_POSITIVE_MANTISSA_SIGN);
823
824    /// Get if a positive sign before the mantissa is not allowed.
825    #[inline(always)]
826    pub const fn no_positive_mantissa_sign(&self) -> bool {
827        Self::NO_POSITIVE_MANTISSA_SIGN
828    }
829
830    /// If a sign symbol before the mantissa is required.
831    pub const REQUIRED_MANTISSA_SIGN: bool = from_flag!(FORMAT, REQUIRED_MANTISSA_SIGN);
832
833    /// Get if a sign symbol before the mantissa is required.
834    #[inline(always)]
835    pub const fn required_mantissa_sign(&self) -> bool {
836        Self::REQUIRED_MANTISSA_SIGN
837    }
838
839    /// If exponent notation is not allowed.
840    pub const NO_EXPONENT_NOTATION: bool = from_flag!(FORMAT, NO_EXPONENT_NOTATION);
841
842    /// Get if exponent notation is not allowed.
843    #[inline(always)]
844    pub const fn no_exponent_notation(&self) -> bool {
845        Self::NO_EXPONENT_NOTATION
846    }
847
848    /// If a positive sign before the exponent is not allowed.
849    pub const NO_POSITIVE_EXPONENT_SIGN: bool = from_flag!(FORMAT, NO_POSITIVE_EXPONENT_SIGN);
850
851    /// Get if a positive sign before the exponent is not allowed.
852    #[inline(always)]
853    pub const fn no_positive_exponent_sign(&self) -> bool {
854        Self::NO_POSITIVE_EXPONENT_SIGN
855    }
856
857    /// If a sign symbol before the exponent is required.
858    pub const REQUIRED_EXPONENT_SIGN: bool = from_flag!(FORMAT, REQUIRED_EXPONENT_SIGN);
859
860    /// Get if a sign symbol before the exponent is required.
861    #[inline(always)]
862    pub const fn required_exponent_sign(&self) -> bool {
863        Self::REQUIRED_EXPONENT_SIGN
864    }
865
866    /// If an exponent without fraction is not allowed.
867    pub const NO_EXPONENT_WITHOUT_FRACTION: bool = from_flag!(FORMAT, NO_EXPONENT_WITHOUT_FRACTION);
868
869    /// Get if an exponent without fraction is not allowed.
870    #[inline(always)]
871    pub const fn no_exponent_without_fraction(&self) -> bool {
872        Self::NO_EXPONENT_WITHOUT_FRACTION
873    }
874
875    /// If special (non-finite) values are not allowed.
876    pub const NO_SPECIAL: bool = from_flag!(FORMAT, NO_SPECIAL);
877
878    /// Get if special (non-finite) values are not allowed.
879    #[inline(always)]
880    pub const fn no_special(&self) -> bool {
881        Self::NO_SPECIAL
882    }
883
884    /// If special (non-finite) values are case-sensitive.
885    pub const CASE_SENSITIVE_SPECIAL: bool = from_flag!(FORMAT, CASE_SENSITIVE_SPECIAL);
886
887    /// Get if special (non-finite) values are case-sensitive.
888    #[inline(always)]
889    pub const fn case_sensitive_special(&self) -> bool {
890        Self::CASE_SENSITIVE_SPECIAL
891    }
892
893    /// If leading zeros before an integer are not allowed.
894    pub const NO_INTEGER_LEADING_ZEROS: bool = from_flag!(FORMAT, NO_INTEGER_LEADING_ZEROS);
895
896    /// Get if leading zeros before an integer are not allowed.
897    #[inline(always)]
898    pub const fn no_integer_leading_zeros(&self) -> bool {
899        Self::NO_INTEGER_LEADING_ZEROS
900    }
901
902    /// If leading zeros before a float are not allowed.
903    pub const NO_FLOAT_LEADING_ZEROS: bool = from_flag!(FORMAT, NO_FLOAT_LEADING_ZEROS);
904
905    /// Get if leading zeros before a float are not allowed.
906    #[inline(always)]
907    pub const fn no_float_leading_zeros(&self) -> bool {
908        Self::NO_FLOAT_LEADING_ZEROS
909    }
910
911    /// If exponent notation is required.
912    pub const REQUIRED_EXPONENT_NOTATION: bool = from_flag!(FORMAT, REQUIRED_EXPONENT_NOTATION);
913
914    /// Get if exponent notation is required.
915    #[inline(always)]
916    pub const fn required_exponent_notation(&self) -> bool {
917        Self::REQUIRED_EXPONENT_NOTATION
918    }
919
920    /// If exponent characters are case-sensitive.
921    pub const CASE_SENSITIVE_EXPONENT: bool = from_flag!(FORMAT, CASE_SENSITIVE_EXPONENT);
922
923    /// Get if exponent characters are case-sensitive.
924    #[inline(always)]
925    pub const fn case_sensitive_exponent(&self) -> bool {
926        Self::CASE_SENSITIVE_EXPONENT
927    }
928
929    /// If base prefixes are case-sensitive.
930    pub const CASE_SENSITIVE_BASE_PREFIX: bool = from_flag!(FORMAT, CASE_SENSITIVE_BASE_PREFIX);
931
932    /// Get if base prefixes are case-sensitive.
933    #[inline(always)]
934    pub const fn case_sensitive_base_prefix(&self) -> bool {
935        Self::CASE_SENSITIVE_BASE_PREFIX
936    }
937
938    /// If base suffixes are case-sensitive.
939    pub const CASE_SENSITIVE_BASE_SUFFIX: bool = from_flag!(FORMAT, CASE_SENSITIVE_BASE_SUFFIX);
940
941    /// Get if base suffixes are case-sensitive.
942    #[inline(always)]
943    pub const fn case_sensitive_base_suffix(&self) -> bool {
944        Self::CASE_SENSITIVE_BASE_SUFFIX
945    }
946
947    // DIGIT SEPARATOR FLAGS & MASKS
948
949    // If digit separators are allowed between integer digits.
950    ///
951    /// This will not consider an input of only the digit separator
952    /// to be a valid separator: the digit separator must be surrounded by
953    /// digits.
954    pub const INTEGER_INTERNAL_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, INTEGER_INTERNAL_DIGIT_SEPARATOR);
955
956    /// Get if digit separators are allowed between integer digits.
957    ///
958    /// This will not consider an input of only the digit separator
959    /// to be a valid separator: the digit separator must be surrounded by
960    /// digits.
961    #[inline(always)]
962    pub const fn integer_internal_digit_separator(&self) -> bool {
963        Self::INTEGER_INTERNAL_DIGIT_SEPARATOR
964    }
965
966    /// If digit separators are allowed between fraction digits.
967    ///
968    /// This will not consider an input of only the digit separator
969    /// to be a valid separator: the digit separator must be surrounded by
970    /// digits.
971    pub const FRACTION_INTERNAL_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, FRACTION_INTERNAL_DIGIT_SEPARATOR);
972
973    /// Get if digit separators are allowed between fraction digits.
974    ///
975    /// This will not consider an input of only the digit separator
976    /// to be a valid separator: the digit separator must be surrounded by
977    /// digits.
978    #[inline(always)]
979    pub const fn fraction_internal_digit_separator(&self) -> bool {
980        Self::FRACTION_INTERNAL_DIGIT_SEPARATOR
981    }
982
983    /// If digit separators are allowed between exponent digits.
984    ///
985    /// This will not consider an input of only the digit separator
986    /// to be a valid separator: the digit separator must be surrounded by
987    /// digits.
988    pub const EXPONENT_INTERNAL_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, EXPONENT_INTERNAL_DIGIT_SEPARATOR);
989
990    /// Get if digit separators are allowed between exponent digits.
991    ///
992    /// This will not consider an input of only the digit separator
993    /// to be a valid separator: the digit separator must be surrounded by
994    /// digits.
995    #[inline(always)]
996    pub const fn exponent_internal_digit_separator(&self) -> bool {
997        Self::EXPONENT_INTERNAL_DIGIT_SEPARATOR
998    }
999
1000    /// If digit separators are allowed between digits.
1001    ///
1002    /// This will not consider an input of only the digit separator
1003    /// to be a valid separator: the digit separator must be surrounded by
1004    /// digits.
1005    pub const INTERNAL_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, INTERNAL_DIGIT_SEPARATOR);
1006
1007    /// Get if digit separators are allowed between digits.
1008    ///
1009    /// This will not consider an input of only the digit separator
1010    /// to be a valid separator: the digit separator must be surrounded by
1011    /// digits.
1012    #[inline(always)]
1013    pub const fn internal_digit_separator(&self) -> bool {
1014        Self::INTERNAL_DIGIT_SEPARATOR
1015    }
1016
1017    /// If a digit separator is allowed before any integer digits.
1018    ///
1019    /// This will consider an input of only the digit separator
1020    /// to be a identical to empty input.
1021    pub const INTEGER_LEADING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, INTEGER_LEADING_DIGIT_SEPARATOR);
1022
1023    /// Get if a digit separator is allowed before any integer digits.
1024    ///
1025    /// This will consider an input of only the digit separator
1026    /// to be a identical to empty input.
1027    #[inline(always)]
1028    pub const fn integer_leading_digit_separator(&self) -> bool {
1029        Self::INTEGER_LEADING_DIGIT_SEPARATOR
1030    }
1031
1032    /// If a digit separator is allowed before any integer digits.
1033    ///
1034    /// This will consider an input of only the digit separator
1035    /// to be a identical to empty input.
1036    pub const FRACTION_LEADING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, FRACTION_LEADING_DIGIT_SEPARATOR);
1037
1038    /// Get if a digit separator is allowed before any fraction digits.
1039    ///
1040    /// This will consider an input of only the digit separator
1041    /// to be a identical to empty input.
1042    #[inline(always)]
1043    pub const fn fraction_leading_digit_separator(&self) -> bool {
1044        Self::FRACTION_LEADING_DIGIT_SEPARATOR
1045    }
1046
1047    /// If a digit separator is allowed before any exponent digits.
1048    ///
1049    /// This will consider an input of only the digit separator
1050    /// to be a identical to empty input.
1051    pub const EXPONENT_LEADING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, EXPONENT_LEADING_DIGIT_SEPARATOR);
1052
1053    /// Get if a digit separator is allowed before any exponent digits.
1054    ///
1055    /// This will consider an input of only the digit separator
1056    /// to be a identical to empty input.
1057    #[inline(always)]
1058    pub const fn exponent_leading_digit_separator(&self) -> bool {
1059        Self::EXPONENT_LEADING_DIGIT_SEPARATOR
1060    }
1061
1062    /// If a digit separator is allowed before any digits.
1063    ///
1064    /// This will consider an input of only the digit separator
1065    /// to be a identical to empty input.
1066    pub const LEADING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, LEADING_DIGIT_SEPARATOR);
1067
1068    /// Get if a digit separator is allowed before any digits.
1069    ///
1070    /// This will consider an input of only the digit separator
1071    /// to be a identical to empty input.
1072    #[inline(always)]
1073    pub const fn leading_digit_separator(&self) -> bool {
1074        Self::LEADING_DIGIT_SEPARATOR
1075    }
1076
1077    /// If a digit separator is allowed after any integer digits.
1078    ///
1079    /// This will consider an input of only the digit separator
1080    /// to be a identical to empty input.
1081    pub const INTEGER_TRAILING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, INTEGER_TRAILING_DIGIT_SEPARATOR);
1082
1083    /// Get if a digit separator is allowed after any integer digits.
1084    ///
1085    /// This will consider an input of only the digit separator
1086    /// to be a identical to empty input.
1087    #[inline(always)]
1088    pub const fn integer_trailing_digit_separator(&self) -> bool {
1089        Self::INTEGER_TRAILING_DIGIT_SEPARATOR
1090    }
1091
1092    /// If a digit separator is allowed after any fraction digits.
1093    ///
1094    /// This will consider an input of only the digit separator
1095    /// to be a identical to empty input.
1096    pub const FRACTION_TRAILING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, FRACTION_TRAILING_DIGIT_SEPARATOR);
1097
1098    /// Get if a digit separator is allowed after any fraction digits.
1099    ///
1100    /// This will consider an input of only the digit separator
1101    /// to be a identical to empty input.
1102    #[inline(always)]
1103    pub const fn fraction_trailing_digit_separator(&self) -> bool {
1104        Self::FRACTION_TRAILING_DIGIT_SEPARATOR
1105    }
1106
1107    /// If a digit separator is allowed after any exponent digits.
1108    ///
1109    /// This will consider an input of only the digit separator
1110    /// to be a identical to empty input.
1111    pub const EXPONENT_TRAILING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, EXPONENT_TRAILING_DIGIT_SEPARATOR);
1112
1113    /// Get if a digit separator is allowed after any exponent digits.
1114    ///
1115    /// This will consider an input of only the digit separator
1116    /// to be a identical to empty input.
1117    #[inline(always)]
1118    pub const fn exponent_trailing_digit_separator(&self) -> bool {
1119        Self::EXPONENT_TRAILING_DIGIT_SEPARATOR
1120    }
1121
1122    /// If a digit separator is allowed after any digits.
1123    ///
1124    /// This will consider an input of only the digit separator
1125    /// to be a identical to empty input.
1126    pub const TRAILING_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, TRAILING_DIGIT_SEPARATOR);
1127
1128    /// Get if a digit separator is allowed after any digits.
1129    ///
1130    /// This will consider an input of only the digit separator
1131    /// to be a identical to empty input.
1132    #[inline(always)]
1133    pub const fn trailing_digit_separator(&self) -> bool {
1134        Self::TRAILING_DIGIT_SEPARATOR
1135    }
1136
1137    /// If multiple consecutive integer digit separators are allowed.
1138    pub const INTEGER_CONSECUTIVE_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, INTEGER_CONSECUTIVE_DIGIT_SEPARATOR);
1139
1140    /// Get if multiple consecutive integer digit separators are allowed.
1141    #[inline(always)]
1142    pub const fn integer_consecutive_digit_separator(&self) -> bool {
1143        Self::INTEGER_CONSECUTIVE_DIGIT_SEPARATOR
1144    }
1145
1146    /// If multiple consecutive fraction digit separators are allowed.
1147    pub const FRACTION_CONSECUTIVE_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, FRACTION_CONSECUTIVE_DIGIT_SEPARATOR);
1148
1149    /// Get if multiple consecutive fraction digit separators are allowed.
1150    #[inline(always)]
1151    pub const fn fraction_consecutive_digit_separator(&self) -> bool {
1152        Self::FRACTION_CONSECUTIVE_DIGIT_SEPARATOR
1153    }
1154
1155    /// If multiple consecutive exponent digit separators are allowed.
1156    pub const EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR);
1157
1158    /// Get if multiple consecutive exponent digit separators are allowed.
1159    #[inline(always)]
1160    pub const fn exponent_consecutive_digit_separator(&self) -> bool {
1161        Self::EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR
1162    }
1163
1164    /// If multiple consecutive digit separators are allowed.
1165    pub const CONSECUTIVE_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, CONSECUTIVE_DIGIT_SEPARATOR);
1166
1167    /// Get if multiple consecutive digit separators are allowed.
1168    #[inline(always)]
1169    pub const fn consecutive_digit_separator(&self) -> bool {
1170        Self::CONSECUTIVE_DIGIT_SEPARATOR
1171    }
1172
1173    /// If any digit separators are allowed in special (non-finite) values.
1174    pub const SPECIAL_DIGIT_SEPARATOR: bool = from_flag!(FORMAT, SPECIAL_DIGIT_SEPARATOR);
1175
1176    /// Get if any digit separators are allowed in special (non-finite) values.
1177    #[inline(always)]
1178    pub const fn special_digit_separator(&self) -> bool {
1179        Self::SPECIAL_DIGIT_SEPARATOR
1180    }
1181
1182    // CHARACTERS
1183
1184    /// The digit separator character in the packed struct.
1185    pub const DIGIT_SEPARATOR: u8 = flags::digit_separator(FORMAT);
1186
1187    /// Get the digit separator character.
1188    ///
1189    /// If the digit separator is 0, digit separators are not allowed.
1190    #[inline(always)]
1191    pub const fn digit_separator(&self) -> u8 {
1192        Self::DIGIT_SEPARATOR
1193    }
1194
1195    /// The base prefix character in the packed struct.
1196    pub const BASE_PREFIX: u8 = flags::base_prefix(FORMAT);
1197
1198    /// Get the character for the base prefix.
1199    ///
1200    /// If the base prefix is 0, base prefixes are not allowed.
1201    /// The number will have then have the format `0$base_prefix...`.
1202    /// For example, a hex base prefix would be `0x`. Base prefixes are
1203    /// always optional.
1204    #[inline(always)]
1205    pub const fn base_prefix(&self) -> u8 {
1206        Self::BASE_PREFIX
1207    }
1208
1209    /// Get if the format has a base suffix.
1210    #[inline(always)]
1211    pub const fn has_base_prefix(&self) -> bool {
1212        self.base_prefix() != 0
1213    }
1214
1215    /// The base suffix character in the packed struct.
1216    pub const BASE_SUFFIX: u8 = flags::base_suffix(FORMAT);
1217
1218    /// Character for the base suffix.
1219    ///
1220    /// If not provided, base suffixes are not allowed.
1221    /// The number will have then have the format `...$base_suffix`.
1222    /// For example, a hex base prefix would be `0x`. Base prefixes are
1223    /// always optional.
1224    #[inline(always)]
1225    pub const fn base_suffix(&self) -> u8 {
1226        Self::BASE_SUFFIX
1227    }
1228
1229    /// Get if the format has a base suffix.
1230    #[inline(always)]
1231    pub const fn has_base_suffix(&self) -> bool {
1232        self.base_suffix() != 0
1233    }
1234
1235    // RADIX
1236
1237    /// The radix for the significant digits in the packed struct.
1238    pub const MANTISSA_RADIX: u32 = flags::mantissa_radix(FORMAT);
1239
1240    /// Get the radix for the mantissa digits.
1241    #[inline(always)]
1242    pub const fn mantissa_radix(&self) -> u32 {
1243        Self::MANTISSA_RADIX
1244    }
1245
1246    /// The radix for the significant digits in the packed struct.
1247    /// Alias for `MANTISSA_RADIX`.
1248    pub const RADIX: u32 = Self::MANTISSA_RADIX;
1249
1250    /// Get the radix for the significant digits.
1251    #[inline(always)]
1252    pub const fn radix(&self) -> u32 {
1253        Self::RADIX
1254    }
1255
1256    /// Get the radix**2 for the significant digits.
1257    #[inline(always)]
1258    pub const fn radix2(&self) -> u32 {
1259        self.radix().wrapping_mul(self.radix())
1260    }
1261
1262    /// Get the radix**4 for the significant digits.
1263    #[inline(always)]
1264    pub const fn radix4(&self) -> u32 {
1265        self.radix2().wrapping_mul(self.radix2())
1266    }
1267
1268    /// Get the radix*** for the significant digits.
1269    #[inline(always)]
1270    pub const fn radix8(&self) -> u32 {
1271        // NOTE: radix >= 16 will overflow here but this has no security concerns
1272        self.radix4().wrapping_mul(self.radix4())
1273    }
1274
1275    /// The base for the exponent.
1276    pub const EXPONENT_BASE: u32 = flags::exponent_base(FORMAT);
1277
1278    /// Get the base for the exponent.
1279    ///
1280    /// IE, a base of 2 means we have `mantissa * 2^exponent`.
1281    /// If not provided, it defaults to `radix`.
1282    #[inline(always)]
1283    pub const fn exponent_base(&self) -> u32 {
1284        Self::EXPONENT_BASE
1285    }
1286
1287    /// The radix for the exponent digits.
1288    pub const EXPONENT_RADIX: u32 = flags::exponent_radix(FORMAT);
1289
1290    /// Get the radix for the exponent digits.
1291    ///
1292    /// If not provided, defaults to `radix`.
1293    #[inline(always)]
1294    pub const fn exponent_radix(&self) -> u32 {
1295        Self::EXPONENT_RADIX
1296    }
1297
1298    // FLAGS
1299
1300    /// Get the flags from the number format.
1301    #[inline(always)]
1302    pub const fn flags(&self) -> u128 {
1303        FORMAT & flags::FLAG_MASK
1304    }
1305
1306    /// Get the interface flags from the number format.
1307    #[inline(always)]
1308    pub const fn interface_flags(&self) -> u128 {
1309        FORMAT & flags::INTERFACE_FLAG_MASK
1310    }
1311
1312    /// Get the digit separator flags from the number format.
1313    #[inline(always)]
1314    pub const fn digit_separator_flags(&self) -> u128 {
1315        FORMAT & flags::DIGIT_SEPARATOR_FLAG_MASK
1316    }
1317
1318    /// Get the exponent flags from the number format.
1319    #[inline(always)]
1320    pub const fn exponent_flags(&self) -> u128 {
1321        FORMAT & flags::EXPONENT_FLAG_MASK
1322    }
1323
1324    /// Get the integer digit separator flags from the number format.
1325    #[inline(always)]
1326    pub const fn integer_digit_separator_flags(&self) -> u128 {
1327        FORMAT & flags::INTEGER_DIGIT_SEPARATOR_FLAG_MASK
1328    }
1329
1330    /// Get the fraction digit separator flags from the number format.
1331    #[inline(always)]
1332    pub const fn fraction_digit_separator_flags(&self) -> u128 {
1333        FORMAT & flags::FRACTION_DIGIT_SEPARATOR_FLAG_MASK
1334    }
1335
1336    /// Get the exponent digit separator flags from the number format.
1337    #[inline(always)]
1338    pub const fn exponent_digit_separator_flags(&self) -> u128 {
1339        FORMAT & flags::EXPONENT_DIGIT_SEPARATOR_FLAG_MASK
1340    }
1341
1342    // BUILDER
1343
1344    /// Get the number format builder from the format.
1345    #[inline(always)]
1346    pub const fn builder() -> NumberFormatBuilder {
1347        NumberFormatBuilder::new()
1348    }
1349
1350    /// Get the number format builder from the format.
1351    #[inline(always)]
1352    pub const fn rebuild() -> NumberFormatBuilder {
1353        NumberFormatBuilder::rebuild(FORMAT)
1354    }
1355}
1356
1357impl<const FORMAT: u128> Default for NumberFormat<FORMAT> {
1358    fn default() -> Self {
1359        Self::new()
1360    }
1361}
1362
1363// PRE-DEFINED CONSTANTS
1364// ---------------------
1365//
1366// Sample Format Shorthand:
1367// ------------------------
1368//
1369// The format shorthand lists the test cases, and if applicable,
1370// the digit separator character. For example, the shorthand
1371// `[134-_]` specifies it passes tests 1, 3, and 4, and uses
1372// `'_'` as a digit-separator character. Meanwhile, `[0]` means it
1373// passes test 0, and has no digit separator.
1374
1375// RUST LITERAL [4569ABFGHIJKMN-_]
1376/// Number format for a `Rust` literal floating-point number.
1377#[rustfmt::skip]
1378pub const RUST_LITERAL: u128 = NumberFormatBuilder::new()
1379    .digit_separator(num::NonZeroU8::new(b'_'))
1380    .required_digits(true)
1381    .no_positive_mantissa_sign(true)
1382    .no_special(true)
1383    .internal_digit_separator(true)
1384    .trailing_digit_separator(true)
1385    .consecutive_digit_separator(true)
1386    .build();
1387
1388const_assert!(NumberFormat::<{ RUST_LITERAL }> {}.is_valid());
1389
1390// RUST STRING [0134567MN]
1391/// Number format to parse a `Rust` float from string.
1392#[rustfmt::skip]
1393pub const RUST_STRING: u128 = NumberFormatBuilder::new().build();
1394const_assert!(NumberFormat::<{ RUST_STRING }> {}.is_valid());
1395
1396/// Number format for a `Python` literal floating-point number.
1397pub const PYTHON_LITERAL: u128 = PYTHON3_LITERAL;
1398
1399/// Number format to parse a `Python` float from string.
1400pub const PYTHON_STRING: u128 = PYTHON3_STRING;
1401
1402/// Number format for a `Python3` literal floating-point number.
1403pub const PYTHON3_LITERAL: u128 = PYTHON36_LITERAL;
1404
1405// PYTHON3 STRING [0134567MN]
1406/// Number format to parse a `Python3` float from string.
1407#[rustfmt::skip]
1408pub const PYTHON3_STRING: u128 = NumberFormatBuilder::new().build();
1409const_assert!(NumberFormat::<{ PYTHON3_STRING }> {}.is_valid());
1410
1411// PYTHON3.6+ LITERAL [013456N-_]
1412/// Number format for a `Python3.6` or higher literal floating-point number.
1413#[rustfmt::skip]
1414pub const PYTHON36_LITERAL: u128 = NumberFormatBuilder::new()
1415    .digit_separator(num::NonZeroU8::new(b'_'))
1416    .no_special(true)
1417    .no_integer_leading_zeros(true)
1418    .internal_digit_separator(true)
1419    .build();
1420
1421const_assert!(NumberFormat::<{ PYTHON36_LITERAL }> {}.is_valid());
1422
1423// PYTHON3.5- LITERAL [013456N]
1424/// Number format for a `Python3.5` or lower literal floating-point number.
1425#[rustfmt::skip]
1426pub const PYTHON35_LITERAL: u128 = NumberFormatBuilder::new()
1427    .no_special(true)
1428    .no_integer_leading_zeros(true)
1429    .build();
1430
1431const_assert!(NumberFormat::<{ PYTHON35_LITERAL }> {}.is_valid());
1432
1433// PYTHON2 LITERAL [013456MN]
1434/// Number format for a `Python2` literal floating-point number.
1435#[rustfmt::skip]
1436pub const PYTHON2_LITERAL: u128 = NumberFormatBuilder::new()
1437    .no_special(true)
1438    .build();
1439
1440const_assert!(NumberFormat::<{ PYTHON2_LITERAL }> {}.is_valid());
1441
1442// PYTHON2 STRING [0134567MN]
1443/// Number format to parse a `Python2` float from string.
1444#[rustfmt::skip]
1445pub const PYTHON2_STRING: u128 = NumberFormatBuilder::new().build();
1446const_assert!(NumberFormat::<{ PYTHON2_STRING }> {}.is_valid());
1447
1448/// Number format for a `C++` literal floating-point number.
1449pub const CXX_LITERAL: u128 = CXX20_LITERAL;
1450
1451/// Number format to parse a `C++` float from string.
1452pub const CXX_STRING: u128 = CXX20_STRING;
1453
1454/// Number format for a `C++` literal hexadecimal floating-point number.
1455#[cfg(feature = "power-of-two")]
1456pub const CXX_HEX_LITERAL: u128 = CXX20_HEX_LITERAL;
1457
1458/// Number format to parse a `C++` hexadecimal float from string.
1459#[cfg(feature = "power-of-two")]
1460pub const CXX_HEX_STRING: u128 = CXX20_HEX_STRING;
1461
1462// C++20 LITERAL [013456789ABMN-']
1463/// Number format for a `C++20` literal floating-point number.
1464#[rustfmt::skip]
1465pub const CXX20_LITERAL: u128 = NumberFormatBuilder::new()
1466    .digit_separator(num::NonZeroU8::new(b'\''))
1467    .case_sensitive_special(true)
1468    .internal_digit_separator(true)
1469    .build();
1470
1471const_assert!(NumberFormat::<{ CXX20_LITERAL }> {}.is_valid());
1472
1473// C++20 STRING [0134567MN]
1474/// Number format for a `C++20` string floating-point number.
1475#[rustfmt::skip]
1476pub const CXX20_STRING: u128 = NumberFormatBuilder::new().build();
1477const_assert!(NumberFormat::<{ CXX20_STRING }> {}.is_valid());
1478
1479// C++20 HEX LITERAL [013456789ABMN-']
1480/// Number format for a `C++20` literal hexadecimal floating-point number.
1481#[rustfmt::skip]
1482#[cfg(feature = "power-of-two")]
1483pub const CXX20_HEX_LITERAL: u128 = NumberFormatBuilder::new()
1484    .required_exponent_notation(true)
1485    .digit_separator(num::NonZeroU8::new(b'\''))
1486    .mantissa_radix(16)
1487    .exponent_base(num::NonZeroU8::new(2))
1488    .exponent_radix(num::NonZeroU8::new(10))
1489    .case_sensitive_special(true)
1490    .internal_digit_separator(true)
1491    .build();
1492
1493#[cfg(feature = "power-of-two")]
1494const_assert!(NumberFormat::<{ CXX20_HEX_LITERAL }> {}.is_valid());
1495
1496// C++20 HEX STRING [0134567MN]
1497/// Number format for a `C++20` string hexadecimal floating-point number.
1498#[rustfmt::skip]
1499#[cfg(feature = "power-of-two")]
1500pub const CXX20_HEX_STRING: u128 = NumberFormatBuilder::new()
1501    .mantissa_radix(16)
1502    .exponent_base(num::NonZeroU8::new(2))
1503    .exponent_radix(num::NonZeroU8::new(10))
1504    .build();
1505
1506#[cfg(feature = "power-of-two")]
1507const_assert!(NumberFormat::<{ CXX20_HEX_STRING }> {}.is_valid());
1508
1509// C++17 LITERAL [013456789ABMN-']
1510/// Number format for a `C++17` literal floating-point number.
1511#[rustfmt::skip]
1512pub const CXX17_LITERAL: u128 = NumberFormatBuilder::new()
1513    .digit_separator(num::NonZeroU8::new(b'\''))
1514    .case_sensitive_special(true)
1515    .internal_digit_separator(true)
1516    .build();
1517
1518const_assert!(NumberFormat::<{ CXX17_LITERAL }> {}.is_valid());
1519
1520// C++17 STRING [0134567MN]
1521/// Number format for a `C++17` string floating-point number.
1522#[rustfmt::skip]
1523pub const CXX17_STRING: u128 = NumberFormatBuilder::new().build();
1524const_assert!(NumberFormat::<{ CXX17_STRING }> {}.is_valid());
1525
1526// C++17 HEX LITERAL [013456789ABMN-']
1527/// Number format for a `C++17` literal hexadecimal floating-point number.
1528#[rustfmt::skip]
1529#[cfg(feature = "power-of-two")]
1530pub const CXX17_HEX_LITERAL: u128 = NumberFormatBuilder::new()
1531    .required_exponent_notation(true)
1532    .digit_separator(num::NonZeroU8::new(b'\''))
1533    .mantissa_radix(16)
1534    .exponent_base(num::NonZeroU8::new(2))
1535    .exponent_radix(num::NonZeroU8::new(10))
1536    .case_sensitive_special(true)
1537    .internal_digit_separator(true)
1538    .build();
1539
1540#[cfg(feature = "power-of-two")]
1541const_assert!(NumberFormat::<{ CXX17_HEX_LITERAL }> {}.is_valid());
1542
1543// C++17 HEX STRING [0134567MN]
1544/// Number format for a `C++17` string hexadecimal floating-point number.
1545#[rustfmt::skip]
1546#[cfg(feature = "power-of-two")]
1547pub const CXX17_HEX_STRING: u128 = NumberFormatBuilder::new()
1548    .mantissa_radix(16)
1549    .exponent_base(num::NonZeroU8::new(2))
1550    .exponent_radix(num::NonZeroU8::new(10))
1551    .build();
1552
1553#[cfg(feature = "power-of-two")]
1554const_assert!(NumberFormat::<{ CXX17_HEX_STRING }> {}.is_valid());
1555
1556// C++14 LITERAL [013456789ABMN-']
1557/// Number format for a `C++14` literal floating-point number.
1558#[rustfmt::skip]
1559pub const CXX14_LITERAL: u128 = NumberFormatBuilder::new()
1560    .digit_separator(num::NonZeroU8::new(b'\''))
1561    .case_sensitive_special(true)
1562    .internal_digit_separator(true)
1563    .build();
1564
1565const_assert!(NumberFormat::<{ CXX14_LITERAL }> {}.is_valid());
1566
1567// C++14 STRING [0134567MN]
1568/// Number format for a `C++14` string floating-point number.
1569#[rustfmt::skip]
1570pub const CXX14_STRING: u128 = NumberFormatBuilder::new().build();
1571const_assert!(NumberFormat::<{ CXX14_STRING }> {}.is_valid());
1572
1573// C++14 HEX STRING [0134567MN]
1574/// Number format for a `C++14` string hexadecimal floating-point number.
1575#[rustfmt::skip]
1576#[cfg(feature = "power-of-two")]
1577pub const CXX14_HEX_STRING: u128 = NumberFormatBuilder::new()
1578    .mantissa_radix(16)
1579    .exponent_base(num::NonZeroU8::new(2))
1580    .exponent_radix(num::NonZeroU8::new(10))
1581    .build();
1582
1583#[cfg(feature = "power-of-two")]
1584const_assert!(NumberFormat::<{ CXX14_HEX_STRING }> {}.is_valid());
1585
1586// C++11 LITERAL [01345678MN]
1587/// Number format for a `C++11` literal floating-point number.
1588#[rustfmt::skip]
1589pub const CXX11_LITERAL: u128 = NumberFormatBuilder::new()
1590    .case_sensitive_special(true)
1591    .build();
1592
1593const_assert!(NumberFormat::<{ CXX11_LITERAL }> {}.is_valid());
1594
1595// C++11 STRING [0134567MN]
1596/// Number format for a `C++11` string floating-point number.
1597#[rustfmt::skip]
1598pub const CXX11_STRING: u128 = NumberFormatBuilder::new().build();
1599const_assert!(NumberFormat::<{ CXX11_STRING }> {}.is_valid());
1600
1601// C++11 HEX STRING [0134567MN]
1602/// Number format for a `C++11` string hexadecimal floating-point number.
1603#[rustfmt::skip]
1604#[cfg(feature = "power-of-two")]
1605pub const CXX11_HEX_STRING: u128 = NumberFormatBuilder::new()
1606    .mantissa_radix(16)
1607    .exponent_base(num::NonZeroU8::new(2))
1608    .exponent_radix(num::NonZeroU8::new(10))
1609    .build();
1610
1611#[cfg(feature = "power-of-two")]
1612const_assert!(NumberFormat::<{ CXX11_HEX_STRING }> {}.is_valid());
1613
1614// C++03 LITERAL [01345678MN]
1615/// Number format for a `C++03` literal floating-point number.
1616#[rustfmt::skip]
1617pub const CXX03_LITERAL: u128 = NumberFormatBuilder::new()
1618    .case_sensitive_special(true)
1619    .build();
1620
1621const_assert!(NumberFormat::<{ CXX03_LITERAL }> {}.is_valid());
1622
1623// C++03 STRING [0134567MN]
1624/// Number format for a `C++03` string floating-point number.
1625#[rustfmt::skip]
1626pub const CXX03_STRING: u128 = NumberFormatBuilder::new().build();
1627const_assert!(NumberFormat::<{ CXX03_STRING }> {}.is_valid());
1628
1629// C++98 LITERAL [01345678MN]
1630/// Number format for a `C++98` literal floating-point number.
1631#[rustfmt::skip]
1632pub const CXX98_LITERAL: u128 = NumberFormatBuilder::new()
1633    .case_sensitive_special(true)
1634    .build();
1635
1636const_assert!(NumberFormat::<{ CXX98_LITERAL }> {}.is_valid());
1637
1638// C++98 STRING [0134567MN]
1639/// Number format for a `C++98` string floating-point number.
1640#[rustfmt::skip]
1641pub const CXX98_STRING: u128 = NumberFormatBuilder::new().build();
1642const_assert!(NumberFormat::<{ CXX98_STRING }> {}.is_valid());
1643
1644/// Number format for a C literal floating-point number.
1645pub const C_LITERAL: u128 = C18_LITERAL;
1646
1647/// Number format to parse a `C` float from string.
1648pub const C_STRING: u128 = C18_STRING;
1649
1650/// Number format for a `C` literal hexadecimal floating-point number.
1651#[cfg(feature = "power-of-two")]
1652pub const C_HEX_LITERAL: u128 = C18_HEX_LITERAL;
1653
1654/// Number format to parse a `C` hexadecimal float from string.
1655#[cfg(feature = "power-of-two")]
1656pub const C_HEX_STRING: u128 = C18_HEX_STRING;
1657
1658// C18 LITERAL [01345678MN]
1659/// Number format for a `C18` literal floating-point number.
1660#[rustfmt::skip]
1661pub const C18_LITERAL: u128 = NumberFormatBuilder::new()
1662    .case_sensitive_special(true)
1663    .build();
1664
1665const_assert!(NumberFormat::<{ C18_LITERAL }> {}.is_valid());
1666
1667// C18 STRING [0134567MN]
1668/// Number format for a `C18` string floating-point number.
1669#[rustfmt::skip]
1670pub const C18_STRING: u128 = NumberFormatBuilder::new().build();
1671const_assert!(NumberFormat::<{ C18_STRING }> {}.is_valid());
1672
1673// C18 HEX LITERAL [01345678MN]
1674/// Number format for a `C18` literal hexadecimal floating-point number.
1675#[rustfmt::skip]
1676#[cfg(feature = "power-of-two")]
1677pub const C18_HEX_LITERAL: u128 = NumberFormatBuilder::new()
1678    .case_sensitive_special(true)
1679    .required_exponent_notation(true)
1680    .mantissa_radix(16)
1681    .exponent_base(num::NonZeroU8::new(2))
1682    .exponent_radix(num::NonZeroU8::new(10))
1683    .build();
1684
1685#[cfg(feature = "power-of-two")]
1686const_assert!(NumberFormat::<{ C18_HEX_LITERAL }> {}.is_valid());
1687
1688// C18 HEX STRING [0134567MN]
1689/// Number format for a `C18` string hexadecimal floating-point number.
1690#[rustfmt::skip]
1691#[cfg(feature = "power-of-two")]
1692pub const C18_HEX_STRING: u128 = NumberFormatBuilder::new()
1693    .mantissa_radix(16)
1694    .exponent_base(num::NonZeroU8::new(2))
1695    .exponent_radix(num::NonZeroU8::new(10))
1696    .build();
1697
1698#[cfg(feature = "power-of-two")]
1699const_assert!(NumberFormat::<{ C18_HEX_STRING }> {}.is_valid());
1700
1701// C11 LITERAL [01345678MN]
1702/// Number format for a `C11` literal floating-point number.
1703#[rustfmt::skip]
1704pub const C11_LITERAL: u128 = NumberFormatBuilder::new()
1705    .case_sensitive_special(true)
1706    .build();
1707
1708const_assert!(NumberFormat::<{ C11_LITERAL }> {}.is_valid());
1709
1710// C11 STRING [0134567MN]
1711/// Number format for a `C11` string floating-point number.
1712#[rustfmt::skip]
1713pub const C11_STRING: u128 = NumberFormatBuilder::new().build();
1714const_assert!(NumberFormat::<{ C11_STRING }> {}.is_valid());
1715
1716// C11 HEX LITERAL [01345678MN]
1717/// Number format for a `C11` literal hexadecimal floating-point number.
1718#[rustfmt::skip]
1719#[cfg(feature = "power-of-two")]
1720pub const C11_HEX_LITERAL: u128 = NumberFormatBuilder::new()
1721    .case_sensitive_special(true)
1722    .required_exponent_notation(true)
1723    .mantissa_radix(16)
1724    .exponent_base(num::NonZeroU8::new(2))
1725    .exponent_radix(num::NonZeroU8::new(10))
1726    .build();
1727
1728#[cfg(feature = "power-of-two")]
1729const_assert!(NumberFormat::<{ C11_HEX_LITERAL }> {}.is_valid());
1730
1731// C11 HEX STRING [0134567MN]
1732/// Number format for a `C11` string hexadecimal floating-point number.
1733#[rustfmt::skip]
1734#[cfg(feature = "power-of-two")]
1735pub const C11_HEX_STRING: u128 = NumberFormatBuilder::new()
1736    .mantissa_radix(16)
1737    .exponent_base(num::NonZeroU8::new(2))
1738    .exponent_radix(num::NonZeroU8::new(10))
1739    .build();
1740
1741#[cfg(feature = "power-of-two")]
1742const_assert!(NumberFormat::<{ C11_HEX_STRING }> {}.is_valid());
1743
1744// C99 LITERAL [01345678MN]
1745/// Number format for a `C99` literal floating-point number.
1746#[rustfmt::skip]
1747pub const C99_LITERAL: u128 = NumberFormatBuilder::new()
1748    .case_sensitive_special(true)
1749    .build();
1750
1751const_assert!(NumberFormat::<{ C99_LITERAL }> {}.is_valid());
1752
1753// C99 STRING [0134567MN]
1754/// Number format for a `C99` string floating-point number.
1755#[rustfmt::skip]
1756pub const C99_STRING: u128 = NumberFormatBuilder::new().build();
1757const_assert!(NumberFormat::<{ C99_STRING }> {}.is_valid());
1758
1759// C99 HEX LITERAL [01345678MN]
1760/// Number format for a `C99` literal hexadecimal floating-point number.
1761#[rustfmt::skip]
1762#[cfg(feature = "power-of-two")]
1763pub const C99_HEX_LITERAL: u128 = NumberFormatBuilder::new()
1764    .case_sensitive_special(true)
1765    .required_exponent_notation(true)
1766    .mantissa_radix(16)
1767    .exponent_base(num::NonZeroU8::new(2))
1768    .exponent_radix(num::NonZeroU8::new(10))
1769    .build();
1770
1771#[cfg(feature = "power-of-two")]
1772const_assert!(NumberFormat::<{ C99_HEX_LITERAL }> {}.is_valid());
1773
1774// C99 HEX STRING [0134567MN]
1775/// Number format for a `C99` string hexadecimal floating-point number.
1776#[rustfmt::skip]
1777#[cfg(feature = "power-of-two")]
1778pub const C99_HEX_STRING: u128 = NumberFormatBuilder::new()
1779    .mantissa_radix(16)
1780    .exponent_base(num::NonZeroU8::new(2))
1781    .exponent_radix(num::NonZeroU8::new(10))
1782    .build();
1783
1784#[cfg(feature = "power-of-two")]
1785const_assert!(NumberFormat::<{ C99_HEX_STRING }> {}.is_valid());
1786
1787// C90 LITERAL [013456MN]
1788/// Number format for a `C90` literal floating-point number.
1789#[rustfmt::skip]
1790pub const C90_LITERAL: u128 = NumberFormatBuilder::new()
1791    .no_special(true)
1792    .build();
1793
1794const_assert!(NumberFormat::<{ C90_LITERAL }> {}.is_valid());
1795
1796// C90 STRING [0134567MN]
1797/// Number format for a `C90` string floating-point number.
1798#[rustfmt::skip]
1799pub const C90_STRING: u128 = NumberFormatBuilder::new().build();
1800const_assert!(NumberFormat::<{ C90_STRING }> {}.is_valid());
1801
1802// C90 HEX STRING [0134567MN]
1803/// Number format for a `C90` string hexadecimal floating-point number.
1804#[rustfmt::skip]
1805#[cfg(feature = "power-of-two")]
1806pub const C90_HEX_STRING: u128 = NumberFormatBuilder::new()
1807    .mantissa_radix(16)
1808    .exponent_base(num::NonZeroU8::new(2))
1809    .exponent_radix(num::NonZeroU8::new(10))
1810    .build();
1811
1812#[cfg(feature = "power-of-two")]
1813const_assert!(NumberFormat::<{ C90_HEX_STRING }> {}.is_valid());
1814
1815// C89 LITERAL [013456MN]
1816/// Number format for a `C89` literal floating-point number.
1817#[rustfmt::skip]
1818pub const C89_LITERAL: u128 = NumberFormatBuilder::new()
1819    .no_special(true)
1820    .build();
1821
1822const_assert!(NumberFormat::<{ C89_LITERAL }> {}.is_valid());
1823
1824// C89 STRING [0134567MN]
1825/// Number format for a `C89` string floating-point number.
1826#[rustfmt::skip]
1827pub const C89_STRING: u128 = NumberFormatBuilder::new().build();
1828const_assert!(NumberFormat::<{ C89_STRING }> {}.is_valid());
1829
1830// C89 HEX STRING [0134567MN]
1831/// Number format for a `C89` string hexadecimal floating-point number.
1832#[rustfmt::skip]
1833#[cfg(feature = "power-of-two")]
1834pub const C89_HEX_STRING: u128 = NumberFormatBuilder::new()
1835    .mantissa_radix(16)
1836    .exponent_base(num::NonZeroU8::new(2))
1837    .exponent_radix(num::NonZeroU8::new(10))
1838    .build();
1839
1840#[cfg(feature = "power-of-two")]
1841const_assert!(NumberFormat::<{ C89_HEX_STRING }> {}.is_valid());
1842
1843// RUBY LITERAL [345689AMN-_]
1844/// Number format for a `Ruby` literal floating-point number.
1845#[rustfmt::skip]
1846pub const RUBY_LITERAL: u128 = NumberFormatBuilder::new()
1847    .digit_separator(num::NonZeroU8::new(b'_'))
1848    .required_exponent_sign(true)
1849    .required_digits(true)
1850    .no_special(true)
1851    .no_integer_leading_zeros(true)
1852    .no_float_leading_zeros(true)
1853    .internal_digit_separator(true)
1854    .build();
1855
1856const_assert!(NumberFormat::<{ RUBY_LITERAL }> {}.is_valid());
1857
1858// RUBY OCTAL LITERAL [345689AN-_]
1859/// Number format for a `Ruby` literal floating-point number.
1860#[rustfmt::skip]
1861#[cfg(feature = "power-of-two")]
1862pub const RUBY_OCTAL_LITERAL: u128 = NumberFormatBuilder::new()
1863    .digit_separator(num::NonZeroU8::new(b'_'))
1864    .mantissa_radix(8)
1865    .required_digits(true)
1866    .no_special(true)
1867    .internal_digit_separator(true)
1868    .build();
1869
1870#[cfg(feature = "power-of-two")]
1871const_assert!(NumberFormat::<{ RUBY_OCTAL_LITERAL }> {}.is_valid());
1872
1873// RUBY STRING [01234569ABMN-_]
1874// Note: Amazingly, Ruby 1.8+ do not allow parsing special values.
1875/// Number format to parse a `Ruby` float from string.
1876#[rustfmt::skip]
1877pub const RUBY_STRING: u128 = NumberFormatBuilder::new()
1878    .digit_separator(num::NonZeroU8::new(b'_'))
1879    .no_special(true)
1880    .internal_digit_separator(true)
1881    .build();
1882
1883const_assert!(NumberFormat::<{ RUBY_STRING }> {}.is_valid());
1884
1885// SWIFT LITERAL [34569ABFGHIJKMN-_]
1886/// Number format for a `Swift` literal floating-point number.
1887#[rustfmt::skip]
1888pub const SWIFT_LITERAL: u128 = NumberFormatBuilder::new()
1889    .digit_separator(num::NonZeroU8::new(b'_'))
1890    .required_digits(true)
1891    .no_special(true)
1892    .internal_digit_separator(true)
1893    .trailing_digit_separator(true)
1894    .consecutive_digit_separator(true)
1895    .build();
1896
1897const_assert!(NumberFormat::<{ SWIFT_LITERAL }> {}.is_valid());
1898
1899// SWIFT STRING [134567MN]
1900/// Number format to parse a `Swift` float from string.
1901#[rustfmt::skip]
1902pub const SWIFT_STRING: u128 = NumberFormatBuilder::new()
1903    .required_fraction_digits(true)
1904    .build();
1905
1906const_assert!(NumberFormat::<{ SWIFT_STRING }> {}.is_valid());
1907
1908// GO LITERAL [13456MN]
1909/// Number format for a `Golang` literal floating-point number.
1910#[rustfmt::skip]
1911pub const GO_LITERAL: u128 = NumberFormatBuilder::new()
1912    .required_fraction_digits(true)
1913    .no_special(true)
1914    .build();
1915
1916const_assert!(NumberFormat::<{ GO_LITERAL }> {}.is_valid());
1917
1918// GO STRING [134567MN]
1919/// Number format to parse a `Golang` float from string.
1920#[rustfmt::skip]
1921pub const GO_STRING: u128 = NumberFormatBuilder::new()
1922    .required_fraction_digits(true)
1923    .build();
1924
1925const_assert!(NumberFormat::<{ GO_STRING }> {}.is_valid());
1926
1927// HASKELL LITERAL [456MN]
1928/// Number format for a `Haskell` literal floating-point number.
1929#[rustfmt::skip]
1930pub const HASKELL_LITERAL: u128 = NumberFormatBuilder::new()
1931    .required_digits(true)
1932    .no_positive_mantissa_sign(true)
1933    .no_special(true)
1934    .build();
1935
1936const_assert!(NumberFormat::<{ HASKELL_LITERAL }> {}.is_valid());
1937
1938// HASKELL STRING [45678MN]
1939/// Number format to parse a `Haskell` float from string.
1940#[rustfmt::skip]
1941pub const HASKELL_STRING: u128 = NumberFormatBuilder::new()
1942    .required_digits(true)
1943    .no_positive_mantissa_sign(true)
1944    .case_sensitive_special(true)
1945    .build();
1946
1947const_assert!(NumberFormat::<{ HASKELL_STRING }> {}.is_valid());
1948
1949// JAVASCRIPT LITERAL [01345678M]
1950/// Number format for a `Javascript` literal floating-point number.
1951#[rustfmt::skip]
1952pub const JAVASCRIPT_LITERAL: u128 = NumberFormatBuilder::new()
1953    .case_sensitive_special(true)
1954    .no_float_leading_zeros(true)
1955    .build();
1956
1957const_assert!(NumberFormat::<{ JAVASCRIPT_LITERAL }> {}.is_valid());
1958
1959// JAVASCRIPT STRING [012345678MN]
1960/// Number format to parse a `Javascript` float from string.
1961#[rustfmt::skip]
1962pub const JAVASCRIPT_STRING: u128 = NumberFormatBuilder::new()
1963    .required_exponent_digits(false)
1964    .case_sensitive_special(true)
1965    .build();
1966
1967const_assert!(NumberFormat::<{ JAVASCRIPT_STRING }> {}.is_valid());
1968
1969// PERL LITERAL [0134569ABDEFGHIJKMN-_]
1970/// Number format for a `Perl` literal floating-point number.
1971#[rustfmt::skip]
1972pub const PERL_LITERAL: u128 = NumberFormatBuilder::new()
1973    .digit_separator(num::NonZeroU8::new(b'_'))
1974    .no_special(true)
1975    .internal_digit_separator(true)
1976    .fraction_leading_digit_separator(true)
1977    .exponent_leading_digit_separator(true)
1978    .trailing_digit_separator(true)
1979    .consecutive_digit_separator(true)
1980    .build();
1981
1982const_assert!(NumberFormat::<{ PERL_LITERAL }> {}.is_valid());
1983
1984// PERL STRING [01234567MN]
1985/// Number format to parse a `Perl` float from string.
1986pub const PERL_STRING: u128 = PERMISSIVE;
1987
1988// PHP LITERAL [01345678MN]
1989/// Number format for a `PHP` literal floating-point number.
1990#[rustfmt::skip]
1991pub const PHP_LITERAL: u128 = NumberFormatBuilder::new()
1992    .case_sensitive_special(true)
1993    .build();
1994
1995const_assert!(NumberFormat::<{ PHP_LITERAL }> {}.is_valid());
1996
1997// PHP STRING [0123456MN]
1998/// Number format to parse a `PHP` float from string.
1999#[rustfmt::skip]
2000pub const PHP_STRING: u128 = NumberFormatBuilder::new()
2001    .required_exponent_digits(false)
2002    .no_special(true)
2003    .build();
2004
2005const_assert!(NumberFormat::<{ PHP_STRING }> {}.is_valid());
2006
2007// JAVA LITERAL [0134569ABIJKMN-_]
2008/// Number format for a `Java` literal floating-point number.
2009#[rustfmt::skip]
2010pub const JAVA_LITERAL: u128 = NumberFormatBuilder::new()
2011    .digit_separator(num::NonZeroU8::new(b'_'))
2012    .no_special(true)
2013    .internal_digit_separator(true)
2014    .consecutive_digit_separator(true)
2015    .build();
2016
2017const_assert!(NumberFormat::<{ JAVA_LITERAL }> {}.is_valid());
2018
2019// JAVA STRING [01345678MN]
2020/// Number format to parse a `Java` float from string.
2021#[rustfmt::skip]
2022pub const JAVA_STRING: u128 = NumberFormatBuilder::new()
2023    .case_sensitive_special(true)
2024    .build();
2025
2026const_assert!(NumberFormat::<{ JAVA_STRING }> {}.is_valid());
2027
2028// R LITERAL [01345678MN]
2029/// Number format for a `R` literal floating-point number.
2030#[rustfmt::skip]
2031pub const R_LITERAL: u128 = NumberFormatBuilder::new()
2032    .case_sensitive_special(true)
2033    .build();
2034
2035const_assert!(NumberFormat::<{ R_LITERAL }> {}.is_valid());
2036
2037// R STRING [01234567MN]
2038/// Number format to parse a `R` float from string.
2039pub const R_STRING: u128 = PERMISSIVE;
2040
2041// KOTLIN LITERAL [0134569ABIJKN-_]
2042/// Number format for a `Kotlin` literal floating-point number.
2043#[rustfmt::skip]
2044pub const KOTLIN_LITERAL: u128 = NumberFormatBuilder::new()
2045    .digit_separator(num::NonZeroU8::new(b'_'))
2046    .no_special(true)
2047    .no_integer_leading_zeros(true)
2048    .internal_digit_separator(true)
2049    .consecutive_digit_separator(true)
2050    .build();
2051
2052const_assert!(NumberFormat::<{ KOTLIN_LITERAL }> {}.is_valid());
2053
2054// KOTLIN STRING [0134568MN]
2055/// Number format to parse a `Kotlin` float from string.
2056#[rustfmt::skip]
2057pub const KOTLIN_STRING: u128 = NumberFormatBuilder::new()
2058    .case_sensitive_special(true)
2059    .build();
2060
2061const_assert!(NumberFormat::<{ KOTLIN_STRING }> {}.is_valid());
2062
2063// JULIA LITERAL [01345689AMN-_]
2064/// Number format for a `Julia` literal floating-point number.
2065#[rustfmt::skip]
2066pub const JULIA_LITERAL: u128 = NumberFormatBuilder::new()
2067    .digit_separator(num::NonZeroU8::new(b'_'))
2068    .case_sensitive_special(true)
2069    .integer_internal_digit_separator(true)
2070    .fraction_internal_digit_separator(true)
2071    .build();
2072
2073const_assert!(NumberFormat::<{ JULIA_LITERAL }> {}.is_valid());
2074
2075// JULIA STRING [01345678MN]
2076/// Number format to parse a `Julia` float from string.
2077#[rustfmt::skip]
2078pub const JULIA_STRING: u128 = NumberFormatBuilder::new().build();
2079const_assert!(NumberFormat::<{ JULIA_STRING }> {}.is_valid());
2080
2081// JULIA HEX LITERAL [01345689AMN-_]
2082/// Number format for a `Julia` literal floating-point number.
2083#[rustfmt::skip]
2084#[cfg(feature = "power-of-two")]
2085pub const JULIA_HEX_LITERAL: u128 = NumberFormatBuilder::new()
2086    .digit_separator(num::NonZeroU8::new(b'_'))
2087    .mantissa_radix(16)
2088    .exponent_base(num::NonZeroU8::new(2))
2089    .exponent_radix(num::NonZeroU8::new(10))
2090    .case_sensitive_special(true)
2091    .integer_internal_digit_separator(true)
2092    .fraction_internal_digit_separator(true)
2093    .build();
2094
2095#[cfg(feature = "power-of-two")]
2096const_assert!(NumberFormat::<{ JULIA_HEX_LITERAL }> {}.is_valid());
2097
2098// JULIA HEX STRING [01345678MN]
2099/// Number format to parse a `Julia` float from string.
2100#[rustfmt::skip]
2101#[cfg(feature = "power-of-two")]
2102pub const JULIA_HEX_STRING: u128 = NumberFormatBuilder::new()
2103    .mantissa_radix(16)
2104    .exponent_base(num::NonZeroU8::new(2))
2105    .exponent_radix(num::NonZeroU8::new(10))
2106    .build();
2107
2108#[cfg(feature = "power-of-two")]
2109const_assert!(NumberFormat::<{ JULIA_HEX_STRING }> {}.is_valid());
2110
2111/// Number format for a `C#` literal floating-point number.
2112pub const CSHARP_LITERAL: u128 = CSHARP7_LITERAL;
2113
2114/// Number format to parse a `C#` float from string.
2115pub const CSHARP_STRING: u128 = CSHARP7_STRING;
2116
2117// CSHARP7 LITERAL [034569ABIJKMN-_]
2118/// Number format for a `C#7` literal floating-point number.
2119#[rustfmt::skip]
2120pub const CSHARP7_LITERAL: u128 = NumberFormatBuilder::new()
2121    .digit_separator(num::NonZeroU8::new(b'_'))
2122    .required_fraction_digits(true)
2123    .no_special(true)
2124    .internal_digit_separator(true)
2125    .consecutive_digit_separator(true)
2126    .build();
2127
2128const_assert!(NumberFormat::<{ CSHARP7_LITERAL }> {}.is_valid());
2129
2130// CSHARP7 STRING [0134568MN]
2131/// Number format to parse a `C#7` float from string.
2132#[rustfmt::skip]
2133pub const CSHARP7_STRING: u128 = NumberFormatBuilder::new()
2134    .case_sensitive_special(true)
2135    .build();
2136
2137const_assert!(NumberFormat::<{ CSHARP7_STRING }> {}.is_valid());
2138
2139// CSHARP6 LITERAL [03456MN]
2140/// Number format for a `C#6` literal floating-point number.
2141#[rustfmt::skip]
2142pub const CSHARP6_LITERAL: u128 = NumberFormatBuilder::new()
2143    .required_fraction_digits(true)
2144    .no_special(true)
2145    .build();
2146
2147const_assert!(NumberFormat::<{ CSHARP6_LITERAL }> {}.is_valid());
2148
2149// CSHARP6 STRING [0134568MN]
2150/// Number format to parse a `C#6` float from string.
2151#[rustfmt::skip]
2152pub const CSHARP6_STRING: u128 = NumberFormatBuilder::new()
2153    .case_sensitive_special(true)
2154    .build();
2155
2156const_assert!(NumberFormat::<{ CSHARP6_STRING }> {}.is_valid());
2157
2158// CSHARP5 LITERAL [03456MN]
2159/// Number format for a `C#5` literal floating-point number.
2160#[rustfmt::skip]
2161pub const CSHARP5_LITERAL: u128 = NumberFormatBuilder::new()
2162    .required_fraction_digits(true)
2163    .no_special(true)
2164    .build();
2165
2166const_assert!(NumberFormat::<{ CSHARP5_LITERAL }> {}.is_valid());
2167
2168// CSHARP5 STRING [0134568MN]
2169/// Number format to parse a `C#5` float from string.
2170#[rustfmt::skip]
2171pub const CSHARP5_STRING: u128 = NumberFormatBuilder::new()
2172    .case_sensitive_special(true)
2173    .build();
2174
2175const_assert!(NumberFormat::<{ CSHARP5_STRING }> {}.is_valid());
2176
2177// CSHARP4 LITERAL [03456MN]
2178/// Number format for a `C#4` literal floating-point number.
2179#[rustfmt::skip]
2180pub const CSHARP4_LITERAL: u128 = NumberFormatBuilder::new()
2181    .required_fraction_digits(true)
2182    .no_special(true)
2183    .build();
2184
2185const_assert!(NumberFormat::<{ CSHARP4_LITERAL }> {}.is_valid());
2186
2187// CSHARP4 STRING [0134568MN]
2188/// Number format to parse a `C#4` float from string.
2189#[rustfmt::skip]
2190pub const CSHARP4_STRING: u128 = NumberFormatBuilder::new()
2191    .case_sensitive_special(true)
2192    .build();
2193
2194const_assert!(NumberFormat::<{ CSHARP4_STRING }> {}.is_valid());
2195
2196// CSHARP3 LITERAL [03456MN]
2197/// Number format for a `C#3` literal floating-point number.
2198#[rustfmt::skip]
2199pub const CSHARP3_LITERAL: u128 = NumberFormatBuilder::new()
2200    .required_fraction_digits(true)
2201    .no_special(true)
2202    .build();
2203
2204const_assert!(NumberFormat::<{ CSHARP3_LITERAL }> {}.is_valid());
2205
2206// CSHARP3 STRING [0134568MN]
2207/// Number format to parse a `C#3` float from string.
2208#[rustfmt::skip]
2209pub const CSHARP3_STRING: u128 = NumberFormatBuilder::new()
2210    .case_sensitive_special(true)
2211    .build();
2212
2213const_assert!(NumberFormat::<{ CSHARP3_STRING }> {}.is_valid());
2214
2215// CSHARP2 LITERAL [03456MN]
2216/// Number format for a `C#2` literal floating-point number.
2217#[rustfmt::skip]
2218pub const CSHARP2_LITERAL: u128 = NumberFormatBuilder::new()
2219    .required_fraction_digits(true)
2220    .no_special(true)
2221    .build();
2222
2223const_assert!(NumberFormat::<{ CSHARP2_LITERAL }> {}.is_valid());
2224
2225// CSHARP2 STRING [0134568MN]
2226/// Number format to parse a `C#2` float from string.
2227#[rustfmt::skip]
2228pub const CSHARP2_STRING: u128 = NumberFormatBuilder::new()
2229    .case_sensitive_special(true)
2230    .build();
2231
2232const_assert!(NumberFormat::<{ CSHARP2_STRING }> {}.is_valid());
2233
2234// CSHARP1 LITERAL [03456MN]
2235/// Number format for a `C#1` literal floating-point number.
2236#[rustfmt::skip]
2237pub const CSHARP1_LITERAL: u128 = NumberFormatBuilder::new()
2238    .required_fraction_digits(true)
2239    .no_special(true)
2240    .build();
2241
2242const_assert!(NumberFormat::<{ CSHARP1_LITERAL }> {}.is_valid());
2243
2244// CSHARP1 STRING [0134568MN]
2245/// Number format to parse a `C#1` float from string.
2246#[rustfmt::skip]
2247pub const CSHARP1_STRING: u128 = NumberFormatBuilder::new()
2248    .case_sensitive_special(true)
2249    .build();
2250
2251const_assert!(NumberFormat::<{ CSHARP1_STRING }> {}.is_valid());
2252
2253// KAWA LITERAL [013456MN]
2254/// Number format for a `Kawa` literal floating-point number.
2255#[rustfmt::skip]
2256pub const KAWA_LITERAL: u128 = NumberFormatBuilder::new()
2257    .no_special(true)
2258    .build();
2259
2260const_assert!(NumberFormat::<{ KAWA_LITERAL }> {}.is_valid());
2261
2262// KAWA STRING [013456MN]
2263/// Number format to parse a `Kawa` float from string.
2264#[rustfmt::skip]
2265pub const KAWA_STRING: u128 = NumberFormatBuilder::new()
2266    .no_special(true)
2267    .build();
2268
2269const_assert!(NumberFormat::<{ KAWA_STRING }> {}.is_valid());
2270
2271// GAMBITC LITERAL [013456MN]
2272/// Number format for a `Gambit-C` literal floating-point number.
2273#[rustfmt::skip]
2274pub const GAMBITC_LITERAL: u128 = NumberFormatBuilder::new()
2275    .no_special(true)
2276    .build();
2277
2278const_assert!(NumberFormat::<{ GAMBITC_LITERAL }> {}.is_valid());
2279
2280// GAMBITC STRING [013456MN]
2281/// Number format to parse a `Gambit-C` float from string.
2282#[rustfmt::skip]
2283pub const GAMBITC_STRING: u128 = NumberFormatBuilder::new()
2284    .no_special(true)
2285    .build();
2286
2287const_assert!(NumberFormat::<{ GAMBITC_STRING }> {}.is_valid());
2288
2289// GUILE LITERAL [013456MN]
2290/// Number format for a `Guile` literal floating-point number.
2291#[rustfmt::skip]
2292pub const GUILE_LITERAL: u128 = NumberFormatBuilder::new()
2293    .no_special(true)
2294    .build();
2295
2296const_assert!(NumberFormat::<{ GUILE_LITERAL }> {}.is_valid());
2297
2298// GUILE STRING [013456MN]
2299/// Number format to parse a `Guile` float from string.
2300#[rustfmt::skip]
2301pub const GUILE_STRING: u128 = NumberFormatBuilder::new()
2302    .no_special(true)
2303    .build();
2304
2305const_assert!(NumberFormat::<{ GUILE_STRING }> {}.is_valid());
2306
2307// CLOJURE LITERAL [13456MN]
2308/// Number format for a `Clojure` literal floating-point number.
2309#[rustfmt::skip]
2310pub const CLOJURE_LITERAL: u128 = NumberFormatBuilder::new()
2311    .required_integer_digits(true)
2312    .no_special(true)
2313    .build();
2314
2315const_assert!(NumberFormat::<{ CLOJURE_LITERAL }> {}.is_valid());
2316
2317// CLOJURE STRING [01345678MN]
2318/// Number format to parse a `Clojure` float from string.
2319#[rustfmt::skip]
2320pub const CLOJURE_STRING: u128 = NumberFormatBuilder::new()
2321    .case_sensitive_special(true)
2322    .build();
2323
2324const_assert!(NumberFormat::<{ CLOJURE_STRING }> {}.is_valid());
2325
2326// ERLANG LITERAL [34578MN]
2327/// Number format for an `Erlang` literal floating-point number.
2328#[rustfmt::skip]
2329pub const ERLANG_LITERAL: u128 = NumberFormatBuilder::new()
2330    .required_digits(true)
2331    .no_exponent_without_fraction(true)
2332    .case_sensitive_special(true)
2333    .build();
2334
2335const_assert!(NumberFormat::<{ ERLANG_LITERAL }> {}.is_valid());
2336
2337// ERLANG STRING [345MN]
2338/// Number format to parse an `Erlang` float from string.
2339#[rustfmt::skip]
2340pub const ERLANG_STRING: u128 = NumberFormatBuilder::new()
2341    .required_digits(true)
2342    .no_exponent_without_fraction(true)
2343    .no_special(true)
2344    .build();
2345
2346const_assert!(NumberFormat::<{ ERLANG_STRING }> {}.is_valid());
2347
2348// ELM LITERAL [456]
2349/// Number format for an `Elm` literal floating-point number.
2350#[rustfmt::skip]
2351pub const ELM_LITERAL: u128 = NumberFormatBuilder::new()
2352    .required_digits(true)
2353    .no_positive_mantissa_sign(true)
2354    .no_integer_leading_zeros(true)
2355    .no_float_leading_zeros(true)
2356    .no_special(true)
2357    .build();
2358
2359const_assert!(NumberFormat::<{ ELM_LITERAL }> {}.is_valid());
2360
2361// ELM STRING [01345678MN]
2362// Note: There is no valid representation of NaN, just Infinity.
2363/// Number format to parse an `Elm` float from string.
2364#[rustfmt::skip]
2365pub const ELM_STRING: u128 = NumberFormatBuilder::new()
2366    .case_sensitive_special(true)
2367    .build();
2368
2369const_assert!(NumberFormat::<{ ELM_STRING }> {}.is_valid());
2370
2371// SCALA LITERAL [3456]
2372/// Number format for a `Scala` literal floating-point number.
2373#[rustfmt::skip]
2374pub const SCALA_LITERAL: u128 = NumberFormatBuilder::new()
2375    .required_digits(true)
2376    .no_special(true)
2377    .no_integer_leading_zeros(true)
2378    .no_float_leading_zeros(true)
2379    .build();
2380
2381const_assert!(NumberFormat::<{ SCALA_LITERAL }> {}.is_valid());
2382
2383// SCALA STRING [01345678MN]
2384/// Number format to parse a `Scala` float from string.
2385#[rustfmt::skip]
2386pub const SCALA_STRING: u128 = NumberFormatBuilder::new()
2387    .case_sensitive_special(true)
2388    .build();
2389
2390const_assert!(NumberFormat::<{ SCALA_STRING }> {}.is_valid());
2391
2392// ELIXIR LITERAL [3459ABMN-_]
2393/// Number format for an `Elixir` literal floating-point number.
2394#[rustfmt::skip]
2395pub const ELIXIR_LITERAL: u128 = NumberFormatBuilder::new()
2396    .digit_separator(num::NonZeroU8::new(b'_'))
2397    .required_digits(true)
2398    .no_exponent_without_fraction(true)
2399    .no_special(true)
2400    .internal_digit_separator(true)
2401    .build();
2402
2403const_assert!(NumberFormat::<{ ELIXIR_LITERAL }> {}.is_valid());
2404
2405// ELIXIR STRING [345MN]
2406/// Number format to parse an `Elixir` float from string.
2407#[rustfmt::skip]
2408pub const ELIXIR_STRING: u128 = NumberFormatBuilder::new()
2409    .required_digits(true)
2410    .no_exponent_without_fraction(true)
2411    .no_special(true)
2412    .build();
2413
2414const_assert!(NumberFormat::<{ ELIXIR_STRING }> {}.is_valid());
2415
2416// FORTRAN LITERAL [013456MN]
2417/// Number format for a `FORTRAN` literal floating-point number.
2418#[rustfmt::skip]
2419pub const FORTRAN_LITERAL: u128 = NumberFormatBuilder::new()
2420    .no_special(true)
2421    .build();
2422
2423const_assert!(NumberFormat::<{ FORTRAN_LITERAL }> {}.is_valid());
2424
2425// FORTRAN STRING [0134567MN]
2426/// Number format to parse a `FORTRAN` float from string.
2427#[rustfmt::skip]
2428pub const FORTRAN_STRING: u128 = NumberFormatBuilder::new().build();
2429const_assert!(NumberFormat::<{ FORTRAN_STRING }> {}.is_valid());
2430
2431// D LITERAL [0134569ABFGHIJKN-_]
2432/// Number format for a `D` literal floating-point number.
2433#[rustfmt::skip]
2434pub const D_LITERAL: u128 = NumberFormatBuilder::new()
2435    .digit_separator(num::NonZeroU8::new(b'_'))
2436    .no_special(true)
2437    .no_integer_leading_zeros(true)
2438    .internal_digit_separator(true)
2439    .trailing_digit_separator(true)
2440    .consecutive_digit_separator(true)
2441    .build();
2442
2443const_assert!(NumberFormat::<{ D_LITERAL }> {}.is_valid());
2444
2445// D STRING [01345679AFGMN-_]
2446/// Number format to parse a `D` float from string.
2447#[rustfmt::skip]
2448pub const D_STRING: u128 = NumberFormatBuilder::new()
2449    .digit_separator(num::NonZeroU8::new(b'_'))
2450    .integer_internal_digit_separator(true)
2451    .fraction_internal_digit_separator(true)
2452    .integer_trailing_digit_separator(true)
2453    .fraction_trailing_digit_separator(true)
2454    .build();
2455
2456const_assert!(NumberFormat::<{ D_STRING }> {}.is_valid());
2457
2458// COFFEESCRIPT LITERAL [01345678]
2459/// Number format for a `Coffeescript` literal floating-point number.
2460#[rustfmt::skip]
2461pub const COFFEESCRIPT_LITERAL: u128 = NumberFormatBuilder::new()
2462    .case_sensitive_special(true)
2463    .no_integer_leading_zeros(true)
2464    .no_float_leading_zeros(true)
2465    .build();
2466
2467const_assert!(NumberFormat::<{ COFFEESCRIPT_LITERAL }> {}.is_valid());
2468
2469// COFFEESCRIPT STRING [012345678MN]
2470/// Number format to parse a `Coffeescript` float from string.
2471#[rustfmt::skip]
2472pub const COFFEESCRIPT_STRING: u128 = NumberFormatBuilder::new()
2473    .case_sensitive_special(true)
2474    .build();
2475
2476const_assert!(NumberFormat::<{ COFFEESCRIPT_STRING }> {}.is_valid());
2477
2478// COBOL LITERAL [0345MN]
2479/// Number format for a `Cobol` literal floating-point number.
2480#[rustfmt::skip]
2481pub const COBOL_LITERAL: u128 = NumberFormatBuilder::new()
2482    .required_fraction_digits(true)
2483    .no_exponent_without_fraction(true)
2484    .no_special(true)
2485    .build();
2486
2487const_assert!(NumberFormat::<{ COBOL_LITERAL }> {}.is_valid());
2488
2489// COBOL STRING [012356MN]
2490/// Number format to parse a `Cobol` float from string.
2491#[rustfmt::skip]
2492pub const COBOL_STRING: u128 = NumberFormatBuilder::new()
2493    .required_exponent_sign(true)
2494    .no_special(true)
2495    .build();
2496
2497const_assert!(NumberFormat::<{ COBOL_STRING }> {}.is_valid());
2498
2499// FSHARP LITERAL [13456789ABIJKMN-_]
2500/// Number format for a `F#` literal floating-point number.
2501#[rustfmt::skip]
2502pub const FSHARP_LITERAL: u128 = NumberFormatBuilder::new()
2503    .digit_separator(num::NonZeroU8::new(b'_'))
2504    .required_integer_digits(true)
2505    .required_exponent_digits(true)
2506    .case_sensitive_special(true)
2507    .internal_digit_separator(true)
2508    .consecutive_digit_separator(true)
2509    .build();
2510
2511const_assert!(NumberFormat::<{ FSHARP_LITERAL }> {}.is_valid());
2512
2513// FSHARP STRING [013456789ABCDEFGHIJKLMN-_]
2514/// Number format to parse a `F#` float from string.
2515#[rustfmt::skip]
2516pub const FSHARP_STRING: u128 = NumberFormatBuilder::new()
2517    .digit_separator(num::NonZeroU8::new(b'_'))
2518    .internal_digit_separator(true)
2519    .leading_digit_separator(true)
2520    .trailing_digit_separator(true)
2521    .consecutive_digit_separator(true)
2522    .special_digit_separator(true)
2523    .build();
2524
2525const_assert!(NumberFormat::<{ FSHARP_STRING }> {}.is_valid());
2526
2527// VB LITERAL [03456MN]
2528/// Number format for a `Visual Basic` literal floating-point number.
2529#[rustfmt::skip]
2530pub const VB_LITERAL: u128 = NumberFormatBuilder::new()
2531    .required_fraction_digits(true)
2532    .no_special(true)
2533    .build();
2534
2535const_assert!(NumberFormat::<{ VB_LITERAL }> {}.is_valid());
2536
2537// VB STRING [01345678MN]
2538/// Number format to parse a `Visual Basic` float from string.
2539// Note: To my knowledge, Visual Basic cannot parse infinity.
2540#[rustfmt::skip]
2541pub const VB_STRING: u128 = NumberFormatBuilder::new()
2542    .case_sensitive_special(true)
2543    .build();
2544
2545const_assert!(NumberFormat::<{ VB_STRING }> {}.is_valid());
2546
2547// OCAML LITERAL [1456789ABDFGHIJKMN-_]
2548/// Number format for an `OCaml` literal floating-point number.
2549#[rustfmt::skip]
2550pub const OCAML_LITERAL: u128 = NumberFormatBuilder::new()
2551    .digit_separator(num::NonZeroU8::new(b'_'))
2552    .required_integer_digits(true)
2553    .required_exponent_digits(true)
2554    .no_positive_mantissa_sign(true)
2555    .case_sensitive_special(true)
2556    .internal_digit_separator(true)
2557    .fraction_leading_digit_separator(true)
2558    .trailing_digit_separator(true)
2559    .consecutive_digit_separator(true)
2560    .build();
2561
2562const_assert!(NumberFormat::<{ OCAML_LITERAL }> {}.is_valid());
2563
2564// OCAML STRING [01345679ABCDEFGHIJKLMN-_]
2565/// Number format to parse an `OCaml` float from string.
2566#[rustfmt::skip]
2567pub const OCAML_STRING: u128 = NumberFormatBuilder::new()
2568    .digit_separator(num::NonZeroU8::new(b'_'))
2569    .internal_digit_separator(true)
2570    .leading_digit_separator(true)
2571    .trailing_digit_separator(true)
2572    .consecutive_digit_separator(true)
2573    .special_digit_separator(true)
2574    .build();
2575
2576const_assert!(NumberFormat::<{ OCAML_STRING }> {}.is_valid());
2577
2578// OBJECTIVEC LITERAL [013456MN]
2579/// Number format for an `Objective-C` literal floating-point number.
2580#[rustfmt::skip]
2581pub const OBJECTIVEC_LITERAL: u128 = NumberFormatBuilder::new()
2582    .no_special(true)
2583    .build();
2584
2585const_assert!(NumberFormat::<{ OBJECTIVEC_LITERAL }> {}.is_valid());
2586
2587// OBJECTIVEC STRING [013456MN]
2588/// Number format to parse an `Objective-C` float from string.
2589#[rustfmt::skip]
2590pub const OBJECTIVEC_STRING: u128 = NumberFormatBuilder::new()
2591    .no_special(true)
2592    .build();
2593
2594const_assert!(NumberFormat::<{ OBJECTIVEC_STRING }> {}.is_valid());
2595
2596// REASONML LITERAL [13456789ABDFGHIJKMN-_]
2597/// Number format for a `ReasonML` literal floating-point number.
2598#[rustfmt::skip]
2599pub const REASONML_LITERAL: u128 = NumberFormatBuilder::new()
2600    .digit_separator(num::NonZeroU8::new(b'_'))
2601    .required_integer_digits(true)
2602    .required_exponent_digits(true)
2603    .case_sensitive_special(true)
2604    .internal_digit_separator(true)
2605    .fraction_leading_digit_separator(true)
2606    .trailing_digit_separator(true)
2607    .consecutive_digit_separator(true)
2608    .build();
2609
2610const_assert!(NumberFormat::<{ REASONML_LITERAL }> {}.is_valid());
2611
2612// REASONML STRING [01345679ABCDEFGHIJKLMN-_]
2613/// Number format to parse a `ReasonML` float from string.
2614#[rustfmt::skip]
2615pub const REASONML_STRING: u128 = NumberFormatBuilder::new()
2616    .digit_separator(num::NonZeroU8::new(b'_'))
2617    .internal_digit_separator(true)
2618    .leading_digit_separator(true)
2619    .trailing_digit_separator(true)
2620    .consecutive_digit_separator(true)
2621    .special_digit_separator(true)
2622    .build();
2623
2624const_assert!(NumberFormat::<{ REASONML_STRING }> {}.is_valid());
2625
2626// OCTAVE LITERAL [013456789ABDFGHIJKMN-_]
2627// Note: Octave accepts both NaN and nan, Inf and inf.
2628/// Number format for an `Octave` literal floating-point number.
2629#[rustfmt::skip]
2630pub const OCTAVE_LITERAL: u128 = NumberFormatBuilder::new()
2631    .digit_separator(num::NonZeroU8::new(b'_'))
2632    .case_sensitive_special(true)
2633    .internal_digit_separator(true)
2634    .fraction_leading_digit_separator(true)
2635    .trailing_digit_separator(true)
2636    .consecutive_digit_separator(true)
2637    .build();
2638
2639const_assert!(NumberFormat::<{ OCTAVE_LITERAL }> {}.is_valid());
2640
2641// OCTAVE STRING [01345679ABCDEFGHIJKMN-,]
2642/// Number format to parse an `Octave` float from string.
2643#[rustfmt::skip]
2644pub const OCTAVE_STRING: u128 = NumberFormatBuilder::new()
2645    .digit_separator(num::NonZeroU8::new(b','))
2646    .internal_digit_separator(true)
2647    .leading_digit_separator(true)
2648    .trailing_digit_separator(true)
2649    .consecutive_digit_separator(true)
2650    .build();
2651
2652const_assert!(NumberFormat::<{ OCTAVE_STRING }> {}.is_valid());
2653
2654// MATLAB LITERAL [013456789ABDFGHIJKMN-_]
2655// Note: Matlab accepts both NaN and nan, Inf and inf.
2656/// Number format for an `Matlab` literal floating-point number.
2657#[rustfmt::skip]
2658pub const MATLAB_LITERAL: u128 = NumberFormatBuilder::new()
2659    .digit_separator(num::NonZeroU8::new(b'_'))
2660    .case_sensitive_special(true)
2661    .internal_digit_separator(true)
2662    .fraction_leading_digit_separator(true)
2663    .trailing_digit_separator(true)
2664    .consecutive_digit_separator(true)
2665    .build();
2666
2667const_assert!(NumberFormat::<{ MATLAB_LITERAL }> {}.is_valid());
2668
2669// MATLAB STRING [01345679ABCDEFGHIJKMN-,]
2670/// Number format to parse an `Matlab` float from string.
2671#[rustfmt::skip]
2672pub const MATLAB_STRING: u128 = NumberFormatBuilder::new()
2673    .digit_separator(num::NonZeroU8::new(b','))
2674    .internal_digit_separator(true)
2675    .leading_digit_separator(true)
2676    .trailing_digit_separator(true)
2677    .consecutive_digit_separator(true)
2678    .build();
2679
2680const_assert!(NumberFormat::<{ MATLAB_STRING }> {}.is_valid());
2681
2682// ZIG LITERAL [1456MN]
2683/// Number format for a `Zig` literal floating-point number.
2684#[rustfmt::skip]
2685pub const ZIG_LITERAL: u128 = NumberFormatBuilder::new()
2686    .required_integer_digits(true)
2687    .no_positive_mantissa_sign(true)
2688    .no_special(true)
2689    .build();
2690
2691const_assert!(NumberFormat::<{ ZIG_LITERAL }> {}.is_valid());
2692
2693// ZIG STRING [01234567MN]
2694/// Number format to parse a `Zig` float from string.
2695pub const ZIG_STRING: u128 = PERMISSIVE;
2696
2697// SAGE LITERAL [012345678MN]
2698// Note: Both Infinity and infinity are accepted.
2699/// Number format for a `Sage` literal floating-point number.
2700#[rustfmt::skip]
2701pub const SAGE_LITERAL: u128 = NumberFormatBuilder::new()
2702    .case_sensitive_special(true)
2703    .build();
2704
2705const_assert!(NumberFormat::<{ SAGE_LITERAL }> {}.is_valid());
2706
2707// SAGE STRING [01345679ABMN-_]
2708/// Number format to parse a `Sage` float from string.
2709#[rustfmt::skip]
2710pub const SAGE_STRING: u128 = NumberFormatBuilder::new()
2711    .digit_separator(num::NonZeroU8::new(b'_'))
2712    .internal_digit_separator(true)
2713    .build();
2714
2715const_assert!(NumberFormat::<{ SAGE_STRING }> {}.is_valid());
2716
2717// JSON [456]
2718/// Number format for a `JSON` literal floating-point number.
2719#[rustfmt::skip]
2720pub const JSON: u128 = NumberFormatBuilder::new()
2721    .required_digits(true)
2722    .no_positive_mantissa_sign(true)
2723    .no_special(true)
2724    .no_integer_leading_zeros(true)
2725    .no_float_leading_zeros(true)
2726    .build();
2727
2728const_assert!(NumberFormat::<{ JSON }> {}.is_valid());
2729
2730// TOML [34569AB]
2731/// Number format for a `TOML` literal floating-point number.
2732#[rustfmt::skip]
2733pub const TOML: u128 = NumberFormatBuilder::new()
2734    .digit_separator(num::NonZeroU8::new(b'_'))
2735    .required_digits(false)
2736    .no_special(true)
2737    .no_integer_leading_zeros(true)
2738    .no_float_leading_zeros(true)
2739    .internal_digit_separator(true)
2740    .build();
2741
2742const_assert!(NumberFormat::<{ TOML }> {}.is_valid());
2743
2744// YAML (defined in-terms of JSON schema).
2745/// Number format for a `YAML` literal floating-point number.
2746pub const YAML: u128 = JSON;
2747
2748// XML [01234578MN]
2749/// Number format for a `XML` literal floating-point number.
2750#[rustfmt::skip]
2751pub const XML: u128 = NumberFormatBuilder::new()
2752    .required_exponent_digits(false)
2753    .case_sensitive_special(true)
2754    .build();
2755
2756const_assert!(NumberFormat::<{ XML }> {}.is_valid());
2757
2758// SQLITE [013456MN]
2759/// Number format for a `SQLite` literal floating-point number.
2760#[rustfmt::skip]
2761pub const SQLITE: u128 = NumberFormatBuilder::new()
2762    .no_special(true)
2763    .build();
2764
2765const_assert!(NumberFormat::<{ SQLITE }> {}.is_valid());
2766
2767// POSTGRESQL [013456MN]
2768/// Number format for a `PostgreSQL` literal floating-point number.
2769#[rustfmt::skip]
2770pub const POSTGRESQL: u128 = NumberFormatBuilder::new()
2771    .no_special(true)
2772    .build();
2773
2774const_assert!(NumberFormat::<{ POSTGRESQL }> {}.is_valid());
2775
2776// MYSQL [013456MN]
2777/// Number format for a `MySQL` literal floating-point number.
2778#[rustfmt::skip]
2779pub const MYSQL: u128 = NumberFormatBuilder::new()
2780    .no_special(true)
2781    .build();
2782
2783const_assert!(NumberFormat::<{ MYSQL }> {}.is_valid());
2784
2785// MONGODB [01345678M]
2786/// Number format for a `MongoDB` literal floating-point number.
2787#[rustfmt::skip]
2788pub const MONGODB: u128 = NumberFormatBuilder::new()
2789    .case_sensitive_special(true)
2790    .no_float_leading_zeros(true)
2791    .build();
2792
2793const_assert!(NumberFormat::<{ MONGODB }> {}.is_valid());
2794
2795// HIDDEN DEFAULTS AND INTERFACES
2796
2797/// Number format when no flags are set.
2798#[doc(hidden)]
2799#[rustfmt::skip]
2800pub const PERMISSIVE: u128 = NumberFormatBuilder::new()
2801    .required_exponent_digits(false)
2802    .required_mantissa_digits(false)
2803    .build();
2804
2805const_assert!(NumberFormat::<{ PERMISSIVE }> {}.is_valid());
2806
2807/// Number format when all digit separator flags are set.
2808#[doc(hidden)]
2809#[rustfmt::skip]
2810pub const IGNORE: u128 = NumberFormatBuilder::new()
2811    .digit_separator(num::NonZeroU8::new(b'_'))
2812    .digit_separator_flags(true)
2813    .required_exponent_digits(false)
2814    .required_mantissa_digits(false)
2815    .build();
2816
2817const_assert!(NumberFormat::<{ IGNORE }> {}.is_valid());