rlb.usa
rlb.usa

Reputation: 15041

VB6 Parser/Lexer/Scripter

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.)?

Upvotes: 2

Views: 2753

Answers (5)

AMissico
AMissico

Reputation: 21684

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.)

Windows Script Control

The Microsoft® Windows® Script Control is an ActiveX® control that provides developers with an easy way to make their applications scriptable. This, in turn, enables users to extend application functionality through scripts, much as they do with macros today.

Upvotes: 4

rlb.usa
rlb.usa

Reputation: 15041

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?

Upvotes: 0

Hans Olsson
Hans Olsson

Reputation: 55049

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.

Upvotes: 2

lhf
lhf

Reputation: 72402

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

Upvotes: 3

Dario
Dario

Reputation: 49218

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.

Upvotes: 2

Related Questions