{"action":"created","issue":{"url":"https://api.github.com/repos/jneen/parsimmon/issues/224","repository_url":"https://api.github.com/repos/jneen/parsimmon","labels_url":"https://api.github.com/repos/jneen/parsimmon/issues/224/labels{/name}","comments_url":"https://api.github.com/repos/jneen/parsimmon/issues/224/comments","events_url":"https://api.github.com/repos/jneen/parsimmon/issues/224/events","html_url":"https://github.com/jneen/parsimmon/issues/224","id":293203525,"number":224,"title":"Loosen parse input constraint.","user":{"login":"theqabalist","id":2925113,"avatar_url":"https://avatars3.githubusercontent.com/u/2925113?v=4","gravatar_id":"","url":"https://api.github.com/users/theqabalist","html_url":"https://github.com/theqabalist","followers_url":"https://api.github.com/users/theqabalist/followers","following_url":"https://api.github.com/users/theqabalist/following{/other_user}","gists_url":"https://api.github.com/users/theqabalist/gists{/gist_id}","starred_url":"https://api.github.com/users/theqabalist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theqabalist/subscriptions","organizations_url":"https://api.github.com/users/theqabalist/orgs","repos_url":"https://api.github.com/users/theqabalist/repos","events_url":"https://api.github.com/users/theqabalist/events{/privacy}","received_events_url":"https://api.github.com/users/theqabalist/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-01-31T15:37:30Z","updated_at":"2018-02-02T13:44:04Z","closed_at":null,"author_association":"NONE","body":"Would it be possible to loosen the parse constraint to include arrays and buffers so that Parsimmon can be used for more generalized parsing? I have used it for several things before but I am needing to reimplement a proprietary binary protocol stored in a buffer. Best I can tell, the library will just work assuming the introduction of a few byte oriented primitives I have written.  But the constraint to strings specifically stops me from using an unforked version currently."},"comment":{"url":"https://api.github.com/repos/jneen/parsimmon/issues/comments/362589896","html_url":"https://github.com/jneen/parsimmon/issues/224#issuecomment-362589896","issue_url":"https://api.github.com/repos/jneen/parsimmon/issues/224","id":362589896,"user":{"login":"theqabalist","id":2925113,"avatar_url":"https://avatars3.githubusercontent.com/u/2925113?v=4","gravatar_id":"","url":"https://api.github.com/users/theqabalist","html_url":"https://github.com/theqabalist","followers_url":"https://api.github.com/users/theqabalist/followers","following_url":"https://api.github.com/users/theqabalist/following{/other_user}","gists_url":"https://api.github.com/users/theqabalist/gists{/gist_id}","starred_url":"https://api.github.com/users/theqabalist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theqabalist/subscriptions","organizations_url":"https://api.github.com/users/theqabalist/orgs","repos_url":"https://api.github.com/users/theqabalist/repos","events_url":"https://api.github.com/users/theqabalist/events{/privacy}","received_events_url":"https://api.github.com/users/theqabalist/received_events","type":"User","site_admin":false},"created_at":"2018-02-02T13:44:04Z","updated_at":"2018-02-02T13:44:04Z","author_association":"NONE","body":"So I have built a decent size parser that seems to work thus far with the changes you have made.  The only thing I have needed to implement was a uintBE parser, which I implemented as follows.\r\n\r\n```javascript\r\nconst uintBE = n => new Parsimmon((input, i) => {\r\n    if (!Buffer.isBuffer(input)) {\r\n        throw new Error('Input is not a buffer.');\r\n    }\r\n    if (i + n >= input.length) {\r\n        return Parsimmon.makeFailure(i, `${n} bytes`);\r\n    }\r\n    return Parsimmon.makeSuccess(i + n, input.readUIntBE(i, n));\r\n});\r\n```\r\nIt's important to note here that node is not capable of reading more than 6 bytes from a buffer into an int, so if you need a bigger integer, or whatever, you have to handle it differently (we have a 96 bit flag value, for example).\r\n\r\nOther than that, I have been able to get by with the primitives `any` and `all`, and the combinators.  One other constructor that may be of use is a byte range constructor like byteRange([0x40, 0x80]), which also came up, but I handled a different way.  It can also be handled by Parsimmon.test technically I think."}}
{"actor":{"display_login":"theqabalist"}}