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

Regex bug on custom <ws> #1222

Open
tisonkun opened this issue Oct 30, 2017 · 14 comments
Open

Regex bug on custom <ws> #1222

tisonkun opened this issue Oct 30, 2017 · 14 comments
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@tisonkun
Copy link
Contributor

grammar { token ws { \s+ }; token zs { \s+ }; token TOP {['if' | 'if' <.zs> 'else'] $} }.parse("if else").say # OUTPUT: «「if else」␤»

grammar { token ws { \s+ }; token zs { \s+ }; token TOP {['if' | 'if' <.ws> 'else'] $} }.parse("if else").say # OUTPUT: «Nil␤»

zs was used to confirm ws was treated as non-declarative, even after you've redefined it in a declarative way.

@ugexe
Copy link
Member

ugexe commented Oct 30, 2017

Same issue as Raku/nqp#367 when naming a match after an internal cursor method (that also affects the cursors state).

@tisonkun
Copy link
Contributor Author

@ugexe Raku/nqp#367 is closed, but the issue still exists. How about it?

@ugexe
Copy link
Member

ugexe commented Nov 25, 2017

I’ve closed all my perl6 related PRs and issues.

@tisonkun
Copy link
Contributor Author

tisonkun commented Nov 25, 2017

So it remains? I wonder if I can close this issue.

@zoffixznet
Copy link
Contributor

I wonder if I can close this issue.

The bug still exists. Don't close.

@moritz
Copy link
Member

moritz commented Nov 25, 2017

@ugexe may I ask why?

@ugexe
Copy link
Member

ugexe commented Nov 26, 2017

@moritz you can read more here.
However this is not nuclear option blackmail, contrary to what messages someone may be portraying this as (and which i hope the fact I’ve not pulled modules from the ecosystem or similar would suggest). Simply put I had been drained of my energy through negativity in my public dealings in the perm 6 community. Now I’m also being provoked to defend myself for closing my own PRs/issues I lack the wherewithal to support (not per this inquiry). Cutting those out sends a message while simultaneously distancing myself from the source draining my energy in the first place.

And here is the thing: I did not make any demands. I did say I would come back when I witnessed a change in attitude, but some have construed this as some type of ultimatum or demand. Unfortunately I think the fact that I did not give a concrete way to resolve this has brought me further animosity, yet i cannot give such an answer. And the answer may require time and self reflection, which is not a satisfactory to someone looking for that concrete right-now resolution path.

I did not like what I was experiencing. I cut ties and backed out until the problem resolved itself, if ever. And now I’m experiencing additional problems for bringing this up period in my own way instead of what someone else thinks they might have done. I can use all this energy towards something productive, and maybe that includes perl 6 again sooner than later... but right now it’s a net negative for me (and strangely only getting worse).

@moritz
Copy link
Member

moritz commented Nov 26, 2017

Thank for the explanation @ugexe, I totally missed that other thread.
I'm sorry that working on Perl 6 caused emotional stress to you. I've been in a similar position at times, and have drawn back for a while. My selfish part hopes that you come to contributing more to Perl 6 eventually.

@lucasbuchala lucasbuchala added the regex Regular expressions, pattern matching, user-defined grammars, tokens and rules label Mar 15, 2019
@JJ
Copy link
Collaborator

JJ commented Jun 1, 2019

Ping?

@tisonkun
Copy link
Contributor Author

No idea what's going on. Feel free to open another issue if it still exists

@AlexDaniel
Copy link
Contributor

It's still there.

@AlexDaniel AlexDaniel reopened this Aug 21, 2019
@tisonkun
Copy link
Contributor Author

tisonkun commented Sep 8, 2021

As #1222 (comment), close this one. Please file another to continue the discussion if any.

@lizmat
Copy link
Contributor

lizmat commented Nov 13, 2023

Reopening because this issue., although related, still exists while the problem of Raku/nqp#367 was fixed.

@lizmat
Copy link
Contributor

lizmat commented Nov 13, 2023

Turns out this is not a shadowing issue at all, but an LTM issue:

% raku -e 'grammar { token ws { \s+ }; token TOP {[if <.ws> else | if] $} }.parse("if else").say'
「if else」

The custom <ws> token blocks Longest Token Matching.

Changing the order of the alternatives does make it match. According to jnthn, this is because if there are multiple alternatives with the same length declarative prefix, it will try them in order.

Removing https://github.com/Raku/nqp/blob/main/src/QRegex/NFA.nqp#L376-L383 would allow a custom <ws>to become part of LTM, but this could potentially break code in the wild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules
Projects
None yet
Development

No branches or pull requests

8 participants