A freelance software engineer with experience in webapplications, databases and bioinformatics.
A contributor to Parrot and the person behind Pipp.
A physicist who worked with third sound in Helium-III and CCD X-ray detectors.
barney on irc.perl.org
github: http://github.com/bschmalhofer [github.com]
XING: https://www.xing.com/profile/Bernhard_Schmalhofer [xing.com]
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, Parro abstract syntax tree As Simple Text.
bernhard@linux:~/devel/Parrot/parrot/languages/python> cat hello_10.py
./ast2past.py hello_10.py > hello_10.past
bernhard@linux:~/devel/Parrot/parrot/languages/python> more hello_10.past
# generated by ast2past.py on Sun Nov 28 16:06:29 2004
) # _options
) # Py_Print
) # Void
) # Stmts
) # Py_Module
) # Parrot_AST
I have been trying to make that functionality available as a Parrot registered compiler. After making some educated guesses, it looks like it might be working.
bernhard@linux:~/devel/Parrot/parrot> cat eval_9.imc
.sub main @MAIN
.local pmc past_compiler
past_compiler = compreg "PAST"
.local string past_source
past_source = 'Parrot_AST( Py_Module( Stmts( Py_Print( Const(9) ) ) ) )'
.local pmc past_compiled_sub
past_compiled_sub = compile past_compiler, past_source
I still need to check wether the python tests are still working. If so I could add and some AST compiler tests.
The idea of Abstract Syntax Trees is mostly that the representation, that is the programming language, doesn't matter much. So it should't be hard to add support for any other tree format. For example one could use YAML. This might bring future support for Parrot YAML, which is an acronym for "Parrot YAML Ain't Machine Language".