Here are my profile runs:
Old -- what I started with. Profiling the expansion of 14 pretty large BML pages. Note that bml_block is at 50% ... ouch. This made me suspect my parser was bad, but bml_block is a pretty light function. Still ... what hurts is that 15% for do_line.
After, 1 -- with the new parser. little better. do_line is totally gone now... deleted that function. the parser is more iterative now than it was before. but why is bml_block still so high? oh, damnit --- i have an eval call in there for _CODE blocks.
After, 2 -- moved the eval inside a new function, eval_code, which bml_block calls. now you can see it's really the eval that's slow (which makes sense --- that's perl parsing the perl in the BML)
I'm not done yet, but I gotta go for a bit. I'll continue to post results as the night goes on. There's a lot of obvious stuff to fix still, but I really wanted to rewrite the parser first, since it was so ugly.