{"action":"created","issue":{"url":"https://api.github.com/repos/pegjs/pegjs/issues/411","labels_url":"https://api.github.com/repos/pegjs/pegjs/issues/411/labels{/name}","comments_url":"https://api.github.com/repos/pegjs/pegjs/issues/411/comments","events_url":"https://api.github.com/repos/pegjs/pegjs/issues/411/events","html_url":"https://github.com/pegjs/pegjs/issues/411","id":128830576,"number":411,"title":"Parse errors should build up a stack trace","user":{"login":"silkentrance","id":6068824,"avatar_url":"https://avatars.githubusercontent.com/u/6068824?v=3","gravatar_id":"","url":"https://api.github.com/users/silkentrance","html_url":"https://github.com/silkentrance","followers_url":"https://api.github.com/users/silkentrance/followers","following_url":"https://api.github.com/users/silkentrance/following{/other_user}","gists_url":"https://api.github.com/users/silkentrance/gists{/gist_id}","starred_url":"https://api.github.com/users/silkentrance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silkentrance/subscriptions","organizations_url":"https://api.github.com/users/silkentrance/orgs","repos_url":"https://api.github.com/users/silkentrance/repos","events_url":"https://api.github.com/users/silkentrance/events{/privacy}","received_events_url":"https://api.github.com/users/silkentrance/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-26T14:10:35Z","updated_at":"2016-01-26T17:07:25Z","closed_at":null,"body":"This would be a follow up to #262.\r\n\r\nGiven the top level symbols in the grammar shown in #410, I would like the parser to be able to report that for example the ``Translation`` symbol could not be found instead of reporting something like ``Expected ws or nl but found eof``.\r\n\r\nWhile at the same time it should be possible to have the parser report syntax errors on sub level symbols such as TranslationId and so on.\r\n\r\nThe reasoning here being that parse errors found at the sub level should bubble up, given you a stack trace of failed symbol matches rather than just that of the top level symbol.\r\n\r\nE.g. given the following input and the grammar from #410 \r\n\r\n```\r\n#= lang en-US\r\n#!\r\n```\r\n\r\nthis should report that a ``translation`` was missing, provided that the top level symbol ``Translation`` had been labelled, and that it was caused by the translation id being malformed, e..g\r\n\r\n```\r\nSyntaxError: translation missing\r\ncaused by\r\nSyntaxError: malformed translation id\r\n```\r\n\r\nWhereas\r\n\r\n```\r\n#= lang en-US\r\n```\r\n\r\nshould report that a ``translation`` is missing and not that either '#' or '!' or whatever basic literal was expected.\r\n\r\nWhat about that for a valid use case?\r\n"},"comment":{"url":"https://api.github.com/repos/pegjs/pegjs/issues/comments/175120343","html_url":"https://github.com/pegjs/pegjs/issues/411#issuecomment-175120343","issue_url":"https://api.github.com/repos/pegjs/pegjs/issues/411","id":175120343,"user":{"login":"silkentrance","id":6068824,"avatar_url":"https://avatars.githubusercontent.com/u/6068824?v=3","gravatar_id":"","url":"https://api.github.com/users/silkentrance","html_url":"https://github.com/silkentrance","followers_url":"https://api.github.com/users/silkentrance/followers","following_url":"https://api.github.com/users/silkentrance/following{/other_user}","gists_url":"https://api.github.com/users/silkentrance/gists{/gist_id}","starred_url":"https://api.github.com/users/silkentrance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silkentrance/subscriptions","organizations_url":"https://api.github.com/users/silkentrance/orgs","repos_url":"https://api.github.com/users/silkentrance/repos","events_url":"https://api.github.com/users/silkentrance/events{/privacy}","received_events_url":"https://api.github.com/users/silkentrance/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T17:07:24Z","updated_at":"2016-01-26T17:07:24Z","body":"Yet, after having patched the sources so I can get at least part of the above described behavior, I realize that is very difficult to decide whether a none-or-multiple, or one, or one-or-multiple rule is mandatory and should lead to a parse error or whether it needs to be ignored unless one is able to provided additional hints to the parser in the grammar and in context of a specific symbol. And, given the given architecture, it is quite impossible to tell the context of a given symbol unless more information is passed to the individual rule match functions. But I might be mistaken here and there might be a context providing facility that would allow a given rule to figure out whether it is purely optional or whether it is actually required to add to a/o generate a trace of its parse errors.\r\n"}}