parseEditDistance static method
Implementation
static QueryParserState? parseEditDistance(QueryParser parser) {
var lexeme = parser.consumeLexeme();
if (lexeme == null) {
return null;
}
var editDistance = int.tryParse(lexeme.str, radix: 10);
if (editDistance == null) {
var errorMessage = "edit distance must be numeric";
throw QueryParseError(errorMessage, lexeme.start, lexeme.end);
}
parser.currentClause.editDistance = editDistance;
var nextLexeme = parser.peekLexeme();
if (nextLexeme == null) {
parser.nextClause();
return null;
}
switch (nextLexeme.type) {
case LexemeType.TERM:
parser.nextClause();
return QueryParser.parseTerm;
case LexemeType.FIELD:
parser.nextClause();
return QueryParser.parseField;
case LexemeType.EDIT_DISTANCE:
return QueryParser.parseEditDistance;
case LexemeType.BOOST:
return QueryParser.parseBoost;
case LexemeType.PRESENCE:
parser.nextClause();
return QueryParser.parsePresence;
default:
var errorMessage = "Unexpected lexeme type '${nextLexeme.type}'";
throw QueryParseError(errorMessage, nextLexeme.start, nextLexeme.end);
}
}