Skip to content

Commit

Permalink
fix: boolean operator fix (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
CHarcoalToast authored and CHarcoalToast committed Oct 18, 2020
1 parent 9814cf4 commit 4b164e6
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.syst3ms.skriptparser.parsing;

import io.github.syst3ms.skriptparser.expressions.ExprBooleanOperators;
import io.github.syst3ms.skriptparser.file.FileSection;
import io.github.syst3ms.skriptparser.lang.*;
import io.github.syst3ms.skriptparser.lang.base.ConditionalExpression;
Expand Down Expand Up @@ -120,6 +121,24 @@ public static <T> Optional<? extends Expression<? extends T>> parseExpression(St
return variable;
}
}
// The isList variable's sole purpose is to prevent us from exchanging boolean operators with lists.
boolean isList = s.toLowerCase().startsWith("list ");
if (isList) {
s = s.substring("list ".length());
}
if (!isList) {
// We parse boolean operators first to prevent clutter while parsing.
var operatorInfo = (ExpressionInfo<ExprBooleanOperators, Boolean>) SyntaxManager.getAllExpressions()
.stream()
.filter(i -> i.getSyntaxClass() == ExprBooleanOperators.class)
.findFirst()
.orElseThrow();
var booleanOperator = matchExpressionInfo(s, operatorInfo, expectedType, parserState, logger);
if (booleanOperator.isPresent()) {
logger.clearErrors();
return booleanOperator;
}
}
if (!expectedType.isSingle()) {
var listLiteral = parseListLiteral(s, expectedType, parserState, logger);
if (listLiteral.isPresent()) {
Expand Down

0 comments on commit 4b164e6

Please sign in to comment.