On 12/19/06, Sean Walton <[EMAIL PROTECTED]> wrote:
David- I'm at the point where I am trying to make sense of the AST I've built from the grammar. It looks like you use something like a visitor pattern to walk through the tree. I've constructed the callback table along with the functions themselves, but I am trying to get things in a different order than a pre-order traversal. Is that what "postkind_..." does? Does "kind_..." perform the pre-order, and the "postkind_..." does the post order? The reason I'm asking is the "postkind_..." and "kind_..." appear to have the same numeric value. If my assumption is wrong, could you please explain what they are for?
kind_XXX identifies a node of type XXX in the AST (so an identifier node has its kind field set to kind_identifier). postkind_XXX is used to support object-oriented type checks: a node is an expression (e.g.) if its kind is >= kind_expression and <= postkind_expression. These checks are used by the is_XXX and CAST_XXX macros. The kind_XXX and postkind_XXX numbers are picked to ensure that this works, by using a depth-first traversal of the AST type tree. You start counting at the root and set kind_XXX as you walk down, and postkind_XXX after you've walked through all children - this is all a standard approach for doing OO type checks. Many kinds of node have kind_XXX == postkind_XXX because they have no subtypes... David Gay _______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
