New scripting language

為{幸葍}努か 提交于 2019-12-06 10:50:27

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

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.

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(); }

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