@live-codes/browser-compilers 0.22.5 → 0.22.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ "use strict";(()=>{var h="minizinc",x={parse(n,i,e){return{type:"minizinc-root",body:n,loc:{start:{line:1,column:0},end:{line:n.split(`
2
+ `).length,column:0}}}},astFormat:h,locStart:n=>n.loc?.start??{line:1,column:0},locEnd:n=>n.loc?.end??{line:1,column:0}},y={print(n,i,e){let t=n.getValue();return t.type==="minizinc-root"?C(t.body,i):t.body}};function C(n,i){let e=i.printWidth||80,t=i.tabWidth||2,s=b(n),c=M(s),o=[];for(let r=0;r<c.length;r++){let l=c[r];if(l.trim()===""){o.push("");continue}let a=P(l,e,t);o.push(a)}return o.join(`
3
+ `)}function d(n){return n.startsWith("%")&&n.length>1&&n[1]!==" "?"% "+n.slice(1):n}function b(n){let i=n.split(`
4
+ `),e=[];for(let t of i){let s=z(t);e.push(...s)}return e.join(`
5
+ `)}function z(n){let i=n.trim();if(i.startsWith("%"))return[d(i)];let e=S(n);if(e!==-1){let t=n.slice(0,e),s=n.slice(e).trim();if(!t.trim())return[d(s)];let c=g(t);if(c.length===0)return[n];let o=c.length-1;return c[o]=c[o]+" "+d(s),c}return g(n)}function S(n){let i=!1,e=null;for(let t=0;t<n.length;t++){let s=n[t],c=t+1<n.length?n[t+1]:null;if(s==="\\"){c!==null&&t++;continue}if(s==='"'||s==="'"){i?s===e&&(i=!1,e=null):(i=!0,e=s);continue}if(!i&&s==="%")return t}return-1}function g(n){let i=[],e="",t=!1,s=null,c=0;for(let r=0;r<n.length;r++){let l=n[r],a=r+1<n.length?n[r+1]:null;if(l==="\\"){e+=l,a!==null&&(r++,e+=n[r]);continue}if(l==='"'||l==="'"){t?l===s&&(t=!1,s=null):(t=!0,s=l),e+=l;continue}if(t||((l==="["||l==="("||l==="{")&&c++,(l==="]"||l===")"||l==="}")&&c--),e+=l,l===";"&&!t&&c===0){let f=e.trim();f&&i.push(f),e=""}}let o=e.trim();return o&&i.push(o),i.length>0?i:[n]}function E(n){let i=S(n),t=(i!==-1?n.slice(0,i):n).trim();return t.endsWith(";")||t.endsWith("]")||t.endsWith(")")&&!n.includes("++")}function M(n){let i=n.split(`
6
+ `),e=[],t="";for(let s=0;s<i.length;s++){let o=i[s].trim();if(o===""){t&&(e.push(t),t=""),e.push("");continue}if(o.startsWith("%")){t&&(e.push(t),t=""),e.push(o);continue}let r=E(o);t?t+=" "+o:t=o,r&&(e.push(t),t="")}return t&&e.push(t),e}function P(n,i,e){let t=n.trim();return t.startsWith("%")||t.length<=i?t:t.match(/^(\w+)\s*\[(.+)\];?\s*$/)?L(t,i,e):t.match(/^(.+?)\((.+)\);?\s*$/)?j(t,i,e):t}function L(n,i,e){let t=n.match(/^(\w+)\s*\[(.+)\];?\s*$/);if(!t)return n;let s=t[1],c=t[2],o=n.trimEnd().endsWith(";"),r=$(c),l=`${s} [${c}]${o?";":""}`;if(l.length<=i)return l;let a=" ".repeat(s.length+2),f=[];for(let m=0;m<r.length;m++)m===0?f.push(r[m]):f.push(a+r[m]);return`${s} [${f.join(`,
7
+ `)}]${o?";":""}`}function j(n,i,e){let t=n.trimEnd().endsWith(";"),s=t?n.slice(0,-1).trimEnd():n,c=0,o=-1;for(let u=0;u<s.length;u++)s[u]==="("?(c===0&&(o=u),c++):s[u]===")"&&c--;if(o===-1)return n;let r=s.slice(0,o),l=s.slice(o+1),a=l.endsWith(")")?l.slice(0,-1):l,f=$(a),m=`${r}(${a})${t?";":""}`;if(m.length<=i)return m;let W=" ".repeat(e),p=[];for(let u=0;u<f.length;u++)u===0?p.push(f[u]):p.push(W+f[u]);return`${r}(${p.join(`,
8
+ `)})${t?";":""}`}function $(n){let i=[],e="",t=!1,s=null,c=0;for(let o=0;o<n.length;o++){let r=n[o],l=o+1<n.length?n[o+1]:null;if(r==="\\"){e+=r,l!==null&&(o++,e+=n[o]);continue}if(r==='"'||r==="'"){t?r===s&&(t=!1,s=null):(t=!0,s=r),e+=r;continue}t||((r==="["||r==="("||r==="{")&&c++,(r==="]"||r===")"||r==="}")&&c--),r===","&&!t&&c===0?(i.push(e.trim()),e=""):e+=r}return e.trim()&&i.push(e.trim()),i}var I=[{name:"MiniZinc",parsers:[h],extensions:[".mzn",".dzn"],vscodeLanguageIds:["minizinc"]}],k={[h]:x},B={[h]:y};(globalThis.prettierPlugins??={})[h]={languages:I,parsers:k,printers:B};})();