Working with expression AST:s
- by Marcus
Hi,
Is there any best practice when working with AST:s?
I have a parsed expression AST. ConstantExpression, BinaryExpression etc.
I want to populate a GUI-dialog with information from the AST, and it's here where I get kinda confused because my code gets pretty messy.
Example:
expression = "Var1 > 10 AND Var2 < 20"
I want to populate two textboxes with value 10 resp. 20 from the AST.
What I'm doing now is a recursive method that checks for correct child expression-types (with .Net Is-operator) and acts accordingly and the code is really "smelly" :)
Is there any design pattern, like Visitor or such, that makes this somewhat easier/more readable/maintainable ?