views:

146

answers:

2

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.

+1  A: 

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.

gimel
+1  A: 

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.

arbiter
I agree with you, that's why I'm looking for an easier solution. I'll look into the RPN. I was hoping to find ready to use library in .NET but the last resort is developing it :)
dr. evil