Subj : Re: The root of the syntax tree To : netscape.public.mozilla.jseng From : joao Date : Wed Jul 07 2004 12:02 pm Hi Brendan, Brendan Eich wrote: > Not when you are generating code. To conserve and recycle JSParseNode > space, each top-level statement is compiled in turn: parsed and then > traversed by js_EmitTree to generate bytecode. If you want the entire > tree, don't use a JSCodeGenerator and don't call js_CompileTokenStream > -- call js_ParseTokenStream instead. Thanks for the explanation, I obviously jumped onto the first piece of code I found, I could have looked better. >> Related question : for a string literal, I get a TOK_STRING token with >> a JSOP_STRING operator, but I can't see how to get at the value of the >> string ; it has arity PN_NULLARY so there's nothing more in the >> JSParseNode. How can I reach this value ? > > pn->pn_atom is the string's atom. Looks like jsparse.h's big comment > does not say this clearly enough. But if you read very carefully, > noting the commas in the first column, you can see it. Look for > "pn_atom: name, string, or object atom" in the third column. You're right, of course. I see now that the comment groups NAME, STRING, and OBJECT together, under the 'name' variant. But this is strange : when I look inside the JSParseNode, token type is TOK_STRING but pn_arity is PN_NULLARY, not PN_NAME... and yet, there is a pn_u.name.atom field. I assumed pn_arity would be the discriminating field for the pn_u union ? Shouldn't the TOK_STRING have arity PN_NAME ? > > /be Thanks again, Joao -- joao at teaser dot fr .