UNPKG

code-server

Version:

Run VS Code on a remote server.

2 lines (1 loc) • 2.54 kB
import{a as n,b as p,c as f}from"./chunk-5TI3OQE5.js";import{a as i}from"./chunk-2S6PUNXZ.js";import{b as l}from"./chunk-R6TTN2K4.js";import"./chunk-MORPLMM4.js";import"./chunk-PAO23QCD.js";import"./chunk-NZ3Q2WJX.js";import"./chunk-PPKVOE2H.js";import{b as m}from"./chunk-JXO2KM4E.js";import"./chunk-PNBHH3ZV.js";import"./chunk-ABRXOUHG.js";import"./chunk-QSWXSH5R.js";import"./chunk-U4VSMEDZ.js";import"./chunk-CQHAQPZP.js";import"./chunk-4HJKLDAT.js";import"./chunk-ROB3ZELR.js";import"./chunk-JZV3OND4.js";import"./chunk-JHQ3LEJ2.js";import"./chunk-BQR5VGCX.js";import"./chunk-ECAF5OLA.js";import"./chunk-QRLMLG33.js";import"./chunk-5Z3D3SW5.js";import{b as o}from"./chunk-SNB7PWCV.js";import"./chunk-CU3WNRKO.js";import{a as t}from"./chunk-5ZAMBDF5.js";import"./chunk-3RNHDNP5.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};