ECMAScript code generator that transforms Mozilla's Parser API ASTs back into executable JavaScript code
95
A utility that generates JavaScript regular expression literals from Abstract Syntax Tree (AST) nodes, with proper handling of Unicode characters and escape sequences.
Transform AST nodes representing regular expressions into JavaScript code with proper syntax.
/hello/i, it generates "/hello/i" @test/\d+/g, it generates "/\d+/g" @testUnicode line separators (U+2028) and paragraph separators (U+2029) in patterns must be escaped to prevent JavaScript syntax errors.
@generates
/**
* Transforms an AST Literal node representing a RegExp into JavaScript code.
*
* @param {Object} node - AST node with type 'Literal' and a regex property
* @param {Object} node.regex - Contains pattern and flags for the regular expression
* @param {string} node.regex.pattern - The regex pattern string
* @param {string} node.regex.flags - The regex flags string
* @returns {string} The generated JavaScript regular expression literal
*/
function transformRegExpNode(node) {
// IMPLEMENTATION HERE
}
module.exports = { transformRegExpNode };Provides AST to JavaScript code generation capabilities, including regular expression handling with Unicode support.
@satisfied-by
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