Hi ,
I am generating below grammar rules dynamically through UI interface which contains different operators {‘<’,’<=’,’>’,’>=’,’In’,’!=’,’=’} and connectors {‘AND’,’OR’} with nested parentheses i.e. ‘(‘,’)’ etc.
( Amount >= 12522 And Amount <= 145111 And (City IN ( 1,2,3,4 ) ) And Age > 25 And Gender IN (‘M’,’F’) ).
I want to check the grammar of above rule syntactically including the valid values of connectors and operators. Also, nested parentheses count should be equal and logical.
So, following rules to be considered as wrong rules
( Amount >= 12522 AndAnd Amount <= 145111 And (City IN ( 1,2,3,4 ) ) And Age > 25 And Gender IN (‘M’,’F’) ). [Two Invalid And Operators]
((( Amount >= 12522 And Amount <= 145111 And (City IN ( 1,2,3,4 ) ) And Age > 25 And Gender IN (‘M’,’F’) ).[Parenthesis count is not equal].
Can anyone share the logic in C# so that I can consume it in my application ?
Thanks,