Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: boolean operator fix (#23) #83

Merged
merged 8 commits into from
Dec 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Mwexim marked this conversation as resolved.
Show resolved Hide resolved
// We parse boolean operators first to prevent clutter while parsing.
Mwexim marked this conversation as resolved.
Show resolved Hide resolved
var operatorInfo = (ExpressionInfo<ExprBooleanOperators, Boolean>) SyntaxManager.getAllExpressions()
Mwexim marked this conversation as resolved.
Show resolved Hide resolved
.stream()
.filter(i -> i.getSyntaxClass() == ExprBooleanOperators.class)
.findFirst()
.orElseThrow();
var booleanOperator = matchExpressionInfo(s, operatorInfo, expectedType, parserState, logger);
if (booleanOperator.isPresent()) {
logger.clearErrors();
Mwexim marked this conversation as resolved.
Show resolved Hide resolved
return booleanOperator;
}
}
if (!expectedType.isSingle()) {
var listLiteral = parseListLiteral(s, expectedType, parserState, logger);
if (listLiteral.isPresent()) {
Expand Down