问题描述
我有一个设计网站的项目,该网站具有javascript& HTML解释器,数据库,C ++编译器。我已经搜索了相关网站,并以
结尾。现在,我正在考虑使用自己的功能构建类似代码学院的网站。尽管我知道如何创建动态网站,但我不知道如何嵌入解释器,编译器以及所有内容。大家帮我构建这个项目并成功运行
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
推荐答案
用非常简单的术语来说,有两种方法可以实现实时解释器网站上的/ compiler:
In very simplified terms, there are two ways to achieve a live interpreter/compiler on a web site:
-
查找(或编写)以Java语言编写的语言的编译器/解释器
Find (or write) a compiler/interpreter for your language that is written in Javascript
创建一个(本机)CGI应用程序,然后在您的服务器上运行该应用程序,该服务器将通过(本机)解释器/编译器(也在您的服务器)并返回运行结果。然后编写一个调用该CGI进行工作的网页,通常使用AJAXy Javascript之类的东西,例如xmlHttpRequest或至少一个Web表单。
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.
基本上所有这些网站都可以归结为这些内容。有些只是具有解释器或CGI,它可以记住调用之间的状态,然后可以向您显示中间步骤。这可能是因为您的基于JavaScript的解释器支持暂停,或者您的CGI可能例如让程序在lldb中运行,然后您的页面向LLDB发送某些命令并返回信息。
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.
注意:如果您的问题是关于如何为了真正用JavaScript编写解释器,我在这里详细介绍了解释器的基础知识:适用于C程序员,但基础知识在任何编程语言中均适用。您始终可以使用数组代替内存块,并使用数组索引代替内存地址。
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.
这篇关于如何将编译器和解释器嵌入到像codecademy这样的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!