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

Dynamic cap count #27

Open
IngwiePhoenix opened this issue Mar 20, 2016 · 4 comments
Open

Dynamic cap count #27

IngwiePhoenix opened this issue Mar 20, 2016 · 4 comments

Comments

@IngwiePhoenix
Copy link

Well, I want to use SLRE in my project, which consists of just a tiny scripting language and tiny extensions. My goal is to use SLRE to introduce RegEx support to it. The problem is that, in the nature of a scripting language, the user might supply multiple capture groups.

That is why I want to ask: How can I best count the capture groups in the buffe,r and then perform matching? I could just go through the buffer and look for (s, but maybe there is an easier method?

@IngwiePhoenix
Copy link
Author

I had a friend of me code a solution for me. He is still a student and learning coding, but I thought it might be good practice for him.

https://gist.github.com/IngwiePhoenix/1a060d80469390b2c142

likely not the most reliable solution, but definitively one that'll work :)

@sebgod
Copy link

sebgod commented Oct 24, 2016

I've coded up something like this in a fork https://github.com/sebgod/slre/commits/introduce-slre_compile-function not sure if that still merges.

@Airr
Copy link

Airr commented Nov 10, 2018

Would it be as simple as copying the value of variable "bi" (lines 282-284, where the sub-matches are captured) to global var and reference that? I did that for an add on for a scripting language and it seemed to work.

In slre.h, I did:
extern int ar_match_count;

And in slre.c, after line 284, I added:
ar_match_count=bi;

ar_match_count is declared in another file.

@IngwiePhoenix
Copy link
Author

@Airr
Interesting idea. I might have to try this out one day. :)

@sebgod
Will look into this later. I somehow never saw this reply, but I will get to looking into the fork soon. Thanks for posting that. :)

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

3 participants