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

Problem with duplicate variables #1

Open
a3nm opened this issue Aug 29, 2019 · 1 comment
Open

Problem with duplicate variables #1

a3nm opened this issue Aug 29, 2019 · 1 comment

Comments

@a3nm
Copy link
Collaborator

a3nm commented Aug 29, 2019

There seems to be a problem when there is a disjunction with the same variable name on both sides:

$ echo "aa" | cargo run --release -- -b "(?P<a>.)|(?P<a>.)" 
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/enum-spanner-rs -b '(?P<a>.)|(?P<a>.)'`
thread 'main' panicked at 'Invalid regexp syntax: Parse(Error { kind: GroupNameDuplicate { original: Span(Position(o: 21, l: 1, c: 22), Position(o: 22, l: 1, c: 23)) }, pattern: "(.|\\s)*(?P<match>(?P<a>.)|(?P<a>.))(.|\\s)*", span: Span(Position(o: 30, l: 1, c: 31), Position(o: 31, l: 1, c: 32)) })', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

There is no such problem in the Python implementation:

echo "aababaababa" | ./main.py "(?P<group_a>a+)(?P<group_b>b+)|(?P<group_b>b+)(?P<group_a>a+)"`

It seems that this could be a limitation of the Rust library for regexps? http://getsentry.github.io/rust-sourcemap/regex_syntax/ast/enum.ErrorKind.html#variant.GroupNameDuplicate

@remi-dupre
Copy link
Owner

Yes , I think tout are right: the error is raised by Rust's regex crate. I don't think that it can easily be tweaked though :(

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

No branches or pull requests

2 participants