{"action":"created","issue":{"url":"https://api.github.com/repos/softdevteam/lrpar/issues/19","labels_url":"https://api.github.com/repos/softdevteam/lrpar/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/softdevteam/lrpar/issues/19/comments","events_url":"https://api.github.com/repos/softdevteam/lrpar/issues/19/events","html_url":"https://github.com/softdevteam/lrpar/pull/19","id":101670489,"number":19,"title":"Added function to build stategraphs","user":{"login":"ptersilie","id":375552,"avatar_url":"https://avatars.githubusercontent.com/u/375552?v=3","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-18T14:31:35Z","updated_at":"2015-08-18T14:47:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/softdevteam/lrpar/pulls/19","html_url":"https://github.com/softdevteam/lrpar/pull/19","diff_url":"https://github.com/softdevteam/lrpar/pull/19.diff","patch_url":"https://github.com/softdevteam/lrpar/pull/19.patch"},"body":"This function takes a `Grammar` as input and then builds a `StateGraph` containing all states and their edges.\r\n\r\nThe `test_stategraph` uses the following grammar:\r\n\r\n```\r\nZ : S\r\nS : Sb\r\n    bAa\r\nA : aSc\r\n    a\r\n    aSb\r\n```\r\n\r\nthe resulting graph looks like this (with one extra state `Start! : Z. {$}` and an additional rule `Start! : .Z {$}` in State #0):\r\n![test_grammar](https://cloud.githubusercontent.com/assets/375552/9332722/f8465e64-45bd-11e5-963a-4da09019e6c5.png)\r\nNote that the state numbers may be different each execution due to the `LR1Items` being stored in a `HashSet` and thus being processed in arbitrary order."},"comment":{"url":"https://api.github.com/repos/softdevteam/lrpar/issues/comments/132237059","html_url":"https://github.com/softdevteam/lrpar/pull/19#issuecomment-132237059","issue_url":"https://api.github.com/repos/softdevteam/lrpar/issues/19","id":132237059,"user":{"login":"ptersilie","id":375552,"avatar_url":"https://avatars.githubusercontent.com/u/375552?v=3","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},"created_at":"2015-08-18T14:47:05Z","updated_at":"2015-08-18T14:47:05Z","body":"Here is what the algorithm does:\r\n\r\n1) Create a state 0 and build it's closure.\r\n2) For each Symbol `s` next to the `dot` in state 0, use `goto1` to generate the states that follow after the parser reads `s`\r\n3) a) Give the new state a unique state id and create an edge (state0, `s`) -> unique_id\r\n    b) If the state already exists, just create an edge from the current state to the existing one\r\n4) Repeat from step 2) with all newly added states, until no new states are being added"}}