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 3 commits
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
Expand Up @@ -64,6 +64,12 @@ public class SyntaxParser {
// Gradle requires the cast, but IntelliJ considers it redundant
public static final PatternType<Object> OBJECTS_PATTERN_TYPE = new PatternType<>((Type<Object>) TypeManager.getByClass(Object.class).orElseThrow(AssertionError::new), false);

public static final ExpressionInfo<ExprBooleanOperators, Boolean> EXPRESSION_BOOLEANOPERATORS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need some testing to check that this isn't being initialized until after registration.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing and no errors appear, which is normal considering we don't use the class until after registration. Unless we change things drastically in the future, this should be fine.

Mwexim marked this conversation as resolved.
Show resolved Hide resolved
= (ExpressionInfo<ExprBooleanOperators, Boolean>) SyntaxManager.getAllExpressions().stream()
.filter(i -> i.getSyntaxClass() == ExprBooleanOperators.class)
.findFirst()
.orElseThrow();

/**
* All {@link Effect effects} that are successfully parsed during parsing, in order of last successful parsing
*/
Expand Down Expand Up @@ -126,13 +132,9 @@ public static <T> Optional<? extends Expression<? extends T>> parseExpression(St
s = s.substring("list ".length());
} else {
// 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()
.stream()
.filter(i -> i.getSyntaxClass() == ExprBooleanOperators.class)
.findFirst()
.orElseThrow();
var booleanOperator = matchExpressionInfo(s, operatorInfo, expectedType, parserState, logger);
var booleanOperator = matchExpressionInfo(s, EXPRESSION_BOOLEANOPERATORS, expectedType, parserState, logger);
if (booleanOperator.isPresent()) {
recentExpressions.acknowledge(EXPRESSION_BOOLEANOPERATORS);
logger.clearErrors();
Mwexim marked this conversation as resolved.
Show resolved Hide resolved
return booleanOperator;
}
Expand Down