2017-09-17 16:33:36 -05:00
|
|
|
//
|
2020-08-23 14:15:53 +00:00
|
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
|
|
//
|
|
|
|
// This is a commercial product and requires a license to operate.
|
|
|
|
// A trial license can be obtained at https://unidoc.io
|
|
|
|
//
|
|
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
2017-09-17 16:33:36 -05:00
|
|
|
|
2020-08-23 14:15:53 +00:00
|
|
|
// Package format provides support for parsing and evaluating
|
|
|
|
// spreadsheetml/Excel number formats.
|
|
|
|
//
|
|
|
|
// Internally spreadsheets store numbers and dates values as a text
|
|
|
|
// representation of a floating point number (e.g. 1.2345). This number is then
|
|
|
|
// displayed in Excel or another spreadsheet viewer differently depending on the
|
|
|
|
// number fornat of the cell style applied to the cell.
|
|
|
|
//
|
|
|
|
// As an example, the same value of 1.2345 can be displayed as:
|
|
|
|
// - "1" with format "0"
|
|
|
|
// - "1.2" with format "0.0"
|
|
|
|
// - "1.23" with format "0.00"
|
|
|
|
// - "1.235" with format "0.000"
|
|
|
|
// - "123%" with format "0%"
|
|
|
|
// - "1 23/100" with fornat "0 0/100"
|
|
|
|
// - "1.23E+00" with format "0.00E+00"
|
|
|
|
// - "29:37:41s" with format `[h]:mm:ss"s"`
|
2020-11-09 01:00:18 +00:00
|
|
|
package format ;import (_fa "bytes";_c "fmt";_cd "github.com/unidoc/unioffice";_d "io";_g "math";_db "strconv";_f "strings";_e "time";);const _cc ="\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u004c\u0069\u0074\u0065\u0072a\u006c\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0044\u0069\u0067\u0069\u0074\u0046\u006d\u0074\u0054y\u0070\u0065\u0044i\u0067\u0069\u0074\u004f\u0070\u0074\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0043o\u006d\u006d\u0061\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0044\u0065\u0063\u0069\u006da\u006c\u0046\u006d\u0074\u0054\u0079\u0070\u0065Pe\u0072\u0063e\u006e\u0074\u0046\u006d\u0074\u0054\u0079\u0070e\u0044\u006f\u006c\u006c\u0061\u0072\u0046\u006d\u0074Ty\u0070\u0065\u0044i\u0067\u0069\u0074\u004f\u0070\u0074\u0054\u0068\u006f\u0075\u0073\u0061n\u0064\u0073\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0055n\u0064\u0065\u0072\u0073c\u006f\u0072\u0065\u0046\u006d\u0074T\u0079\u0070\u0065\u0044\u0061\u0074\u0065\u0046\u006d\u0074\u0054y\u0070e\u0054\u0069\u006d\u0065\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0046\u0072\u0061\u0063t\u0069\u006f\u006e\u0046\u006dt\u0054\u0079\u0070\u0065\u0054e\u0078\u0074";const _aggg int =0;
|
2017-09-17 16:33:36 -05:00
|
|
|
|
2020-11-09 01:00:18 +00:00
|
|
|
// AddToken adds a format token to the format.
|
|
|
|
func (_aa *Format )AddToken (t FmtType ,l []byte ){if _aa ._dgc {_aa ._dgc =false ;return ;};switch t {case FmtTypeDecimal :_aa ._cf =true ;case FmtTypeUnderscore :_aa ._dgc =true ;case FmtTypeText :_aa .Whole =append (_aa .Whole ,Token {Type :t });case FmtTypeDate ,FmtTypeTime :_aa .Whole =append (_aa .Whole ,Token {Type :t ,DateTime :string (l )});case FmtTypePercent :_aa ._cdg =true ;t =FmtTypeLiteral ;l =[]byte {'%'};fallthrough;case FmtTypeDigitOpt :fallthrough;case FmtTypeLiteral ,FmtTypeDigit ,FmtTypeDollar ,FmtTypeComma :if l ==nil {l =[]byte {0};};for _ ,_eb :=range l {if _aa .IsExponential {_aa .Exponent =append (_aa .Exponent ,Token {Type :t ,Literal :_eb });}else if !_aa ._cf {_aa .Whole =append (_aa .Whole ,Token {Type :t ,Literal :_eb });}else {_aa .Fractional =append (_aa .Fractional ,Token {Type :t ,Literal :_eb });};};case FmtTypeDigitOptThousands :_aa ._ed =true ;case FmtTypeFraction :_ec :=_f .Split (string (l ),"\u002f");if len (_ec )==2{_aa ._b =true ;_aa ._ef ,_ =_db .ParseInt (_ec [1],10,64);for _ ,_fg :=range _ec [1]{if _fg =='?'||_fg =='0'{_aa ._ca ++;};};};default:_cd .Log ("\u0075\u006e\u0073u\u0070\u0070\u006f\u0072t\u0065\u0064\u0020\u0070\u0068\u0020\u0074y\u0070\u0065\u0020\u0069\u006e\u0020\u0070\u0061\u0072\u0073\u0065\u0020\u0025\u0076",t );};};func _bfb (_ceb ,_aaa float64 ,_dbdg Format )[]byte {if len (_dbdg .Whole )==0{return nil ;};_ae :=_e .Date (1899,12,30,0,0,0,0,_e .UTC );_cff :=_ae .Add (_e .Duration (_aaa *float64 (24*_e .Hour )));_cff =_bffd (_cff );_efa :=_db .AppendFloat (nil ,_ceb ,'f',-1,64);_ebc :=make ([]byte ,0,len (_efa ));_ggeg :=0;_af :=1;_eff :for _bad :=len (_dbdg .Whole )-1;_bad >=0;_bad --{_edf :=len (_efa )-1-_ggeg ;_aae :=_dbdg .Whole [_bad ];switch _aae .Type {case FmtTypeDigit :if _edf >=0{_ebc =append (_ebc ,_efa [_edf ]);_ggeg ++;_af =_bad ;}else {_ebc =append (_ebc ,'0');};case FmtTypeDigitOpt :if _edf >=0{_ebc =append (_ebc ,_efa [_edf ]);_ggeg ++;_af =_bad ;}else {for _dfd :=_bad ;_dfd >=0;_dfd --{_agg :=_dbdg .Whole [_dfd ];if _agg .Type ==FmtTypeLiteral {_ebc =append (_ebc ,_agg .Literal );};};break _eff ;};case FmtTypeDollar :for _gca :=_ggeg ;_gca < len (_efa );_gca ++{_ebc =append (_ebc ,_efa [len (_efa )-1-_gca ]);_ggeg ++;};_ebc =append (_ebc ,'$');case FmtTypeComma :if !_dbdg ._ed {_ebc =append (_ebc ,',');};case FmtTypeLiteral :_ebc =append (_ebc ,_aae .Literal );case FmtTypeDate :_ebc =append (_ebc ,_eeb (_edg (_cff ,_aae .DateTime ))...);case FmtTypeTime :_ebc =append (_ebc ,_eeb (_de (_cff ,_aaa ,_aae .DateTime ))...);default:_cd .Log ("\u0075\u006e\u0073\u0075p\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0074\u0079\u0070e\u0020i\u006e\u0020\u0077\u0068\u006f\u006c\u0065 \u0025\u0076",_aae );};};_gab :=_eeb (_ebc );if _ggeg < len (_efa )&&(_ggeg !=0||_dbdg ._cf ){_ffa :=len (_efa )-_ggeg ;_fgd :=make ([]byte ,len (_gab )+_ffa );copy (_fgd ,_gab [0:_af ]);copy (_fgd [_af :],_efa [0:]);copy (_fgd [_af +_ffa :],_gab [_af :]);_gab =_fgd ;};if _dbdg ._ed {_cce :=_fa .Buffer {};_bg :=0;for _agd :=len (_gab )-1;_agd >=0;_agd --{if !(_gab [_agd ]>='0'&&_gab [_agd ]<='9'){_bg ++;}else {break ;};};for _bd :=0;_bd < len (_gab );_bd ++{_bc :=(len (_gab )-_bd -_bg );if _bc %3==0&&_bc !=0&&_bd !=0{_cce .WriteByte (',');};_cce .WriteByte (_gab [_bd ]);};_gab =_cce .Bytes ();};return _gab ;};
|
2017-09-17 19:23:49 -05:00
|
|
|
|
2020-11-09 01:00:18 +00:00
|
|
|
// FmtType is the type of a format token.
|
|
|
|
//go:generate stringer -type=FmtType
|
|
|
|
type FmtType byte ;const _ce =1e11;
|
2020-10-12 13:59:12 +00:00
|
|
|
|
2017-09-17 19:23:49 -05:00
|
|
|
// Number is used to format a number with a format string. If the format
|
2017-09-17 16:33:36 -05:00
|
|
|
// string is empty, then General number formatting is used which attempts to mimic
|
|
|
|
// Excel's general formatting.
|
2020-11-09 01:00:18 +00:00
|
|
|
func Number (v float64 ,f string )string {if f ==""||f =="\u0047e\u006e\u0065\u0072\u0061\u006c"||f =="\u0040"{return NumberGeneric (v );};_faf :=Parse (f );if len (_faf )==1{return _cdgg (v ,_faf [0],false );}else if len (_faf )> 1&&v < 0{return _cdgg (v ,_faf [1],true );}else if len (_faf )> 2&&v ==0{return _cdgg (v ,_faf [2],false );};return _cdgg (v ,_faf [0],false );};const _ab =1e-10;
|
2017-09-17 19:23:49 -05:00
|
|
|
|
2020-11-09 01:00:18 +00:00
|
|
|
// String returns the string formatted according to the type. In format strings
|
|
|
|
// this is the fourth item, where '@' is used as a placeholder for text.
|
|
|
|
func String (v string ,f string )string {_fb :=Parse (f );var _ee Format ;if len (_fb )==1{_ee =_fb [0];}else if len (_fb )==4{_ee =_fb [3];};_eba :=false ;for _ ,_aaf :=range _ee .Whole {if _aaf .Type ==FmtTypeText {_eba =true ;};};if !_eba {return v ;};_ba :=_fa .Buffer {};for _ ,_cdc :=range _ee .Whole {switch _cdc .Type {case FmtTypeLiteral :_ba .WriteByte (_cdc .Literal );case FmtTypeText :_ba .WriteString (v );};};return _ba .String ();};var _ga =[...]uint8 {0,14,26,41,53,67,81,94,118,135,146,157,172,183};func _cb (_baf float64 )string {_edeg :=_db .FormatFloat (_baf ,'E',-1,64);_ffd :=_db .FormatFloat (_baf ,'E',5,64);if len (_edeg )< len (_ffd ){return _db .FormatFloat (_baf ,'E',2,64);};return _ffd ;};func _eeg (_dfe ,_bgf float64 ,_cde Format )[]byte {if len (_cde .Fractional )==0{return nil ;};_ggd :=_db .AppendFloat (nil ,_dfe ,'f',-1,64);if len (_ggd )> 2{_ggd =_ggd [2:];}else {_ggd =nil ;};_bge :=make ([]byte ,0,len (_ggd ));_bge =append (_bge ,'.');_ece :=0;_cdcd :for _ge :=0;_ge < len (_cde .Fractional );_ge ++{_eed :=_ge ;_cfb :=_cde .Fractional [_ge ];switch _cfb .Type {case FmtTypeDigit :if _eed < len (_ggd ){_bge =append (_bge ,_ggd [_eed ]);_ece ++;}else {_bge =append (_bge ,'0');};case FmtTypeDigitOpt :if _eed >=0{_bge =append (_bge ,_ggd [_eed ]);_ece ++;}else {break _cdcd ;};case FmtTypeLiteral :_bge =append (_bge ,_cfb .Literal );default:_cd .Log ("\u0075\u006e\u0073\u0075\u0070\u0070o\u0072\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u006e\u0020f\u0072\u0061\u0063\u0074\u0069\u006f\u006ea\u006c\u0020\u0025\u0076",_cfb );};};return _bge ;};func _eeb (_ad []byte )[]byte {for _be :=0;_be < len (_ad )/2;_be ++{_add :=len (_ad )-1-_be ;_ad [_be ],_ad [_add ]=_ad [_add ],_ad [_be ];};return _ad ;};const _abb int =-1;const _gdd int =34;func _dfge (_gdc []byte )[]byte {_ebe :=len (_gdc );_cec :=false ;_aec :=false ;for _ffe :=len (_gdc )-1;_ffe >=0;_ffe --{if _gdc [_ffe ]=='0'&&!_aec &&!_cec {_ebe =_ffe ;}else if _gdc [_ffe ]=='.'{_cec =true ;}else {_aec =true ;};};if _cec &&_aec {if _gdc [_ebe -1]=='.'{_ebe --;};return _gdc [0:_ebe ];};return _gdc ;};const _ecee int =34;type Lexer struct{_cbc Format ;_dca []Format ;};func IsNumber (data string )(_bbcb bool ){_ggegd ,_cbe ,_cdb :=0,0,len (data );_eac :=len (data );_cffc ,_gb ,_aff :=0,0,0;_ =_gb ;_ =_aff ;_ =_cffc ;{_ggegd =_gff ;_cffc =0;_gb =0;_aff =0;};{if _cbe ==_cdb {goto _cffg ;};switch _ggegd {case 0:goto _dag ;case 1:goto _ccb ;case 2:goto _bbca ;case 3:goto _deb ;case 4:goto _degd ;case 5:goto _gcd ;case 6:goto _ged ;case 7:goto _dac ;};goto _gefe ;_fgg :_gb =_cbe ;_cbe --;{_bbcb =false ;};goto _cbeg ;_fac :_gb =_cbe ;_cbe --;{_bbcb =_gb ==len (data );};goto _cbeg ;_fbdb :_gb =_cbe ;_cbe --;{_bbcb =_gb ==len (data );};goto _cbeg ;_fae :switch _aff {case 2:{_cbe =(_gb )-1;_bbcb =_gb ==len (data );};case 3:{_cbe =(_gb )-1;_bbcb =false ;};};goto _cbeg ;_cbeg :_cffc =0;if _cbe ++;_cbe ==_cdb {goto _cecc ;};_dag :_cffc =_cbe ;switch data [_cbe ]{case 43:goto _cfeg ;case 45:goto _cfeg ;};if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _aee ;};goto _egc ;_egc :if _cbe ++;_cbe ==_cdb {goto _fag ;};_ccb :goto _egc ;_cfeg :if _cbe ++;_cbe ==_cdb {goto _bcc ;};_bbca :if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _aee ;};goto _egc ;_aee :if _cbe ++;_cbe ==_cdb {goto _eae ;};_deb :if data [_cbe ]==46{goto _efc ;};if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _aee ;};goto _egc ;_efc :if _cbe ++;_cbe ==_cdb {goto _afg ;};_degd :if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _fdb ;};goto _egc ;_fdb :if _cbe ++;_cbe ==_cdb {goto _bca ;};_gcd :if data [_cbe ]==69{goto _aafd ;};if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _fdb ;};goto _egc ;_aafd :if _cbe ++;_cbe ==_cdb {goto _cacb ;};_ged :switch data [_cbe ]{case 43:goto _fbbe ;case 45:goto _fbbe ;};goto _egc ;_fbbe :_gb =_cbe +1;_aff =3;goto _cac ;_gffe :_gb =_cbe +1;_aff =2;goto _cac ;_cac :if _cbe ++;_cbe ==_cdb {goto _edfa ;};_dac :if 48<=data [_cbe ]&&data [_cbe ]<=57{goto _gffe ;};goto _egc ;_gefe :_cecc :_ggegd =0;goto _cffg ;_fag :_ggegd =1;goto _cffg ;_bcc :_ggegd =2;goto _cffg ;_eae :_ggegd =3;goto _c
|
2020-10-12 13:59:12 +00:00
|
|
|
|
2020-11-09 01:00:18 +00:00
|
|
|
// Value formats a value as a number or string depending on if it appears to be
|
|
|
|
// a number or string.
|
|
|
|
func Value (v string ,f string )string {if IsNumber (v ){_gg ,_ :=_db .ParseFloat (v ,64);return Number (_gg ,f );};return String (v ,f );};
|
|
|
|
|
|
|
|
// Format is a parsed number format.
|
|
|
|
type Format struct{Whole []Token ;Fractional []Token ;Exponent []Token ;IsExponential bool ;_b bool ;_cdg bool ;_df bool ;_ed bool ;_dgc bool ;_cf bool ;_ef int64 ;_ca int ;};func _gf (_ede int64 ,_fbd Format )[]byte {if !_fbd .IsExponential ||len (_fbd .Exponent )==0{return nil ;};_fbb :=_db .AppendInt (nil ,_cdcb (_ede ),10);_adg :=make ([]byte ,0,len (_fbb )+2);_adg =append (_adg ,'E');if _ede >=0{_adg =append (_adg ,'+');}else {_adg =append (_adg ,'-');_ede *=-1;};_aeb :=0;_dgb :for _dfg :=len (_fbd .Exponent )-1;_dfg >=0;_dfg --{_gdeb :=len (_fbb )-1-_aeb ;_bbc :=_fbd .Exponent [_dfg ];switch _bbc .Type {case FmtTypeDigit :if _gdeb >=0{_adg =append (_adg ,_fbb [_gdeb ]);_aeb ++;}else {_adg =append (_adg ,'0');};case FmtTypeDigitOpt :if _gdeb >=0{_adg =append (_adg ,_fbb [_gdeb ]);_aeb ++;}else {for _gef :=_dfg ;_gef >=0;_gef --{_fdc :=_fbd .Exponent [_gef ];if _fdc .Type ==FmtTypeLiteral {_adg =append (_adg ,_fdc .Literal );};};break _dgb ;};case FmtTypeLiteral :_adg =append (_adg ,_bbc .Literal );default:_cd .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0074\u0079\u0070\u0065\u0020\u0069\u006e\u0020\u0065\u0078p\u0020\u0025\u0076",_bbc );};};if _aeb < len (_fbb ){_adg =append (_adg ,_fbb [len (_fbb )-_aeb -1:_aeb -1]...);};_eeb (_adg [2:]);return _adg ;};func _bffd (_fgf _e .Time )_e .Time {_fgf =_fgf .UTC ();return _e .Date (_fgf .Year (),_fgf .Month (),_fgf .Day (),_fgf .Hour (),_fgf .Minute (),_fgf .Second (),_fgf .Nanosecond (),_e .Local );};func (_dbg *Lexer )nextFmt (){_dbg ._dca =append (_dbg ._dca ,_dbg ._cbc );_dbg ._cbc =Format {}};
|
2017-09-17 16:33:36 -05:00
|
|
|
|
|
|
|
// NumberGeneric formats the number with the generic format which attemps to
|
|
|
|
// mimic Excel's general formatting.
|
2020-11-09 01:00:18 +00:00
|
|
|
func NumberGeneric (v float64 )string {if _g .Abs (v )>=_ce ||_g .Abs (v )<=_ab &&v !=0{return _cb (v );};_dcg :=make ([]byte ,0,15);_dcg =_db .AppendFloat (_dcg ,v ,'f',-1,64);if len (_dcg )> 11{_afb :=_dcg [11]-'0';if _afb >=5&&_afb <=9{_dcg [10]++;_dcg =_dcg [0:11];_dcg =_beb (_dcg );};_dcg =_dcg [0:11];}else if len (_dcg )==11{if _dcg [len (_dcg )-1]=='9'{_dcg [len (_dcg )-1]++;_dcg =_beb (_dcg );};};_dcg =_dfge (_dcg );return string (_dcg );};func _edg (_cfe _e .Time ,_bgg string )[]byte {_bef :=[]byte {};_afbe :=0;for _acg :=0;_acg < len (_bgg );_acg ++{var _eea string ;if _bgg [_acg ]=='/'{_eea =string (_bgg [_afbe :_acg ]);_afbe =_acg +1;}else if _acg ==len (_bgg )-1{_eea =string (_bgg [_afbe :_acg +1]);}else {continue ;};switch _eea {case "\u0079\u0079":_bef =_cfe .AppendFormat (_bef ,"\u0030\u0036");case "\u0079\u0079\u0079\u0079":_bef =_cfe .AppendFormat (_bef ,"\u0032\u0030\u0030\u0036");case "\u006d":_bef =_cfe .AppendFormat (_bef ,"\u0031");case "\u006d\u006d":_bef =_cfe .AppendFormat (_bef ,"\u0030\u0031");case "\u006d\u006d\u006d":_bef =_cfe .AppendFormat (_bef ,"\u004a\u0061\u006e");case "\u006d\u006d\u006d\u006d":_bef =_cfe .AppendFormat (_bef ,"\u004aa\u006e\u0075\u0061\u0072\u0079");case "\u006d\u006d\u006dm\u006d":switch _cfe .Month (){case _e .January ,_e .July ,_e .June :_bef =append (_bef ,'J');case _e .February :_bef =append (_bef ,'M');case _e .March ,_e .May :_bef =append (_bef ,'M');case _e .April ,_e .August :_bef =append (_bef ,'A');case _e .September :_bef =append (_bef ,'S');case _e .October :_bef =append (_bef ,'O');case _e .November :_bef =append (_bef ,'N');case _e .December :_bef =append (_bef ,'D');};case "\u0064":_bef =_cfe .AppendFormat (_bef ,"\u0032");case "\u0064\u0064":_bef =_cfe .AppendFormat (_bef ,"\u0030\u0032");case "\u0064\u0064\u0064":_bef =_cfe .AppendFormat (_bef ,"\u004d\u006f\u006e");case "\u0064\u0064\u0064\u0064":_bef =_cfe .AppendFormat (_bef ,"\u004d\u006f\u006e\u0064\u0061\u0079");default:_cd .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061t\u0020\u0025\u0073",_eea );};if _bgg [_acg ]=='/'{_bef =append (_bef ,'/');};};return _bef ;};
|
2020-08-31 22:58:25 +00:00
|
|
|
|
2020-11-09 01:00:18 +00:00
|
|
|
// Token is a format token in the Excel format string.
|
|
|
|
type Token struct{Type FmtType ;Literal byte ;DateTime string ;};const _cdcbc int =-1;const _ega int =0;func _beb (_fda []byte )[]byte {for _bafc :=len (_fda )-1;_bafc > 0;_bafc --{if _fda [_bafc ]=='9'+1{_fda [_bafc ]='0';if _fda [_bafc -1]=='.'{_bafc --;};_fda [_bafc -1]++;};};if _fda [0]=='9'+1{_fda [0]='0';copy (_fda [1:],_fda [0:]);_fda [0]='1';};return _fda ;};func _cdgg (_ff float64 ,_ggc Format ,_ac bool )string {if _ggc ._df {return NumberGeneric (_ff );};_fd :=make ([]byte ,0,20);_da :=_g .Signbit (_ff );_bb :=_g .Abs (_ff );_gd :=int64 (0);_dcf :=int64 (0);if _ggc .IsExponential {for _bb >=10{_dcf ++;_bb /=10;};for _bb < 1{_dcf --;_bb *=10;};}else if _ggc ._cdg {_bb *=100;}else if _ggc ._b {if _ggc ._ef ==0{_fe :=_g .Pow (10,float64 (_ggc ._ca ));_eda ,_eef :=1.0,1.0;_ =_eda ;for _fec :=1.0;_fec < _fe ;_fec ++{_ ,_eg :=_g .Modf (_bb *float64 (_fec ));if _eg < _eef {_eef =_eg ;_eda =_fec ;if _eg ==0{break ;};};};_ggc ._ef =int64 (_eda );};_gd =int64 (_bb *float64 (_ggc ._ef )+0.5);if len (_ggc .Whole )> 0&&_gd > _ggc ._ef {_gd =int64 (_bb *float64 (_ggc ._ef ))%_ggc ._ef ;_bb -=float64 (_gd )/float64 (_ggc ._ef );}else {_bb -=float64 (_gd )/float64 (_ggc ._ef );if _g .Abs (_bb )< 1{_ggf :=true ;for _ ,_bbe :=range _ggc .Whole {if _bbe .Type ==FmtTypeDigitOpt {continue ;};if _bbe .Type ==FmtTypeLiteral &&_bbe .Literal ==' '{continue ;};_ggf =false ;};if _ggf {_ggc .Whole =nil ;};};};};_cg :=1;for _ ,_gc :=range _ggc .Fractional {if _gc .Type ==FmtTypeDigit ||_gc .Type ==FmtTypeDigitOpt {_cg ++;};};_bb +=5*_g .Pow10 (-_cg );_gcg ,_gde :=_g .Modf (_bb );_fd =append (_fd ,_bfb (_gcg ,_ff ,_ggc )...);_fd =append (_fd ,_eeg (_gde ,_ff ,_ggc )...);_fd =append (_fd ,_gf (_dcf ,_ggc )...);if _ggc ._b {_fd =_db .AppendInt (_fd ,_gd ,10);_fd =append (_fd ,'/');_fd =_db .AppendInt (_fd ,_ggc ._ef ,10);};if !_ac &&_da {return "\u002d"+string (_fd );};return string (_fd );};const (FmtTypeLiteral FmtType =iota ;FmtTypeDigit ;FmtTypeDigitOpt ;FmtTypeComma ;FmtTypeDecimal ;FmtTypePercent ;FmtTypeDollar ;FmtTypeDigitOptThousands ;FmtTypeUnderscore ;FmtTypeDate ;FmtTypeTime ;FmtTypeFraction ;FmtTypeText ;);func (_dbc *Lexer )Lex (r _d .Reader ){_gda ,_bab ,_dcb :=0,0,0;_fecf :=-1;_cfg ,_ggb ,_cbb :=0,0,0;_ =_ggb ;_ =_cbb ;_ebb :=1;_ =_ebb ;_cgc :=make ([]byte ,4096);_dcaa :=false ;for !_dcaa {_bag :=0;if _cfg > 0{_bag =_bab -_cfg ;};_bab =0;_gad ,_bfbb :=r .Read (_cgc [_bag :]);if _gad ==0||_bfbb !=nil {_dcaa =true ;};_dcb =_gad +_bag ;if _dcb < len (_cgc ){_fecf =_dcb ;};{_gda =_gdd ;_cfg =0;_ggb =0;_cbb =0;};{if _bab ==_dcb {goto _gdeg ;};switch _gda {case 34:goto _bgff ;case 35:goto _cfc ;case 0:goto _beec ;case 36:goto _bda ;case 37:goto _egg ;case 1:goto _aba ;case 2:goto _ceae ;case 38:goto _bfg ;case 3:goto _dee ;case 4:goto _dbgg ;case 39:goto _faeb ;case 5:goto _dec ;case 6:goto _bade ;case 7:goto _bae ;case 8:goto _gae ;case 40:goto _fee ;case 9:goto _bfa ;case 41:goto _fge ;case 10:goto _gbga ;case 42:goto _adca ;case 11:goto _eag ;case 43:goto _abba ;case 44:goto _egaf ;case 45:goto _bdeg ;case 12:goto _dfef ;case 46:goto _aaeb ;case 13:goto _eaea ;case 14:goto _bbf ;case 15:goto _ecc ;case 16:goto _acb ;case 47:goto _ceg ;case 17:goto _dga ;case 48:goto _gfg ;case 18:goto _gbb ;case 19:goto _bgb ;case 20:goto _cag ;case 49:goto _bbb ;case 50:goto _ffaa ;case 21:goto _aeeg ;case 22:goto _fab ;case 23:goto _gedf ;case 24:goto _fdbf ;case 25:goto _acbc ;case 51:goto _dacd ;case 26:goto _adcc ;case 52:goto _aga ;case 53:goto _ccee ;case 54:goto _afa ;case 55:goto _fefd ;case 56:goto _bdef ;case 57:goto _beeb ;case 27:goto _gcge ;case 28:goto _gac ;case 29:goto _ade ;case 30:goto _ebaga ;case 31:goto _aea ;case 58:goto _gdec ;case 32:goto _beba ;case 59:goto _caf ;case 33:goto _cdea ;case 60:goto _daf ;case 61:goto _adcd ;case 62:goto _acga ;};goto _aceb ;_gada :switch _cbb {case 2:{_bab =(_ggb )-1;_dbc ._cbc .AddToken (FmtTypeDigit ,nil );};case 3:{_bab =(_ggb )-1;_dbc ._cbc .AddToken (FmtTypeDigitOpt ,nil );};case 5:{_bab =(_ggb )-1;};case 8:{_bab =(_ggb )-1;_dbc ._cbc .AddToken (FmtTypePercent ,nil );};case 13:{_bab =
|