parseField static method
Implementation
static QueryParserState? parseField(QueryParser parser) {
var lexeme = parser.consumeLexeme();
if (lexeme == null) {
return null;
}
if (!parser.query.allFields.contains(lexeme.str)) {
var possibleFields = parser.query.allFields.map((f) => "'$f'").join(', '),
errorMessage =
"unrecognised field '${lexeme.str}', possible fields: $possibleFields";
throw QueryParseError(errorMessage, lexeme.start, lexeme.end);
}
parser.currentClause.fields = [lexeme.str];
var nextLexeme = parser.peekLexeme();
if (nextLexeme == null) {
var errorMessage = 'expecting term, found nothing';
throw QueryParseError(errorMessage, lexeme.start, lexeme.end);
}
switch (nextLexeme.type) {
case LexemeType.TERM:
return QueryParser.parseTerm;
default:
var errorMessage = "expecting term, found '${nextLexeme.type}'";
throw QueryParseError(errorMessage, nextLexeme.start, nextLexeme.end);
}
}