src/rxstacks.c - Regex stack handling routines for Parrot


Same as regular stacks, except they store only INTVAL values and don't have cleanup routines.

Functions ^

IntStack intstack_new(Interp *interpreter)

Creates and returns a new stack.

INTVAL intstack_depth(Interp *interpreter, IntStack stack)

Returns the depth of the stack.

void intstack_push(Interp *interpreter, IntStack stack, INTVAL data)

Pushes data onto the stack.

INTVAL intstack_pop(Interp *interpreter, IntStack stack)

Pops the top value off the stack and returns it.

void intstack_free(Interp *interpreter, IntStack stack)

Frees all the memory used by the stack.


src/rx.c, include/parrot/rx.h, src/rxstacks.c, include/parrot/rxstacks.h>.


You'll note that src/intlist.c and src/rxstacks.c both claim to do the stack handling. Steve Fink explains why:

The integer stack is fairly useless for a complete regex engine. It prevents reentrancy and complicates some of the trickier things that need to be done in regexes. We can drop it anytime, and instead use an integer-only array PMC instead. (Such a PMC exists and is called "intlist.pmc", and uses the same stack engine as the control, user, and pad stacks.)

I would remove the rxstack, but I didn't want to break the closest thing we have to a regex engine until I or someone else managed to release a different working implementation. The particular technique of using a single stack tied directly the interpreter is an evolutionary dead end, however. Good for a proof of concept, but that's it.