OneLang icon indicating copy to clipboard operation
OneLang copied to clipboard

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

Open sukhchainn opened this issue 5 years ago • 7 comments

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 avatar Feb 29 '20 14:02 sukhchainn

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

sukhchainn avatar Feb 29 '20 14:02 sukhchainn

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.

koczkatamas avatar Mar 02 '20 16:03 koczkatamas

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, [email protected] 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 https://github.com/onelang/OneLang/issues/38?email_source=notifications&email_token=AHU4P6Z535DGYNDYYSP6FVLRFPOWFA5CNFSM4K6XUOF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENQAUNI#issuecomment-593496629, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHU4P67D3WS4PBP4RTXUAZLRFPOWFANCNFSM4K6XUOFQ .

sukhchainn avatar Mar 02 '20 18:03 sukhchainn

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 :)

johnashu avatar Mar 03 '20 09:03 johnashu

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.)

koczkatamas avatar Mar 04 '20 18:03 koczkatamas

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 avatar Dec 20 '21 23:12 RobBW

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.

RobBW avatar Dec 21 '21 00:12 RobBW