UNPKG

solidity-antlr4

Version:

Solidity Lang Lexer and Parser by official ANTLR4 grammar

44 lines (43 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _exportNames = { print: true }; exports.print = void 0; var _declaration = require("./declaration.cjs"); var _expression = require("./expression.cjs"); var _meta = require("./meta.cjs"); var _statement = require("./statement.cjs"); var _type = require("./type.cjs"); var _yul = require("./yul.cjs"); var _comment = require("./comment.cjs"); Object.keys(_comment).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _comment[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function () { return _comment[key]; } }); }); const print = (path, options, _print) => { const node = path.node; if (node === null) return ""; if (Array.isArray(node)) return path.map(_print); const printerName = `print${node.type}`; const mixin = Object.assign({}, new _declaration.PrinterDeclaration(options, _print), new _expression.PrinterExpression(options, _print), new _meta.PrinterMeta(options, _print), new _statement.PrinterStatement(options, _print), new _type.PrinterType(options, _print), new _yul.PrinterYul(options, _print)); const printer = mixin[printerName]; if (!printer) throw new Error(`missing printer for node type "${node.type}"`); const document = printer({ path, options, print: _print, node }); return document; }; exports.print = print;