{"action":"created","issue":{"url":"https://api.github.com/repos/pegjs/pegjs/issues/565","repository_url":"https://api.github.com/repos/pegjs/pegjs","labels_url":"https://api.github.com/repos/pegjs/pegjs/issues/565/labels{/name}","comments_url":"https://api.github.com/repos/pegjs/pegjs/issues/565/comments","events_url":"https://api.github.com/repos/pegjs/pegjs/issues/565/events","html_url":"https://github.com/pegjs/pegjs/issues/565","id":300262694,"number":565,"title":"Parametrized text separator","user":{"login":"xduseko","id":9591957,"avatar_url":"https://avatars3.githubusercontent.com/u/9591957?v=4","gravatar_id":"","url":"https://api.github.com/users/xduseko","html_url":"https://github.com/xduseko","followers_url":"https://api.github.com/users/xduseko/followers","following_url":"https://api.github.com/users/xduseko/following{/other_user}","gists_url":"https://api.github.com/users/xduseko/gists{/gist_id}","starred_url":"https://api.github.com/users/xduseko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xduseko/subscriptions","organizations_url":"https://api.github.com/users/xduseko/orgs","repos_url":"https://api.github.com/users/xduseko/repos","events_url":"https://api.github.com/users/xduseko/events{/privacy}","received_events_url":"https://api.github.com/users/xduseko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-26T14:39:05Z","updated_at":"2018-02-26T17:01:08Z","closed_at":null,"author_association":"NONE","body":"### Issue type\r\n\r\n- **Question**\r\n\r\n### Description\r\n\r\nIs it possible to create parameterized text separator passed through options?\r\n\r\nConsider example grammar:\r\n```\r\nLiterals\r\n  = string1:Literal strings:(Separator Literal)* {\r\n    return strings.reduce(function(array, record) {\r\n      return array.concat(record[1]);\r\n    }, [string1]);\r\n  }\r\n\r\nLiteral\r\n  = char:(!Separator Character)+ {\r\n    return char\r\n      .map(function(x) {\r\n        return x[1];\r\n      })\r\n      .join('');\r\n  }\r\n\r\nSeparator\r\n  = \"--\"\r\n\r\nCharacter\r\n  = .\r\n```\r\n\r\nThere is `Separator` that have to be excluded from `Literal`. I would like to have it configurable.\r\n\r\nI have managed to read it from options, but I don't know how to consume variable character length. Example bellow is working for every separator composed from 2 characters. But what if someone pass 3 characters?\r\n\r\n```\r\n{\r\n  options.separator = options.separator || '--';\r\n}\r\n\r\nLiterals\r\n  = string1:Literal strings:(Separator Literal)* {\r\n    return strings.reduce(function(array, record) {\r\n      return array.concat(record[1]);\r\n    }, [string1]);\r\n  }\r\n\r\nLiteral\r\n  = char:(!Separator Character)+ {\r\n    return char\r\n      .map(function(x) {\r\n        return x[1];\r\n      })\r\n      .join('');\r\n  }\r\n\r\nSeparator\r\n  = chars:(. .) & {\r\n    return chars.join('') === options.separator;\r\n  }\r\n\r\nCharacter\r\n  = .\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pegjs/pegjs/issues/comments/368572119","html_url":"https://github.com/pegjs/pegjs/issues/565#issuecomment-368572119","issue_url":"https://api.github.com/repos/pegjs/pegjs/issues/565","id":368572119,"user":{"login":"Mingun","id":450131,"avatar_url":"https://avatars0.githubusercontent.com/u/450131?v=4","gravatar_id":"","url":"https://api.github.com/users/Mingun","html_url":"https://github.com/Mingun","followers_url":"https://api.github.com/users/Mingun/followers","following_url":"https://api.github.com/users/Mingun/following{/other_user}","gists_url":"https://api.github.com/users/Mingun/gists{/gist_id}","starred_url":"https://api.github.com/users/Mingun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mingun/subscriptions","organizations_url":"https://api.github.com/users/Mingun/orgs","repos_url":"https://api.github.com/users/Mingun/repos","events_url":"https://api.github.com/users/Mingun/events{/privacy}","received_events_url":"https://api.github.com/users/Mingun/received_events","type":"User","site_admin":false},"created_at":"2018-02-26T17:01:08Z","updated_at":"2018-02-26T17:01:08Z","author_association":"CONTRIBUTOR","body":"No it is possible, just more boilerplate. You can implement range in current terms, something like:\r\n```\r\n{let count = ...;}\r\nList = $(. &{ return count-->0; })\r\n```\r\nbut do not forget about backtraking."}}
{"actor":{"display_login":"Mingun"}}