Implementing a scripting language in C#

后端 未结 7 1457
孤城傲影
孤城傲影 2020-12-09 14:32

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 poss

相关标签:
7条回答
  • 2020-12-09 14:48

    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.

    0 讨论(0)
  • 2020-12-09 14:54

    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.

    0 讨论(0)
  • 2020-12-09 14:58

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

    0 讨论(0)
  • 2020-12-09 15:02

    have you looked at CSScript?

    0 讨论(0)
  • 2020-12-09 15:03

    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.

    0 讨论(0)
  • 2020-12-09 15:12

    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.

    0 讨论(0)
提交回复
热议问题