Literal Class Info Parsing#7722
Conversation
Burbulinis
left a comment
There was a problem hiding this comment.
lgtm, just tests for the errors
|
if it's not already possible, can you run the type through |
|
perhaps we could call these "clarified literals" and "literal clarification" |
Seems that |
|
Note that the classinfo parser already handles stripping indefinite articles |
…olutionism/SkriptTest into dev/LiteralParseClassInfo
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
abandonedaccount6235
left a comment
There was a problem hiding this comment.
code looks good, thanks! i'd like to wait for some additional team member input over the next few weeks before we merge :)
|
I would also like to agree upon a name for this functionality before we merge |
literal type clarification |
In all fairness, what does it matter? This doesn't appear to be documented. If you want people to agree up on a name, you should include your reasoning as to WHY it should be agreed upon, other than for personal reasons. Its common knowledge that SkriptLang lacks in communication, and this response is a great example of just that. |
* Initial Commit * Test * For loop * Fix wolf variant test * Test File Name Lowercased * Update literal classinfo parse.sk * Test File Name Change * Requested Changes * Requested Changes * Fix Error Test * Requested Changes * Additional Changes * Touch Up Changes * Update SkriptParser.java * Update literal specification.sk * Update src/main/java/ch/njol/skript/lang/SkriptParser.java Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Helper Method --------- Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

Description
Problem
There are many literals in Skript that share the same name, like
unknown, which is used for at least 8 different things. This can cause issues when Skript isn't given enough context, likeset {_x} to black. Should it be a wolf variant or a color?Solution
This pr attempts to solve that by introducing a method of clarification after the literal:
black (wolf color)orblack (color). This is not meant to replace the current system of unparsed literals and attempting re-parses, but to work alongside it and allow users to specify exactly what they mean if they do encounter issues.How It Works
During literal parsing, the input is checked against a regex pattern to see if the user supplied a clarifying type. If so, only that classinfo's parser is attempted instead of trying all possible parsers. If the clarifying type doesn't match the target type, we can simply exit, which is earlier than if all parsers had to be attempted.
Any Possible Risks/Benefits
This should help improve the experience of users dealing with ambiguous literals and allow them to write more consistent, readable code. The format of
literal (classinfo)isn't set in stone, but from discussion it seemed to fit best as a point of clarification within a sentence, like "She went to that bar (Elmsworth's) down on Main Street". Testing is needed to ensure this doesn't conflict with any existing syntax, though I cannot think of any cases off the top of my head. Functions might be the closest, but those should not permit a space between the name and the (.Target Minecraft Versions: any
Requirements: none
Related Issues: #7589