On Tue, Dec 12, 2006 at 09:43:39AM -0800, Allison Randal wrote:
> Patrick, what's the best way to pass-through string types from a 
> compiler to Parrot without doing full string processing? To pass the 
> current tests, Punie only needs Parrot's single- and double-quoted 
> strings, but Past-pm is escaping them. 

PAST-pm expects it to be pretty rare that a HLL's string literal
format will exactly match what works as a string literal in PIR, so 
PAST::Val nodes expect the HLL to have already decoded the string
constant according to whatever rules the HLL uses.  Then PAST-pm
can re-encode the string into a form that is guaranteed to work
in Parrot (even handling things such as placing "unicode:" in
front of PIR string literals if the string has characters that
fall outside of the ASCII range.)

I can modify PAST-pm to provide a "send exactly this string to PIR" 
option for PAST::Val.  More generally useful would seem to be to 
provide a generic function or opcode that can decode single/double 
quoted strings according to PIR's encoding rules, and then use
that to get the string into PAST::Val.

PGE::Text could provide such a feature as part of its library-- i.e., 
subrules like:

    " <PGE::Text::pir_quoted_string: "> "
    ' <PGE::Text::pir_quoted_string: '>  '

could parse a valid pir string literal and provide the
decoded value as the result object.

> (I will add full string processing to Punie later, but since other 
> compilers will also need basic Parrot string types, it makes sense to 
> figure it out now.)

I think that the various languages have enough differences in
string literal handling that each compiler will end up writing 
its own string literal decoder.  (Or we need a semi-powerful library
to handle the many differences.)  In the meantime having an 
easy-to-access subrule for "just pretend it's a quoted literal 
according to PIR conventions" might be a good way for someone
wanting to bootstrap a compiler, without placing Parrot-specific
encodings into PAST-pm.

Lastly, I'm still working out the handling of HLL to Parrot
type mappings -- it's also possible that some of this will
fall out as a result of that.

Pm

Reply via email to