parse method
Parses input and returns the numeric value.
Throws FormatException when input cannot be parsed by this codec.
Implementation
@override
int parse(String input) {
var text = _normalize(input);
if (text.isEmpty) {
throw FormatException('Expected a Spanish cardinal number.', input);
}
var negative = false;
if (text.startsWith('menos ')) {
negative = true;
text = text.substring('menos '.length);
if (text.isEmpty) {
throw FormatException('Expected a Spanish cardinal number.', input);
}
}
final tokens = text.split(' ');
if (tokens.length == 1 && tokens.single == 'cero') return 0;
if (tokens.contains('cero')) {
throw FormatException('Unexpected Spanish cardinal token.', input);
}
final value = _parseLarge(tokens, input, _billion * 1000000);
if (value == 0 || value > _maxValue) {
throw FormatException('Unexpected Spanish cardinal token.', input);
}
return negative ? -value : value;
}