Socket
Socket
Sign inDemoInstall

@bavary/core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bavary/core - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

lib/types/ast/nodes/character-selection/common-token.d.ts

4

lib/bavary.js

@@ -1,3 +0,3 @@

/*! Bavary 0.0.20 MIT | https://github.com/Simonwep/bavary */
var e,t;e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:Function("return this")(),t=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=19)}([function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.maybe=e=>t=>{t.stash();const r=e(t);return null!==r?(t.recycle(),r):(t.pop(),null)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(6);t.optional=(e,t,r,...o)=>n.check(e,t,r,...o)?e.next(t).value:null},function(e,t,r){function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(25)),n(r(26)),n(r(28)),n(r(29)),n(r(31)),n(r(16)),n(r(32)),n(r(33)),n(r(35)),n(r(36)),n(r(37)),n(r(38)),n(r(39)),n(r(44)),n(r(15)),n(r(10));var o=r(14);t.operatorPriority=o.operatorPriority},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.expect=(e,t,r,...o)=>{const s=n.optional(e,t,r,...o);if(null!==s)return s;const a=e.next(t);null!==a&&e.throwError(`Expected ${o.join(", ")} (${r}) but got ${a.value} (${a.type})`),e.throwError("Unxpected end of input.")}},function(e,t,r){function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(46)),n(r(49)),n(r(50)),n(r(51)),n(r(53)),n(r(54)),n(r(55)),n(r(56)),n(r(57)),n(r(58))},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.skipWhitespace=e=>{var t;"ws"===(null===(t=e.peek(!0))||void 0===t?void 0:t.type)&&e.next(!0)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.check=(e,t,r,...n)=>{const o=e.peek(t);return!(!o||o.type!==r)&&(!n.length||n.includes(o.value))}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.combine=(...e)=>t=>{for(const r of e){const e=r(t);if(null!==e)return e}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isPunctuation=e=>e<"0"||e>"z"||e>"9"&&e<"A"||e>"Z"&&e<"a",t.isNonWhitespace=e=>e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e,t.isWhiteSpace=e=>"\t"===e||"\n"===e||"\r"===e||" "===e,t.isNumeric=e=>e>="0"&&e<="9"},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Streamable=class{constructor(e,t=null){this.vals=e,this.length=e.length,this.source=t,this.index=0,this.stashed=[]}stash(){this.stashed.push(this.index)}pop(){this.index=this.stashed.pop()}next(){return this.hasNext()?this.vals[this.index++]:null}peek(){return this.hasNext()?this.vals[this.index]:null}hasNext(){return this.index<this.vals.length}recycle(){this.stashed.pop()}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(7),s=r(3),a=r(0),i=r(1),l=a.maybe(e=>{if(!i.optional(e,!0,"punc","."))return null;const t=n.parseIdentifier(e);return t?t.value:e.throwError("Expected identifier.")}),u=a.maybe(e=>{if(!i.optional(e,!0,"punc","["))return null;const t=s.expect(e,!1,"num");return s.expect(e,!0,"punc","]"),t});t.parseValueAccessor=a.maybe(e=>{const t=n.parseIdentifier(e),r=t?[t.value]:[],s=o.combine(l,u);for(let t=null;null!==(t=s(e));)r.push(t);return r.length?{type:"value-accessor",value:r}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(12);t.lookupValue=(e,t)=>{for(const r of t){const t=n.typeOf(e);if("array"!==t&&"string"!==t||"length"!==r){if("string"==typeof r){if("object"==typeof e&&null!==e&&void 0!==(e=e[r]))continue}else if(Array.isArray(e)&&r<e.length){e=e[r];continue}return null}e=e.length}return e}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.typeOf=e=>{const t=typeof e;return"object"===t?Array.isArray(e)?"array":"object":t}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.maybeMultiplier=e=>t=>{const{stream:r,decl:n}=t,o=()=>{const r=[];for(let n;n=e(t);)r.push(n);return r};if(r.stash(),n.multiplier){const{type:e,value:t}=n.multiplier;switch(e){case"zero-infinity":return r.recycle(),o();case"one-infinity":{const e=o();return e.length?(r.recycle(),e):(r.pop(),null)}case"range":{const{start:e,end:n}=t,s=o();return s.length<e||null!==n&&s.length>n?(r.pop(),null):(r.recycle(),s)}}}return r.recycle(),e(t)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.operatorPriority={"|":1,"&":2,"=":4,"<":4,">":4,"!=":4,"<=":4,">=":4}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(0),s=r(1);t.parseTag=o.maybe(e=>{if(!s.optional(e,!0,"punc","#"))return null;const t=n.parseIdentifier(e);return t?{type:"tag",value:t.value}:e.throwError("Expected identifier")})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(3),s=r(0),a=r(1);t.parseDeclaration=s.maybe(e=>{var t;const r=a.optional(e,!1,"kw","entry","default","export");let s,i=null,l=null;return a.optional(e,!1,"punc","<")?(i=n.parseIdentifier(e),i||e.throwError("Expected identifier."),l=n.parseArguments(e),o.expect(e,!1,"punc",">"),o.expect(e,!1,"punc","=")):r||e.throwError("Expected declaration."),(null===(t=l)||void 0===t?void 0:t.length)?(s=n.parseGroup(e),s||e.throwError("Expected a group.")):(s=n.parseGroup(e)||n.parseBlock(e),s||e.throwError("Expected a group or block-statement.")),{type:"declaration",name:i?i.value:null,variant:r,value:s,arguments:l}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeParsingResult=function e(t,r,n=!1){const{obj:o}=r;for(const s of t)"reference"===s.type&&s.tag?((void 0===o[s.tag]||n)&&(o[s.tag]=null),r.pure=!1):"group"===s.type||"combinator"===s.type?e(s.value,r,n):"conditional-statement"===s.type&&(e([s.consequent],r,n),s.alternate&&e([s.alternate],r,n))}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.consumeWhile=(e,t)=>{let r="";for(;e.hasNext()&&t(e.peek(),r);)r+=e.next();return r}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(20),o=r(45),s=r(60),a=r(61);t.compile=(e,t)=>{const r=Array.isArray(e)?e:n.parseAST(a.tokenize(e),e);return o.compileDeclarations(r,t)},t.compileChunk=e=>n.parseAST(a.tokenize(e),e),t.version=s.ENV_VERSION},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(21);r(2);const o=r(16);t.parseAST=(e,t)=>{const r=new n.TokenStream(e,t),s=[];for(;r.hasNext();)s.push(o.parseDeclaration(r));return s}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(9),o=r(22);class s extends n.Streamable{next(e=!1){const{index:t,length:r,vals:n}=this;if(e&&t<r)return n[this.index++];for(let e=t;e<r;e++)if("ws"!==n[e].type)return this.index=e+1,n[e];return null}peek(e=!1){const{index:t,length:r,vals:n}=this;if(e&&t<r)return n[t];for(let e=t;e<r;e++)if("ws"!==n[e].type)return n[e];return null}hasNext(e=!1){return null!==this.peek(e)}throwError(e){const{index:t,source:r}=this;if(!r)throw new o.ParsingError(e);if(this.hasNext()){const t=this.peek();throw new o.ParsingError(r,e,t.start,t.end)}throw new o.ParsingError(r,e,t,t)}}t.TokenStream=s},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(23);class o extends Error{constructor(e,t,r,o){super(r&&o&&t?n.prettifyError(e,t,r,o):e),this.source=t,this.start=r,this.end=o,this.msg=e,this.name="Parsing Error"}}t.ParsingError=o},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(24));function s(e,t,r=-1){return e===r?t:e}t.prettifyError=(e,t,r,n)=>{const a=s(o.default(e,"\n",r),-1)+1,i=s(e.indexOf("\n",n),e.length),l=r-a;return`\n${e.slice(a,i)}\n${" ".repeat(l)}^\n${t}`}},function(e,t){e.exports=(e,t,r)=>{if("string"!=typeof t||"string"!=typeof e||r<t.length-1)return-1;"number"!=typeof r&&(r=e.length-1);const n=t.length-1;for(let o=r,s=n;o>=0;o--)if(e[o]===t[s]){if(s--,!~s)return o}else s!==n&&(s=n,o++);return-1}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(0),s=r(1),a=r(5);t.parseArguments=o.maybe(e=>{const t=[];for(;;){a.skipWhitespace(e);const r=n.parseIdentifier(e);if(!r)break;let o=null;s.optional(e,!1,"punc","=")&&(o=n.parseGroup(e),o||e.throwError("Expected a group.")),t.push({type:"argument",name:r.value,value:o})}return t.length?t:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(7),s=r(3),a=r(0),i=r(1),l=r(5),u=r(14),c=r(27);t.parseBinaryExpression=a.maybe(e=>{if(!i.optional(e,!1,"punc","("))return null;const r=o.combine(c.taggedValueAccessor,t.parseBinaryExpression,n.parseString,n.parseNumber,n.parseIdentifier),a=r(e);if(!a)return null;const p=function e(t,r,n,o=0){r.stash();const s=i.optional(r,!1,"punc")+(i.optional(r,!0,"punc")||"");if(!(s&&s in u.operatorPriority))return r.pop(),t;const a=u.operatorPriority[s];if(a>o){l.skipWhitespace(r);const i=n(r);return i||r.throwError("Expected right-hand value"),e({type:"binary-expression",right:e(i,r,n,a),operator:s,left:t},r,n,o)}return r.pop(),t}(a,e,r);return"binary-expression"!==p.type&&e.throwError("Expected binary expression."),s.expect(e,!1,"punc",")"),p})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(15),s=r(10);t.taggedValueAccessor=n.maybe(e=>{var t;const r=o.parseTag(e);return r?{type:"value-accessor",value:[r.value,...(null===(t=s.parseValueAccessor(e))||void 0===t?void 0:t.value)||[]]}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(6),s=r(3),a=r(0),i=r(1);t.parseBlock=a.maybe(e=>{if(!i.optional(e,!1,"punc","{"))return null;const t=[];for(;!o.check(e,!1,"punc","}");)t.push(n.parseDeclaration(e));return s.expect(e,!1,"punc","}"),{type:"block",value:t}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(30),s=r(3),a=r(0),i=r(1),l=e=>{const t=o.parseUnicodeEscape(e);if(null!==t)return t;if(!e.hasNext())return null;const r=e.peek(),n=String(r.value),s="\\"===n;if(1!==n.length||"punc"===r.type&&!s)return null;if(e.next(),s){if(!e.hasNext())return null;const t=e.peek(),r=String(t.value);return"punc"!==t.type&&e.throwError("Only punctuation characters need to be escaped."),e.next(),r.charCodeAt(0)}return n.charCodeAt(0)},u=e=>{const t=[];for(;;){let r=null,n=null;if(r=l(e),null===r&&e.throwError("Missing character (-sequence)."),i.optional(e,!1,"punc","-")?(n=l(e),null===n&&e.throwError("Expected end position.")):n=null,null!==n?t.push([Math.min(r,n),Math.max(r,n)]):t.push(r),!i.optional(e,!1,"punc",","))break}return t};t.parseCharacterSelecton=a.maybe(e=>{if(!i.optional(e,!1,"punc","("))return null;const t=[],r=[];return t.push(...u(e)),i.optional(e,!1,"kw","except")&&r.push(...u(e)),s.expect(e,!1,"punc",")"),{type:"character-selection",multiplier:n.parseMultiplier(e),included:t,excluded:r}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(1);t.parseUnicodeEscape=n.maybe(e=>{if(!o.optional(e,!1,"punc","\\")||!e.hasNext())return null;const t=String(e.next().value);if(!t.startsWith("u"))return null;5!==t.length&&e.throwError('An unicode-escape sequence consists out of an "u" followed by a code-point.');const r=t.slice(1);for(const t of r){const r=t.charCodeAt(0);(r<48||r>57&&r<97||r>102)&&e.throwError("Invalid unicode-range.")}return parseInt(r,16)})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(0),s=r(1);t.parseConditionalStatement=o.maybe(e=>{if(!s.optional(e,!1,"kw","if"))return null;const r=n.parseBinaryExpression(e);r||e.throwError("Expected a binary expression.");const o=n.parseGroup(e);o||e.throwError("Expected a group.");let a=null;return s.optional(e,!1,"kw","else")&&(a=n.parseGroup(e)||t.parseConditionalStatement(e),a||e.throwError("Expected a group.")),{type:"conditional-statement",condition:r,consequent:o,alternate:a}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(6),s=r(7),a=r(3),i=r(0),l=r(1),u=r(5);t.parseFunction=i.maybe(e=>{u.skipWhitespace(e);const t=n.parseIdentifier(e);if(!t||!l.optional(e,!1,"punc","("))return null;const r=s.combine(n.parseIdentifier,n.parseTag,n.parseGroup,n.parseString,n.parseReference),i=[];for(;!o.check(e,!1,"punc",")");){u.skipWhitespace(e),i.length&&a.expect(e,!1,"punc",","),u.skipWhitespace(e);const t=r(e);t||e.throwError("Expected an a group, tag or identifier."),i.push(t)}return a.expect(e,!1,"punc",")"),{type:"function",name:t.value,args:i}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(34),s=r(6),a=r(7),i=r(3),l=r(0),u=r(1);t.parseGroup=l.maybe(e=>{if(!u.optional(e,!1,"punc","["))return null;const r=[],l=a.combine(n.parseConditionalStatement,n.parseFunction,n.parseIgnored,t.parseGroup,n.parseReference,n.parseCharacterSelecton,n.parseString);let c=null;for(;!s.check(e,!1,"punc","]");){const t=l(e),n=o.parseCombinator(e);if(t||e.throwError("Expected a type, group or raw string / character-range."),n){if(c){if(n===c.sign)c.value.push(t);else{const e={type:"combinator",value:[t],sign:n};c.value.push(e),c=e}continue}c={type:"combinator",value:[t],sign:n},r.push(c)}else c?(c.value.push(t),c=null):r.push(t)}return c&&e.throwError("Combinator is missing a value!"),i.expect(e,!1,"punc","]"),{type:"group",multiplier:n.parseMultiplier(e),value:r}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(1);t.parseCombinator=n.maybe(e=>{let t=o.optional(e,!1,"punc","|","&");return t?("&"===t&&o.optional(e,!1,"punc","&")&&(t+="&"),t):null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseIdentifier=n.maybe(e=>{let t="";for(;e.hasNext(!0);){const{type:r,value:n}=e.peek(!0);if("ws"===r)break;if(!("punc"===r&&"-"===n&&t.length||"num"===r||"kw"===r))break;t+=n,e.next(!0)}return t.endsWith("-")&&e.throwError("Identifier cannot end with a hyphen"),t.length?{type:"identifier",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(3),o=r(0),s=r(1),a={"*":"zero-infinity","+":"one-infinity","?":"optional"};t.parseMultiplier=o.maybe(e=>{const t=s.optional(e,!0,"punc","*","+","?","{");if("{"===t){const t=n.expect(e,!1,"num");n.expect(e,!1,"punc",",");const r=s.optional(e,!1,"num");return null!==r&&r-t<0&&e.throwError("The difference between start and end-value cannot be negative or zero."),n.expect(e,!1,"punc","}"),{type:"range",value:{start:t,end:r}}}return t?{type:a[t],value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(3),s=r(0),a=r(1);t.parseIgnored=s.maybe(e=>{if(!a.optional(e,!1,"punc","/"))return null;const t=n.parseGroup(e);return t||e.throwError("Expected group."),o.expect(e,!1,"punc","/"),{type:"ignored",value:t}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(1);t.parseNumber=n.maybe(e=>{const t=o.optional(e,!1,"num");return t?{type:"number",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(40),s=r(43),a=r(3),i=r(0),l=r(1);t.parseReference=i.maybe(e=>{var t;const r=s.parseSpreadOperator(e);if(!l.optional(e,!1,"punc","<"))return null;const i=[];let u=!1;for(;e.hasNext();){const t=n.parseIdentifier(e);if(t&&(u=!1,i.push(t.value)),!l.optional(e,!1,"punc",":"))break;u=!0}!u&&i.length||e.throwError("Expected identifier");const c=n.parseTag(e);r&&c&&e.throwError("Type cannot have both a tag an spread operator attached to it.");const p=o.parseModification(e),f=n.parseArguments(e);a.expect(e,!1,"punc",">");const d=n.parseMultiplier(e);return{type:"reference",tag:(null===(t=c)||void 0===t?void 0:t.value)||null,arguments:f,modifiers:p,multiplier:d,spread:r,value:i}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(3),o=r(0),s=r(1),a=r(5),i=r(41),l=r(42),u={def:i.parseDefineModifier,del:l.parseDeleteModifier};t.parseModification=o.maybe(e=>{if(!s.optional(e,!0,"punc","{"))return null;const t=[];do{const r=s.optional(e,!1,"kw","def","del");r?(a.skipWhitespace(e),t.push(u[r](e))):e.throwError("Expected operator")}while(s.optional(e,!1,"punc",","));return n.expect(e,!1,"punc","}"),t})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(3),s=r(5);t.parseDefineModifier=e=>{const t=n.parseIdentifier(e);t||e.throwError("Expected identifier"),o.expect(e,!1,"punc","="),s.skipWhitespace(e);const r=n.parseString(e)||n.parseValueAccessor(e);return r||e.throwError("Expected string, function-call or value-accessor."),{type:"def",key:t.value,value:r}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(10);t.parseDeleteModifier=e=>{const t=n.parseValueAccessor(e);return t||e.throwError("Expected a value accessor."),{type:"del",param:t}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(1);t.parseSpreadOperator=n.maybe(e=>{for(let t=0;t<3;t++)if(!o.optional(e,!1,"punc","."))return!1;return!0})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(1);t.parseString=n.maybe(e=>{const t=o.optional(e,!1,"str");return null===t||t.length||e.throwError("Strings shouldn't be empty."),t?{type:"string",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(9),o=r(4),s=r(59);t.compileDeclarations=(e,t={locationData:!1,functions:{}})=>{const r=new s.Scope({global:!0});r.registerAll(e),!0===t.locationData&&(t.locationData={start:"__starts",end:"__ends"});const a=r.lookup("entry");if(!a)throw new Error("Couldn't resolve entry type. Use the entry keyword to declare one.");const[i,l]=a;return e=>{const r=new n.Streamable(e),s=o.evalGroup({config:t,stream:r,scope:l,decl:i.value});return r.hasNext()?null:s}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(47),o=r(48);t.evalModification=(e,t)=>{for(const r of t.modifiers)switch(r.type){case"def":n.def(e,r);break;case"del":o.del(e,r)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(11);t.def=(e,{value:t,key:r})=>{switch(t.type){case"string":e[r]=t.value;break;case"value-accessor":e[r]=n.lookupValue(e,t.value)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(11),o=r(12);t.del=(e,t)=>{const r=[...t.param.value],s=r.pop(),a=o.typeOf(s),i=n.lookupValue(e,r),l=o.typeOf(i);if(!i)throw new Error("Failed to resolve parent value.");if("array"===l){if("number"!==a)throw new Error(`To delete an array entry you need to specify a index, got ${s} instead.`);i.splice(s,1)}else{if("object"!==l)throw new Error("Target must be an object or array.");if("string"!==a)throw new Error("To remove an object-property you need to specify a identifier.");delete i[s]}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(13),o=(e,t)=>e.some(e=>"number"==typeof e?e===t:t>=e[0]&&t<=e[1]);t.evalCharacterSelection=({config:e,stream:t,decl:r,scope:s,result:a})=>{const{included:i,excluded:l}=r,u=n.maybeMultiplier(()=>{if(t.hasNext()){const e=t.peek(),r=e.charCodeAt(0);if(o(i,r)&&!o(l,r))return t.next(),e}return null})({config:e,stream:t,decl:r,scope:s,result:a});if(Array.isArray(u))a.str+=u.join("");else if("string"==typeof u)a.str+=u;else if(!u&&!r.multiplier||r.multiplier&&"optional"!==r.multiplier.type)return!1;return!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),o=r(17);t.evalCombiantor=({config:e,stream:t,decl:r,scope:s,result:a})=>{switch(t.stash(),o.serializeParsingResult(r.value,a),r.sign){case"|":{const o=r.value;for(let r=0;r<o.length;r++)if(n.evalDeclaration({config:e,stream:t,decl:o[r],scope:s,result:a}))return t.recycle(),!0;break}case"&&":case"&":{const o=[...r.value];for(let r=0;r<o.length;r++)n.evalDeclaration({config:e,stream:t,decl:o[r],scope:s,result:a})&&(o.splice(r,1),r=-1);if(!o.length||"&&"===r.sign&&o.length<r.value.length)return t.recycle(),!0;break}}return t.pop(),!1}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),o=r(52);t.evalConditionalStatement=({config:e,stream:r,decl:s,scope:a,result:i})=>{const{condition:l,consequent:u,alternate:c}=s,p=o.evalBinaryExpression(i,l)?u:c;if(!p)return!0;const f=("group"===p.type?n.evalGroup:t.evalConditionalStatement)({config:e,stream:r,scope:a,result:i,decl:p});return null!==f&&!1!==f}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(11);function o(e,t){switch(t.type){case"binary-expression":return a(e,t);case"value-accessor":{const[r]=t.value;if(void 0===e.obj[r])throw new Error(`Tag "${r}" isn't defined anywhere but used in a condition.`);return n.lookupValue(e.obj,t.value)}case"identifier":if("null"===t.value)return null;throw new Error(`Unknown constant: "${t.value}"`);default:return t.value}}function s(e){return!(!1===e||null==e)}function a(e,t){let{operator:r}=t,n=o(e,t.left),a=o(e,t.right);switch(">"===r?(r="<",[n,a]=[a,n]):">="===r&&(r="<=",[n,a]=[a,n]),r){case"|":return s(n)||s(a);case"&":return s(n)&&s(a);case"=":return n===a;case"!=":return n!==a;case"<":{const e=typeof n,t=typeof a;if("string"===e&&"string"===t)return-1===n.localeCompare(a);if("number"===e&&"number"===t)return n<a;if(null!==n&&null!==a)throw new Error(`Invalid types used in comparison: ${e} ("${n}") ≠ ${t} ("${a}")`);return!1}case"<=":{const e=typeof n,t=typeof a;if("string"===e&&"string"===t)return n.localeCompare(a)<1;if("number"===e&&"number"===t)return n<=a;if(null!==n&&null!==a)throw new Error(`Invalid types used in comparison: ${e} ("${n}") ≠ ${t} ("${a}")`);return!1}}}t.evalBinaryExpression=a},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4);t.evalDeclaration=({config:e,stream:t,decl:r,scope:o,result:s})=>{switch(t.stash(),r.type){case"combinator":if(!n.evalCombiantor({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"string":if(!n.evalString({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"character-selection":if(!n.evalCharacterSelection({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"reference":if(!n.evalReference({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"ignored":case"group":{const a="ignored"===r.type?r.value:r;if(!(n.evalGroup({config:e,stream:t,scope:o,decl:a,result:"ignored"===r.type?{pure:!1,obj:{},str:""}:s})||a.multiplier&&"optional"===a.multiplier.type))return t.pop(),!1;break}case"function":if(!n.evalFunction({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"conditional-statement":if(!n.evalConditionalStatement({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1}return t.recycle(),!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4);t.evalFunction=({config:e,stream:t,decl:r,scope:o,result:s})=>{const a=[];for(const i of r.args)switch(i.type){case"tag":{const e=s.obj[i.value];if(void 0===e)throw new Error(`Tag "${e}" isn't defined anywhere but used in a function call.`);a.push(e);break}case"group":a.push(n.evalGroup({config:e,stream:t,decl:i,scope:o}));break;case"string":case"identifier":a.push(i.value);break;case"reference":a.push(n.evalRawReference({config:e,stream:t,scope:o,result:{pure:!1,obj:{},str:""},decl:i}))}const i=e.functions&&e.functions[r.name];if("function"!=typeof i)throw new Error(`There is no such function: ${r.name}`);try{return i({state:s,setString(e){if(!s.pure)throw new Error("Can't apply string, result isn't pure.");s.str=e},setProperty(e,t){s.obj[e]=t,s.pure=!1}},...a)}catch(e){throw new Error(`Function "${r.name}" throwed an error:\n${e.message}`)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),o=r(13),s=r(17);t.evalGroup=o.maybeMultiplier(({config:e,stream:t,decl:r,scope:o,result:a={obj:{},str:"",pure:!0}})=>{t.stash();const i=a.str,l=r.value;for(let r=0;r<l.length;r++){const u=l[r];if(!n.evalDeclaration({config:e,stream:t,decl:u,scope:o,result:a}))return t.pop(),s.serializeParsingResult(l,a,!0),a.str=i,null}return s.serializeParsingResult(l,a),t.recycle(),a.pure?a.str:a.obj})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),o=r(12);t.evalReference=({config:e,stream:t,decl:r,scope:s,result:a})=>{const i=t.index,l=n.evalRawReference({config:e,stream:t,decl:r,scope:s,result:a}),u=o.typeOf(l);if(r.tag){const e=a.obj[r.tag];if(null!=e)throw new Error(`Tag "${r.tag}" is already defined (Contains "${e}").\nYou may used it multiple times or within a group + multipliers, you should avoid that.`);a.obj[r.tag]=l}if(t.stash(),null===l)return t.pop(),!(!r.multiplier||"optional"!==r.multiplier.type);if(e.locationData&&"object"===u){const{end:r,start:n}=e.locationData;l[n]=i,l[r]=t.index-1}if(r.spread){if("object"!==u)throw new Error(`"${r.value}" doesn't return a object which is required for the spread operator to work.`);Object.assign(a.obj,l),a.pure=!1}else if(r.tag)a.pure=!1;else if("array"===u&&l.every(e=>"string"==typeof e))a.str+=l.join("");else{if("string"!==u)throw new Error(`Type "${r.value}" is missing a tag.`);a.str+=l}return t.recycle(),!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),o=r(13);t.evalRawReference=({config:e,stream:t,decl:r,scope:s,result:a})=>{const i=s.lookupByPath(r.value);if(!i)throw new Error(`Failed to resolve "${r.value.join(":")}". If it's a block a default export may be missing.`);const[l,u]=i,c=l.arguments,p=[...r.arguments||[]];if(c){for(const{value:e,name:t}of c){let r=e;const n=p.findIndex(e=>e.name===t);if(~n&&([{value:r}]=p.splice(n,1)),!r)throw new Error(`Argument "${t}" is missing on type ${l.name}.`);u.injectValue(r,t)}if(p.length)throw new Error(`These arguments were passed into "${l.name}" but not expected: ${p.map(e=>e.name).join(", ")}`)}else if(p.length)throw new Error(`Type "${l.name}" does not expect any arguments.`);const f=o.maybeMultiplier(()=>n.evalGroup({config:e,stream:t,decl:l.value,scope:u}))({config:e,stream:t,decl:r,result:a,scope:u});return f&&r.modifiers&&n.evalModification(f,r),f}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.evalString=({stream:e,decl:t,result:r})=>{const{value:n}=t;e.stash();for(let t=0;t<n.length;t++)if(e.next()!==n[t])return e.pop(),!1;return e.recycle(),r.str+=n,!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});class n{constructor({parent:e=null,global:t=!1}){this.exports=new Map,this.members=new Map,this.specials=new Map,this.parent=e,this.global=t}registerAll(e){for(const t of e)this.register(t)}register(e){const t=this.resolveValueFor(e);switch(e.variant){case"entry":if(this.specials.has("entry"))throw new Error("There can only be one entry.");if(!this.global)throw new Error("Only the global scope can contain entries.");null!==e.name&&this.setMember(e.name,t),this.specials.set("entry",t);break;case"default":if(this.specials.has("default"))throw new Error("There can only be one default export.");if(this.global)throw new Error("The global scope can't have default exports.");null!==e.name&&this.setMember(e.name,t),this.specials.set("default",t);break;case"export":{const r=e.name;if(this.global)throw new Error("The global scope can't have exported members.");this.exports.set(r,t),this.setMember(e.name,t);break}default:this.setMember(e.name,t)}}setMember(e,t){if(this.members.has(e))throw new Error(`The type named "${e}" is already declared.`);this.members.set(e,t)}injectValue(e,t){this.register({type:"declaration",variant:null,arguments:null,value:e,name:t})}lookupByPath(e){const[t,...r]=e,o=this.lookupByName(t);return o?o instanceof n?o.lookupDeepReference(r):r.length?null:[o,this]:null}lookup(e){const t=this.specials.get(e);return t?t instanceof n?t.lookup("default"):[t,this]:null}resolveValueFor(e){if("block"===e.value.type){const t=new n({parent:this});return t.registerAll(e.value.value),t}return e}lookupByName(e){return this.members.has(e)?this.members.get(e):this.parent?this.parent.lookupByName(e):null}lookupDeepReference(e){const t=e.length?this.exports.get(e.shift()):null;return t?t instanceof n?t.lookupDeepReference(e):e.length?null:[t,this]:e.length?null:this.lookup("default")}}t.Scope=n},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ENV_VERSION="0.0.20"},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(9),o=r(62),s=r(63),a=r(64),i=r(65),l=[r(67).ws,i.str,o.kw,s.num,a.punc];t.tokenize=e=>{const t=new n.Streamable(e),r=[];e:for(;t.hasNext();){for(const e of l){const n=t.index,o=e(t);if(o){if("/"===o.value&&"/"===t.peek()){for(;t.hasNext()&&"\n"!==t.peek();)t.next();continue e}if("ws"===o.type&&r.length&&"ws"===r[r.length-1].type){const e=r[r.length-1];e.value+=o.value,e.end=t.index;continue e}r.push(Object.assign(Object.assign({},o),{start:n,end:t.index}));continue e}}throw new Error("Failed to parse input sequence.")}return r}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(18),o=r(8);t.kw=e=>{const t=n.consumeWhile(e,(e,t)=>o.isNonWhitespace(e)||!(!o.isNumeric(e)||!t.length));return t.length?{type:"kw",value:t}:null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.num=e=>{let t="";for(;e.hasNext();){const r=e.peek();if(!n.isNumeric(r))break;t+=r,e.next()}return t.length?{type:"num",value:Number(t)}:null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.punc=e=>n.isPunctuation(e.peek())?{type:"punc",value:e.next()}:null},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(66),o=["'",'"'];t.str=e=>{for(const t of o){if(e.stash(),e.peek()===t){e.next();const r=n.consumeEscaped(e,t);if(null!==r)return{type:"str",value:r}}e.pop()}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.consumeEscaped=(e,t)=>{let r=!1,n="";for(let o=e.next();;o=e.next()){if("\n"===o&&!r)return null;if(r)n+=o,r=!1;else if("\\"===o)r=!0;else{if(o===t)return n;if(!e.hasNext())break;n+=o}}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(18),o=r(8);t.ws=e=>{const t=n.consumeWhile(e,o.isWhiteSpace);return t.length?{type:"ws",value:t}:null}}])},"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Bavary=t():e.Bavary=t();
/*! Bavary 0.0.21 MIT | https://github.com/Simonwep/bavary */
var e,t;e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:Function("return this")(),t=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.maybe=e=>t=>{t.stash();const r=e(t);return null!==r?(t.recycle(),r):(t.pop(),null)}},function(e,t,r){function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(20)),n(r(21)),n(r(24)),n(r(25)),n(r(34)),n(r(11)),n(r(35)),n(r(36)),n(r(38)),n(r(39)),n(r(40)),n(r(41)),n(r(42)),n(r(47)),n(r(10)),n(r(6))},function(e,t,r){function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(49)),n(r(52)),n(r(53)),n(r(54)),n(r(56)),n(r(57)),n(r(58)),n(r(59)),n(r(60)),n(r(61))},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.combine=(...e)=>t=>{for(const r of e){const e=r(t);if(null!==e)return e}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isPunctuation=e=>e<"0"||e>"z"||e>"9"&&e<"A"||e>"Z"&&e<"a",t.isNonWhitespace=e=>e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e,t.isWhiteSpace=e=>"\t"===e||"\n"===e||"\r"===e||" "===e,t.isNumeric=e=>e>="0"&&e<="9"},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Streamable=class{constructor(e,t=null){this.vals=e,this.length=e.length,this.source=t,this.index=0,this.stashed=[]}stash(){this.stashed.push(this.index)}pop(){this.index=this.stashed.pop()}next(){return this.hasNext()?this.vals[this.index++]:null}peek(){return this.hasNext()?this.vals[this.index]:null}hasNext(){return this.index<this.vals.length}recycle(){this.stashed.pop()}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(3),s=r(0),a=s.maybe(e=>{if(!e.optional(!0,"punc","."))return null;const t=n.parseIdentifier(e);return t||e.throwError("Expected identifier."),t.value}),i=s.maybe(e=>{if(!e.optional(!0,"punc","["))return null;const t=e.expect(!1,"num");return e.expect(!0,"punc","]"),t});t.parseValueAccessor=s.maybe(e=>{const t=n.parseIdentifier(e),r=t?[t.value]:[],s=o.combine(a,i);for(let t=null;null!==(t=s(e));)r.push(t);return r.length?{type:"value-accessor",value:r}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.lookupValue=(e,t)=>{for(const r of t){const t=n.typeOf(e);if("array"!==t&&"string"!==t||"length"!==r){if("string"==typeof r){if("object"==typeof e&&null!==e&&void 0!==(e=e[r]))continue}else if(Array.isArray(e)&&r<e.length){e=e[r];continue}return null}e=e.length}return e}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.typeOf=e=>{const t=typeof e;return"object"===t?Array.isArray(e)?"array":"object":t}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.maybeMultiplier=e=>t=>{const{stream:r,decl:n}=t,o=()=>{const r=[];for(let n;n=e(t);)r.push(n);return r};if(r.stash(),n.multiplier){const{type:e,value:t}=n.multiplier;switch(e){case"zero-infinity":return r.recycle(),o();case"one-infinity":{const e=o();return e.length?(r.recycle(),e):(r.pop(),null)}case"range":{const{start:e,end:n}=t,s=o();return s.length<e||null!==n&&s.length>n?(r.pop(),null):(r.recycle(),s)}}}return r.recycle(),e(t)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseTag=o.maybe(e=>{if(!e.optional(!0,"punc","#"))return null;const t=n.parseIdentifier(e);return t||e.throwError("Expected identifier"),{type:"tag",value:t.value}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseDeclaration=o.maybe(e=>{var t;const r=e.optional(!1,"kw","entry","default","export");let o,s=null,a=null;return e.optional(!1,"punc","<")?(s=n.parseIdentifier(e),s||e.throwError("Expected identifier."),a=n.parseArguments(e),e.expect(!1,"punc",">"),e.expect(!1,"punc","=")):r||e.throwError("Expected declaration."),(null===(t=a)||void 0===t?void 0:t.length)?(o=n.parseGroup(e),o||e.throwError("Expected a group.")):(o=n.parseGroup(e)||n.parseBlock(e),o||e.throwError("Expected a group or block-statement.")),{type:"declaration",name:s?s.value:null,variant:r,value:o,arguments:a}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeParsingResult=function e(t,r,n=!1){const{obj:o}=r;for(const s of t)"reference"===s.type&&s.tag?((void 0===o[s.tag]||n)&&(o[s.tag]=null),r.pure=!1):"group"===s.type||"combinator"===s.type?e(s.value,r,n):"conditional-statement"===s.type&&(e([s.consequent],r,n),s.alternate&&e([s.alternate],r,n))}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.consumeWhile=(e,t)=>{let r="";for(;e.hasNext()&&t(e.peek(),r);)r+=e.next();return r}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(15),o=r(48),s=r(63),a=r(64);t.compile=(e,t)=>{const r=Array.isArray(e)?e:n.parse(a.tokenize(e),e);return o.compileDeclarations(r,t)},t.compileChunk=e=>n.parse(a.tokenize(e),e),t.version=s.ENV_VERSION},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(16);r(1);const o=r(11);t.parse=(e,t)=>{const r=new n.TokenStream(e,t),s=[];for(;r.hasNext();)s.push(o.parseDeclaration(r));return s}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(5),o=r(17);class s extends n.Streamable{next(e=!1){const{index:t,length:r,vals:n}=this;if(e&&t<r)return n[this.index++];for(let e=t;e<r;e++)if("ws"!==n[e].type)return this.index=e+1,n[e];return null}peek(e=!1){const{index:t,length:r,vals:n}=this;if(e&&t<r)return n[t];for(let e=t;e<r;e++)if("ws"!==n[e].type)return n[e];return null}hasNext(e=!1){return null!==this.peek(e)}consumeSpace(){this.hasNext(!0)&&"ws"===this.peek(!0).type&&this.next(!0)}match(e=!1,t,...r){const n=this.peek(e);return!(!n||n.type!==t)&&(!r.length||r.includes(n.value))}optional(e=!1,t,...r){const n=this.peek(e);return n&&n.type===t&&this.match(e,t,...r)?this.next(e).value:null}expect(e=!1,t,...r){const n=this.optional(e,t,...r);if(null!==n)return n;if(this.hasNext(e)){const n=this.next(e);this.throwError(`Expected ${r.join(", ")} (${t}) but got ${n.value} (${n.type})`)}this.throwError("Unxpected end of input.")}throwError(e){const{index:t,source:r}=this;if(!r)throw new o.ParsingError(e);if(this.hasNext()){const t=this.peek();throw new o.ParsingError(r,e,t.start,t.end)}throw new o.ParsingError(r,e,t,t)}}t.TokenStream=s},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(18);class o extends Error{constructor(e,t,r,o){super(r&&o&&t?n.prettifyError(e,t,r,o):e),this.source=t,this.start=r,this.end=o,this.msg=e,this.name="Parsing Error"}}t.ParsingError=o},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(19));function s(e,t,r=-1){return e===r?t:e}t.prettifyError=(e,t,r,n)=>{const a=s(o.default(e,"\n",r),-1)+1,i=s(e.indexOf("\n",n),e.length),l=r-a;return`\n${e.slice(a,i)}\n${" ".repeat(l)}^\n${t}`}},function(e,t){e.exports=(e,t,r)=>{if("string"!=typeof t||"string"!=typeof e||r<t.length-1)return-1;"number"!=typeof r&&(r=e.length-1);const n=t.length-1;for(let o=r,s=n;o>=0;o--)if(e[o]===t[s]){if(s--,!~s)return o}else s!==n&&(s=n,o++);return-1}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseArguments=o.maybe(e=>{const t=[];for(;;){e.consumeSpace();const r=n.parseIdentifier(e);if(!r)break;let o=null;e.optional(!1,"punc","=")&&(o=n.parseGroup(e),o||e.throwError("Expected a group.")),t.push({type:"argument",name:r.value,value:o})}return t.length?t:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(3),s=r(0),a=r(22),i=r(23);t.parseBinaryExpression=s.maybe(e=>{if(!e.optional(!1,"punc","("))return null;const r=o.combine(i.taggedValueAccessor,t.parseBinaryExpression,n.parseString,n.parseNumber,n.parseIdentifier),s=r(e);if(!s)return null;const l=function e(t,r,n,o=0){r.stash();const s=r.optional(!1,"punc")+(r.optional(!0,"punc")||"");if(!(s&&s in a.operatorPriority))return r.pop(),t;const i=a.operatorPriority[s];if(i>o){r.consumeSpace();const a=n(r);return a||r.throwError("Expected right-hand value"),e({type:"binary-expression",right:e(a,r,n,i),operator:s,left:t},r,n,o)}return r.pop(),t}(s,e,r);return"binary-expression"!==l.type&&e.throwError("Expected binary expression."),e.expect(!1,"punc",")"),l})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.operatorPriority={"|":1,"&":2,"=":4,"<":4,">":4,"!=":4,"<=":4,">=":4}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(10),s=r(6);t.taggedValueAccessor=n.maybe(e=>{var t;const r=o.parseTag(e);return r?{type:"value-accessor",value:[r.value,...(null===(t=s.parseValueAccessor(e))||void 0===t?void 0:t.value)||[]]}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseBlock=o.maybe(e=>{if(!e.optional(!1,"punc","{"))return null;const t=[];for(;!e.match(!1,"punc","}");)t.push(n.parseDeclaration(e));return e.expect(!1,"punc","}"),{type:"block",value:t}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(26);t.parseCharacterSelecton=o.maybe(e=>{if(!e.optional(!1,"punc","("))return null;const t=[],r=[];return t.push(...s.parseSequence(e)),e.optional(!1,"kw","except")&&r.push(...s.parseSequence(e)),e.expect(!1,"punc",")"),{type:"character-selection",multiplier:n.parseMultiplier(e),included:t,excluded:r}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(27),o=r(29);t.parseSequence=e=>{const t=[];do{const r=o.parseToken(e);if(null!==r)if(e.optional(!1,"punc","-")){const n=o.parseToken(e);null===n&&e.throwError("Expected end position."),t.push([Math.min(r,n),Math.max(r,n)])}else t.push(r);else{const r=n.parseCommonToken(e);r?t.push(...r):e.throwError("Expected character-selection.")}}while(e.optional(!1,"punc",","));return t}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(28);t.parseCommonToken=n.maybe(e=>{if(e.optional(!1,"punc","."))return[[0,65535]];if(!e.optional(!1,"punc","\\"))return null;const t=e.next(!0);t?"ws"===t.type&&e.throwError(`Expected token but got "${t.value}".`):e.throwError("Expected token.");const r=t.value,n=o.commonTokens[r];return void 0===n&&e.throwError(`Unknown token: "${r}"`),n})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.commonTokens={t:[9],n:[10],r:[13],0:[0],s:[9,10,32],d:[[48,57]],w:[[97,122],[65,90],[48,57],95]}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(30),s=r(32);t.parseToken=n.maybe(e=>{const t=o.parseHexCharacter(e)||s.parseOctalCharacter(e);if(null!==t)return t;if(!e.hasNext())return null;const r=e.peek(),n=String(r.value),a="\\"===n;if(1!==n.length||"punc"===r.type&&!a)return null;if(e.next(),a){if(!e.hasNext())return null;const t=e.peek(),r=String(t.value);return"punc"!==t.type?null:(e.next(),r.charCodeAt(0))}return n.charCodeAt(0)})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(31),o=r(0);t.parseHexCharacter=o.maybe(e=>{if(!e.optional(!1,"punc","\\"))return null;const t=e.optional(!1,"kw");if(!t||!t.startsWith("x"))return null;const r=t.slice(1);return 2!==r.length&&4!==r.length?e.throwError("Hex value must either be 2 or 4 values."):n.isValidHex(r)||e.throwError("Invalid hex value."),parseInt(r,16)})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidHex=e=>{for(const t of e)if(t<"0"||t>"9"&&t<"A"||t>"F"&&t<"a"||t>"f")return!1;return!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),o=r(0);t.parseOctalCharacter=o.maybe(e=>{if(!e.optional(!1,"punc","\\"))return null;const t=e.optional(!1,"num");if(!t)return null;const r=String(t);return(!n.isValidOctal(r)||t>999)&&e.throwError("Invalid octal value."),parseInt(r,8)})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidOctal=e=>{for(const t of e)if(t<"0"||t>"7")return!1;return!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseConditionalStatement=o.maybe(e=>{if(!e.optional(!1,"kw","if"))return null;const r=n.parseBinaryExpression(e);r||e.throwError("Expected a binary expression.");const o=n.parseGroup(e);o||e.throwError("Expected a group.");let s=null;return e.optional(!1,"kw","else")&&(s=n.parseGroup(e)||t.parseConditionalStatement(e),s||e.throwError("Expected a group.")),{type:"conditional-statement",condition:r,consequent:o,alternate:s}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(3),s=r(0);t.parseFunction=s.maybe(e=>{e.consumeSpace();const t=n.parseIdentifier(e);if(!t||!e.optional(!1,"punc","("))return null;const r=o.combine(n.parseIdentifier,n.parseTag,n.parseGroup,n.parseString,n.parseReference),s=[];for(;!e.match(!1,"punc",")");){e.consumeSpace(),s.length&&e.expect(!1,"punc",","),e.consumeSpace();const t=r(e);t||e.throwError("Expected an a group, tag or identifier."),s.push(t)}return e.expect(!1,"punc",")"),{type:"function",name:t.value,args:s}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(37),s=r(3),a=r(0);t.parseGroup=a.maybe(e=>{if(!e.optional(!1,"punc","["))return null;const r=[],a=s.combine(n.parseConditionalStatement,n.parseFunction,n.parseIgnored,t.parseGroup,n.parseReference,n.parseCharacterSelecton,n.parseString);let i=null;for(;!e.match(!1,"punc","]");){const t=a(e),n=o.parseCombinator(e);if(t||e.throwError("Expected a type, group or raw string / character-range."),n){if(i){if(n===i.sign)i.value.push(t);else{const e={type:"combinator",value:[t],sign:n};i.value.push(e),i=e}continue}i={type:"combinator",value:[t],sign:n},r.push(i)}else i?(i.value.push(t),i=null):r.push(t)}return i&&e.throwError("Combinator is missing a value!"),e.expect(!1,"punc","]"),{type:"group",multiplier:n.parseMultiplier(e),value:r}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseCombinator=n.maybe(e=>{let t=e.optional(!1,"punc","|","&");return t?("&"===t&&e.optional(!1,"punc","&")&&(t+="&"),t):null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseIdentifier=n.maybe(e=>{let t="";for(;e.hasNext(!0);){const{type:r,value:n}=e.peek(!0);if("ws"===r)break;if(!("punc"===r&&"-"===n&&t.length||"num"===r||"kw"===r))break;t+=n,e.next(!0)}return t.endsWith("-")&&e.throwError("Identifier cannot end with a hyphen"),t.length?{type:"identifier",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o={"*":"zero-infinity","+":"one-infinity","?":"optional"};t.parseMultiplier=n.maybe(e=>{const t=e.optional(!0,"punc","*","+","?","{");if("{"===t){const t=e.expect(!1,"num");e.expect(!1,"punc",",");const r=e.optional(!1,"num");return null!==r&&r-t<0&&e.throwError("The difference between start and end-value cannot be negative or zero."),e.expect(!1,"punc","}"),{type:"range",value:{start:t,end:r}}}return t?{type:o[t],value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(0);t.parseIgnored=o.maybe(e=>{if(!e.optional(!1,"punc","/"))return null;const t=n.parseGroup(e);return t||e.throwError("Expected group."),e.expect(!1,"punc","/"),{type:"ignored",value:t}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseNumber=n.maybe(e=>{const t=e.optional(!1,"num");return t?{type:"number",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(43),s=r(46),a=r(0);t.parseReference=a.maybe(e=>{var t;const r=s.parseSpreadOperator(e);if(!e.optional(!1,"punc","<"))return null;const a=[];let i=!1;for(;e.hasNext();){const t=n.parseIdentifier(e);if(t&&(i=!1,a.push(t.value)),!e.optional(!1,"punc",":"))break;i=!0}!i&&a.length||e.throwError("Expected identifier");const l=n.parseTag(e);r&&l&&e.throwError("Type cannot have both a tag an spread operator attached to it.");const u=o.parseModification(e),c=n.parseArguments(e);e.expect(!1,"punc",">");const p=n.parseMultiplier(e);return{type:"reference",tag:(null===(t=l)||void 0===t?void 0:t.value)||null,arguments:c,modifiers:u,multiplier:p,spread:r,value:a}})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),o=r(44),s=r(45),a={def:o.parseDefineModifier,del:s.parseDeleteModifier};t.parseModification=n.maybe(e=>{if(!e.optional(!0,"punc","{"))return null;const t=[];do{const r=e.optional(!1,"kw","def","del");r?(e.consumeSpace(),t.push(a[r](e))):e.throwError("Expected operator")}while(e.optional(!1,"punc",","));return e.expect(!1,"punc","}"),t})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.parseDefineModifier=e=>{const t=n.parseIdentifier(e);t||e.throwError("Expected identifier"),e.expect(!1,"punc","="),e.consumeSpace();const r=n.parseString(e)||n.parseValueAccessor(e);return r||e.throwError("Expected string, function-call or value-accessor."),{type:"def",key:t.value,value:r}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(6);t.parseDeleteModifier=e=>{const t=n.parseValueAccessor(e);return t||e.throwError("Expected a value accessor."),{type:"del",param:t}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseSpreadOperator=n.maybe(e=>{for(let t=0;t<3;t++)if(!e.optional(!1,"punc","."))return!1;return!0})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.parseString=n.maybe(e=>{const t=e.optional(!1,"str");return null===t||t.length||e.throwError("Strings shouldn't be empty."),t?{type:"string",value:t}:null})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(5),o=r(2),s=r(62);t.compileDeclarations=(e,t={locationData:!1,functions:{}})=>{const r=new s.Scope({global:!0});r.registerAll(e),!0===t.locationData&&(t.locationData={start:"__starts",end:"__ends"});const a=r.lookup("entry");if(!a)throw new Error("Couldn't resolve entry type. Use the entry keyword to declare one.");const[i,l]=a;return e=>{const r=new n.Streamable(e),s=o.evalGroup({config:t,stream:r,scope:l,decl:i.value});return r.hasNext()?null:s}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(50),o=r(51);t.evalModification=(e,t)=>{for(const r of t.modifiers)switch(r.type){case"def":n.def(e,r);break;case"del":o.del(e,r)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(7);t.def=(e,{value:t,key:r})=>{switch(t.type){case"string":e[r]=t.value;break;case"value-accessor":e[r]=n.lookupValue(e,t.value)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(7),o=r(8);t.del=(e,t)=>{const r=[...t.param.value],s=r.pop(),a=o.typeOf(s),i=n.lookupValue(e,r),l=o.typeOf(i);if(!i)throw new Error("Failed to resolve parent value.");if("array"===l){if("number"!==a)throw new Error(`To delete an array entry you need to specify a index, got ${s} instead.`);i.splice(s,1)}else{if("object"!==l)throw new Error("Target must be an object or array.");if("string"!==a)throw new Error("To remove an object-property you need to specify a identifier.");delete i[s]}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(9),o=(e,t)=>e.some(e=>"number"==typeof e?e===t:t>=e[0]&&t<=e[1]);t.evalCharacterSelection=({config:e,stream:t,decl:r,scope:s,result:a})=>{const{included:i,excluded:l}=r,u=n.maybeMultiplier(()=>{if(t.hasNext()){const e=t.peek(),r=e.charCodeAt(0);if(o(i,r)&&!o(l,r))return t.next(),e}return null})({config:e,stream:t,decl:r,scope:s,result:a});if(Array.isArray(u))a.str+=u.join("");else if("string"==typeof u)a.str+=u;else if(!u&&!r.multiplier||r.multiplier&&"optional"!==r.multiplier.type)return!1;return!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(12);t.evalCombiantor=({config:e,stream:t,decl:r,scope:s,result:a})=>{switch(t.stash(),o.serializeParsingResult(r.value,a),r.sign){case"|":{const o=r.value;for(let r=0;r<o.length;r++)if(n.evalDeclaration({config:e,stream:t,decl:o[r],scope:s,result:a}))return t.recycle(),!0;break}case"&&":case"&":{const o=[...r.value];for(let r=0;r<o.length;r++)n.evalDeclaration({config:e,stream:t,decl:o[r],scope:s,result:a})&&(o.splice(r,1),r=-1);if(!o.length||"&&"===r.sign&&o.length<r.value.length)return t.recycle(),!0;break}}return t.pop(),!1}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(55);t.evalConditionalStatement=({config:e,stream:r,decl:s,scope:a,result:i})=>{const{condition:l,consequent:u,alternate:c}=s,p=o.evalBinaryExpression(i,l)?u:c;if(!p)return!0;const f=("group"===p.type?n.evalGroup:t.evalConditionalStatement)({config:e,stream:r,scope:a,result:i,decl:p});return null!==f&&!1!==f}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(7);function o(e,t){switch(t.type){case"binary-expression":return a(e,t);case"value-accessor":{const[r]=t.value;if(void 0===e.obj[r])throw new Error(`Tag "${r}" isn't defined anywhere but used in a condition.`);return n.lookupValue(e.obj,t.value)}case"identifier":if("null"===t.value)return null;throw new Error(`Unknown constant: "${t.value}"`);default:return t.value}}function s(e){return!(!1===e||null==e)}function a(e,t){let{operator:r}=t,n=o(e,t.left),a=o(e,t.right);switch(">"===r?(r="<",[n,a]=[a,n]):">="===r&&(r="<=",[n,a]=[a,n]),r){case"|":return s(n)||s(a);case"&":return s(n)&&s(a);case"=":return n===a;case"!=":return n!==a;case"<":{const e=typeof n,t=typeof a;if("string"===e&&"string"===t)return-1===n.localeCompare(a);if("number"===e&&"number"===t)return n<a;if(null!==n&&null!==a)throw new Error(`Invalid types used in comparison: ${e} ("${n}") ≠ ${t} ("${a}")`);return!1}case"<=":{const e=typeof n,t=typeof a;if("string"===e&&"string"===t)return n.localeCompare(a)<1;if("number"===e&&"number"===t)return n<=a;if(null!==n&&null!==a)throw new Error(`Invalid types used in comparison: ${e} ("${n}") ≠ ${t} ("${a}")`);return!1}}}t.evalBinaryExpression=a},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2);t.evalDeclaration=({config:e,stream:t,decl:r,scope:o,result:s})=>{switch(t.stash(),r.type){case"combinator":if(!n.evalCombiantor({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"string":if(!n.evalString({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"character-selection":if(!n.evalCharacterSelection({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"reference":if(!n.evalReference({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"ignored":case"group":{const a="ignored"===r.type?r.value:r;if(!(n.evalGroup({config:e,stream:t,scope:o,decl:a,result:"ignored"===r.type?{pure:!1,obj:{},str:""}:s})||a.multiplier&&"optional"===a.multiplier.type))return t.pop(),!1;break}case"function":if(!n.evalFunction({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1;break;case"conditional-statement":if(!n.evalConditionalStatement({config:e,stream:t,decl:r,scope:o,result:s}))return t.pop(),!1}return t.recycle(),!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2);t.evalFunction=({config:e,stream:t,decl:r,scope:o,result:s})=>{const a=[];for(const i of r.args)switch(i.type){case"tag":{const e=s.obj[i.value];if(void 0===e)throw new Error(`Tag "${e}" isn't defined anywhere but used in a function call.`);a.push(e);break}case"group":a.push(n.evalGroup({config:e,stream:t,decl:i,scope:o}));break;case"string":case"identifier":a.push(i.value);break;case"reference":a.push(n.evalRawReference({config:e,stream:t,scope:o,result:{pure:!1,obj:{},str:""},decl:i}))}const i=e.functions&&e.functions[r.name];if("function"!=typeof i)throw new Error(`There is no such function: ${r.name}`);try{return i({state:s,setString(e){if(!s.pure)throw new Error("Can't apply string, result isn't pure.");s.str=e},setProperty(e,t){s.obj[e]=t,s.pure=!1}},...a)}catch(e){throw new Error(`Function "${r.name}" throwed an error:\n${e.message}`)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(9),s=r(12);t.evalGroup=o.maybeMultiplier(({config:e,stream:t,decl:r,scope:o,result:a={obj:{},str:"",pure:!0}})=>{t.stash();const i=a.str,l=r.value;for(let r=0;r<l.length;r++){const u=l[r];if(!n.evalDeclaration({config:e,stream:t,decl:u,scope:o,result:a}))return t.pop(),s.serializeParsingResult(l,a,!0),a.str=i,null}return s.serializeParsingResult(l,a),t.recycle(),a.pure?a.str:a.obj})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(8);t.evalReference=({config:e,stream:t,decl:r,scope:s,result:a})=>{const i=t.index,l=n.evalRawReference({config:e,stream:t,decl:r,scope:s,result:a}),u=o.typeOf(l);if(r.tag){const e=a.obj[r.tag];if(null!=e)throw new Error(`Tag "${r.tag}" is already defined (Contains "${e}").\nYou may used it multiple times or within a group + multipliers, you should avoid that.`);a.obj[r.tag]=l}if(t.stash(),null===l)return t.pop(),!(!r.multiplier||"optional"!==r.multiplier.type);if(e.locationData&&"object"===u){const{end:r,start:n}=e.locationData;l[n]=i,l[r]=t.index-1}if(r.spread){if("object"!==u)throw new Error(`"${r.value}" doesn't return a object which is required for the spread operator to work.`);Object.assign(a.obj,l),a.pure=!1}else if(r.tag)a.pure=!1;else if("array"===u&&l.every(e=>"string"==typeof e))a.str+=l.join("");else{if("string"!==u)throw new Error(`Type "${r.value}" is missing a tag.`);a.str+=l}return t.recycle(),!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),o=r(9);t.evalRawReference=({config:e,stream:t,decl:r,scope:s,result:a})=>{const i=s.lookupByPath(r.value);if(!i)throw new Error(`Failed to resolve "${r.value.join(":")}". If it's a block a default export may be missing.`);const[l,u]=i,c=l.arguments,p=[...r.arguments||[]];if(c){for(const{value:e,name:t}of c){let r=e;const n=p.findIndex(e=>e.name===t);if(~n&&([{value:r}]=p.splice(n,1)),!r)throw new Error(`Argument "${t}" is missing on type ${l.name}.`);u.injectValue(r,t)}if(p.length)throw new Error(`These arguments were passed into "${l.name}" but not expected: ${p.map(e=>e.name).join(", ")}`)}else if(p.length)throw new Error(`Type "${l.name}" does not expect any arguments.`);const f=o.maybeMultiplier(()=>n.evalGroup({config:e,stream:t,decl:l.value,scope:u}))({config:e,stream:t,decl:r,result:a,scope:u});return f&&r.modifiers&&n.evalModification(f,r),f}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.evalString=({stream:e,decl:t,result:r})=>{const{value:n}=t;e.stash();for(let t=0;t<n.length;t++)if(e.next()!==n[t])return e.pop(),!1;return e.recycle(),r.str+=n,!0}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});class n{constructor({parent:e=null,global:t=!1}){this.exports=new Map,this.members=new Map,this.specials=new Map,this.parent=e,this.global=t}registerAll(e){for(const t of e)this.register(t)}register(e){const t=this.resolveValueFor(e);switch(e.variant){case"entry":if(this.specials.has("entry"))throw new Error("There can only be one entry.");if(!this.global)throw new Error("Only the global scope can contain entries.");null!==e.name&&this.setMember(e.name,t),this.specials.set("entry",t);break;case"default":if(this.specials.has("default"))throw new Error("There can only be one default export.");if(this.global)throw new Error("The global scope can't have default exports.");null!==e.name&&this.setMember(e.name,t),this.specials.set("default",t);break;case"export":{const r=e.name;if(this.global)throw new Error("The global scope can't have exported members.");this.exports.set(r,t),this.setMember(e.name,t);break}default:this.setMember(e.name,t)}}setMember(e,t){if(this.members.has(e))throw new Error(`The type named "${e}" is already declared.`);this.members.set(e,t)}injectValue(e,t){this.register({type:"declaration",variant:null,arguments:null,value:e,name:t})}lookupByPath(e){const[t,...r]=e,o=this.lookupByName(t);return o?o instanceof n?o.lookupDeepReference(r):r.length?null:[o,this]:null}lookup(e){const t=this.specials.get(e);return t?t instanceof n?t.lookup("default"):[t,this]:null}resolveValueFor(e){if("block"===e.value.type){const t=new n({parent:this});return t.registerAll(e.value.value),t}return e}lookupByName(e){return this.members.has(e)?this.members.get(e):this.parent?this.parent.lookupByName(e):null}lookupDeepReference(e){const t=e.length?this.exports.get(e.shift()):null;return t?t instanceof n?t.lookupDeepReference(e):e.length?null:[t,this]:e.length?null:this.lookup("default")}}t.Scope=n},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ENV_VERSION="0.0.21"},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(5),o=r(65),s=r(66),a=r(67),i=r(68),l=r(69),u=r(71),c=[o.cmt,u.ws,l.str,s.kw,a.num,i.punc];t.tokenize=e=>{const t=new n.Streamable(e),r=[];e:for(;t.hasNext();){for(const e of c){const n=t.index,o=e(t);if(o){if("ws"===o.type&&r.length&&"ws"===r[r.length-1].type){const e=r[r.length-1];e.value+=o.value,e.end=t.index;continue e}r.push(Object.assign(Object.assign({},o),{start:n,end:t.index}));continue e}}throw new Error("Failed to parse input sequence.")}return r}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.cmt=e=>{if("/"===e.peek()){e.stash(),e.next();const t=e.next();if("/"===t)for(;e.hasNext();){if("\n"===e.peek()){e.recycle();break}e.next()}else if("*"===t){for(;e.hasNext();)if("*"===e.next()&&"/"===e.next()){e.recycle();break}}else e.pop()}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(13),o=r(4);t.kw=e=>{const t=n.consumeWhile(e,(e,t)=>o.isNonWhitespace(e)||!(!o.isNumeric(e)||!t.length));return t.length?{type:"kw",value:t}:null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4);t.num=e=>{let t="";for(;e.hasNext();){const r=e.peek();if(!n.isNumeric(r))break;t+=r,e.next()}return t.length?{type:"num",value:Number(t)}:null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4);t.punc=e=>n.isPunctuation(e.peek())?{type:"punc",value:e.next()}:null},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(70),o=["'",'"'];t.str=e=>{for(const t of o){if(e.stash(),e.peek()===t){e.next();const r=n.consumeEscaped(e,t);if(null!==r)return{type:"str",value:r}}e.pop()}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.consumeEscaped=(e,t)=>{let r=!1,n="";for(let o=e.next();;o=e.next()){if("\n"===o&&!r)return null;if(r)n+=o,r=!1;else if("\\"===o)r=!0;else{if(o===t)return n;if(!e.hasNext())break;n+=o}}return null}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(13),o=r(4);t.ws=e=>{const t=n.consumeWhile(e,o.isWhiteSpace);return t.length?{type:"ws",value:t}:null}}])},"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Bavary=t():e.Bavary=t();
//# sourceMappingURL=bavary.js.map

@@ -9,2 +9,2 @@ import { Token } from '../tokenizer/types';

*/
export declare const parseAST: (tokens: Token[], source: string) => Declaration[];
export declare const parse: (tokens: Token[], source: string) => Declaration[];

@@ -17,2 +17,1 @@ export * from './nodes/arguments';

export * from './nodes/value-accessor';
export { operatorPriority } from './nodes/binary-expression/operator-priority';
import { Streamable } from '../../streamable';
import { Token } from '../types';
import { Token, TokenType } from '../types';
export declare class TokenStream extends Streamable<Token> {

@@ -8,6 +8,22 @@ next(includeWhitespace?: boolean): Token | null;

/**
* Consumes following whitespace
*/
consumeSpace(): void;
/**
* Checks if the next token matches the given conditioons
*/
match(includeWhitespace: boolean | undefined, type: TokenType, ...values: Array<string | number>): boolean;
/**
* Same as match but it'll consume the token if the conditions are met
*/
optional(includeWhitespace: boolean | undefined, type: TokenType, ...values: Array<string | number>): string | number | null;
/**
* Same as match but it'll throw an error if the conditions aren't met
*/
expect(includeWhitespace: boolean | undefined, type: TokenType, ...values: Array<string | number>): string | number | never;
/**
* Throws an ParsingError
* @param msg
* @param msg Error message
*/
throwError(msg: string): never;
}
{
"name": "@bavary/core",
"version": "0.0.20",
"version": "0.0.21",
"description": "Customizable, elegant and fast syntax-parser",

@@ -44,9 +44,9 @@ "author": "Simon Reinisch <trash@reinisch.io>",

"@types/mocha": "^5.2.7",
"@types/node": "^13.1.1",
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0",
"@types/node": "^13.1.4",
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"chai": "^4.2.0",
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"eslint-config-problems": "^3.0.1",
"eslint-config-problems": "^3.1.0",
"eslint-loader": "^3.0.3",

@@ -53,0 +53,0 @@ "mocha": "^6.2.2",

@@ -12,3 +12,3 @@ import {TokenStream} from '../tokenizer/stream/token-stream';

*/
export const parseAST = (tokens: Array<Token>, source: string): Array<Declaration> => {
export const parse = (tokens: Array<Token>, source: string): Array<Declaration> => {
const stream = new TokenStream(tokens, source);

@@ -15,0 +15,0 @@ const declarations: Array<Declaration> = [];

@@ -17,2 +17,1 @@ export * from './nodes/arguments';

export * from './nodes/value-accessor';
export {operatorPriority} from './nodes/binary-expression/operator-priority';

@@ -1,6 +0,6 @@

import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {maybe} from '../tools/maybe';
export const parseCombinator = maybe<string>(stream => {
let combinator = optional(stream, false, 'punc', '|', '&');
export const parseCombinator = maybe<string>((stream: TokenStream) => {
let combinator = stream.optional(false, 'punc', '|', '&');

@@ -12,3 +12,3 @@ if (!combinator) {

// It may be a extended combinator
if (combinator === '&' && optional(stream, false, 'punc', '&')) {
if (combinator === '&' && stream.optional(false, 'punc', '&')) {
combinator += '&';

@@ -15,0 +15,0 @@ }

import {TokenStream} from '../../../tokenizer/stream/token-stream';
import {parseIdentifier, parseString, parseValueAccessor} from '../../internal';
import {expect} from '../../tools/expect';
import {skipWhitespace} from '../../tools/skip-whitespace';
import {DefineModifier} from '../../types';

@@ -13,4 +11,4 @@

expect(stream, false, 'punc', '=');
skipWhitespace(stream);
stream.expect(false, 'punc', '=');
stream.consumeSpace();

@@ -17,0 +15,0 @@ const value = parseString(stream) || parseValueAccessor(stream);

import {TokenStream} from '../../../tokenizer/stream/token-stream';
import {expect} from '../../tools/expect';
import {maybe} from '../../tools/maybe';
import {optional} from '../../tools/optional';
import {skipWhitespace} from '../../tools/skip-whitespace';
import {Modifier, Modifiers} from '../../types';

@@ -21,4 +18,4 @@ import {parseDefineModifier} from './def';

*/
export const parseModification = maybe<Modifiers | null>(stream => {
if (!optional(stream, true, 'punc', '{')) {
export const parseModification = maybe<Modifiers | null>((stream: TokenStream) => {
if (!stream.optional(true, 'punc', '{')) {
return null;

@@ -31,3 +28,3 @@ }

do {
const op = optional(stream, false, 'kw', 'def', 'del');
const op = stream.optional(false, 'kw', 'def', 'del');

@@ -37,3 +34,3 @@ if (!op) {

} else {
skipWhitespace(stream);
stream.consumeSpace();
set.push(parsers[op](stream));

@@ -43,6 +40,6 @@ }

// Pairs are seperated via a comma
} while (optional(stream, false, 'punc', ','));
} while (stream.optional(false, 'punc', ','));
expect(stream, false, 'punc', '}');
stream.expect(false, 'punc', '}');
return set;
});

@@ -1,3 +0,3 @@

import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {maybe} from '../tools/maybe';

@@ -8,5 +8,5 @@ /**

*/
export const parseSpreadOperator = maybe<boolean>(stream => {
export const parseSpreadOperator = maybe<boolean>((stream: TokenStream) => {
for (let i = 0; i < 3; i++) {
if (!optional(stream, false, 'punc', '.')) {
if (!stream.optional(false, 'punc', '.')) {
return false;

@@ -13,0 +13,0 @@ }

@@ -0,12 +1,11 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseGroup, parseIdentifier} from '../internal';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {skipWhitespace} from '../tools/skip-whitespace';
import {Arguments} from '../types';
export const parseArguments = maybe<Arguments>(stream => {
export const parseArguments = maybe<Arguments>((stream: TokenStream) => {
const args: Arguments = [];
while (true) {
skipWhitespace(stream);
stream.consumeSpace();
const name = parseIdentifier(stream);

@@ -20,3 +19,3 @@

let value = null;
if (optional(stream, false, 'punc', '=')) {
if (stream.optional(false, 'punc', '=')) {
value = parseGroup(stream);

@@ -23,0 +22,0 @@

import {TokenStream} from '../../../tokenizer/stream/token-stream';
import {parseIdentifier, parseNumber, parseString} from '../../internal';
import {combine} from '../../tools/combine';
import {expect} from '../../tools/expect';
import {maybe} from '../../tools/maybe';
import {optional} from '../../tools/optional';
import {skipWhitespace} from '../../tools/skip-whitespace';
import {BinaryExpression, BinaryExpressionValue} from '../../types';

@@ -27,4 +24,4 @@ import {operatorPriority} from './operator-priority';

const operator = optional(stream, false, 'punc') as string
+ (optional(stream, true, 'punc') || '');
const operator = stream.optional(false, 'punc') as string
+ (stream.optional(true, 'punc') || '');

@@ -41,3 +38,3 @@ if (!operator || !(operator in operatorPriority)) {

// Parse right-hand value
skipWhitespace(stream);
stream.consumeSpace();
const rightValue = parse(stream);

@@ -60,4 +57,4 @@ if (!rightValue) {

export const parseBinaryExpression = maybe<BinaryExpression>(stream => {
if (!optional(stream, false, 'punc', '(')) {
export const parseBinaryExpression = maybe<BinaryExpression>((stream: TokenStream) => {
if (!stream.optional(false, 'punc', '(')) {
return null;

@@ -85,4 +82,4 @@ }

expect(stream, false, 'punc', ')');
return bex as BinaryExpression;
stream.expect(false, 'punc', ')');
return bex;
});

@@ -0,1 +1,2 @@

import {TokenStream} from '../../../tokenizer/stream/token-stream';
import {maybe} from '../../tools/maybe';

@@ -6,3 +7,3 @@ import {ValueAccessor} from '../../types';

export const taggedValueAccessor = maybe<ValueAccessor>(stream => {
export const taggedValueAccessor = maybe<ValueAccessor>((stream: TokenStream) => {
const tag = parseTag(stream);

@@ -9,0 +10,0 @@

@@ -0,12 +1,10 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseDeclaration} from '../internal';
import {check} from '../tools/check';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Block, Declaration} from '../types';
export const parseBlock = maybe<Block>(stream => {
export const parseBlock = maybe<Block>((stream: TokenStream) => {
// It may be a block
if (!optional(stream, false, 'punc', '{')) {
if (!stream.optional(false, 'punc', '{')) {
return null;

@@ -18,7 +16,7 @@ }

while (!check(stream, false, 'punc', '}')) {
while (!stream.match(false, 'punc', '}')) {
declarations.push(parseDeclaration(stream) as Declaration);
}
expect(stream, false, 'punc', '}');
stream.expect(false, 'punc', '}');
return {

@@ -25,0 +23,0 @@ type: 'block',

@@ -0,8 +1,8 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseBinaryExpression, parseGroup} from '../internal';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {ConditionalStatement, Group, ParserFunction} from '../types';
export const parseConditionalStatement: ParserFunction<ConditionalStatement> = maybe(stream => {
if (!optional(stream, false, 'kw', 'if')) {
export const parseConditionalStatement: ParserFunction<ConditionalStatement> = maybe((stream: TokenStream) => {
if (!stream.optional(false, 'kw', 'if')) {
return null;

@@ -25,3 +25,3 @@ }

let alternative: Group | ConditionalStatement | null = null;
if (optional(stream, false, 'kw', 'else')) {
if (stream.optional(false, 'kw', 'else')) {
alternative = parseGroup(stream) || parseConditionalStatement(stream);

@@ -28,0 +28,0 @@

@@ -0,15 +1,14 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseArguments, parseBlock, parseGroup, parseIdentifier} from '../internal';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Declaration} from '../types';
export const parseDeclaration = maybe<Declaration>(stream => {
export const parseDeclaration = maybe<Declaration>((stream: TokenStream) => {
// Parse optional variant
const variant = optional(stream, false, 'kw', 'entry', 'default', 'export');
const variant = stream.optional(false, 'kw', 'entry', 'default', 'export');
let name = null, args = null;
// It may be a named one
if (optional(stream, false, 'punc', '<')) {
if (stream.optional(false, 'punc', '<')) {

@@ -23,4 +22,4 @@ name = parseIdentifier(stream);

args = parseArguments(stream);
expect(stream, false, 'punc', '>');
expect(stream, false, 'punc', '=');
stream.expect(false, 'punc', '>');
stream.expect(false, 'punc', '=');
} else if (!variant) {

@@ -27,0 +26,0 @@ stream.throwError('Expected declaration.');

@@ -0,15 +1,12 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseGroup, parseIdentifier, parseReference, parseString, parseTag} from '../internal';
import {check} from '../tools/check';
import {combine} from '../tools/combine';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {skipWhitespace} from '../tools/skip-whitespace';
import {Func, FuncArgument} from '../types';
export const parseFunction = maybe<Func>(stream => {
export const parseFunction = maybe<Func>((stream: TokenStream) => {
skipWhitespace(stream);
stream.consumeSpace();
const name = parseIdentifier(stream);
if (!name || !optional(stream, false, 'punc', '(')) {
if (!name || !stream.optional(false, 'punc', '(')) {
return null;

@@ -28,9 +25,9 @@ }

const args = [];
while (!check(stream, false, 'punc', ')')) {
skipWhitespace(stream);
while (!stream.match(false, 'punc', ')')) {
stream.consumeSpace();
if (args.length) {
expect(stream, false, 'punc', ',');
stream.expect(false, 'punc', ',');
}
skipWhitespace(stream);
stream.consumeSpace();
const arg = parse(stream);

@@ -44,3 +41,3 @@ if (!arg) {

expect(stream, false, 'punc', ')');
stream.expect(false, 'punc', ')');
return {

@@ -47,0 +44,0 @@ type: 'function',

@@ -0,14 +1,12 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseCharacterSelecton, parseConditionalStatement, parseFunction, parseIgnored, parseMultiplier, parseReference, parseString} from '../internal';
import {parseCombinator} from '../modifiers/combinator';
import {check} from '../tools/check';
import {combine} from '../tools/combine';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {BinaryCombinator, Group, GroupValue} from '../types';
export const parseGroup = maybe<Group>(stream => {
export const parseGroup = maybe<Group>((stream: TokenStream) => {
// It may be a group
if (!optional(stream, false, 'punc', '[')) {
if (!stream.optional(false, 'punc', '[')) {
return null;

@@ -31,3 +29,3 @@ }

let comg: null | BinaryCombinator = null;
while (!check(stream, false, 'punc', ']')) {
while (!stream.match(false, 'punc', ']')) {
const value = parsers(stream);

@@ -47,3 +45,3 @@ const sign = parseCombinator(stream);

// Still the same binary combinator since the sign is the same
comg.value.push(value as GroupValue);
comg.value.push(value);
} else {

@@ -79,3 +77,3 @@

// Last element of combinator, push it and set current combinator back to null
comg.value.push(value as GroupValue);
comg.value.push(value);
comg = null;

@@ -85,3 +83,3 @@ } else {

// Element does no correspond to any binary combinator
values.push(value as GroupValue);
values.push(value);
}

@@ -95,3 +93,3 @@ }

expect(stream, false, 'punc', ']');
stream.expect(false, 'punc', ']');

@@ -98,0 +96,0 @@ return {

@@ -1,4 +0,5 @@

import {Token} from '../../tokenizer/types';
import {maybe} from '../tools/maybe';
import {Identifier} from '../types';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {Token} from '../../tokenizer/types';
import {maybe} from '../tools/maybe';
import {Identifier} from '../types';

@@ -9,3 +10,3 @@ /**

*/
export const parseIdentifier = maybe<Identifier>(stream => {
export const parseIdentifier = maybe<Identifier>((stream: TokenStream) => {
let name = '';

@@ -12,0 +13,0 @@

@@ -1,6 +0,5 @@

import {parseGroup} from '../internal';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Ignored} from '../types';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseGroup} from '../internal';
import {maybe} from '../tools/maybe';
import {Ignored} from '../types';

@@ -10,4 +9,4 @@ /**

*/
export const parseIgnored = maybe<Ignored>(stream => {
if (!optional(stream, false, 'punc', '/')) {
export const parseIgnored = maybe<Ignored>((stream: TokenStream) => {
if (!stream.optional(false, 'punc', '/')) {
return null;

@@ -22,3 +21,3 @@ }

expect(stream, false, 'punc', '/');
stream.expect(false, 'punc', '/');
return {

@@ -25,0 +24,0 @@ type: 'ignored',

@@ -1,5 +0,4 @@

import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Multiplier} from '../types';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {maybe} from '../tools/maybe';
import {Multiplier} from '../types';

@@ -12,10 +11,10 @@ const types: {[key: string]: string} = {

export const parseMultiplier = maybe<Multiplier>(stream => {
const mp = optional(stream, true, 'punc', '*', '+', '?', '{');
export const parseMultiplier = maybe<Multiplier>((stream: TokenStream) => {
const mp = stream.optional(true, 'punc', '*', '+', '?', '{');
if (mp === '{') {
const start = expect(stream, false, 'num');
const start = stream.expect(false, 'num');
expect(stream, false, 'punc', ',');
const end = optional(stream, false, 'num');
stream.expect(false, 'punc', ',');
const end = stream.optional(false, 'num');

@@ -30,3 +29,3 @@ if (end !== null) {

expect(stream, false, 'punc', '}');
stream.expect(false, 'punc', '}');
return {

@@ -33,0 +32,0 @@ type: 'range',

@@ -1,7 +0,7 @@

import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Num} from '../types';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {maybe} from '../tools/maybe';
import {Num} from '../types';
export const parseNumber = maybe<Num>(stream => {
const num = optional(stream, false, 'num');
export const parseNumber = maybe<Num>((stream: TokenStream) => {
const num = stream.optional(false, 'num');

@@ -8,0 +8,0 @@ return num ? {

@@ -0,10 +1,9 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseArguments, parseIdentifier, parseMultiplier, parseTag} from '../internal';
import {parseModification} from '../modifiers/modifications';
import {parseSpreadOperator} from '../modifiers/spread-operator';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Reference} from '../types';
export const parseReference = maybe<Reference>(stream => {
export const parseReference = maybe<Reference>((stream: TokenStream) => {

@@ -15,3 +14,3 @@ // It may have a spread operator attached to it

// It may be a type
if (!optional(stream, false, 'punc', '<')) {
if (!stream.optional(false, 'punc', '<')) {
return null;

@@ -31,3 +30,3 @@ }

if (!optional(stream, false, 'punc', ':')) {
if (!stream.optional(false, 'punc', ':')) {
break;

@@ -54,3 +53,3 @@ } else {

expect(stream, false, 'punc', '>');
stream.expect(false, 'punc', '>');
const mult = parseMultiplier(stream);

@@ -57,0 +56,0 @@

@@ -1,7 +0,7 @@

import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Str} from '../types';
import {TokenStream} from '../../tokenizer/stream/token-stream';
import {maybe} from '../tools/maybe';
import {Str} from '../types';
export const parseString = maybe<Str>(stream => {
const string = optional(stream, false, 'str');
export const parseString = maybe<Str>((stream: TokenStream) => {
const string = stream.optional(false, 'str');

@@ -8,0 +8,0 @@ if (string !== null && !(string as string).length) {

@@ -0,8 +1,8 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseIdentifier} from '../internal';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {Tag} from '../types';
export const parseTag = maybe<Tag>(stream => {
if (!optional(stream, true, 'punc', '#')) {
export const parseTag = maybe<Tag>((stream: TokenStream) => {
if (!stream.optional(true, 'punc', '#')) {
return null;

@@ -13,3 +13,3 @@ }

if (!ident) {
return stream.throwError('Expected identifier');
stream.throwError('Expected identifier');
}

@@ -16,0 +16,0 @@

@@ -0,10 +1,9 @@

import {TokenStream} from '../../tokenizer/stream/token-stream';
import {parseIdentifier} from '../internal';
import {combine} from '../tools/combine';
import {expect} from '../tools/expect';
import {maybe} from '../tools/maybe';
import {optional} from '../tools/optional';
import {ValueAccessor} from '../types';
const parseObjectAccessor = maybe<string>(stream => {
if (!optional(stream, true, 'punc', '.')) {
const parseObjectAccessor = maybe<string>((stream: TokenStream) => {
if (!stream.optional(true, 'punc', '.')) {
return null;

@@ -15,3 +14,3 @@ }

if (!ident) {
return stream.throwError('Expected identifier.');
stream.throwError('Expected identifier.');
}

@@ -22,9 +21,9 @@

const parseArrayAccessor = maybe<number>(stream => {
if (!optional(stream, true, 'punc', '[')) {
const parseArrayAccessor = maybe<number>((stream: TokenStream) => {
if (!stream.optional(true, 'punc', '[')) {
return null;
}
const index = expect(stream, false, 'num');
expect(stream, true, 'punc', ']');
const index = stream.expect(false, 'num');
stream.expect(true, 'punc', ']');

@@ -34,3 +33,3 @@ return index as number;

export const parseValueAccessor = maybe<ValueAccessor>(stream => {
export const parseValueAccessor = maybe<ValueAccessor>((stream: TokenStream) => {
const entry = parseIdentifier(stream);

@@ -37,0 +36,0 @@

@@ -0,0 +0,0 @@ import {CharacterSelection, CharacterSelectionArray} from '../../ast/types';

@@ -46,2 +46,3 @@ import {Group, ModifierTarget, Reference} from '../../ast/types';

// TODO: Bug in loops
newScope.injectValue(argVal, name);

@@ -48,0 +49,0 @@ }

@@ -1,2 +0,2 @@

import {parseAST} from './ast';
import {parse} from './ast';
import {Declaration} from './ast/types';

@@ -17,3 +17,3 @@ import {compileDeclarations} from './compiler';

// Use precompiled declarations or compile raw string
const tree = Array.isArray(input) ? input : parseAST(tokenize(input), input);
const tree = Array.isArray(input) ? input : parse(tokenize(input), input);
return compileDeclarations(tree, config);

@@ -27,3 +27,3 @@ };

*/
export const compileChunk = (str: string): Array<Declaration> => parseAST(tokenize(str), str);
export const compileChunk = (str: string): Array<Declaration> => parse(tokenize(str), str);

@@ -30,0 +30,0 @@ /**

@@ -0,0 +0,0 @@

import {Streamable} from '../streamable';
import {Token} from './types';
import {cmt} from './types/cmt';
import {kw} from './types/kw';

@@ -10,2 +11,3 @@ import {num} from './types/num';

const parser = [
cmt,
ws,

@@ -39,15 +41,2 @@ str,

// Check if token could be the beginning of a comment
if (parsed.value === '/' && stream.peek() === '/') {
while (stream.hasNext()) {
if (stream.peek() === '\n') {
break;
}
stream.next();
}
continue outer;
}
// There may be a comment between whitespace, concatenate that

@@ -54,0 +43,0 @@ if (parsed.type === 'ws' && tokens.length && tokens[tokens.length - 1].type === 'ws') {

@@ -1,5 +0,6 @@

import {Streamable} from '../../streamable';
import {RangeInformation, Token} from '../types';
import {ParsingError} from './parsing-error';
import {Streamable} from '../../streamable';
import {RangeInformation, Token, TokenType} from '../types';
import {ParsingError} from './parsing-error';
/* istanbul ignore next */
export class TokenStream extends Streamable<Token> {

@@ -45,4 +46,62 @@

/**
* Consumes following whitespace
*/
consumeSpace(): void {
if (this.hasNext(true) && (this.peek(true) as Token).type === 'ws') {
this.next(true);
}
}
/**
* Checks if the next token matches the given conditioons
*/
match(includeWhitespace = false, type: TokenType, ...values: Array<string | number>): boolean {
const peek = this.peek(includeWhitespace);
// Check if type matches
if (!peek || peek.type !== type) {
return false;
}
// Check if value matches
return !values.length || values.includes(peek.value);
}
/**
* Same as match but it'll consume the token if the conditions are met
*/
optional(includeWhitespace = false, type: TokenType, ...values: Array<string | number>): string | number | null {
const peek = this.peek(includeWhitespace);
// Check if type matches
if (!peek || peek.type !== type) {
return null;
}
// Check if next token matches the given condition
return this.match(includeWhitespace, type, ...values) ? (this.next(includeWhitespace) as Token).value : null;
}
/**
* Same as match but it'll throw an error if the conditions aren't met
*/
expect(includeWhitespace = false, type: TokenType, ...values: Array<string | number>): string | number | never {
// Check if next token matches type and value
const expected = this.optional(includeWhitespace, type, ...values);
if (expected !== null) {
return expected;
}
if (this.hasNext(includeWhitespace)) {
const nxt = this.next(includeWhitespace) as Token;
this.throwError(`Expected ${values.join(', ')} (${type}) but got ${nxt.value} (${nxt.type})`);
}
this.throwError('Unxpected end of input.');
}
/**
* Throws an ParsingError
* @param msg
* @param msg Error message
*/

@@ -49,0 +108,0 @@ throwError(msg: string): never {

@@ -7,2 +7,4 @@ import {Streamable} from '../../streamable';

export const kw = (stream: Streamable<string>): Token | null => {
// TODO: Should a keyword contain numeric characters?
const str = consumeWhile(stream, (v, c) => {

@@ -9,0 +11,0 @@ return isNonWhitespace(v) || !!(isNumeric(v) && c.length);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc