UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

113 lines (112 loc) 3.08 kB
import { f as m, t as l } from "./mermaid-parser.core-uIDZYuBu.js"; import { n as t } from "./chunk-Y2CYZVJY-0JxdZxki.js"; import { m as o } from "./src-DtRLxcYO.js"; import "./chunk-WYO6CB5R-DDHkKowO.js"; import "./chunk-VAUOI2AC-izt0o4id.js"; import { n as p, r as f, t as n } from "./chunk-MOJQB5TN-BC46HDyu.js"; import { t as u } from "./chunk-JWPE2WC7-CGEmUMMZ.js"; var c = m().RailroadEbnf.parser.LangiumParser, s = /* @__PURE__ */ t((e) => { const r = e.alternatives.map(E); return r.length === 1 ? r[0] : { type: "choice", alternatives: r }; }, "transformChoice"), E = /* @__PURE__ */ t((e) => { const r = e.elements.map(y); return r.length === 1 ? r[0] : { type: "sequence", elements: r }; }, "transformSequence"), i = /* @__PURE__ */ t((e) => { switch (e.$type) { case "EbnfTerminal": return { type: "terminal", value: e.value }; case "EbnfNonTerminal": return { type: "nonterminal", name: e.name }; case "EbnfSpecial": return { type: "special", text: e.text }; case "EbnfGroup": return s(e.element); case "EbnfOptional": return { type: "optional", element: s(e.element) }; case "EbnfRepetition": return { type: "repetition", element: s(e.element), min: 0, max: 1 / 0 }; default: throw new Error(`Unsupported EBNF primary node: ${e.$type}`); } }, "transformPrimary"), b = /* @__PURE__ */ t((e, r) => { switch (r.$type) { case "EbnfOptionalPostfix": return { type: "optional", element: e }; case "EbnfZeroOrMorePostfix": return { type: "repetition", element: e, min: 0, max: 1 / 0 }; case "EbnfOneOrMorePostfix": return { type: "repetition", element: e, min: 1, max: 1 / 0 }; case "EbnfExceptionPostfix": return { type: "sequence", elements: [ e, { type: "terminal", value: "-" }, i(r.except) ] }; default: throw new Error(`Unsupported EBNF postfix node: ${r.$type}`); } }, "transformPostfix"), y = /* @__PURE__ */ t((e) => e.postfixes.reduce((r, a) => b(r, a), i(e.base)), "transformTerm"), d = /* @__PURE__ */ t((e) => ({ name: e.name, definition: s(e.definition) }), "transformRule"), v = /* @__PURE__ */ t((e) => { u(e, n), e.title && n.setTitle(e.title), e.rules.map((r) => n.addRule(d(r))); }, "populateDb"), S = { parser: { parse: /* @__PURE__ */ t((e) => { n.clear(), o.debug("[EBNF Parser] Starting Langium parse"); const r = c.parse(e); if (r.lexerErrors.length > 0 || r.parserErrors.length > 0) throw new l(r); const a = r.value; o.debug("[EBNF Parser] Parsed rules:", a.rules.length), v(a), o.debug("[EBNF Parser] Parse complete"); }, "parse"), parser: { yy: n } }, db: n, renderer: f, styles: p }; export { S as diagram };