-
-
Notifications
You must be signed in to change notification settings - Fork 400
Syntax Simplification #7841
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
Syntax Simplification #7841
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. Do you think Arithmetic tests that verify the SyntaxElement is a Literal would be possible?
src/main/java/org/skriptlang/skript/lang/simplification/SimplifiedLiteral.java
Outdated
Show resolved
Hide resolved
…) on expressions capable of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good. I might prefer to see the classes of the new simplification package under ch.njol. Mainly, given that rewritten classes are possible in the future, it'll make compatibility easier to handle
src/main/java/org/skriptlang/skript/lang/simplification/SimplifiedLiteral.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/lang/util/ConvertedExpression.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, although aren't there more expressions that can implement simplify under org/skriptlang/skript/
?
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
if (debug) | ||
return "[" + sourceExpr.toString(event, true) + " (SIMPLIFIED)]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we mention what it was simplified to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would get rather confusing, the toString's already rather busy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Re-request after conflict resolution for approval 🙂
Description
Skript has always had this little method on Expression called simplify(), which has never been implemented. It's intended to take expressions and, if possible, simplify them to Literals or similarly simplify the code tree.
This PR attempts to properly implement that idea via a Simplifiable interface. A config option is added to allow users to opt out if issues arise.
Every element is simplified immediately after init() in SkriptParser. In addition, it may be called at any time by parent elements, though it should be ensured that no other objects maintain critical references to the element, as simplify may return new objects.
ExprArithmetic is a special case that can only be simplified once all elements in the chain have been parsed and ordered, so it requires checking the ParsingStack to see if it's the top-level element in the chain. If so, it can then call simplify recursively on all elements in the chain.
Todo:
Target Minecraft Versions: any
Requirements: none
Related Issues: none