{"action":"created","issue":{"url":"https://api.github.com/repos/softdevteam/rstreediff/issues/2","repository_url":"https://api.github.com/repos/softdevteam/rstreediff","labels_url":"https://api.github.com/repos/softdevteam/rstreediff/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/softdevteam/rstreediff/issues/2/comments","events_url":"https://api.github.com/repos/softdevteam/rstreediff/issues/2/events","html_url":"https://github.com/softdevteam/rstreediff/pull/2","id":226863456,"number":2,"title":"Parse input files into a custom AST structure","user":{"login":"snim2","id":97674,"avatar_url":"https://avatars1.githubusercontent.com/u/97674?v=3","gravatar_id":"","url":"https://api.github.com/users/snim2","html_url":"https://github.com/snim2","followers_url":"https://api.github.com/users/snim2/followers","following_url":"https://api.github.com/users/snim2/following{/other_user}","gists_url":"https://api.github.com/users/snim2/gists{/gist_id}","starred_url":"https://api.github.com/users/snim2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snim2/subscriptions","organizations_url":"https://api.github.com/users/snim2/orgs","repos_url":"https://api.github.com/users/snim2/repos","events_url":"https://api.github.com/users/snim2/events{/privacy}","received_events_url":"https://api.github.com/users/snim2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"vext01","id":604955,"avatar_url":"https://avatars1.githubusercontent.com/u/604955?v=3","gravatar_id":"","url":"https://api.github.com/users/vext01","html_url":"https://github.com/vext01","followers_url":"https://api.github.com/users/vext01/followers","following_url":"https://api.github.com/users/vext01/following{/other_user}","gists_url":"https://api.github.com/users/vext01/gists{/gist_id}","starred_url":"https://api.github.com/users/vext01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vext01/subscriptions","organizations_url":"https://api.github.com/users/vext01/orgs","repos_url":"https://api.github.com/users/vext01/repos","events_url":"https://api.github.com/users/vext01/events{/privacy}","received_events_url":"https://api.github.com/users/vext01/received_events","type":"User","site_admin":false},"assignees":[{"login":"vext01","id":604955,"avatar_url":"https://avatars1.githubusercontent.com/u/604955?v=3","gravatar_id":"","url":"https://api.github.com/users/vext01","html_url":"https://github.com/vext01","followers_url":"https://api.github.com/users/vext01/followers","following_url":"https://api.github.com/users/vext01/following{/other_user}","gists_url":"https://api.github.com/users/vext01/gists{/gist_id}","starred_url":"https://api.github.com/users/vext01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vext01/subscriptions","organizations_url":"https://api.github.com/users/vext01/orgs","repos_url":"https://api.github.com/users/vext01/repos","events_url":"https://api.github.com/users/vext01/events{/privacy}","received_events_url":"https://api.github.com/users/vext01/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2017-05-07T14:20:41Z","updated_at":"2017-05-08T14:51:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/softdevteam/rstreediff/pulls/2","html_url":"https://github.com/softdevteam/rstreediff/pull/2","diff_url":"https://github.com/softdevteam/rstreediff/pull/2.diff","patch_url":"https://github.com/softdevteam/rstreediff/pull/2.patch"},"body":"This PR makes the following improvements:\r\n\r\n  * The user can now specify two files on the command line (previously only one was expected)\r\n  * A new `treediff::ast` module provides a small implementation of an \"index tree\"  data structure to represent ASTs.\r\n  * A very simple calculator grammar has been added, to help with unit and integration tests.\r\n  * The user can pass in `-a` or `--ast` to dump out pretty-printed ASTs of the input files to STDOUT\r\n  * The user can pass in `-d FILENAME` or `--dot FILENAME` to dump out AST representations of the input file(s) in [graphviz](http://graphviz.org/) format. As well as adding confidence in the new AST code, this will hopefully useful for debugging later on.\r\n\r\nIndex trees are a Rust idiom for creating tree / graph structures. The core idea is to create an \"arena\" which is a vector of nodes in the tree/graph. Each node is a `struct` which contains \"pointers\" to related nodes (parent, siblings, children). These \"pointers\" are simply node ids -- i.e. indexes to the vector inside the arena. More complete implementations can be found elsewhere, e.g.:\r\n\r\n  * https://github.com/saschagrunert/indextree/\r\n  * https://github.com/SimonSapin/rust-forest/\r\n\r\nIn the implementation here, nodes contain a number of fields that store details from the parsed input file: indentation level, production name (e.g. `Expr`, `Term`, `Factor`, etc.) and literal values for terminals. More data may be added in later PRs, if necessary.\r\n\r\nThe index tree implementation here is just sufficient to create and prettty-print an AST, many features are missing (such as iterators, functions to calculate height, size, etc.), and will be added as needed.\r\n\r\n### Testing\r\n\r\nA number of unit and integration tests have been added in this PR. \r\n\r\nThe `-a` option on the command line should print ASTs in exactly the same format as the `lrpar` crate, e.g.:\r\n\r\n```sh\r\n$./target/debug/rstreediff tests/one.calc tests/add.calc -a\r\nExpr\r\n Term\r\n  Factor\r\n   INT 1\r\n\r\nExpr\r\n Term\r\n  Factor\r\n   INT 1\r\n PLUS +\r\n Expr\r\n  Term\r\n   Factor\r\n    INT 2\r\n\r\n$\r\n```\r\n\r\nThere are no integration tests for the code which renders a graphviz file, because the [dot](https://docs.rs/dot/0.1.2/dot/) crate renders its output directly to an open file. However, the results for the test files all seem sensible, e.g.:\r\n\r\n```sh\r\n$ ./target/debug/rstreediff tests/add.calc -d add.dot tests/Hello.java -d hello.dot\r\n$ dot add.dot -Tpng -oadd.png\r\n$ dot hello.dot -Tpng -ohello.png\r\n```\r\nproduces the following output:\r\n\r\n**add.png**\r\n![add](https://cloud.githubusercontent.com/assets/97674/25781916/0139233a-3338-11e7-9439-aa437cac5d89.png)\r\n\r\n**hello.png**\r\n![hello](https://cloud.githubusercontent.com/assets/97674/25781918/066d2ea0-3338-11e7-8548-04119d3e0b77.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/softdevteam/rstreediff/issues/comments/299889251","html_url":"https://github.com/softdevteam/rstreediff/pull/2#issuecomment-299889251","issue_url":"https://api.github.com/repos/softdevteam/rstreediff/issues/2","id":299889251,"user":{"login":"vext01","id":604955,"avatar_url":"https://avatars1.githubusercontent.com/u/604955?v=3","gravatar_id":"","url":"https://api.github.com/users/vext01","html_url":"https://github.com/vext01","followers_url":"https://api.github.com/users/vext01/followers","following_url":"https://api.github.com/users/vext01/following{/other_user}","gists_url":"https://api.github.com/users/vext01/gists{/gist_id}","starred_url":"https://api.github.com/users/vext01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vext01/subscriptions","organizations_url":"https://api.github.com/users/vext01/orgs","repos_url":"https://api.github.com/users/vext01/repos","events_url":"https://api.github.com/users/vext01/events{/privacy}","received_events_url":"https://api.github.com/users/vext01/received_events","type":"User","site_admin":false},"created_at":"2017-05-08T14:51:54Z","updated_at":"2017-05-08T14:51:54Z","body":"go for it"}}
{"actor":{"display_login":"vext01"}}