Working with expression AST:s
Posted
by Marcus
on Stack Overflow
See other posts from Stack Overflow
or by Marcus
Published on 2010-04-12T14:56:53Z
Indexed on
2010/04/12
15:13 UTC
Read the original article
Hit count: 501
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 ?
© Stack Overflow or respective owner