{"action":"created","issue":{"url":"https://api.github.com/repos/kach/nearley/issues/371","repository_url":"https://api.github.com/repos/kach/nearley","labels_url":"https://api.github.com/repos/kach/nearley/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/kach/nearley/issues/371/comments","events_url":"https://api.github.com/repos/kach/nearley/issues/371/events","html_url":"https://github.com/kach/nearley/issues/371","id":315108307,"number":371,"title":"Unexpected ident when using generated grammar within js script","user":{"login":"raphaelchenouard","id":883882,"avatar_url":"https://avatars2.githubusercontent.com/u/883882?v=4","gravatar_id":"","url":"https://api.github.com/users/raphaelchenouard","html_url":"https://github.com/raphaelchenouard","followers_url":"https://api.github.com/users/raphaelchenouard/followers","following_url":"https://api.github.com/users/raphaelchenouard/following{/other_user}","gists_url":"https://api.github.com/users/raphaelchenouard/gists{/gist_id}","starred_url":"https://api.github.com/users/raphaelchenouard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphaelchenouard/subscriptions","organizations_url":"https://api.github.com/users/raphaelchenouard/orgs","repos_url":"https://api.github.com/users/raphaelchenouard/repos","events_url":"https://api.github.com/users/raphaelchenouard/events{/privacy}","received_events_url":"https://api.github.com/users/raphaelchenouard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-17T15:17:24Z","updated_at":"2018-04-18T10:28:36Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI'm trying to use nearley to make a parser for an existing language, but I got an error (Unexpected ident token). I don't see what I'm doing wrong. I built a simple example showing the problem (see attached files below). I just want \"hello\" to be optional before \"world\", so I use \":?\" ebnf operator.\r\n\r\nUsing nearley-test (`nearley-test -q hello_world.js -i \"world\"`) give the expected result:\r\n`[ [ null,\r\n    [ { type: 'world',\r\n        value: 'world',\r\n        text: 'world',\r\n        toString: [Function: tokenToString],\r\n        offset: 0,\r\n        lineBreaks: 0,\r\n        line: 1,\r\n        col: 1 } ] ] ]`\r\n\r\nBut when I use helloworld.js in a javascript file (`node main_hw.js`), it works for \"hello world\", but it gives the error `Unexpected ident token: \"world\"`when feeding the parser with string \"world\". I use Moo, but I have the same problem if I change the grammar to work without any lexer (`Unexpected ident token: \"w\"`).\r\n\r\nI'm using:\r\n- node v9.11.1\r\n- nearley 2.11.0\r\n- moo 0.4.3\r\n\r\nHere is my simple code: \r\n[Archive.zip](https://github.com/kach/nearley/files/1920440/Archive.zip)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/kach/nearley/issues/comments/382341326","html_url":"https://github.com/kach/nearley/issues/371#issuecomment-382341326","issue_url":"https://api.github.com/repos/kach/nearley/issues/371","id":382341326,"user":{"login":"raphaelchenouard","id":883882,"avatar_url":"https://avatars2.githubusercontent.com/u/883882?v=4","gravatar_id":"","url":"https://api.github.com/users/raphaelchenouard","html_url":"https://github.com/raphaelchenouard","followers_url":"https://api.github.com/users/raphaelchenouard/followers","following_url":"https://api.github.com/users/raphaelchenouard/following{/other_user}","gists_url":"https://api.github.com/users/raphaelchenouard/gists{/gist_id}","starred_url":"https://api.github.com/users/raphaelchenouard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphaelchenouard/subscriptions","organizations_url":"https://api.github.com/users/raphaelchenouard/orgs","repos_url":"https://api.github.com/users/raphaelchenouard/repos","events_url":"https://api.github.com/users/raphaelchenouard/events{/privacy}","received_events_url":"https://api.github.com/users/raphaelchenouard/received_events","type":"User","site_admin":false},"created_at":"2018-04-18T10:28:36Z","updated_at":"2018-04-18T10:28:36Z","author_association":"NONE","body":"With my DSL grammar, I get this error too with nodejs, but when running the grammar inside a web browser it works as expected (like with nearley-test)."}}
{"actor":{"display_login":"raphaelchenouard"}}