c# - Nested Condition Statements to its equivalent TreeStucture -


i have string containing c function condition statements inside.

string inputfunction = "if(x > 10) {     if(x == 11)     {         //more conditions     }     if(x == 12)     {     } }"; 

using regular expression parse condition statements then, parse code block. repeat process again next conditions. plan store them in class i've created:

class condition {      public string conditionstring { get; set; }      public string parentcondition { get; set; }      public string childconditions { get; set; } } 

now problem is: cannot create parent-child relationship current algorithm.

i able identify first set of parents. can repeat process again parse children, children can have child conditions inside. have suggestion or s there better way of doing this?

for tree structure, golden rule have collection of entity within itself.

i think class structure should this

class condition {     public string conditionstring{get;set;}     public condition parentcondition{get;set;}     public list<condition> childconditions{get;set;} // in case there more                                                       // 1 conditions. } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -