UNPKG

chevrotain

Version:

Chevrotain is a high performance fault Tolerant Javascript parsing DSL for building recursive decent parsers

3 lines 103 kB
/*! chevrotain - v0.5.13 - 2016-01-02 */ !function(root,factory){"function"==typeof define&&define.amd?define("chevrotain",["lodash"],function(a0){return root.API=factory(a0)}):"object"==typeof exports?module.exports=factory(require("lodash")):root.chevrotain=factory(_)}(this,function(_){var utils;!function(utils){function isEmpty(arr){return 0===arr.length}function keys(obj){return Object.keys(obj)}function values(obj){for(var vals=[],keys=Object.keys(obj),i=0;i<keys.length;i++)vals.push(obj[keys[i]]);return vals}function map(arr,callback){for(var result=[],idx=0;idx<arr.length;idx++)result.push(callback.call(null,arr[idx],idx));return result}utils.isEmpty=isEmpty,utils.keys=keys,utils.values=values,utils.map=map}(utils||(utils={}));var chevrotain;!function(chevrotain){var lang;!function(lang){function classNameFromInstance(instance){return functionName(instance.constructor)}function functionName(func){if(hasNativeName)return func.name;if(func.rdtFuncNameCache666)return func.rdtFuncNameCache666;var name_1=func.toString().match(nameRegex)[1];return func.rdtFuncNameCache666=name_1,name_1}var nameRegex=/^\s*function\s*(\S*)\s*\(/,hasNativeName="undefined"!=typeof function(){}.name;lang.classNameFromInstance=classNameFromInstance,lang.functionName=functionName;var HashTable=function(){function HashTable(){this._state={}}return HashTable.prototype.keys=function(){return utils.keys(this._state)},HashTable.prototype.values=function(){return utils.values(this._state)},HashTable.prototype.put=function(key,value){this._state[key]=value},HashTable.prototype.putAll=function(other){this._state=_.assign(this._state,other._state)},HashTable.prototype.get=function(key){return this._state[key]},HashTable.prototype.containsKey=function(key){return _.has(this._state,key)},HashTable}();lang.HashTable=HashTable}(lang=chevrotain.lang||(chevrotain.lang={}))}(chevrotain||(chevrotain={}));var chevrotain,__extends=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)};!function(chevrotain){function tokenName(clazz){return _.isString(clazz.tokenName)?clazz.tokenName:lang.functionName(clazz)}function extendToken(tokenName,patternOrParent,parentConstructor){void 0===patternOrParent&&(patternOrParent=void 0),void 0===parentConstructor&&(parentConstructor=Token);var pattern;_.isRegExp(patternOrParent)||patternOrParent===chevrotain.Lexer.SKIPPED||patternOrParent===chevrotain.Lexer.NA?pattern=patternOrParent:_.isFunction(patternOrParent)&&(parentConstructor=patternOrParent,pattern=void 0);var derivedCostructor=function(){parentConstructor.apply(this,arguments)};return _.forOwn(parentConstructor,function(v,k){derivedCostructor[k]=v}),derivedCostructor.tokenName=tokenName,derivedCostructor.prototype=Object.create(parentConstructor.prototype),derivedCostructor.prototype.constructor=derivedCostructor,_.isUndefined(pattern)||(derivedCostructor.PATTERN=pattern),derivedCostructor}var lang=chevrotain.lang;chevrotain.tokenName=tokenName,chevrotain.extendToken=extendToken;var Token=function(){function Token(image,offset,startLine,startColumn,endLine,endColumn){void 0===endLine&&(endLine=startLine),void 0===endColumn&&(endColumn=startColumn+image.length-1),this.image=image,this.offset=offset,this.startLine=startLine,this.startColumn=startColumn,this.endLine=endLine,this.endColumn=endColumn,this.isInsertedInRecovery=!1}return Token}();chevrotain.Token=Token;var VirtualToken=function(_super){function VirtualToken(){_super.call(this,"",-1,-1,-1,-1,-1)}return __extends(VirtualToken,_super),VirtualToken}(Token);chevrotain.VirtualToken=VirtualToken;var EOF=function(_super){function EOF(){_super.apply(this,arguments)}return __extends(EOF,_super),EOF}(VirtualToken);chevrotain.EOF=EOF}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){!function(LexerDefinitionErrorType){LexerDefinitionErrorType[LexerDefinitionErrorType.MISSING_PATTERN=0]="MISSING_PATTERN",LexerDefinitionErrorType[LexerDefinitionErrorType.INVALID_PATTERN=1]="INVALID_PATTERN",LexerDefinitionErrorType[LexerDefinitionErrorType.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",LexerDefinitionErrorType[LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",LexerDefinitionErrorType[LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",LexerDefinitionErrorType[LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND"}(chevrotain.LexerDefinitionErrorType||(chevrotain.LexerDefinitionErrorType={}));var Lexer=(chevrotain.LexerDefinitionErrorType,function(){function Lexer(tokenClasses,deferDefinitionErrorsHandling){if(void 0===deferDefinitionErrorsHandling&&(deferDefinitionErrorsHandling=!1),this.tokenClasses=tokenClasses,this.lexerDefinitionErrors=[],this.lexerDefinitionErrors=chevrotain.validatePatterns(tokenClasses),!utils.isEmpty(this.lexerDefinitionErrors)&&!deferDefinitionErrorsHandling){var allErrMessages=utils.map(this.lexerDefinitionErrors,function(error){return error.message}),allErrMessagesString=allErrMessages.join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+allErrMessagesString)}if(utils.isEmpty(this.lexerDefinitionErrors)){var analyzeResult=chevrotain.analyzeTokenClasses(tokenClasses);this.allPatterns=analyzeResult.allPatterns,this.patternIdxToClass=analyzeResult.patternIdxToClass,this.patternIdxToGroup=analyzeResult.patternIdxToGroup,this.patternIdxToLongerAltIdx=analyzeResult.patternIdxToLongerAltIdx,this.patternIdxToCanLineTerminator=analyzeResult.patternIdxToCanLineTerminator,this.emptyGroups=analyzeResult.emptyGroups}}return Lexer.prototype.tokenize=function(text){var match,i,j,matchAlt,longerAltIdx,matchedImage,imageLength,group,tokClass,newToken,errLength,canMatchedContainLineTerminator,fixForEndingInLT,c,droppedChar,lastLTIdx,errorMessage,lastCharIsLT,orgInput=text,offset=0,matchedTokens=[],errors=[],line=1,column=1,groups=_.clone(this.emptyGroups);if(!utils.isEmpty(this.lexerDefinitionErrors)){var allErrMessages=utils.map(this.lexerDefinitionErrors,function(error){return error.message}),allErrMessagesString=allErrMessages.join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+allErrMessagesString)}for(;text.length>0;){for(match=null,i=0;i<this.allPatterns.length;i++)if(match=this.allPatterns[i].exec(text),null!==match){longerAltIdx=this.patternIdxToLongerAltIdx[i],longerAltIdx&&(matchAlt=this.allPatterns[longerAltIdx].exec(text),matchAlt&&matchAlt[0].length>match[0].length&&(match=matchAlt,i=longerAltIdx));break}if(null!==match){if(matchedImage=match[0],imageLength=matchedImage.length,group=this.patternIdxToGroup[i],void 0!==group&&(tokClass=this.patternIdxToClass[i],newToken=new tokClass(matchedImage,offset,line,column),"default"===group?matchedTokens.push(newToken):groups[group].push(newToken)),text=text.slice(imageLength),offset+=imageLength,column+=imageLength,canMatchedContainLineTerminator=this.patternIdxToCanLineTerminator[i]){var lineTerminatorsInMatch=chevrotain.countLineTerminators(matchedImage);if(0!==lineTerminatorsInMatch){for(line+=lineTerminatorsInMatch,lastLTIdx=imageLength-1;lastLTIdx>=0&&(c=matchedImage.charCodeAt(lastLTIdx),13!==c&&10!==c);)lastLTIdx--;column=imageLength-lastLTIdx,void 0!==group&&(lastCharIsLT=lastLTIdx===imageLength-1,fixForEndingInLT=lastCharIsLT?-1:0,1===lineTerminatorsInMatch&&lastCharIsLT||(newToken.endLine=line+fixForEndingInLT,newToken.endColumn=column-1+-fixForEndingInLT))}}}else{for(var errorStartOffset=offset,errorLine=line,errorColumn=column,foundResyncPoint=!1;!foundResyncPoint&&text.length>0;)for(droppedChar=text.charCodeAt(0),10===droppedChar||13===droppedChar&&(1===text.length||text.length>1&&10!==text.charCodeAt(1))?(line++,column=1):column++,text=text.substr(1),offset++,j=0;j<this.allPatterns.length&&!(foundResyncPoint=this.allPatterns[j].test(text));j++);errLength=offset-errorStartOffset,errorMessage="unexpected character: ->"+orgInput.charAt(errorStartOffset)+"<- at offset: "+errorStartOffset+","+(" skipped "+(offset-errorStartOffset)+" characters."),errors.push({line:errorLine,column:errorColumn,length:errLength,message:errorMessage})}}return{tokens:matchedTokens,groups:groups,errors:errors}},Lexer.SKIPPED={description:"This marks a skipped Token pattern, this means each token identified by it willbe consumed and then throw into oblivion, this can be used to for example: skip whitespace."},Lexer.NA=/NOT_APPLICABLE/,Lexer}());chevrotain.Lexer=Lexer}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){function analyzeTokenClasses(tokenClasses){var onlyRelevantClasses=_.reject(tokenClasses,function(currClass){return currClass[PATTERN]===chevrotain.Lexer.NA}),allTransformedPatterns=utils.map(onlyRelevantClasses,function(currClass){return addStartOfInput(currClass[PATTERN])}),allPatternsToClass=_.zipObject(allTransformedPatterns,onlyRelevantClasses),patternIdxToClass=utils.map(allTransformedPatterns,function(pattern){return allPatternsToClass[pattern.toString()]}),patternIdxToGroup=utils.map(onlyRelevantClasses,function(clazz){var groupName=clazz.GROUP;if(groupName!==chevrotain.Lexer.SKIPPED){if(_.isString(groupName))return groupName;if(_.isUndefined(groupName))return"default";throw Error("non exhaustive match")}}),patternIdxToLongerAltIdx=utils.map(onlyRelevantClasses,function(clazz){var longerAltClass=clazz.LONGER_ALT;if(longerAltClass){var longerAltIdx=_.indexOf(onlyRelevantClasses,longerAltClass);return longerAltIdx}}),patternIdxToCanLineTerminator=utils.map(allTransformedPatterns,function(pattern){return/\\n|\\r|\\s/g.test(pattern.source)}),emptyGroups=_.reduce(onlyRelevantClasses,function(acc,clazz){var groupName=clazz.GROUP;return _.isString(groupName)&&(acc[groupName]=[]),acc},{});return{allPatterns:allTransformedPatterns,patternIdxToClass:patternIdxToClass,patternIdxToGroup:patternIdxToGroup,patternIdxToLongerAltIdx:patternIdxToLongerAltIdx,patternIdxToCanLineTerminator:patternIdxToCanLineTerminator,emptyGroups:emptyGroups}}function validatePatterns(tokenClasses){var errors=[],missingResult=findMissingPatterns(tokenClasses),validTokenClasses=missingResult.validTokenClasses;errors=errors.concat(missingResult.errors);var invalidResult=findInvalidPatterns(validTokenClasses);return validTokenClasses=invalidResult.validTokenClasses,errors=errors.concat(invalidResult.errors),errors=errors.concat(findEndOfInputAnchor(validTokenClasses)),errors=errors.concat(findUnsupportedFlags(validTokenClasses)),errors=errors.concat(findDuplicatePatterns(validTokenClasses)),errors=errors.concat(findInvalidGroupType(validTokenClasses))}function findMissingPatterns(tokenClasses){var tokenClassesWithMissingPattern=_.filter(tokenClasses,function(currClass){return!_.has(currClass,PATTERN)}),errors=utils.map(tokenClassesWithMissingPattern,function(currClass){return{message:"Token class: ->"+chevrotain.tokenName(currClass)+"<- missing static 'PATTERN' property",type:chevrotain.LexerDefinitionErrorType.MISSING_PATTERN,tokenClasses:[currClass]}}),validTokenClasses=_.difference(tokenClasses,tokenClassesWithMissingPattern);return{errors:errors,validTokenClasses:validTokenClasses}}function findInvalidPatterns(tokenClasses){var tokenClassesWithInvalidPattern=_.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return!_.isRegExp(pattern)}),errors=utils.map(tokenClassesWithInvalidPattern,function(currClass){return{message:"Token class: ->"+chevrotain.tokenName(currClass)+"<- static 'PATTERN' can only be a RegExp",type:chevrotain.LexerDefinitionErrorType.INVALID_PATTERN,tokenClasses:[currClass]}}),validTokenClasses=_.difference(tokenClasses,tokenClassesWithInvalidPattern);return{errors:errors,validTokenClasses:validTokenClasses}}function findEndOfInputAnchor(tokenClasses){var invalidRegex=_.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return end_of_input.test(pattern.source)}),errors=utils.map(invalidRegex,function(currClass){return{message:"Token class: ->"+chevrotain.tokenName(currClass)+"<- static 'PATTERN' cannot contain end of input anchor '$'",type:chevrotain.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenClasses:[currClass]}});return errors}function findUnsupportedFlags(tokenClasses){var invalidFlags=_.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return pattern instanceof RegExp&&(pattern.multiline||pattern.global)}),errors=utils.map(invalidFlags,function(currClass){return{message:"Token class: ->"+chevrotain.tokenName(currClass)+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:chevrotain.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenClasses:[currClass]}});return errors}function findDuplicatePatterns(tokenClasses){var found=[],identicalPatterns=utils.map(tokenClasses,function(outerClass){return _.reduce(tokenClasses,function(result,innerClass){return outerClass.PATTERN.source!==innerClass.PATTERN.source||_.contains(found,innerClass)||innerClass.PATTERN===chevrotain.Lexer.NA?result:(found.push(innerClass),_.union(result,[innerClass]))},[])});identicalPatterns=_.compact(identicalPatterns);var duplicatePatterns=_.filter(identicalPatterns,function(currIdenticalSet){return _.size(currIdenticalSet)>1}),errors=utils.map(duplicatePatterns,function(setOfIdentical){var classNames=utils.map(setOfIdentical,function(currClass){return chevrotain.tokenName(currClass)}),dupPatternSrc=_.first(setOfIdentical).PATTERN;return{message:"The same RegExp pattern ->"+dupPatternSrc+"<-"+("has been used in all the following classes: "+classNames.join(", ")+" <-"),type:chevrotain.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenClasses:setOfIdentical}});return errors}function findInvalidGroupType(tokenClasses){var invalidTypes=_.filter(tokenClasses,function(clazz){if(!_.has(clazz,"GROUP"))return!1;var group=clazz.GROUP;return group!==chevrotain.Lexer.SKIPPED&&group!==chevrotain.Lexer.NA&&!_.isString(group)}),errors=utils.map(invalidTypes,function(currClass){return{message:"Token class: ->"+chevrotain.tokenName(currClass)+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:chevrotain.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenClasses:[currClass]}});return errors}function addStartOfInput(pattern){var flags=pattern.ignoreCase?"i":"";return new RegExp("^(?:"+pattern.source+")",flags)}function countLineTerminators(text){for(var lineTerminators=0,currOffset=0;currOffset<text.length;){var c=text.charCodeAt(currOffset);10===c?lineTerminators++:13===c&&(currOffset!==text.length-1&&10===text.charCodeAt(currOffset+1)||lineTerminators++),currOffset++}return lineTerminators}var PATTERN="PATTERN";chevrotain.analyzeTokenClasses=analyzeTokenClasses,chevrotain.validatePatterns=validatePatterns,chevrotain.findMissingPatterns=findMissingPatterns,chevrotain.findInvalidPatterns=findInvalidPatterns;var end_of_input=/[^\\][\$]/;chevrotain.findEndOfInputAnchor=findEndOfInputAnchor,chevrotain.findUnsupportedFlags=findUnsupportedFlags,chevrotain.findDuplicatePatterns=findDuplicatePatterns,chevrotain.findInvalidGroupType=findInvalidGroupType,chevrotain.addStartOfInput=addStartOfInput,chevrotain.countLineTerminators=countLineTerminators}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var range;!function(range){function isValidRange(start,end){return!(0>start||start>end)}var Range=function(){function Range(start,end){if(this.start=start,this.end=end,!isValidRange(start,end))throw new Error("INVALID RANGE")}return Range.prototype.contains=function(num){return this.start<=num&&this.end>=num},Range.prototype.containsRange=function(other){return this.start<=other.start&&this.end>=other.end},Range.prototype.isContainedInRange=function(other){return other.containsRange(this)},Range.prototype.strictlyContainsRange=function(other){return this.start<other.start&&this.end>other.end},Range.prototype.isStrictlyContainedInRange=function(other){return other.strictlyContainsRange(this)},Range}();range.Range=Range,range.isValidRange=isValidRange}(range=chevrotain.range||(chevrotain.range={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var constants;!function(constants){constants.IN="_~IN~_"}(constants=chevrotain.constants||(chevrotain.constants={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var gast;!function(gast){var AbstractProduction=function(){function AbstractProduction(definition){this.definition=definition,this.implicitOccurrenceIndex=!1}return AbstractProduction.prototype.accept=function(visitor){visitor.visit(this),_.forEach(this.definition,function(prod){prod.accept(visitor)})},AbstractProduction}();gast.AbstractProduction=AbstractProduction;var NonTerminal=function(_super){function NonTerminal(nonTerminalName,referencedRule,occurrenceInParent){void 0===referencedRule&&(referencedRule=void 0),void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,[]),this.nonTerminalName=nonTerminalName,this.referencedRule=referencedRule,this.occurrenceInParent=occurrenceInParent}return __extends(NonTerminal,_super),Object.defineProperty(NonTerminal.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(definition){},enumerable:!0,configurable:!0}),NonTerminal.prototype.accept=function(visitor){visitor.visit(this)},NonTerminal}(AbstractProduction);gast.NonTerminal=NonTerminal;var Rule=function(_super){function Rule(name,definition,orgText){void 0===orgText&&(orgText=""),_super.call(this,definition),this.name=name,this.orgText=orgText}return __extends(Rule,_super),Rule}(AbstractProduction);gast.Rule=Rule;var Flat=function(_super){function Flat(definition){_super.call(this,definition)}return __extends(Flat,_super),Flat}(AbstractProduction);gast.Flat=Flat;var Option=function(_super){function Option(definition,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.occurrenceInParent=occurrenceInParent}return __extends(Option,_super),Option}(AbstractProduction);gast.Option=Option;var RepetitionMandatory=function(_super){function RepetitionMandatory(definition,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.occurrenceInParent=occurrenceInParent}return __extends(RepetitionMandatory,_super),RepetitionMandatory}(AbstractProduction);gast.RepetitionMandatory=RepetitionMandatory;var RepetitionMandatoryWithSeparator=function(_super){function RepetitionMandatoryWithSeparator(definition,separator,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.separator=separator,this.occurrenceInParent=occurrenceInParent}return __extends(RepetitionMandatoryWithSeparator,_super),RepetitionMandatoryWithSeparator}(AbstractProduction);gast.RepetitionMandatoryWithSeparator=RepetitionMandatoryWithSeparator;var Repetition=function(_super){function Repetition(definition,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.occurrenceInParent=occurrenceInParent}return __extends(Repetition,_super),Repetition}(AbstractProduction);gast.Repetition=Repetition;var RepetitionWithSeparator=function(_super){function RepetitionWithSeparator(definition,separator,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.separator=separator,this.occurrenceInParent=occurrenceInParent}return __extends(RepetitionWithSeparator,_super),RepetitionWithSeparator}(AbstractProduction);gast.RepetitionWithSeparator=RepetitionWithSeparator;var Alternation=function(_super){function Alternation(definition,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),_super.call(this,definition),this.occurrenceInParent=occurrenceInParent}return __extends(Alternation,_super),Alternation}(AbstractProduction);gast.Alternation=Alternation;var Terminal=function(){function Terminal(terminalType,occurrenceInParent){void 0===occurrenceInParent&&(occurrenceInParent=1),this.terminalType=terminalType,this.occurrenceInParent=occurrenceInParent,this.implicitOccurrenceIndex=!1}return Terminal.prototype.accept=function(visitor){visitor.visit(this)},Terminal}();gast.Terminal=Terminal;var GAstVisitor=function(){function GAstVisitor(){}return GAstVisitor.prototype.visit=function(node){node instanceof NonTerminal?this.visitNonTerminal(node):node instanceof Flat?this.visitFlat(node):node instanceof Option?this.visitOption(node):node instanceof RepetitionMandatory?this.visitRepetitionMandatory(node):node instanceof RepetitionMandatoryWithSeparator?this.visitRepetitionMandatoryWithSeparator(node):node instanceof RepetitionWithSeparator?this.visitRepetitionWithSeparator(node):node instanceof Repetition?this.visitRepetition(node):node instanceof Alternation?this.visitAlternation(node):node instanceof Terminal&&this.visitTerminal(node)},GAstVisitor.prototype.visitNonTerminal=function(node){},GAstVisitor.prototype.visitFlat=function(node){},GAstVisitor.prototype.visitOption=function(node){},GAstVisitor.prototype.visitRepetition=function(node){},GAstVisitor.prototype.visitRepetitionMandatory=function(node){},GAstVisitor.prototype.visitRepetitionMandatoryWithSeparator=function(node){},GAstVisitor.prototype.visitRepetitionWithSeparator=function(node){},GAstVisitor.prototype.visitAlternation=function(node){},GAstVisitor.prototype.visitTerminal=function(node){},GAstVisitor}();gast.GAstVisitor=GAstVisitor}(gast=chevrotain.gast||(chevrotain.gast={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var gast;!function(gast){function isSequenceProd(prod){return prod instanceof gast.Flat||prod instanceof gast.Option||prod instanceof gast.Repetition||prod instanceof gast.RepetitionMandatory||prod instanceof gast.RepetitionMandatoryWithSeparator||prod instanceof gast.RepetitionWithSeparator||prod instanceof gast.Terminal||prod instanceof gast.Rule}function isOptionalProd(prod,alreadyVisited){void 0===alreadyVisited&&(alreadyVisited=[]);var isDirectlyOptional=prod instanceof gast.Option||prod instanceof gast.Repetition||prod instanceof gast.RepetitionWithSeparator;return isDirectlyOptional?!0:prod instanceof gast.Alternation?_.some(prod.definition,function(subProd){return isOptionalProd(subProd,alreadyVisited)}):prod instanceof gast.NonTerminal&&_.contains(alreadyVisited,prod)?!1:prod instanceof gast.AbstractProduction?(prod instanceof gast.NonTerminal&&alreadyVisited.push(prod),_.every(prod.definition,function(subProd){return isOptionalProd(subProd,alreadyVisited)})):!1}function isBranchingProd(prod){return prod instanceof gast.Alternation}function getProductionDslName(prod){var clazz=prod.constructor,prodName=lang.functionName(clazz);return productionToDslName[prodName]}var lang=chevrotain.lang;gast.isSequenceProd=isSequenceProd,gast.isOptionalProd=isOptionalProd,gast.isBranchingProd=isBranchingProd;var productionToDslName={};productionToDslName[lang.functionName(gast.NonTerminal)]="SUBRULE",productionToDslName[lang.functionName(gast.Option)]="OPTION",productionToDslName[lang.functionName(gast.RepetitionMandatory)]="AT_LEAST_ONE",productionToDslName[lang.functionName(gast.RepetitionMandatoryWithSeparator)]="AT_LEAST_ONE_SEP",productionToDslName[lang.functionName(gast.RepetitionWithSeparator)]="MANY_SEP",productionToDslName[lang.functionName(gast.Repetition)]="MANY",productionToDslName[lang.functionName(gast.Alternation)]="OR",productionToDslName[lang.functionName(gast.Terminal)]="CONSUME",gast.getProductionDslName=getProductionDslName}(gast=chevrotain.gast||(chevrotain.gast={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var first;!function(first_1){function first(prod){if(prod instanceof gast.NonTerminal)return first(prod.referencedRule);if(prod instanceof gast.Terminal)return firstForTerminal(prod);if(gast.isSequenceProd(prod))return firstForSequence(prod);if(gast.isBranchingProd(prod))return firstForBranching(prod);throw Error("non exhaustive match")}function firstForSequence(prod){for(var currSubProd,firstSet=[],seq=prod.definition,nextSubProdIdx=0,hasInnerProdsRemaining=seq.length>nextSubProdIdx,isLastInnerProdOptional=!0;hasInnerProdsRemaining&&isLastInnerProdOptional;)currSubProd=seq[nextSubProdIdx],isLastInnerProdOptional=gast.isOptionalProd(currSubProd),firstSet=firstSet.concat(first(currSubProd)),nextSubProdIdx+=1,hasInnerProdsRemaining=seq.length>nextSubProdIdx;return _.uniq(firstSet)}function firstForBranching(prod){var allAlternativesFirsts=utils.map(prod.definition,function(innerProd){return first(innerProd)});return _.uniq(_.flatten(allAlternativesFirsts))}function firstForTerminal(terminal){return[terminal.terminalType]}var gast=chevrotain.gast;first_1.first=first,first_1.firstForSequence=firstForSequence,first_1.firstForBranching=firstForBranching,first_1.firstForTerminal=firstForTerminal}(first=chevrotain.first||(chevrotain.first={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var rest;!function(rest){function restForRepetitionWithSeparator(repSepProd,currRest,prevRest){var repSepRest=[new g.Option([new g.Terminal(repSepProd.separator)].concat(repSepProd.definition))],fullRepSepRest=repSepRest.concat(currRest,prevRest);return fullRepSepRest}var g=chevrotain.gast,RestWalker=function(){function RestWalker(){}return RestWalker.prototype.walk=function(prod,prevRest){var _this=this;void 0===prevRest&&(prevRest=[]),_.forEach(prod.definition,function(subProd,index){var currRest=_.drop(prod.definition,index+1);if(subProd instanceof g.NonTerminal)_this.walkProdRef(subProd,currRest,prevRest);else if(subProd instanceof g.Terminal)_this.walkTerminal(subProd,currRest,prevRest);else if(subProd instanceof g.Flat)_this.walkFlat(subProd,currRest,prevRest);else if(subProd instanceof g.Option)_this.walkOption(subProd,currRest,prevRest);else if(subProd instanceof g.RepetitionMandatory)_this.walkAtLeastOne(subProd,currRest,prevRest);else if(subProd instanceof g.RepetitionMandatoryWithSeparator)_this.walkAtLeastOneSep(subProd,currRest,prevRest);else if(subProd instanceof g.RepetitionWithSeparator)_this.walkManySep(subProd,currRest,prevRest);else if(subProd instanceof g.Repetition)_this.walkMany(subProd,currRest,prevRest);else{if(!(subProd instanceof g.Alternation))throw Error("non exhaustive match");_this.walkOr(subProd,currRest,prevRest)}})},RestWalker.prototype.walkTerminal=function(terminal,currRest,prevRest){},RestWalker.prototype.walkProdRef=function(refProd,currRest,prevRest){},RestWalker.prototype.walkFlat=function(flatProd,currRest,prevRest){var fullOrRest=currRest.concat(prevRest);this.walk(flatProd,fullOrRest)},RestWalker.prototype.walkOption=function(optionProd,currRest,prevRest){var fullOrRest=currRest.concat(prevRest);this.walk(optionProd,fullOrRest)},RestWalker.prototype.walkAtLeastOne=function(atLeastOneProd,currRest,prevRest){var fullAtLeastOneRest=[new g.Option(atLeastOneProd.definition)].concat(currRest,prevRest);this.walk(atLeastOneProd,fullAtLeastOneRest)},RestWalker.prototype.walkAtLeastOneSep=function(atLeastOneSepProd,currRest,prevRest){var fullAtLeastOneSepRest=restForRepetitionWithSeparator(atLeastOneSepProd,currRest,prevRest);this.walk(atLeastOneSepProd,fullAtLeastOneSepRest)},RestWalker.prototype.walkMany=function(manyProd,currRest,prevRest){var fullManyRest=[new g.Option(manyProd.definition)].concat(currRest,prevRest);this.walk(manyProd,fullManyRest)},RestWalker.prototype.walkManySep=function(manySepProd,currRest,prevRest){var fullManySepRest=restForRepetitionWithSeparator(manySepProd,currRest,prevRest);this.walk(manySepProd,fullManySepRest)},RestWalker.prototype.walkOr=function(orProd,currRest,prevRest){var _this=this,fullOrRest=currRest.concat(prevRest);_.forEach(orProd.definition,function(alt){var prodWrapper=new chevrotain.gast.Flat([alt]);_this.walk(prodWrapper,fullOrRest)})},RestWalker}();rest.RestWalker=RestWalker}(rest=chevrotain.rest||(chevrotain.rest={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var follow;!function(follow){function computeAllProdsFollows(topProductions){var reSyncFollows=new lang.HashTable;return _.forEach(topProductions,function(topProd){var currRefsFollow=new ResyncFollowsWalker(topProd).startWalking();reSyncFollows.putAll(currRefsFollow)}),reSyncFollows}function buildBetweenProdsFollowPrefix(inner,occurenceInParent){return inner.name+occurenceInParent+IN}function buildInProdFollowPrefix(terminal){var terminalName=chevrotain.tokenName(terminal.terminalType);return terminalName+terminal.occurrenceInParent+IN}var g=chevrotain.gast,r=chevrotain.rest,f=chevrotain.first,IN=chevrotain.constants.IN,lang=chevrotain.lang,ResyncFollowsWalker=function(_super){function ResyncFollowsWalker(topProd){_super.call(this),this.topProd=topProd,this.follows=new lang.HashTable}return __extends(ResyncFollowsWalker,_super),ResyncFollowsWalker.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},ResyncFollowsWalker.prototype.walkTerminal=function(terminal,currRest,prevRest){},ResyncFollowsWalker.prototype.walkProdRef=function(refProd,currRest,prevRest){var followName=buildBetweenProdsFollowPrefix(refProd.referencedRule,refProd.occurrenceInParent)+this.topProd.name,fullRest=currRest.concat(prevRest),restProd=new g.Flat(fullRest),t_in_topProd_follows=f.first(restProd);this.follows.put(followName,t_in_topProd_follows)},ResyncFollowsWalker}(r.RestWalker);follow.ResyncFollowsWalker=ResyncFollowsWalker,follow.computeAllProdsFollows=computeAllProdsFollows,follow.buildBetweenProdsFollowPrefix=buildBetweenProdsFollowPrefix,follow.buildInProdFollowPrefix=buildInProdFollowPrefix}(follow=chevrotain.follow||(chevrotain.follow={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var interpreter;!function(interpreter){var g=chevrotain.gast,f=chevrotain.first,r=chevrotain.rest,AbstractNextPossibleTokensWalker=function(_super){function AbstractNextPossibleTokensWalker(topProd,path){_super.call(this),this.topProd=topProd,this.path=path,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}return __extends(AbstractNextPossibleTokensWalker,_super),AbstractNextPossibleTokensWalker.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=_.clone(this.path.ruleStack).reverse(),this.occurrenceStack=_.clone(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},AbstractNextPossibleTokensWalker.prototype.walk=function(prod,prevRest){void 0===prevRest&&(prevRest=[]),this.found||_super.prototype.walk.call(this,prod,prevRest)},AbstractNextPossibleTokensWalker.prototype.walkProdRef=function(refProd,currRest,prevRest){if(refProd.referencedRule.name===this.nextProductionName&&refProd.occurrenceInParent===this.nextProductionOccurrence){var fullRest=currRest.concat(prevRest);this.updateExpectedNext(),this.walk(refProd.referencedRule,fullRest)}},AbstractNextPossibleTokensWalker.prototype.updateExpectedNext=function(){utils.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},AbstractNextPossibleTokensWalker}(r.RestWalker);interpreter.AbstractNextPossibleTokensWalker=AbstractNextPossibleTokensWalker;var NextAfterTokenWalker=function(_super){function NextAfterTokenWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=chevrotain.tokenName(this.path.lastTok),this.nextTerminalOccurrence=this.path.lastTokOccurrence}return __extends(NextAfterTokenWalker,_super),NextAfterTokenWalker.prototype.walkTerminal=function(terminal,currRest,prevRest){ if(this.isAtEndOfPath&&chevrotain.tokenName(terminal.terminalType)===this.nextTerminalName&&terminal.occurrenceInParent===this.nextTerminalOccurrence&&!this.found){var fullRest=currRest.concat(prevRest),restProd=new g.Flat(fullRest);this.possibleTokTypes=f.first(restProd),this.found=!0}},NextAfterTokenWalker}(AbstractNextPossibleTokensWalker);interpreter.NextAfterTokenWalker=NextAfterTokenWalker;var NextInsideOptionWalker=function(_super){function NextInsideOptionWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextOptionOccurrence=0,this.nextOptionOccurrence=this.path.occurrence}return __extends(NextInsideOptionWalker,_super),NextInsideOptionWalker.prototype.walkOption=function(optionProd,currRest,prevRest){if(this.isAtEndOfPath&&optionProd.occurrenceInParent===this.nextOptionOccurrence&&!this.found){var restProd=new g.Flat(optionProd.definition);this.possibleTokTypes=f.first(restProd),this.found=!0}else _super.prototype.walkOption.call(this,optionProd,currRest,prevRest)},NextInsideOptionWalker}(AbstractNextPossibleTokensWalker);interpreter.NextInsideOptionWalker=NextInsideOptionWalker;var NextInsideManyWalker=function(_super){function NextInsideManyWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextOccurrence=0,this.nextOccurrence=this.path.occurrence}return __extends(NextInsideManyWalker,_super),NextInsideManyWalker.prototype.walkMany=function(manyProd,currRest,prevRest){if(this.isAtEndOfPath&&manyProd.occurrenceInParent===this.nextOccurrence&&!this.found){var restProd=new g.Flat(manyProd.definition);this.possibleTokTypes=f.first(restProd),this.found=!0}else _super.prototype.walkMany.call(this,manyProd,currRest,prevRest)},NextInsideManyWalker}(AbstractNextPossibleTokensWalker);interpreter.NextInsideManyWalker=NextInsideManyWalker;var NextInsideManySepWalker=function(_super){function NextInsideManySepWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextOccurrence=0,this.nextOccurrence=this.path.occurrence}return __extends(NextInsideManySepWalker,_super),NextInsideManySepWalker.prototype.walkManySep=function(manySepProd,currRest,prevRest){if(this.isAtEndOfPath&&manySepProd.occurrenceInParent===this.nextOccurrence&&!this.found){var restProd=new g.Flat(manySepProd.definition);this.possibleTokTypes=f.first(restProd),this.found=!0}else _super.prototype.walkManySep.call(this,manySepProd,currRest,prevRest)},NextInsideManySepWalker}(AbstractNextPossibleTokensWalker);interpreter.NextInsideManySepWalker=NextInsideManySepWalker;var NextInsideAtLeastOneWalker=function(_super){function NextInsideAtLeastOneWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextOccurrence=0,this.nextOccurrence=this.path.occurrence}return __extends(NextInsideAtLeastOneWalker,_super),NextInsideAtLeastOneWalker.prototype.walkAtLeastOne=function(atLeastOneProd,currRest,prevRest){if(this.isAtEndOfPath&&atLeastOneProd.occurrenceInParent===this.nextOccurrence&&!this.found){var restProd=new g.Flat(atLeastOneProd.definition);this.possibleTokTypes=f.first(restProd),this.found=!0}else _super.prototype.walkAtLeastOne.call(this,atLeastOneProd,currRest,prevRest)},NextInsideAtLeastOneWalker}(AbstractNextPossibleTokensWalker);interpreter.NextInsideAtLeastOneWalker=NextInsideAtLeastOneWalker;var NextInsideAtLeastOneSepWalker=function(_super){function NextInsideAtLeastOneSepWalker(topProd,path){_super.call(this,topProd,path),this.path=path,this.nextOccurrence=0,this.nextOccurrence=this.path.occurrence}return __extends(NextInsideAtLeastOneSepWalker,_super),NextInsideAtLeastOneSepWalker.prototype.walkAtLeastOneSep=function(atLeastOneSepProd,currRest,prevRest){if(this.isAtEndOfPath&&atLeastOneSepProd.occurrenceInParent===this.nextOccurrence&&!this.found){var restProd=new g.Flat(atLeastOneSepProd.definition);this.possibleTokTypes=f.first(restProd),this.found=!0}else _super.prototype.walkAtLeastOneSep.call(this,atLeastOneSepProd,currRest,prevRest)},NextInsideAtLeastOneSepWalker}(AbstractNextPossibleTokensWalker);interpreter.NextInsideAtLeastOneSepWalker=NextInsideAtLeastOneSepWalker;var NextInsideOrWalker=function(_super){function NextInsideOrWalker(topRule,occurrence){_super.call(this),this.topRule=topRule,this.occurrence=occurrence,this.result=[]}return __extends(NextInsideOrWalker,_super),NextInsideOrWalker.prototype.startWalking=function(){return this.walk(this.topRule),this.result},NextInsideOrWalker.prototype.walkOr=function(orProd,currRest,prevRest){orProd.occurrenceInParent===this.occurrence?this.result=utils.map(orProd.definition,function(alt){var altWrapper=new chevrotain.gast.Flat([alt]);return f.first(altWrapper)}):_super.prototype.walkOr.call(this,orProd,currRest,prevRest)},NextInsideOrWalker}(r.RestWalker);interpreter.NextInsideOrWalker=NextInsideOrWalker;var AbstractNextTerminalAfterProductionWalker=function(_super){function AbstractNextTerminalAfterProductionWalker(topRule,occurrence){_super.call(this),this.topRule=topRule,this.occurrence=occurrence,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}return __extends(AbstractNextTerminalAfterProductionWalker,_super),AbstractNextTerminalAfterProductionWalker.prototype.startWalking=function(){return this.walk(this.topRule),this.result},AbstractNextTerminalAfterProductionWalker}(r.RestWalker);interpreter.AbstractNextTerminalAfterProductionWalker=AbstractNextTerminalAfterProductionWalker;var NextTerminalAfterManyWalker=function(_super){function NextTerminalAfterManyWalker(){_super.apply(this,arguments)}return __extends(NextTerminalAfterManyWalker,_super),NextTerminalAfterManyWalker.prototype.walkMany=function(manyProd,currRest,prevRest){if(manyProd.occurrenceInParent===this.occurrence){var firstAfterMany=_.first(currRest.concat(prevRest));this.result.isEndOfRule=void 0===firstAfterMany,firstAfterMany instanceof chevrotain.gast.Terminal&&(this.result.token=firstAfterMany.terminalType,this.result.occurrence=firstAfterMany.occurrenceInParent)}else _super.prototype.walkMany.call(this,manyProd,currRest,prevRest)},NextTerminalAfterManyWalker}(AbstractNextTerminalAfterProductionWalker);interpreter.NextTerminalAfterManyWalker=NextTerminalAfterManyWalker;var NextTerminalAfterManySepWalker=function(_super){function NextTerminalAfterManySepWalker(){_super.apply(this,arguments)}return __extends(NextTerminalAfterManySepWalker,_super),NextTerminalAfterManySepWalker.prototype.walkManySep=function(manySepProd,currRest,prevRest){if(manySepProd.occurrenceInParent===this.occurrence){var firstAfterManySep=_.first(currRest.concat(prevRest));this.result.isEndOfRule=void 0===firstAfterManySep,firstAfterManySep instanceof chevrotain.gast.Terminal&&(this.result.token=firstAfterManySep.terminalType,this.result.occurrence=firstAfterManySep.occurrenceInParent)}else _super.prototype.walkManySep.call(this,manySepProd,currRest,prevRest)},NextTerminalAfterManySepWalker}(AbstractNextTerminalAfterProductionWalker);interpreter.NextTerminalAfterManySepWalker=NextTerminalAfterManySepWalker;var NextTerminalAfterAtLeastOneWalker=function(_super){function NextTerminalAfterAtLeastOneWalker(){_super.apply(this,arguments)}return __extends(NextTerminalAfterAtLeastOneWalker,_super),NextTerminalAfterAtLeastOneWalker.prototype.walkAtLeastOne=function(atLeastOneProd,currRest,prevRest){if(atLeastOneProd.occurrenceInParent===this.occurrence){var firstAfterAtLeastOne=_.first(currRest.concat(prevRest));this.result.isEndOfRule=void 0===firstAfterAtLeastOne,firstAfterAtLeastOne instanceof chevrotain.gast.Terminal&&(this.result.token=firstAfterAtLeastOne.terminalType,this.result.occurrence=firstAfterAtLeastOne.occurrenceInParent)}else _super.prototype.walkAtLeastOne.call(this,atLeastOneProd,currRest,prevRest)},NextTerminalAfterAtLeastOneWalker}(AbstractNextTerminalAfterProductionWalker);interpreter.NextTerminalAfterAtLeastOneWalker=NextTerminalAfterAtLeastOneWalker;var NextTerminalAfterAtLeastOneSepWalker=function(_super){function NextTerminalAfterAtLeastOneSepWalker(){_super.apply(this,arguments)}return __extends(NextTerminalAfterAtLeastOneSepWalker,_super),NextTerminalAfterAtLeastOneSepWalker.prototype.walkAtLeastOneSep=function(atleastOneSepProd,currRest,prevRest){if(atleastOneSepProd.occurrenceInParent===this.occurrence){var firstAfterfirstAfterAtLeastOneSep=_.first(currRest.concat(prevRest));this.result.isEndOfRule=void 0===firstAfterfirstAfterAtLeastOneSep,firstAfterfirstAfterAtLeastOneSep instanceof chevrotain.gast.Terminal&&(this.result.token=firstAfterfirstAfterAtLeastOneSep.terminalType,this.result.occurrence=firstAfterfirstAfterAtLeastOneSep.occurrenceInParent)}else _super.prototype.walkAtLeastOneSep.call(this,atleastOneSepProd,currRest,prevRest)},NextTerminalAfterAtLeastOneSepWalker}(AbstractNextTerminalAfterProductionWalker);interpreter.NextTerminalAfterAtLeastOneSepWalker=NextTerminalAfterAtLeastOneSepWalker}(interpreter=chevrotain.interpreter||(chevrotain.interpreter={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var cache;!function(cache){function getProductionsForClass(className){return getFromNestedHashTable(className,cache.CLASS_TO_GRAMMAR_PRODUCTIONS)}function getResyncFollowsForClass(className){return getFromNestedHashTable(className,cache.CLASS_TO_RESYNC_FOLLOW_SETS)}function setResyncFollowsForClass(className,followSet){cache.CLASS_TO_RESYNC_FOLLOW_SETS.put(className,followSet)}function getLookaheadFuncsForClass(className){return getFromNestedHashTable(className,cache.CLASS_TO_LOOKAHEAD_FUNCS)}function getFirstAfterRepForClass(className){return getFromNestedHashTable(className,cache.CLASS_TO_FIRST_AFTER_REPETITION)}function initLookAheadKeyCache(className){cache.CLASS_TO_OR_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),cache.CLASS_TO_MANY_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),cache.CLASS_TO_MANY_SEP_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),cache.CLASS_TO_AT_LEAST_ONE_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),cache.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),cache.CLASS_TO_OPTION_LA_CACHE[className]=new Array(cache.MAX_OCCURRENCE_INDEX),initSingleLookAheadKeyCache(cache.CLASS_TO_OR_LA_CACHE[className]),initSingleLookAheadKeyCache(cache.CLASS_TO_MANY_LA_CACHE[className]),initSingleLookAheadKeyCache(cache.CLASS_TO_MANY_SEP_LA_CACHE[className]),initSingleLookAheadKeyCache(cache.CLASS_TO_AT_LEAST_ONE_LA_CACHE[className]),initSingleLookAheadKeyCache(cache.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[className]),initSingleLookAheadKeyCache(cache.CLASS_TO_OPTION_LA_CACHE[className])}function initSingleLookAheadKeyCache(laCache){for(var i=0;i<cache.MAX_OCCURRENCE_INDEX;i++)laCache[i]=new chevrotain.lang.HashTable}function getFromNestedHashTable(className,hashTable){var result=hashTable.get(className);return void 0===result&&(hashTable.put(className,new chevrotain.lang.HashTable),result=hashTable.get(className)),result}cache.CLASS_TO_DEFINITION_ERRORS=new chevrotain.lang.HashTable,cache.CLASS_TO_SELF_ANALYSIS_DONE=new chevrotain.lang.HashTable,cache.CLASS_TO_GRAMMAR_PRODUCTIONS=new chevrotain.lang.HashTable,cache.getProductionsForClass=getProductionsForClass,cache.CLASS_TO_RESYNC_FOLLOW_SETS=new chevrotain.lang.HashTable,cache.getResyncFollowsForClass=getResyncFollowsForClass,cache.setResyncFollowsForClass=setResyncFollowsForClass,cache.CLASS_TO_LOOKAHEAD_FUNCS=new chevrotain.lang.HashTable,cache.getLookaheadFuncsForClass=getLookaheadFuncsForClass,cache.CLASS_TO_FIRST_AFTER_REPETITION=new chevrotain.lang.HashTable,cache.getFirstAfterRepForClass=getFirstAfterRepForClass,cache.CLASS_TO_OR_LA_CACHE=new chevrotain.lang.HashTable,cache.CLASS_TO_MANY_LA_CACHE=new chevrotain.lang.HashTable,cache.CLASS_TO_MANY_SEP_LA_CACHE=new chevrotain.lang.HashTable,cache.CLASS_TO_AT_LEAST_ONE_LA_CACHE=new chevrotain.lang.HashTable,cache.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE=new chevrotain.lang.HashTable,cache.CLASS_TO_OPTION_LA_CACHE=new chevrotain.lang.HashTable,cache.MAX_OCCURRENCE_INDEX=5,cache.initLookAheadKeyCache=initLookAheadKeyCache}(cache=chevrotain.cache||(chevrotain.cache={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var lookahead;!function(lookahead){function buildLookaheadForTopLevel(rule){var restProd=new gast.Flat(rule.definition),possibleTokTypes=f.first(restProd);return getSimpleLookahead(possibleTokTypes)}function buildLookaheadForOption(optionOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interp.NextInsideOptionWalker,optionOccurrence,ruleGrammar)}function buildLookaheadForMany(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interp.NextInsideManyWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForManySep(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interp.NextInsideManySepWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForAtLeastOne(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interp.NextInsideAtLeastOneWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForAtLeastOneSep(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interp.NextInsideAtLeastOneSepWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForOr(orOccurrence,ruleGrammar,ignoreAmbiguities){void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1);var alternativesTokens=new interp.NextInsideOrWalker(ruleGrammar,orOccurrence).startWalking();ignoreAmbiguities||checkForOrAmbiguities(alternativesTokens,orOccurrence,ruleGrammar);var hasLastAnEmptyAlt=utils.isEmpty(_.last(alternativesTokens));if(hasLastAnEmptyAlt){var lastIdx=alternativesTokens.length-1;return function(){for(var nextToken=this.NEXT_TOKEN(),i=0;lastIdx>i;i++)for(var currAltTokens=alternativesTokens[i],j=0;j<currAltTokens.length;j++)if(nextToken instanceof currAltTokens[j])return i;return lastIdx}}return function(){for(var nextToken=this.NEXT_TOKEN(),i=0;i<alternativesTokens.length;i++)for(var currAltTokens=alternativesTokens[i],j=0;j<currAltTokens.length;j++)if(nextToken instanceof currAltTokens[j])return i;return-1}}function checkForOrAmbiguities(alternativesTokens,orOccurrence,ruleGrammar){var altsAmbiguityErrors=checkAlternativesAmbiguities(alternativesTokens);if(!utils.isEmpty(altsAmbiguityErrors)){var errorMessages=utils.map(altsAmbiguityErrors,function(currAmbiguity){return"Ambiguous alternatives: <"+currAmbiguity.alts.join(" ,")+"> in <OR"+orOccurrence+"> inside <"+ruleGrammar.name+"> "+("Rule, <"+chevrotain.tokenName(currAmbiguity.token)+"> may appears as the first Terminal in all these alternatives.\n")});throw new Error(errorMessages.join("\n ---------------- \n")+"To Resolve this, either: \n1. refactor your grammar to be LL(1)\n2. provide explicit lookahead functions in the form {WHEN:laFunc, THEN_DO:...}\n3. Add ignore arg to this OR Production:\nOR([], 'msg', recognizer.IGNORE_AMBIGUITIES)\nIn that case the parser will always pick the first alternative that matches and ignore all the others")}}function checkAlternativesAmbiguities(alternativesTokens){var allTokensFlat=_.flatten(alternativesTokens),uniqueTokensFlat=_.uniq(allTokensFlat),tokensToAltsIndicesItAppearsIn=utils.map(uniqueTokensFlat,function(seekToken){var altsCurrTokenAppearsIn=_.pick(alternativesTokens,function(altToLookIn){return _.find(altToLookIn,function(currToken){return currToken===seekToken})}),altsIndicesTokenAppearsIn=utils.map(utils.keys(altsCurrTokenAppearsIn),function(index){return parseInt(index,10)+1});return{token:seekToken,alts:altsIndicesTokenAppearsIn}}),tokensToAltsIndicesWithAmbiguity=_.filter(tokensToAltsIndicesItAppearsIn,function(tokAndAltsItAppearsIn){return tokAndAltsItAppearsIn.alts.length>1});return tokensToAltsIndicesWithAmbiguity}function buildLookAheadForGrammarProd(prodWalkerConstructor,ruleOccurrence,ruleGrammar){var path={ruleStack:[ruleGrammar.name],occurrenceStack:[1],occurrence:ruleOccurrence},walker=new prodWalkerConstructor(ruleGrammar,path),possibleNextTokTypes=walker.startWalking();return getSimpleLookahead(possibleNextTokTypes)}function getSimpleLookahead(possibleNextTokTypes){return function(){for(var nextToken=this.NEXT_TOKEN(),j=0;j<possibleNextTokTypes.length;j++)if(nextToken instanceof possibleNextTokTypes[j])return!0;return!1}}var gast=chevrotain.gast,interp=chevrotain.interpreter,f=chevrotain.first;lookahead.buildLookaheadForTopLevel=buildLookaheadForTopLevel,lookahead.buildLookaheadForOption=buildLookaheadForOption,lookahead.buildLookaheadForMany=buildLookaheadForMany,lookahead.buildLookaheadForManySep=buildLookaheadForManySep,lookahead.buildLookaheadForAtLeastOne=buildLookaheadForAtLeastOne,lookahead.buildLookaheadForAtLeastOneSep=buildLookaheadForAtLeastOneSep,lookahead.buildLookaheadForOr=buildLookaheadForOr,lookahead.checkForOrAmbiguities=checkForOrAmbiguities,lookahead.checkAlternativesAmbiguities=checkAlternativesAmbiguities}(lookahead=chevrotain.lookahead||(chevrotain.lookahead={}))}(chevrotain||(chevrotain={}));var chevrotain;!function(chevrotain){var gastBuilder;!function(gastBuilder){function buildTopProduction(impelText,name,terminals){gastBuilder.terminalNameToConstructor=terminals;var spacedImpelText=" "+impelText,txtWithoutComments=removeComments(" "+spacedImpelText),textWithoutCommentsAndStrings=removeStringLiterals(txtWithoutComments),prodRanges=createRanges(textWithoutCommentsAndStrings),topRange=new r.Range(0,impelText.length+2);return buildTopLevel(name,topRange,prodRanges,impelText)}function buildTopLevel(name,topRange,allRanges,orgText){var topLevelProd=new gast.Rule(name,[],orgText);return buildAbstractProd(topLevelProd,topRange,allRanges)}function buildProdGast(prodRange,allRanges){"use strict";switch(prodRange.type){case ProdType.AT_LEAST_ONE:return buildAtLeastOneProd(prodRange,allRanges);case ProdType.AT_LEAST_ONE_SEP:return buildAtLeastOneSepProd(prodRange,allRanges);case ProdType.MANY_SEP:return buildManySepProd(prodRange,allRanges);case ProdType.MANY:return buildManyProd(prodRange,allRanges);ca