Bernhard Schmalhofer

Bernhard Schmalhofer

Parrot YAML ain't machine language

Published: Sun Nov 28 00:00:00 -0800 2004

In the last weeks I have used some off-work hours for looking into Abstract Syntax Tree for Parrot. It looks like this is one of the less civilised areas of Parrot, as documentation is somewhat scarce.

Leo Tötsch added support for AST when coding for the infamous Piethon bet. So far one can take a Python program and turn it into PAST, Parrot abstract syntax tree As Simple Text.

bernhard@linux:~/devel/Parrot/parrot/languages/python> cat hello_10.py
print 10;
bernhard@linux:~/devel/Parrot/parrot/languages/python&gt;<nobr> <wbr></nobr>./ast2past.py hello_10.py &gt; hello_10.past
bernhard@linux:~/devel/Parrot/parrot/languages/python&gt; more hello_10.past

# generated by ast2past.py on Sun Nov 28 16:06:29 2004

Parrot_AST(
&nbsp; version(Const('0.1'))
_options(
) # _options
Src_File("hello_10.py")
Py_Module(
&nbsp; _()
&nbsp; Stmts(
&nbsp; &nbsp;Py_Print(
&nbsp; &nbsp; Const(10)
&nbsp; &nbsp;) # Py_Print
&nbsp; &nbsp;Py_Print_nl()
&nbsp; &nbsp;Void(
&nbsp; &nbsp; Const(None)
&nbsp; &nbsp;) # Void
&nbsp; ) # Stmts
) # Py_Module
# end
) # Parrot_AST
bernhard@linux:~/devel/Parrot/parrot/languages/python&gt;<nobr> <wbr></nobr>../../parrot hello_10.past
10

About

Bernhard Schmalhofer from Munich in Germany.