ECMAScript code generator that transforms Mozilla's Parser API ASTs back into executable JavaScript code
95
Build a JavaScript AST code generation utility that can generate code from Abstract Syntax Trees while supporting Mozilla-specific JavaScript extensions through configuration options.
Your utility should accept an AST node and generation options, then produce JavaScript code. The utility must handle Mozilla-specific generator function syntax variations through configuration.
The utility should support configuring how generator functions are represented in the output code:
* token in their syntax* tokenfunction* gen() { yield 1; } with default settings, the output includes the * token @test* token in the function declaration @test* token @test* token @test@generates
/**
* Generate JavaScript code from an AST node with Mozilla extension support
* @param {Object} ast - Mozilla Parser API compatible AST node
* @param {Object} options - Generation options including Mozilla-specific settings
* @param {Object} [options.moz] - Mozilla-specific options
* @param {boolean} [options.moz.starlessGenerator] - Generate generators without * syntax
* @returns {string} Generated JavaScript code
*/
function generateCode(ast, options);
module.exports = { generateCode };Provides AST to JavaScript code generation with Mozilla extension support.
Install with Tessl CLI
npx tessl i tessl/npm-escodegendocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10