LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm wondering are there any projects trying to parse the optree to generate foreign code out of Perl syntax? Preferably realized in Perl?

I don't mean emulating all perl-features (like attempted by B::C or B::CC), just a reasonable subset/intersection ...

I would really like to try to produce Lisp snippets and so maybe I don't need to reinvent the wheel.

If not how would you start trying this?

Cheers Rolf

OOPS: seems like B:C and B::CC are pure Perl...

Replies are listed 'Best First'.
Re: using perlsyntax for other languages?
by ambrus (Abbot) on Apr 16, 2010 at 16:44 UTC
      thx looks interesting! :)

      Cheers Rolf

Re: using perlsyntax for other languages?
by ikegami (Patriarch) on Apr 16, 2010 at 15:12 UTC
    Why do you think it would be easier than B::C which is simply an opcode serializer? For what you'd want to do, you'd need to serialize the opcodes AND port the C code that forms Perl, starting with basics like porting scalars.
      Since my intention is not to emulate perl but to reuse perl syntax with foreign semantics.

      B::CC tries to emulate all Perl semantics , I just wanna use Perl's syntax to write a foreign code.

      The complication of B::CC is the goal that running the perl-interpreter produces in details the same result with the same code ...

      But thats not realistic, I'd rather prefer throwing errors when not easily implementable features are requested.

      For instance a really easy thing like if () {} else {} has plenty of flavors in lisp to avoid parens, that could be simplified.

      Cheers Rolf

        I didn't mention B:CC???

        Since my intention is not to emulate perl but to reuse perl syntax with foreign semantics

        So you want a Perl tokenizer or parser. On both counts, the answer is PPI.

        Update: Mentioned PPI.
        Update: Mentioned tokenizer.