Perlito - reviewing some older code

Today I've finally updated the Perlito compiler ChangeLog, this covers a little more than a year of commits.

The most significant update was the new Perlito5-to-Java backend, which is work-in-progress. It covers a lot of ground, but there is a lot more.

There were also some interesting new Perlito5-to-Javascript features, such as regex /e modifier, and file operators support in nodejs.

The Perl6 backends have not been updated, but things still work.

While reviewing the README-perlito6 file, I've found some interesting stuff that I haven't touched in a while - here is a piece of generated code that goes through 3 different languages:

This is a snippet generated by "make build-6py" - it is the bootstrapped Perlito6-to-Python code that compiles Perlito6-to-Lisp. The source code for this is here.

def f_emit_lisp_program(v_comp_units=mp6_Scalar()):
    try:
        v_str = mp6_Scalar()
        Hash_unit_seen = mp6_Hash({})
        List_tmp_comp_unit = mp6_Array([])
        v_str.f_set(u'')
        Hash_unit_seen
        List_tmp_comp_unit
        def f__anon_28(v_comp_unit):
            v_name = mp6_Scalar()
            v_name.f_set(v_comp_unit.f_name())
            if mp6_to_bool(Hash_unit_seen.f_lookup(v_name)):
                for v_stmt in ((v_comp_unit.f_body())):
                    (Hash_unit_seen.f_lookup(v_name)).f_body().f_push(v_stmt)
            else:
                Hash_unit_seen.f_lookup(v_name).f_set(v_comp_unit)
                return List_tmp_comp_unit.f_push(v_comp_unit)
[snip]

Perlito6 needs some serious update work - the Perl6 specification changed in significant ways since this code was written.

Leave a comment

About Flávio S. Glock

user-pic I blog about Perl.