Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the "ast" module #902

Closed
kmod opened this issue Sep 8, 2015 · 6 comments
Closed

Support the "ast" module #902

kmod opened this issue Sep 8, 2015 · 6 comments

Comments

@kmod
Copy link
Collaborator

kmod commented Sep 8, 2015

I think this boils down to just implementing the "_ast" module which has the actual Python types. We have a simple module (src/runtime/builtin_modules/ast.cpp) that declares the different types, but they're currently empty.

I think any individual type is pretty straightforward, but there are 90 of them. CPython auto-generates their module (Python/Python-ast.c) from their grammar file. We could try to modify their grammar generator, or modify the output, or just continue to implement the module from scratch.

@aisk
Copy link
Contributor

aisk commented Sep 16, 2015

I'll try this if no one had been assigned 😸

@corona10
Copy link

i done by modifying some files and add

new file:   from_cpython/Include/Python-ast.h
new file:   from_cpython/Include/asdl.h
new file:   from_cpython/Python/Python-ast.c
new file:   from_cpython/Python/asdl.c
new file:   from_cpython/Python/pyarena.c

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   from_cpython/CMakeLists.txt

but i don't know what to next

@Daetalus
Copy link
Contributor

My proposal is write some types manually first. Summarize and find the pattern, them modify CPython grammar generator, or write the module from scratch. Just some thoughts, not verify it.

@corona10
Copy link

@Daetalus so it means code generator should makes src/runtime/builtin_modules/ast.cpp??

@Daetalus
Copy link
Contributor

Just my proposal, wait for @kmod to give some concrete suggestions

@kmod
Copy link
Collaborator Author

kmod commented Sep 22, 2015

I agree with daetalus, I don't think we should jump straight to using their generator. I think there are a couple ways we could attack this, but the one I would suggest is:

  • copy in Python-ast.c (and just that file)
  • try to convert it from using CPython's AST structs (Python-ast.h) to our AST structs (src/core/ast.h)
  • see what needs to be changed; if it's a small amount I would just make the changes in the generated file. if it's a lot, then maybe take a look at the generator to see if modifying that would be easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants