{"action":"created","issue":{"url":"https://api.github.com/repos/SAP/chevrotain/issues/296","repository_url":"https://api.github.com/repos/SAP/chevrotain","labels_url":"https://api.github.com/repos/SAP/chevrotain/issues/296/labels{/name}","comments_url":"https://api.github.com/repos/SAP/chevrotain/issues/296/comments","events_url":"https://api.github.com/repos/SAP/chevrotain/issues/296/events","html_url":"https://github.com/SAP/chevrotain/issues/296","id":187142112,"number":296,"title":"GATE parser rules in thrown errors messages","user":{"login":"Zumbala","id":7052083,"avatar_url":"https://avatars.githubusercontent.com/u/7052083?v=3","gravatar_id":"","url":"https://api.github.com/users/Zumbala","html_url":"https://github.com/Zumbala","followers_url":"https://api.github.com/users/Zumbala/followers","following_url":"https://api.github.com/users/Zumbala/following{/other_user}","gists_url":"https://api.github.com/users/Zumbala/gists{/gist_id}","starred_url":"https://api.github.com/users/Zumbala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zumbala/subscriptions","organizations_url":"https://api.github.com/users/Zumbala/orgs","repos_url":"https://api.github.com/users/Zumbala/repos","events_url":"https://api.github.com/users/Zumbala/events{/privacy}","received_events_url":"https://api.github.com/users/Zumbala/received_events","type":"User","site_admin":false},"labels":[{"id":200144683,"url":"https://api.github.com/repos/SAP/chevrotain/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-03T17:47:19Z","updated_at":"2016-11-03T19:51:46Z","closed_at":null,"body":"I want to have the parser throw an error when a certain TOKEN is used more than once.\r\nFor that I have created a GATE surrounding rule function.\r\n\r\neg: **string**,number,object,**string** <- should trigger an error, which it does\r\n\r\n[{\"name\":\"NoViableAltException\",\"message\":\"Expecting: one of these possible Token sequences:\\n  <['number'] ,**_['string']_** ,['null'] ,['integer'] ,['boolean']>  but found: **_'string'_**\",\"token\":{\"image\":\"string\",\"startOffset\":200,\"startLine\":18,\"startColumn\":27,\"endLine\":18,\"endColumn\":32,\"isInsertedInRecovery\":false},\"resyncedTokens\":[],\"context\":{\"ruleStack\":[\"start\",\"definitions\",\"type\",\"types_in\",\"in_types\"]\r\n\r\nSo when a gate is closed, TOKEN already used, it should not be in the possible list of Token sequences.\r\nThus not confusing the user with an error that makes no sence.\r\n\r\nIs it possible to do so?\r\nShould I do it like this or at compile time?\r\nPlease advise.\r\n\r\nbelow a part of the code:\r\n\r\n    function GATE(rule) {\r\n       var data = {};\r\n       rule.GATEGET = function (nr) { return function () { \r\n         return !data[nr]; \r\n       }; };\r\n       rule.GATESET = function (nr,value) { \r\n         data[nr] = 1; return value; \r\n       };\r\n       rule.GATES = function () { data = {}; };\r\n       return rule;\r\n     }\r\n\r\n    $.in_types = GATE($.RULE(\"in_types\",function () {\r\n      return $.OR([\r\n        { GATE : $.in_types.GATEGET(0),ALT : function () { return $.in_types.GATESET(0,VALUE($.CONSUME(TOKENS.number))); }},\r\n        { GATE : $.in_types.GATEGET(1),ALT : function () { return $.in_types.GATESET(1,VALUE($.CONSUME(TOKENS.string))); }},\r\n        { GATE : $.in_types.GATEGET(2),ALT : function () { return $.in_types.GATESET(2,VALUE($.CONSUME(TOKENS.null))); }},\r\n        { GATE : $.in_types.GATEGET(3),ALT : function () { return $.in_types.GATESET(3,VALUE($.CONSUME(TOKENS.integer))); }},\r\n        { GATE : $.in_types.GATEGET(4),ALT : function () { return $.in_types.GATESET(4,VALUE($.CONSUME(TOKENS.boolean))); }}\r\n      ]);\r\n    }));\r\n\r\n    $.types_in = $.RULE(\"types_in\",function () {\r\n      return (function(result) { \r\n                  result = $.OR([\r\n                    { ALT : function () { return VALUE($.CONSUME(TOKENS.ASTERISK)); }},\r\n                    { ALT : function () { return $.SUBRULE($.out_type_array); }},\r\n                    { ALT : function () { return VALUE($.CONSUME(TOKENS.object)); }},\r\n                    { ALT : function () { \r\n                      AST(result,null);\r\n                      $.in_types.GATES(); // CLEAR the used GATES\r\n                      AST(result,$.SUBRULE1($.in_types));\r\n                      $.MANY(function () {\r\n                        $.CONSUME(TOKENS.COMMA);\r\n                        AST(result,$.SUBRULE2($.in_types));                    \r\n                      });\r\n                      return AST(result);\r\n                    }}\r\n                  ]);\r\n                  return result;\r\n              })(\"in\");\r\n    });\r\n"},"comment":{"url":"https://api.github.com/repos/SAP/chevrotain/issues/comments/258254656","html_url":"https://github.com/SAP/chevrotain/issues/296#issuecomment-258254656","issue_url":"https://api.github.com/repos/SAP/chevrotain/issues/296","id":258254656,"user":{"login":"Zumbala","id":7052083,"avatar_url":"https://avatars.githubusercontent.com/u/7052083?v=3","gravatar_id":"","url":"https://api.github.com/users/Zumbala","html_url":"https://github.com/Zumbala","followers_url":"https://api.github.com/users/Zumbala/followers","following_url":"https://api.github.com/users/Zumbala/following{/other_user}","gists_url":"https://api.github.com/users/Zumbala/gists{/gist_id}","starred_url":"https://api.github.com/users/Zumbala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zumbala/subscriptions","organizations_url":"https://api.github.com/users/Zumbala/orgs","repos_url":"https://api.github.com/users/Zumbala/repos","events_url":"https://api.github.com/users/Zumbala/events{/privacy}","received_events_url":"https://api.github.com/users/Zumbala/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T19:51:46Z","updated_at":"2016-11-03T19:51:46Z","body":"In your example you use a mood argument, how is this filled with the value \"positive\" or \"negative\".\r\n\r\nI tried this format to determine an errorMessage, but mine argument is always undefined"}}
{"actor":{"display_login":"Zumbala"}}