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

Syntax: preserve last/named match from a discarded branch #6574

Open
eugenesvk opened this issue Dec 27, 2024 · 0 comments
Open

Syntax: preserve last/named match from a discarded branch #6574

eugenesvk opened this issue Dec 27, 2024 · 0 comments
Labels

Comments

@eugenesvk
Copy link

eugenesvk commented Dec 27, 2024

Problem description

There is a sytnax with dedenting
(all numbers here represent different types of spaces literal spaces are only used for alignment)

my_dedented_string = "
12   line1 with indent of 2 spaces, 12 removed
123  line2 with indent of 3 spaces, 12 removed, 3 stays
21   line3 with indent of 2 WRONG spaces, so ERROR
12"  closing line defines the exact indentat should be removed (order and type)

I'd like to have the information from (12)" matching group from the end of the string to be available for comparison at the beginning of the string.

I think there is a way to get to the closing string in a branch, match whatever is before the last ", then fail that branch, then backtrack and switch to another branch.

But then this match before the last " is lost!

Preferred solution

Preserve the last match from the failed branch in a \1, or better yet, in some named dedent variable scoped to the whole branch

Alternatives

Maybe this more general proposal could also work #2912, though my shallow understanding is that it's mostly about carrying some information "forward" (matching new tag to old ones), but maybe a parameter can be recorded in a faild branch as well?

Or maybe there is an even better non-branching solution?

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants