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.
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.
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.
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.
To create an interpreter first you need to create a lexer to get the tokens of your input program. Next you create a parser that takes those tokens and, by following the rules of a formal grammar, returns an AST of your input program. Finally, the interpreter takes that AST and interprets it in some way.
Programming languages like JavaScript, Python, Ruby use interpreters. Programming languages like C, C++, Java use compilers.
How about using the same existing C interpreter from C# via interop?
The excellent ANTLR parser generator has support for C#. Its examples include a C grammar for C#.
This obviously isn't a full interpreter, but the grammar, lexer and parser would make a good starting point.
I don't know of any C interpreter for C# but there is a c# scripting engine that you might be able to use.
http://www.csscript.net/index.html
The nearist think I'm aware of is: http://www.softintegration.com/
Added the following Link Is there an interpreter for C?
Regards Friedrich
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With