I'm looking for references stating how to write a web scripting language and interface it with a web-server.
I'm not looking for "how to write the language" or "how to write an interpreter" references rather - I don't know how the basics of a web-script interpreter work? Is it a simply a CGI based interpreter that is passed the HTTP 开发者_开发百科parameters through stdin then interprets the script and pushes the output back to stdout?
What about interfacing and registering with the web-server (IIS, Apache) how is that done? Again, through stdin/stdout?
Any basic examples, references or comments would be appreciated.
Eric Lippert had a series of posts on building your own script engine. They may be of help/interest:
SimpleScript, Part Zero
SimpleScript Part One: DllMain is Boring
SimpleScript Part Two: Class Factories Are Also Boring
SimpleScript Part Three: Engine Skeleton
SimpleScript Part Four: Finite State Machines and Script Engines
SimpleScript Part Five: Named Items and Modules
SimpleScript Part Six: Threading Technicalities
SimpleScript Part Seven: Binder Skeleton
Is it a simply a CGI based interpreter that is passed the HTTP parameters through stdin then interprets the script and pushes the output back to stdout?
It could be.
What about interfacing and registering with the web-server (IIS, Apache) how is that done?
If it is CGI, then you would use their built in CGI modules.
Otherwise, you might use FastCGI (again with built in modules), or the APIs provided by the server: Apache, IIS
This is certainly going to be server-dependent. Apache is very modular and afaik uses own IPC protocol. In any case, the interpreter should be something that is started up once for the server, not once per request. As far as IPC, stdin is one option as you mentioned; others would be shared memory, pipes, or localhost TCP.
精彩评论