Question

What I'm trying to do this is writing a simple parser for the following case in .NET

( [PART3]function1() AND [PART4]function7() ) OR [PART2]function90() 
  • [PART] indicates the evaluation location, (assume that this is huge text file, PART separates text files into large chunks)
  • function() s are my documented function which can be called via this queries. Returns true or false
  • Based on this True/False and other operators between, I want to combine the results and return one final True or False from the whole input.

What's the best way to implement such a thing in .NET, is there any easy library which allows me to integrate this, or shall I just write a simple parser and then do it by myself?

P.S. I couldn't find a good title for the question.

Was it helpful?

Solution

Looks like simple condition, so in my opinion you do not need full-featured compiler producer. I can suggest you look into Reverse Polish Notation, use it to unwrap your conditions into stack, and then evaluate resulting stack using simple interpreting.

OTHER TIPS

Try Irony, although not ready for prime time (yet), it shows some promise.

Irony is a development kit for implementing languages on .NET platform. It uses the flexibility and power of c# language and .NET Framework 3.5 to implement a completely new and streamlined technology of compiler construction. Unlike most existing yacc/lex-style solutions Irony does not employ any scanner or parser code generation from grammar specifications written in a specialized meta-language. In Irony the target language grammar is coded directly in c# using operator overloading to express grammar constructs. Irony's scanner and parser modules use the grammar encoded as c# class to control the parsing process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top