{"action":"created","comment":{"url":"https://api.github.com/repos/OatmealLick/grepper/pulls/comments/158586977","pull_request_review_id":85427459,"id":158586977,"diff_hunk":"@@ -0,0 +1,76 @@\n+-module(regex2tree).\n+-include_lib(\"eunit/include/eunit.hrl\").\n+\n+%% API\n+-export([re2post/1,\n+         extract_from_parentheses/1]).\n+\n+re2post([]) -> [];\n+re2post(Input) -> re2post(Input, 0, [], []).\n+\n+re2post([], WrittenCount, OperatorStack, Output) ->\n+  PostfixNotation = lists:append(lists:reverse(OperatorStack), Output),\n+  case (length(OperatorStack) =:= 0) and (WrittenCount > 1) of\n+    true -> Result = concatenation(PostfixNotation);\n+    false -> Result = PostfixNotation\n+  end,\n+  lists:reverse(Result);\n+re2post([Char | Input], WrittenCount, OperatorStack, Output) ->\n+  case is_unary_operator(Char) of\n+    true -> re2post(Input, WrittenCount, OperatorStack, [Char | Output]);\n+    false ->\n+      if\n+        WrittenCount =:= 2 ->\n+          case length(OperatorStack) > 0 of\n+            true ->\n+              [Operator | LeftOperators] = OperatorStack,\n+              re2post([Char | Input], 1, LeftOperators, [Operator | Output]);\n+            false ->\n+              re2post([Char | Input], 1, OperatorStack, concatenation(Output))\n+          end;\n+        true -> case Char of\n+            $( ->\n+              [Inside, Outside] = extract_from_parentheses(Input),\n+              PostfixOfInside = lists:reverse(re2post(Inside)),\n+              NewOutput = lists:append(PostfixOfInside, Output),\n+              re2post(Outside, WrittenCount + 1, OperatorStack, NewOutput);\n+            BinaryOperator when BinaryOperator =:= $+ ->\n+              re2post(Input, WrittenCount, [BinaryOperator | OperatorStack], Output);\n+            UnaryOperator when UnaryOperator =:= $* ->\n+              re2post(Input, WrittenCount, OperatorStack, [UnaryOperator | Output]);\n+            CharLiteral ->\n+              re2post(Input, WrittenCount + 1, OperatorStack, [CharLiteral | Output])\n+          end\n+      end\n+  end.\n+\n+extract_from_parentheses(Input) -> extract_from_parentheses(Input, [], 0).\n+\n+extract_from_parentheses([Char | Input], Inside, Count) ->\n+  case Char of\n+    $( -> extract_from_parentheses(Input, [Char | Inside], Count + 1);\n+    $) -> case Count of\n+             0 -> [lists:reverse(Inside), Input];\n+             _ -> extract_from_parentheses(Input, [Char | Inside], Count - 1)\n+           end;\n+    NotParentheses -> extract_from_parentheses(Input, [NotParentheses | Inside], Count)\n+  end.\n+\n+is_unary_operator(Char) -> lists:member(Char, [$*]).\n+\n+concatenation(Output) -> [$. | Output].\n+\n+\n+re2post_test() ->\n+  [\n+    ?assert(re2post(\"\") =:= []),","path":"regex2tree.erl","position":66,"original_position":66,"commit_id":"6e1bbf99d4b80bc37986f938349fe03b07b4b72c","original_commit_id":"6e1bbf99d4b80bc37986f938349fe03b07b4b72c","user":{"login":"OatmealLick","id":23723393,"avatar_url":"https://avatars3.githubusercontent.com/u/23723393?v=4","gravatar_id":"","url":"https://api.github.com/users/OatmealLick","html_url":"https://github.com/OatmealLick","followers_url":"https://api.github.com/users/OatmealLick/followers","following_url":"https://api.github.com/users/OatmealLick/following{/other_user}","gists_url":"https://api.github.com/users/OatmealLick/gists{/gist_id}","starred_url":"https://api.github.com/users/OatmealLick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OatmealLick/subscriptions","organizations_url":"https://api.github.com/users/OatmealLick/orgs","repos_url":"https://api.github.com/users/OatmealLick/repos","events_url":"https://api.github.com/users/OatmealLick/events{/privacy}","received_events_url":"https://api.github.com/users/OatmealLick/received_events","type":"User","site_admin":false},"body":"you should use `?_assert` macro, cause it's equivalent to `?_test(?assert(...))`, ?assert does not create test object itself.","created_at":"2017-12-23T18:29:40Z","updated_at":"2017-12-23T18:31:13Z","html_url":"https://github.com/OatmealLick/grepper/pull/2#discussion_r158586977","pull_request_url":"https://api.github.com/repos/OatmealLick/grepper/pulls/2","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/comments/158586977"},"html":{"href":"https://github.com/OatmealLick/grepper/pull/2#discussion_r158586977"},"pull_request":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/OatmealLick/grepper/pulls/2","id":159975295,"html_url":"https://github.com/OatmealLick/grepper/pull/2","diff_url":"https://github.com/OatmealLick/grepper/pull/2.diff","patch_url":"https://github.com/OatmealLick/grepper/pull/2.patch","issue_url":"https://api.github.com/repos/OatmealLick/grepper/issues/2","number":2,"state":"open","locked":false,"title":"Reimplemented re2post function","user":{"login":"Bzdeco","id":24151621,"avatar_url":"https://avatars3.githubusercontent.com/u/24151621?v=4","gravatar_id":"","url":"https://api.github.com/users/Bzdeco","html_url":"https://github.com/Bzdeco","followers_url":"https://api.github.com/users/Bzdeco/followers","following_url":"https://api.github.com/users/Bzdeco/following{/other_user}","gists_url":"https://api.github.com/users/Bzdeco/gists{/gist_id}","starred_url":"https://api.github.com/users/Bzdeco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bzdeco/subscriptions","organizations_url":"https://api.github.com/users/Bzdeco/orgs","repos_url":"https://api.github.com/users/Bzdeco/repos","events_url":"https://api.github.com/users/Bzdeco/events{/privacy}","received_events_url":"https://api.github.com/users/Bzdeco/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-23T17:54:24Z","updated_at":"2017-12-23T18:31:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05b3133717ee5ffe8371cd0910f2c895e17f6cd7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/OatmealLick/grepper/pulls/2/commits","review_comments_url":"https://api.github.com/repos/OatmealLick/grepper/pulls/2/comments","review_comment_url":"https://api.github.com/repos/OatmealLick/grepper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OatmealLick/grepper/issues/2/comments","statuses_url":"https://api.github.com/repos/OatmealLick/grepper/statuses/6e1bbf99d4b80bc37986f938349fe03b07b4b72c","head":{"label":"OatmealLick:re2post-reimplementation","ref":"re2post-reimplementation","sha":"6e1bbf99d4b80bc37986f938349fe03b07b4b72c","user":{"login":"OatmealLick","id":23723393,"avatar_url":"https://avatars3.githubusercontent.com/u/23723393?v=4","gravatar_id":"","url":"https://api.github.com/users/OatmealLick","html_url":"https://github.com/OatmealLick","followers_url":"https://api.github.com/users/OatmealLick/followers","following_url":"https://api.github.com/users/OatmealLick/following{/other_user}","gists_url":"https://api.github.com/users/OatmealLick/gists{/gist_id}","starred_url":"https://api.github.com/users/OatmealLick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OatmealLick/subscriptions","organizations_url":"https://api.github.com/users/OatmealLick/orgs","repos_url":"https://api.github.com/users/OatmealLick/repos","events_url":"https://api.github.com/users/OatmealLick/events{/privacy}","received_events_url":"https://api.github.com/users/OatmealLick/received_events","type":"User","site_admin":false},"repo":{"id":114898090,"name":"grepper","full_name":"OatmealLick/grepper","owner":{"login":"OatmealLick","id":23723393,"avatar_url":"https://avatars3.githubusercontent.com/u/23723393?v=4","gravatar_id":"","url":"https://api.github.com/users/OatmealLick","html_url":"https://github.com/OatmealLick","followers_url":"https://api.github.com/users/OatmealLick/followers","following_url":"https://api.github.com/users/OatmealLick/following{/other_user}","gists_url":"https://api.github.com/users/OatmealLick/gists{/gist_id}","starred_url":"https://api.github.com/users/OatmealLick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OatmealLick/subscriptions","organizations_url":"https://api.github.com/users/OatmealLick/orgs","repos_url":"https://api.github.com/users/OatmealLick/repos","events_url":"https://api.github.com/users/OatmealLick/events{/privacy}","received_events_url":"https://api.github.com/users/OatmealLick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OatmealLick/grepper","description":"Grep but better! Concurrent grep for Hopcroft's regular expressions.","fork":false,"url":"https://api.github.com/repos/OatmealLick/grepper","forks_url":"https://api.github.com/repos/OatmealLick/grepper/forks","keys_url":"https://api.github.com/repos/OatmealLick/grepper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OatmealLick/grepper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OatmealLick/grepper/teams","hooks_url":"https://api.github.com/repos/OatmealLick/grepper/hooks","issue_events_url":"https://api.github.com/repos/OatmealLick/grepper/issues/events{/number}","events_url":"https://api.github.com/repos/OatmealLick/grepper/events","assignees_url":"https://api.github.com/repos/OatmealLick/grepper/assignees{/user}","branches_url":"https://api.github.com/repos/OatmealLick/grepper/branches{/branch}","tags_url":"https://api.github.com/repos/OatmealLick/grepper/tags","blobs_url":"https://api.github.com/repos/OatmealLick/grepper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OatmealLick/grepper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OatmealLick/grepper/git/refs{/sha}","trees_url":"https://api.github.com/repos/OatmealLick/grepper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OatmealLick/grepper/statuses/{sha}","languages_url":"https://api.github.com/repos/OatmealLick/grepper/languages","stargazers_url":"https://api.github.com/repos/OatmealLick/grepper/stargazers","contributors_url":"https://api.github.com/repos/OatmealLick/grepper/contributors","subscribers_url":"https://api.github.com/repos/OatmealLick/grepper/subscribers","subscription_url":"https://api.github.com/repos/OatmealLick/grepper/subscription","commits_url":"https://api.github.com/repos/OatmealLick/grepper/commits{/sha}","git_commits_url":"https://api.github.com/repos/OatmealLick/grepper/git/commits{/sha}","comments_url":"https://api.github.com/repos/OatmealLick/grepper/comments{/number}","issue_comment_url":"https://api.github.com/repos/OatmealLick/grepper/issues/comments{/number}","contents_url":"https://api.github.com/repos/OatmealLick/grepper/contents/{+path}","compare_url":"https://api.github.com/repos/OatmealLick/grepper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OatmealLick/grepper/merges","archive_url":"https://api.github.com/repos/OatmealLick/grepper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OatmealLick/grepper/downloads","issues_url":"https://api.github.com/repos/OatmealLick/grepper/issues{/number}","pulls_url":"https://api.github.com/repos/OatmealLick/grepper/pulls{/number}","milestones_url":"https://api.github.com/repos/OatmealLick/grepper/milestones{/number}","notifications_url":"https://api.github.com/repos/OatmealLick/grepper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OatmealLick/grepper/labels{/name}","releases_url":"https://api.github.com/repos/OatmealLick/grepper/releases{/id}","deployments_url":"https://api.github.com/repos/OatmealLick/grepper/deployments","created_at":"2017-12-20T14:44:58Z","updated_at":"2017-12-20T15:22:31Z","pushed_at":"2017-12-23T18:11:33Z","git_url":"git://github.com/OatmealLick/grepper.git","ssh_url":"git@github.com:OatmealLick/grepper.git","clone_url":"https://github.com/OatmealLick/grepper.git","svn_url":"https://github.com/OatmealLick/grepper","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"wtfpl","name":"Do What The F*ck You Want To Public License","spdx_id":"WTFPL","url":"https://api.github.com/licenses/wtfpl"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"OatmealLick:regex-to-tree-conversion","ref":"regex-to-tree-conversion","sha":"aabd2f2ff66dcd6b2687811349cd8e8ca8a20a9f","user":{"login":"OatmealLick","id":23723393,"avatar_url":"https://avatars3.githubusercontent.com/u/23723393?v=4","gravatar_id":"","url":"https://api.github.com/users/OatmealLick","html_url":"https://github.com/OatmealLick","followers_url":"https://api.github.com/users/OatmealLick/followers","following_url":"https://api.github.com/users/OatmealLick/following{/other_user}","gists_url":"https://api.github.com/users/OatmealLick/gists{/gist_id}","starred_url":"https://api.github.com/users/OatmealLick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OatmealLick/subscriptions","organizations_url":"https://api.github.com/users/OatmealLick/orgs","repos_url":"https://api.github.com/users/OatmealLick/repos","events_url":"https://api.github.com/users/OatmealLick/events{/privacy}","received_events_url":"https://api.github.com/users/OatmealLick/received_events","type":"User","site_admin":false},"repo":{"id":114898090,"name":"grepper","full_name":"OatmealLick/grepper","owner":{"login":"OatmealLick","id":23723393,"avatar_url":"https://avatars3.githubusercontent.com/u/23723393?v=4","gravatar_id":"","url":"https://api.github.com/users/OatmealLick","html_url":"https://github.com/OatmealLick","followers_url":"https://api.github.com/users/OatmealLick/followers","following_url":"https://api.github.com/users/OatmealLick/following{/other_user}","gists_url":"https://api.github.com/users/OatmealLick/gists{/gist_id}","starred_url":"https://api.github.com/users/OatmealLick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OatmealLick/subscriptions","organizations_url":"https://api.github.com/users/OatmealLick/orgs","repos_url":"https://api.github.com/users/OatmealLick/repos","events_url":"https://api.github.com/users/OatmealLick/events{/privacy}","received_events_url":"https://api.github.com/users/OatmealLick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OatmealLick/grepper","description":"Grep but better! Concurrent grep for Hopcroft's regular expressions.","fork":false,"url":"https://api.github.com/repos/OatmealLick/grepper","forks_url":"https://api.github.com/repos/OatmealLick/grepper/forks","keys_url":"https://api.github.com/repos/OatmealLick/grepper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OatmealLick/grepper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OatmealLick/grepper/teams","hooks_url":"https://api.github.com/repos/OatmealLick/grepper/hooks","issue_events_url":"https://api.github.com/repos/OatmealLick/grepper/issues/events{/number}","events_url":"https://api.github.com/repos/OatmealLick/grepper/events","assignees_url":"https://api.github.com/repos/OatmealLick/grepper/assignees{/user}","branches_url":"https://api.github.com/repos/OatmealLick/grepper/branches{/branch}","tags_url":"https://api.github.com/repos/OatmealLick/grepper/tags","blobs_url":"https://api.github.com/repos/OatmealLick/grepper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OatmealLick/grepper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OatmealLick/grepper/git/refs{/sha}","trees_url":"https://api.github.com/repos/OatmealLick/grepper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OatmealLick/grepper/statuses/{sha}","languages_url":"https://api.github.com/repos/OatmealLick/grepper/languages","stargazers_url":"https://api.github.com/repos/OatmealLick/grepper/stargazers","contributors_url":"https://api.github.com/repos/OatmealLick/grepper/contributors","subscribers_url":"https://api.github.com/repos/OatmealLick/grepper/subscribers","subscription_url":"https://api.github.com/repos/OatmealLick/grepper/subscription","commits_url":"https://api.github.com/repos/OatmealLick/grepper/commits{/sha}","git_commits_url":"https://api.github.com/repos/OatmealLick/grepper/git/commits{/sha}","comments_url":"https://api.github.com/repos/OatmealLick/grepper/comments{/number}","issue_comment_url":"https://api.github.com/repos/OatmealLick/grepper/issues/comments{/number}","contents_url":"https://api.github.com/repos/OatmealLick/grepper/contents/{+path}","compare_url":"https://api.github.com/repos/OatmealLick/grepper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OatmealLick/grepper/merges","archive_url":"https://api.github.com/repos/OatmealLick/grepper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OatmealLick/grepper/downloads","issues_url":"https://api.github.com/repos/OatmealLick/grepper/issues{/number}","pulls_url":"https://api.github.com/repos/OatmealLick/grepper/pulls{/number}","milestones_url":"https://api.github.com/repos/OatmealLick/grepper/milestones{/number}","notifications_url":"https://api.github.com/repos/OatmealLick/grepper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OatmealLick/grepper/labels{/name}","releases_url":"https://api.github.com/repos/OatmealLick/grepper/releases{/id}","deployments_url":"https://api.github.com/repos/OatmealLick/grepper/deployments","created_at":"2017-12-20T14:44:58Z","updated_at":"2017-12-20T15:22:31Z","pushed_at":"2017-12-23T18:11:33Z","git_url":"git://github.com/OatmealLick/grepper.git","ssh_url":"git@github.com:OatmealLick/grepper.git","clone_url":"https://github.com/OatmealLick/grepper.git","svn_url":"https://github.com/OatmealLick/grepper","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"wtfpl","name":"Do What The F*ck You Want To Public License","spdx_id":"WTFPL","url":"https://api.github.com/licenses/wtfpl"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/2"},"html":{"href":"https://github.com/OatmealLick/grepper/pull/2"},"issue":{"href":"https://api.github.com/repos/OatmealLick/grepper/issues/2"},"comments":{"href":"https://api.github.com/repos/OatmealLick/grepper/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OatmealLick/grepper/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/OatmealLick/grepper/statuses/6e1bbf99d4b80bc37986f938349fe03b07b4b72c"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"OatmealLick"}}