{"action":"created","comment":{"url":"https://api.github.com/repos/softdevteam/grmtools/pulls/comments/238226991","pull_request_review_id":180714234,"id":238226991,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODIyNjk5MQ==","diff_hunk":"@@ -398,11 +402,19 @@ where\n                         };\n                     }\n                     if let Some(s) = grm.action(pidx) {\n-                        let ns = re.replace_all(\n-                            s,\n-                            format!(\"{prefix}arg_$1\", prefix = ACTION_PREFIX).as_str()\n+                        // Replace $1 ... $n with the correct local variable","path":"lrpar/src/lib/ctbuilder.rs","position":85,"original_position":27,"commit_id":"d333b59407cdd5cf0207e72f912c2fd3750d3a78","original_commit_id":"f476197f16d88a7e9961082c9e70efcf8107d161","user":{"login":"ptersilie","id":375552,"node_id":"MDQ6VXNlcjM3NTU1Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/375552?v=4","gravatar_id":"","url":"https://api.github.com/users/ptersilie","html_url":"https://github.com/ptersilie","followers_url":"https://api.github.com/users/ptersilie/followers","following_url":"https://api.github.com/users/ptersilie/following{/other_user}","gists_url":"https://api.github.com/users/ptersilie/gists{/gist_id}","starred_url":"https://api.github.com/users/ptersilie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptersilie/subscriptions","organizations_url":"https://api.github.com/users/ptersilie/orgs","repos_url":"https://api.github.com/users/ptersilie/repos","events_url":"https://api.github.com/users/ptersilie/events{/privacy}","received_events_url":"https://api.github.com/users/ptersilie/received_events","type":"User","site_admin":false},"body":"I quickly checked, and Yacc ignores `$X` within strings, so we should at least document this somewhere. My first thought at a somewhat ok fix for this would be to count unescaped quotes and only replace `$X` if the count is even. It's not enough, but it might be better than nothing?","created_at":"2018-12-03T11:09:24Z","updated_at":"2018-12-03T11:09:24Z","html_url":"https://github.com/softdevteam/grmtools/pull/58#discussion_r238226991","pull_request_url":"https://api.github.com/repos/softdevteam/grmtools/pulls/58","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/comments/238226991"},"html":{"href":"https://github.com/softdevteam/grmtools/pull/58#discussion_r238226991"},"pull_request":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/58"}},"in_reply_to_id":238223737},"pull_request":{"url":"https://api.github.com/repos/softdevteam/grmtools/pulls/58","id":235384565,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1Mzg0NTY1","html_url":"https://github.com/softdevteam/grmtools/pull/58","diff_url":"https://github.com/softdevteam/grmtools/pull/58.diff","patch_url":"https://github.com/softdevteam/grmtools/pull/58.patch","issue_url":"https://api.github.com/repos/softdevteam/grmtools/issues/58","number":58,"state":"open","locked":false,"title":"Allow errors to percolate upwards in the actions API","user":{"login":"ltratt","id":20318,"node_id":"MDQ6VXNlcjIwMzE4","avatar_url":"https://avatars1.githubusercontent.com/u/20318?v=4","gravatar_id":"","url":"https://api.github.com/users/ltratt","html_url":"https://github.com/ltratt","followers_url":"https://api.github.com/users/ltratt/followers","following_url":"https://api.github.com/users/ltratt/following{/other_user}","gists_url":"https://api.github.com/users/ltratt/gists{/gist_id}","starred_url":"https://api.github.com/users/ltratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ltratt/subscriptions","organizations_url":"https://api.github.com/users/ltratt/orgs","repos_url":"https://api.github.com/users/ltratt/repos","events_url":"https://api.github.com/users/ltratt/events{/privacy}","received_events_url":"https://api.github.com/users/ltratt/received_events","type":"User","site_admin":false},"body":"This PR contains two major things.\r\n\r\nFirst it provides a way to differentiate between lexemes of zero length (e.g. `DEDENT` tokens in Python) and lexemes created by error recovery (which have no content) in https://github.com/softdevteam/grmtools/commit/3db2be06e5c0980d272739dee322360007195c86.\r\n\r\nSecond it changes the actions API in two related ways in https://github.com/softdevteam/grmtools/commit/faee83c26bea71c0040ccbf47194bb88cec523fc: it now passes `Lexeme`s to actions (instead of strings); and it passes `Lexeme`s in an a `Result<Lexeme, Lexeme>` type, allowing users to easily tell if a lexeme is the result of user input (the `Ok` case) or error recovery (the `Err` case).\r\n\r\nWhen combined with the ability to use arbitrary types for `%type` https://github.com/softdevteam/grmtools/commit/46c4265ebdf20d41dc0cd068105dbad4d34175ab, this allows users a lot of flexibility to write flexible actions, but also makes it relatively painless to do so. For example, here's the new calculator grammar:\r\n\r\n```\r\nstart Expr\r\n%type Result<u64, ()>\r\n%%\r\nExpr: Term 'PLUS' Expr { Ok($1? + $3?) }\r\n    | Term { $1 }\r\n    ;\r\n\r\nTerm: Factor 'MUL' Term { Ok($1? * $3?) }\r\n    | Factor { $1 }\r\n    ;\r\n\r\nFactor: 'LBRACK' Expr 'RBRACK' { $2 }\r\n      | 'INT' {\r\n            let l = $1.map_err(|_| ())?;\r\n            match $lexer.lexeme_str(&l).parse::<u64>() {\r\n                Ok(v) => Ok(v),\r\n                Err(_) => {\r\n                    let (_, col) = $lexer.line_and_col(&l);\r\n                    eprintln!(\"Error at column {}: '{}' cannot be represented as a u64\",\r\n                              col,\r\n                              $lexer.lexeme_str(&l));\r\n                    Err(())\r\n                }\r\n            }\r\n        }\r\n      ;\r\n```\r\n\r\nand here's a session using it:\r\n\r\n```\r\n>>> 1+2\r\nResult: 3\r\n>>> 1++2\r\nParsing error at column 3.\r\nResult: 3\r\n>>> 1+18446744073709551616\r\nError at column 3: '18446744073709551616' cannot be represented as a u64\r\nUnable to evaluate\r\n>>> 1+18446744073709551616+18446744073709551616\r\nError at column 3: '18446744073709551616' cannot be represented as a u64\r\nError at column 24: '18446744073709551616' cannot be represented as a u64\r\nUnable to evaluate\r\n```\r\n\r\nIn essence, we give users the choice for how to handle the semantic consequences of syntactic errors. Interestingly, my first attempt at this embedded the `Resulte<u64, ()>` idiom into `lrpar`, before I realised that we can let the user do it themselves just as easily.\r\n\r\nThere is one part of `lrpar`'s API which this PR makes even worse: the return type of `parse_action` is a mess, requiring the user to deal with too many cases. Fixing that is a medium sized job and best left to a subsequent PR IMHO. [It might also be a good idea to provide easy functions for the user to pretty print things like repair sequences, but that might turn out to be bloat. I'll experiment.]\r\n","created_at":"2018-12-03T09:53:54Z","updated_at":"2018-12-03T11:09:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1031b2d9b312fb1c01f9efbca66d8146a49e7aae","assignee":{"login":"ptersilie","id":375552,"node_id":"MDQ6VXNlcjM3NTU1Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/375552?v=4","gravatar_id":"","url":"https://api.github.com/users/ptersilie","html_url":"https://github.com/ptersilie","followers_url":"https://api.github.com/users/ptersilie/followers","following_url":"https://api.github.com/users/ptersilie/following{/other_user}","gists_url":"https://api.github.com/users/ptersilie/gists{/gist_id}","starred_url":"https://api.github.com/users/ptersilie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptersilie/subscriptions","organizations_url":"https://api.github.com/users/ptersilie/orgs","repos_url":"https://api.github.com/users/ptersilie/repos","events_url":"https://api.github.com/users/ptersilie/events{/privacy}","received_events_url":"https://api.github.com/users/ptersilie/received_events","type":"User","site_admin":false},"assignees":[{"login":"ptersilie","id":375552,"node_id":"MDQ6VXNlcjM3NTU1Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/375552?v=4","gravatar_id":"","url":"https://api.github.com/users/ptersilie","html_url":"https://github.com/ptersilie","followers_url":"https://api.github.com/users/ptersilie/followers","following_url":"https://api.github.com/users/ptersilie/following{/other_user}","gists_url":"https://api.github.com/users/ptersilie/gists{/gist_id}","starred_url":"https://api.github.com/users/ptersilie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptersilie/subscriptions","organizations_url":"https://api.github.com/users/ptersilie/orgs","repos_url":"https://api.github.com/users/ptersilie/repos","events_url":"https://api.github.com/users/ptersilie/events{/privacy}","received_events_url":"https://api.github.com/users/ptersilie/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/softdevteam/grmtools/pulls/58/commits","review_comments_url":"https://api.github.com/repos/softdevteam/grmtools/pulls/58/comments","review_comment_url":"https://api.github.com/repos/softdevteam/grmtools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/softdevteam/grmtools/issues/58/comments","statuses_url":"https://api.github.com/repos/softdevteam/grmtools/statuses/d333b59407cdd5cf0207e72f912c2fd3750d3a78","head":{"label":"softdevteam:error_cascading_actions_api","ref":"error_cascading_actions_api","sha":"d333b59407cdd5cf0207e72f912c2fd3750d3a78","user":{"login":"softdevteam","id":10271085,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjcxMDg1","avatar_url":"https://avatars0.githubusercontent.com/u/10271085?v=4","gravatar_id":"","url":"https://api.github.com/users/softdevteam","html_url":"https://github.com/softdevteam","followers_url":"https://api.github.com/users/softdevteam/followers","following_url":"https://api.github.com/users/softdevteam/following{/other_user}","gists_url":"https://api.github.com/users/softdevteam/gists{/gist_id}","starred_url":"https://api.github.com/users/softdevteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softdevteam/subscriptions","organizations_url":"https://api.github.com/users/softdevteam/orgs","repos_url":"https://api.github.com/users/softdevteam/repos","events_url":"https://api.github.com/users/softdevteam/events{/privacy}","received_events_url":"https://api.github.com/users/softdevteam/received_events","type":"Organization","site_admin":false},"repo":{"id":143743108,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3NDMxMDg=","name":"grmtools","full_name":"softdevteam/grmtools","private":false,"owner":{"login":"softdevteam","id":10271085,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjcxMDg1","avatar_url":"https://avatars0.githubusercontent.com/u/10271085?v=4","gravatar_id":"","url":"https://api.github.com/users/softdevteam","html_url":"https://github.com/softdevteam","followers_url":"https://api.github.com/users/softdevteam/followers","following_url":"https://api.github.com/users/softdevteam/following{/other_user}","gists_url":"https://api.github.com/users/softdevteam/gists{/gist_id}","starred_url":"https://api.github.com/users/softdevteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softdevteam/subscriptions","organizations_url":"https://api.github.com/users/softdevteam/orgs","repos_url":"https://api.github.com/users/softdevteam/repos","events_url":"https://api.github.com/users/softdevteam/events{/privacy}","received_events_url":"https://api.github.com/users/softdevteam/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/softdevteam/grmtools","description":"Rust grammar tool libraries and binaries","fork":false,"url":"https://api.github.com/repos/softdevteam/grmtools","forks_url":"https://api.github.com/repos/softdevteam/grmtools/forks","keys_url":"https://api.github.com/repos/softdevteam/grmtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softdevteam/grmtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softdevteam/grmtools/teams","hooks_url":"https://api.github.com/repos/softdevteam/grmtools/hooks","issue_events_url":"https://api.github.com/repos/softdevteam/grmtools/issues/events{/number}","events_url":"https://api.github.com/repos/softdevteam/grmtools/events","assignees_url":"https://api.github.com/repos/softdevteam/grmtools/assignees{/user}","branches_url":"https://api.github.com/repos/softdevteam/grmtools/branches{/branch}","tags_url":"https://api.github.com/repos/softdevteam/grmtools/tags","blobs_url":"https://api.github.com/repos/softdevteam/grmtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softdevteam/grmtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softdevteam/grmtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/softdevteam/grmtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softdevteam/grmtools/statuses/{sha}","languages_url":"https://api.github.com/repos/softdevteam/grmtools/languages","stargazers_url":"https://api.github.com/repos/softdevteam/grmtools/stargazers","contributors_url":"https://api.github.com/repos/softdevteam/grmtools/contributors","subscribers_url":"https://api.github.com/repos/softdevteam/grmtools/subscribers","subscription_url":"https://api.github.com/repos/softdevteam/grmtools/subscription","commits_url":"https://api.github.com/repos/softdevteam/grmtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/softdevteam/grmtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/softdevteam/grmtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/softdevteam/grmtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/softdevteam/grmtools/contents/{+path}","compare_url":"https://api.github.com/repos/softdevteam/grmtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softdevteam/grmtools/merges","archive_url":"https://api.github.com/repos/softdevteam/grmtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softdevteam/grmtools/downloads","issues_url":"https://api.github.com/repos/softdevteam/grmtools/issues{/number}","pulls_url":"https://api.github.com/repos/softdevteam/grmtools/pulls{/number}","milestones_url":"https://api.github.com/repos/softdevteam/grmtools/milestones{/number}","notifications_url":"https://api.github.com/repos/softdevteam/grmtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softdevteam/grmtools/labels{/name}","releases_url":"https://api.github.com/repos/softdevteam/grmtools/releases{/id}","deployments_url":"https://api.github.com/repos/softdevteam/grmtools/deployments","created_at":"2018-08-06T14:50:43Z","updated_at":"2018-11-30T14:51:58Z","pushed_at":"2018-12-03T09:53:55Z","git_url":"git://github.com/softdevteam/grmtools.git","ssh_url":"git@github.com:softdevteam/grmtools.git","clone_url":"https://github.com/softdevteam/grmtools.git","svn_url":"https://github.com/softdevteam/grmtools","homepage":null,"size":1623,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"softdevteam:master","ref":"master","sha":"4d19ee4f86a48409e40909add637873ad2902f5e","user":{"login":"softdevteam","id":10271085,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjcxMDg1","avatar_url":"https://avatars0.githubusercontent.com/u/10271085?v=4","gravatar_id":"","url":"https://api.github.com/users/softdevteam","html_url":"https://github.com/softdevteam","followers_url":"https://api.github.com/users/softdevteam/followers","following_url":"https://api.github.com/users/softdevteam/following{/other_user}","gists_url":"https://api.github.com/users/softdevteam/gists{/gist_id}","starred_url":"https://api.github.com/users/softdevteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softdevteam/subscriptions","organizations_url":"https://api.github.com/users/softdevteam/orgs","repos_url":"https://api.github.com/users/softdevteam/repos","events_url":"https://api.github.com/users/softdevteam/events{/privacy}","received_events_url":"https://api.github.com/users/softdevteam/received_events","type":"Organization","site_admin":false},"repo":{"id":143743108,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3NDMxMDg=","name":"grmtools","full_name":"softdevteam/grmtools","private":false,"owner":{"login":"softdevteam","id":10271085,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjcxMDg1","avatar_url":"https://avatars0.githubusercontent.com/u/10271085?v=4","gravatar_id":"","url":"https://api.github.com/users/softdevteam","html_url":"https://github.com/softdevteam","followers_url":"https://api.github.com/users/softdevteam/followers","following_url":"https://api.github.com/users/softdevteam/following{/other_user}","gists_url":"https://api.github.com/users/softdevteam/gists{/gist_id}","starred_url":"https://api.github.com/users/softdevteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softdevteam/subscriptions","organizations_url":"https://api.github.com/users/softdevteam/orgs","repos_url":"https://api.github.com/users/softdevteam/repos","events_url":"https://api.github.com/users/softdevteam/events{/privacy}","received_events_url":"https://api.github.com/users/softdevteam/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/softdevteam/grmtools","description":"Rust grammar tool libraries and binaries","fork":false,"url":"https://api.github.com/repos/softdevteam/grmtools","forks_url":"https://api.github.com/repos/softdevteam/grmtools/forks","keys_url":"https://api.github.com/repos/softdevteam/grmtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softdevteam/grmtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softdevteam/grmtools/teams","hooks_url":"https://api.github.com/repos/softdevteam/grmtools/hooks","issue_events_url":"https://api.github.com/repos/softdevteam/grmtools/issues/events{/number}","events_url":"https://api.github.com/repos/softdevteam/grmtools/events","assignees_url":"https://api.github.com/repos/softdevteam/grmtools/assignees{/user}","branches_url":"https://api.github.com/repos/softdevteam/grmtools/branches{/branch}","tags_url":"https://api.github.com/repos/softdevteam/grmtools/tags","blobs_url":"https://api.github.com/repos/softdevteam/grmtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softdevteam/grmtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softdevteam/grmtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/softdevteam/grmtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softdevteam/grmtools/statuses/{sha}","languages_url":"https://api.github.com/repos/softdevteam/grmtools/languages","stargazers_url":"https://api.github.com/repos/softdevteam/grmtools/stargazers","contributors_url":"https://api.github.com/repos/softdevteam/grmtools/contributors","subscribers_url":"https://api.github.com/repos/softdevteam/grmtools/subscribers","subscription_url":"https://api.github.com/repos/softdevteam/grmtools/subscription","commits_url":"https://api.github.com/repos/softdevteam/grmtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/softdevteam/grmtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/softdevteam/grmtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/softdevteam/grmtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/softdevteam/grmtools/contents/{+path}","compare_url":"https://api.github.com/repos/softdevteam/grmtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softdevteam/grmtools/merges","archive_url":"https://api.github.com/repos/softdevteam/grmtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softdevteam/grmtools/downloads","issues_url":"https://api.github.com/repos/softdevteam/grmtools/issues{/number}","pulls_url":"https://api.github.com/repos/softdevteam/grmtools/pulls{/number}","milestones_url":"https://api.github.com/repos/softdevteam/grmtools/milestones{/number}","notifications_url":"https://api.github.com/repos/softdevteam/grmtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softdevteam/grmtools/labels{/name}","releases_url":"https://api.github.com/repos/softdevteam/grmtools/releases{/id}","deployments_url":"https://api.github.com/repos/softdevteam/grmtools/deployments","created_at":"2018-08-06T14:50:43Z","updated_at":"2018-11-30T14:51:58Z","pushed_at":"2018-12-03T09:53:55Z","git_url":"git://github.com/softdevteam/grmtools.git","ssh_url":"git@github.com:softdevteam/grmtools.git","clone_url":"https://github.com/softdevteam/grmtools.git","svn_url":"https://github.com/softdevteam/grmtools","homepage":null,"size":1623,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/58"},"html":{"href":"https://github.com/softdevteam/grmtools/pull/58"},"issue":{"href":"https://api.github.com/repos/softdevteam/grmtools/issues/58"},"comments":{"href":"https://api.github.com/repos/softdevteam/grmtools/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/softdevteam/grmtools/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/softdevteam/grmtools/statuses/d333b59407cdd5cf0207e72f912c2fd3750d3a78"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ptersilie"}}