import{a as r,b as l,c as m}from"./chunk-UITSOMYB.mjs";import{a as f}from"./chunk-JQRUD6KW.mjs";import{b as p}from"./chunk-DMV4VAQV.mjs";import"./chunk-HNC4WDU7.mjs";import"./chunk-SATU7PGQ.mjs";import"./chunk-224SPVON.mjs";import"./chunk-EQFTRU2I.mjs";import{b as s}from"./chunk-E5QJAATJ.mjs";import"./chunk-66DQ2XMT.mjs";import"./chunk-D6VWDJW2.mjs";import"./chunk-BI6VK774.mjs";import"./chunk-XNMVGMAZ.mjs";import"./chunk-4RFN2BYJ.mjs";import"./chunk-FWYVLQTC.mjs";import"./chunk-RRFMTAIC.mjs";import"./chunk-TZUXEDM2.mjs";import"./chunk-OIYT25JQ.mjs";import"./chunk-NV3KIAZN.mjs";import"./chunk-L5GCOVLC.mjs";import"./chunk-Y3FQM624.mjs";import"./chunk-KEUXMURM.mjs";import{b as i}from"./chunk-LIEV3EAG.mjs";import{a as n}from"./chunk-AQ6EADP3.mjs";var b=s().RailroadEbnf.parser.LangiumParser,a=n(e=>{let t=e.alternatives.map(c);return t.length===1?t[0]:{type:"choice",alternatives:t}},"transformChoice"),c=n(e=>{let t=e.elements.map(d);return t.length===1?t[0]:{type:"sequence",elements:t}},"transformSequence"),u=n(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 a(e.element);case"EbnfOptional":return{type:"optional",element:a(e.element)};case"EbnfRepetition":return{type:"repetition",element:a(e.element),min:0,max:1/0};default:throw new Error(`Unsupported EBNF primary node: ${e.$type}`)}},"transformPrimary"),y=n((e,t)=>{switch(t.$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(t.except)]};default:throw new Error(`Unsupported EBNF postfix node: ${t.$type}`)}},"transformPostfix"),d=n(e=>e.postfixes.reduce((t,o)=>y(t,o),u(e.base)),"transformTerm"),g=n(e=>({name:e.name,definition:a(e.definition)}),"transformRule"),x=n(e=>{f(e,r),e.title&&r.setTitle(e.title),e.rules.map(t=>r.addRule(g(t)))},"populateDb"),E={parse:n(e=>{r.clear(),i.debug("[EBNF Parser] Starting Langium parse");let t=b.parse(e);if(t.lexerErrors.length>0||t.parserErrors.length>0)throw new p(t);let o=t.value;i.debug("[EBNF Parser] Parsed rules:",o.rules.length),x(o),i.debug("[EBNF Parser] Parse complete")},"parse"),parser:{yy:r}};var O={parser:E,db:r,renderer:m,styles:l};export{O as diagram};
