UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

22 lines 1.08 kB
/* eslint-disable @typescript-eslint/no-explicit-any */ import { extractVariant } from './extract-variant.js'; export function createNonterminalVariantSimpleCreator(constructors) { return (variant, collected, options) => { for (const [slangAstClass, constructor] of constructors) { if (variant instanceof slangAstClass) return new constructor(variant, collected, options); } throw new Error(`Unexpected variant: ${JSON.stringify(variant)}`); }; } export function createNonterminalVariantCreator(constructors, extractVariantConstructors) { const simpleCreator = createNonterminalVariantSimpleCreator(constructors); return (variant, collected, options) => { for (const [slangAstClass, constructor] of extractVariantConstructors) { if (variant instanceof slangAstClass) return extractVariant(new constructor(variant, collected, options)); } return simpleCreator(variant, collected, options); }; } //# sourceMappingURL=create-nonterminal-variant-creator.js.map