| 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package numberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/ |
| 6 | |
| 7 | import ( |
| 8 | "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/" |
| 9 | "unicode/utf8scip-go gomod github.com/golang/go/src go1.25.0 `unicode/utf8`/" |
| 10 | ) |
| 11 | |
| 12 | // This file contains a parser for the CLDR number patterns as described in |
| 13 | // https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns. |
| 14 | // |
| 15 | // The following BNF is derived from this standard. |
| 16 | // |
| 17 | // pattern := subpattern (';' subpattern)? |
| 18 | // subpattern := affix? number exponent? affix? |
| 19 | // number := decimal | sigDigits |
| 20 | // decimal := '#'* '0'* ('.' fraction)? | '#' | '0' |
| 21 | // fraction := '0'* '#'* |
| 22 | // sigDigits := '#'* '@' '@'* '#'* |
| 23 | // exponent := 'E' '+'? '0'* '0' |
| 24 | // padSpec := '*' \L |
| 25 | // |
| 26 | // Notes: |
| 27 | // - An affix pattern may contain any runes, but runes with special meaning |
| 28 | // should be escaped. |
| 29 | // - Sequences of digits, '#', and '@' in decimal and sigDigits may have |
| 30 | // interstitial commas. |
| 31 | |
| 32 | // TODO: replace special characters in affixes (-, +, ¤) with control codes. |
| 33 | |
| 34 | // Pattern holds information for formatting numbers. It is designed to hold |
| 35 | // information from CLDR number patterns. |
| 36 | // |
| 37 | // This pattern is precompiled for all patterns for all languages. Even though |
| 38 | // the number of patterns is not very large, we want to keep this small. |
| 39 | // |
| 40 | // This type is only intended for internal use. |
| 41 | type Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern# struct { |
| 42 | RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#RoundingContext. |
| 43 | |
| 44 | Affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Affix. string // includes prefix and suffix. First byte is prefix length. |
| 45 | Offsetscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Offset. uint16 // Offset into Affix for prefix and suffix |
| 46 | NegOffsetscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#NegOffset. uint16 // Offset into Affix for negative prefix and suffix or 0. |
| 47 | PadRunescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#PadRune. rune |
| 48 | FormatWidthscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#FormatWidth. uint16 |
| 49 | |
| 50 | GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize. [2]uint8 |
| 51 | Flagsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Flags. PatternFlagscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PatternFlag# |
| 52 | } |
| 53 | |
| 54 | // A RoundingContext indicates how a number should be converted to digits. |
| 55 | // It contains all information needed to determine the "visible digits" as |
| 56 | // required by the pluralization rules. |
| 57 | type RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext# struct { |
| 58 | // TODO: unify these two fields so that there is a more unambiguous meaning |
| 59 | // of how precision is handled. |
| 60 | MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. int16 // -1 is unlimited |
| 61 | MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. int16 // -1 is unlimited |
| 62 | |
| 63 | Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment. uint32 |
| 64 | IncrementScalescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#IncrementScale. uint8 // May differ from printed scale. |
| 65 | |
| 66 | Modescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Mode. RoundingModescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingMode# |
| 67 | |
| 68 | DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift. uint8 // Number of decimals to shift. Used for % and ‰. |
| 69 | |
| 70 | // Number of digits. |
| 71 | MinIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinIntegerDigits. uint8 |
| 72 | |
| 73 | MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. uint8 |
| 74 | MinFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinFractionDigits. uint8 |
| 75 | MinSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinSignificantDigits. uint8 |
| 76 | |
| 77 | MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits. uint8 |
| 78 | } |
| 79 | |
| 80 | // RoundSignificantDigits returns the number of significant digits an |
| 81 | // implementation of Convert may round to or n < 0 if there is no maximum or |
| 82 | // a maximum is not recommended. |
| 83 | func (r *RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#) RoundSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#RoundSignificantDigits().() (n int) { |
| 84 | if r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. == 0 && r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. > 0 { |
| 85 | return int(r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits.) |
| 86 | } else if r.isScientificscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#isScientific().() && r.MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. == 1 { |
| 87 | if r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. == 0 || |
| 88 | int(r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits.+1) == int(r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits.) { |
| 89 | // Note: don't add DigitShift: it is only used for decimals. |
| 90 | return int(r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits.) + 1 |
| 91 | } |
| 92 | } |
| 93 | return -1 |
| 94 | } |
| 95 | |
| 96 | // RoundFractionDigits returns the number of fraction digits an implementation |
| 97 | // of Convert may round to or n < 0 if there is no maximum or a maximum is not |
| 98 | // recommended. |
| 99 | func (r *RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#) RoundFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#RoundFractionDigits().() (n int) { |
| 100 | if r.MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits. == 0 && |
| 101 | r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. == 0 && |
| 102 | r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. >= 0 { |
| 103 | return int(r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits.) + int(r.DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift.) |
| 104 | } |
| 105 | return -1 |
| 106 | } |
| 107 | |
| 108 | // SetScale fixes the RoundingContext to a fixed number of fraction digits. |
| 109 | func (r *RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#) SetScalescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#SetScale().(scale int) { |
| 110 | r.MinFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinFractionDigits. = uint8(scale) |
| 111 | r.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. = int16(scale) |
| 112 | } |
| 113 | |
| 114 | func (r *RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#) SetPrecisionscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#SetPrecision().(prec int) { |
| 115 | r.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. = int16(prec) |
| 116 | } |
| 117 | |
| 118 | func (r *RoundingContextscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#) isScientificscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#isScientific().() bool { |
| 119 | return r.MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits. > 0 |
| 120 | } |
| 121 | |
| 122 | func (f *Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#) needsSepscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#needsSep().(pos int) bool { |
| 123 | p := pos - 1 |
| 124 | size := int(f.GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize.[0]) |
| 125 | if size == 0 || p == 0 { |
| 126 | return false |
| 127 | } |
| 128 | if p == size { |
| 129 | return true |
| 130 | } |
| 131 | if p -= size; p < 0 { |
| 132 | return false |
| 133 | } |
| 134 | // TODO: make second groupingsize the same as first if 0 so that we can |
| 135 | // avoid this check. |
| 136 | if x := int(f.GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize.[1]); x != 0 { |
| 137 | size = x |
| 138 | } |
| 139 | return p%size == 0 |
| 140 | } |
| 141 | |
| 142 | // A PatternFlag is a bit mask for the flag field of a Pattern. |
| 143 | type PatternFlagscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PatternFlag# uint8 |
| 144 | |
| 145 | const ( |
| 146 | AlwaysSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/AlwaysSign. PatternFlagscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PatternFlag# = 1 << iota |
| 147 | ElideSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/ElideSign. // Use space instead of plus sign. AlwaysSign must be true. |
| 148 | AlwaysExpSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/AlwaysExpSign. |
| 149 | AlwaysDecimalSeparatorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/AlwaysDecimalSeparator. |
| 150 | ParenthesisForNegativescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/ParenthesisForNegative. // Common pattern. Saves space. |
| 151 | |
| 152 | PadAfterNumberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterNumber. |
| 153 | PadAfterAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterAffix. |
| 154 | |
| 155 | PadBeforePrefixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadBeforePrefix. = 0 // Default |
| 156 | PadAfterPrefixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterPrefix. = PadAfterAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterAffix. |
| 157 | PadBeforeSuffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadBeforeSuffix. = PadAfterNumberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterNumber. |
| 158 | PadAfterSuffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterSuffix. = PadAfterNumberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterNumber. | PadAfterAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterAffix. |
| 159 | PadMaskscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadMask. = PadAfterNumberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterNumber. | PadAfterAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterAffix. |
| 160 | ) |
| 161 | |
| 162 | type parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser# struct { |
| 163 | *Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#Pattern. |
| 164 | |
| 165 | leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps. int |
| 166 | |
| 167 | posscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#pos. int |
| 168 | errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. error |
| 169 | doNotTerminatescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#doNotTerminate. bool |
| 170 | groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount. uint |
| 171 | hasGroupscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#hasGroup. bool |
| 172 | bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. []byte |
| 173 | } |
| 174 | |
| 175 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(err error) { |
| 176 | if p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. == nil { |
| 177 | p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. = err |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() { |
| 182 | if p.hasGroupscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#hasGroup. && |
| 183 | 0 < p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount. && p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount. < 255 { |
| 184 | p.GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize.[1] = p.GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize.[0] |
| 185 | p.GroupingSizescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#GroupingSize.[0] = uint8(p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.) |
| 186 | } |
| 187 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount. = 0 |
| 188 | p.hasGroupscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#hasGroup. = true |
| 189 | } |
| 190 | |
| 191 | var ( |
| 192 | // TODO: more sensible and localizeable error messages. |
| 193 | errMultiplePadSpecifiersscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errMultiplePadSpecifiers. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: pattern has multiple pad specifiers") |
| 194 | errInvalidPadSpecifierscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errInvalidPadSpecifier. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: invalid pad specifier") |
| 195 | errInvalidQuotescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errInvalidQuote. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: invalid quote") |
| 196 | errAffixTooLargescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errAffixTooLarge. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: prefix or suffix exceeds maximum UTF-8 length of 256 bytes") |
| 197 | errDuplicatePercentSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errDuplicatePercentSign. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: duplicate percent sign") |
| 198 | errDuplicatePermilleSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errDuplicatePermilleSign. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: duplicate permille sign") |
| 199 | errUnexpectedEndscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errUnexpectedEnd. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: unexpected end of pattern") |
| 200 | ) |
| 201 | |
| 202 | // ParsePattern extracts formatting information from a CLDR number pattern. |
| 203 | // |
| 204 | // See https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns. |
| 205 | func ParsePatternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/ParsePattern().(s string) (f *Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#, err error) { |
| 206 | p := parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#{Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#Pattern.: &Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#{}} |
| 207 | |
| 208 | s = p.parseSubPatternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseSubPattern().(s) |
| 209 | |
| 210 | if s != "" { |
| 211 | // Parse negative sub pattern. |
| 212 | if s[0] != ';' { |
| 213 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: error parsing first sub pattern")) |
| 214 | return nil, p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. |
| 215 | } |
| 216 | neg := parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#{Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#Pattern.: &Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#{}} // just for extracting the affixes. |
| 217 | s = neg.parseSubPatternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseSubPattern().(s[len(";"):]) |
| 218 | p.NegOffsetscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#NegOffset. = uint16(len(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf.)) |
| 219 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., neg.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf....) |
| 220 | } |
| 221 | if s != "" { |
| 222 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: spurious characters at end of pattern")) |
| 223 | } |
| 224 | if p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. != nil { |
| 225 | return nil, p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. |
| 226 | } |
| 227 | if affix := string(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf.); affix == "\x00\x00" || affix == "\x00\x00\x00\x00" { |
| 228 | // No prefix or suffixes. |
| 229 | p.NegOffsetscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#NegOffset. = 0 |
| 230 | } else { |
| 231 | p.Affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Affix. = affix |
| 232 | } |
| 233 | if p.Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment. == 0 { |
| 234 | p.IncrementScalescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#IncrementScale. = 0 |
| 235 | } |
| 236 | return p.Patternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#Pattern., nil |
| 237 | } |
| 238 | |
| 239 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) parseSubPatternscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseSubPattern().(s string) string { |
| 240 | s = p.parsePadscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parsePad().(s, PadBeforePrefixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadBeforePrefix.) |
| 241 | s = p.parseAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseAffix().(s) |
| 242 | s = p.parsePadscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parsePad().(s, PadAfterPrefixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterPrefix.) |
| 243 | |
| 244 | s = p.parsescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parse().(p.numberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#number()., s) |
| 245 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 246 | |
| 247 | s = p.parsePadscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parsePad().(s, PadBeforeSuffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadBeforeSuffix.) |
| 248 | s = p.parseAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseAffix().(s) |
| 249 | s = p.parsePadscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parsePad().(s, PadAfterSuffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PadAfterSuffix.) |
| 250 | return s |
| 251 | } |
| 252 | |
| 253 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) parsePadscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parsePad().(s string, f PatternFlagscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/PatternFlag#) (tail string) { |
| 254 | if len(s) >= 2 && s[0] == '*' { |
| 255 | r, sz := utf8scip-go gomod github.com/golang/go/src go1.25.0 `unicode/utf8`/.DecodeRuneInStringscip-go gomod github.com/golang/go/src go1.25.0 `unicode/utf8`/DecodeRuneInString().(s[1:]) |
| 256 | if p.PadRunescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#PadRune. != 0 { |
| 257 | p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. = errMultiplePadSpecifiersscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errMultiplePadSpecifiers. |
| 258 | } else { |
| 259 | p.Flagsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Flags. |= f |
| 260 | p.PadRunescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#PadRune. = r |
| 261 | } |
| 262 | return s[1+sz:] |
| 263 | } |
| 264 | return s |
| 265 | } |
| 266 | |
| 267 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) parseAffixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parseAffix().(s string) string { |
| 268 | x := len(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf.) |
| 269 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., 0) // placeholder for affix length |
| 270 | |
| 271 | s = p.parsescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parse().(p.affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#affix()., s) |
| 272 | |
| 273 | n := len(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf.) - x - 1 |
| 274 | if n > 0xFF { |
| 275 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errAffixTooLargescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errAffixTooLarge.) |
| 276 | } |
| 277 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf.[x] = uint8(n) |
| 278 | return s |
| 279 | } |
| 280 | |
| 281 | // state implements a state transition. It returns the new state. A state |
| 282 | // function may set an error on the parser or may simply return on an incorrect |
| 283 | // token and let the next phase fail. |
| 284 | type statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# func(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# |
| 285 | |
| 286 | // parse repeatedly applies a state function on the given string until a |
| 287 | // termination condition is reached. |
| 288 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) parsescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#parse().(fn statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state#, s string) (tail string) { |
| 289 | for i, r := range s { |
| 290 | p.doNotTerminatescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#doNotTerminate. = false |
| 291 | if fn = fn(r); fn == nil || p.errscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#err. != nil { |
| 292 | return s[i:] |
| 293 | } |
| 294 | p.FormatWidthscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#FormatWidth.++ |
| 295 | } |
| 296 | if p.doNotTerminatescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#doNotTerminate. { |
| 297 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errUnexpectedEndscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errUnexpectedEnd.) |
| 298 | } |
| 299 | return "" |
| 300 | } |
| 301 | |
| 302 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#affix().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 303 | switch r { |
| 304 | case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
| 305 | '#', '@', '.', '*', ',', ';': |
| 306 | return nil |
| 307 | case '\'': |
| 308 | p.FormatWidthscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#FormatWidth.-- |
| 309 | return p.escapeFirstscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#escapeFirst(). |
| 310 | case '%': |
| 311 | if p.DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift. != 0 { |
| 312 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errDuplicatePercentSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errDuplicatePercentSign.) |
| 313 | } |
| 314 | p.DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift. = 2 |
| 315 | case '\u2030': // ‰ Per mille |
| 316 | if p.DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift. != 0 { |
| 317 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errDuplicatePermilleSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/errDuplicatePermilleSign.) |
| 318 | } |
| 319 | p.DigitShiftscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#DigitShift. = 3 |
| 320 | // TODO: handle currency somehow: ¤, ¤¤, ¤¤¤, ¤¤¤¤ |
| 321 | } |
| 322 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., string(r)...) |
| 323 | return p.affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#affix(). |
| 324 | } |
| 325 | |
| 326 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) escapeFirstscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#escapeFirst().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 327 | switch r { |
| 328 | case '\'': |
| 329 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., "\\'"...) |
| 330 | return p.affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#affix(). |
| 331 | default: |
| 332 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., '\'') |
| 333 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., string(r)...) |
| 334 | } |
| 335 | return p.escapescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#escape(). |
| 336 | } |
| 337 | |
| 338 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) escapescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#escape().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 339 | switch r { |
| 340 | case '\'': |
| 341 | p.FormatWidthscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#FormatWidth.-- |
| 342 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., '\'') |
| 343 | return p.affixscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#affix(). |
| 344 | default: |
| 345 | p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf. = append(p.bufscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#buf., string(r)...) |
| 346 | } |
| 347 | return p.escapescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#escape(). |
| 348 | } |
| 349 | |
| 350 | // number parses a number. The BNF says the integer part should always have |
| 351 | // a '0', but that does not appear to be the case according to the rest of the |
| 352 | // documentation. We will allow having only '#' numbers. |
| 353 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) numberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#number().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 354 | switch r { |
| 355 | case '#': |
| 356 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.++ |
| 357 | p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps.++ |
| 358 | case '@': |
| 359 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.++ |
| 360 | p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps. = 0 |
| 361 | p.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. = -1 |
| 362 | return p.sigDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigits().(r) |
| 363 | case ',': |
| 364 | if p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps. == 0 { // no leading commas |
| 365 | return nil |
| 366 | } |
| 367 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 368 | case 'E': |
| 369 | p.MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. = uint8(p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps.) |
| 370 | return p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 371 | case '.': // allow ".##" etc. |
| 372 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 373 | return p.fractionscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#fraction(). |
| 374 | case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': |
| 375 | return p.integerscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#integer().(r) |
| 376 | default: |
| 377 | return nil |
| 378 | } |
| 379 | return p.numberscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#number(). |
| 380 | } |
| 381 | |
| 382 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) integerscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#integer().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 383 | if !('0' <= r && r <= '9') { |
| 384 | var next statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# |
| 385 | switch r { |
| 386 | case 'E': |
| 387 | if p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps. > 0 { |
| 388 | p.MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. = uint8(p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps.) + p.MinIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinIntegerDigits. |
| 389 | } |
| 390 | next = p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 391 | case '.': |
| 392 | next = p.fractionscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#fraction(). |
| 393 | case ',': |
| 394 | next = p.integerscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#integer(). |
| 395 | } |
| 396 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 397 | return next |
| 398 | } |
| 399 | p.Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment. = p.Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment.*10 + uint32(r-'0') |
| 400 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.++ |
| 401 | p.MinIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinIntegerDigits.++ |
| 402 | return p.integerscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#integer(). |
| 403 | } |
| 404 | |
| 405 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) sigDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigits().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 406 | switch r { |
| 407 | case '@': |
| 408 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.++ |
| 409 | p.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits.++ |
| 410 | p.MinSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinSignificantDigits.++ |
| 411 | case '#': |
| 412 | return p.sigDigitsFinalscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigitsFinal().(r) |
| 413 | case 'E': |
| 414 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 415 | return p.normalizeSigDigitsWithExponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#normalizeSigDigitsWithExponent().() |
| 416 | default: |
| 417 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 418 | return nil |
| 419 | } |
| 420 | return p.sigDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigits(). |
| 421 | } |
| 422 | |
| 423 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) sigDigitsFinalscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigitsFinal().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 424 | switch r { |
| 425 | case '#': |
| 426 | p.groupingCountscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#groupingCount.++ |
| 427 | p.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits.++ |
| 428 | case 'E': |
| 429 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 430 | return p.normalizeSigDigitsWithExponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#normalizeSigDigitsWithExponent().() |
| 431 | default: |
| 432 | p.updateGroupingscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#updateGrouping().() |
| 433 | return nil |
| 434 | } |
| 435 | return p.sigDigitsFinalscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#sigDigitsFinal(). |
| 436 | } |
| 437 | |
| 438 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) normalizeSigDigitsWithExponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#normalizeSigDigitsWithExponent().() statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 439 | p.MinIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinIntegerDigits., p.MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. = 1, 1 |
| 440 | p.MinFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinFractionDigits. = p.MinSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinSignificantDigits. - 1 |
| 441 | p.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits. = p.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. - 1 |
| 442 | p.MinSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinSignificantDigits., p.MaxSignificantDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxSignificantDigits. = 0, 0 |
| 443 | return p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 444 | } |
| 445 | |
| 446 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) fractionscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#fraction().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 447 | switch r { |
| 448 | case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': |
| 449 | p.Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment. = p.Incrementscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#Increment.*10 + uint32(r-'0') |
| 450 | p.IncrementScalescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#IncrementScale.++ |
| 451 | p.MinFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinFractionDigits.++ |
| 452 | p.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits.++ |
| 453 | case '#': |
| 454 | p.MaxFractionDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxFractionDigits.++ |
| 455 | case 'E': |
| 456 | if p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps. > 0 { |
| 457 | p.MaxIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MaxIntegerDigits. = uint8(p.leadingSharpsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#leadingSharps.) + p.MinIntegerDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinIntegerDigits. |
| 458 | } |
| 459 | return p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 460 | default: |
| 461 | return nil |
| 462 | } |
| 463 | return p.fractionscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#fraction(). |
| 464 | } |
| 465 | |
| 466 | func (p *parserscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#) exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent().(r rune) statescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/state# { |
| 467 | switch r { |
| 468 | case '+': |
| 469 | // Set mode and check it wasn't already set. |
| 470 | if p.Flagsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Flags.&AlwaysExpSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/AlwaysExpSign. != 0 || p.MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits. > 0 { |
| 471 | break |
| 472 | } |
| 473 | p.Flagsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/Pattern#Flags. |= AlwaysExpSignscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/AlwaysExpSign. |
| 474 | p.doNotTerminatescip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#doNotTerminate. = true |
| 475 | return p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 476 | case '0': |
| 477 | p.MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits.++ |
| 478 | return p.exponentscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#exponent(). |
| 479 | } |
| 480 | // termination condition |
| 481 | if p.MinExponentDigitsscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/RoundingContext#MinExponentDigits. == 0 { |
| 482 | p.setErrorscip-go gomod golang.org/x/text . `golang.org/x/text/internal/number`/parser#setError().(errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("format: need at least one digit")) |
| 483 | } |
| 484 | return nil |
| 485 | } |