New scripting language

和自甴很熟 提交于 2019-12-22 18:00:03

问题


I am trying to create a scripting language by myself (it doesn't have to be perfect - although that would be great if it was), mostly because i'm doing it for fun and to learn about how they're created etc.

According to the answer over here: Creating a scripting language what I'm supposed to be looking into is this: http://msdn.microsoft.com/en-us/library/xawadt95%28VS.85%29.aspx . But, I have absolutely no idea what that MSDN page is on about.

Can somebody please help?

P.S. Are there any free/open source scripting languages that target the Windows Script Host, that also have full source code available for it that I can play around with?

Thank you


回答1:


I started writing a guide to how to implement your own language engine for Windows Script Host but I ran out of steam and never finished it.

http://blogs.msdn.com/ericlippert/archive/tags/SimpleScript/default.aspx




回答2:


If you're doing this for fun and to learn how languages are created, I advise you to stay far, far away from Windows Script Host. Instead, try learning from better examples. A good first step would be to get yourself on over to http://www.lua.org/, study the language, read about how it is implemented, and roll your own. Another language that is horrible from a language point of view, but very easy to implement is Tcl. Start with Ousterhout's original Usenix paper.

I wish I could recommend a good book on designing and implementing your own programming language. I've never seen one. (I've seen some bad books along these lines, but not wishing to disrespect the authors, I won't identify them.) But if you can spend some quality time in a good university library, you will be able to find some interesting papers. You might also find it worthwhile to check our Friedman and Wand's book Essentials of Programming Languages—although it is very technical, it does have some good stuff about writing interpreters. There's also a good (but very old) book by P. J. Brown called Writing Interactive Compilers and Interpreters.




回答3:


The easist way to make a simple script interrupter is by spliting your source code by the line break character into an array and cycling through each member. Here is an example string source = @" print Hello World! stop "); foreach(string a in source.split('\n')) { if(a.StartsWith("print ")) { Console.WriteLine(a.Substring(6)); } if(a == "stop") { Console.ReadLine(); }



来源:https://stackoverflow.com/questions/2455032/new-scripting-language

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