Parrot speaks more languages

François Perrad francois.perrad at gadz.org
Mon Jan 12 14:44:48 UTC 2009


I saw the Stephen Weeks's blog : 
http://blogs.gurulabs.com/stephen/2009/01/parrot-speaks-your-language.html

So, I update some of my languages Markdown(r35437) & Lua (r35438)
with the proper interface.

Now, we can write
   $ cat markdown.p6
   my $markdown := q{
Title
=====
Some text (could be useful for a Wiki).

   };

   say eval($markdown, :lang<markdown>);

And
   $ cat lua.p6
   eval(q<print 'hello'>, :lang<lua>)

but here without success

Program received signal SIGSEGV, Segmentation fault.

(gdb) bt
#0  0x687412c3 in pmc_new_noinit (interp=0x3f4178, base_type=0)
     at src/pmc.c:335
#1  0x6873f826 in thaw_create_pmc (interp=0x3f4178, info=0x22fa50, type=0)
     at src/pmc_freeze.c:1305
#2  0x6873fa14 in do_thaw (interp=0x3f4178, pmc=0x0, info=0x22fa50)
     at src/pmc_freeze.c:1391
#3  0x68740388 in visit_todo_list_thaw (interp=0x3f4178, old=0x0,
     info=0x22fa50) at src/pmc_freeze.c:1660
#4  0x6890f86b in Parrot_Object_visit (interp=0x3f4178, pmc=0x1a91ae0,
     info=0x22fa50) at src/pmc/object.pmc:732
#5  0x6874061f in visit_loop_todo_list (interp=0x3f4178, current=0x1a91ae0,
     info=0x22fa50) at src/pmc_freeze.c:1733
#6  0x68740988 in run_thaw (interp=0x3f4178, image=0x1458a30,
     what=VISIT_THAW_NORMAL) at src/pmc_freeze.c:1857
#7  0x68740c79 in Parrot_thaw (interp=0x3f4178, image=0x1458a30)
     at src/pmc_freeze.c:1981
#8  0x68739159 in PackFile_Constant_unpack_pmc (interp=0x3f4178,
     constt=0x162a348, self=0x1c28ee0, cursor=0x3ee4558) at 
src/packfile.c:3723
#9  0x687396a0 in PackFile_Constant_unpack (interp=0x3f4178, 
constt=0x162a348,
     self=0x1c28ee0, cursor=0x3ee44a4) at src/packfile.c:3676
#10 0x6873987f in PackFile_ConstTable_unpack (interp=0x3f4178, 
seg=0x162a348,
     cursor=0x3ee44a0) at src/packfile.c:3466
#11 0x68734ef6 in PackFile_Segment_unpack (interp=0x3f4178, self=0x162a348,
     cursor=0x3ec8a00) at src/packfile.c:1781
#12 0x68736c44 in directory_unpack (interp=0x3f4178, segp=0x1b43368,
     cursor=0x3ec89f0) at src/packfile.c:1985
#13 0x68734ef6 in PackFile_Segment_unpack (interp=0x3f4178, self=0x1b43368,
     cursor=0x3e80060) at src/packfile.c:1781
#14 0x6873531b in PackFile_unpack (interp=0x3f4178, self=0x1b43368,
     packed=0x3e80020, packed_size=755440) at src/packfile.c:1014
#15 0x686e527a in Parrot_readbc (interp=0x3f4178,
     fullname=0x15de978 
"C:\\fperrad\\Parrot\\trunk\\.\\languages\\lua\\lua.pbc")
  at src/embed.c:530
#16 0x6873ad88 in PackFile_append_pbc (interp=0x3f4178,
     filename=0x15de978 
"C:\\fperrad\\Parrot\\trunk\\.\\languages\\lua\\lua.pbc")
  at src/packfile.c:4367
#17 0x6873afa1 in Parrot_load_bytecode (interp=0x3f4178, file_str=0xdc1238)
     at src/packfile.c:4429
#18 0x6868637d in Parrot_load_bytecode_s (cur_opcode=0xc0f5f8, 
interp=0x3f4178)
     at src/ops/core.ops:151
#19 0x6874239f in runops_slow_core (interp=0x3f4178, pc=0xc0f5f8)
     at src/runops_cores.c:228
#20 0x68702ae7 in runops_int (interp=0x3f4178, offset=20544)
     at src/interpreter.c:984
#21 0x687033c6 in runops (interp=0x3f4178, offs=20544) at 
src/inter_run.c:108
#22 0x68703617 in runops_args (interp=0x3f4178, sub=0xde3930, obj=0x9a4d78,
     meth_unused=0x0, sig=0x689ec9a7 "vP", ap=0x22febc "\210¾®\001xA?")
     at src/inter_run.c:248
#23 0x68704328 in Parrot_runops_fromc_args (interp=0x3f4178, sub=0xde3930,
     sig=0x689ec9a7 "vP") at src/inter_run.c:315
#24 0x686e5db9 in Parrot_runcode (interp=0x3f4178, argc=2, argv=0x3f412c)
     at src/embed.c:984
#25 0x689729c5 in imcc_run_pbc (interp=0x3f4178, obj_file=0, 
output_file=0x0,
     argc=2, argv=0x3f412c) at compilers/imcc/main.c:824
#26 0x6897355b in imcc_run (interp=0x3f4178,
     sourcefile=0x3f2a05 "languages\\\\perl6\\\\perl6.pbc", argc=2,
     argv=0x3f412c) at compilers/imcc/main.c:1116
#27 0x004013c4 in main (argc=2, argv=0x3f412c) at src/main.c:61
(gdb)

Direct call from PIR is OK.
   $ cat lua.pir
   .sub 'eval' :main
       .local pmc compiler, invokable
       load_bytecode 'languages/lua/lua.pbc'
       compiler = compreg 'lua'
       .local string code
       code = 'print "hello"'
       invokable = compiler.'compile'(code)
       $P0 = invokable()
   .end

François



More information about the parrot-dev mailing list