Hi, The Reflect.parse API returns a tree of objects. That's cool. However Reflect.parse also allows for a user-specified callback to be run instead on the individual nodes. This is the "builder" interface:
https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API#Builder_objects So you can do: js> var builder = { identifier: function () { return Array.slice(arguments) } }; js> Reflect.parse("foo", {builder : builder }) ({ loc: {start:{line:1, column:0}, end:{line:1, column:3}, source:null}, type:"Program", body:[{ loc: {start:{line:1, column:0}, end:{line:1, column:3}, source:null}, type:"ExpressionStatement", expression: ["foo", {start:{line:1, column:0}, end:{line:1, column:3}, source:null}]}]}) It really ends with }]}]}). And people complain about Lisp! Anyway :) Note that the "expression" part of the ExpressionStatement is the array of arguments that get passed to the "identifier" callback. The issue here is that the different aspects of each parse node kind are passed as positional arguments, and terminated by the location. So the yieldExpression callback expects to get an argument and a location. There's no place to put in a "delegating: true" argument for yield* (which is otherwise a YieldExpression in Esprima). Likewise there is no compatible way to extend the function callback to indicate that a generator is an ES6 generator as opposed to a JS1.7 generator. It is difficult to preserve compatibility in the builder interface, while adding new variations on old syntax. Furthermore there is this positional argument protocol, where the builder callback has to know which arg maps to which named part. So my concrete question is, firstly, what do I do for yield* and ES6 generators? Do I break the callbacks by adding a positional before the location? Do I add an argument after the location? Do I diverge from Esprima, and add a different AST node type with its own callback signature? Secondly, is this really the interface that you want? I know positional args will be more performant, but simply passing the object literal we would have returned to the callback would be more flexible, and still allow the callback to control the peak memory usage. Thanks, Andy _______________________________________________ dev-tech-js-engine-internals mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

