-
Notifications
You must be signed in to change notification settings - Fork 745
Expanded RegEx Support? #2432
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
Comments
Maybe you're getting bitten by this: https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#regular-expression-arguments |
I did not think so. I did try with and without the ^$ and the regex works in either case as long as I'm not using the negative lookahead |
I'll try again without them. |
removing the ^ and $ had no effect, the regex still matches nothing now. |
Hmmm ok yeah I get what you mean. Sadly That being said, I think changing the For the time being a workaround would be to use the |
or maybe conditionally use fancy-regex? :) sigh... I'm so close to not needing to use the parsecallbacks |
at a minimum... should this panic if it tries to compile a regex with a feature we don't support (hopefully yet)? |
I agree
Yeah I agree, right now we emit a |
@hcldan I have news! So regarding diagnostics, I'm working on a little something to actually display warnings and I'll have something ready soon. About the actual issue you're having I think we might That being said I'm not sure if
If we could solve these issues, we could move forward. |
I was hoping to read in that ticket you linked that they would add support for lookaround via a crate feature... |
maybe? It all depends on the order/labeling of the groups. If someone passes the regexes Even if groups are named it could be that users name their groups for some odd reason. We would have to use some obfuscated enough names to do so. |
Where are the regexes being smooshed together? I can certainly understand that people want performant regex, and I would not mind at all if the features that make it potentially less-performant were roped off into a feature... It's a hack but I'd be fine with doc that says: "don't use names like this" or something. Is it really that much less performant to run n different regexes than 1 regex that's a concatenation of all n? |
Alternatively.... do you know of a way that I can write a derive macro to fail silently, without an error and not actually implementing the trait, based on some logic I have in the macro? Can I fail without a panic and just have the type not be derived? It's certainly not ideal to have it labelled as #[derive(Thing)] and have it not actually be derived... |
For the record, I'm not saying that we shouldn't have this. Just that we have to figure out the best way to handle it.
No, we use
I'd say yes. The extreme scenario would be having two expressions that only differ in the last symbol. Their automaton would be the same except for the last transition. If I understand correctly, if you had something like
Well you would have to define your own derive macro crate for that. But If I were to do that, I'd do the name handling there instead of relying it to bindgen. |
Oh, I know. I very much appreciate the discussion here. I'm just exploring options. |
I went down that path. I'm not thrilled of having a derive trait that just doesn't do it. I found a way to emit warnings, but I still feel uneasy about devs seeing a derive and it not having those traits. Oh well. I'm unblocked, and while it would be cool to have lookarounds for this project, I get why it might be an issue. I guess this issue can just fill the need to emit an error/warning for patterns that aren't supported. |
We're working already on the diagnostics part. Yeah if we can figure out a way to make fancy-regex work maybe we can give it a try. |
@pvdrz
Following on the heels of #2328 ... I've changed to start using the new option and it's working great but I ran into a snag...
Some of the older c libs that I'm using have structs that don't always follow proper naming patterns.
Rather than having to exclude them from the bindgen, I'd like to just filter them from having a derive applied to them.
Here's a sample of the RegEx I was trying to use:
https://regex101.com/r/pjeUkB/1
Basically, If the struct starts with "My" and doesn't contain
Foo
in it, then apply the derive.This doesn't seem to work, and seems to silently ignore the regex. Am I doing this wrong?
This doesn't seem to match anything. I have verified that this does though:
But it matches the ones I don't want as well.
Does the regex impl in use not support lookahead or negative lookahead?
I would have expected the regex compile to fail or something.
Bindgen Invocation
Actual Results
No structs are labeled with a MyStructTrait derive.
Expected Results
I expect to see:
The text was updated successfully, but these errors were encountered: