How would you create an expression parser in c#?

后端 未结 3 779
春和景丽
春和景丽 2021-01-24 04:10

I am just curious. Like in interpreted languages or even statement calculators how do people convert the strings given by input or files to actual expressions? e.g \"Ent

相关标签:
3条回答
  • 2021-01-24 04:33

    I believe this can be achieved using expression trees, which is how LINQ is implemented.

    http://msdn.microsoft.com/en-us/library/bb397951.aspx

    0 讨论(0)
  • 2021-01-24 04:37

    Here's an article you might check out. There are also tools like Flee. Or yet another technique which allows you to evaluate C# expressions using a CodeDom provider.

    0 讨论(0)
  • 2021-01-24 04:47

    Google "parse tree". One can be written in any Turing-complete language.

    0 讨论(0)
提交回复
热议问题