Subj : Re: The root of the syntax tree To : netscape.public.mozilla.jseng From : joao Date : Wed Jul 07 2004 10:29 pm Brendan Eich wrote: > Actually, I recall my design decision now. PN_NULLARY is accurate, > there are no JSParseNode kids of a TOK_STRING (or of a TOK_OBJECT). > PN_NAME, on the other hand, denotes a TOK_NAME or TOK_DOT node, which > may or must (respectively) have a non-null pn_expr "child". Because > this pn_expr link may be null, and because of the other distinct members > of the pn_u.name variant such as atom, I made another "arity" than > PN_UNARY to distinguish TOK_NAME, TOK_DOT, and any similar future types. Yes, I get it. > So you should not take PN_NULLARY to mean "not a literal". Arity has to > do with tree node child count, and a literal string or object is always > a leaf node: zero kids. That does not mean it can't have ad-hoc leaf > data, e.g., pn_atom. Well, looking at the source code (jsparse.h), the question is how do I access the sub-fields inside the union... actually, *which* sub-fields do I access is a better question. Looking at the definition of JSParseNodeArity, just before the definition of JSParseNode, there seems to be a mapping between those enum values and the sub-fields, so the reader is led to believe that if it's a PN_NAME, then you can access pn_atom, otherwise you can't. And if it's PN_NULLARY, then there's nothing else (dval maybe ?). But you were right, it *is* described in the comment, if you read it carefully. I'll be using that. > /be Joao -- joao at teaser dot fr .