Fix the bug regarding unquoted strings in collection types in the DSL#1763
Draft
RobinPicard wants to merge 1 commit intomainfrom
Draft
Fix the bug regarding unquoted strings in collection types in the DSL#1763RobinPicard wants to merge 1 commit intomainfrom
RobinPicard wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explores a solution to #1630
As shown in the issue above, we have a problem in our regex DSL regarding the quotation of text elements in Python collection types. Quite simply, we must put between quotations marks everything that ends up being a string if it's used in a collection type to respect Python grammar. The issue is that if those same elements are not used in a collection type, then there is no need to add those quotations marks (and we should not add them as the user never asked for it).
We need to have a system that allows us to add these quotes when handling collection types within our DSL. We need to:
Regexclass)Sequence, aLiteral, aQuantifyMinimum... and we want to quote the whole containing term, not the items is containsThe solution envisioned uses 2 properties possessed by each term, knowing that all Python types are eventually turned into terms (the naming of those properties will be improved):
requires_quoting: tells whether this term should be quoted if it where in a collection type. The value of the property can either be set by the user or is deduced from the type of term or the other terms it contains.apply_quotation: whether the term is in a collection type such that it should be quoted (if applicable). The value of the property default toFalse, but is then turned toTruein thepython_types_to_termsfunction depending on whether the term is contained in a collection type.In the
to_regexfunction, we wrap the content of the term inreprif both properties above areTrue