parsePresence static method
Implementation
static QueryParserState? parsePresence(QueryParser parser) {
var lexeme = parser.consumeLexeme();
if (lexeme == null) {
return null;
}
switch (lexeme.str) {
case "-":
parser.currentClause.presence = QueryPresence.PROHIBITED;
break;
case "+":
parser.currentClause.presence = QueryPresence.REQUIRED;
break;
default:
var errorMessage = 'unrecognised presence operator ${lexeme.str}';
throw QueryParseError(errorMessage, lexeme.start, lexeme.end);
}
var nextLexeme = parser.peekLexeme();
if (nextLexeme == null) {
var errorMessage = "expecting term or field, found nothing";
throw QueryParseError(errorMessage, lexeme.start, lexeme.end);
}
switch (nextLexeme.type) {
case LexemeType.FIELD:
return QueryParser.parseField;
case LexemeType.TERM:
return QueryParser.parseTerm;
default:
var errorMessage = 'expecting term or field, found ${nextLexeme.type}';
throw QueryParseError(errorMessage, nextLexeme.start, nextLexeme.end);
}
}