Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to yaml npm package #28

Open
cowboyd opened this issue Nov 28, 2022 · 1 comment
Open

Migrate to yaml npm package #28

cowboyd opened this issue Nov 28, 2022 · 1 comment

Comments

@cowboyd
Copy link
Member

cowboyd commented Nov 28, 2022

In order to support documentation quick-views inside the language server, and for improved stack traces, we should use the modern, more actively maintained YAML parser. https://eemeli.org/yaml/#comments-and-blank-lines

I tried using this package before and it may require some fixes to make it work with Deno.

@cowboyd
Copy link
Member Author

cowboyd commented Jan 5, 2023

This is currently also blocking compiling the pls executable because the compiled version blows up with this:

$ ./pls ./artist-lookup-catalog-info.ps.yaml
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')
`+n)),r},e}();Ue.exports=Fn});var y=g(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});var Ge=B(),Sn=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],kn=["scalar","sequence","mapping"];function In(e){var i={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){i[String(r)]=n})}),i}var Tn=function(){function e(i,n){if(n=n||{},Object.keys(n).forEach(function(r){if(Sn.indexOf(r)===-1)throw new Ge('Unknown option "'+r+'" is met in definition of "'+i+'" YAML type.')}),this.tag=i,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.defaultStyle=n.defaultStyle||null,this.styleAliases=In(n.styleAliases||null),kn.indexOf(this.kind)===-1)throw new Ge('Unknown kind "'+this.kind+'" is specified for "'+i+'" YAML type.')}return e}();ce.Type=Tn});var U=g(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});var Ke=M(),z=B(),On=y();function pe(e,i,n){var r=[];return e.include.forEach(function(o){n=pe(o,i,n)}),e[i].forEach(function(o){n.forEach(function(l,u){l.tag===o.tag&&r.push(u)}),n.push(o)}),n.filter(function(o,l){return r.indexOf(l)===-1})}function Nn(){var e={},i,n;function r(o){e[o.tag]=o}for(i=0,n=arguments.length;i<n;i+=1)arguments[i].forEach(r);return e}var Pn=function(){function e(i){this.include=i.include||[],this.implicit=i.implicit||[],this.explicit=i.explicit||[],this.implicit.forEach(function(n){if(n.loadKind&&n.loadKind!=="scalar")throw new z("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=pe(this,"implicit",[]),this.compiledExplicit=pe(this,"explicit",[]),this.compiledTypeMap=Nn(this.compiledImplicit,this.compiledExplicit)}return e.DEFAULT=null,e.create=function(){var n,r;switch(arguments.length){case 1:n=e.DEFAULT,r=arguments[0];break;case 2:n=arguments[0],r=arguments[1];break;default:throw new z("Wrong number of arguments for Schema.create function")}if(n=Ke.toArray(n),r=Ke.toArray(r),!n.every(function(o){return o instanceof e}))throw new z("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(o){return o instanceof On.Type}))throw new z("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new e({include:n,explicit:r})},e}();ae.Schema=Pn});var Qe=g((ul,$e)=>{"use strict";var Ln=y();$e.exports=new Ln.Type("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var je=g((tl,Ve)=>{"use strict";var Mn=y();Ve.exports=new Mn.Type("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var We=g((fl,Je)=>{"use strict";var bn=y();Je.exports=new bn.Type("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var ze=g((cl,Xe)=>{"use strict";var Rn=U();Xe.exports=new Rn.Schema({explicit:[Qe(),je(),We()]})});var ei=g((pl,Ze)=>{"use strict";var Dn=y();function qn(e){if(e===null)return!0;var i=e.length;return i===1&&e==="~"||i===4&&(e==="null"||e==="Null"||e==="NULL")}function Yn(){return null}function Bn(e){return e===null}Ze.exports=new Dn.Type("tag:yaml.org,2002:null",{kind:"scalar",resolve:qn,construct:Yn,predicate:Bn,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var ni=g((al,ii)=>{"use strict";"use strict";var Un=y();function Hn(e){if(e===null)return!1;var i=e.length;return i===4&&(e==="true"||e==="True"||e==="TRUE")||i===5&&(e==="false"||e==="False"||e==="FALSE")}function Gn(e){return e==="true"||e==="True"||e==="TRUE"}function Kn(e){return Object.prototype.toString.call(e)==="[object Boolean]"}ii.exports=new Un.Type("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Hn,construct:Gn,predicate:Kn,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var oi=g((sl,ri)=>{"use strict";var $n=M(),Qn=y();function Vn(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function jn(e){return 48<=e&&e<=55}function Jn(e){return 48<=e&&e<=57}function Wn(e){if(e===null)return!1;var i=e.length,n=0,r=!1,o;if(!i)return!1;if(o=e[n],(o==="-"||o==="+")&&(o=e[++n]),o==="0"){if(n+1===i)return!0;if(o=e[++n],o==="b"){for(n++;n<i;n++)if(o=e[n],o!=="_"){if(o!=="0"&&o!=="1")return!1;r=!0}return r}if(o==="x"){for(n++;n<i;n++)if(o=e[n],o!=="_"){if(!Vn(e.charCodeAt(n)))return!1;r=!0}return r}for(;n<i;n++)if(o=e[n],o!=="_"){if(!jn(e.charCodeAt(n)))return!1;r=!0}return r}for(;n<i;n++)if(o=e[n],o!=="_"){if(o===":")break;if(!Jn(e.charCodeAt(n)))return!1;r=!0}return r?o!==":"?!0:/^(:[0-5]?[0-9])+$/.test(e.slice(n)):!1}function Xn(e){var i=e,n=1,r,o,l=[];return i.indexOf("_")!==-1&&(i=i.replace(/_/g,"")),r=i[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),i=i.slice(1),r=i[0]),i==="0"?0:r==="0"?i[1]==="b"?n*parseInt(i.slice(2),2):i[1]==="x"?n*parseInt(i,16):n*parseInt(i,8):i.indexOf(":")!==-1?(i.split(":").forEach(function(u){l.unshift(parseInt(u,10))}),i=0,o=1,l.forEach(function(u){i+=u*o,o*=60}),n*i):n*parseInt(i,10)}function zn(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!$n.isNegativeZero(e)}ri.exports=new Qn.Type("tag:yaml.org,2002:int",{kind:"scalar",resolve:Wn,construct:Xn,predicate:zn,represent:{binary:function(e){return"0b"+e.toString(2)},octal:function(e){return"0"+e.toString(8)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return"0x"+e.toString(16).toUpperCase()}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var ti=g((dl,ui)=>{"use strict";var li=M(),Zn=y(),er=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?|\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function ir(e){if(e===null)return!1;var i,n,r,o;return!!er.test(e)}function nr(e){var i,n,r,o;return i=e.replace(/_/g,"").toLowerCase(),n=i[0]==="-"?-1:1,o=[],0<="+-".indexOf(i[0])&&(i=i.slice(1)),i===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:i===".nan"?NaN:0<=i.indexOf(":")?(i.split(":").forEach(function(l){o.unshift(parseFloat(l,10))}),i=0,r=1,o.forEach(function(l){i+=l*r,r*=60}),n*i):n*parseFloat(i,10)}function rr(e,i){if(isNaN(e))switch(i){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(i){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(i){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(li.isNegativeZero(e))return"-0.0";return e.toString(10)}function or(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||li.isNegativeZero(e))}ui.exports=new Zn.Type("tag:yaml.org,2002:float",{kind:"scalar",resolve:ir,construct:nr,predicate:or,represent:rr,defaultStyle:"lowercase"})});var ci=g((hl,fi)=>{"use strict";var lr=U();fi.exports=new lr.Schema({include:[ze()],implicit:[ei(),ni(),oi(),ti()]})});var ai=g((xl,pi)=>{"use strict";var ur=U();pi.exports=new ur.Schema({include:[ci()]})});var hi=g((ml,di)=>{"use strict";var tr=y(),si=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");function fr(e){if(e===null)return!1;var i,n,r,o,l,u,t,f=0,p=null,c,x,s;return i=si.exec(e),i!==null}function cr(e){var i,n,r,o,l,u,t,f=0,p=null,c,x,s;if(i=si.exec(e),i===null)throw new Error("Date resolve error");if(n=+i[1],r=+i[2]-1,o=+i[3],!i[4])return new Date(Date.UTC(n,r,o));if(l=+i[4],u=+i[5],t=+i[6],i[7]){for(f=i[7].slice(0,3);f.length<3;)f=f+"0";f=+f}return i[9]&&(c=+i[10],x=+(i[11]||0),p=(c*60+x)*6e4,i[9]==="-"&&(p=-p)),s=new Date(Date.UTC(n,r,o,l,u,t,f)),p&&s.setTime(s.getTime()-p),s}function pr(e){return e.toISOString()}di.exports=new tr.Type("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:fr,construct:cr,instanceOf:Date,represent:pr})});var mi=g((gl,xi)=>{"use strict";var ar=y();function sr(e){return e==="<<"||e===null}xi.exports=new ar.Type("tag:yaml.org,2002:merge",{kind:"scalar",resolve:sr})});var vi=g((vl,gi)=>{"use strict";var Z=__buffer$.Buffer,dr=y(),se=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
    at e.qn [as resolve] (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:6:3198)
    at K (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:17:5378)
    at uo (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:17:1303)
    at K (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:17:4752)
    at po (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:17:7001)
    at Hi (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:18:197)
    at ke (https://esm.sh/v96/[email protected]/deno/yaml-ast-parser.js:19:347)
    at parse (file:///Users/cowboyd/Code/@frontside/yamlscript/evaluate.ts:173:16)
    at load (file:///Users/cowboyd/Code/@frontside/yamlscript/load.ts:8:16)
    at load.next (<anonymous>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant