astbuilder

Simple tool to build an ast

Usage no npm install needed!

<script type="module">
  import astbuilder from 'https://cdn.skypack.dev/astbuilder';
</script>

README

AST Builder


Set of tools to easy building ast.

Plug in with escodegen to simply generate javascript code from function calls.

Usage:

const ast = require('astbuilder');
const escodegen = require('escodegen');

const ast = ast.program([ast.AssignmentExpression(ast.Identiifer('a'), ast.Literal(2))]);

let code = escodegen.generate(ast);
eval(code);

console.log(a); // 2