From 1a3240ce6568a0e65c7442a3a028ea2491434566 Mon Sep 17 00:00:00 2001 From: Shahar Soel Date: Fri, 29 Jan 2016 19:05:36 +0200 Subject: [PATCH] release 0.5.16 --- .travis.yml | 4 ++-- bower.json | 2 +- docs/tutorial/step2_parsing.md | 16 ++++++++-------- docs/tutorial/step3_adding_actions.md | 6 +++--- package.json | 2 +- readme.md | 2 +- release/chevrotain.d.ts | 2 +- release/chevrotain.js | 6 +++--- release/chevrotain.min.js | 9 ++++----- src/api.ts | 2 +- 10 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 270812804..633fb0a07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,8 +58,8 @@ deploy: api_key: secure: DNq1wbqLPHVpJPDx9O89HZM+RJB6v2R7/wk8pok7Z8NT72kUWdvbqcThGhczPO4sZ8cUTJ3ergTCE8hs9mynlR/lX6932U4fj4+uICQL9+G+deBB/t2SNyTBllkE64WrJ9BKmQvIk/Chh7ZJOM0Fro3p2BIq3JsVnfYg1tZ3U5o= file: - - package/chevrotain-binaries-0.5.15.zip - - package/chevrotain-binaries-0.5.15.tar.gz + - package/chevrotain-binaries-0.5.16.zip + - package/chevrotain-binaries-0.5.16.tar.gz on: tags : true all_branches: true diff --git a/bower.json b/bower.json index 3fb636cc7..3d4962189 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "chevrotain", - "version": "0.5.15", + "version": "0.5.16", "description": "Chevrotain is a high performance fault Tolerant Javascript parsing DSL for building recursive decent parsers", "main": "release/chevrotain.js", "dependencies": {}, diff --git a/docs/tutorial/step2_parsing.md b/docs/tutorial/step2_parsing.md index 3b45cbb13..03d48d919 100644 --- a/docs/tutorial/step2_parsing.md +++ b/docs/tutorial/step2_parsing.md @@ -44,16 +44,16 @@ relationalOperator A Chevrotain Parser analyses a [Token](https://github.com/SAP/chevrotain/blob/master/src/scan/tokens_public.ts#L61) vector that conforms to some grammar. -The grammar is defined using the [parsing DSL](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#at_least_one), +The grammar is defined using the [parsing DSL](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#at_least_one), Which includes the following methods. -* [CONSUME](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#consume1) - 'eat' a Token. -* [SUBRULE](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#subrule1) - reference to another rule. -* [OPTION](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#option1) - optional production. -* [MANY](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#many1) - repetition zero or more. -* [AT_LEAST_ONE](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#at_least_one1) - repetition one or more. -* [MANY_SEP](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#many_sep1) - repetition (zero or more) with a separator between any two items -* [AT_LEAST_ONE_SEP](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#at_least_one_sep1) - repetition (one or more) with a separator between any two items +* [CONSUME](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#consume1) - 'eat' a Token. +* [SUBRULE](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#subrule1) - reference to another rule. +* [OPTION](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#option1) - optional production. +* [MANY](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#many1) - repetition zero or more. +* [AT_LEAST_ONE](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#at_least_one1) - repetition one or more. +* [MANY_SEP](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#many_sep1) - repetition (zero or more) with a separator between any two items +* [AT_LEAST_ONE_SEP](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#at_least_one_sep1) - repetition (one or more) with a separator between any two items #### Lets implement our first grammar rule. diff --git a/docs/tutorial/step3_adding_actions.md b/docs/tutorial/step3_adding_actions.md index 816ae1ef1..d5be6a317 100644 --- a/docs/tutorial/step3_adding_actions.md +++ b/docs/tutorial/step3_adding_actions.md @@ -18,9 +18,9 @@ validates the input conforms to the grammar. In most real world use cases the pa result/data structure/value. This can be accomplished using two features of the Parsing DSL: -* [CONSUME](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#consume1) will return - The [Token](http://sap.github.io/chevrotain/documentation/0_5_15/classes/token.html) instance consumed. -* [SUBRULE](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#subrule1) will return +* [CONSUME](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#consume1) will return + The [Token](http://sap.github.io/chevrotain/documentation/0_5_16/classes/token.html) instance consumed. +* [SUBRULE](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#subrule1) will return the result on invoking the rule. diff --git a/package.json b/package.json index d330919ef..61b21fa53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chevrotain", - "version": "0.5.15", + "version": "0.5.16", "description": "Chevrotain is a high performance fault tolerant javascript parsing DSL for building recursive decent parsers", "keywords": [ "parser", diff --git a/readme.md b/readme.md index d1a8f9901..626174bc7 100644 --- a/readme.md +++ b/readme.md @@ -57,7 +57,7 @@ any code generation phase. ## Documentation * [Latest released version's HTML docs](http://sap.github.io/chevrotain/documentation) - * [Parsing DSL](http://sap.github.io/chevrotain/documentation/0_5_15/classes/parser.html#at_least_one) + * [Parsing DSL](http://sap.github.io/chevrotain/documentation/0_5_16/classes/parser.html#at_least_one) * Annotated source code (dev version): * [tokens_public.ts](https://github.com/SAP/chevrotain/blob/master/src/scan/tokens_public.ts) diff --git a/release/chevrotain.d.ts b/release/chevrotain.d.ts index 8f1431f22..f148a5023 100644 --- a/release/chevrotain.d.ts +++ b/release/chevrotain.d.ts @@ -1,4 +1,4 @@ -/*! chevrotain - v0.5.15 - 2016-01-18 */ +/*! chevrotain - v0.5.16 - 2016-01-29 */ declare namespace chevrotain { class HashTable{} export function tokenName(clazz: Function): string; diff --git a/release/chevrotain.js b/release/chevrotain.js index 45c44e2ac..15dc8b23b 100644 --- a/release/chevrotain.js +++ b/release/chevrotain.js @@ -1,4 +1,4 @@ -/*! chevrotain - v0.5.15 - 2016-01-18 */ +/*! chevrotain - v0.5.16 - 2016-01-29 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') @@ -68,7 +68,7 @@ return /******/ (function(modules) { // webpackBootstrap */ var API = {}; // semantic version - API.VERSION = "0.5.15"; + API.VERSION = "0.5.16"; // runtime API API.Parser = parser_public_1.Parser; API.Lexer = lexer_public_1.Lexer; @@ -1707,7 +1707,7 @@ return /******/ (function(modules) { // webpackBootstrap } exports.has = has; function contains(arr, item) { - return find(arr, function (currItem) { return currItem === item; }) ? true : false; + return find(arr, function (currItem) { return currItem === item; }) !== undefined ? true : false; } exports.contains = contains; /** diff --git a/release/chevrotain.min.js b/release/chevrotain.min.js index 914d1cbf3..888d503a4 100644 --- a/release/chevrotain.min.js +++ b/release/chevrotain.min.js @@ -1,5 +1,4 @@ -/*! chevrotain - v0.5.15 - 2016-01-18 */ -!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define("chevrotain",[],factory):"object"==typeof exports?exports.chevrotain=factory():root.chevrotain=factory()}(this,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){var parser_public_1=__webpack_require__(1),lexer_public_1=__webpack_require__(11),tokens_public_1=__webpack_require__(10),exceptions_public_1=__webpack_require__(5),gast_public_1=__webpack_require__(7),cache_public_1=__webpack_require__(21),API={};API.VERSION="0.5.15",API.Parser=parser_public_1.Parser,API.Lexer=lexer_public_1.Lexer,API.Token=tokens_public_1.Token,API.VirtualToken=tokens_public_1.VirtualToken,API.EOF=tokens_public_1.EOF,API.extendToken=tokens_public_1.extendToken,API.tokenName=tokens_public_1.tokenName,API.EMPTY_ALT=parser_public_1.EMPTY_ALT,API.exceptions={},API.exceptions.isRecognitionException=exceptions_public_1.exceptions.isRecognitionException,API.exceptions.EarlyExitException=exceptions_public_1.exceptions.EarlyExitException,API.exceptions.MismatchedTokenException=exceptions_public_1.exceptions.MismatchedTokenException,API.exceptions.NotAllInputParsedException=exceptions_public_1.exceptions.NotAllInputParsedException,API.exceptions.NoViableAltException=exceptions_public_1.exceptions.NoViableAltException,API.gast={},API.gast.GAstVisitor=gast_public_1.gast.GAstVisitor,API.gast.Flat=gast_public_1.gast.Flat,API.gast.Repetition=gast_public_1.gast.Repetition,API.gast.RepetitionWithSeparator=gast_public_1.gast.RepetitionWithSeparator,API.gast.RepetitionMandatory=gast_public_1.gast.RepetitionMandatory,API.gast.RepetitionMandatoryWithSeparator=gast_public_1.gast.RepetitionMandatoryWithSeparator,API.gast.Option=gast_public_1.gast.Option,API.gast.Alternation=gast_public_1.gast.Alternation,API.gast.NonTerminal=gast_public_1.gast.NonTerminal,API.gast.Terminal=gast_public_1.gast.Terminal,API.gast.Rule=gast_public_1.gast.Rule,API.clearCache=cache_public_1.clearCache,module.exports=API},function(module,exports,__webpack_require__){function EMPTY_ALT(value){return void 0===value&&(value=void 0),function(){return value}}function InRuleRecoveryException(message){this.name=lang_extensions_1.functionName(InRuleRecoveryException),this.message=message}var cache=__webpack_require__(2),exceptions_public_1=__webpack_require__(5),lang_extensions_1=__webpack_require__(3),resolver_1=__webpack_require__(6),checks_1=__webpack_require__(8),utils_1=__webpack_require__(4),follow_1=__webpack_require__(14),tokens_public_1=__webpack_require__(10),lookahead_1=__webpack_require__(17),gast_builder_1=__webpack_require__(19),interpreter_1=__webpack_require__(18),constants_1=__webpack_require__(16);!function(ParserDefinitionErrorType){ParserDefinitionErrorType[ParserDefinitionErrorType.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",ParserDefinitionErrorType[ParserDefinitionErrorType.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",ParserDefinitionErrorType[ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS=2]="DUPLICATE_PRODUCTIONS",ParserDefinitionErrorType[ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF=3]="UNRESOLVED_SUBRULE_REF",ParserDefinitionErrorType[ParserDefinitionErrorType.LEFT_RECURSION=4]="LEFT_RECURSION",ParserDefinitionErrorType[ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT=5]="NONE_LAST_EMPTY_ALT"}(exports.ParserDefinitionErrorType||(exports.ParserDefinitionErrorType={}));exports.ParserDefinitionErrorType;exports.EMPTY_ALT=EMPTY_ALT;var EOF_FOLLOW_KEY={},Parser=function(){function Parser(input,tokensMapOrArr,isErrorRecoveryEnabled){if(void 0===isErrorRecoveryEnabled&&(isErrorRecoveryEnabled=!0),this.errors=[],this._input=[],this.inputIdx=-1,this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.tokensMap=void 0,this.definedRulesNames=[],this._input=input,this.isErrorRecoveryEnabled=isErrorRecoveryEnabled,this.className=lang_extensions_1.classNameFromInstance(this),this.firstAfterRepMap=cache.getFirstAfterRepForClass(this.className),this.classLAFuncs=cache.getLookaheadFuncsForClass(this.className),cache.CLASS_TO_DEFINITION_ERRORS.containsKey(this.className)?this.definitionErrors=cache.CLASS_TO_DEFINITION_ERRORS.get(this.className):(this.definitionErrors=[],cache.CLASS_TO_DEFINITION_ERRORS.put(this.className,this.definitionErrors)),utils_1.isArray(tokensMapOrArr))this.tokensMap=utils_1.reduce(tokensMapOrArr,function(acc,tokenClazz){return acc[tokens_public_1.tokenName(tokenClazz)]=tokenClazz,acc},{});else{if(!utils_1.isObject(tokensMapOrArr))throw new Error("'tokensMapOrArr' argument must be An Array of Token constructors or a Dictionary of Tokens.");this.tokensMap=utils_1.cloneObj(tokensMapOrArr)}this.tokensMap[tokens_public_1.tokenName(tokens_public_1.EOF)]=tokens_public_1.EOF,void 0===cache.CLASS_TO_OR_LA_CACHE[this.className]&&cache.initLookAheadKeyCache(this.className),this.orLookaheadKeys=cache.CLASS_TO_OR_LA_CACHE[this.className],this.manyLookaheadKeys=cache.CLASS_TO_MANY_LA_CACHE[this.className],this.manySepLookaheadKeys=cache.CLASS_TO_MANY_SEP_LA_CACHE[this.className],this.atLeastOneLookaheadKeys=cache.CLASS_TO_AT_LEAST_ONE_LA_CACHE[this.className],this.atLeastOneSepLookaheadKeys=cache.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[this.className],this.optionLookaheadKeys=cache.CLASS_TO_OPTION_LA_CACHE[this.className]}return Parser.performSelfAnalysis=function(classInstance){var defErrorsMsgs,definitionErrors=[],className=lang_extensions_1.classNameFromInstance(classInstance);if(!cache.CLASS_TO_SELF_ANALYSIS_DONE.containsKey(className)){var grammarProductions=cache.getProductionsForClass(className);definitionErrors=cache.CLASS_TO_DEFINITION_ERRORS.get(className);var resolverErrors=resolver_1.resolveGrammar(grammarProductions);definitionErrors.push.apply(definitionErrors,resolverErrors),cache.CLASS_TO_SELF_ANALYSIS_DONE.put(className,!0);var validationErrors=checks_1.validateGrammar(grammarProductions.values());if(definitionErrors.push.apply(definitionErrors,validationErrors),!utils_1.isEmpty(definitionErrors)&&!Parser.DEFER_DEFINITION_ERRORS_HANDLING)throw defErrorsMsgs=utils_1.map(definitionErrors,function(defError){return defError.message}),new Error("Parser Definition Errors detected\n: "+defErrorsMsgs.join("\n-------------------------------\n"));if(utils_1.isEmpty(definitionErrors)){var allFollows=follow_1.computeAllProdsFollows(grammarProductions.values());cache.setResyncFollowsForClass(className,allFollows)}}if(!utils_1.isEmpty(cache.CLASS_TO_DEFINITION_ERRORS.get(className))&&!Parser.DEFER_DEFINITION_ERRORS_HANDLING)throw defErrorsMsgs=utils_1.map(cache.CLASS_TO_DEFINITION_ERRORS.get(className),function(defError){return defError.message}),new Error("Parser Definition Errors detected\n: "+defErrorsMsgs.join("\n-------------------------------\n"))},Object.defineProperty(Parser.prototype,"input",{get:function(){return utils_1.cloneArr(this._input)},set:function(newInput){this.reset(),this._input=newInput},enumerable:!0,configurable:!0}),Parser.prototype.reset=function(){this.isBackTrackingStack=[],this.errors=[],this._input=[],this.inputIdx=-1,this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[]},Parser.prototype.isAtEndOfInput=function(){return this.LA(1)instanceof tokens_public_1.EOF},Parser.prototype.getGAstProductions=function(){return cache.getProductionsForClass(this.className)},Parser.prototype.isBackTracking=function(){return!utils_1.isEmpty(this.isBackTrackingStack)},Parser.prototype.SAVE_ERROR=function(error){if(exceptions_public_1.exceptions.isRecognitionException(error))return this.errors.push(error),error;throw Error("trying to save an Error which is not a RecognitionException")},Parser.prototype.NEXT_TOKEN=function(){return this.LA(1)},Parser.prototype.LA=function(howMuch){return this._input.length<=this.inputIdx+howMuch?new tokens_public_1.EOF:this._input[this.inputIdx+howMuch]},Parser.prototype.isNextRule=function(ruleName){var classLAFuncs=cache.getLookaheadFuncsForClass(this.className),condition=classLAFuncs.get(ruleName);if(void 0===condition){var ruleGrammar=this.getGAstProductions().get(ruleName);condition=lookahead_1.buildLookaheadForTopLevel(ruleGrammar),classLAFuncs.put(ruleName,condition)}return condition.call(this)},Parser.prototype.BACKTRACK=function(grammarRule,isValid){var _this=this;return function(){_this.isBackTrackingStack.push(1);var orgState=_this.saveRecogState();try{var ruleResult=grammarRule.call(_this);return isValid(ruleResult)}catch(e){if(exceptions_public_1.exceptions.isRecognitionException(e))return!1;throw e}finally{_this.reloadRecogState(orgState),_this.isBackTrackingStack.pop()}}},Parser.prototype.SKIP_TOKEN=function(){return this.inputIdx<=this._input.length-2?(this.inputIdx++,this.NEXT_TOKEN()):new tokens_public_1.EOF},Parser.prototype.CONSUME=function(tokClass){return this.CONSUME1(tokClass)},Parser.prototype.CONSUME1=function(tokClass){return this.consumeInternal(tokClass,1)},Parser.prototype.CONSUME2=function(tokClass){return this.consumeInternal(tokClass,2)},Parser.prototype.CONSUME3=function(tokClass){return this.consumeInternal(tokClass,3)},Parser.prototype.CONSUME4=function(tokClass){return this.consumeInternal(tokClass,4)},Parser.prototype.CONSUME5=function(tokClass){return this.consumeInternal(tokClass,5)},Parser.prototype.SUBRULE=function(ruleToCall,args){return void 0===args&&(args=[]),this.SUBRULE1(ruleToCall,args)},Parser.prototype.SUBRULE1=function(ruleToCall,args){return void 0===args&&(args=[]),ruleToCall.call(this,1,args)},Parser.prototype.SUBRULE2=function(ruleToCall,args){return void 0===args&&(args=[]),ruleToCall.call(this,2,args)},Parser.prototype.SUBRULE3=function(ruleToCall,args){return void 0===args&&(args=[]),ruleToCall.call(this,3,args)},Parser.prototype.SUBRULE4=function(ruleToCall,args){return void 0===args&&(args=[]),ruleToCall.call(this,4,args)},Parser.prototype.SUBRULE5=function(ruleToCall,args){return void 0===args&&(args=[]),ruleToCall.call(this,5,args)},Parser.prototype.OPTION=function(laFuncOrAction,action){return this.OPTION1.call(this,laFuncOrAction,action)},Parser.prototype.OPTION1=function(laFuncOrAction,action){return void 0===action&&(action=laFuncOrAction,laFuncOrAction=this.getLookaheadFuncForOption(1)),this.optionInternal(laFuncOrAction,action)},Parser.prototype.OPTION2=function(laFuncOrAction,action){return void 0===action&&(action=laFuncOrAction,laFuncOrAction=this.getLookaheadFuncForOption(2)),this.optionInternal(laFuncOrAction,action)},Parser.prototype.OPTION3=function(laFuncOrAction,action){return void 0===action&&(action=laFuncOrAction,laFuncOrAction=this.getLookaheadFuncForOption(3)),this.optionInternal(laFuncOrAction,action)},Parser.prototype.OPTION4=function(laFuncOrAction,action){return void 0===action&&(action=laFuncOrAction,laFuncOrAction=this.getLookaheadFuncForOption(4)),this.optionInternal(laFuncOrAction,action)},Parser.prototype.OPTION5=function(laFuncOrAction,action){return void 0===action&&(action=laFuncOrAction,laFuncOrAction=this.getLookaheadFuncForOption(5)),this.optionInternal(laFuncOrAction,action)},Parser.prototype.OR=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.OR1(alts,errMsgTypes,ignoreAmbiguities)},Parser.prototype.OR1=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.orInternal(alts,errMsgTypes,1,ignoreAmbiguities)},Parser.prototype.OR2=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.orInternal(alts,errMsgTypes,2,ignoreAmbiguities)},Parser.prototype.OR3=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.orInternal(alts,errMsgTypes,3,ignoreAmbiguities)},Parser.prototype.OR4=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.orInternal(alts,errMsgTypes,4,ignoreAmbiguities)},Parser.prototype.OR5=function(alts,errMsgTypes,ignoreAmbiguities){return void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1),this.orInternal(alts,errMsgTypes,5,ignoreAmbiguities)},Parser.prototype.MANY=function(laFuncOrAction,action){return this.MANY1.call(this,laFuncOrAction,action)},Parser.prototype.MANY1=function(laFuncOrAction,action){this.manyInternal(this.MANY1,"MANY1",1,laFuncOrAction,action)},Parser.prototype.MANY2=function(laFuncOrAction,action){this.manyInternal(this.MANY2,"MANY2",2,laFuncOrAction,action)},Parser.prototype.MANY3=function(laFuncOrAction,action){this.manyInternal(this.MANY3,"MANY3",3,laFuncOrAction,action)},Parser.prototype.MANY4=function(laFuncOrAction,action){this.manyInternal(this.MANY4,"MANY4",4,laFuncOrAction,action)},Parser.prototype.MANY5=function(laFuncOrAction,action){this.manyInternal(this.MANY5,"MANY5",5,laFuncOrAction,action)},Parser.prototype.MANY_SEP=function(separator,laFuncOrAction,action){return this.MANY_SEP1.call(this,separator,laFuncOrAction,action)},Parser.prototype.MANY_SEP1=function(separator,laFuncOrAction,action){return this.manySepFirstInternal(this.MANY_SEP1,"MANY_SEP1",1,separator,laFuncOrAction,action)},Parser.prototype.MANY_SEP2=function(separator,laFuncOrAction,action){return this.manySepFirstInternal(this.MANY_SEP2,"MANY_SEP2",2,separator,laFuncOrAction,action)},Parser.prototype.MANY_SEP3=function(separator,laFuncOrAction,action){return this.manySepFirstInternal(this.MANY_SEP3,"MANY_SEP3",3,separator,laFuncOrAction,action)},Parser.prototype.MANY_SEP4=function(separator,laFuncOrAction,action){return this.manySepFirstInternal(this.MANY_SEP4,"MANY_SEP4",4,separator,laFuncOrAction,action)},Parser.prototype.MANY_SEP5=function(separator,laFuncOrAction,action){return this.manySepFirstInternal(this.MANY_SEP5,"MANY_SEP5",5,separator,laFuncOrAction,action)},Parser.prototype.AT_LEAST_ONE=function(laFuncOrAction,action,errMsg){return this.AT_LEAST_ONE1.call(this,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE1=function(laFuncOrAction,action,errMsg){this.atLeastOneInternal(this.AT_LEAST_ONE1,"AT_LEAST_ONE1",1,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE2=function(laFuncOrAction,action,errMsg){this.atLeastOneInternal(this.AT_LEAST_ONE2,"AT_LEAST_ONE2",2,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE3=function(laFuncOrAction,action,errMsg){this.atLeastOneInternal(this.AT_LEAST_ONE3,"AT_LEAST_ONE3",3,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE4=function(laFuncOrAction,action,errMsg){this.atLeastOneInternal(this.AT_LEAST_ONE4,"AT_LEAST_ONE4",4,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE5=function(laFuncOrAction,action,errMsg){this.atLeastOneInternal(this.AT_LEAST_ONE5,"AT_LEAST_ONE5",5,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP=function(separator,laFuncOrAction,action,errMsg){return this.AT_LEAST_ONE_SEP1.call(this,separator,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP1=function(separator,laFuncOrAction,action,errMsg){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP1",1,separator,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP2=function(separator,laFuncOrAction,action,errMsg){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP2",2,separator,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP3=function(separator,laFuncOrAction,action,errMsg){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP3",3,separator,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP4=function(separator,laFuncOrAction,action,errMsg){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP4",4,separator,laFuncOrAction,action,errMsg)},Parser.prototype.AT_LEAST_ONE_SEP5=function(separator,laFuncOrAction,action,errMsg){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP5",5,separator,laFuncOrAction,action,errMsg)},Parser.prototype.RULE_NO_RESYNC=function(ruleName,impl,invalidRet){return this.RULE(ruleName,impl,invalidRet,!1)},Parser.prototype.RULE=function(ruleName,impl,invalidRet,doReSync){void 0===invalidRet&&(invalidRet=this.defaultInvalidReturn),void 0===doReSync&&(doReSync=!0);var ruleNameErrors=checks_1.validateRuleName(ruleName,this.definedRulesNames,this.className);this.definedRulesNames.push(ruleName),this.definitionErrors.push.apply(this.definitionErrors,ruleNameErrors);var parserClassProductions=cache.getProductionsForClass(this.className);if(!parserClassProductions.containsKey(ruleName)){var gastProduction=gast_builder_1.buildTopProduction(impl.toString(),ruleName,this.tokensMap);parserClassProductions.put(ruleName,gastProduction)}var wrappedGrammarRule=function(idxInCallingRule,args){void 0===idxInCallingRule&&(idxInCallingRule=1),void 0===args&&(args=[]),this.ruleInvocationStateUpdate(ruleName,idxInCallingRule);try{return impl.apply(this,args)}catch(e){var isFirstInvokedRule=1===this.RULE_STACK.length,reSyncEnabled=isFirstInvokedRule||doReSync&&!this.isBackTracking()&&this.isErrorRecoveryEnabled;if(reSyncEnabled&&exceptions_public_1.exceptions.isRecognitionException(e)){var reSyncTokType=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(reSyncTokType))return this.reSyncTo(reSyncTokType),invalidRet();throw e}throw e}finally{this.ruleFinallyStateUpdate()}},ruleNamePropName="ruleName";return wrappedGrammarRule[ruleNamePropName]=ruleName,wrappedGrammarRule},Parser.prototype.ruleInvocationStateUpdate=function(ruleName,idxInCallingRule){this.RULE_OCCURRENCE_STACK.push(idxInCallingRule),this.RULE_STACK.push(ruleName)},Parser.prototype.ruleFinallyStateUpdate=function(){this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop();var maxInputIdx=this._input.length-1;if(0===this.RULE_STACK.length&&this.inputIdx"+expectedTokName+"<-- but found -->'"+nextTokenWithoutResync.image+"'<--";return this.SAVE_ERROR(new exceptions_public_1.exceptions.MismatchedTokenException(msg,nextTokenWithoutResync)),void grammarRule.apply(this,grammarRuleArgs)}currToken instanceof reSyncTokType&&(passedResyncPoint=!0),currToken=this.SKIP_TOKEN()}this.inputIdx=orgInputIdx},Parser.prototype.shouldInRepetitionRecoveryBeTried=function(expectTokAfterLastMatch,nextTokIdx){return void 0===expectTokAfterLastMatch||void 0===nextTokIdx?!1:this.NEXT_TOKEN()instanceof expectTokAfterLastMatch?!1:this.isBackTracking()?!1:this.canPerformInRuleRecovery(expectTokAfterLastMatch,this.getFollowsForInRuleRecovery(expectTokAfterLastMatch,nextTokIdx))?!1:!0},Parser.prototype.getFollowsForInRuleRecovery=function(tokClass,tokIdxInRule){var pathRuleStack=utils_1.cloneArr(this.RULE_STACK),pathOccurrenceStack=utils_1.cloneArr(this.RULE_OCCURRENCE_STACK),grammarPath={ruleStack:pathRuleStack,occurrenceStack:pathOccurrenceStack,lastTok:tokClass,lastTokOccurrence:tokIdxInRule},topRuleName=utils_1.first(pathRuleStack),gastProductions=this.getGAstProductions(),topProduction=gastProductions.get(topRuleName),follows=new interpreter_1.NextAfterTokenWalker(topProduction,grammarPath).startWalking();return follows},Parser.prototype.tryInRuleRecovery=function(expectedTokType,follows){if(this.canRecoverWithSingleTokenInsertion(expectedTokType,follows)){var tokToInsert=this.getTokenToInsert(expectedTokType);return tokToInsert.isInsertedInRecovery=!0,tokToInsert}if(this.canRecoverWithSingleTokenDeletion(expectedTokType)){var nextTok=this.SKIP_TOKEN();return this.inputIdx++,nextTok}throw new InRuleRecoveryException("sad sad panda")},Parser.prototype.canPerformInRuleRecovery=function(expectedToken,follows){return this.canRecoverWithSingleTokenInsertion(expectedToken,follows)||this.canRecoverWithSingleTokenDeletion(expectedToken)},Parser.prototype.canRecoverWithSingleTokenInsertion=function(expectedTokType,follows){if(!this.canTokenTypeBeInsertedInRecovery(expectedTokType))return!1;if(utils_1.isEmpty(follows))return!1;var mismatchedTok=this.NEXT_TOKEN(),isMisMatchedTokInFollows=void 0!==utils_1.find(follows,function(possibleFollowsTokType){return mismatchedTok instanceof possibleFollowsTokType});return isMisMatchedTokInFollows},Parser.prototype.canRecoverWithSingleTokenDeletion=function(expectedTokType){var isNextTokenWhatIsExpected=this.LA(2)instanceof expectedTokType;return isNextTokenWhatIsExpected},Parser.prototype.isInCurrentRuleReSyncSet=function(token){var followKey=this.getCurrFollowKey(),currentRuleReSyncSet=this.getFollowSetFromFollowKey(followKey);return utils_1.contains(currentRuleReSyncSet,token)},Parser.prototype.findReSyncTokenType=function(){for(var allPossibleReSyncTokTypes=this.flattenFollowSet(),nextToken=this.NEXT_TOKEN(),k=2;;){var nextTokenType=nextToken.constructor;if(utils_1.contains(allPossibleReSyncTokTypes,nextTokenType))return nextTokenType;nextToken=this.LA(k),k++}},Parser.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return EOF_FOLLOW_KEY;var currRuleIdx=this.RULE_STACK.length-1,currRuleOccIdx=currRuleIdx,prevRuleIdx=currRuleIdx-1;return{ruleName:this.RULE_STACK[currRuleIdx],idxInCallingRule:this.RULE_OCCURRENCE_STACK[currRuleOccIdx],inRule:this.RULE_STACK[prevRuleIdx]}},Parser.prototype.buildFullFollowKeyStack=function(){var _this=this;return utils_1.map(this.RULE_STACK,function(ruleName,idx){return 0===idx?EOF_FOLLOW_KEY:{ruleName:ruleName,idxInCallingRule:_this.RULE_OCCURRENCE_STACK[idx],inRule:_this.RULE_STACK[idx-1]}})},Parser.prototype.flattenFollowSet=function(){var _this=this,followStack=utils_1.map(this.buildFullFollowKeyStack(),function(currKey){return _this.getFollowSetFromFollowKey(currKey)});return utils_1.flatten(followStack)},Parser.prototype.getFollowSetFromFollowKey=function(followKey){if(followKey===EOF_FOLLOW_KEY)return[tokens_public_1.EOF];var followName=followKey.ruleName+followKey.idxInCallingRule+constants_1.IN+followKey.inRule;return cache.getResyncFollowsForClass(this.className).get(followName)},Parser.prototype.reSyncTo=function(tokClass){for(var nextTok=this.NEXT_TOKEN();nextTok instanceof tokClass==!1;)nextTok=this.SKIP_TOKEN()},Parser.prototype.attemptInRepetitionRecovery=function(prodFunc,args,lookaheadFunc,prodName,prodOccurrence,nextToksWalker,prodKeys){var key=this.getKeyForAutomaticLookahead(prodName,prodKeys,prodOccurrence),firstAfterRepInfo=this.firstAfterRepMap.get(key);if(void 0===firstAfterRepInfo){var currRuleName=utils_1.last(this.RULE_STACK),ruleGrammar=this.getGAstProductions().get(currRuleName),walker=new nextToksWalker(ruleGrammar,prodOccurrence);firstAfterRepInfo=walker.startWalking(),this.firstAfterRepMap.put(key,firstAfterRepInfo)}var expectTokAfterLastMatch=firstAfterRepInfo.token,nextTokIdx=firstAfterRepInfo.occurrence,isEndOfRule=firstAfterRepInfo.isEndOfRule;1===this.RULE_STACK.length&&isEndOfRule&&void 0===expectTokAfterLastMatch&&(expectTokAfterLastMatch=tokens_public_1.EOF,nextTokIdx=1),this.shouldInRepetitionRecoveryBeTried(expectTokAfterLastMatch,nextTokIdx)&&this.tryInRepetitionRecovery(prodFunc,args,lookaheadFunc,expectTokAfterLastMatch)},Parser.prototype.optionInternal=function(condition,action){return condition.call(this)?(action.call(this),!0):!1},Parser.prototype.atLeastOneInternal=function(prodFunc,prodName,prodOccurrence,lookAheadFunc,action,errMsg){if(utils_1.isString(action)&&(errMsg=action,action=lookAheadFunc,lookAheadFunc=this.getLookaheadFuncForAtLeastOne(prodOccurrence)),!lookAheadFunc.call(this))throw this.SAVE_ERROR(new exceptions_public_1.exceptions.EarlyExitException("expecting at least one: "+errMsg,this.NEXT_TOKEN()));for(action.call(this);lookAheadFunc.call(this);)action.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(prodFunc,[lookAheadFunc,action,errMsg],lookAheadFunc,prodName,prodOccurrence,interpreter_1.NextTerminalAfterAtLeastOneWalker,this.atLeastOneLookaheadKeys)},Parser.prototype.atLeastOneSepFirstInternal=function(prodFunc,prodName,prodOccurrence,separator,firstIterationLookAheadFunc,action,errMsg){var _this=this,separatorsResult=[];if(utils_1.isString(action)&&(errMsg=action,action=firstIterationLookAheadFunc,firstIterationLookAheadFunc=this.getLookaheadFuncForAtLeastOneSep(prodOccurrence)),!firstIterationLookAheadFunc.call(this))throw this.SAVE_ERROR(new exceptions_public_1.exceptions.EarlyExitException("expecting at least one: "+errMsg,this.NEXT_TOKEN()));action.call(this);for(var separatorLookAheadFunc=function(){return _this.NEXT_TOKEN()instanceof separator};separatorLookAheadFunc();)separatorsResult.push(this.CONSUME(separator)),action.call(this);return this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[prodName,prodOccurrence,separator,separatorLookAheadFunc,action,separatorsResult,this.atLeastOneSepLookaheadKeys,interpreter_1.NextTerminalAfterAtLeastOneSepWalker],separatorLookAheadFunc,prodName,prodOccurrence,interpreter_1.NextTerminalAfterAtLeastOneSepWalker,this.atLeastOneSepLookaheadKeys),separatorsResult},Parser.prototype.manyInternal=function(prodFunc,prodName,prodOccurrence,lookAheadFunc,action){for(void 0===action&&(action=lookAheadFunc,lookAheadFunc=this.getLookaheadFuncForMany(prodOccurrence));lookAheadFunc.call(this);)action.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(prodFunc,[lookAheadFunc,action],lookAheadFunc,prodName,prodOccurrence,interpreter_1.NextTerminalAfterManyWalker,this.manyLookaheadKeys)},Parser.prototype.manySepFirstInternal=function(prodFunc,prodName,prodOccurrence,separator,firstIterationLookAheadFunc,action){var _this=this,separatorsResult=[];if(void 0===action&&(action=firstIterationLookAheadFunc,firstIterationLookAheadFunc=this.getLookaheadFuncForManySep(prodOccurrence)),firstIterationLookAheadFunc.call(this)){action.call(this);for(var separatorLookAheadFunc=function(){return _this.NEXT_TOKEN()instanceof separator};separatorLookAheadFunc();)separatorsResult.push(this.CONSUME(separator)),action.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[prodName,prodOccurrence,separator,separatorLookAheadFunc,action,separatorsResult,this.manySepLookaheadKeys,interpreter_1.NextTerminalAfterManySepWalker],separatorLookAheadFunc,prodName,prodOccurrence,interpreter_1.NextTerminalAfterManySepWalker,this.manySepLookaheadKeys)}return separatorsResult},Parser.prototype.repetitionSepSecondInternal=function(prodName,prodOccurrence,separator,separatorLookAheadFunc,action,separatorsResult,laKeys,nextTerminalAfterWalker){for(;separatorLookAheadFunc();)separatorsResult.push(this.CONSUME(separator)),action.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[prodName,prodOccurrence,separator,separatorLookAheadFunc,action,separatorsResult,laKeys,nextTerminalAfterWalker],separatorLookAheadFunc,prodName,prodOccurrence,nextTerminalAfterWalker,laKeys)},Parser.prototype.orInternal=function(alts,errMsgTypes,occurrence,ignoreAmbiguities){if(void 0!==alts[0].WHEN){for(var i=0;i"+expectedTokType+"<-- but found -->'"+nextToken.image+"'<--";throw this.SAVE_ERROR(new exceptions_public_1.exceptions.MismatchedTokenException(msg,nextToken))},Parser.prototype.getKeyForAutomaticLookahead=function(prodName,prodKeys,occurrence){var occuMap=prodKeys[occurrence-1],currRule=utils_1.last(this.RULE_STACK),key=occuMap[currRule];return void 0===key&&(key=prodName+occurrence+constants_1.IN+currRule,occuMap[currRule]=key),key},Parser.prototype.getLookaheadFuncForOption=function(occurence){var key=this.getKeyForAutomaticLookahead("OPTION",this.optionLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForOption)},Parser.prototype.getLookaheadFuncForOr=function(occurence,ignoreErrors){var key=this.getKeyForAutomaticLookahead("OR",this.orLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForOr,[ignoreErrors])},Parser.prototype.getLookaheadFuncForMany=function(occurence){var key=this.getKeyForAutomaticLookahead("MANY",this.manyLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForMany)},Parser.prototype.getLookaheadFuncForManySep=function(occurence){var key=this.getKeyForAutomaticLookahead("MANY_SEP",this.manySepLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForManySep)},Parser.prototype.getLookaheadFuncForAtLeastOne=function(occurence){var key=this.getKeyForAutomaticLookahead("AT_LEAST_ONE",this.atLeastOneLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForAtLeastOne)},Parser.prototype.getLookaheadFuncForAtLeastOneSep=function(occurence){var key=this.getKeyForAutomaticLookahead("AT_LEAST_ONE_SEP",this.atLeastOneSepLookaheadKeys,occurence);return this.getLookaheadFuncFor(key,occurence,lookahead_1.buildLookaheadForAtLeastOneSep)},Parser.prototype.getLookaheadFuncFor=function(key,occurrence,laFuncBuilder,extraArgs){void 0===extraArgs&&(extraArgs=[]);var ruleName=utils_1.last(this.RULE_STACK),condition=this.classLAFuncs.get(key);if(void 0===condition){var ruleGrammar=this.getGAstProductions().get(ruleName);condition=laFuncBuilder.apply(null,[occurrence,ruleGrammar].concat(extraArgs)),this.classLAFuncs.put(key,condition)}return condition},Parser.prototype.saveRecogState=function(){var savedErrors=utils_1.cloneArr(this.errors),savedRuleStack=utils_1.cloneArr(this.RULE_STACK);return{errors:savedErrors,inputIdx:this.inputIdx,RULE_STACK:savedRuleStack}},Parser.prototype.reloadRecogState=function(newState){this.errors=newState.errors,this.inputIdx=newState.inputIdx, -this.RULE_STACK=newState.RULE_STACK},Parser.prototype.raiseNoAltException=function(occurrence,errMsgTypes){var errSuffix=" but found: '"+this.NEXT_TOKEN().image+"'";if(void 0===errMsgTypes){var ruleName=utils_1.last(this.RULE_STACK),ruleGrammar=this.getGAstProductions().get(ruleName),nextTokens=new interpreter_1.NextInsideOrWalker(ruleGrammar,occurrence).startWalking(),nextTokensFlat=utils_1.flatten(nextTokens),nextTokensNames=utils_1.map(nextTokensFlat,function(currTokenClass){return tokens_public_1.tokenName(currTokenClass)});errMsgTypes="one of: <"+nextTokensNames.join(" ,")+">"}throw this.SAVE_ERROR(new exceptions_public_1.exceptions.NoViableAltException("expecting: "+errMsgTypes+" "+errSuffix,this.NEXT_TOKEN()))},Parser.IGNORE_AMBIGUITIES=!0,Parser.NO_RESYNC=!1,Parser.DEFER_DEFINITION_ERRORS_HANDLING=!1,Parser}();exports.Parser=Parser,InRuleRecoveryException.prototype=Error.prototype},function(module,exports,__webpack_require__){function getProductionsForClass(className){return getFromNestedHashTable(className,exports.CLASS_TO_GRAMMAR_PRODUCTIONS)}function getResyncFollowsForClass(className){return getFromNestedHashTable(className,exports.CLASS_TO_RESYNC_FOLLOW_SETS)}function setResyncFollowsForClass(className,followSet){exports.CLASS_TO_RESYNC_FOLLOW_SETS.put(className,followSet)}function getLookaheadFuncsForClass(className){return getFromNestedHashTable(className,exports.CLASS_TO_LOOKAHEAD_FUNCS)}function getFirstAfterRepForClass(className){return getFromNestedHashTable(className,exports.CLASS_TO_FIRST_AFTER_REPETITION)}function initLookAheadKeyCache(className){exports.CLASS_TO_OR_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),exports.CLASS_TO_MANY_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),exports.CLASS_TO_MANY_SEP_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),exports.CLASS_TO_AT_LEAST_ONE_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),exports.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),exports.CLASS_TO_OPTION_LA_CACHE[className]=new Array(exports.MAX_OCCURRENCE_INDEX),initSingleLookAheadKeyCache(exports.CLASS_TO_OR_LA_CACHE[className]),initSingleLookAheadKeyCache(exports.CLASS_TO_MANY_LA_CACHE[className]),initSingleLookAheadKeyCache(exports.CLASS_TO_MANY_SEP_LA_CACHE[className]),initSingleLookAheadKeyCache(exports.CLASS_TO_AT_LEAST_ONE_LA_CACHE[className]),initSingleLookAheadKeyCache(exports.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[className]),initSingleLookAheadKeyCache(exports.CLASS_TO_OPTION_LA_CACHE[className])}function initSingleLookAheadKeyCache(laCache){for(var i=0;i1}),errors=utils.map(utils.values(duplicates),function(currDuplicates){var firstProd=utils.first(currDuplicates),msg=createDuplicatesErrorMessage(currDuplicates,topLevelRule.name),dslName=gast_1.getProductionDslName(firstProd),defError={message:msg,type:parser_public_1.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:topLevelRule.name,dslName:dslName,occurrence:firstProd.occurrenceInParent},param=getExtraProductionArgument(firstProd);return param&&(defError.parameter=param),defError});return errors}function createDuplicatesErrorMessage(duplicateProds,topLevelName){var firstProd=utils.first(duplicateProds),index=firstProd.occurrenceInParent,dslName=gast_1.getProductionDslName(firstProd),extraArgument=getExtraProductionArgument(firstProd),msg="->"+dslName+"<- with occurrence index: ->"+index+"<-\n "+(extraArgument?"and argument: "+extraArgument:"")+"\n appears more than once ("+duplicateProds.length+" times) in the top level rule: "+topLevelName+".\n "+(1===index?"note that "+dslName+" and "+dslName+"1 both have the same occurrence index 1}":"")+"}\n to fix this make sure each usage of "+dslName+" "+(extraArgument?"with the argument: "+extraArgument:"")+"\n in the rule "+topLevelName+" has a different occurrence index (1-5), as that combination acts as a unique\n position key in the grammar, which is needed by the parsing engine.";return msg=msg.replace(/[ \t]+/g," "),msg=msg.replace(/\s\s+/g,"\n")}function identifyProductionForDuplicates(prod){return gast_1.getProductionDslName(prod)+"_#_"+prod.occurrenceInParent+"_#_"+getExtraProductionArgument(prod)}function getExtraProductionArgument(prod){return prod instanceof gast_public_1.gast.Terminal?tokens_public_1.tokenName(prod.terminalType):prod instanceof gast_public_1.gast.NonTerminal?prod.nonTerminalName:""}function validateRuleName(ruleName,definedRulesNames,className){var errMsg,errors=[];return ruleName.match(ruleNamePattern)||(errMsg="Invalid Grammar rule name --> "+ruleName+" it must match the pattern: "+ruleNamePattern.toString(),errors.push({message:errMsg,type:parser_public_1.ParserDefinitionErrorType.INVALID_RULE_NAME,ruleName:ruleName})),utils.contains(definedRulesNames,ruleName)&&(errMsg="Duplicate definition, rule: "+ruleName+" is already defined in the grammar: "+className,errors.push({message:errMsg,type:parser_public_1.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:ruleName})),errors}function validateNoLeftRecursion(topRule,currRule,path){void 0===path&&(path=[]);var errors=[],nextNonTerminals=getFirstNoneTerminal(currRule.definition);if(utils.isEmpty(nextNonTerminals))return[];var ruleName=topRule.name,foundLeftRecursion=utils.contains(nextNonTerminals,topRule),pathNames=utils.map(path,function(currRule){return currRule.name}),leftRecursivePath=ruleName+" --> "+pathNames.concat([ruleName]).join(" --> ");if(foundLeftRecursion){var errMsg="Left Recursion found in grammar.\n"+("rule: <"+ruleName+"> can be invoked from itself (directly or indirectly)\n")+("without consuming any Tokens. The grammar path that causes this is: \n "+leftRecursivePath+"\n")+" To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.";errors.push({message:errMsg,type:parser_public_1.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:ruleName})}var validNextSteps=utils.difference(nextNonTerminals,path.concat([topRule])),errorsFromNextSteps=utils.map(validNextSteps,function(currRefRule){var newPath=utils.cloneArr(path);return newPath.push(currRefRule),validateNoLeftRecursion(topRule,currRefRule,newPath)});return errors.concat(utils.flatten(errorsFromNextSteps))}function getFirstNoneTerminal(definition){var result=[];if(utils.isEmpty(definition))return result;var firstProd=utils.first(definition);if(firstProd instanceof gast_public_1.gast.NonTerminal){if(void 0===firstProd.referencedRule)return result;result.push(firstProd.referencedRule)}else if(firstProd instanceof gast_public_1.gast.Flat||firstProd instanceof gast_public_1.gast.Option||firstProd instanceof gast_public_1.gast.RepetitionMandatory||firstProd instanceof gast_public_1.gast.RepetitionMandatoryWithSeparator||firstProd instanceof gast_public_1.gast.RepetitionWithSeparator||firstProd instanceof gast_public_1.gast.Repetition)result=result.concat(getFirstNoneTerminal(firstProd.definition));else if(firstProd instanceof gast_public_1.gast.Alternation)result=utils.flatten(utils.map(firstProd.definition,function(currSubDef){return getFirstNoneTerminal(currSubDef.definition)}));else if(!(firstProd instanceof gast_public_1.gast.Terminal))throw Error("non exhaustive match");var isFirstOptional=gast_1.isOptionalProd(firstProd),hasMore=definition.length>1;if(isFirstOptional&&hasMore){var rest=utils.drop(definition);return result.concat(getFirstNoneTerminal(rest))}return result}function validateEmptyOrAlternative(topLevelRule){var orCollector=new OrCollector;topLevelRule.accept(orCollector);var ors=orCollector.alternations,errors=utils.reduce(ors,function(errors,currOr){var exceptLast=utils.dropRight(currOr.definition),currErrors=utils.map(exceptLast,function(currAlternative,currAltIdx){return utils.isEmpty(first_1.first(currAlternative))?{message:"Ambiguous empty alternative: <"+(currAltIdx+1)+">"+(" in inside <"+topLevelRule.name+"> Rule.\n")+"Only the last alternative may be an empty alternative.",type:parser_public_1.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:topLevelRule.name,occurrence:currOr.occurrenceInParent,alternative:currAltIdx+1}:null});return errors.concat(utils.compact(currErrors))},[]);return errors}var __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 __)},utils=__webpack_require__(4),parser_public_1=__webpack_require__(1),gast_public_1=__webpack_require__(7),gast_1=__webpack_require__(9),tokens_public_1=__webpack_require__(10),first_1=__webpack_require__(13);exports.validateGrammar=validateGrammar,exports.identifyProductionForDuplicates=identifyProductionForDuplicates;var OccurrenceValidationCollector=function(_super){function OccurrenceValidationCollector(){_super.apply(this,arguments),this.allProductions=[]}return __extends(OccurrenceValidationCollector,_super),OccurrenceValidationCollector.prototype.visitNonTerminal=function(subrule){this.allProductions.push(subrule)},OccurrenceValidationCollector.prototype.visitOption=function(option){this.allProductions.push(option)},OccurrenceValidationCollector.prototype.visitRepetitionWithSeparator=function(manySep){this.allProductions.push(manySep)},OccurrenceValidationCollector.prototype.visitRepetitionMandatory=function(atLeastOne){this.allProductions.push(atLeastOne)},OccurrenceValidationCollector.prototype.visitRepetitionMandatoryWithSeparator=function(atLeastOneSep){this.allProductions.push(atLeastOneSep)},OccurrenceValidationCollector.prototype.visitRepetition=function(many){this.allProductions.push(many)},OccurrenceValidationCollector.prototype.visitAlternation=function(or){this.allProductions.push(or)},OccurrenceValidationCollector.prototype.visitTerminal=function(terminal){this.allProductions.push(terminal)},OccurrenceValidationCollector}(gast_public_1.gast.GAstVisitor);exports.OccurrenceValidationCollector=OccurrenceValidationCollector;var ruleNamePattern=/^[a-zA-Z_]\w*$/;exports.validateRuleName=validateRuleName,exports.validateNoLeftRecursion=validateNoLeftRecursion,exports.getFirstNoneTerminal=getFirstNoneTerminal;var OrCollector=function(_super){function OrCollector(){_super.apply(this,arguments),this.alternations=[]}return __extends(OrCollector,_super),OrCollector.prototype.visitAlternation=function(node){this.alternations.push(node)},OrCollector}(gast_public_1.gast.GAstVisitor);exports.validateEmptyOrAlternative=validateEmptyOrAlternative},function(module,exports,__webpack_require__){function isSequenceProd(prod){return prod instanceof gast_public_1.gast.Flat||prod instanceof gast_public_1.gast.Option||prod instanceof gast_public_1.gast.Repetition||prod instanceof gast_public_1.gast.RepetitionMandatory||prod instanceof gast_public_1.gast.RepetitionMandatoryWithSeparator||prod instanceof gast_public_1.gast.RepetitionWithSeparator||prod instanceof gast_public_1.gast.Terminal||prod instanceof gast_public_1.gast.Rule}function isOptionalProd(prod,alreadyVisited){void 0===alreadyVisited&&(alreadyVisited=[]);var isDirectlyOptional=prod instanceof gast_public_1.gast.Option||prod instanceof gast_public_1.gast.Repetition||prod instanceof gast_public_1.gast.RepetitionWithSeparator;return isDirectlyOptional?!0:prod instanceof gast_public_1.gast.Alternation?utils_1.some(prod.definition,function(subProd){return isOptionalProd(subProd,alreadyVisited)}):prod instanceof gast_public_1.gast.NonTerminal&&utils_1.contains(alreadyVisited,prod)?!1:prod instanceof gast_public_1.gast.AbstractProduction?(prod instanceof gast_public_1.gast.NonTerminal&&alreadyVisited.push(prod),utils_1.every(prod.definition,function(subProd){return isOptionalProd(subProd,alreadyVisited)})):!1}function isBranchingProd(prod){return prod instanceof gast_public_1.gast.Alternation}function getProductionDslName(prod){var clazz=prod.constructor,prodName=lang_extensions_1.functionName(clazz);return productionToDslName[prodName]}var gast_public_1=__webpack_require__(7),utils_1=__webpack_require__(4),lang_extensions_1=__webpack_require__(3);exports.isSequenceProd=isSequenceProd,exports.isOptionalProd=isOptionalProd,exports.isBranchingProd=isBranchingProd;var productionToDslName={};productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.NonTerminal)]="SUBRULE",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.Option)]="OPTION",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.RepetitionMandatory)]="AT_LEAST_ONE",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.RepetitionMandatoryWithSeparator)]="AT_LEAST_ONE_SEP",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.RepetitionWithSeparator)]="MANY_SEP",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.Repetition)]="MANY",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.Alternation)]="OR",productionToDslName[lang_extensions_1.functionName(gast_public_1.gast.Terminal)]="CONSUME",exports.getProductionDslName=getProductionDslName},function(module,exports,__webpack_require__){function tokenName(clazz){return utils_1.isString(clazz.tokenName)?clazz.tokenName:lang_extensions_1.functionName(clazz)}function extendToken(tokenName,patternOrParent,parentConstructor){void 0===patternOrParent&&(patternOrParent=void 0),void 0===parentConstructor&&(parentConstructor=Token);var pattern;utils_1.isRegExp(patternOrParent)||patternOrParent===lexer_public_1.Lexer.SKIPPED||patternOrParent===lexer_public_1.Lexer.NA?pattern=patternOrParent:utils_1.isFunction(patternOrParent)&&(parentConstructor=patternOrParent,pattern=void 0);var derivedCostructor=function(){parentConstructor.apply(this,arguments)};return derivedCostructor=utils_1.assign(derivedCostructor,parentConstructor),derivedCostructor.tokenName=tokenName,derivedCostructor.prototype=Object.create(parentConstructor.prototype),derivedCostructor.prototype.constructor=derivedCostructor,utils_1.isUndefined(pattern)||(derivedCostructor.PATTERN=pattern),derivedCostructor}var __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 __)},utils_1=__webpack_require__(4),lang_extensions_1=__webpack_require__(3),lexer_public_1=__webpack_require__(11);exports.tokenName=tokenName, -exports.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}();exports.Token=Token;var VirtualToken=function(_super){function VirtualToken(){_super.call(this,"",-1,-1,-1,-1,-1)}return __extends(VirtualToken,_super),VirtualToken}(Token);exports.VirtualToken=VirtualToken;var EOF=function(_super){function EOF(){_super.apply(this,arguments)}return __extends(EOF,_super),EOF}(VirtualToken);exports.EOF=EOF},function(module,exports,__webpack_require__){var lexer_1=__webpack_require__(12),utils_1=__webpack_require__(4);!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"}(exports.LexerDefinitionErrorType||(exports.LexerDefinitionErrorType={}));var Lexer=(exports.LexerDefinitionErrorType,function(){function Lexer(tokenClasses,deferDefinitionErrorsHandling){if(void 0===deferDefinitionErrorsHandling&&(deferDefinitionErrorsHandling=!1),this.tokenClasses=tokenClasses,this.lexerDefinitionErrors=[],this.lexerDefinitionErrors=lexer_1.validatePatterns(tokenClasses),!utils_1.isEmpty(this.lexerDefinitionErrors)&&!deferDefinitionErrorsHandling){var allErrMessages=utils_1.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_1.isEmpty(this.lexerDefinitionErrors)){var analyzeResult=lexer_1.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=utils_1.cloneObj(this.emptyGroups);if(!utils_1.isEmpty(this.lexerDefinitionErrors)){var allErrMessages=utils_1.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;imatch[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=lexer_1.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"+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}());exports.Lexer=Lexer},function(module,exports,__webpack_require__){function analyzeTokenClasses(tokenClasses){var onlyRelevantClasses=utils_1.reject(tokenClasses,function(currClass){return currClass[PATTERN]===lexer_public_1.Lexer.NA}),allTransformedPatterns=utils_1.map(onlyRelevantClasses,function(currClass){return addStartOfInput(currClass[PATTERN])}),allPatternsToClass=utils_1.zipObject(allTransformedPatterns,onlyRelevantClasses),patternIdxToClass=utils_1.map(allTransformedPatterns,function(pattern){return allPatternsToClass[pattern.toString()]}),patternIdxToGroup=utils_1.map(onlyRelevantClasses,function(clazz){var groupName=clazz.GROUP;if(groupName!==lexer_public_1.Lexer.SKIPPED){if(utils_1.isString(groupName))return groupName;if(utils_1.isUndefined(groupName))return"default";throw Error("non exhaustive match")}}),patternIdxToLongerAltIdx=utils_1.map(onlyRelevantClasses,function(clazz){var longerAltClass=clazz.LONGER_ALT;if(longerAltClass){var longerAltIdx=utils_1.indexOf(onlyRelevantClasses,longerAltClass);return longerAltIdx}}),patternIdxToCanLineTerminator=utils_1.map(allTransformedPatterns,function(pattern){return/\\n|\\r|\\s/g.test(pattern.source)}),emptyGroups=utils_1.reduce(onlyRelevantClasses,function(acc,clazz){var groupName=clazz.GROUP;return utils_1.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=utils_1.filter(tokenClasses,function(currClass){return!utils_1.has(currClass,PATTERN)}),errors=utils_1.map(tokenClassesWithMissingPattern,function(currClass){return{message:"Token class: ->"+tokens_public_1.tokenName(currClass)+"<- missing static 'PATTERN' property",type:lexer_public_1.LexerDefinitionErrorType.MISSING_PATTERN,tokenClasses:[currClass]}}),validTokenClasses=utils_1.difference(tokenClasses,tokenClassesWithMissingPattern);return{errors:errors,validTokenClasses:validTokenClasses}}function findInvalidPatterns(tokenClasses){var tokenClassesWithInvalidPattern=utils_1.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return!utils_1.isRegExp(pattern)}),errors=utils_1.map(tokenClassesWithInvalidPattern,function(currClass){return{message:"Token class: ->"+tokens_public_1.tokenName(currClass)+"<- static 'PATTERN' can only be a RegExp",type:lexer_public_1.LexerDefinitionErrorType.INVALID_PATTERN,tokenClasses:[currClass]}}),validTokenClasses=utils_1.difference(tokenClasses,tokenClassesWithInvalidPattern);return{errors:errors,validTokenClasses:validTokenClasses}}function findEndOfInputAnchor(tokenClasses){var invalidRegex=utils_1.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return end_of_input.test(pattern.source)}),errors=utils_1.map(invalidRegex,function(currClass){return{message:"Token class: ->"+tokens_public_1.tokenName(currClass)+"<- static 'PATTERN' cannot contain end of input anchor '$'",type:lexer_public_1.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenClasses:[currClass]}});return errors}function findUnsupportedFlags(tokenClasses){var invalidFlags=utils_1.filter(tokenClasses,function(currClass){var pattern=currClass[PATTERN];return pattern instanceof RegExp&&(pattern.multiline||pattern.global)}),errors=utils_1.map(invalidFlags,function(currClass){return{message:"Token class: ->"+tokens_public_1.tokenName(currClass)+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:lexer_public_1.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenClasses:[currClass]}});return errors}function findDuplicatePatterns(tokenClasses){var found=[],identicalPatterns=utils_1.map(tokenClasses,function(outerClass){return utils_1.reduce(tokenClasses,function(result,innerClass){return outerClass.PATTERN.source!==innerClass.PATTERN.source||utils_1.contains(found,innerClass)||innerClass.PATTERN===lexer_public_1.Lexer.NA?result:(found.push(innerClass),result.push(innerClass),result)},[])});identicalPatterns=utils_1.compact(identicalPatterns);var duplicatePatterns=utils_1.filter(identicalPatterns,function(currIdenticalSet){return currIdenticalSet.length>1}),errors=utils_1.map(duplicatePatterns,function(setOfIdentical){var classNames=utils_1.map(setOfIdentical,function(currClass){return tokens_public_1.tokenName(currClass)}),dupPatternSrc=utils_1.first(setOfIdentical).PATTERN;return{message:"The same RegExp pattern ->"+dupPatternSrc+"<-"+("has been used in all the following classes: "+classNames.join(", ")+" <-"),type:lexer_public_1.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenClasses:setOfIdentical}});return errors}function findInvalidGroupType(tokenClasses){var invalidTypes=utils_1.filter(tokenClasses,function(clazz){if(!utils_1.has(clazz,"GROUP"))return!1;var group=clazz.GROUP;return group!==lexer_public_1.Lexer.SKIPPED&&group!==lexer_public_1.Lexer.NA&&!utils_1.isString(group)}),errors=utils_1.map(invalidTypes,function(currClass){return{message:"Token class: ->"+tokens_public_1.tokenName(currClass)+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:lexer_public_1.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;currOffsetnextSubProdIdx,isLastInnerProdOptional=!0;hasInnerProdsRemaining&&isLastInnerProdOptional;)currSubProd=seq[nextSubProdIdx],isLastInnerProdOptional=gast_1.isOptionalProd(currSubProd),firstSet=firstSet.concat(first(currSubProd)),nextSubProdIdx+=1,hasInnerProdsRemaining=seq.length>nextSubProdIdx;return utils_1.uniq(firstSet)}function firstForBranching(prod){var allAlternativesFirsts=utils_1.map(prod.definition,function(innerProd){return first(innerProd)});return utils_1.uniq(utils_1.flatten(allAlternativesFirsts))}function firstForTerminal(terminal){return[terminal.terminalType]}var gast_public_1=__webpack_require__(7),gast_1=__webpack_require__(9),utils_1=__webpack_require__(4);exports.first=first,exports.firstForSequence=firstForSequence,exports.firstForBranching=firstForBranching,exports.firstForTerminal=firstForTerminal},function(module,exports,__webpack_require__){function computeAllProdsFollows(topProductions){var reSyncFollows=new lang_extensions_1.HashTable;return utils_1.forEach(topProductions,function(topProd){var currRefsFollow=new ResyncFollowsWalker(topProd).startWalking();reSyncFollows.putAll(currRefsFollow)}),reSyncFollows}function buildBetweenProdsFollowPrefix(inner,occurenceInParent){return inner.name+occurenceInParent+constants_1.IN}function buildInProdFollowPrefix(terminal){var terminalName=tokens_public_1.tokenName(terminal.terminalType);return terminalName+terminal.occurrenceInParent+constants_1.IN}var __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 __)},rest_1=__webpack_require__(15),lang_extensions_1=__webpack_require__(3),gast_public_1=__webpack_require__(7),first_1=__webpack_require__(13),utils_1=__webpack_require__(4),constants_1=__webpack_require__(16),tokens_public_1=__webpack_require__(10),ResyncFollowsWalker=function(_super){function ResyncFollowsWalker(topProd){_super.call(this),this.topProd=topProd,this.follows=new lang_extensions_1.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 gast_public_1.gast.Flat(fullRest),t_in_topProd_follows=first_1.first(restProd);this.follows.put(followName,t_in_topProd_follows)},ResyncFollowsWalker}(rest_1.RestWalker);exports.ResyncFollowsWalker=ResyncFollowsWalker,exports.computeAllProdsFollows=computeAllProdsFollows,exports.buildBetweenProdsFollowPrefix=buildBetweenProdsFollowPrefix,exports.buildInProdFollowPrefix=buildInProdFollowPrefix},function(module,exports,__webpack_require__){function restForRepetitionWithSeparator(repSepProd,currRest,prevRest){var repSepRest=[new gast_public_1.gast.Option([new gast_public_1.gast.Terminal(repSepProd.separator)].concat(repSepProd.definition))],fullRepSepRest=repSepRest.concat(currRest,prevRest);return fullRepSepRest}var gast_public_1=__webpack_require__(7),utils_1=__webpack_require__(4),RestWalker=function(){function RestWalker(){}return RestWalker.prototype.walk=function(prod,prevRest){var _this=this;void 0===prevRest&&(prevRest=[]),utils_1.forEach(prod.definition,function(subProd,index){var currRest=utils_1.drop(prod.definition,index+1);if(subProd instanceof gast_public_1.gast.NonTerminal)_this.walkProdRef(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.Terminal)_this.walkTerminal(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.Flat)_this.walkFlat(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.Option)_this.walkOption(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.RepetitionMandatory)_this.walkAtLeastOne(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.RepetitionMandatoryWithSeparator)_this.walkAtLeastOneSep(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.RepetitionWithSeparator)_this.walkManySep(subProd,currRest,prevRest);else if(subProd instanceof gast_public_1.gast.Repetition)_this.walkMany(subProd,currRest,prevRest);else{if(!(subProd instanceof gast_public_1.gast.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 gast_public_1.gast.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 gast_public_1.gast.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);utils_1.forEach(orProd.definition,function(alt){var prodWrapper=new gast_public_1.gast.Flat([alt]);_this.walk(prodWrapper,fullOrRest)})},RestWalker}();exports.RestWalker=RestWalker},function(module,exports){exports.IN="_~IN~_"},function(module,exports,__webpack_require__){function buildLookaheadForTopLevel(rule){var restProd=new gast_public_1.gast.Flat(rule.definition),possibleTokTypes=first_1.first(restProd);return getSimpleLookahead(possibleTokTypes)}function buildLookaheadForOption(optionOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interpreter_1.NextInsideOptionWalker,optionOccurrence,ruleGrammar)}function buildLookaheadForMany(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interpreter_1.NextInsideManyWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForManySep(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interpreter_1.NextInsideManySepWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForAtLeastOne(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interpreter_1.NextInsideAtLeastOneWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForAtLeastOneSep(manyOccurrence,ruleGrammar){return buildLookAheadForGrammarProd(interpreter_1.NextInsideAtLeastOneSepWalker,manyOccurrence,ruleGrammar)}function buildLookaheadForOr(orOccurrence,ruleGrammar,ignoreAmbiguities){void 0===ignoreAmbiguities&&(ignoreAmbiguities=!1);var alternativesTokens=new interpreter_1.NextInsideOrWalker(ruleGrammar,orOccurrence).startWalking();ignoreAmbiguities||checkForOrAmbiguities(alternativesTokens,orOccurrence,ruleGrammar);var hasLastAnEmptyAlt=utils_1.isEmpty(utils_1.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 in inside <"+ruleGrammar.name+"> "+("Rule, <"+tokens_public_1.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=utils_1.flatten(alternativesTokens),uniqueTokensFlat=utils_1.uniq(allTokensFlat),tokensToAltsIndicesItAppearsIn=utils_1.map(uniqueTokensFlat,function(seekToken){var altsCurrTokenAppearsIn=utils_1.pick(alternativesTokens,function(altToLookIn){return utils_1.find(altToLookIn,function(currToken){return currToken===seekToken})}),altsIndicesTokenAppearsIn=utils_1.map(utils_1.keys(altsCurrTokenAppearsIn),function(index){return parseInt(index,10)+1});return{token:seekToken,alts:altsIndicesTokenAppearsIn}}),tokensToAltsIndicesWithAmbiguity=utils_1.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;jstart||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.startother.end},Range.prototype.isStrictlyContainedInRange=function(other){return other.strictlyContainsRange(this)},Range}();exports.Range=Range,exports.isValidRange=isValidRange},function(module,exports,__webpack_require__){function clearCache(){cache_1.clearCache()}var cache_1=__webpack_require__(2);exports.clearCache=clearCache}])}); \ No newline at end of file +/*! chevrotain - v0.5.16 - 2016-01-29 */ +!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()}(this,function(){return function(t){function __webpack_require__(n){if(e[n])return e[n].exports;var r=e[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}var e={};return __webpack_require__.m=t,__webpack_require__.c=e,__webpack_require__.p="",__webpack_require__(0)}([function(t,e,n){var r=n(1),i=n(11),o=n(10),a=n(5),s=n(7),c=n(21),u={};u.VERSION="0.5.16",u.Parser=r.Parser,u.Lexer=i.Lexer,u.Token=o.Token,u.VirtualToken=o.VirtualToken,u.EOF=o.EOF,u.extendToken=o.extendToken,u.tokenName=o.tokenName,u.EMPTY_ALT=r.EMPTY_ALT,u.exceptions={},u.exceptions.isRecognitionException=a.exceptions.isRecognitionException,u.exceptions.EarlyExitException=a.exceptions.EarlyExitException,u.exceptions.MismatchedTokenException=a.exceptions.MismatchedTokenException,u.exceptions.NotAllInputParsedException=a.exceptions.NotAllInputParsedException,u.exceptions.NoViableAltException=a.exceptions.NoViableAltException,u.gast={},u.gast.GAstVisitor=s.gast.GAstVisitor,u.gast.Flat=s.gast.Flat,u.gast.Repetition=s.gast.Repetition,u.gast.RepetitionWithSeparator=s.gast.RepetitionWithSeparator,u.gast.RepetitionMandatory=s.gast.RepetitionMandatory,u.gast.RepetitionMandatoryWithSeparator=s.gast.RepetitionMandatoryWithSeparator,u.gast.Option=s.gast.Option,u.gast.Alternation=s.gast.Alternation,u.gast.NonTerminal=s.gast.NonTerminal,u.gast.Terminal=s.gast.Terminal,u.gast.Rule=s.gast.Rule,u.clearCache=c.clearCache,t.exports=u},function(t,e,n){function EMPTY_ALT(t){return void 0===t&&(t=void 0),function(){return t}}function InRuleRecoveryException(t){this.name=o.functionName(InRuleRecoveryException),this.message=t}var r=n(2),i=n(5),o=n(3),a=n(6),s=n(8),c=n(4),u=n(14),l=n(10),p=n(17),f=n(19),h=n(18),d=n(16);!function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.DUPLICATE_PRODUCTIONS=2]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=3]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=4]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=5]="NONE_LAST_EMPTY_ALT"}(e.ParserDefinitionErrorType||(e.ParserDefinitionErrorType={}));e.ParserDefinitionErrorType;e.EMPTY_ALT=EMPTY_ALT;var E={},A=function(){function Parser(t,e,n){if(void 0===n&&(n=!0),this.errors=[],this._input=[],this.inputIdx=-1,this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.tokensMap=void 0,this.definedRulesNames=[],this._input=t,this.isErrorRecoveryEnabled=n,this.className=o.classNameFromInstance(this),this.firstAfterRepMap=r.getFirstAfterRepForClass(this.className),this.classLAFuncs=r.getLookaheadFuncsForClass(this.className),r.CLASS_TO_DEFINITION_ERRORS.containsKey(this.className)?this.definitionErrors=r.CLASS_TO_DEFINITION_ERRORS.get(this.className):(this.definitionErrors=[],r.CLASS_TO_DEFINITION_ERRORS.put(this.className,this.definitionErrors)),c.isArray(e))this.tokensMap=c.reduce(e,function(t,e){return t[l.tokenName(e)]=e,t},{});else{if(!c.isObject(e))throw new Error("'tokensMapOrArr' argument must be An Array of Token constructors or a Dictionary of Tokens.");this.tokensMap=c.cloneObj(e)}this.tokensMap[l.tokenName(l.EOF)]=l.EOF,void 0===r.CLASS_TO_OR_LA_CACHE[this.className]&&r.initLookAheadKeyCache(this.className),this.orLookaheadKeys=r.CLASS_TO_OR_LA_CACHE[this.className],this.manyLookaheadKeys=r.CLASS_TO_MANY_LA_CACHE[this.className],this.manySepLookaheadKeys=r.CLASS_TO_MANY_SEP_LA_CACHE[this.className],this.atLeastOneLookaheadKeys=r.CLASS_TO_AT_LEAST_ONE_LA_CACHE[this.className],this.atLeastOneSepLookaheadKeys=r.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[this.className],this.optionLookaheadKeys=r.CLASS_TO_OPTION_LA_CACHE[this.className]}return Parser.performSelfAnalysis=function(t){var e,n=[],i=o.classNameFromInstance(t);if(!r.CLASS_TO_SELF_ANALYSIS_DONE.containsKey(i)){var l=r.getProductionsForClass(i);n=r.CLASS_TO_DEFINITION_ERRORS.get(i);var p=a.resolveGrammar(l);n.push.apply(n,p),r.CLASS_TO_SELF_ANALYSIS_DONE.put(i,!0);var f=s.validateGrammar(l.values());if(n.push.apply(n,f),!c.isEmpty(n)&&!Parser.DEFER_DEFINITION_ERRORS_HANDLING)throw e=c.map(n,function(t){return t.message}),new Error("Parser Definition Errors detected\n: "+e.join("\n-------------------------------\n"));if(c.isEmpty(n)){var h=u.computeAllProdsFollows(l.values());r.setResyncFollowsForClass(i,h)}}if(!c.isEmpty(r.CLASS_TO_DEFINITION_ERRORS.get(i))&&!Parser.DEFER_DEFINITION_ERRORS_HANDLING)throw e=c.map(r.CLASS_TO_DEFINITION_ERRORS.get(i),function(t){return t.message}),new Error("Parser Definition Errors detected\n: "+e.join("\n-------------------------------\n"))},Object.defineProperty(Parser.prototype,"input",{get:function(){return c.cloneArr(this._input)},set:function(t){this.reset(),this._input=t},enumerable:!0,configurable:!0}),Parser.prototype.reset=function(){this.isBackTrackingStack=[],this.errors=[],this._input=[],this.inputIdx=-1,this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[]},Parser.prototype.isAtEndOfInput=function(){return this.LA(1)instanceof l.EOF},Parser.prototype.getGAstProductions=function(){return r.getProductionsForClass(this.className)},Parser.prototype.isBackTracking=function(){return!c.isEmpty(this.isBackTrackingStack)},Parser.prototype.SAVE_ERROR=function(t){if(i.exceptions.isRecognitionException(t))return this.errors.push(t),t;throw Error("trying to save an Error which is not a RecognitionException")},Parser.prototype.NEXT_TOKEN=function(){return this.LA(1)},Parser.prototype.LA=function(t){return this._input.length<=this.inputIdx+t?new l.EOF:this._input[this.inputIdx+t]},Parser.prototype.isNextRule=function(t){var e=r.getLookaheadFuncsForClass(this.className),n=e.get(t);if(void 0===n){var i=this.getGAstProductions().get(t);n=p.buildLookaheadForTopLevel(i),e.put(t,n)}return n.call(this)},Parser.prototype.BACKTRACK=function(t,e){var n=this;return function(){n.isBackTrackingStack.push(1);var r=n.saveRecogState();try{var o=t.call(n);return e(o)}catch(a){if(i.exceptions.isRecognitionException(a))return!1;throw a}finally{n.reloadRecogState(r),n.isBackTrackingStack.pop()}}},Parser.prototype.SKIP_TOKEN=function(){return this.inputIdx<=this._input.length-2?(this.inputIdx++,this.NEXT_TOKEN()):new l.EOF},Parser.prototype.CONSUME=function(t){return this.CONSUME1(t)},Parser.prototype.CONSUME1=function(t){return this.consumeInternal(t,1)},Parser.prototype.CONSUME2=function(t){return this.consumeInternal(t,2)},Parser.prototype.CONSUME3=function(t){return this.consumeInternal(t,3)},Parser.prototype.CONSUME4=function(t){return this.consumeInternal(t,4)},Parser.prototype.CONSUME5=function(t){return this.consumeInternal(t,5)},Parser.prototype.SUBRULE=function(t,e){return void 0===e&&(e=[]),this.SUBRULE1(t,e)},Parser.prototype.SUBRULE1=function(t,e){return void 0===e&&(e=[]),t.call(this,1,e)},Parser.prototype.SUBRULE2=function(t,e){return void 0===e&&(e=[]),t.call(this,2,e)},Parser.prototype.SUBRULE3=function(t,e){return void 0===e&&(e=[]),t.call(this,3,e)},Parser.prototype.SUBRULE4=function(t,e){return void 0===e&&(e=[]),t.call(this,4,e)},Parser.prototype.SUBRULE5=function(t,e){return void 0===e&&(e=[]),t.call(this,5,e)},Parser.prototype.OPTION=function(t,e){return this.OPTION1.call(this,t,e)},Parser.prototype.OPTION1=function(t,e){return void 0===e&&(e=t,t=this.getLookaheadFuncForOption(1)),this.optionInternal(t,e)},Parser.prototype.OPTION2=function(t,e){return void 0===e&&(e=t,t=this.getLookaheadFuncForOption(2)),this.optionInternal(t,e)},Parser.prototype.OPTION3=function(t,e){return void 0===e&&(e=t,t=this.getLookaheadFuncForOption(3)),this.optionInternal(t,e)},Parser.prototype.OPTION4=function(t,e){return void 0===e&&(e=t,t=this.getLookaheadFuncForOption(4)),this.optionInternal(t,e)},Parser.prototype.OPTION5=function(t,e){return void 0===e&&(e=t,t=this.getLookaheadFuncForOption(5)),this.optionInternal(t,e)},Parser.prototype.OR=function(t,e,n){return void 0===n&&(n=!1),this.OR1(t,e,n)},Parser.prototype.OR1=function(t,e,n){return void 0===n&&(n=!1),this.orInternal(t,e,1,n)},Parser.prototype.OR2=function(t,e,n){return void 0===n&&(n=!1),this.orInternal(t,e,2,n)},Parser.prototype.OR3=function(t,e,n){return void 0===n&&(n=!1),this.orInternal(t,e,3,n)},Parser.prototype.OR4=function(t,e,n){return void 0===n&&(n=!1),this.orInternal(t,e,4,n)},Parser.prototype.OR5=function(t,e,n){return void 0===n&&(n=!1),this.orInternal(t,e,5,n)},Parser.prototype.MANY=function(t,e){return this.MANY1.call(this,t,e)},Parser.prototype.MANY1=function(t,e){this.manyInternal(this.MANY1,"MANY1",1,t,e)},Parser.prototype.MANY2=function(t,e){this.manyInternal(this.MANY2,"MANY2",2,t,e)},Parser.prototype.MANY3=function(t,e){this.manyInternal(this.MANY3,"MANY3",3,t,e)},Parser.prototype.MANY4=function(t,e){this.manyInternal(this.MANY4,"MANY4",4,t,e)},Parser.prototype.MANY5=function(t,e){this.manyInternal(this.MANY5,"MANY5",5,t,e)},Parser.prototype.MANY_SEP=function(t,e,n){return this.MANY_SEP1.call(this,t,e,n)},Parser.prototype.MANY_SEP1=function(t,e,n){return this.manySepFirstInternal(this.MANY_SEP1,"MANY_SEP1",1,t,e,n)},Parser.prototype.MANY_SEP2=function(t,e,n){return this.manySepFirstInternal(this.MANY_SEP2,"MANY_SEP2",2,t,e,n)},Parser.prototype.MANY_SEP3=function(t,e,n){return this.manySepFirstInternal(this.MANY_SEP3,"MANY_SEP3",3,t,e,n)},Parser.prototype.MANY_SEP4=function(t,e,n){return this.manySepFirstInternal(this.MANY_SEP4,"MANY_SEP4",4,t,e,n)},Parser.prototype.MANY_SEP5=function(t,e,n){return this.manySepFirstInternal(this.MANY_SEP5,"MANY_SEP5",5,t,e,n)},Parser.prototype.AT_LEAST_ONE=function(t,e,n){return this.AT_LEAST_ONE1.call(this,t,e,n)},Parser.prototype.AT_LEAST_ONE1=function(t,e,n){this.atLeastOneInternal(this.AT_LEAST_ONE1,"AT_LEAST_ONE1",1,t,e,n)},Parser.prototype.AT_LEAST_ONE2=function(t,e,n){this.atLeastOneInternal(this.AT_LEAST_ONE2,"AT_LEAST_ONE2",2,t,e,n)},Parser.prototype.AT_LEAST_ONE3=function(t,e,n){this.atLeastOneInternal(this.AT_LEAST_ONE3,"AT_LEAST_ONE3",3,t,e,n)},Parser.prototype.AT_LEAST_ONE4=function(t,e,n){this.atLeastOneInternal(this.AT_LEAST_ONE4,"AT_LEAST_ONE4",4,t,e,n)},Parser.prototype.AT_LEAST_ONE5=function(t,e,n){this.atLeastOneInternal(this.AT_LEAST_ONE5,"AT_LEAST_ONE5",5,t,e,n)},Parser.prototype.AT_LEAST_ONE_SEP=function(t,e,n,r){return this.AT_LEAST_ONE_SEP1.call(this,t,e,n,r)},Parser.prototype.AT_LEAST_ONE_SEP1=function(t,e,n,r){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP1",1,t,e,n,r)},Parser.prototype.AT_LEAST_ONE_SEP2=function(t,e,n,r){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP2",2,t,e,n,r)},Parser.prototype.AT_LEAST_ONE_SEP3=function(t,e,n,r){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP3",3,t,e,n,r)},Parser.prototype.AT_LEAST_ONE_SEP4=function(t,e,n,r){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP4",4,t,e,n,r)},Parser.prototype.AT_LEAST_ONE_SEP5=function(t,e,n,r){return this.atLeastOneSepFirstInternal(this.atLeastOneSepFirstInternal,"AT_LEAST_ONE_SEP5",5,t,e,n,r)},Parser.prototype.RULE_NO_RESYNC=function(t,e,n){return this.RULE(t,e,n,!1)},Parser.prototype.RULE=function(t,e,n,o){void 0===n&&(n=this.defaultInvalidReturn),void 0===o&&(o=!0);var a=s.validateRuleName(t,this.definedRulesNames,this.className);this.definedRulesNames.push(t),this.definitionErrors.push.apply(this.definitionErrors,a);var c=r.getProductionsForClass(this.className);if(!c.containsKey(t)){var u=f.buildTopProduction(e.toString(),t,this.tokensMap);c.put(t,u)}var l=function(r,a){void 0===r&&(r=1),void 0===a&&(a=[]),this.ruleInvocationStateUpdate(t,r);try{return e.apply(this,a)}catch(s){var c=1===this.RULE_STACK.length,u=c||o&&!this.isBackTracking()&&this.isErrorRecoveryEnabled;if(u&&i.exceptions.isRecognitionException(s)){var l=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(l))return this.reSyncTo(l),n();throw s}throw s}finally{this.ruleFinallyStateUpdate()}},p="ruleName";return l[p]=t,l},Parser.prototype.ruleInvocationStateUpdate=function(t,e){this.RULE_OCCURRENCE_STACK.push(e),this.RULE_STACK.push(t)},Parser.prototype.ruleFinallyStateUpdate=function(){this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop();var t=this._input.length-1;if(0===this.RULE_STACK.length&&this.inputIdx"+p+"<-- but found -->'"+s.image+"'<--";return this.SAVE_ERROR(new i.exceptions.MismatchedTokenException(f,s)),void t.apply(this,e)}c instanceof o&&(u=!0),c=this.SKIP_TOKEN()}this.inputIdx=a},Parser.prototype.shouldInRepetitionRecoveryBeTried=function(t,e){return void 0===t||void 0===e?!1:this.NEXT_TOKEN()instanceof t?!1:this.isBackTracking()?!1:this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,e))?!1:!0},Parser.prototype.getFollowsForInRuleRecovery=function(t,e){var n=c.cloneArr(this.RULE_STACK),r=c.cloneArr(this.RULE_OCCURRENCE_STACK),i={ruleStack:n,occurrenceStack:r,lastTok:t,lastTokOccurrence:e},o=c.first(n),a=this.getGAstProductions(),s=a.get(o),u=new h.NextAfterTokenWalker(s,i).startWalking();return u},Parser.prototype.tryInRuleRecovery=function(t,e){if(this.canRecoverWithSingleTokenInsertion(t,e)){var n=this.getTokenToInsert(t);return n.isInsertedInRecovery=!0,n}if(this.canRecoverWithSingleTokenDeletion(t)){var r=this.SKIP_TOKEN();return this.inputIdx++,r}throw new InRuleRecoveryException("sad sad panda")},Parser.prototype.canPerformInRuleRecovery=function(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)},Parser.prototype.canRecoverWithSingleTokenInsertion=function(t,e){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(c.isEmpty(e))return!1;var n=this.NEXT_TOKEN(),r=void 0!==c.find(e,function(t){return n instanceof t});return r},Parser.prototype.canRecoverWithSingleTokenDeletion=function(t){var e=this.LA(2)instanceof t;return e},Parser.prototype.isInCurrentRuleReSyncSet=function(t){var e=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(e);return c.contains(n,t)},Parser.prototype.findReSyncTokenType=function(){for(var t=this.flattenFollowSet(),e=this.NEXT_TOKEN(),n=2;;){var r=e.constructor;if(c.contains(t,r))return r;e=this.LA(n),n++}},Parser.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return E;var t=this.RULE_STACK.length-1,e=t,n=t-1;return{ruleName:this.RULE_STACK[t],idxInCallingRule:this.RULE_OCCURRENCE_STACK[e],inRule:this.RULE_STACK[n]}},Parser.prototype.buildFullFollowKeyStack=function(){var t=this;return c.map(this.RULE_STACK,function(e,n){return 0===n?E:{ruleName:e,idxInCallingRule:t.RULE_OCCURRENCE_STACK[n],inRule:t.RULE_STACK[n-1]}})},Parser.prototype.flattenFollowSet=function(){var t=this,e=c.map(this.buildFullFollowKeyStack(),function(e){return t.getFollowSetFromFollowKey(e)});return c.flatten(e)},Parser.prototype.getFollowSetFromFollowKey=function(t){if(t===E)return[l.EOF];var e=t.ruleName+t.idxInCallingRule+d.IN+t.inRule;return r.getResyncFollowsForClass(this.className).get(e)},Parser.prototype.reSyncTo=function(t){for(var e=this.NEXT_TOKEN();e instanceof t==!1;)e=this.SKIP_TOKEN()},Parser.prototype.attemptInRepetitionRecovery=function(t,e,n,r,i,o,a){var s=this.getKeyForAutomaticLookahead(r,a,i),u=this.firstAfterRepMap.get(s);if(void 0===u){var p=c.last(this.RULE_STACK),f=this.getGAstProductions().get(p),h=new o(f,i);u=h.startWalking(),this.firstAfterRepMap.put(s,u)}var d=u.token,E=u.occurrence,A=u.isEndOfRule;1===this.RULE_STACK.length&&A&&void 0===d&&(d=l.EOF,E=1),this.shouldInRepetitionRecoveryBeTried(d,E)&&this.tryInRepetitionRecovery(t,e,n,d)},Parser.prototype.optionInternal=function(t,e){return t.call(this)?(e.call(this),!0):!1},Parser.prototype.atLeastOneInternal=function(t,e,n,r,o,a){if(c.isString(o)&&(a=o,o=r,r=this.getLookaheadFuncForAtLeastOne(n)),!r.call(this))throw this.SAVE_ERROR(new i.exceptions.EarlyExitException("expecting at least one: "+a,this.NEXT_TOKEN()));for(o.call(this);r.call(this);)o.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(t,[r,o,a],r,e,n,h.NextTerminalAfterAtLeastOneWalker,this.atLeastOneLookaheadKeys)},Parser.prototype.atLeastOneSepFirstInternal=function(t,e,n,r,o,a,s){var u=this,l=[];if(c.isString(a)&&(s=a,a=o,o=this.getLookaheadFuncForAtLeastOneSep(n)),!o.call(this))throw this.SAVE_ERROR(new i.exceptions.EarlyExitException("expecting at least one: "+s,this.NEXT_TOKEN()));a.call(this);for(var p=function(){return u.NEXT_TOKEN()instanceof r};p();)l.push(this.CONSUME(r)),a.call(this);return this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,r,p,a,l,this.atLeastOneSepLookaheadKeys,h.NextTerminalAfterAtLeastOneSepWalker],p,e,n,h.NextTerminalAfterAtLeastOneSepWalker,this.atLeastOneSepLookaheadKeys),l},Parser.prototype.manyInternal=function(t,e,n,r,i){for(void 0===i&&(i=r,r=this.getLookaheadFuncForMany(n));r.call(this);)i.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(t,[r,i],r,e,n,h.NextTerminalAfterManyWalker,this.manyLookaheadKeys)},Parser.prototype.manySepFirstInternal=function(t,e,n,r,i,o){var a=this,s=[];if(void 0===o&&(o=i,i=this.getLookaheadFuncForManySep(n)),i.call(this)){o.call(this);for(var c=function(){return a.NEXT_TOKEN()instanceof r};c();)s.push(this.CONSUME(r)),o.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,r,c,o,s,this.manySepLookaheadKeys,h.NextTerminalAfterManySepWalker],c,e,n,h.NextTerminalAfterManySepWalker,this.manySepLookaheadKeys)}return s},Parser.prototype.repetitionSepSecondInternal=function(t,e,n,r,i,o,a,s){for(;r();)o.push(this.CONSUME(n)),i.call(this);this.isErrorRecoveryEnabled&&this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,r,i,o,a,s],r,t,e,s,a)},Parser.prototype.orInternal=function(t,e,n,r){if(void 0!==t[0].WHEN){for(var i=0;i"+n+"<-- but found -->'"+e.image+"'<--";throw this.SAVE_ERROR(new i.exceptions.MismatchedTokenException(r,e))},Parser.prototype.getKeyForAutomaticLookahead=function(t,e,n){var r=e[n-1],i=c.last(this.RULE_STACK),o=r[i];return void 0===o&&(o=t+n+d.IN+i,r[i]=o),o},Parser.prototype.getLookaheadFuncForOption=function(t){var e=this.getKeyForAutomaticLookahead("OPTION",this.optionLookaheadKeys,t);return this.getLookaheadFuncFor(e,t,p.buildLookaheadForOption)},Parser.prototype.getLookaheadFuncForOr=function(t,e){var n=this.getKeyForAutomaticLookahead("OR",this.orLookaheadKeys,t);return this.getLookaheadFuncFor(n,t,p.buildLookaheadForOr,[e])},Parser.prototype.getLookaheadFuncForMany=function(t){var e=this.getKeyForAutomaticLookahead("MANY",this.manyLookaheadKeys,t);return this.getLookaheadFuncFor(e,t,p.buildLookaheadForMany)},Parser.prototype.getLookaheadFuncForManySep=function(t){var e=this.getKeyForAutomaticLookahead("MANY_SEP",this.manySepLookaheadKeys,t);return this.getLookaheadFuncFor(e,t,p.buildLookaheadForManySep)},Parser.prototype.getLookaheadFuncForAtLeastOne=function(t){var e=this.getKeyForAutomaticLookahead("AT_LEAST_ONE",this.atLeastOneLookaheadKeys,t);return this.getLookaheadFuncFor(e,t,p.buildLookaheadForAtLeastOne)},Parser.prototype.getLookaheadFuncForAtLeastOneSep=function(t){var e=this.getKeyForAutomaticLookahead("AT_LEAST_ONE_SEP",this.atLeastOneSepLookaheadKeys,t);return this.getLookaheadFuncFor(e,t,p.buildLookaheadForAtLeastOneSep)},Parser.prototype.getLookaheadFuncFor=function(t,e,n,r){void 0===r&&(r=[]);var i=c.last(this.RULE_STACK),o=this.classLAFuncs.get(t);if(void 0===o){var a=this.getGAstProductions().get(i);o=n.apply(null,[e,a].concat(r)),this.classLAFuncs.put(t,o)}return o},Parser.prototype.saveRecogState=function(){var t=c.cloneArr(this.errors),e=c.cloneArr(this.RULE_STACK);return{errors:t,inputIdx:this.inputIdx,RULE_STACK:e}},Parser.prototype.reloadRecogState=function(t){this.errors=t.errors,this.inputIdx=t.inputIdx,this.RULE_STACK=t.RULE_STACK},Parser.prototype.raiseNoAltException=function(t,e){var n=" but found: '"+this.NEXT_TOKEN().image+"'";if(void 0===e){var r=c.last(this.RULE_STACK),o=this.getGAstProductions().get(r),a=new h.NextInsideOrWalker(o,t).startWalking(),s=c.flatten(a),u=c.map(s,function(t){return l.tokenName(t)});e="one of: <"+u.join(" ,")+">"}throw this.SAVE_ERROR(new i.exceptions.NoViableAltException("expecting: "+e+" "+n,this.NEXT_TOKEN()))},Parser.IGNORE_AMBIGUITIES=!0,Parser.NO_RESYNC=!1,Parser.DEFER_DEFINITION_ERRORS_HANDLING=!1,Parser}();e.Parser=A,InRuleRecoveryException.prototype=Error.prototype},function(t,e,n){function getProductionsForClass(t){return getFromNestedHashTable(t,e.CLASS_TO_GRAMMAR_PRODUCTIONS)}function getResyncFollowsForClass(t){return getFromNestedHashTable(t,e.CLASS_TO_RESYNC_FOLLOW_SETS)}function setResyncFollowsForClass(t,n){e.CLASS_TO_RESYNC_FOLLOW_SETS.put(t,n)}function getLookaheadFuncsForClass(t){return getFromNestedHashTable(t,e.CLASS_TO_LOOKAHEAD_FUNCS)}function getFirstAfterRepForClass(t){return getFromNestedHashTable(t,e.CLASS_TO_FIRST_AFTER_REPETITION)}function initLookAheadKeyCache(t){e.CLASS_TO_OR_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),e.CLASS_TO_MANY_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),e.CLASS_TO_MANY_SEP_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),e.CLASS_TO_AT_LEAST_ONE_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),e.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),e.CLASS_TO_OPTION_LA_CACHE[t]=new Array(e.MAX_OCCURRENCE_INDEX),initSingleLookAheadKeyCache(e.CLASS_TO_OR_LA_CACHE[t]),initSingleLookAheadKeyCache(e.CLASS_TO_MANY_LA_CACHE[t]),initSingleLookAheadKeyCache(e.CLASS_TO_MANY_SEP_LA_CACHE[t]),initSingleLookAheadKeyCache(e.CLASS_TO_AT_LEAST_ONE_LA_CACHE[t]),initSingleLookAheadKeyCache(e.CLASS_TO_AT_LEAST_ONE_SEP_LA_CACHE[t]),initSingleLookAheadKeyCache(e.CLASS_TO_OPTION_LA_CACHE[t])}function initSingleLookAheadKeyCache(t){for(var n=0;n1}),c=i.map(i.values(a),function(e){var n=i.first(e),r=createDuplicatesErrorMessage(e,t.name),a=s.getProductionDslName(n),c={message:r,type:o.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:a,occurrence:n.occurrenceInParent},u=getExtraProductionArgument(n);return u&&(c.parameter=u),c});return c}function createDuplicatesErrorMessage(t,e){var n=i.first(t),r=n.occurrenceInParent,o=s.getProductionDslName(n),a=getExtraProductionArgument(n),c="->"+o+"<- with occurrence index: ->"+r+"<-\n "+(a?"and argument: "+a:"")+"\n appears more than once ("+t.length+" times) in the top level rule: "+e+".\n "+(1===r?"note that "+o+" and "+o+"1 both have the same occurrence index 1}":"")+"}\n to fix this make sure each usage of "+o+" "+(a?"with the argument: "+a:"")+"\n in the rule "+e+" has a different occurrence index (1-5), as that combination acts as a unique\n position key in the grammar, which is needed by the parsing engine.";return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n")}function identifyProductionForDuplicates(t){return s.getProductionDslName(t)+"_#_"+t.occurrenceInParent+"_#_"+getExtraProductionArgument(t)}function getExtraProductionArgument(t){return t instanceof a.gast.Terminal?c.tokenName(t.terminalType):t instanceof a.gast.NonTerminal?t.nonTerminalName:""}function validateRuleName(t,e,n){var r,a=[];return t.match(p)||(r="Invalid Grammar rule name --> "+t+" it must match the pattern: "+p.toString(),a.push({message:r,type:o.ParserDefinitionErrorType.INVALID_RULE_NAME,ruleName:t})),i.contains(e,t)&&(r="Duplicate definition, rule: "+t+" is already defined in the grammar: "+n,a.push({message:r,type:o.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:t})),a}function validateNoLeftRecursion(t,e,n){void 0===n&&(n=[]);var r=[],a=getFirstNoneTerminal(e.definition);if(i.isEmpty(a))return[];var s=t.name,c=i.contains(a,t),u=i.map(n,function(t){return t.name}),l=s+" --> "+u.concat([s]).join(" --> ");if(c){var p="Left Recursion found in grammar.\n"+("rule: <"+s+"> can be invoked from itself (directly or indirectly)\n")+("without consuming any Tokens. The grammar path that causes this is: \n "+l+"\n")+" To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.";r.push({message:p,type:o.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:s})}var f=i.difference(a,n.concat([t])),h=i.map(f,function(e){var r=i.cloneArr(n);return r.push(e),validateNoLeftRecursion(t,e,r)});return r.concat(i.flatten(h))}function getFirstNoneTerminal(t){var e=[];if(i.isEmpty(t))return e;var n=i.first(t);if(n instanceof a.gast.NonTerminal){if(void 0===n.referencedRule)return e;e.push(n.referencedRule)}else if(n instanceof a.gast.Flat||n instanceof a.gast.Option||n instanceof a.gast.RepetitionMandatory||n instanceof a.gast.RepetitionMandatoryWithSeparator||n instanceof a.gast.RepetitionWithSeparator||n instanceof a.gast.Repetition)e=e.concat(getFirstNoneTerminal(n.definition));else if(n instanceof a.gast.Alternation)e=i.flatten(i.map(n.definition,function(t){return getFirstNoneTerminal(t.definition)}));else if(!(n instanceof a.gast.Terminal))throw Error("non exhaustive match");var r=s.isOptionalProd(n),o=t.length>1;if(r&&o){var c=i.drop(t);return e.concat(getFirstNoneTerminal(c))}return e}function validateEmptyOrAlternative(t){var e=new f;t.accept(e);var n=e.alternations,r=i.reduce(n,function(e,n){var r=i.dropRight(n.definition),a=i.map(r,function(e,r){return i.isEmpty(u.first(e))?{message:"Ambiguous empty alternative: <"+(r+1)+">"+(" in inside <"+t.name+"> Rule.\n")+"Only the last alternative may be an empty alternative.",type:o.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:n.occurrenceInParent,alternative:r+1}:null});return e.concat(i.compact(a))},[]);return r}var r=this&&this.__extends||function(t,e){function __(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)},i=n(4),o=n(1),a=n(7),s=n(9),c=n(10),u=n(13);e.validateGrammar=validateGrammar,e.identifyProductionForDuplicates=identifyProductionForDuplicates;var l=function(t){function OccurrenceValidationCollector(){t.apply(this,arguments),this.allProductions=[]}return r(OccurrenceValidationCollector,t),OccurrenceValidationCollector.prototype.visitNonTerminal=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitOption=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitRepetition=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitAlternation=function(t){this.allProductions.push(t)},OccurrenceValidationCollector.prototype.visitTerminal=function(t){this.allProductions.push(t)},OccurrenceValidationCollector}(a.gast.GAstVisitor);e.OccurrenceValidationCollector=l;var p=/^[a-zA-Z_]\w*$/;e.validateRuleName=validateRuleName,e.validateNoLeftRecursion=validateNoLeftRecursion,e.getFirstNoneTerminal=getFirstNoneTerminal;var f=function(t){function OrCollector(){t.apply(this,arguments),this.alternations=[]}return r(OrCollector,t),OrCollector.prototype.visitAlternation=function(t){this.alternations.push(t)},OrCollector}(a.gast.GAstVisitor);e.validateEmptyOrAlternative=validateEmptyOrAlternative},function(t,e,n){function isSequenceProd(t){return t instanceof r.gast.Flat||t instanceof r.gast.Option||t instanceof r.gast.Repetition||t instanceof r.gast.RepetitionMandatory||t instanceof r.gast.RepetitionMandatoryWithSeparator||t instanceof r.gast.RepetitionWithSeparator||t instanceof r.gast.Terminal||t instanceof r.gast.Rule}function isOptionalProd(t,e){void 0===e&&(e=[]);var n=t instanceof r.gast.Option||t instanceof r.gast.Repetition||t instanceof r.gast.RepetitionWithSeparator;return n?!0:t instanceof r.gast.Alternation?i.some(t.definition,function(t){return isOptionalProd(t,e)}):t instanceof r.gast.NonTerminal&&i.contains(e,t)?!1:t instanceof r.gast.AbstractProduction?(t instanceof r.gast.NonTerminal&&e.push(t),i.every(t.definition,function(t){return isOptionalProd(t,e)})):!1}function isBranchingProd(t){return t instanceof r.gast.Alternation}function getProductionDslName(t){var e=t.constructor,n=o.functionName(e);return a[n]}var r=n(7),i=n(4),o=n(3);e.isSequenceProd=isSequenceProd,e.isOptionalProd=isOptionalProd,e.isBranchingProd=isBranchingProd;var a={};a[o.functionName(r.gast.NonTerminal)]="SUBRULE",a[o.functionName(r.gast.Option)]="OPTION",a[o.functionName(r.gast.RepetitionMandatory)]="AT_LEAST_ONE",a[o.functionName(r.gast.RepetitionMandatoryWithSeparator)]="AT_LEAST_ONE_SEP",a[o.functionName(r.gast.RepetitionWithSeparator)]="MANY_SEP",a[o.functionName(r.gast.Repetition)]="MANY",a[o.functionName(r.gast.Alternation)]="OR",a[o.functionName(r.gast.Terminal)]="CONSUME",e.getProductionDslName=getProductionDslName},function(t,e,n){function tokenName(t){return i.isString(t.tokenName)?t.tokenName:o.functionName(t)}function extendToken(t,e,n){void 0===e&&(e=void 0),void 0===n&&(n=s);var r;i.isRegExp(e)||e===a.Lexer.SKIPPED||e===a.Lexer.NA?r=e:i.isFunction(e)&&(n=e,r=void 0);var o=function(){n.apply(this,arguments)};return o=i.assign(o,n),o.tokenName=t,o.prototype=Object.create(n.prototype),o.prototype.constructor=o,i.isUndefined(r)||(o.PATTERN=r),o}var r=this&&this.__extends||function(t,e){function __(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)},i=n(4),o=n(3),a=n(11);e.tokenName=tokenName,e.extendToken=extendToken;var s=function(){function Token(t,e,n,r,i,o){void 0===i&&(i=n),void 0===o&&(o=r+t.length-1),this.image=t,this.offset=e,this.startLine=n,this.startColumn=r,this.endLine=i,this.endColumn=o,this.isInsertedInRecovery=!1}return Token}();e.Token=s;var c=function(t){function VirtualToken(){t.call(this,"",-1,-1,-1,-1,-1)}return r(VirtualToken,t),VirtualToken}(s);e.VirtualToken=c;var u=function(t){function EOF(){t.apply(this,arguments)}return r(EOF,t),EOF}(c);e.EOF=u},function(t,e,n){var r=n(12),i=n(4);!function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND"}(e.LexerDefinitionErrorType||(e.LexerDefinitionErrorType={}));var o=(e.LexerDefinitionErrorType,function(){function Lexer(t,e){if(void 0===e&&(e=!1),this.tokenClasses=t,this.lexerDefinitionErrors=[],this.lexerDefinitionErrors=r.validatePatterns(t),!i.isEmpty(this.lexerDefinitionErrors)&&!e){var n=i.map(this.lexerDefinitionErrors,function(t){return t.message}),o=n.join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+o)}if(i.isEmpty(this.lexerDefinitionErrors)){var a=r.analyzeTokenClasses(t);this.allPatterns=a.allPatterns,this.patternIdxToClass=a.patternIdxToClass,this.patternIdxToGroup=a.patternIdxToGroup,this.patternIdxToLongerAltIdx=a.patternIdxToLongerAltIdx,this.patternIdxToCanLineTerminator=a.patternIdxToCanLineTerminator,this.emptyGroups=a.emptyGroups}}return Lexer.prototype.tokenize=function(t){var e,n,o,a,s,c,u,l,p,f,h,d,E,A,T,y,O,N,R=t,_=0,g=[],m=[],v=1,S=1,P=i.cloneObj(this.emptyGroups);if(!i.isEmpty(this.lexerDefinitionErrors)){var L=i.map(this.lexerDefinitionErrors,function(t){return t.message}),k=L.join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+k)}for(;t.length>0;){for(e=null,n=0;ne[0].length&&(e=a,n=s));break}if(null!==e){if(c=e[0],u=c.length,l=this.patternIdxToGroup[n],void 0!==l&&(p=this.patternIdxToClass[n],f=new p(c,_,v,S),"default"===l?g.push(f):P[l].push(f)),t=t.slice(u),_+=u,S+=u,d=this.patternIdxToCanLineTerminator[n]){var I=r.countLineTerminators(c);if(0!==I){for(v+=I,y=u-1;y>=0&&(A=c.charCodeAt(y),13!==A&&10!==A);)y--;S=u-y,void 0!==l&&(N=y===u-1,E=N?-1:0,1===I&&N||(f.endLine=v+E,f.endColumn=S-1+-E))}}}else{for(var x=_,F=v,C=S,w=!1;!w&&t.length>0;)for(T=t.charCodeAt(0),10===T||13===T&&(1===t.length||t.length>1&&10!==t.charCodeAt(1))?(v++,S=1):S++,t=t.substr(1),_++,o=0;o"+R.charAt(x)+"<- at offset: "+x+","+(" skipped "+(_-x)+" characters."),m.push({line:F,column:C,length:h,message:O})}}return{tokens:g,groups:P,errors:m}},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}());e.Lexer=o},function(t,e,n){function analyzeTokenClasses(t){var e=o.reject(t,function(t){return t[a]===i.Lexer.NA}),n=o.map(e,function(t){return addStartOfInput(t[a])}),r=o.zipObject(n,e),s=o.map(n,function(t){return r[t.toString()]}),c=o.map(e,function(t){var e=t.GROUP;if(e!==i.Lexer.SKIPPED){if(o.isString(e))return e;if(o.isUndefined(e))return"default";throw Error("non exhaustive match")}}),u=o.map(e,function(t){var n=t.LONGER_ALT;if(n){var r=o.indexOf(e,n);return r}}),l=o.map(n,function(t){return/\\n|\\r|\\s/g.test(t.source)}),p=o.reduce(e,function(t,e){var n=e.GROUP;return o.isString(n)&&(t[n]=[]),t},{});return{allPatterns:n,patternIdxToClass:s,patternIdxToGroup:c,patternIdxToLongerAltIdx:u,patternIdxToCanLineTerminator:l,emptyGroups:p}}function validatePatterns(t){var e=[],n=findMissingPatterns(t),r=n.validTokenClasses;e=e.concat(n.errors);var i=findInvalidPatterns(r);return r=i.validTokenClasses,e=e.concat(i.errors),e=e.concat(findEndOfInputAnchor(r)),e=e.concat(findUnsupportedFlags(r)),e=e.concat(findDuplicatePatterns(r)),e=e.concat(findInvalidGroupType(r))}function findMissingPatterns(t){var e=o.filter(t,function(t){return!o.has(t,a)}),n=o.map(e,function(t){return{message:"Token class: ->"+r.tokenName(t)+"<- missing static 'PATTERN' property",type:i.LexerDefinitionErrorType.MISSING_PATTERN,tokenClasses:[t]}}),s=o.difference(t,e);return{errors:n,validTokenClasses:s}}function findInvalidPatterns(t){var e=o.filter(t,function(t){var e=t[a];return!o.isRegExp(e)}),n=o.map(e,function(t){return{message:"Token class: ->"+r.tokenName(t)+"<- static 'PATTERN' can only be a RegExp",type:i.LexerDefinitionErrorType.INVALID_PATTERN,tokenClasses:[t]}}),s=o.difference(t,e);return{errors:n,validTokenClasses:s}}function findEndOfInputAnchor(t){var e=o.filter(t,function(t){var e=t[a];return s.test(e.source)}),n=o.map(e,function(t){return{message:"Token class: ->"+r.tokenName(t)+"<- static 'PATTERN' cannot contain end of input anchor '$'",type:i.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenClasses:[t]}});return n}function findUnsupportedFlags(t){var e=o.filter(t,function(t){var e=t[a];return e instanceof RegExp&&(e.multiline||e.global)}),n=o.map(e,function(t){return{message:"Token class: ->"+r.tokenName(t)+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:i.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenClasses:[t]}});return n}function findDuplicatePatterns(t){var e=[],n=o.map(t,function(n){return o.reduce(t,function(t,r){return n.PATTERN.source!==r.PATTERN.source||o.contains(e,r)||r.PATTERN===i.Lexer.NA?t:(e.push(r),t.push(r),t)},[])});n=o.compact(n);var a=o.filter(n,function(t){return t.length>1}),s=o.map(a,function(t){var e=o.map(t,function(t){return r.tokenName(t)}),n=o.first(t).PATTERN;return{message:"The same RegExp pattern ->"+n+"<-"+("has been used in all the following classes: "+e.join(", ")+" <-"),type:i.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenClasses:t}});return s}function findInvalidGroupType(t){var e=o.filter(t,function(t){if(!o.has(t,"GROUP"))return!1;var e=t.GROUP;return e!==i.Lexer.SKIPPED&&e!==i.Lexer.NA&&!o.isString(e)}),n=o.map(e,function(t){return{message:"Token class: ->"+r.tokenName(t)+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:i.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenClasses:[t]}});return n}function addStartOfInput(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function countLineTerminators(t){for(var e=0,n=0;na,c=!0;s&&c;)e=r[a],c=i.isOptionalProd(e),n=n.concat(first(e)),a+=1,s=r.length>a;return o.uniq(n)}function firstForBranching(t){var e=o.map(t.definition,function(t){return first(t)});return o.uniq(o.flatten(e))}function firstForTerminal(t){return[t.terminalType]}var r=n(7),i=n(9),o=n(4);e.first=first,e.firstForSequence=firstForSequence,e.firstForBranching=firstForBranching,e.firstForTerminal=firstForTerminal},function(t,e,n){function computeAllProdsFollows(t){var e=new o.HashTable;return c.forEach(t,function(t){var n=new p(t).startWalking();e.putAll(n)}),e}function buildBetweenProdsFollowPrefix(t,e){return t.name+e+u.IN}function buildInProdFollowPrefix(t){var e=l.tokenName(t.terminalType);return e+t.occurrenceInParent+u.IN}var r=this&&this.__extends||function(t,e){function __(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)},i=n(15),o=n(3),a=n(7),s=n(13),c=n(4),u=n(16),l=n(10),p=function(t){function ResyncFollowsWalker(e){t.call(this),this.topProd=e,this.follows=new o.HashTable}return r(ResyncFollowsWalker,t),ResyncFollowsWalker.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},ResyncFollowsWalker.prototype.walkTerminal=function(t,e,n){},ResyncFollowsWalker.prototype.walkProdRef=function(t,e,n){var r=buildBetweenProdsFollowPrefix(t.referencedRule,t.occurrenceInParent)+this.topProd.name,i=e.concat(n),o=new a.gast.Flat(i),c=s.first(o);this.follows.put(r,c)},ResyncFollowsWalker}(i.RestWalker);e.ResyncFollowsWalker=p,e.computeAllProdsFollows=computeAllProdsFollows,e.buildBetweenProdsFollowPrefix=buildBetweenProdsFollowPrefix,e.buildInProdFollowPrefix=buildInProdFollowPrefix},function(t,e,n){function restForRepetitionWithSeparator(t,e,n){var i=[new r.gast.Option([new r.gast.Terminal(t.separator)].concat(t.definition))],o=i.concat(e,n);return o}var r=n(7),i=n(4),o=function(){function RestWalker(){}return RestWalker.prototype.walk=function(t,e){var n=this;void 0===e&&(e=[]),i.forEach(t.definition,function(o,a){var s=i.drop(t.definition,a+1);if(o instanceof r.gast.NonTerminal)n.walkProdRef(o,s,e);else if(o instanceof r.gast.Terminal)n.walkTerminal(o,s,e);else if(o instanceof r.gast.Flat)n.walkFlat(o,s,e);else if(o instanceof r.gast.Option)n.walkOption(o,s,e);else if(o instanceof r.gast.RepetitionMandatory)n.walkAtLeastOne(o,s,e);else if(o instanceof r.gast.RepetitionMandatoryWithSeparator)n.walkAtLeastOneSep(o,s,e);else if(o instanceof r.gast.RepetitionWithSeparator)n.walkManySep(o,s,e);else if(o instanceof r.gast.Repetition)n.walkMany(o,s,e);else{if(!(o instanceof r.gast.Alternation))throw Error("non exhaustive match");n.walkOr(o,s,e)}})},RestWalker.prototype.walkTerminal=function(t,e,n){},RestWalker.prototype.walkProdRef=function(t,e,n){},RestWalker.prototype.walkFlat=function(t,e,n){var r=e.concat(n);this.walk(t,r)},RestWalker.prototype.walkOption=function(t,e,n){var r=e.concat(n);this.walk(t,r)},RestWalker.prototype.walkAtLeastOne=function(t,e,n){var i=[new r.gast.Option(t.definition)].concat(e,n);this.walk(t,i)},RestWalker.prototype.walkAtLeastOneSep=function(t,e,n){var r=restForRepetitionWithSeparator(t,e,n);this.walk(t,r)},RestWalker.prototype.walkMany=function(t,e,n){var i=[new r.gast.Option(t.definition)].concat(e,n);this.walk(t,i)},RestWalker.prototype.walkManySep=function(t,e,n){var r=restForRepetitionWithSeparator(t,e,n);this.walk(t,r)},RestWalker.prototype.walkOr=function(t,e,n){var o=this,a=e.concat(n);i.forEach(t.definition,function(t){var e=new r.gast.Flat([t]);o.walk(e,a)})},RestWalker}();e.RestWalker=o},function(t,e){e.IN="_~IN~_"},function(t,e,n){function buildLookaheadForTopLevel(t){var e=new r.gast.Flat(t.definition),n=i.first(e);return getSimpleLookahead(n)}function buildLookaheadForOption(t,e){return buildLookAheadForGrammarProd(o.NextInsideOptionWalker,t,e)}function buildLookaheadForMany(t,e){return buildLookAheadForGrammarProd(o.NextInsideManyWalker,t,e)}function buildLookaheadForManySep(t,e){return buildLookAheadForGrammarProd(o.NextInsideManySepWalker,t,e)}function buildLookaheadForAtLeastOne(t,e){return buildLookAheadForGrammarProd(o.NextInsideAtLeastOneWalker,t,e)}function buildLookaheadForAtLeastOneSep(t,e){return buildLookAheadForGrammarProd(o.NextInsideAtLeastOneSepWalker,t,e)}function buildLookaheadForOr(t,e,n){void 0===n&&(n=!1);var r=new o.NextInsideOrWalker(e,t).startWalking();n||checkForOrAmbiguities(r,t,e);var i=a.isEmpty(a.last(r));if(i){var s=r.length-1;return function(){for(var t=this.NEXT_TOKEN(),e=0;s>e;e++)for(var n=r[e],i=0;i in inside <"+n.name+"> "+("Rule, <"+s.tokenName(t.token)+"> may appears as the first Terminal in all these alternatives.\n")});throw new Error(i.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(t){var e=a.flatten(t),n=a.uniq(e),r=a.map(n,function(e){var n=a.pick(t,function(t){return a.find(t,function(t){return t===e})}),r=a.map(a.keys(n),function(t){return parseInt(t,10)+1});return{token:e,alts:r}}),i=a.filter(r,function(t){return t.alts.length>1});return i}function buildLookAheadForGrammarProd(t,e,n){var r={ruleStack:[n.name],occurrenceStack:[1],occurrence:e},i=new t(n,r),o=i.startWalking();return getSimpleLookahead(o)}function getSimpleLookahead(t){return function(){for(var e=this.NEXT_TOKEN(),n=0;nt||t>e)}var n=function(){function Range(t,e){if(this.start=t,this.end=e,!isValidRange(t,e))throw new Error("INVALID RANGE")}return Range.prototype.contains=function(t){return this.start<=t&&this.end>=t},Range.prototype.containsRange=function(t){return this.start<=t.start&&this.end>=t.end},Range.prototype.isContainedInRange=function(t){return t.containsRange(this)},Range.prototype.strictlyContainsRange=function(t){return this.startt.end},Range.prototype.isStrictlyContainedInRange=function(t){return t.strictlyContainsRange(this)},Range}();e.Range=n,e.isValidRange=isValidRange},function(t,e,n){function clearCache(){r.clearCache()}var r=n(2);e.clearCache=clearCache}])}); \ No newline at end of file diff --git a/src/api.ts b/src/api.ts index c79926425..2dc86b2df 100644 --- a/src/api.ts +++ b/src/api.ts @@ -12,7 +12,7 @@ import {clearCache} from "./parse/cache_public" let API:any = {} // semantic version -API.VERSION = "0.5.15" +API.VERSION = "0.5.16" // runtime API API.Parser = Parser