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

They say, it takes a village to raise a child! #38

Open
sukhchainn opened this issue Feb 29, 2020 · 7 comments
Open

They say, it takes a village to raise a child! #38

sukhchainn opened this issue Feb 29, 2020 · 7 comments
Labels

Comments

@sukhchainn
Copy link

I am very interested in this project and I want to know how well does it compile to C language as I want to use it to transpile Python like code in C.

@sukhchainn
Copy link
Author

I will be motivated in contributing to this project if it can do the job.

@koczkatamas
Copy link
Collaborator

Hi @sukhchainn!

OneLang currently does not compile to C, only C++. Also C support is not planned in the short-term as C is very different from the other supported languages (e.g. OO). I would say somewhat limited C support is realistic in ~1 year if the current development speed is kept.

If you want to compile from only one language (Python) to an another (C) I would suggest using a Python AST parser and try to generate valid C code by yourself. If you need for a specific use-case then you have a good chance that it will satisfy your needs without too much work.

@sukhchainn
Copy link
Author

sukhchainn commented Mar 2, 2020 via email

@johnashu
Copy link

johnashu commented Mar 3, 2020

Thanks for an honest reply. What I need is a parser which can compile an XML template containing Python code. The parser should be able to differentiate between XML code and Python code. Now I think that I would need to create it from scratch and because it's a very specific edge case. I think reading through your codebase will help me with making my own parser.

On Mon, 2 Mar, 2020, 10:12 PM Tamás Koczka, @.***> wrote: Hi @sukhchainn https://github.com/sukhchainn! OneLang currently does not compile to C, only C++. Also C support is not planned in the short-term as C is very different from the other supported languages (e.g. OO). I would say somewhat limited C support is realistic in ~1 year if the current development speed is kept. If you want to compile from only one language (Python) to an another (C) I would suggest using a Python AST parser and try to generate valid C code by yourself. If you need for a specific use-case then you have a good chance that it will satisfy your needs without too much work. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#38?email_source=notifications&email_token=AHU4P6Z535DGYNDYYSP6FVLRFPOWFA5CNFSM4K6XUOF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENQAUNI#issuecomment-593496629>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHU4P67D3WS4PBP4RTXUAZLRFPOWFANCNFSM4K6XUOFQ .

I would be interested in such a project.. Hit me up if you make a start :)

@koczkatamas
Copy link
Collaborator

I am not sure if I understand correctly, but I would parse a XML file with a XML library and then use the Python code stored as node values.

Meanwhile I remembered that there is an another project which supports much more languages: https://github.com/jarble/transpiler , in theory it can compile Python to C. You may want to give it a try. (I never really tested it deeply, so I don't know how well it works.)

@RobBW
Copy link

RobBW commented Dec 20, 2021

There is also Transpyle: [https://github.com/mbdevpl/transpyle] which has much of the infrastructure that Tamás suggests.
Re c++ the site says:

Only very basic syntax is supported currentl

y

@RobBW
Copy link

RobBW commented Dec 21, 2021

Just found this at: https://github.com/alexander-jackson/ptc maybe it will meet the need.

Python to C Compiler (ptc)

ptc is a source-to-source compiler for converting Python to C code. It aims to allow converted code to be dropped into a project as if it had been handwritten. It is written using the Rust programming language.

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

No branches or pull requests

4 participants