I used AWK for many years, but one day I realized that I had pushed AWK beyond whats its meant for, same as the author here. classic red flag from the article:
function NUMBER( res) {
return (tryParse1("-", res) || 1) &&
(tryParse1("0", res) || tryParse1("123456789", res) && (tryParseDigits(res)||1)) &&
(tryParse1(".", res) ? tryParseDigits(res) : 1) &&
(tryParse1("eE", res) ? (tryParse1("-+",res)||1) && tryParseDigits(res) : 1) &&
asm("number") && asm(res[0])
}
why put yourself through this, when you can just do something like this instead: package parse
import "strconv"
func parse_float(s string) (float64, error) {
return strconv.ParseFloat(s, 64)
}
func parse_int(s string) (int64, error) {
return strconv.ParseInt(s, 10, 64)
}