How to Write a Scripting Language using C? Any Idea? Links?
C/C++ can be used for maximal performance and complicated systems programming tasks. Scripting languages can be used for rapid prototyping, interactive debugging, scripting, and access to high-level data structures such associative arrays.
The only theoretical difference is that a scripting language does not include the compilation step- it is interpreted instead. For instance, one needs to first compile a C program before running it. On the other hand, one does not need to compile a scripting language such as PHP or JavaScript.
Do you mean, how to write a language that is interpreted in C?
If so, you'll want to check Wikipedia and other sources on the following topics:
It's a lot more work than you might think... Happy reading!
You can take a look at the book "The UNIX programming environment"
(source: bell-labs.com)
At the end of the book, and pretty much the last chapter, the authors, wrote a small interpreter in C with enough and detailed information step by step. Very interesting and very easy to follow.
The source code of that interpreter is here
Why not look at the C-Code for a (easy) scripting language? Maybe Lua? (link )
Maybe you should also read somesthing about parser generators, which are the first building block that your program can interpret a language. The second block is to actually do, what was being parsed (sometimes you can integrate that into the parser, it can callback functions at each token/each structure being parsed). Easy examples, like parsing and executing math formulas could help.
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