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

eggex 'a'{N *} crashes, needs a proper error #1895

Closed
glyh opened this issue Apr 4, 2024 · 6 comments
Closed

eggex 'a'{N *} crashes, needs a proper error #1895

glyh opened this issue Apr 4, 2024 · 6 comments

Comments

@glyh
Copy link
Collaborator

glyh commented Apr 4, 2024

$ = / 'a'{N *} / 
ysh: _gen/bin/oils_for_unix.mycpp.cc:50177: syntax_asdl::re_repeat_t* expr_to_ast::Transformer::_RepeatOp(pnode::PNode*): Assertion `0' failed.
fish: Job 1, 'ysh' terminated by signal SIGABRT (Abort)

Oils 0.21.0 https://www.oilshell.org/

git commit = cc2f683

@glyh
Copy link
Collaborator Author

glyh commented Apr 4, 2024

Looks like this is simply unimplemented.

# Haven't implemented the modifier, e.g. x{+ P}

Also representing something like "term repeating 1 ~ 4 times non-greedily" doesn't seem to have an elegant solution for now.

@glyh glyh changed the title eggex nongreedy operator is broken Implement nongreedy eggex quantifiers Apr 4, 2024
@glyh
Copy link
Collaborator Author

glyh commented Apr 4, 2024

If there'll be a refactor I guess it would be nice to have something like https://docs.raku.org/language/grammars

@glyh glyh changed the title Implement nongreedy eggex quantifiers Implement non-greedy eggex quantifiers Apr 5, 2024
@andychu
Copy link
Contributor

andychu commented Apr 6, 2024

In Oils, we use libc regcomp() / regexec() which only supports POSIX ERE, which doesn't have greedy like Perl/Python

So this should definitely not crash, but it will still be a parse error.

Or we can parse it, and allow people to export to the AST, so they can translate it to Python/Perl syntax

@andychu andychu changed the title Implement non-greedy eggex quantifiers eggex 'a'{N *} crashes, needs a proper error Apr 6, 2024
@glyh
Copy link
Collaborator Author

glyh commented Apr 6, 2024

I think at least user should be able to use eggex to match in a if statement.

andychu pushed a commit that referenced this issue Apr 12, 2024
Rather than an assertion.

Perl-style operators can't be translated to POSIX ERE (implemented by
libc)

This is issue #1895.
@andychu
Copy link
Contributor

andychu commented Apr 12, 2024

This is now a proper parse error

Not sure what you mean, the problem here is that Oils uses libc, which supports POSIX ERE, not Perl-style repetition

'a'{N *} is supposed to be a*? -- nongreedy repetition

In theory eggex can be translated to Perl-style engines, but we don't have that

@andychu
Copy link
Contributor

andychu commented Jun 20, 2024

@andychu andychu closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants