On Mon, Mar 17, 2003 at 12:14:00PM -0700, Luke Palmer wrote:
Before anyone replies, I just realized I should probably just first browse around in parrot since regex is already implemented ;-)

No---you shouldn't do that. Regex (in languages/perl6) is a naive and is due for a rewrite.

And I just realized the issue of subrules hasn't even been touched yet.


If regular subroutine invocation were used, then everything would be cleaned up rather the rule matches, and therefore there would be no way to backtrack into the subrule.

The subrule *has* to do a callback into the enclosing rule to match the remainder. That way backtracking into the subrule is simply a return. It's a simple and neat solution. (note that this isn't a continuation - when you invoke a continuation, it actually never returns)

This may start to sound a bit like perl6 implementation rather than language, but it most certainly *does* have impact on the language; specifically on the calling conventions of rules.

I have seen the following two ways to invoke a rule (in A5 etc):

Grammar.rule($matchstring)      # $matchstring =~ /<Grammar::rule>/
$state.rule()                   # <rule>:  inside another rule

Note how it's <rule>: (with colon) because without any closure passed, it can never backtrack into the subrule.

So $state.rule() must have an optional closure parameter, and Grammer.rule() probably also needs an additional optional parameter: the modifiers

This makes the class method behave rather differently from the object method.. can this be consolidated?


I've volunteered to do that (after I do the type system (no, I'm not being ambitious or anything :-P )). I'd appreciate some help in the design and implementation, so feel free to jump in!

I dunno, I'm already quite busy... but I'd say I'm helping with the design as we speak :-)



-- Matthijs van Duin -- May the Forth be with you!

Reply via email to