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