59 lines
38 KiB
Go
Raw Normal View History

//
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/
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"`
2021-07-30 17:03:26 +00:00
package format ;import (_fg "bytes";_d "fmt";_de "github.com/unidoc/unioffice";_b "io";_be "math";_a "strconv";_ba "strings";_c "time";);func _beae (_adgd int64 ,_dec Format )[]byte {if !_dec .IsExponential ||len (_dec .Exponent )==0{return nil ;};_eca :=_a .AppendInt (nil ,_abbd (_adgd ),10);_deg :=make ([]byte ,0,len (_eca )+2);_deg =append (_deg ,'E');if _adgd >=0{_deg =append (_deg ,'+');}else {_deg =append (_deg ,'-');_adgd *=-1;};_fbe :=0;_bdg :for _bcd :=len (_dec .Exponent )-1;_bcd >=0;_bcd --{_ade :=len (_eca )-1-_fbe ;_fee :=_dec .Exponent [_bcd ];switch _fee .Type {case FmtTypeDigit :if _ade >=0{_deg =append (_deg ,_eca [_ade ]);_fbe ++;}else {_deg =append (_deg ,'0');};case FmtTypeDigitOpt :if _ade >=0{_deg =append (_deg ,_eca [_ade ]);_fbe ++;}else {for _egf :=_bcd ;_egf >=0;_egf --{_aag :=_dec .Exponent [_egf ];if _aag .Type ==FmtTypeLiteral {_deg =append (_deg ,_aag .Literal );};};break _bdg ;};case FmtTypeLiteral :_deg =append (_deg ,_fee .Literal );default:_de .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",_fee );};};if _fbe < len (_eca ){_deg =append (_deg ,_eca [len (_eca )-_fbe -1:_fbe -1]...);};_ff (_deg [2:]);return _deg ;};const _gdd int =0;func _dac (_fgb _c .Time ,_ead float64 ,_adb string )[]byte {_fge :=[]byte {};_eadc :=0;for _ccg :=0;_ccg < len (_adb );_ccg ++{var _bgac string ;if _adb [_ccg ]==':'{_bgac =string (_adb [_eadc :_ccg ]);_eadc =_ccg +1;}else if _ccg ==len (_adb )-1{_bgac =string (_adb [_eadc :_ccg +1]);}else {continue ;};switch _bgac {case "\u0064":_fge =_fgb .AppendFormat (_fge ,"\u0032");case "\u0068":_fge =_fgb .AppendFormat (_fge ,"\u0033");case "\u0068\u0068":_fge =_fgb .AppendFormat (_fge ,"\u0031\u0035");case "\u006d":_fge =_fgb .AppendFormat (_fge ,"\u0034");case "\u006d\u006d":_fge =_fgb .AppendFormat (_fge ,"\u0030\u0034");case "\u0073":_fge =_fgb .Round (_c .Second ).AppendFormat (_fge ,"\u0035");case "\u0073\u002e\u0030":_fge =_fgb .Round (_c .Second /10).AppendFormat (_fge ,"\u0035\u002e\u0030");case "\u0073\u002e\u0030\u0030":_fge =_fgb .Round (_c .Second /100).AppendFormat (_fge ,"\u0035\u002e\u0030\u0030");case "\u0073\u002e\u00300\u0030":_fge =_fgb .Round (_c .Second /1000).AppendFormat (_fge ,"\u0035\u002e\u00300\u0030");case "\u0073\u0073":_fge =_fgb .Round (_c .Second ).AppendFormat (_fge ,"\u0030\u0035");case "\u0073\u0073\u002e\u0030":_fge =_fgb .Round (_c .Second /10).AppendFormat (_fge ,"\u0030\u0035\u002e\u0030");case "\u0073\u0073\u002e0\u0030":_fge =_fgb .Round (_c .Second /100).AppendFormat (_fge ,"\u0030\u0035\u002e0\u0030");case "\u0073\u0073\u002e\u0030\u0030\u0030":_fge =_fgb .Round (_c .Second /1000).AppendFormat (_fge ,"\u0030\u0035\u002e\u0030\u0030\u0030");case "\u0041\u004d\u002fP\u004d":_fge =_fgb .AppendFormat (_fge ,"\u0050\u004d");case "\u005b\u0068\u005d":_fge =_a .AppendInt (_fge ,int64 (_ead *24),10);case "\u005b\u006d\u005d":_fge =_a .AppendInt (_fge ,int64 (_ead *24*60),10);case "\u005b\u0073\u005d":_fge =_a .AppendInt (_fge ,int64 (_ead *24*60*60),10);case "":default:_de .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061t\u0020\u0025\u0073",_bgac );};if _adb [_ccg ]==':'{_fge =append (_fge ,':');};};return _fge ;};func _gcge (_bdb float64 )string {_beec :=_a .FormatFloat (_bdb ,'E',-1,64);_bab :=_a .FormatFloat (_bdb ,'E',5,64);if len (_beec )< len (_bab ){return _a .FormatFloat (_bdb ,'E',2,64);};return _bab ;};const _fcc int =0;func (_e FmtType )String ()string {if _e >=FmtType (len (_bb )-1){return _d .Sprintf ("F\u006d\u0074\u0054\u0079\u0070\u0065\u0028\u0025\u0064\u0029",_e );};return _cf [_bb [_e ]:_bb [_e +1]];};
2021-04-23 20:00:00 +00:00
2021-07-30 17:03:26 +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 {_cb :=Parse (f );var _fb Format ;if len (_cb )==1{_fb =_cb [0];}else if len (_cb )==4{_fb =_cb [3];};_bg :=false ;for _ ,_cd :=range _fb .Whole {if _cd .Type ==FmtTypeText {_bg =true ;};};if !_bg {return v ;};_egc :=_fg .Buffer {};for _ ,_ca :=range _fb .Whole {switch _ca .Type {case FmtTypeLiteral :_egc .WriteByte (_ca .Literal );case FmtTypeText :_egc .WriteString (v );};};return _egc .String ();};func _daf (_ga []byte )[]byte {_gdb :=len (_ga );_bbg :=false ;_acd :=false ;for _ecc :=len (_ga )-1;_ecc >=0;_ecc --{if _ga [_ecc ]=='0'&&!_acd &&!_bbg {_gdb =_ecc ;}else if _ga [_ecc ]=='.'{_bbg =true ;}else {_acd =true ;};};if _bbg &&_acd {if _ga [_gdb -1]=='.'{_gdb --;};return _ga [0:_gdb ];};return _ga ;};
2021-06-16 07:10:52 +00:00
// Token is a format token in the Excel format string.
2021-07-30 17:03:26 +00:00
type Token struct{Type FmtType ;Literal byte ;DateTime string ;};func _dbf (_bbc []byte )[]byte {for _egb :=len (_bbc )-1;_egb > 0;_egb --{if _bbc [_egb ]=='9'+1{_bbc [_egb ]='0';if _bbc [_egb -1]=='.'{_egb --;};_bbc [_egb -1]++;};};if _bbc [0]=='9'+1{_bbc [0]='0';copy (_bbc [1:],_bbc [0:]);_bbc [0]='1';};return _bbc ;};const _gdg int =0;func _ff (_ag []byte )[]byte {for _ggg :=0;_ggg < len (_ag )/2;_ggg ++{_fgcg :=len (_ag )-1-_ggg ;_ag [_ggg ],_ag [_fgcg ]=_ag [_fgcg ],_ag [_ggg ];};return _ag ;};func _abbd (_beag int64 )int64 {if _beag < 0{return -_beag ;};return _beag ;};func _aabc (_fec _c .Time ,_cdf string )[]byte {_ddd :=[]byte {};_fcdc :=0;for _fga :=0;_fga < len (_cdf );_fga ++{var _cfg string ;if _cdf [_fga ]=='/'{_cfg =string (_cdf [_fcdc :_fga ]);_fcdc =_fga +1;}else if _fga ==len (_cdf )-1{_cfg =string (_cdf [_fcdc :_fga +1]);}else {continue ;};switch _cfg {case "\u0079\u0079":_ddd =_fec .AppendFormat (_ddd ,"\u0030\u0036");case "\u0079\u0079\u0079\u0079":_ddd =_fec .AppendFormat (_ddd ,"\u0032\u0030\u0030\u0036");case "\u006d":_ddd =_fec .AppendFormat (_ddd ,"\u0031");case "\u006d\u006d":_ddd =_fec .AppendFormat (_ddd ,"\u0030\u0031");case "\u006d\u006d\u006d":_ddd =_fec .AppendFormat (_ddd ,"\u004a\u0061\u006e");case "\u006d\u006d\u006d\u006d":_ddd =_fec .AppendFormat (_ddd ,"\u004aa\u006e\u0075\u0061\u0072\u0079");case "\u006d\u006d\u006dm\u006d":switch _fec .Month (){case _c .January ,_c .July ,_c .June :_ddd =append (_ddd ,'J');case _c .February :_ddd =append (_ddd ,'M');case _c .March ,_c .May :_ddd =append (_ddd ,'M');case _c .April ,_c .August :_ddd =append (_ddd ,'A');case _c .September :_ddd =append (_ddd ,'S');case _c .October :_ddd =append (_ddd ,'O');case _c .November :_ddd =append (_ddd ,'N');case _c .December :_ddd =append (_ddd ,'D');};case "\u0064":_ddd =_fec .AppendFormat (_ddd ,"\u0032");case "\u0064\u0064":_ddd =_fec .AppendFormat (_ddd ,"\u0030\u0032");case "\u0064\u0064\u0064":_ddd =_fec .AppendFormat (_ddd ,"\u004d\u006f\u006e");case "\u0064\u0064\u0064\u0064":_ddd =_fec .AppendFormat (_ddd ,"\u004d\u006f\u006e\u0064\u0061\u0079");default:_de .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",_cfg );};if _cdf [_fga ]=='/'{_ddd =append (_ddd ,'/');};};return _ddd ;};
// Number is used to format a number with a format string. If the format
// string is empty, then General number formatting is used which attempts to mimic
// Excel's general formatting.
func Number (v float64 ,f string )string {if f ==""||f =="\u0047e\u006e\u0065\u0072\u0061\u006c"||f =="\u0040"{return NumberGeneric (v );};_aae :=Parse (f );if len (_aae )==1{return _adg (v ,_aae [0],false );}else if len (_aae )> 1&&v < 0{return _adg (v ,_aae [1],true );}else if len (_aae )> 2&&v ==0{return _adg (v ,_aae [2],false );};return _adg (v ,_aae [0],false );};func (_geb *Lexer )Lex (r _b .Reader ){_bad ,_dg ,_bafg :=0,0,0;_bag :=-1;_efb ,_dfb ,_beca :=0,0,0;_ =_dfb ;_ =_beca ;_ede :=1;_ =_ede ;_aca :=make ([]byte ,4096);_bfg :=false ;for !_bfg {_gfb :=0;if _efb > 0{_gfb =_dg -_efb ;};_dg =0;_aed ,_deeb :=r .Read (_aca [_gfb :]);if _aed ==0||_deeb !=nil {_bfg =true ;};_bafg =_aed +_gfb ;if _bafg < len (_aca ){_bag =_bafg ;};{_bad =_ebc ;_efb =0;_dfb =0;_beca =0;};{if _dg ==_bafg {goto _fce ;};switch _bad {case 34:goto _eccd ;case 35:goto _cgfc ;case 0:goto _bffg ;case 36:goto _dcge ;case 37:goto _deea ;case 1:goto _bfca ;case 2:goto _aee ;case 38:goto _bffe ;case 3:goto _bbad ;case 4:goto _fae ;case 39:goto _bcfb ;case 5:goto _gggc ;case 6:goto _bdgg ;case 7:goto _ffee ;case 8:goto _ebb ;case 40:goto _fddd ;case 9:goto _bfe ;case 41:goto _cacf ;case 10:goto _ffgg ;case 42:goto _feg ;case 11:goto _afbb ;case 43:goto _aga ;case 44:goto _fagc ;case 45:goto _fffe ;case 12:goto _agba ;case 46:goto _dea ;case 13:goto _edee ;case 14:goto _bfd ;case 15:goto _gcbf ;case 16:goto _gbe ;case 47:goto _ebg ;case 17:goto _cge ;case 48:goto _fcdca ;case 18:goto _bfaf ;case 19:goto _aabe ;case 20:goto _bbe ;case 49:goto _gbdc ;case 50:goto _decg ;case 21:goto _ffaa ;case 22:goto _aaf ;case 23:goto _efe ;case 24:goto _gebf ;case 25:goto _dfce ;case 51:goto _ace ;case 26:goto _eec ;case 52:goto _bfdb ;case 53:goto _aeef ;case 54:goto _def ;case 55:goto _ffc ;case 56:goto _ceg ;case 57:goto _bcbf ;case 27:goto _ecbf ;case 28:goto _ffcf ;case 29:goto _ggc ;case 30:goto _fgee ;case 31:goto _abef ;case 58:goto _deed ;case 32:goto _dbge ;case 59:goto _dgdg ;case 33:goto _dfea ;case 60:goto _fcde ;case 61:goto _dcf ;case 62:goto _gac ;};goto _caf ;_fdd :switch _beca {case 2:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeDigit ,nil );};case 3:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeDigitOpt ,nil );};case 5:{_dg =(_dfb )-1;};case 8:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypePercent ,nil );};case 13:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeFraction ,_aca [_efb :_dfb ]);};case 14:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeDate ,_aca [_efb :_dfb ]);};case 15:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeTime ,_aca [_efb :_dfb ]);};case 16:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeTime ,_aca [_efb :_dfb ]);};case 18:{_dg =(_dfb )-1;};case 20:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeLiteral ,_aca [_efb :_dfb ]);};case 21:{_dg =(_dfb )-1;_geb ._ccgb .AddToken (FmtTypeLiteral ,_aca [_efb +1:_dfb -1]);};};goto _gbf ;_bba :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeFraction ,_aca [_efb :_dfb ]);};goto _gbf ;_aagf :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeDigitOpt ,nil );};goto _gbf ;_fgg :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeDigitOptThousands ,nil );};goto _gbf ;_dgg :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypePercent ,nil );};goto _gbf ;_cff :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeDate ,_aca [_efb :_dfb ]);};goto _gbf ;_dde :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeDigit ,nil );};goto _gbf ;_bgg :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeTime ,_aca [_efb :_dfb ]);};goto _gbf ;_gdba :_dg =(_dfb )-1;{_geb ._ccgb .AddToken (FmtTypeLiteral ,_aca [_efb :_dfb ]);};goto _gbf ;_afa :_dfb =_dg +1;{_geb ._ccgb ._bff =true ;};goto _gbf ;_cacg :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeLiteral ,_aca [_efb :_dfb ]);};goto _gbf ;_aeb :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeDollar ,nil );};goto _gbf ;_ggae :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeComma ,nil );};goto _gbf ;_age :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeDecimal ,nil );};goto _gbf ;_gcf :_dfb =_dg +1;{_geb .nextFmt ();};goto _gbf ;_fgea :_dfb =_dg +1;{_geb ._ccgb .AddToken (FmtTypeText ,nil );};goto _gbf ;_eeeb :_dfb =_dg +1
2021-06-16 07:10:52 +00:00
// Format is a parsed number format.
2021-07-30 17:03:26 +00:00
type Format struct{Whole []Token ;Fractional []Token ;Exponent []Token ;IsExponential bool ;_db bool ;_bf bool ;_bff bool ;_df bool ;_ef bool ;_aa bool ;_gg int64 ;_eg int ;};func (_ceb *Lexer )nextFmt (){_ceb ._agf =append (_ceb ._agf ,_ceb ._ccgb );_ceb ._ccgb =Format {}};const _g =1e-10;func _bbb (_dbag _c .Time )_c .Time {_dbag =_dbag .UTC ();return _c .Date (_dbag .Year (),_dbag .Month (),_dbag .Day (),_dbag .Hour (),_dbag .Minute (),_dbag .Second (),_dbag .Nanosecond (),_c .Local );};const _dbae int =34;const _abg int =-1;const _ae =1e11;
2021-03-16 20:51:18 +00:00
2021-07-30 17:03:26 +00:00
// NumberGeneric formats the number with the generic format which attemps to
// mimic Excel's general formatting.
func NumberGeneric (v float64 )string {if _be .Abs (v )>=_ae ||_be .Abs (v )<=_g &&v !=0{return _gcge (v );};_cbc :=make ([]byte ,0,15);_cbc =_a .AppendFloat (_cbc ,v ,'f',-1,64);if len (_cbc )> 11{_da :=_cbc [11]-'0';if _da >=5&&_da <=9{_cbc [10]++;_cbc =_cbc [0:11];_cbc =_dbf (_cbc );};_cbc =_cbc [0:11];}else if len (_cbc )==11{if _cbc [len (_cbc )-1]=='9'{_cbc [len (_cbc )-1]++;_cbc =_dbf (_cbc );};};_cbc =_daf (_cbc );return string (_cbc );};
2020-12-17 22:07:08 +00:00
2021-04-23 20:00:00 +00:00
// Value formats a value as a number or string depending on if it appears to be
// a number or string.
2021-07-30 17:03:26 +00:00
func Value (v string ,f string )string {if IsNumber (v ){_cg ,_ :=_a .ParseFloat (v ,64);return Number (_cg ,f );};return String (v ,f );};
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// AddToken adds a format token to the format.
2021-07-30 17:03:26 +00:00
func (_dd *Format )AddToken (t FmtType ,l []byte ){if _dd ._ef {_dd ._ef =false ;return ;};switch t {case FmtTypeDecimal :_dd ._aa =true ;case FmtTypeUnderscore :_dd ._ef =true ;case FmtTypeText :_dd .Whole =append (_dd .Whole ,Token {Type :t });case FmtTypeDate ,FmtTypeTime :_dd .Whole =append (_dd .Whole ,Token {Type :t ,DateTime :string (l )});case FmtTypePercent :_dd ._bf =true ;t =FmtTypeLiteral ;l =[]byte {'%'};fallthrough;case FmtTypeDigitOpt :fallthrough;case FmtTypeLiteral ,FmtTypeDigit ,FmtTypeDollar ,FmtTypeComma :if l ==nil {l =[]byte {0};};for _ ,_ec :=range l {if _dd .IsExponential {_dd .Exponent =append (_dd .Exponent ,Token {Type :t ,Literal :_ec });}else if !_dd ._aa {_dd .Whole =append (_dd .Whole ,Token {Type :t ,Literal :_ec });}else {_dd .Fractional =append (_dd .Fractional ,Token {Type :t ,Literal :_ec });};};case FmtTypeDigitOptThousands :_dd ._df =true ;case FmtTypeFraction :_ad :=_ba .Split (string (l ),"\u002f");if len (_ad )==2{_dd ._db =true ;_dd ._gg ,_ =_a .ParseInt (_ad [1],10,64);for _ ,_dc :=range _ad [1]{if _dc =='?'||_dc =='0'{_dd ._eg ++;};};};default:_de .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 _cbe (_bca ,_ffb float64 ,_gdc Format )[]byte {if len (_gdc .Fractional )==0{return nil ;};_dfe :=_a .AppendFloat (nil ,_bca ,'f',-1,64);if len (_dfe )> 2{_dfe =_dfe [2:];}else {_dfe =nil ;};_cfbb :=make ([]byte ,0,len (_dfe ));_cfbb =append (_cfbb ,'.');_agb :=0;_gba :for _fed :=0;_fed < len (_gdc .Fractional );_fed ++{_eee :=_fed ;_bdd :=_gdc .Fractional [_fed ];switch _bdd .Type {case FmtTypeDigit :if _eee < len (_dfe ){_cfbb =append (_cfbb ,_dfe [_eee ]);_agb ++;}else {_cfbb =append (_cfbb ,'0');};case FmtTypeDigitOpt :if _eee >=0{_cfbb =append (_cfbb ,_dfe [_eee ]);_agb ++;}else {break _gba ;};case FmtTypeLiteral :_cfbb =append (_cfbb ,_bdd .Literal );default:_de .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",_bdd );};};return _cfbb ;};
// FmtType is the type of a format token.
//go:generate stringer -type=FmtType
type FmtType byte ;const _cdg int =34;func IsNumber (data string )(_bcf bool ){_dee ,_bdgd ,_dbfb :=0,0,len (data );_dba :=len (data );_gcd ,_agcg ,_ed :=0,0,0;_ =_agcg ;_ =_ed ;_ =_gcd ;{_dee =_gdd ;_gcd =0;_agcg =0;_ed =0;};{if _bdgd ==_dbfb {goto _fbg ;};switch _dee {case 0:goto _ffbg ;case 1:goto _cdfg ;case 2:goto _aeg ;case 3:goto _cbeb ;case 4:goto _cac ;case 5:goto _ddf ;case 6:goto _dcg ;case 7:goto _fcfe ;};goto _beg ;_ge :_agcg =_bdgd ;_bdgd --;{_bcf =false ;};goto _cga ;_bec :_agcg =_bdgd ;_bdgd --;{_bcf =_agcg ==len (data );};goto _cga ;_bdc :_agcg =_bdgd ;_bdgd --;{_bcf =_agcg ==len (data );};goto _cga ;_dbb :switch _ed {case 2:{_bdgd =(_agcg )-1;_bcf =_agcg ==len (data );};case 3:{_bdgd =(_agcg )-1;_bcf =false ;};};goto _cga ;_cga :_gcd =0;if _bdgd ++;_bdgd ==_dbfb {goto _gbg ;};_ffbg :_gcd =_bdgd ;switch data [_bdgd ]{case 43:goto _acb ;case 45:goto _acb ;};if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _adc ;};goto _dcc ;_dcc :if _bdgd ++;_bdgd ==_dbfb {goto _fgab ;};_cdfg :goto _dcc ;_acb :if _bdgd ++;_bdgd ==_dbfb {goto _ccc ;};_aeg :if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _adc ;};goto _dcc ;_adc :if _bdgd ++;_bdgd ==_dbfb {goto _bfbc ;};_cbeb :if data [_bdgd ]==46{goto _ecce ;};if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _adc ;};goto _dcc ;_ecce :if _bdgd ++;_bdgd ==_dbfb {goto _cgg ;};_cac :if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _bgfd ;};goto _dcc ;_bgfd :if _bdgd ++;_bdgd ==_dbfb {goto _eda ;};_ddf :if data [_bdgd ]==69{goto _cad ;};if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _bgfd ;};goto _dcc ;_cad :if _bdgd ++;_bdgd ==_dbfb {goto _faag ;};_dcg :switch data [_bdgd ]{case 43:goto _baf ;case 45:goto _baf ;};goto _dcc ;_baf :_agcg =_bdgd +1;_ed =3;goto _ega ;_cbea :_agcg =_bdgd +1;_ed =2;goto _ega ;_ega :if _bdgd ++;_bdgd ==_dbfb {goto _beed ;};_fcfe :if 48<=data [_bdgd ]&&data [_bdgd ]<=57{goto _cbea ;};goto _dcc ;_beg :_gbg :_dee =0;goto _fbg ;_fgab :_dee =1;goto _fbg ;_ccc :_dee =2;goto _fbg ;_bfbc :_dee =3;goto _fbg ;_cgg :_dee =4;goto _fbg ;_eda :_dee =5;goto _fbg ;_faag :_dee =6;goto _fbg ;_beed :_dee =7;goto _fbg ;_fbg :{};if _bdgd ==_dba {switch _dee {case 1:goto _ge ;case 2:goto _ge ;case 3:goto _bec ;case 4:goto _ge ;case 5:goto _bdc ;case 6:goto _ge ;case 7:goto _dbb ;};};};if _dee ==_edg {return false ;};return ;};func Parse (s string )[]Format {_fgd :=Lexer {};_fgd .Lex (_ba .NewReader (s ));_fgd ._agf =append (_fgd ._agf ,_fgd ._ccgb );return _fgd ._agf ;};const _ebc int =34;const _cf ="\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 (FmtTypeLiteral FmtType =iota ;FmtTypeDigit ;FmtTypeDigitOpt ;FmtTypeComma ;FmtTypeDecimal ;FmtTypePercent ;FmtTypeDollar ;FmtTypeDigitOptThousands ;FmtTypeUnderscore ;FmtTypeDate ;FmtTypeTime ;FmtTypeFraction ;FmtTypeText ;);func _adg (_fa float64 ,_ac Format ,_fff bool )string {if _ac ._bff {return NumberGeneric (_fa );};_eb :=make ([]byte ,0,20);_gb :=_be .Signbit (_fa );_agc :=_be .Abs (_fa );_ab :=int64 (0);_bga :=int64 (0);if _ac .IsExponential {for _agc >=10{_bga ++;_agc /=10;};for _agc < 1{_bga --;_agc *=10;};}else if _ac ._bf {_agc *=100;}else if _ac ._db {if _ac ._gg ==0{_aaec :=_be .Pow (10,float64 (