Skip to content

Conversation

sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Sep 21, 2025

Problem

The SkriptParser class is a sprawling mess. There's multiple versions of the same method doing different things, 7 different ways to parse something, and a very limited ability to tell it what exactly you want it to parse. You can supply an iterator of syntaxes to attempt, but that can become hard to construct if, say, you want a section that doesn't allow functions, but within that you want another section that only allows things that return String. These constraints are hard to manage and are fully the responsibility of the caller, who may not be aware of existing constraints.

Constraints also exist in the form of a set of bitmap flags, which are clunky and poorly documented at the best of times.

Solution

The goal of this PR is to provide a new class, ParsingConstraints, that holds all the information necessary to constrain a parse to the user's desire. It provides control over whether functions are allowed, literals, non-literals, and even provides methods to only include or specifically exclude certain syntaxes via their class.

Since this requires a significant rework to the internals of SkriptParser, I am also addressing the messiness of the class. I have moved many methods out into other classes, such as the string search/check methods to StringUtils, and a variable parsing method to Variable. I've also added FunctionParser and ExpressionParser classes that are SkriptParsers of their own that specialize in parsing specific syntax types. This significantly reduces the load of the single SkriptParser class and reduces the complexity and mess of the parser. Many helper methods and other ways of reducing complexity are also being implemented to help out.

This is still very much a work in progress and I am currently in the process of duplicating all the features of SkriptParser. Reviews are welcome, but know that all of the code is subject to change as I continue. I would love high-level feedback on the design that doesn't focus on details, though.

Testing Completed

Supporting Information

I am targeting this to be ready for merging just after the 2.13 release.

FunctionParser is outdated and needs to be updated to reflect the changes to function parsing in 2.12.


Completes: none
Related: none

@sovdeeth sovdeeth added enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature. labels Sep 21, 2025
@sovdeeth sovdeeth moved this to In Progress in 2.14 Releases Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant