At 4:52 PM +0100 3/19/03, Matthijs van Duin wrote:
On Wed, Mar 19, 2003 at 10:40:02AM -0500, Dan Sugalski wrote:
By compile-time interpolation. <foo> isn't so much a subroutine as a macro. For this to work, if we had:

  foo: \w+?
  bar: [plugh]{2,5}

then what the regex engine *really* got to compile would be:

(\w+?) ([plugh]{2,5})

with names attached to the two paren groups. Treating them as actual subroutines leads to madness,

Ehm, Foo.test cannot inline Foo.foo since it may be overridden:


grammar Foo {
        rule foo { \w+? }
        rule bar { [plugh]{2,5} }
        rule test { <foo> <bar> }
}

grammar Bar is Foo {
        rule foo { <alpha>+? }
}

What you say is only allowed if I put "is inline" on foo.

At the time I run the regex, I can inline things. There's nothing that prevents it. Yes, at compile time it's potentially an issue, since things can be overridden later, but that's going to be relatively rare, and can be dealt with by selective recompilation.


By the time the regex is actually executed, it's fully specified. By definition if nothing else--you aren't allowed to selectively redefine rules in the middle of a regex that uses those rules. Or, rather, you can but the update won't take effect until after the end of the regex, the same way that you can't redefine a sub you're in the middle of executing. (And yes, I'm aware that if you do that you'll pick up the new version if you recursively call, but that won't work with regexes)

continuations don't quite work

Care to elaborate on that? I'd say they work fine

There's issues with hypothetical variables and continuations. (And with coroutines as well) While this is a general issue, they come up most with regexes.


We do, after all, want this fast, right?

Ofcourse, and we should optimize as much as we can - but not optimize *more* than we can. Rules need generic backtracking semantics, and that's what I'm talking about.

No. No, in fact they don't. Rules need very specific backtracking semantics, since rules are fairly specific. We're talking about backtracking in regular expressions, which is a fairly specific generality. If you want to talk about a more general backtracking that's fine, but it won't apply to how regexes backtrack.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to