how to embed compiler and interpreters to a website like codecademy?

江枫思渺然 提交于 2019-12-14 03:37:05

问题


I got a project to design a website which has a javascript & HTML interpreters, Database, C++ compiler. I have searched related websites and I ended searching with codecademy . Now I'm thinking to build something like codecademy website with my own features and functionality. Although I know how to create a dynamic website but I don't know how to embed interpreters, compilers and all. Please guys help me to build this project and successfully run


回答1:


In very simplified terms, there are two ways to achieve a live interpreter/compiler on a web site:

  1. Find (or write) a compiler/interpreter for your language that is written in Javascript

  2. Create a (native) CGI application and run it on your server that will run a given piece of code through a (native) interpreter/compiler (also on your server) and return the result of the run. Then write a web page that calls on that CGI to do the work, usually using AJAXy Javascript things like xmlHttpRequest, or at least a web form.

That's what all of these sites essentially boil down to. Some just have an interpreter or CGI that can remember state between calls, and can then show you intermediate steps. This could be because your JavaScript-based interpreter supports pausing, or your CGI could e.g. have the program run in lldb and then your page sends certain commands to LLDB and returns information.

Note: If your question was more about how to actually write an interpreter in JavaScript, I detail the basics of parts of an interpreter here: http://orangejuiceliberationfront.com/how-to-write-a-compiler/ It is for C programmers, but the basics hold true in any programming language. You can always use arrays instead of memory blocks, and array indexes instead of memory addresses.




回答2:


Simply web application takes our code as input and store in file with respective the programming language extension like .java, .c etc and then they used the server side install compiler to run the code and forward the output to the client through web page.

Suppose in java, there is class Runtime and Process with the help of this class we get the control on server side install software like java, javac etc with that we run the program and transfer the output to User..

It is very simple if any one want code for that then ping me..



来源:https://stackoverflow.com/questions/39102913/how-to-embed-compiler-and-interpreters-to-a-website-like-codecademy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!