Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# expression tree
Hello,
I am working on an algorithm and perhaps an implementation in C++/c# for logical expressions. I want this logical expression for example, k = ((((a+b)'c)+((d+e)'f))g. My task is to put this expression in a short DNF / Sum of Products form such as abc'+bdf'+.... To do this I planned to put the expression in a tree like :
.
| |
+ g
|
Not.
..
..
.. and so on. Then I will apply de-morgan rule and at the last step Distribution law of multiplication over +. However I am facing problems about implementation. During my research many people are using Linq.Expression system classes or some articles are about Evaluant.Anltr framework to create tree. I want to indicate that I do not want to evaluate the logical expression. I just want to have Sum of Products form. Is there anyone who did similar thing so can give me some hints? Perhaps I dont expect a source code or smt but at least it will be nice to get some tips or guidence to create a hierarchic tree
Best regards
Posted 11-Feb-10 3:25am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

(Hope I got you) ANTLR is great at this.
the ANTLR web page [^] has tutorials, reference documentation, sample grammars.
Smile | :)
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Is there any tutorial or example that you can provide for ANTLR?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 270
1 OriginalGriff 184
2 BillWoodruff 170
3 Zoltán Zörgő 165
4 Sergey Alexandrovich Kryukov 125
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 11 Feb 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100