{"id":16359942,"url":"https://github.com/superjmn/statemachinecompiler","last_synced_at":"2025-03-23T01:32:20.899Z","repository":{"id":75248277,"uuid":"158114442","full_name":"SuperJMN/StateMachineCompiler","owner":"SuperJMN","description":"State Machine Compiler inspired by Uncle Bob","archived":false,"fork":false,"pushed_at":"2019-11-03T16:17:49.000Z","size":46,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T16:40:27.833Z","etag":null,"topics":["clean-code","compiler","csharp","dotnet","finite-state-machine","parser-combinators","visitor-pattern"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SuperJMN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-18T18:31:12.000Z","updated_at":"2024-06-01T09:11:12.000Z","dependencies_parsed_at":"2023-06-05T20:45:26.368Z","dependency_job_id":null,"html_url":"https://github.com/SuperJMN/StateMachineCompiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperJMN%2FStateMachineCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperJMN%2FStateMachineCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperJMN%2FStateMachineCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperJMN%2FStateMachineCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SuperJMN","download_url":"https://codeload.github.com/SuperJMN/StateMachineCompiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245044108,"owners_count":20551878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-code","compiler","csharp","dotnet","finite-state-machine","parser-combinators","visitor-pattern"],"created_at":"2024-10-11T02:10:04.630Z","updated_at":"2025-03-23T01:32:20.891Z","avatar_url":"https://github.com/SuperJMN.png","language":"C#","readme":"# State Machine Compiler\nState Machine Compiler inspired by [Robert C. Martin](https://twitter.com/unclebobmartin), AKA \"Uncle Bob\", and his work.\n\nThis the State Machine Compiler (SMC) that Robert C. Martin builds in episodes [28](https://cleancoders.com/episode/clean-code-episode-28/show), [29](https://cleancoders.com/episode/clean-code-episode-29/show) and [30](https://cleancoders.com/episode/clean-code-episode-30/show) of [Clean Coders](https://cleancoders.com/), built from scratch in C#. \n\nIt can be used to create Finite State Machines in several programming languages, like Java, C, Python, and C#, of course. In fact, it's built on C# 😄\n\n# Syntax\n```\nActions: Turnstile\nFSM: TwoCoinTurnstile\nInitial: Locked\n{\n\t(Base)  Reset  Locked  Lock\n\tLocked : Base \n\t{\n\t\tPass  Alarming   -\n\t\tCoin  FirstCoin  -\n\t}\n                  \n\tAlarming : Base  \u003eAlarmOn \u003cAlarmOff \n\t{\n        \t-\t-\t-\n\t}\n                          \n\tFirstCoin : Base \n\t{\n        \tPass\tAlarming\t-\n\t\tCoin\tUnlocked\tUnlock\n\t}\n                          \n\tUnlocked : Base \n\t{\n\t\tPass\tLocked  Lock\n\t\tCoin\t-\tThankYou\n\t}\n}\n```\n\nThe syntax is quite easy to understand:\n\n- The first 3 lines are the **header**.\n- After the header, there is a block enclosed with braces, this block is the definition of the **transitions** of the Finite State Machine (FSM)\n- Each each transition consists of 4 values: `current state, event, next state, actions`. Notice that the actions can be 0 or more values enclosed by braces, like {action1, action2, ...)\n  For instance `dry rain wet { getUmbrella, getCoat }`. That means: given the \"dry\" state, when the `rain` event is received, turn to the `wet` state and execute the `getUmbrella` and `getCoat` actions\n- However, the transitions of one state can be grouped under a block like this:\n\t```\n\tcurrentState \n\t{ \n\t\tevent, state, actions\n\t\tevent, state, actions\n\t}\n\t```\n- The hyphen (**-**). It's a placeholder to indicate \"nothing\" or \"unchanged\". For instance, if a transition has its `next state` to **-**, it means that the next state is remains the same (the state won't change).\n\nThere are some cool features to make it easier to define the states:\n- **Base states.** A state can derive from a base state, inheriting the transitions from the base state. It's denoted by `State : Base`\n- **Entry and exit actions.** You can define which actions happen every time a state enters or exists.  Entry actions are denoted by `\u003eaction` and exit actions are denoted by `\u003caction`\n- **Abstract states.** They are states that only exists so other states can derive from it. They don't translate to a real state. They are denoted by `(state)` (the name between parentheses).\n\n# Credits\n\n- [Robert C. Martin](https://twitter.com/unclebobmartin) for his wonderful lessons at [Clean Coders](https://cleancoders.com/)\n- [Nicholas Blumhardt](https://github.com/nblumhardt) for the great parser combinator library [Superpower](https://github.com/nblumhardt/superpower)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperjmn%2Fstatemachinecompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperjmn%2Fstatemachinecompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperjmn%2Fstatemachinecompiler/lists"}