"Patrick R. Michaud" <[EMAIL PROTECTED]> wrote:
:How does p5 do it?

Brokenly. It looks for balanced curlies unintelligently; try:
  perl -we '/(?{ "})" })/'

I'd expect p6 rules to be parsed using a grammar, and within such
a context to invoke the 'closure' rule; it's that rule that'd have
the responsibility of knowing where to start and stop, and what
language it's supposed to be reading. I'd expect it to discover
the language initially from independent contextual information
(ie C< use rx deflang('PIR') >), but be able to switch based on
the string being parsed (ie C< m/{use grammar 'PIR'; ...}/ >).

It does get tricky if the language you're parsing does (or can) use
'}' in an unbalanced manner, the equivalent of a perl5/6 TERM
starting with a '}' that didn't close a previous '{' - I don't know
how you'd decide in that case which '}' terminates the closure, but
that's a problem for the grammar implementing 'closure' in that
language, not for the 'rule' parser per se. I think that simply
means that not every language can embed every language in this way.

Hugo

Reply via email to