VB6 解析器/词法分析器/脚本编写器
我有一个 VB6 游戏,它运行得很好,但我一直在考虑创建一个脚本引擎的想法。我想我希望 VB6 为我读取纯文本脚本文件,然后 lex/parse/execute 它们。
我有很好的编程经验,之前也搭建过一个简单的C编译器,以及一个LOGO模拟器。
我的问题是: 我可以使用 Lexx/Yakk/Bison 等工具来帮助我吗?我应该如何在词法分析、解析和将命令反馈给 VB6 方面解决这个问题,以便我可以处理它们?这个想法是否是一个坏主意,因为路上有太多障碍(例如,在组装中建造扫雷艇,虽然不是不可能,但非常困难,而且是一个坏主意。)?
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.)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
VB6 似乎还有一个附加替代方案:
SadScript 是 VB6 的一个变体,最常用于 VB6 作为 MMORPGS 中的脚本引擎。
请参阅此处了解更多信息:什么是 Sadscript?我可以在vb.net中使用它吗?为什么我问过的人都没有听说过它?
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?
我实际上已经在 VB6[1] 中看到了一些相当合理的编译器/解释器的实现 - 这不是我会选择的语言(功能特性很少,静态类型系统不足),但是凭借经验,您可以克服这些缺点并提高工作效率- 那为什么不呢。
您可以使用支持 VB6 的 GOLD 解析器生成器 作为开始。
[1]:PSC 上或在此 下载存储库 我认为...
请注意,有 MSScriptControl 也是如此。
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.
如果您愿意使用 VBScript 而不是 VB6,您也许可以只使用
MSScriptControl
来运行命令,而不用创建自己的命令。 这里有一篇文章讨论从 .Net 应用程序中使用它,尽管它是ActiveX 控件因此应该为您提供相当大的灵活性。该控件可以从 下载在这里。
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.
除非您是按照自己的指示进行操作,否则您可能需要尝试使用 Lua:VB6 - Lua 集成
Unless you're doing it for your own instruction, you may want to try using Lua: VB6 - Lua Integration
使用 Microsoft® Windows® 脚本控件,因为它很容易集成到现有的 VB6 应用程序中。该控件支持 VBScript、JScript 或任何其他“活动脚本”实现。
我已经在四个项目中使用了Windows 脚本控件,并且它运行得非常好。非常容易集成。我希望 Microsoft 能够为我们提供 .NET 的替代品,并使其易于使用。 (我知道 .NET 中不需要该控件,但能够简单地创建一个处理所有内容的对象是很好的。)
信息:在哪里获取脚本控件位于 http://support .microsoft.com/kb/184739。包含指向其他操作方法支持文章的链接。
第 13 章:向应用程序添加脚本支持,位于 http://msdn.microsoft.com/en-us/library/aa227413(VS.60).aspx
设计计算器,位于 http://msdn.microsoft.com/en-us/library/aa227421(VS.60).aspx
如何使用脚本控制模块和过程集合,插入自 http://support.microsoft.com/kb/184745
如何使用脚本控件的 AddObject 方法,插入自 http://support.microsoft.com/kb/185697
示例:SCRIPTEX.EXE 将 ScriptControl 与 Visual Basic 结合使用,插入自 http://support。 microsoft.com/kb/189484
Windows 脚本控制可以在 http://www.microsoft.com/ downloads/details.aspx?familyid=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en。 (支持的操作系统:Windows 2000;Windows 98 Second Edition;Windows ME;Windows NT;Windows Server 2003;Windows XP)
MSDN 搜索“MSScriptControl.ScriptControlClass”,网址为 http://social.msdn.microsoft.com/Search/en-US?query =%22MSScriptControl.ScriptControlClass%22&ac=8
MSDN 搜索“Windows 脚本控制”,网址为 http://social.msdn.microsoft.com/Search/en-US?query=%22Windows+Script+Control%22&ac=8
MSDN 搜索“MSSCRIPT”位于 http://social.msdn.microsoft。 com/Search/en-US?query=MSSCRIPT&ac=8
Use the Microsoft® Windows® Script Control because it is easy to integrate into existing VB6 applications. The control supports VBScript, JScript, or any other "Active Script" implementation.
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.)
INFO: Where to Obtain the Script Control at http://support.microsoft.com/kb/184739. Includes links to other howto support articles.
Chapter 13: Adding Scripting Support to Your Application at http://msdn.microsoft.com/en-us/library/aa227413(VS.60).aspx
Designing a Calculator at http://msdn.microsoft.com/en-us/library/aa227421(VS.60).aspx
How To Use Script Control Modules and Procedures Collections, Inserted from http://support.microsoft.com/kb/184745
How To Use the AddObject Method of the Script Control, Inserted from http://support.microsoft.com/kb/185697
SAMPLE: SCRIPTEX.EXE Uses the ScriptControl with Visual Basic, Inserted from http://support.microsoft.com/kb/189484
Windows Script Control can be downloaded at http://www.microsoft.com/downloads/details.aspx?familyid=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en. (Supported Operating Systems: Windows 2000; Windows 98 Second Edition; Windows ME; Windows NT; Windows Server 2003; Windows XP)
MSDN Search of "MSScriptControl.ScriptControlClass" at http://social.msdn.microsoft.com/Search/en-US?query=%22MSScriptControl.ScriptControlClass%22&ac=8
MSDN Search of "Windows Script Control" at http://social.msdn.microsoft.com/Search/en-US?query=%22Windows+Script+Control%22&ac=8
MSDN Search of "MSSCRIPT" at http://social.msdn.microsoft.com/Search/en-US?query=MSSCRIPT&ac=8