Patrick R. Michaud wrote:
On Tue, Sep 14, 2004 at 12:42:59PM -0700, Larry Wall wrote:
I agree that the default should be the current outer language.
I agree that the default ought to be overridable.
I agree that the right way to do that is with something like "use PIR;"
rather than inventing an inconsistent syntax.
/me starts to make an observation that making it look like perl6 when it's not is paramount to lying to our users, but decides to invoke rule 1 in his mind.

I'm assuming s/outer language/inner language/g in the following, as it makes no sense otherwise...
What should the mechanism be for the rule parser to figure out where a closure begins and ends within a rule expression? Does the rules
parser have to call the outer language compiler directly?

If so, does this imply that the rules parser has to be running in Parrot to be able to call the outer language compiler, or is there a way to do this from C?
It has to either be within Parrot or embed Parrot, as most of the language compilers are written in PIR.

And does the outer language compiler have to have options that
allow the caller to say: "hey, here's some program code with perhaps a bunch of rule-syntax stuff appended to it, could you just give me back the first complete 'closure unit' and oh, by the way, tell me how many characters you used to do it or give me the left-over string so
I can continue parsing my stuff?"
Not presently, but there should be. (And there should be an extra, optional, argument to the compile opcode to pass in options like this.)

(The interface should probably be to consume the used portion of the S register passed in.)

Or is there some syntactic shortcut that can be made to let us find
the end of a closure without having to fully parse the closure itself?
Well, we could do that for the time being, in which case, I suggest the end condition be a m:5/^}\s*/ line.

How does p5 do it?
To quote perlre, "Currently, the rules to determine where the "code" ends are somewhat convoluted." (Search for "(?{ code })".)

(And you can see why I've been willing to postpone true closures in rules just a bit longer until we got a p6 compiler started. :-)
Aye, I can, but if you work with p6i to get compilers to take a hint that says that they're parsing embedded code, and tell us when they're finished, and get the PIR compiler to pay attention to such a hint, then you can lob the hard bits off to the inner language compilers... and get correct semantics out of it, instead of the mostly-correct semantics that perl5 has.

-=- James Matros

Reply via email to