{"action":"created","issue":{"url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/90","repository_url":"https://api.github.com/repos/nikomatsakis/lalrpop","labels_url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/90/comments","events_url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/90/events","html_url":"https://github.com/nikomatsakis/lalrpop/issues/90","id":135515035,"number":90,"title":"Improve error report about @L @R tokens","user":{"login":"LukasKalbertodt","id":7419664,"avatar_url":"https://avatars.githubusercontent.com/u/7419664?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasKalbertodt","html_url":"https://github.com/LukasKalbertodt","followers_url":"https://api.github.com/users/LukasKalbertodt/followers","following_url":"https://api.github.com/users/LukasKalbertodt/following{/other_user}","gists_url":"https://api.github.com/users/LukasKalbertodt/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasKalbertodt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasKalbertodt/subscriptions","organizations_url":"https://api.github.com/users/LukasKalbertodt/orgs","repos_url":"https://api.github.com/users/LukasKalbertodt/repos","events_url":"https://api.github.com/users/LukasKalbertodt/events{/privacy}","received_events_url":"https://api.github.com/users/LukasKalbertodt/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nikomatsakis/lalrpop/labels/design-work-needed","name":"design-work-needed","color":"84b6eb"},{"url":"https://api.github.com/repos/nikomatsakis/lalrpop/labels/wishlist","name":"wishlist","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-02-22T19:23:35Z","updated_at":"2016-02-24T14:57:04Z","closed_at":null,"body":"I just confused myself by creating a stupid grammar that would read two `@L` tokens successively. A minimal example:\r\n\r\n```rust\r\ngrammar;\r\n\r\nSpanned<T> = @L <T> @R;\r\nWord: String = <s:r\"[a-z]+\"> => <>;\r\n\r\npub Foo = {\r\n    Spanned<Word> \"~\",\r\n    Spanned<Spanned<Word>> \"+\",\r\n};\r\n```\r\n\r\nWhen having many macros like `Spanned`, it can easily happen to next two `Spanned` macros. The grammar above results in:\r\n\r\n```\r\ntest.lalrpop:3:14: 3:15: Local ambiguity detected\r\n\r\n  The problem arises after having observed the following symbols in the input:\r\n    @L\r\n  At that point, if the next token is a `r#\"[a-z]+\"#`, then the parser can\r\n  proceed in two different ways.\r\n\r\n  First, the parser could execute the production at\r\n  src/grammar/test.lalrpop:3:14: 3:15, which would consume the top 0 token(s)\r\n  from the stack and produce a `@L`. This might then yield a parse tree like\r\n    ╷      ╷ Word  @R\r\n    ├─@L───┘        │\r\n    └─Spanned<Word>─┘\r\n\r\n  Alternatively, the parser could shift the `r#\"[a-z]+\"#` token and later use it\r\n  to construct a `Word`. This might then yield a parse tree like\r\n    @L r#\"[a-z]+\"# @R\r\n    │  └─Word────┘  │\r\n    └─Spanned<Word>─┘\r\n\r\n  See the LALRPOP manual for advice on making your grammar LR(1).\r\n```\r\n\r\nThis is not really helpful right now (my real error message with my big grammar was even more confusing...). \r\n\r\n(the new error reporting is awesome though :3)"},"comment":{"url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/comments/188290426","html_url":"https://github.com/nikomatsakis/lalrpop/issues/90#issuecomment-188290426","issue_url":"https://api.github.com/repos/nikomatsakis/lalrpop/issues/90","id":188290426,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T14:57:04Z","updated_at":"2016-02-24T14:57:04Z","body":"(I also decided to keep the user interface as `@L` and `@R` rather than making a \"spanned\" combinator, though that'd be easy enough to change if we wanted. It's kind of orthogonal. Curious to hear what people think would be more convenient in practice.)"}}