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 French cardinal number.', input);
}
var negative = false;
if (text == 'moins') {
throw FormatException('Expected a French cardinal number.', input);
}
if (text.startsWith('moins ')) {
negative = true;
text = text.substring('moins '.length);
if (text.isEmpty) {
throw FormatException('Expected a French cardinal number.', input);
}
}
final tokens = text.split(' ');
if (tokens.length == 1 && _isZero(tokens.single)) return 0;
if (tokens.any(_isZero)) {
throw FormatException('Unexpected French cardinal token.', input);
}
final value = _parsePositive(tokens, input);
if (value == 0 || value > _maxValue) {
throw FormatException('Unexpected French cardinal token.', input);
}
return negative ? -value : value;
}