denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)
Denise ([staff profile] denise) wrote in [site community profile] dw_dev2011-04-18 04:37 am

o.O

Regular Expression Generator

Billed as "headache relief for programmers".

(Insert applicable jwz quote about regular expressions here.)
eftychia: Me in poufy shirt, kilt, and Darth Vader mask, playing a bouzouki (vader)

Re: What, no sed/vi/vim/ex language button?

[personal profile] eftychia 2011-04-19 06:22 am (UTC)(link)
I may take you up on that, once I get around to looking in detail at what those tools will and won't do for me. I do have a tendency to push things kind of far with sed -- my gut instinct whenever an RE situation comes up and it's not in an interactive editing session, is to say, "Oh, just run it through sed; that's what pipelines are for." Or worse yet, "It's late and I always screw something up when I try to use sscanf() -- screw it, pipe it through sed, dc, sort, and then sed again, and I won't even try to capture anything until all the math is already done. This works disgustingly often, but as I get farther from "grab the nth space-delimited word" or "extract columns n through m" and more into "insert this token after the first of this type of token that has these allowable forms and before the next of that other type of token that has eight optional constituent parts I might have to recognize" territory, my sed scripts are getting longer and I start thinking "maybe I should treat this grammar as, like, a grammar someday".

But no, I'm not sure I'm actually into 'heavyweight' parsing yet. (I'm not sure where the line is generally considered to be, but I tend to categorize problems as "my first thought before serious analysis was to use sed," and "my first thought before serious analysis was that I'd wind up writing a state machine". I'm thinking heavyweight would be, "yeah, I can do this with my old tools but it's not gonna be fun.") Hmm.

You've probably guessed by now that I'm not using Perl much, because I probably wouldn't be reaching for sed and dc as often if I were.
vlion: cut of the flammarion woodcut, colored (Default)

Re: What, no sed/vi/vim/ex language button?

[personal profile] vlion 2011-04-21 03:05 pm (UTC)(link)
Loosely, when you have to track the number of things on each side, you need to jump off into parsing.

Here's a problem sample that requires parsing - say you want to write a program that does a call graph of perl.


Program goes in, graph that tracks what function calls what comes out.

You can't explain that with regex alone.


FWIW, it's a mildly annoying problem i need to solve one of these days. Last run I took at it left me bleeding in the lambda and class methods.