script to translate from compiler AST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrey Khavryuchenko

    script to translate from compiler AST

    Hi!

    I'm looking for a script to translate from 'compiler' AST to py source
    and executable code.

    Google search reveals hardly useful links.

    Is there something like that or it is left as an exercise for a curious
    developer?

    --
    Andrey V Khavryuchenko http://www.kds.com.ua/
    Silver Bullet Software Solutions http://www.kds.com.ua/training/
  • Miki Tebeka

    #2
    Re: script to translate from compiler AST

    Hello Andrey,
    [color=blue]
    > I'm looking for a script to translate from 'compiler' AST to py source
    > and executable code.
    >
    > Google search reveals hardly useful links.
    >
    > Is there something like that or it is left as an exercise for a curious
    > developer?[/color]

    Have you looked at the parser module?
    (http://www.python.org/doc/current/li...le-parser.html) it does
    have some functions operating on AST. The is also a visitor patter
    support in the compiler module.

    HTH.
    Miki

    Comment

    • Michael Hudson

      #3
      Re: script to translate from compiler AST

      Andrey Khavryuchenko <akhavr@kds.com .ua> writes:
      [color=blue]
      > Hi!
      >
      > I'm looking for a script to translate from 'compiler' AST to py source[/color]

      google('decompy le')
      [color=blue]
      > and executable code.[/color]

      Um, not sure what you're asking for here. You might be asking for
      Python2C, but it's probably not what you want...

      Cheers,
      mwh

      --
      Enlightenment is probably antithetical to impatience.
      -- Erik Naggum, comp.lang.lisp

      Comment

      • Andrey Khavryuchenko

        #4
        Re: script to translate from compiler AST

        Miki,

        "MT" == Miki Tebeka wrote:

        MT> Have you looked at the parser module?
        MT> (http://www.python.org/doc/current/li...le-parser.html) it does
        MT> have some functions operating on AST. The is also a visitor patter
        MT> support in the compiler module.

        Well, I'm speaking exactly about the compiler module. Imagine, I've built
        an AST that I want to run. I've not found an easy (read library) way to do
        that, hence the questions.

        --
        Andrey V Khavryuchenko http://www.kds.com.ua/
        Silver Bullet Software Solutions http://www.kds.com.ua/training/

        Comment

        • Andrey Khavryuchenko

          #5
          Re: script to translate from compiler AST

          Michael,

          "MH" == Michael Hudson wrote:

          MH> Andrey Khavryuchenko <akhavr@kds.com .ua> writes:[color=blue][color=green]
          >> I'm looking for a script to translate from 'compiler' AST to py source[/color][/color]

          MH> google('decompy le')

          Well, not *that* :)
          [color=blue][color=green]
          >> and executable code.[/color][/color]

          MH> Um, not sure what you're asking for here. You might be asking for
          MH> Python2C, but it's probably not what you want...

          Imagine, I've built an AST that I want to run. I've not found an easy
          (read library) way to do that, hence the question.

          Is there a way or I'd better write a proper 'visitor' myself?

          --
          Andrey V Khavryuchenko http://www.kds.com.ua/
          Silver Bullet Software Solutions http://www.kds.com.ua/training/

          Comment

          • Michael Hudson

            #6
            Re: script to translate from compiler AST

            Andrey Khavryuchenko <akhavr@kds.com .ua> writes:
            [color=blue]
            > Imagine, I've built an AST that I want to run. I've not found an
            > easy (read library) way to do that, hence the question.[/color]

            Ah! Try



            Cheers,
            mwh

            --
            A.D. 1517: Martin Luther nails his 95 Theses to the church door and
            is promptly moderated down to (-1, Flamebait).
            -- http://slashdot.org/comments.pl?sid=...1815221&cid=52
            (although I've seen it before)

            Comment

            • Andrey Khavryuchenko

              #7
              Re: script to translate from compiler AST

              Michael,

              "MH" == Michael Hudson wrote:

              MH> Andrey Khavryuchenko <akhavr@kds.com .ua> writes:[color=blue][color=green]
              >> Imagine, I've built an AST that I want to run. I've not found an
              >> easy (read library) way to do that, hence the question.[/color][/color]

              MH> Ah! Try

              MH> http://groups.google.com/groups?th=f3f7a7f6fac16ca2

              Wow, thanks! Exactly what I need. Unfortunately pycodegen is not yet
              documented :)

              --
              Andrey V Khavryuchenko http://www.kds.com.ua/
              Silver Bullet Software Solutions http://www.kds.com.ua/training/

              Comment

              Working...