Skip to content

Literal Class Info Parsing#7722

Merged
Efnilite merged 24 commits into
SkriptLang:dev/featurefrom
Absolutionism:dev/LiteralParseClassInfo
Mar 30, 2025
Merged

Literal Class Info Parsing#7722
Efnilite merged 24 commits into
SkriptLang:dev/featurefrom
Absolutionism:dev/LiteralParseClassInfo

Conversation

@Absolutionism
Copy link
Copy Markdown
Contributor

@Absolutionism Absolutionism commented Mar 18, 2025

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, like set {_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) or black (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

Comment thread src/test/skript/tests/misc/Literal-Class-Info-Parse.sk Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
@Efnilite Efnilite added the feature Pull request adding a new feature. label Mar 18, 2025
Comment thread src/test/skript/tests/misc/literal specification.sk Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Copy link
Copy Markdown
Member

@Burbulinis Burbulinis left a comment

Choose a reason for hiding this comment

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

lgtm, just tests for the errors

@Absolutionism Absolutionism requested review from a team as code owners March 19, 2025 22:19
@Absolutionism Absolutionism requested a review from sovdeeth March 19, 2025 23:58
@abandonedaccount6235
Copy link
Copy Markdown
Contributor

if it's not already possible, can you run the type through Noun#stripIndefiniteArticle so that users can do black (the wolf color)? I honestly envisioned the syntax as always being used with "the", but I'm not sure if it makes sense to actually enforce requiring it. I think including the makes it fit much better but I'm not sure if it should actually be required.

Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/test/skript/tests/misc/literal specification.sk
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
@abandonedaccount6235
Copy link
Copy Markdown
Contributor

perhaps we could call these "clarified literals" and "literal clarification"

@Absolutionism
Copy link
Copy Markdown
Contributor Author

Absolutionism commented Mar 20, 2025

if it's not already possible, can you run the type through Noun#stripIndefiniteArticle so that users can do black (the wolf color)? I honestly envisioned the syntax as always being used with "the", but I'm not sure if it makes sense to actually enforce requiring it. I think including the makes it fit much better but I'm not sure if it should actually be required.

Seems that Noun#stripIndefiniteArticle only removes a and an
the is stored as a definite article, and I dont see a method to remove that, should I add one?

idea64_WsgTiBVRpI

@sovdeeth
Copy link
Copy Markdown
Member

Note that the classinfo parser already handles stripping indefinite articles

Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/localization/Noun.java
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
@Absolutionism Absolutionism requested a review from sovdeeth March 20, 2025 23:55
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
@Absolutionism Absolutionism requested a review from sovdeeth March 21, 2025 00:35
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Comment thread src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated
Copy link
Copy Markdown
Contributor

@abandonedaccount6235 abandonedaccount6235 left a comment

Choose a reason for hiding this comment

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

code looks good, thanks! i'd like to wait for some additional team member input over the next few weeks before we merge :)

@abandonedaccount6235
Copy link
Copy Markdown
Contributor

I would also like to agree upon a name for this functionality before we merge

@sovdeeth sovdeeth added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Mar 29, 2025
@sovdeeth
Copy link
Copy Markdown
Member

I would also like to agree upon a name for this functionality before we merge

literal type clarification

@ShaneBeee
Copy link
Copy Markdown
Contributor

ShaneBeee commented Mar 30, 2025

I would also like to agree upon a name for this functionality before we merge

In all fairness, what does it matter? This doesn't appear to be documented.
You're asking to agree upon a name, but for what reason?
Where exactly is the naming being worried about?

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.

@Efnilite Efnilite merged commit 17617fc into SkriptLang:dev/feature Mar 30, 2025
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Pull request adding a new feature. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants