Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Regex from XS

by hv (Parson)
on Apr 10, 2006 at 00:37 UTC ( #542197=note: print w/replies, xml ) Need Help??

in reply to Regex from XS

I haven't tried to do this, but I'd start by unravelling the code in pp_hot.c:pp_match(), and see if you can extract from that the infrastructure you need.

The guts is incorporated in the CALLREGEXEC() macro, which (via a pluggable hook, used by the re module) makes its way to regexec.c:Perl_regexec_flags() where the actual match happens - the regexp compile already happens before this - and setting things up correctly before that call is the critical bit.

It would certainly help if you can find prior art - if you have a greppable CPAN mirror handy, a search for CALLREGEXEC and/or regexec_flags should tell you if there is any to be found there.

Time permitting, I'd be happy to help debug any problems you run into, feel free to give me a shout.


Replies are listed 'Best First'.
Re^2: Regex from XS
by creamygoodness (Curate) on Apr 12, 2006 at 04:40 UTC


    Thanks for the kind offer. I understand a bit more about the Perl executable now, and I understand why, in the only previous info I could find on the subject (a Nick Ing-Simmons p5p post), it's stated that you can't do this without "faking an op".

    There doesn't appear to be prior art for this. While I don't happen to have a greppable mirror, Google indexes .pm, .xs, .c, and .h files, and a Google search for those terms limited to doesn't turn up anything useful.

    I banged my head against pp_hot.c for a while, but there's just too many things I don't understand yet. It will be a happy day when I figure out what a "shrieking SV" is. :) An awful lot happens in pp_match, so the right route is presumably "fake an op" and call pp_match directly, rather than duplicate its innards.

    However, manipulation of the op tree is beyond me right now. It doesn't look like this is as simple as calling a couple macros that aren't listed in perlapi, and while I'm very interested in continuing to study the subject, I haven't got time right now to dig this deep in one go. Thanks a bunch for helping me to frame the problem.

    Marvin Humphrey
    Rectangular Research ―

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://542197]
[GrandFather]: However, by the end of the day I had discovered its deceptions and now have it working correctly, so yes, all's well that ends well. :-D
[Corion]: GrandFather: Ah, (hardware) APIs - I have a similar situation with Chrome and its API... It is fairly underdocumented and I guess I have to hunt...
[Corion]: ... down supposedly working code to find out what I'm supposed to do
[GrandFather]: I haven't any "working code" to inspect! I have to find ways to generate reference signals then check the numbers I get at the far end match.
[GrandFather]: That's ok when the signal is a voltage, but there are three axis accelerometers, gyroscopes and magnetometers in these things! A little invention is needed at times!
[Corion]: GrandFather: Yeah, in that aspect, hardware is far more a black box than software
[GrandFather]: Oh, and the manufacturer tells lies too! I'm sure they don't mean to, but I know for sure some of the stuff they say is just wrong. It's possible they don't understand what we are asking, but that's not a good look either
[Corion]: GrandFather: Ah, unit testing hardware is fun, especially when the hardware is uncalibrated ...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-08-24 07:11 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (365 votes). Check out past polls.