mirror of
https://github.com/unidoc/unioffice.git
synced 2025-05-04 22:17:38 +08:00
46 lines
935 B
Ragel
46 lines
935 B
Ragel
// Copyright 2017 Baliance. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by the terms of the Affero GNU General
|
|
// Public License version 3.0 as published by the Free Software Foundation and
|
|
// appearing in the file LICENSE included in the packaging of this file. A
|
|
// commercial license can be purchased by contacting sales@baliance.com.
|
|
|
|
|
|
package format
|
|
import (
|
|
)
|
|
|
|
|
|
%%{
|
|
machine isnumber;
|
|
write data;
|
|
|
|
sign = '+' | '-';
|
|
integer = sign? [0-9]+;
|
|
float = sign? [0-9]+ '.' [0-9]+ ('E' sign [0-9]+)?;
|
|
|
|
main := |*
|
|
integer => { isNumber = te == len(data); };
|
|
float => { isNumber = te == len(data); };
|
|
any* => { isNumber = false; };
|
|
*|;
|
|
}%%
|
|
func IsNumber(data string) (isNumber bool) {
|
|
cs, p, pe := 0, 0, len(data)
|
|
eof := len(data)
|
|
ts, te,act := 0,0,0
|
|
_ = te
|
|
_ = act
|
|
_ = ts
|
|
|
|
|
|
%%{
|
|
write init;
|
|
write exec;
|
|
}%%
|
|
if cs == format_error {
|
|
return false
|
|
}
|
|
return
|
|
}
|