UNPKG

chevrotain

Version:

Chevrotain is a high performance fault tolerant javascript parsing DSL for building recursive decent parsers

2 lines 129 kB
/*! chevrotain - v2.0.1 */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("chevrotain",[],e):"object"==typeof exports?exports.chevrotain=e():t.chevrotain=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=15)}([function(t,e,n){"use strict";function r(t){return t&&0===t.length}function i(t){return void 0===t||null===t?[]:Object.keys(t)}function o(t){for(var e=[],n=Object.keys(t),r=0;r<n.length;r++)e.push(t[n[r]]);return e}function a(t,e){for(var n=[],r=i(t),o=0;o<r.length;o++){var a=r[o];n.push(e.call(null,t[a],a))}return n}function s(t,e){for(var n=[],r=0;r<t.length;r++)n.push(e.call(null,t[r],r));return n}function u(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e=e.concat(u(r)):e.push(r)}return e}function c(t){return r(t)?void 0:t[0]}function l(t){var e=t&&t.length;return e?t[e-1]:void 0}function p(t,e){if(Array.isArray(t))for(var n=0;n<t.length;n++)e.call(null,t[n],n);else{if(!C(t))throw Error("non exhaustive match");for(var r=i(t),n=0;n<r.length;n++){var o=r[n],a=t[o];e.call(null,a,o)}}}function f(t){return"string"==typeof t}function h(t){return void 0===t}function d(t){return t instanceof Function}function T(t,e){return void 0===e&&(e=1),t.slice(e,t.length)}function E(t,e){return void 0===e&&(e=1),t.slice(0,t.length-e)}function m(t,e){var n=[];if(Array.isArray(t))for(var r=0;r<t.length;r++){var i=t[r];e.call(null,i)&&n.push(i)}return n}function y(t,e){return m(t,function(t){return!e(t)})}function v(t,e){for(var n=Object.keys(t),r={},i=0;i<n.length;i++){var o=n[i],a=t[o];e(a)&&(r[o]=a)}return r}function _(t,e){return!!C(t)&&t.hasOwnProperty(e)}function R(t,e){return void 0!==S(t,function(t){return t===e})}function A(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function N(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function S(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(e.call(null,r))return r}}function O(t,e){for(var n=[],r=0;r<t.length;r++){var i=t[r];e.call(null,i)&&n.push(i)}return n}function g(t,e,n){for(var r=Array.isArray(t)?t:o(t),i=n,a=0;a<r.length;a++)i=e.call(null,i,r[a],a);return i}function I(t){return y(t,function(t){return null===t||void 0===t})}function L(t,e){void 0===e&&(e=function(t){return t});var n=[];return g(t,function(t,r){var i=e(r);return R(n,i)?t:(n.push(i),t.concat(r))},[])}function P(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=[null],i=r.concat(e);return Function.bind.apply(t,i)}function k(t){return Array.isArray(t)}function x(t){return t instanceof RegExp}function C(t){return t instanceof Object}function M(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0}function F(t,e){return y(t,function(t){return R(e,t)})}function D(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return!0;return!1}function b(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}function w(t,e){var n=A(t);return n.sort(function(t,n){return e(t)-e(n)}),n}function U(t,e){if(t.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var n={},r=0;r<t.length;r++)n[t[r]]=e[r];return n}function K(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var o=e[r],a=i(o),s=0;s<a.length;s++){var u=a[s];t[u]=o[u]}return t}function W(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var o=e[r];if(!h(o))for(var a=i(o),s=0;s<a.length;s++){var u=a[s];_(t,u)||(t[u]=o[u])}}return t}function G(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return W.apply(null,[{}].concat(t))}function V(t,e){var n={};return p(t,function(t){var r=e(t),i=n[r];i?i.push(t):n[r]=[t]}),n}function B(t,e){for(var n=N(t),r=i(e),o=0;o<r.length;o++){var a=r[o],s=e[a];n[a]=s}return n}function j(){}function Y(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=r,e.keys=i,e.values=o,e.mapValues=a,e.map=s,e.flatten=u,e.first=c,e.last=l,e.forEach=p,e.isString=f,e.isUndefined=h,e.isFunction=d,e.drop=T,e.dropRight=E,e.filter=m,e.reject=y,e.pick=v,e.has=_,e.contains=R,e.cloneArr=A,e.cloneObj=N,e.find=S,e.findAll=O,e.reduce=g,e.compact=I,e.uniq=L,e.partial=P,e.isArray=k,e.isRegExp=x,e.isObject=C,e.every=M,e.difference=F,e.some=D,e.indexOf=b,e.sortBy=w,e.zipObject=U,e.assign=K,e.assignNoOverwrite=W,e.defaults=G,e.groupBy=V,e.merge=B,e.NOOP=j,e.IDENTITY=Y},function(t,e,n){"use strict";function r(t){return a.map(t,i)}function i(t){function e(t){return a.map(t,i)}if(t instanceof c)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof p)return{type:"Flat",definition:e(t.definition)};if(t instanceof f)return{type:"Option",definition:e(t.definition)};if(t instanceof h)return{type:"RepetitionMandatory",definition:e(t.definition)};if(t instanceof d)return{type:"RepetitionMandatoryWithSeparator",separator:i(new y({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof E)return{type:"RepetitionWithSeparator",separator:i(new y({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof T)return{type:"Repetition",definition:e(t.definition)};if(t instanceof m)return{type:"Alternation",definition:e(t.definition)};if(t instanceof y){var n={type:"Terminal",name:s.tokenName(t.terminalType),label:s.tokenLabel(t.terminalType),idx:t.idx},r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=a.isRegExp(r)?r.source:r),n}if(t instanceof l)return{type:"Rule",name:t.name,definition:e(t.definition)};throw Error("non exhaustive match")}var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var a=n(0),s=n(2),u=function(){function t(t){this.definition=t}return t.prototype.accept=function(t){t.visit(this),a.forEach(this.definition,function(e){e.accept(t)})},t}();e.AbstractProduction=u;var c=function(t){function e(e){var n=t.call(this,[])||this;return n.idx=1,a.assign(n,e),n}return o(e,t),Object.defineProperty(e.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(t){},enumerable:!0,configurable:!0}),e.prototype.accept=function(t){t.visit(this)},e}(u);e.NonTerminal=c;var l=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.orgText="",a.assign(n,e),n}return o(e,t),e}(u);e.Rule=l;var p=function(t){function e(e){var n=t.call(this,e.definition)||this;return a.assign(n,e),n}return o(e,t),e}(u);e.Flat=p;var f=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.Option=f;var h=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.RepetitionMandatory=h;var d=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.RepetitionMandatoryWithSeparator=d;var T=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.Repetition=T;var E=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.RepetitionWithSeparator=E;var m=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,a.assign(n,e),n}return o(e,t),e}(u);e.Alternation=m;var y=function(){function t(t){this.idx=1,a.assign(this,t)}return t.prototype.accept=function(t){t.visit(this)},t}();e.Terminal=y,e.serializeGrammar=r,e.serializeProduction=i},function(t,e,n){"use strict";function r(t){return i(t)?t.LABEL:o(t)}function i(t){return l.isString(t.LABEL)&&""!==t.LABEL}function o(t){return l.isObject(t)&&t.hasOwnProperty("tokenName")&&l.isString(t.tokenName)?t.tokenName:p.functionName(t)}function a(t){return s(t)}function s(t){var e=t.name,n=t.pattern,r={};if(p.defineNameProp(r,e)||(r.tokenName=e),l.isUndefined(n)||(r.PATTERN=n),l.has(t,d))throw"The parent property is no longer supported.\nSee: https://github.com/SAP/chevrotain/issues/564#issuecomment-349062346 for details.";return l.has(t,T)&&(r.CATEGORIES=t[T]),h.augmentTokenTypes([r]),l.has(t,E)&&(r.LABEL=t[E]),l.has(t,m)&&(r.GROUP=t[m]),l.has(t,v)&&(r.POP_MODE=t[v]),l.has(t,y)&&(r.PUSH_MODE=t[y]),l.has(t,_)&&(r.LONGER_ALT=t[_]),l.has(t,R)&&(r.LINE_BREAKS=t[R]),r}function u(t,e,n,r,i,o,a,s){return{image:e,startOffset:n,endOffset:r,startLine:i,endLine:o,startColumn:a,endColumn:s,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function c(t,e){return h.tokenStructuredMatcher(t,e)}Object.defineProperty(e,"__esModule",{value:!0});var l=n(0),p=n(3),f=n(11),h=n(8);e.tokenLabel=r,e.hasTokenLabel=i,e.tokenName=o;var d="parent",T="categories",E="label",m="group",y="push_mode",v="pop_mode",_="longer_alt",R="line_breaks";e.createToken=a,e.EOF=a({name:"EOF",pattern:f.Lexer.NA}),h.augmentTokenTypes([e.EOF]),e.createTokenInstance=u,e.tokenMatcher=c},function(t,e,n){"use strict";function r(t){return i(t.constructor)}function i(t){var e=t.name;return e||t.toString().match(u)[1]}function o(t,e){var n=Object.getOwnPropertyDescriptor(t,c);return!(!s.isUndefined(n)&&!n.configurable)&&(Object.defineProperty(t,c,{enumerable:!1,configurable:!0,writable:!1,value:e}),!0)}Object.defineProperty(e,"__esModule",{value:!0});var a=n(0),s=n(0);e.classNameFromInstance=r;var u=/^\s*function\s*(\S*)\s*\(/,c="name";e.functionName=i,e.defineNameProp=o;var l=function(){function t(){this._state={}}return t.prototype.keys=function(){return a.keys(this._state)},t.prototype.values=function(){return a.values(this._state)},t.prototype.put=function(t,e){this._state[t]=e},t.prototype.putAll=function(t){this._state=a.assign(this._state,t._state)},t.prototype.get=function(t){return this._state[t]},t.prototype.containsKey=function(t){return a.has(this._state,t)},t.prototype.clear=function(){this._state={}},t}();e.HashTable=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),i=function(){function t(){}return t.prototype.visit=function(t){if(t instanceof r.NonTerminal)return this.visitNonTerminal(t);if(t instanceof r.Flat)return this.visitFlat(t);if(t instanceof r.Option)return this.visitOption(t);if(t instanceof r.RepetitionMandatory)return this.visitRepetitionMandatory(t);if(t instanceof r.RepetitionMandatoryWithSeparator)return this.visitRepetitionMandatoryWithSeparator(t);if(t instanceof r.RepetitionWithSeparator)return this.visitRepetitionWithSeparator(t);if(t instanceof r.Repetition)return this.visitRepetition(t);if(t instanceof r.Alternation)return this.visitAlternation(t);if(t instanceof r.Terminal)return this.visitTerminal(t);if(t instanceof r.Rule)return this.visitRule(t);throw Error("non exhaustive match")},t.prototype.visitNonTerminal=function(t){},t.prototype.visitFlat=function(t){},t.prototype.visitOption=function(t){},t.prototype.visitRepetition=function(t){},t.prototype.visitRepetitionMandatory=function(t){},t.prototype.visitRepetitionMandatoryWithSeparator=function(t){},t.prototype.visitRepetitionWithSeparator=function(t){},t.prototype.visitAlternation=function(t){},t.prototype.visitTerminal=function(t){},t.prototype.visitRule=function(t){},t}();e.GAstVisitor=i},function(t,e,n){"use strict";function r(t){return t instanceof l.Flat||t instanceof l.Option||t instanceof l.Repetition||t instanceof l.RepetitionMandatory||t instanceof l.RepetitionMandatoryWithSeparator||t instanceof l.RepetitionWithSeparator||t instanceof l.Terminal||t instanceof l.Rule}function i(t,e){return void 0===e&&(e=[]),!!(t instanceof l.Option||t instanceof l.Repetition||t instanceof l.RepetitionWithSeparator)||(t instanceof l.Alternation?c.some(t.definition,function(t){return i(t,e)}):!(t instanceof l.NonTerminal&&c.contains(e,t))&&t instanceof l.AbstractProduction&&(t instanceof l.NonTerminal&&e.push(t),c.every(t.definition,function(t){return i(t,e)})))}function o(t){return t instanceof l.Alternation}function a(t){if(t instanceof l.NonTerminal)return"SUBRULE";if(t instanceof l.Option)return"OPTION";if(t instanceof l.Alternation)return"OR";if(t instanceof l.RepetitionMandatory)return"AT_LEAST_ONE";if(t instanceof l.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(t instanceof l.RepetitionWithSeparator)return"MANY_SEP";if(t instanceof l.Repetition)return"MANY";if(t instanceof l.Terminal)return"CONSUME";throw Error("non exhaustive match")}function s(t){return(new h).visit(t)}var u=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var c=n(0),l=n(1),p=n(4),f=n(2);e.isSequenceProd=r,e.isOptionalProd=i,e.isBranchingProd=o,e.getProductionDslName=a;var h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.visitNonTerminal=function(t){return new l.NonTerminal({nonTerminalName:t.nonTerminalName,idx:t.idx})},e.prototype.visitFlat=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.Flat({definition:n,name:t.name})},e.prototype.visitOption=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.Option({definition:n,idx:t.idx,name:t.name})},e.prototype.visitRepetition=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.Repetition({definition:n,idx:t.idx,name:t.name})},e.prototype.visitRepetitionMandatory=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.RepetitionMandatory({definition:n,idx:t.idx,name:t.name})},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.RepetitionMandatoryWithSeparator({definition:n,separator:t.separator,idx:t.idx,name:t.name})},e.prototype.visitRepetitionWithSeparator=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.RepetitionWithSeparator({definition:n,separator:t.separator,idx:t.idx,name:t.name})},e.prototype.visitAlternation=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.Alternation({definition:n,idx:t.idx,name:t.name})},e.prototype.visitTerminal=function(t){return new l.Terminal({terminalType:t.terminalType,idx:t.idx})},e.prototype.visitRule=function(t){var e=this,n=c.map(t.definition,function(t){return e.visit(t)});return new l.Rule({name:t.name,definition:n,orgText:t.orgText})},e}(p.GAstVisitor);e.cloneProduction=s;var d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.separator="-",e.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},e}return u(e,t),e.prototype.visitTerminal=function(t){var e=f.tokenName(t.terminalType)+this.separator+"Terminal";c.has(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitNonTerminal=function(t){var e=t.nonTerminalName+this.separator+"Terminal";c.has(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitOption=function(t){this.dslMethods.option.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.dslMethods.repetitionWithSeparator.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.dslMethods.repetitionMandatory.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)},e.prototype.visitRepetition=function(t){this.dslMethods.repetition.push(t)},e.prototype.visitAlternation=function(t){this.dslMethods.alternation.push(t)},e}(p.GAstVisitor);e.DslMethodsCollectorVisitor=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),i=n(0),o=n(0),a=n(1),s=n(5),u=n(7),c=n(14);e.defaultParserErrorProvider={buildMismatchTokenMessage:function(t){var e=t.expected,n=t.actual;t.ruleName;return"Expecting "+(r.hasTokenLabel(e)?"--\x3e "+r.tokenLabel(e)+" <--":"token of type --\x3e "+r.tokenName(e)+" <--")+" but found --\x3e '"+n.image+"' <--"},buildNotAllInputParsedMessage:function(t){var e=t.firstRedundant;t.ruleName;return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(t){var e=t.expectedPathsPerAlt,n=t.actual,i=t.customUserDescription,a=(t.ruleName,o.first(n).image),s="\nbut found: '"+a+"'";if(i)return"Expecting: "+i+s;var u=o.reduce(e,function(t,e){return t.concat(e)},[]),c=o.map(u,function(t){return"["+o.map(t,function(t){return r.tokenLabel(t)}).join(", ")+"]"});return"Expecting: one of these possible Token sequences:\n"+o.map(c,function(t,e){return" "+(e+1)+". "+t}).join("\n")+s},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,n=t.actual,i=t.customUserDescription,a=(t.ruleName,o.first(n).image),s="\nbut found: '"+a+"'";return i?"Expecting: "+i+s:"Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <"+o.map(e,function(t){return"["+o.map(t,function(t){return r.tokenLabel(t)}).join(",")+"]"}).join(" ,")+">"+s}},Object.freeze(e.defaultParserErrorProvider),e.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"}},e.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(t,e){var n=t.name,i=o.first(e),u=i.idx,c=s.getProductionDslName(i),l=function(t){return t instanceof a.Terminal?r.tokenName(t.terminalType):t instanceof a.NonTerminal?t.nonTerminalName:""}(i),p="->"+c+"<- with numerical suffix: ->"+u+"<-\n "+(l?"and argument: ->"+l+"<-":"")+"\n appears more than once ("+e.length+" times) in the top level rule: ->"+n+"<-.\n "+(0===u?"Also note that numerical suffix 0 means "+c+" without any suffix.":"")+"\n To fix this make sure each usage of "+c+" "+(l?"with the argument: ->"+l+"<-":"")+"\n in the rule ->"+n+"<- has a different occurrence index (0-5), as that combination acts as a unique\n position key in the grammar, which is needed by the parsing engine.\n \n For further details see: http://sap.github.io/chevrotain/website/FAQ.html#NUMERICAL_SUFFIXES \n ";return p=p.replace(/[ \t]+/g," "),p=p.replace(/\s\s+/g,"\n")},buildInvalidNestedRuleNameError:function(t,e){return"Invalid nested rule name: ->"+e.name+"<- inside rule: ->"+t.name+"<-\nit must match the pattern: ->"+u.validNestedRuleName.toString()+"<-.\nNote that this means a nested rule name must start with the '$'(dollar) sign."},buildDuplicateNestedRuleNameError:function(t,e){return"Duplicate nested rule name: ->"+o.first(e).name+"<- inside rule: ->"+t.name+"<-\nA nested name must be unique in the scope of a top level grammar rule."},buildNamespaceConflictError:function(t){return"Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+t.name+">.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter."},buildAlternationPrefixAmbiguityError:function(t){var e=o.map(t.prefixPath,function(t){return r.tokenLabel(t)}).join(", "),n=0===t.alternation.idx?"":t.alternation.idx;return"Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+"> due to common lookahead prefix\nin <OR"+n+"> inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\nhttp://sap.github.io/chevrotain/website/Building_Grammars/resolving_grammar_errors.html#COMMON_PREFIX For farther details."},buildAlternationAmbiguityError:function(t){var e=o.map(t.prefixPath,function(t){return r.tokenLabel(t)}).join(", "),n=0===t.alternation.idx?"":t.alternation.idx,i="Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+"> in <OR"+n+"> inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\n";return i=i+"To Resolve this, try one of of the following: \n1. Refactor your grammar to be LL(K) for the current value of k (by default k=5)\n2. Increase the value of K for your grammar by providing a larger 'maxLookahead' value in the parser's config\n3. This issue can be ignored (if you know what you are doing...), see http://sap.github.io/chevrotain/documentation/"+c.VERSION.replace(/\./g,"_")+"/interfaces/iparserconfig.html#ignoredissues for more details\n"},buildEmptyRepetitionError:function(t){var e=s.getProductionDslName(t.repetition);return 0!==t.repetition.idx&&(e+=t.repetition.idx),"The repetition <"+e+"> within Rule <"+t.topLevelRule.name+"> can never consume any tokens.\nThis could lead to an infinite loop."},buildTokenNameError:function(t){return"Invalid Grammar Token name: ->"+r.tokenName(t.tokenType)+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildEmptyAlternationError:function(t){return"Ambiguous empty alternative: <"+(t.emptyChoiceIdx+1)+"> in <OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+"> Rule.\nOnly the last alternative may be an empty alternative."},buildTooManyAlternativesError:function(t){return"An Alternation cannot have more than 256 alternatives:\n<OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+"> Rule.\n has "+(t.alternation.definition.length+1)+" alternatives."},buildLeftRecursionError:function(t){var e=t.topLevelRule.name;return"Left Recursion found in grammar.\nrule: <"+e+"> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n "+e+" --\x3e "+i.map(t.leftRecursionPath,function(t){return t.name}).concat([e]).join(" --\x3e ")+"\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."},buildInvalidRuleNameError:function(t){return"Invalid grammar rule name: ->"+t.topLevelRule.name+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildDuplicateRuleNameError:function(t){return"Duplicate definition, rule: ->"+(t.topLevelRule instanceof a.Rule?t.topLevelRule.name:t.topLevelRule)+"<- is already defined in the grammar: ->"+t.grammarName+"<-"}}},function(t,e,n){"use strict";function r(t,e,n,r,a,s){void 0===r&&(r={}),void 0===a&&(a=F.defaultGrammarValidatorErrorProvider);var c=S.map(t,function(t){return o(t,a)}),f=S.map(t,function(t){return h(t,t,a)}),d=[],v=[];O.every(f,O.isEmpty)&&(d=O.map(t,function(t){return T(t,a)}),v=O.map(t,function(t){return E(t,e,r,a)}));var _=R(t,n,a),N=S.map(n,function(t){return l(t,a)}),g=i(t,a),I=A(t,a),L=y(t,e,a),P=O.map(t,function(t){return m(t,a)}),k=O.map(t,function(t){return u(t,a)}),x=O.map(t,function(e){return p(e,t,s,a)});return S.flatten(c.concat(N,g,I,L,f,d,v,_,P,k,x))}function i(t,e){var n=[];return O.forEach(t,function(t){var r=new k.NamedDSLMethodsCollectorVisitor("");t.accept(r);var i=O.map(r.result,function(t){return t.orgProd});n.push(O.map(i,function(n){return c(t,n,e)}))}),O.flatten(n)}function o(t,e){var n=new D;t.accept(n);var r=n.allProductions,i=S.groupBy(r,a),o=S.pick(i,function(t){return t.length>1});return S.map(S.values(o),function(n){var r=S.first(n),i=e.buildDuplicateFoundError(t,n),o=I.getProductionDslName(r),a={message:i,type:g.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:o,occurrence:r.idx},u=s(r);return u&&(a.parameter=u),a})}function a(t){return I.getProductionDslName(t)+"_#_"+t.idx+"_#_"+s(t)}function s(t){return t instanceof C.Terminal?L.tokenName(t.terminalType):t instanceof C.NonTerminal?t.nonTerminalName:""}function u(t,n){var r=[],i=t.name;return i.match(e.validTermsPattern)||r.push({message:n.buildInvalidRuleNameError({topLevelRule:t,expectedPattern:e.validTermsPattern}),type:g.ParserDefinitionErrorType.INVALID_RULE_NAME,ruleName:i}),r}function c(t,n,r){var i,o=[];return n.name.match(e.validNestedRuleName)||(i=r.buildInvalidNestedRuleNameError(t,n),o.push({message:i,type:g.ParserDefinitionErrorType.INVALID_NESTED_RULE_NAME,ruleName:t.name})),o}function l(t,n){var r=[];return L.tokenName(t).match(e.validTermsPattern)||r.push({message:n.buildTokenNameError({tokenType:t,expectedPattern:e.validTermsPattern}),type:g.ParserDefinitionErrorType.INVALID_TOKEN_NAME}),r}function p(t,e,n,r){var i=[];if(O.reduce(e,function(e,n){return n.name===t.name?e+1:e},0)>1){var o=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});i.push({message:o,type:g.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:t.name})}return i}function f(t,e,n){var r,i=[];return S.contains(e,t)||(r="Invalid rule override, rule: ->"+t+"<- cannot be overridden in the grammar: ->"+n+"<-as it is not defined in any of the super grammars ",i.push({message:r,type:g.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:t})),i}function h(t,e,n,r){void 0===r&&(r=[]);var i=[],o=d(e.definition);if(S.isEmpty(o))return[];var a=t.name;S.contains(o,t)&&i.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:g.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:a});var s=S.difference(o,r.concat([t])),u=S.map(s,function(e){var i=S.cloneArr(r);return i.push(e),h(t,e,n,i)});return i.concat(S.flatten(u))}function d(t){var e=[];if(S.isEmpty(t))return e;var n=S.first(t);if(n instanceof C.NonTerminal)e.push(n.referencedRule);else if(n instanceof C.Flat||n instanceof C.Option||n instanceof C.RepetitionMandatory||n instanceof C.RepetitionMandatoryWithSeparator||n instanceof C.RepetitionWithSeparator||n instanceof C.Repetition)e=e.concat(d(n.definition));else if(n instanceof C.Alternation)e=S.flatten(S.map(n.definition,function(t){return d(t.definition)}));else if(!(n instanceof C.Terminal))throw Error("non exhaustive match");var r=I.isOptionalProd(n),i=t.length>1;if(r&&i){var o=S.drop(t);return e.concat(d(o))}return e}function T(t,e){var n=new b;t.accept(n);var r=n.alternations;return S.reduce(r,function(n,r){var i=S.dropRight(r.definition),o=S.map(i,function(n,i){var o=x.nextPossibleTokensAfter([n],[],null,1);return S.isEmpty(o)?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:r,emptyChoiceIdx:i}),type:g.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:r.idx,alternative:i+1}:null});return n.concat(S.compact(o))},[])}function E(t,e,n,r){var i=new b;t.accept(i);var o=i.alternations,a=n[t.name];return a&&(o=O.reject(o,function(t){return a[I.getProductionDslName(t)+(0===t.idx?"":t.idx)]})),S.reduce(o,function(n,i){var o=i.idx,a=P.getLookaheadPathsForOr(o,t,e),s=v(a,i,t,r),u=_(a,i,t,r);return n.concat(s,u)},[])}function m(t,e){var n=new b;t.accept(n);var r=n.alternations;return S.reduce(r,function(n,r){return r.definition.length>255&&n.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:r}),type:g.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:t.name,occurrence:r.idx}),n},[])}function y(t,e,n){var r=[];return O.forEach(t,function(t){var i=new w;t.accept(i);var o=i.allProductions;O.forEach(o,function(i){var o=P.getProdType(i),a=i.idx,s=P.getLookaheadPathsForOptionalProd(a,t,o,e),u=s[0];if(O.isEmpty(O.flatten(u))){var c=n.buildEmptyRepetitionError({topLevelRule:t,repetition:i});r.push({message:c,type:g.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:t.name})}})}),r}function v(t,e,n,r){var i=[],o=O.reduce(t,function(e,n,r){return O.forEach(n,function(n){var o=[r];O.forEach(t,function(t,e){r!==e&&P.containsPath(t,n)&&o.push(e)}),o.length>1&&!P.containsPath(i,n)&&(i.push(n),e.push({alts:o,path:n}))}),e},[]);return S.map(o,function(t){var i=O.map(t.alts,function(t){return t+1});return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:i,prefixPath:t.path}),type:g.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:[t.alts]}})}function _(t,e,n,r){var i=[],o=O.reduce(t,function(t,e,n){var r=O.map(e,function(t){return{idx:n,path:t}});return t.concat(r)},[]);return O.forEach(o,function(t){var a=t.idx,s=t.path,u=O.findAll(o,function(t){return t.idx<a&&P.isStrictPrefixOfPath(t.path,s)}),c=O.map(u,function(t){var i=[t.idx+1,a+1],o=0===e.idx?"":e.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:i,prefixPath:t.path}),type:g.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}});i=i.concat(c)}),i}function R(t,e,n){var r=[],i=O.map(e,function(t){return L.tokenName(t)});return O.forEach(t,function(t){var e=t.name;if(O.contains(i,e)){var o=n.buildNamespaceConflictError(t);r.push({message:o,type:g.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:e})}}),r}function A(t,e){var n=[];return O.forEach(t,function(t){var r=new k.NamedDSLMethodsCollectorVisitor("");t.accept(r);var i=O.groupBy(r.result,function(t){return t.name}),o=O.pick(i,function(t){return t.length>1});O.forEach(O.values(o),function(r){var i=O.map(r,function(t){return t.orgProd}),o=e.buildDuplicateNestedRuleNameError(t,i);n.push({message:o,type:g.ParserDefinitionErrorType.DUPLICATE_NESTED_NAME,ruleName:t.name})})}),n}var N=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var S=n(0),O=n(0),g=n(9),I=n(5),L=n(2),P=n(17),k=n(19),x=n(12),C=n(1),M=n(4),F=n(6);e.validateGrammar=r,e.identifyProductionForDuplicates=a;var D=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return N(e,t),e.prototype.visitNonTerminal=function(t){this.allProductions.push(t)},e.prototype.visitOption=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e.prototype.visitAlternation=function(t){this.allProductions.push(t)},e.prototype.visitTerminal=function(t){this.allProductions.push(t)},e}(M.GAstVisitor);e.OccurrenceValidationCollector=D,e.validTermsPattern=/^[a-zA-Z_]\w*$/,e.validNestedRuleName=new RegExp(e.validTermsPattern.source.replace("^","^\\$")),e.validateRuleName=u,e.validateNestedRuleName=c,e.validateTokenName=l,e.validateRuleDoesNotAlreadyExist=p,e.validateRuleIsOverridden=f,e.validateNoLeftRecursion=h,e.getFirstNoneTerminal=d;var b=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alternations=[],e}return N(e,t),e.prototype.visitAlternation=function(t){this.alternations.push(t)},e}(M.GAstVisitor);e.validateEmptyOrAlternative=T,e.validateAmbiguousAlternationAlternatives=E;var w=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return N(e,t),e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e}(M.GAstVisitor);e.RepetionCollector=w,e.validateTooManyAlts=m,e.validateSomeNonEmptyLookaheadPath=y},function(t,e,n){"use strict";function r(t,e){var n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function i(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}function o(t){var e=a(t);s(e),c(e),u(e),m.forEach(e,function(t){t.isParent=t.categoryMatches.length>0})}function a(t){for(var e=m.cloneArr(t),n=t,r=!0;r;){n=m.compact(m.flatten(m.map(n,function(t){return t.CATEGORIES})));var i=m.difference(n,e);e=e.concat(i),m.isEmpty(i)?r=!1:n=i}return e}function s(t){m.forEach(t,function(t){p(t)||(e.tokenIdxToClass.put(e.tokenShortNameIdx,t),t.tokenTypeIdx=e.tokenShortNameIdx++),f(t)&&!m.isArray(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),f(t)||(t.CATEGORIES=[]),h(t)||(t.categoryMatches=[]),d(t)||(t.categoryMatchesMap={}),T(t)||(t.tokenName=v.tokenName(t))})}function u(t){m.forEach(t,function(t){t.categoryMatches=[],m.forEach(t.categoryMatchesMap,function(n,r){t.categoryMatches.push(e.tokenIdxToClass.get(r).tokenTypeIdx)})})}function c(t){m.forEach(t,function(t){l([],t)})}function l(t,e){m.forEach(t,function(t){e.categoryMatchesMap[t.tokenTypeIdx]=!0}),m.forEach(e.CATEGORIES,function(n){var r=t.concat(e);m.contains(r,n)||l(r,n)})}function p(t){return m.has(t,"tokenTypeIdx")}function f(t){return m.has(t,"CATEGORIES")}function h(t){return m.has(t,"categoryMatches")}function d(t){return m.has(t,"categoryMatchesMap")}function T(t){return m.has(t,"tokenName")}function E(t){return m.has(t,"tokenTypeIdx")}Object.defineProperty(e,"__esModule",{value:!0});var m=n(0),y=n(3),v=n(2);e.tokenStructuredMatcher=r,e.tokenStructuredMatcherNoCategories=i,e.tokenShortNameIdx=1,e.tokenIdxToClass=new y.HashTable,e.augmentTokenTypes=o,e.expandCategories=a,e.assignTokenDefaultProps=s,e.assignCategoriesTokensProp=u,e.assignCategoriesMapProp=c,e.hasShortKeyProperty=p,e.hasCategoriesProperty=f,e.hasExtendingTokensTypesProperty=h,e.hasExtendingTokensTypesMapProperty=d,e.hasTokenNameProperty=T,e.isTokenType=E},function(t,e,n){"use strict";function r(t){return void 0===t&&(t=void 0),function(){return t}}function i(t){this.name=g,this.message=t}Object.defineProperty(e,"__esModule",{value:!0});var o,a=n(10),s=n(10),u=n(16),c=n(3),l=n(7),p=n(0),f=n(24),h=n(2),d=n(17),T=n(25),E=n(12),m=n(21),y=n(5),v=n(8),_=n(19),R=n(20),A=n(27),N=n(6),S=n(1),O=n(22);!function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.INVALID_NESTED_RULE_NAME=10]="INVALID_NESTED_RULE_NAME",t[t.DUPLICATE_NESTED_NAME=11]="DUPLICATE_NESTED_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=12]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=13]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=14]="TOO_MANY_ALTS"}(o=e.ParserDefinitionErrorType||(e.ParserDefinitionErrorType={}));var g="InRuleRecoveryException";e.END_OF_FILE=h.createTokenInstance(h.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(e.END_OF_FILE);var I=Object.freeze({recoveryEnabled:!1,maxLookahead:4,ignoredIssues:{},dynamicTokensEnabled:!1,outputCst:!1,errorMessageProvider:N.defaultParserErrorProvider}),L=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});e.EMPTY_ALT=r;var P={},k=function(){function t(t,e,n){if(void 0===n&&(n=I),this._errors=[],this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.CST_STACK=[],this.tokensMap=void 0,this.definedRulesNames=[],this.shortRuleNameToFull=new c.HashTable,this.fullRuleNameToShort=new c.HashTable,this.ruleShortNameIdx=256,this.LAST_EXPLICIT_RULE_STACK=[],this.selfAnalysisDone=!1,this.currIdx=-1,this._productions=new c.HashTable,this.input=t,this.recoveryEnabled=p.has(n,"recoveryEnabled")?n.recoveryEnabled:I.recoveryEnabled,this.recoveryEnabled||(this.attemptInRepetitionRecovery=p.NOOP),this.dynamicTokensEnabled=p.has(n,"dynamicTokensEnabled")?n.dynamicTokensEnabled:I.dynamicTokensEnabled,this.maxLookahead=p.has(n,"maxLookahead")?n.maxLookahead:I.maxLookahead,this.ignoredIssues=p.has(n,"ignoredIssues")?n.ignoredIssues:I.ignoredIssues,this.outputCst=p.has(n,"outputCst")?n.outputCst:I.outputCst,this.errorMessageProvider=p.defaults(n.errorMessageProvider,I.errorMessageProvider),this.outputCst||(this.cstInvocationStateUpdate=p.NOOP,this.cstFinallyStateUpdate=p.NOOP,this.cstPostTerminal=p.NOOP,this.cstPostNonTerminal=p.NOOP,this.getLastExplicitRuleShortName=this.getLastExplicitRuleShortNameNoCst,this.getPreviousExplicitRuleShortName=this.getPreviousExplicitRuleShortNameNoCst,this.getPreviousExplicitRuleOccurenceIndex=this.getPreviousExplicitRuleOccurenceIndexNoCst,this.manyInternal=this.manyInternalNoCst,this.orInternal=this.orInternalNoCst,this.optionInternal=this.optionInternalNoCst,this.atLeastOneInternal=this.atLeastOneInternalNoCst,this.manySepFirstInternal=this.manySepFirstInternalNoCst,this.atLeastOneSepFirstInternal=this.atLeastOneSepFirstInternalNoCst),this.className=c.classNameFromInstance(this),this.firstAfterRepMap=a.getFirstAfterRepForClass(this.className),this.classLAFuncs=a.getLookaheadFuncsForClass(this.className),this.cstDictDefForRule=a.getCstDictDefPerRuleForClass(this.className),a.CLASS_TO_DEFINITION_ERRORS.containsKey(this.className)?this.definitionErrors=a.CLASS_TO_DEFINITION_ERRORS.get(this.className):(this.definitionErrors=[],a.CLASS_TO_DEFINITION_ERRORS.put(this.className,this.definitionErrors)),p.isArray(e))this.tokensMap=p.reduce(e,function(t,e){return t[h.tokenName(e)]=e,t},{});else if(p.has(e,"modes")&&p.every(p.flatten(p.values(e.modes)),v.isTokenType)){var r=p.flatten(p.values(e.modes)),i=p.uniq(r);this.tokensMap=p.reduce(i,function(t,e){return t[h.tokenName(e)]=e,t},{})}else{if(!p.isObject(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=p.cloneObj(e)}var o=p.every(p.values(e),function(t){return p.isEmpty(t.categoryMatches)});this.tokenMatcher=o?v.tokenStructuredMatcherNoCategories:v.tokenStructuredMatcher,this.tokensMap.EOF=h.EOF,v.augmentTokenTypes(p.values(this.tokensMap))}return t.performSelfAnalysis=function(e){var n,r=[];e.selfAnalysisDone=!0;var i=c.classNameFromInstance(e);if(""===i)throw Error("A Parser's constructor may not be an anonymous Function, it must be a named function\nThe constructor's name is used at runtime for performance (caching) purposes.");if(!a.CLASS_TO_SELF_ANALYSIS_DONE.containsKey(i)){a.CLASS_TO_SELF_ANALYSIS_DONE.put(i,!0);var o=e._productions,s=new c.HashTable;p.forEach(o.keys(),function(t){var e=o.get(t);s.put(t,y.cloneProduction(e))}),a.getProductionsForClass(i).putAll(s),r=a.CLASS_TO_DEFINITION_ERRORS.get(i);var u=O.resolveGrammar({rules:s.values()});if(r.push.apply(r,u),p.isEmpty(u)){var l=O.validateGrammar({rules:s.values(),maxLookahead:e.maxLookahead,tokenTypes:p.values(e.tokensMap),ignoredIssues:e.ignoredIssues,errMsgProvider:N.defaultGrammarValidatorErrorProvider,grammarName:i});r.push.apply(r,l)}if(!p.isEmpty(r)&&!t.DEFER_DEFINITION_ERRORS_HANDLING)throw n=p.map(r,function(t){return t.message}),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"));if(p.isEmpty(r)){var h=f.computeAllProdsFollows(s.values());a.setResyncFollowsForClass(i,h)}var d=_.analyzeCst(s.values(),e.fullRuleNameToShort);a.getCstDictDefPerRuleForClass(i).putAll(d.dictDef),a.CLASS_TO_ALL_RULE_NAMES.put(i,d.allRuleNames)}if(!p.isEmpty(a.CLASS_TO_DEFINITION_ERRORS.get(i))&&!t.DEFER_DEFINITION_ERRORS_HANDLING)throw n=p.map(a.CLASS_TO_DEFINITION_ERRORS.get(i),function(t){return t.message}),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"))},Object.defineProperty(t.prototype,"errors",{get:function(){return p.cloneArr(this._errors)},set:function(t){this._errors=t},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.LAST_EXPLICIT_RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),h.EOF)},t.prototype.getBaseCstVisitorConstructor=function(){var t=s.CLASS_TO_BASE_CST_VISITOR.get(this.className);if(p.isUndefined(t)){var e=s.CLASS_TO_ALL_RULE_NAMES.get(this.className);t=A.createBaseSemanticVisitorConstructor(this.className,e),s.CLASS_TO_BASE_CST_VISITOR.put(this.className,t)}return t},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){var t=s.CLASS_TO_BASE_CST_VISITOR_WITH_DEFAULTS.get(this.className);if(p.isUndefined(t)){var e=s.CLASS_TO_ALL_RULE_NAMES.get(this.className),n=this.getBaseCstVisitorConstructor();t=A.createBaseVisitorConstructorWithDefaults(this.className,e,n),s.CLASS_TO_BASE_CST_VISITOR_WITH_DEFAULTS.put(this.className,t)}return t},t.prototype.getGAstProductions=function(){return a.getProductionsForClass(this.className)},t.prototype.getSerializedGastProductions=function(){return S.serializeGrammar(a.getProductionsForClass(this.className).values())},t.prototype.computeContentAssist=function(t,e){var n=a.getProductionsForClass(this.className).get(t);if(p.isUndefined(n))throw Error("Rule ->"+t+"<- does not exist in this grammar.");return E.nextPossibleTokensAfter([n],e,this.tokenMatcher,this.maxLookahead)},t.prototype.isBackTracking=function(){return!p.isEmpty(this.isBackTrackingStack)},t.prototype.getCurrRuleFullName=function(){var t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull.get(t)},t.prototype.shortRuleNameToFullName=function(t){return this.shortRuleNameToFull.get(t)},t.prototype.getHumanReadableRuleStack=function(){var t=this;return p.isEmpty(this.LAST_EXPLICIT_RULE_STACK)?p.map(this.RULE_STACK,function(e){return t.shortRuleNameToFullName(e)}):p.map(this.LAST_EXPLICIT_RULE_STACK,function(e){return t.shortRuleNameToFullName(t.RULE_STACK[e])})},t.prototype.SAVE_ERROR=function(t){if(u.isRecognitionException(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:p.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")},t.prototype.BACKTRACK=function(t,e){return function(){this.isBackTrackingStack.push(1);var n=this.saveRecogState();try{return t.apply(this,e),!0}catch(t){if(u.isRecognitionException(t))return!1;throw t}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}},t.prototype.CONSUME=function(t,e){return this.consumeInternal(t,0,e)},t.prototype.CONSUME1=function(t,e){return this.consumeInternal(t,1,e)},t.prototype.CONSUME2=function(t,e){return this.consumeInternal(t,2,e)},t.prototype.CONSUME3=function(t,e){return this.consumeInternal(t,3,e)},t.prototype.CONSUME4=function(t,e){return this.consumeInternal(t,4,e)},t.prototype.CONSUME5=function(t,e){return this.consumeInternal(t,5,e)},t.prototype.CONSUME6=function(t,e){return this.consumeInternal(t,6,e)},t.prototype.CONSUME7=function(t,e){return this.consumeInternal(t,7,e)},t.prototype.CONSUME8=function(t,e){return this.consumeInternal(t,8,e)},t.prototype.CONSUME9=function(t,e){return this.consumeInternal(t,9,e)},t.prototype.SUBRULE=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,0,e)},t.prototype.SUBRULE1=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,1,e)},t.prototype.SUBRULE2=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,2,e)},t.prototype.SUBRULE3=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,3,e)},t.prototype.SUBRULE4=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,4,e)},t.prototype.SUBRULE5=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,5,e)},t.prototype.SUBRULE6=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,6,e)},t.prototype.SUBRULE7=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,7,e)},t.prototype.SUBRULE8=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,8,e)},t.prototype.SUBRULE9=function(t,e){return void 0===e&&(e=void 0),this.subruleInternal(t,9,e)},t.prototype.OPTION=function(t){return this.optionInternal(t,0)},t.prototype.OPTION1=function(t){return this.optionInternal(t,1)},t.prototype.OPTION2=function(t){return this.optionInternal(t,2)},t.prototype.OPTION3=function(t){return this.optionInternal(t,3)},t.prototype.OPTION4=function(t){return this.optionInternal(t,4)},t.prototype.OPTION5=function(t){return this.optionInternal(t,5)},t.prototype.OPTION6=function(t){return this.optionInternal(t,6)},t.prototype.OPTION7=function(t){return this.optionInternal(t,7)},t.prototype.OPTION8=function(t){return this.optionInternal(t,8)},t.prototype.OPTION9=function(t){return this.optionInternal(t,9)},t.prototype.OR=function(t){return this.orInternal(t,0)},t.prototype.OR1=function(t){return this.orInternal(t,1)},t.prototype.OR2=function(t){return this.orInternal(t,2)},t.prototype.OR3=function(t){return this.orInternal(t,3)},t.prototype.OR4=function(t){return this.orInternal(t,4)},t.prototype.OR5=function(t){return this.orInternal(t,5)},t.prototype.OR6=function(t){return this.orInternal(t,6)},t.prototype.OR7=function(t){return this.orInternal(t,7)},t.prototype.OR8=function(t){return this.orInternal(t,8)},t.prototype.OR9=function(t){return this.orInternal(t,9)},t.prototype.MANY=function(t){return this.manyInternal(0,t,[])},t.prototype.MANY1=function(t){return this.manyInternal(1,t,[])},t.prototype.MANY2=function(t){return this.manyInternal(2,t,[])},t.prototype.MANY3=function(t){return this.manyInternal(3,t,[])},t.prototype.MANY4=function(t){return this.manyInternal(4,t,[])},t.prototype.MANY5=function(t){return this.manyInternal(5,t,[])},t.prototype.MANY6=function(t){return this.manyInternal(6,t,[])},t.prototype.MANY7=function(t){return this.manyInternal(7,t,[])},t.prototype.MANY8=function(t){return this.manyInternal(8,t,[])},t.prototype.MANY9=function(t){return this.manyInternal(9,t,[])},t.prototype.MANY_SEP=function(t){return this.manySepFirstInternal(0,t,{values:[],separators:[]})},t.prototype.MANY_SEP1=function(t){return this.manySepFirstInternal(1,t,{values:[],separators:[]})},t.prototype.MANY_SEP2=function(t){return this.manySepFirstInternal(2,t,{values:[],separators:[]})},t.prototype.MANY_SEP3=function(t){return this.manySepFirstInternal(3,t,{values:[],separators:[]})},t.prototype.MANY_SEP4=function(t){return this.manySepFirstInternal(4,t,{values:[],separators:[]})},t.prototype.MANY_SEP5=function(t){return this.manySepFirstInternal(5,t,{values:[],separators:[]})},t.prototype.MANY_SEP6=function(t){return this.manySepFirstInternal(6,t,{values:[],separators:[]})},t.prototype.MANY_SEP7=function(t){return this.manySepFirstInternal(7,t,{values:[],separators:[]})},t.prototype.MANY_SEP8=function(t){return this.manySepFirstInternal(8,t,{values:[],separators:[]})},t.prototype.MANY_SEP9=function(t){return this.manySepFirstInternal(9,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE=function(t){return this.atLeastOneInternal(0,t,[])},t.prototype.AT_LEAST_ONE1=function(t){return this.atLeastOneInternal(1,t,[])},t.prototype.AT_LEAST_ONE2=function(t){return this.atLeastOneInternal(2,t,[])},t.prototype.AT_LEAST_ONE3=function(t){return this.atLeastOneInternal(3,t,[])},t.prototype.AT_LEAST_ONE4=function(t){return this.atLeastOneInternal(4,t,[])},t.prototype.AT_LEAST_ONE5=function(t){return this.atLeastOneInternal(5,t,[])},t.prototype.AT_LEAST_ONE6=function(t){return this.atLeastOneInternal(6,t,[])},t.prototype.AT_LEAST_ONE7=function(t){return this.atLeastOneInternal(7,t,[])},t.prototype.AT_LEAST_ONE8=function(t){return this.atLeastOneInternal(8,t,[])},t.prototype.AT_LEAST_ONE9=function(t){return this.atLeastOneInternal(9,t,[])},t.prototype.AT_LEAST_ONE_SEP=function(t){return this.atLeastOneSepFirstInternal(0,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP1=function(t){return this.atLeastOneSepFirstInternal(1,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP2=function(t){return this.atLeastOneSepFirstInternal(2,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP3=function(t){return this.atLeastOneSepFirstInternal(3,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP4=function(t){return this.atLeastOneSepFirstInternal(4,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP5=function(t){return this.atLeastOneSepFirstInternal(5,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP6=function(t){return this.atLeastOneSepFirstInternal(6,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP7=function(t){return this.atLeastOneSepFirstInternal(7,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP8=function(t){return this.atLeastOneSepFirstInternal(8,t,{values:[],separators:[]})},t.prototype.AT_LEAST_ONE_SEP9=function(t){return this.atLeastOneSepFirstInternal(9,t,{values:[],separators:[]})},t.prototype.RULE=function(t,e,n){if(void 0===n&&(n=L),p.contains(this.definedRulesNames,t)){var r=N.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),i={message:r,type:o.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(i)}if(this.definedRulesNames.push(t),this._productions.containsKey(t)){var s=a.getP