About 13 years ago I needed a way to script an application I was writing in Borland C++. I found a C interpreter and embedded that in my application. This has been working fine and I have quite a number of scripts.
大约13年前,我需要一种方法来编写我在Borland C ++中编写的应用程序。我在我的应用程序中找到了一个C解释器并嵌入了它。这一直很好,我有很多脚本。
I now need to rework the app and will do this in C#. Does anyone know of a C interpreter for C#? I have the sources for the original interpreter but I just need to save some time.
我现在需要重做应用程序并将在C#中执行此操作。有没有人知道C#的C解释器?我有原始翻译的来源,但我只需要节省一些时间。
Edit Here is an extract from a script:
编辑这是脚本的摘录:
main()
{
LwSet( "STUFE", "00.00" );
LwSet( "STATUS", "Warten", "AUS" );
do
{
LwSet( "DEBUG", "OFF" );
LwSet( "FUNKTION", "Warten auf Start" );
do
{
rc = LwGet( "Event" );
if( rc == "QUIT" ) {
...
The LwSet/LwGet calls a functions which I registered with the interpreter and are features of my application.
LwSet / LwGet调用我在解释器中注册的函数,这些函数是我的应用程序的特性。
Edit2
Before anyone feels the need to tell me what other language I should have used, here is my comment from below:
在任何人觉得有必要告诉我我应该使用的其他语言之前,以下是我的评论:
At the time, and considering the skills available it was not an annoying choice. Now, 13 years later, a lot of things look a whole lot different! I'm just stuck with a pile of quasi-C scripts which I would like to use without having to convert them all somehow.
当时,考虑到可用的技能,这不是一个烦人的选择。现在,13年后,很多事情看起来有很多不同!我只是坚持使用一堆准C脚本,我想使用它而不必以某种方式转换它们。
4 个解决方案
#1
5
How about using the same existing C interpreter from C# via interop?
如何通过互操作从C#使用相同的现有C解释器?
#2
3
The excellent ANTLR parser generator has support for C#. Its examples include a C grammar for C#.
优秀的ANTLR解析器生成器支持C#。它的例子包括C#的C语法。
This obviously isn't a full interpreter, but the grammar, lexer and parser would make a good starting point.
这显然不是一个完整的解释器,但语法,词法分析器和解析器将成为一个很好的起点。
#3
2
I don't know of any C interpreter for C# but there is a c# scripting engine that you might be able to use.
我不知道C#的任何C解释器,但是你可以使用一个c#脚本引擎。
#4
2
The nearist think I'm aware of is: http://www.softintegration.com/
近乎认为我知道的是:http://www.softintegration.com/
Added the following Link Is there an interpreter for C?
添加了以下链接是否有C的解释器?
Regards Friedrich
#1
5
How about using the same existing C interpreter from C# via interop?
如何通过互操作从C#使用相同的现有C解释器?
#2
3
The excellent ANTLR parser generator has support for C#. Its examples include a C grammar for C#.
优秀的ANTLR解析器生成器支持C#。它的例子包括C#的C语法。
This obviously isn't a full interpreter, but the grammar, lexer and parser would make a good starting point.
这显然不是一个完整的解释器,但语法,词法分析器和解析器将成为一个很好的起点。
#3
2
I don't know of any C interpreter for C# but there is a c# scripting engine that you might be able to use.
我不知道C#的任何C解释器,但是你可以使用一个c#脚本引擎。
#4
2
The nearist think I'm aware of is: http://www.softintegration.com/
近乎认为我知道的是:http://www.softintegration.com/
Added the following Link Is there an interpreter for C?
添加了以下链接是否有C的解释器?
Regards Friedrich