You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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)...)
) syntaxthis 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 subsetIf 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 matchThe text was updated successfully, but these errors were encountered: