Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Bernhard (4508)

https://www.xing ... hard_Schmalhofer

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
github: []
LinkedIn: []
XING: []

Journal of Bernhard (4508)

Sunday November 28, 2004
10:17 AM

Parrot YAML ain't machine language

[ #22034 ]

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
print 10;
bernhard@linux:~/devel/Parrot/parrot/languages/python> ./ > hello_10.past
bernhard@linux:~/devel/Parrot/parrot/languages/python> more hello_10.past

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

) # _options
   ) # Py_Print
   ) # Void
  ) # Stmts
) # Py_Module
# end
) # Parrot_AST
bernhard@linux:~/devel/Parrot/parrot/languages/python> ../../parrot hello_10.past

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
     print "before\n"
     print "after\n"

bernhard@linux:~/devel/Parrot/parrot> ./parrot eval_9.imc

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".

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.