One of the projects that I am working on is how to write a scripting language using c++. At first thought, I imagined the task to be hard, but to my surprise it is quiet easy.
In this post I will introduce the basics. However, I do suggest you visit my youtube channel and watch the video series.
As you can see from the image to the left, my script engine basically takes a string expression, converts it to tokens, determines its meaning, and then compiles the effective byte code.
Byte code is the instruction set for my script language. It will tell our virtual machine or virtual process what an instruction is suppose to do.
In more detail, the script engine does a recursive call with the tokens to successfully generate all the corresponding byte code.
In this post I will introduce the basics. However, I do suggest you visit my youtube channel and watch the video series.
token evaluation process |
Byte code is the instruction set for my script language. It will tell our virtual machine or virtual process what an instruction is suppose to do.
In more detail, the script engine does a recursive call with the tokens to successfully generate all the corresponding byte code.
Hello,
ReplyDeleteI have a little problem.
When I use s.execute("equation(1,2)"); It just keeps printing the message over and over again.
Can you help me?
ReplyDeletebut if(var1=var2) and else don't work how can I solve it?