{"action":"opened","issue":{"url":"https://api.github.com/repos/PistonDevelopers/meta/issues/237","labels_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/237/comments","events_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/237/events","html_url":"https://github.com/PistonDevelopers/meta/issues/237","id":95942886,"number":237,"title":"Add a function for parsing a file with a syntax file","user":{"login":"bvssvni","id":1743862,"avatar_url":"https://avatars.githubusercontent.com/u/1743862?v=3","gravatar_id":"","url":"https://api.github.com/users/bvssvni","html_url":"https://github.com/bvssvni","followers_url":"https://api.github.com/users/bvssvni/followers","following_url":"https://api.github.com/users/bvssvni/following{/other_user}","gists_url":"https://api.github.com/users/bvssvni/gists{/gist_id}","starred_url":"https://api.github.com/users/bvssvni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvssvni/subscriptions","organizations_url":"https://api.github.com/users/bvssvni/orgs","repos_url":"https://api.github.com/users/bvssvni/repos","events_url":"https://api.github.com/users/bvssvni/events{/privacy}","received_events_url":"https://api.github.com/users/bvssvni/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PistonDevelopers/meta/labels/draft","name":"draft","color":"e11d21"},{"url":"https://api.github.com/repos/PistonDevelopers/meta/labels/easy","name":"easy","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-19T19:40:16Z","updated_at":"2015-07-19T19:40:16Z","closed_at":null,"body":"A common use case is when you have a file and a syntax file that describes how the file is parsed and errors are dumped to standard error output. Currently this takes 8 lines of code:\r\n\r\n```Rust\r\n        let mut words_syntax_file = File::open(\"assets/words-syntax.txt\").unwrap();\r\n        let mut words_syntax = String::new();\r\n        words_syntax_file.read_to_string(&mut words_syntax);\r\n        let rules = stderr_unwrap(&words_syntax, syntax(&words_syntax));\r\n\r\n        let mut words_file = File::open(\"assets/words.txt\").unwrap();\r\n        let mut words = String::new();\r\n        words_file.read_to_string(&mut words);\r\n        let words_data = stderr_unwrap(&words, parse(&rules, &words));\r\n```\r\n\r\nThis could be reduced to a single line:\r\n\r\n```Rust\r\nlet words_data = parse_syntax_data(\"assets/words-syntax.txt\", \"assets/words.txt\");\r\n```"}}