expand method
The basic rules this block stands for. Called once per block.
Implementation
@override
List<Rule> expand() {
final separator = this.separator;
String run(String digits) {
if (separator == null) return '[$digits]+';
final withSeparator = '$digits${_escapeClass(separator)}';
return '[$digits](?:[$withSeparator]*[$digits])?';
}
final decimal =
'(?:${run('0-9')}(?:\\.${run('0-9')})?|\\.${run('0-9')})'
'(?:[eE][+-]?${run('0-9')})?';
final forms = [
if (hex) '0[xX]${run('0-9a-fA-F')}',
if (binary) '0[bB]${run('01')}',
if (octal) '0[oO]${run('0-7')}',
decimal,
];
final suffix = this.suffix.isEmpty ? '' : '(?:${this.suffix})';
return [
TokenRule(
'(?<![\\w\$.])(?:${forms.join('|')})$suffix(?![\\w\$])',
scope: scope,
),
];
}