cwap
cwap

Reputation: 11267

Implementing a scripting language in C#

We got a project where we're supposed to let 3rd party developers create their own GUI / CodeBehind drivers. Our GUI is running on WPF.

Now, we got a number of possibilities for doing so, but one of the things we're considering is to create some sort of sub-Xaml XSD to let the create their GUI using markup (dunno if it'll be XAML or our own XML-"language", and then let them do their code-behind through a scripting language.

I thought about it, and this model seems to have many similarities to the way World of Warcraft let's people create their own GUI. The way WoW does it, is by implementing the LUA scripting language and then expose some of their own API calls. We want similar behaviour.

However, we're on a sort-of strict deadline, and this implementation ain't the highest of our priorities. Therefore I'm looking for a .Net compliant script parser / "compiler", to use in our project. Which scripting language we're using is not a major concern, we just want to be able to implement it rather fast, without too much fuzz.

Does anyone know of this sort of library? Or do you guys have a smarter solution for these requirements?

Obviously, we're dreaming of creating our own WYSIWYG editor and our own domain specific language, but this seems like overkill for us. We just want a scripting language which can do nothing but to do calls though our API while letting the 3rd party developer use conditionals, loops, maybe OO, etc..

Thanks in advance :)

Upvotes: 4

Views: 6683

Answers (7)

Vadim
Vadim

Reputation: 21704

You can use IronPython as your scripting language. Here's an article that gives a basic idea how you can do it.

Upvotes: 15

cdiggins
cdiggins

Reputation: 18203

Maybe you are interested in reinventing the wheel, or want to better understand how to write your own programming language tools in C# see Implementing Programming Languages using C# at CodeProject.com.

Upvotes: 0

Eric Lippert
Eric Lippert

Reputation: 659964

I strongly agree. Inventing new general-purpose "script a bunch of control flow and object model invocations" language is "minus one thousand points" on my team; that is, the cost of doing so is so high, and the cost to our customers of having to learn a new language is so high, that the benefit has to be at least "a thousand points" just to get out of negative territory. There are plenty of scripty languages that you don't have to design, specify, develop, test, debug, document, ship, maintain and teach your customers how to use; you can avoid all those costs.

If I were in your shoes I would only be developing a new language if its value was that it was very different from every other language out there, due to its special-purpose applicability to a specific domain. It sounds like you are well on your way to developing a static markup DSL, which is a great idea. By making it a subset of an existing tag-structured language you don't have to take on the burdens of building parsers and lexical verifiers and whatnot.

Upvotes: 3

Darien Ford
Darien Ford

Reputation: 1049

Antlr is a lexer/parser generator. It is a little more involved than just using Iron Python, however, you are able to create your own DSL fairly easily, allowing only the types of operations you want.

With the generated parser/lexer you can use it as a real time interpreted language, or a traditional statically compiled, or use it to generate C# code, which then gets compiled.

The options are quite endless.

Upvotes: 1

Daniel Brückner
Daniel Brückner

Reputation: 59645

Lua plus LuaInterface is the choice for our current project - just register methods from your API with LuaInterfcae and they can be called from script code. Our user interface uses Scintilla and ScintillaNET for script editors.

This is probably not the best solution for building complex user interfaces, but it is possible.

Upvotes: 4

Mark Seemann
Mark Seemann

Reputation: 233125

Have you considered creating a DSL in Boo?.

It doesn't have to be very hard and complex to get started, but you get excellent options for expanding the DSL if you get more time on your hands later on.

Upvotes: 1

Brandon
Brandon

Reputation: 214

have you looked at CSScript?

Upvotes: 4

Related Questions