Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a simple scripting language in C#

Tags:

c#

scripting

I need to create a very simple scripting language, as an evolution of a macro language (where placeholders were present and were exchanged for the realdata) which is based essentially on statements that need to be executed in order. I need to support nesting of statements and maybe possibly if conditions.

I think I need a parser to properly detect the statements

For example one statement could be:

Input("Message"=#Clipboard())

In this case, I would need to execute the #Clipboard() statement first and then the #Input.

Any suggestion of what's the approach for it? I guess I need to contruct a tree and execute it. Thanks.

like image 610
Andrea Nagar Avatar asked Aug 05 '26 22:08

Andrea Nagar


1 Answers

See my answer to a similar question here:

Basically, you parse your string using Postfix Notation.

Also, if you are going to use something more complex, look into building a Recursive Descent Parser. Eric White's blog has a great set of articles on the topic.

like image 193
GalacticJello Avatar answered Aug 07 '26 11:08

GalacticJello