On Sat, Apr 16, 2005 at 06:28:37PM +0300, Roie Marianer wrote:
: Hi all.
: 
: I'm trying to get quoting interpolation to work, which means I first have to 
: understand it a little better.
: 
: In Perl 5, as far as I can see, the delimiter of quoting constructs (whether 
: it's "", '' or qq <delim>) is searched for before the string is parsed. This 
: means that, for example, 
:  "%hash{"string value"}"
: parses as 
:  "%hash{" 
: which is a syntax error.
: 
: Current behaviour in Pugs is to read anything that interpolates until its 
: logical conclusion, so that for example
:  "{"a"}"
: is 'a', and not a syntax error. I think this behaviour is more useful than 
the 
: old behaviour when it's not ambiguous. (By the way, this behaviour is my 
: fault, so it's not authoritative in any way)

Please rest assured that that behavior, is, in fact, mandated.

: My suggestion is to check for delimiters only when it's ambiguous: Inside a 
: variable name (qq x$varxy -> "$var"y), and at the beginning of every 
: subscript of a scalar, and every subscript after the first one of an array, 
: hash of sub (because in these cases the first subscript is mandatory).

The basic rule of thumb is that we pretend we're a top-down parser
even if we aren't, and we only look for the trailing delimiter when
we're not trying to parse something embedded that would naturally
slurp up the trailing delimiter as part of the internal construct.
Certainly any kind of bracketing structure hides anything inside it
from the delimiter scanner, but so do tokens like identifiers.

: By the way, maybe it's not even an issue: Is it possible for the closing 
: delimiter of a string to be an opening bracket or brace?

Nope, if you open with an opener it only looks for the closer.

: In Perl 5, if a 
: quote is opened by a closing brace it must be closed by the same closing 
: brace, while in current Pugs an opening closing brace is closed by a closing 
: opening brace:
:  Perl5: q]a]  Pugs: q]a[
: both mean 'a'. If the Perl 5 behaviour is maintained, then there is no chance 
: at all of ever mistaking a subscript for a closing delimiter, which makes the 
: only special case qq x$varxy.

I think I would prefer the Perl 5 behavior here, or maybe we should
simply disallow closers as openers.  As Juerd points out, it really
makes little sense to allow alphanumerics either, especially now that
we Âallow ãanyã ãUnicodeã ãbracketsã ãtoã ãbeã 
ãusedã.

And inside-out brackets are just going to drive highlighters absolutely
bonkers, though arguably the same could be said for q]a], only more so.

: Sorry for being long-winded; does this make any sense at all?

Yep, it makes any sense at all.

Larry

Reply via email to