{"action":"created","issue":{"url":"https://api.github.com/repos/ziglang/zig/issues/1677","repository_url":"https://api.github.com/repos/ziglang/zig","labels_url":"https://api.github.com/repos/ziglang/zig/issues/1677/labels{/name}","comments_url":"https://api.github.com/repos/ziglang/zig/issues/1677/comments","events_url":"https://api.github.com/repos/ziglang/zig/issues/1677/events","html_url":"https://github.com/ziglang/zig/issues/1677","id":372356165,"node_id":"MDU6SXNzdWUzNzIzNTYxNjU=","number":1677,"title":"Syntax flaw: Block statements and terminating semicolon","user":{"login":"Hejsil","id":3759175,"node_id":"MDQ6VXNlcjM3NTkxNzU=","avatar_url":"https://avatars3.githubusercontent.com/u/3759175?v=4","gravatar_id":"","url":"https://api.github.com/users/Hejsil","html_url":"https://github.com/Hejsil","followers_url":"https://api.github.com/users/Hejsil/followers","following_url":"https://api.github.com/users/Hejsil/following{/other_user}","gists_url":"https://api.github.com/users/Hejsil/gists{/gist_id}","starred_url":"https://api.github.com/users/Hejsil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hejsil/subscriptions","organizations_url":"https://api.github.com/users/Hejsil/orgs","repos_url":"https://api.github.com/users/Hejsil/repos","events_url":"https://api.github.com/users/Hejsil/events{/privacy}","received_events_url":"https://api.github.com/users/Hejsil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-10-21T20:57:48Z","updated_at":"2018-10-23T09:01:28Z","closed_at":null,"author_association":"MEMBER","body":"Currently, block expressions (`for`, `if`, `while`) are only terminated with `;`, if the ending block of that expression is not a block. This makes the grammar very hard (maybe even impossible) to make context-free. My best bet at formalizing a grammar for this have been something along these lines:\r\n```\r\nStatement \r\n    : IfStatement\r\n    | Block\r\n    ...\r\n    | Expr Semicolon\r\n\r\nIfStatement\r\n    : \"if\" GroupedExpr option(Payload) Statement\r\n    | \"if\" GroupedExpr option(Payload) Expr \"else\" option(Payload) Statement\r\n\r\nIfExpr\r\n    : \"if\" GroupedExpr option(Payload) Expr option(\"else\" option(Payload) Expr)\r\n```\r\n\r\nSadly, this grammar requires `N` token lookahead at best, and at worst it is ambiguous because a `Block` is also an `Expr`."},"comment":{"url":"https://api.github.com/repos/ziglang/zig/issues/comments/432160840","html_url":"https://github.com/ziglang/zig/issues/1677#issuecomment-432160840","issue_url":"https://api.github.com/repos/ziglang/zig/issues/1677","id":432160840,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjE2MDg0MA==","user":{"login":"Hejsil","id":3759175,"node_id":"MDQ6VXNlcjM3NTkxNzU=","avatar_url":"https://avatars3.githubusercontent.com/u/3759175?v=4","gravatar_id":"","url":"https://api.github.com/users/Hejsil","html_url":"https://github.com/Hejsil","followers_url":"https://api.github.com/users/Hejsil/followers","following_url":"https://api.github.com/users/Hejsil/following{/other_user}","gists_url":"https://api.github.com/users/Hejsil/gists{/gist_id}","starred_url":"https://api.github.com/users/Hejsil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hejsil/subscriptions","organizations_url":"https://api.github.com/users/Hejsil/orgs","repos_url":"https://api.github.com/users/Hejsil/repos","events_url":"https://api.github.com/users/Hejsil/events{/privacy}","received_events_url":"https://api.github.com/users/Hejsil/received_events","type":"User","site_admin":false},"created_at":"2018-10-23T09:01:27Z","updated_at":"2018-10-23T09:01:27Z","author_association":"MEMBER","body":"> I don't think this is ambiguous. You're supposed to match the patterns in highest-to-lowest precedent as listed. So if Defer(Block) matches, then don't bother trying to match Defer(Expression) \";\". Is this not good enough?\r\n\r\nGrammars are ambiguous as long as there are one input that has two ways of expanding the grammar. Some parsing technices do not have the concept of \"highest-to-lowest\", so they will parse grammars differnelty from parsers that do if the grammar is ambiguous (LARL parsers expand the grammar into states, where a state can handle `N` rules at the same time.)"}}
{"actor":{"display_login":"Hejsil"}}