VB6 Parser/Lexer/Scripter

匿名 (未验证) 提交于 2019-12-03 02:53:02

问题:

I've got a game in VB6 and it works great and all, but I have been toying with the idea of creating a scripting engine. Ii'm thinking I'd like VB6 to read in flat text script files for me and then lex/parse/execute them.

I have good programming experience, and I've built a simple C compiler, as well as a LOGO emulator before.

My question is: Are there any tools that I can use, like Lexx/Yakk/Bison to help me? How should I approach this problem in regards to lexing, parsing, and feeding the commands back to VB6 so I can handle them? Is this idea a BAD IDEA in the sense that there are too many obstacles in the way (For example, building minesweeper in assembly, though not impossible, is very difficult, and a bad idea.)?

回答1:

If you're willing to use VBScript rather than VB6 you might be able to just use the MSScriptControl to run the commands rather than creating your own. Here's an article discussing using it from a .Net app, though it's an ActiveX control so should give you quite a bit of flexibility.

The control can be downloaded from here.



回答2:

I have used the Windows Script Control in four projects and it works extremely well. Very easy to integrate. I wish Microsoft would have given us a replacement in .NET, and made it as easy to use. (I understand the control is not needed in .NET, but having the ability to simply create an object that handles everything is nice.)

Windows Script Control



回答3:

Unless you're doing it for your own instruction, you may want to try using Lua: VB6 - Lua Integration



回答4:

I've actually seen some quite reasonable implementations of compilers/interpreters in VB6[1] - It's not the language I would choose (few functional features, insufficent static type system), but with experience, you can outweigh these drawbacks and be quite productive - So why not.

You can use the GOLD parser generator that supports VB6 as a start.

[1]: Somewhere on PSC or in this download repository I think ...

Note that there is the MSScriptControl too.



回答5:

There also appears to be an additonal alternative for VB6:

SadScript is an variant of VB6 most prominently used for VB6 as an scripting engine in MMORPGS .

See here for more : What is sadscript? Can I use it in vb.net? Why hasn't anyone I have asked heard of it?



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