Translation from Python to CIL(C Intermediate Language)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Peggy Yao
    New Member
    • Apr 2011
    • 1

    Translation from Python to CIL(C Intermediate Language)

    I have worked on the static analysis on Python source code recently. There is already a static analyzer written in Ocaml for CIL(C Intermediate Language) in our group. We want to reuse this analyzer, so our ideal approach is to translate Python to CIL.

    Currently, I use Python built-in ast module to parse Python to Python AST. And then I translate the Python AST that ast.dump printed to C AST. In consider of C AST to CIL API and the static analyzer all written in Ocaml. I choose Ocamllex&Ocamly acc to parse Python AST to C AST. However, there are some big problems.

    The AST representation which ast.dump printed is hard to identify. That make my parser not easy to implement. On the other hand, I can't use Ocaml to acess the Python ast internal structure. I thought about maybe I should use other programming languages before, but I didn’t know if it will affect the execution of C AST to CIL and static analysis later.

    I wonder whether I choose a wrong approach on the translation from Python code to CIL at first? Is there any other existing tools or approaches that may meet my requirements?

    If there is anything I miss, please just point out that will be a lot of help for me. Thanks.
Working...