Skip to content
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

Add Option to Format in often used match expression parts #178

Open
Hendiadyoin1 opened this issue Jun 6, 2022 · 1 comment
Open

Add Option to Format in often used match expression parts #178

Hendiadyoin1 opened this issue Jun 6, 2022 · 1 comment
Labels
feature-request Request for new features or functionality

Comments

@Hendiadyoin1
Copy link

Hendiadyoin1 commented Jun 6, 2022

Languages often have patterns that reappear in multiple places, like identifiers or argument-lists.
These can have quite some length to it and may make the match-expression as a whole less readable.

To solve this you could add a top-level dict to the grammar description that contains name-regex pairs which are substituted into the requested places at runtime.

A good solution would be to add all defined helper functions as a preamble to each match in a named group with 0 repetitions like (?<Name>...){0}


Another possible solution might be PCRE's (?&name) (and (?(DEFINE)...)) syntax
this could be emulated via preprocessing of the patterns and string superstition,
this would not break any old code because (?&...) is illegal in ECMA's regex subset

If a switch to PCRE happens or native support is added you would just need to add a list of (?(DEFINE)...)s to the start of each match

@RedCMD
Copy link

RedCMD commented Jun 9, 2022

Probably should request this at https://github.com/textmate/textmate

@alexdima alexdima added the feature-request Request for new features or functionality label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants