matchList static method
Return the token that matches the unit ident found.
Implementation
static int matchList(List<Map<String, dynamic>> identList, String tokenField,
String text, int offset, int length) {
for (final entry in identList) {
final ident = entry['value'] as String;
if (length == ident.length) {
var idx = offset;
var match = true;
for (var i = 0; i < ident.length; i++) {
var identChar = ident.codeUnitAt(i);
var char = text.codeUnitAt(idx++);
// Compare lowercase to lowercase then check if char is uppercase.
match = match &&
(char == identChar ||
((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
(char + 32) == identChar));
if (!match) {
break;
}
}
if (match) {
// Completely matched; return the token for this unit.
return entry[tokenField] as int;
}
}
}
return -1; // Not a unit token.
}