print "1..2\n";
has been translated by lwall's PERL5_MADSKILLS (also known as PPD) into a XML dump of the OP tree that looks like this (abridged):
<op_leave seq="1 -> DONE" targ="1" flags="VOID,KIDS,PARENS" private="REFCOUNTED" <op_leave seq="1 -> DONE" targ="1" flags="VOID,KIDS,PARENS" private="REFCOUNTED" refcnt="1">
<op_enter seq="2 -> 3"/>
<op_nextstate seq="3 -> 4" flags="VOID" line="5" package="main"/>
<op_print seq="6 -> 7" flags="VOID,KIDS">
<madprops>
<mad_pv key="o" val="print"/> </madprops>
<op_pushmark seq="4 -> 5" flags="SCALAR"/>
<op_const seq="5 -> 6" flags="SCALAR" PV="1..2 ">
<madprops> <mad_op key="F">
<op_stringify seq="39 -> DONE" targ="1" flags="SCALAR,KIDS"> <op_null seq="0 -> (40)" was="pushmark" flags="SCALAR"/> <op_const seq="40 -> 39" flags="SCALAR" PV="1..2 ">
<madprops><mad_pv key="X" val="1..2\n"/></madprops>
</op_const>
</op_stringify>
</mad_op>
<mad_pv key="o" val=""1..2\n""/> <mad_pv key="_" val=" "/>
<mad_pv key="(" val=""/>
<mad_pv key=")" val=""/> </madprops>
</op_const> </op_print>
</op_leave>
This, in turn, goes through a xml2pl program in Perl 5 that turns it into a P5AST object. After that, the object is dumped into Haskell expression:
P5AST [ OpLeave [ OpPrint [Items [ ] , Items [ Bare " " , OpConst [Bare "\"" , OpStringify [Bare "" , OpConst [Bare "1..2\\n" ] , Bare "" ] , Bare "\"" ] ] ] ] ]
...
Pugs's new Pugs.Frontend.P5AST module takes that expression, then compile to a Pugs parser tree of the Exp type:
Stmts (App (Var "&print") Nothing [Val (VStr "1..2\n")]) Noop
After that, the Pugs.Compile module takes over and turn it into a PIL intermediate code expression:
PStmts PNoop (PStmts (PExp (PApp TTailCall TCxtVoid (PExp (PVar "&print")) [PLit (PVal VStr "1..2\n"])) PNil))
Which can emit this very much unoptimised PIR code:
.sub "main" @ANON
.local pmc P1263_lex
P1263_lex = new.PerlUndef
P1263_lex = find_name "&print"
.local pmc P1264_lit
P1264_lit = new.PerlUndef
P1264_lit = assign "1..2\n"
.local pmc P1265_app
P1265_app = new.PerlUndef
set_args '(16)', P1264_lit
get_results "(0)", P1265_app
invokecc P1263_lex
.end
...and Parrot happily runs it and prints the string. Pretty cool, no? Especially cool is that we are getting the P5AST in its desugared (post-source filter) form, so it's indeed using perl to parse Perl.
Historic, no? (Score:2)