简体   繁体   中英

Creating a simple scripting language in C#

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM