3

I am trying to parse some code in C into Javascript to use it on a website. I have downloaded pycparser as said in the github documentation https://github.com/eliben/pycparser but I donot know how to use it. For example what commands do I need to use and how to do a preprocessing of the code with clang or cpp.

¿Can anyone help me?

Thanks.

Maria M
  • 31
  • 2
  • 1
    Hi. I think that converting code from C to Javascript may not be such a trivial task. However, you may be interested in [emscripten](https://github.com/emscripten-core/emscripten), which compiles C and C++ code to WebAssembly. Also, see [this](https://stackoverflow.com/questions/4210797/translating-c-to-javascript) question. – icebp Mar 03 '21 at 09:11
  • 1
    Does this answer your question? [Translating C to JavaScript](https://stackoverflow.com/questions/4210797/translating-c-to-javascript) – icebp Mar 03 '21 at 09:11
  • Hi, I have already tried to use Emscripten tools. It seems that my functions in C have too many includes and when trying to tranpile them there's always an error. – Maria M Mar 03 '21 at 09:25
  • I had already seen that Post >https://stackoverflow.com/questions/4210797/translating-c-to-javascript. There the C functions do not have #includes and there are a function per file. That's not my case, so using Emscripten is a bit harder for me – Maria M Mar 03 '21 at 09:26
  • 1
    Using Emscripten is still probably way easier than writing a transpiler from scratch. I suggest to either ask a question with a [minimal](https://stackoverflow.com/help/minimal-reproducible-example) example of where Emscripten fails, or even [opening an issue](https://github.com/emscripten-core/emscripten/issues) asking for help if the Emscripten [tutorial](https://emscripten.org/docs/getting_started/Tutorial.html) and docs are not covering your use case. – icebp Mar 03 '21 at 09:58

0 Answers0