{"action":"created","comment":{"url":"https://api.github.com/repos/danReynolds/Splash/pulls/comments/32287890","id":32287890,"diff_hunk":"@@ -0,0 +1,65 @@\n+use parser_combinators::{spaces, many1, satisfy, parser, between,\n+    Parser, ParseResult, ParseError, ParserExt};\n+use parser_combinators::primitives::{State, Stream};\n+\n+#[derive(Debug, PartialEq)]\n+pub enum AST {\n+    Word(String)\n+}\n+\n+fn word<I>(input: State<I>) -> ParseResult<AST, I> where I: Stream<Item=char> {\n+    many1(satisfy(|c: char| !c.is_whitespace()))\n+        .map(AST::Word)\n+        .parse_state(input)\n+}\n+\n+fn command<I>(input: State<I>) -> ParseResult<Vec<AST>, I> where I: Stream<Item=char> {\n+    many1(parser(word::<I>).skip(spaces()))\n+        .parse_state(input)\n+}\n+\n+pub fn parse_command(input: &str) -> Result<Vec<AST>, ParseError<char>> {\n+    between(spaces(), spaces(), parser(command))\n+        .parse(input)\n+        .map(|x| x.0)\n+}\n+\n+#[cfg(test)]\n+mod tests {\n+    use super::*;\n+\n+    #[test]\n+    fn parse_single_word() {\n+        let word = parse_command(\"cmd\").unwrap();\n+        assert_vec_eq(word, vec![to_word(\"cmd\")]);\n+    }\n+\n+    #[test]\n+    fn parse_multiple_words() {\n+        let word = parse_command(\"hello world\").unwrap();\n+        assert_vec_eq(word, vec![to_word(\"hello\"), to_word(\"world\")]);\n+    }\n+\n+    #[test]\n+    fn parse_leading_ws() {\n+        let word = parse_command(\"    cmd\").unwrap();\n+        assert_vec_eq(word, vec![to_word(\"cmd\")]);\n+    }\n+\n+    #[test]\n+    fn parse_trailing_ws() {\n+        let word = parse_command(\"cmd    \").unwrap();\n+        assert_vec_eq(word, vec![to_word(\"cmd\")]);\n+    }\n+\n+    fn to_word(s: &str) -> AST {\n+        AST::Word(s.to_string())\n+    }\n+\n+    fn assert_vec_eq<T: PartialEq + Debug>(v1: Vec<T>, v2: Vec<T>) {","path":"src/parser.rs","position":59,"original_position":59,"commit_id":"2f63ee0e7bf31bbd6c7bf055258b27dc4de66a74","original_commit_id":"2f63ee0e7bf31bbd6c7bf055258b27dc4de66a74","user":{"login":"nikklassen","id":3314933,"avatar_url":"https://avatars.githubusercontent.com/u/3314933?v=3","gravatar_id":"","url":"https://api.github.com/users/nikklassen","html_url":"https://github.com/nikklassen","followers_url":"https://api.github.com/users/nikklassen/followers","following_url":"https://api.github.com/users/nikklassen/following{/other_user}","gists_url":"https://api.github.com/users/nikklassen/gists{/gist_id}","starred_url":"https://api.github.com/users/nikklassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikklassen/subscriptions","organizations_url":"https://api.github.com/users/nikklassen/orgs","repos_url":"https://api.github.com/users/nikklassen/repos","events_url":"https://api.github.com/users/nikklassen/events{/privacy}","received_events_url":"https://api.github.com/users/nikklassen/received_events","type":"User","site_admin":false},"body":"We don't actually need that trait so I'll just remove it","created_at":"2015-06-12T03:14:20Z","updated_at":"2015-06-12T03:14:20Z","html_url":"https://github.com/danReynolds/Splash/pull/30#discussion_r32287890","pull_request_url":"https://api.github.com/repos/danReynolds/Splash/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/comments/32287890"},"html":{"href":"https://github.com/danReynolds/Splash/pull/30#discussion_r32287890"},"pull_request":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/danReynolds/Splash/pulls/30","id":37474987,"html_url":"https://github.com/danReynolds/Splash/pull/30","diff_url":"https://github.com/danReynolds/Splash/pull/30.diff","patch_url":"https://github.com/danReynolds/Splash/pull/30.patch","issue_url":"https://api.github.com/repos/danReynolds/Splash/issues/30","number":30,"state":"open","locked":false,"title":"Parser","user":{"login":"nikklassen","id":3314933,"avatar_url":"https://avatars.githubusercontent.com/u/3314933?v=3","gravatar_id":"","url":"https://api.github.com/users/nikklassen","html_url":"https://github.com/nikklassen","followers_url":"https://api.github.com/users/nikklassen/followers","following_url":"https://api.github.com/users/nikklassen/following{/other_user}","gists_url":"https://api.github.com/users/nikklassen/gists{/gist_id}","starred_url":"https://api.github.com/users/nikklassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikklassen/subscriptions","organizations_url":"https://api.github.com/users/nikklassen/orgs","repos_url":"https://api.github.com/users/nikklassen/repos","events_url":"https://api.github.com/users/nikklassen/events{/privacy}","received_events_url":"https://api.github.com/users/nikklassen/received_events","type":"User","site_admin":false},"body":"closes #25 ","created_at":"2015-06-11T15:18:57Z","updated_at":"2015-06-12T03:14:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ee8ac89d8a4528d1a2f4e1426cc14294cb4a760","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/danReynolds/Splash/pulls/30/commits","review_comments_url":"https://api.github.com/repos/danReynolds/Splash/pulls/30/comments","review_comment_url":"https://api.github.com/repos/danReynolds/Splash/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danReynolds/Splash/issues/30/comments","statuses_url":"https://api.github.com/repos/danReynolds/Splash/statuses/2f63ee0e7bf31bbd6c7bf055258b27dc4de66a74","head":{"label":"danReynolds:parser","ref":"parser","sha":"2f63ee0e7bf31bbd6c7bf055258b27dc4de66a74","user":{"login":"danReynolds","id":2192930,"avatar_url":"https://avatars.githubusercontent.com/u/2192930?v=3","gravatar_id":"","url":"https://api.github.com/users/danReynolds","html_url":"https://github.com/danReynolds","followers_url":"https://api.github.com/users/danReynolds/followers","following_url":"https://api.github.com/users/danReynolds/following{/other_user}","gists_url":"https://api.github.com/users/danReynolds/gists{/gist_id}","starred_url":"https://api.github.com/users/danReynolds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danReynolds/subscriptions","organizations_url":"https://api.github.com/users/danReynolds/orgs","repos_url":"https://api.github.com/users/danReynolds/repos","events_url":"https://api.github.com/users/danReynolds/events{/privacy}","received_events_url":"https://api.github.com/users/danReynolds/received_events","type":"User","site_admin":false},"repo":{"id":36906680,"name":"Splash","full_name":"danReynolds/Splash","owner":{"login":"danReynolds","id":2192930,"avatar_url":"https://avatars.githubusercontent.com/u/2192930?v=3","gravatar_id":"","url":"https://api.github.com/users/danReynolds","html_url":"https://github.com/danReynolds","followers_url":"https://api.github.com/users/danReynolds/followers","following_url":"https://api.github.com/users/danReynolds/following{/other_user}","gists_url":"https://api.github.com/users/danReynolds/gists{/gist_id}","starred_url":"https://api.github.com/users/danReynolds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danReynolds/subscriptions","organizations_url":"https://api.github.com/users/danReynolds/orgs","repos_url":"https://api.github.com/users/danReynolds/repos","events_url":"https://api.github.com/users/danReynolds/events{/privacy}","received_events_url":"https://api.github.com/users/danReynolds/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danReynolds/Splash","description":"A Systems Programming Language Shell written in Rust, a systems programming language.","fork":false,"url":"https://api.github.com/repos/danReynolds/Splash","forks_url":"https://api.github.com/repos/danReynolds/Splash/forks","keys_url":"https://api.github.com/repos/danReynolds/Splash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danReynolds/Splash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danReynolds/Splash/teams","hooks_url":"https://api.github.com/repos/danReynolds/Splash/hooks","issue_events_url":"https://api.github.com/repos/danReynolds/Splash/issues/events{/number}","events_url":"https://api.github.com/repos/danReynolds/Splash/events","assignees_url":"https://api.github.com/repos/danReynolds/Splash/assignees{/user}","branches_url":"https://api.github.com/repos/danReynolds/Splash/branches{/branch}","tags_url":"https://api.github.com/repos/danReynolds/Splash/tags","blobs_url":"https://api.github.com/repos/danReynolds/Splash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danReynolds/Splash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danReynolds/Splash/git/refs{/sha}","trees_url":"https://api.github.com/repos/danReynolds/Splash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danReynolds/Splash/statuses/{sha}","languages_url":"https://api.github.com/repos/danReynolds/Splash/languages","stargazers_url":"https://api.github.com/repos/danReynolds/Splash/stargazers","contributors_url":"https://api.github.com/repos/danReynolds/Splash/contributors","subscribers_url":"https://api.github.com/repos/danReynolds/Splash/subscribers","subscription_url":"https://api.github.com/repos/danReynolds/Splash/subscription","commits_url":"https://api.github.com/repos/danReynolds/Splash/commits{/sha}","git_commits_url":"https://api.github.com/repos/danReynolds/Splash/git/commits{/sha}","comments_url":"https://api.github.com/repos/danReynolds/Splash/comments{/number}","issue_comment_url":"https://api.github.com/repos/danReynolds/Splash/issues/comments{/number}","contents_url":"https://api.github.com/repos/danReynolds/Splash/contents/{+path}","compare_url":"https://api.github.com/repos/danReynolds/Splash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danReynolds/Splash/merges","archive_url":"https://api.github.com/repos/danReynolds/Splash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danReynolds/Splash/downloads","issues_url":"https://api.github.com/repos/danReynolds/Splash/issues{/number}","pulls_url":"https://api.github.com/repos/danReynolds/Splash/pulls{/number}","milestones_url":"https://api.github.com/repos/danReynolds/Splash/milestones{/number}","notifications_url":"https://api.github.com/repos/danReynolds/Splash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danReynolds/Splash/labels{/name}","releases_url":"https://api.github.com/repos/danReynolds/Splash/releases{/id}","created_at":"2015-06-05T02:11:23Z","updated_at":"2015-06-07T03:58:17Z","pushed_at":"2015-06-11T15:18:57Z","git_url":"git://github.com/danReynolds/Splash.git","ssh_url":"git@github.com:danReynolds/Splash.git","clone_url":"https://github.com/danReynolds/Splash.git","svn_url":"https://github.com/danReynolds/Splash","homepage":null,"size":281,"stargazers_count":2,"watchers_count":2,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":2,"default_branch":"master"}},"base":{"label":"danReynolds:master","ref":"master","sha":"b5c2b05bec9e0c1e9407621a622379f86f950b94","user":{"login":"danReynolds","id":2192930,"avatar_url":"https://avatars.githubusercontent.com/u/2192930?v=3","gravatar_id":"","url":"https://api.github.com/users/danReynolds","html_url":"https://github.com/danReynolds","followers_url":"https://api.github.com/users/danReynolds/followers","following_url":"https://api.github.com/users/danReynolds/following{/other_user}","gists_url":"https://api.github.com/users/danReynolds/gists{/gist_id}","starred_url":"https://api.github.com/users/danReynolds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danReynolds/subscriptions","organizations_url":"https://api.github.com/users/danReynolds/orgs","repos_url":"https://api.github.com/users/danReynolds/repos","events_url":"https://api.github.com/users/danReynolds/events{/privacy}","received_events_url":"https://api.github.com/users/danReynolds/received_events","type":"User","site_admin":false},"repo":{"id":36906680,"name":"Splash","full_name":"danReynolds/Splash","owner":{"login":"danReynolds","id":2192930,"avatar_url":"https://avatars.githubusercontent.com/u/2192930?v=3","gravatar_id":"","url":"https://api.github.com/users/danReynolds","html_url":"https://github.com/danReynolds","followers_url":"https://api.github.com/users/danReynolds/followers","following_url":"https://api.github.com/users/danReynolds/following{/other_user}","gists_url":"https://api.github.com/users/danReynolds/gists{/gist_id}","starred_url":"https://api.github.com/users/danReynolds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danReynolds/subscriptions","organizations_url":"https://api.github.com/users/danReynolds/orgs","repos_url":"https://api.github.com/users/danReynolds/repos","events_url":"https://api.github.com/users/danReynolds/events{/privacy}","received_events_url":"https://api.github.com/users/danReynolds/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danReynolds/Splash","description":"A Systems Programming Language Shell written in Rust, a systems programming language.","fork":false,"url":"https://api.github.com/repos/danReynolds/Splash","forks_url":"https://api.github.com/repos/danReynolds/Splash/forks","keys_url":"https://api.github.com/repos/danReynolds/Splash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danReynolds/Splash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danReynolds/Splash/teams","hooks_url":"https://api.github.com/repos/danReynolds/Splash/hooks","issue_events_url":"https://api.github.com/repos/danReynolds/Splash/issues/events{/number}","events_url":"https://api.github.com/repos/danReynolds/Splash/events","assignees_url":"https://api.github.com/repos/danReynolds/Splash/assignees{/user}","branches_url":"https://api.github.com/repos/danReynolds/Splash/branches{/branch}","tags_url":"https://api.github.com/repos/danReynolds/Splash/tags","blobs_url":"https://api.github.com/repos/danReynolds/Splash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danReynolds/Splash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danReynolds/Splash/git/refs{/sha}","trees_url":"https://api.github.com/repos/danReynolds/Splash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danReynolds/Splash/statuses/{sha}","languages_url":"https://api.github.com/repos/danReynolds/Splash/languages","stargazers_url":"https://api.github.com/repos/danReynolds/Splash/stargazers","contributors_url":"https://api.github.com/repos/danReynolds/Splash/contributors","subscribers_url":"https://api.github.com/repos/danReynolds/Splash/subscribers","subscription_url":"https://api.github.com/repos/danReynolds/Splash/subscription","commits_url":"https://api.github.com/repos/danReynolds/Splash/commits{/sha}","git_commits_url":"https://api.github.com/repos/danReynolds/Splash/git/commits{/sha}","comments_url":"https://api.github.com/repos/danReynolds/Splash/comments{/number}","issue_comment_url":"https://api.github.com/repos/danReynolds/Splash/issues/comments{/number}","contents_url":"https://api.github.com/repos/danReynolds/Splash/contents/{+path}","compare_url":"https://api.github.com/repos/danReynolds/Splash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danReynolds/Splash/merges","archive_url":"https://api.github.com/repos/danReynolds/Splash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danReynolds/Splash/downloads","issues_url":"https://api.github.com/repos/danReynolds/Splash/issues{/number}","pulls_url":"https://api.github.com/repos/danReynolds/Splash/pulls{/number}","milestones_url":"https://api.github.com/repos/danReynolds/Splash/milestones{/number}","notifications_url":"https://api.github.com/repos/danReynolds/Splash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danReynolds/Splash/labels{/name}","releases_url":"https://api.github.com/repos/danReynolds/Splash/releases{/id}","created_at":"2015-06-05T02:11:23Z","updated_at":"2015-06-07T03:58:17Z","pushed_at":"2015-06-11T15:18:57Z","git_url":"git://github.com/danReynolds/Splash.git","ssh_url":"git@github.com:danReynolds/Splash.git","clone_url":"https://github.com/danReynolds/Splash.git","svn_url":"https://github.com/danReynolds/Splash","homepage":null,"size":281,"stargazers_count":2,"watchers_count":2,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/30"},"html":{"href":"https://github.com/danReynolds/Splash/pull/30"},"issue":{"href":"https://api.github.com/repos/danReynolds/Splash/issues/30"},"comments":{"href":"https://api.github.com/repos/danReynolds/Splash/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danReynolds/Splash/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/danReynolds/Splash/statuses/2f63ee0e7bf31bbd6c7bf055258b27dc4de66a74"}}}}