import{a as n,b as p,c as f}from"./chunk-WBKED7LK.js";import"./chunk-AQ7QNAOH.js";import{a as i}from"./chunk-CDENLQJG.js";import{b as l}from"./chunk-GCLFR7RJ.js";import"./chunk-GBAVNUHL.js";import{b as m}from"./chunk-BPMBFFCK.js";import"./chunk-OMKCQORZ.js";import"./chunk-NPTHKJ2T.js";import"./chunk-PNOROMQC.js";import"./chunk-YLPW272G.js";import"./chunk-EE6VSO4L.js";import"./chunk-KIKOYZ3Y.js";import"./chunk-AYJOBZGG.js";import"./chunk-72QLSRFG.js";import"./chunk-RZZP2ERR.js";import"./chunk-SR3GFKQL.js";import"./chunk-6FD75OKF.js";import"./chunk-QY6Y4V6I.js";import"./chunk-O4AR42YJ.js";import"./chunk-F4FWBINX.js";import"./chunk-2LQZINQI.js";import{b as o}from"./chunk-BG5BKATX.js";import{a as t}from"./chunk-YUSHYV7C.js";import"./chunk-3ZIVKGVJ.js";import"./chunk-OOJM4CTU.js";var c=m().RailroadEbnf.parser.LangiumParser,s=t(e=>{let r=e.alternatives.map(E);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformChoice"),E=t(e=>{let r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformSequence"),u=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=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:"-"},u(r.except)]};default:throw new Error(`Unsupported EBNF postfix node: ${r.$type}`)}},"transformPostfix"),y=t(e=>e.postfixes.reduce((r,a)=>b(r,a),u(e.base)),"transformTerm"),d=t(e=>({name:e.name,definition:s(e.definition)}),"transformRule"),v=t(e=>{i(e,n),e.title&&n.setTitle(e.title),e.rules.map(r=>n.addRule(d(r)))},"populateDb"),P={parse:t(e=>{n.clear(),o.debug("[EBNF Parser] Starting Langium parse");let r=c.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new l(r);let a=r.value;o.debug("[EBNF Parser] Parsed rules:",a.rules.length),v(a),o.debug("[EBNF Parser] Parse complete")},"parse"),parser:{yy:n}},$={parser:P,db:n,renderer:f,styles:p};export{$ as diagram};
