in reply to Regex Report

When you post this, please be sure to not leave important parts of the grammar in inaccessible lexicals. I tried to do something once with YAPE::Regexp but had to write Re: Stealing lexicals - best practice suggestions just to get access to the grammar in my %pat. That really sucked. The only change I really needed was to have %pat be a global so it'd be re-useable.

Purty please? Won't you think of the children?

Replies are listed 'Best First'.
Re^2: Regex Report
by japhy (Canon) on Jun 28, 2004 at 13:39 UTC
    Heh, sorry. You'll be happy to know all the grammar is stored (gasp?) as methods of the object. This means you have method names like "(" and "[" and "|". If you think this is blasphemous, tough cookies. In fact, the only non-weird looking method name is "atom", which is the starting node for the grammar.

    Another thing. Right now, the grammar is determined on the fly. That is, each rule (upon successful match) tells the object what possible rules follow it. Perhaps I should implement that differently.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      So there's code that looks like $next = List::Util::first { eval { $self->$_ } } @tokens? Oof. Holey AUTOLOAD batman! Why not just make the token a parameter to some function instead of passing the value via the function name? Or is this so you can get overriding? When do we get to see this code and are you sure you couldn't have written this using a mundane method?

        Rules are methods of the object so that object inheritence works easily. Data is not inherited easily, methods are.
        _____________________________________________________
        Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
        s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;