{"id":16208699,"url":"https://github.com/cloudef/zig-fsm-compiler","last_synced_at":"2025-10-19T06:48:07.736Z","repository":{"id":214950688,"uuid":"737754460","full_name":"Cloudef/zig-fsm-compiler","owner":"Cloudef","description":"Ragel compatible FSM compiler for Zig","archived":false,"fork":false,"pushed_at":"2025-01-16T16:24:20.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T20:43:42.355Z","etag":null,"topics":["compiler","fsm","lexer","logic","parser","parsing","state","state-machine","state-management","tokenizer","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cloudef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-01-01T11:24:02.000Z","updated_at":"2025-03-01T18:03:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"360c0d9c-c4f5-49c0-b50c-d2f0ddf09777","html_url":"https://github.com/Cloudef/zig-fsm-compiler","commit_stats":null,"previous_names":["cloudef/zig-fsm-compiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cloudef/zig-fsm-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloudef%2Fzig-fsm-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloudef%2Fzig-fsm-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloudef%2Fzig-fsm-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloudef%2Fzig-fsm-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cloudef","download_url":"https://codeload.github.com/Cloudef/zig-fsm-compiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloudef%2Fzig-fsm-compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279727190,"owners_count":26217107,"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","status":"online","status_checked_at":"2025-10-19T02:00:07.647Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["compiler","fsm","lexer","logic","parser","parsing","state","state-machine","state-management","tokenizer","zig"],"created_at":"2024-10-10T10:25:19.021Z","updated_at":"2025-10-19T06:48:07.695Z","avatar_url":"https://github.com/Cloudef.png","language":"Zig","readme":"# zig-fsm-compiler\n\nRagel compatible FSM compiler for Zig\n\n\u003e [!CAUTION]\n\u003e This project is still in WIP stage.\n\u003e You won't be able to use it yet.\n\u003e\n\u003e Once the ragel language scanner itself can be compiled, it should be usable.\n\n---\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nProject is tested on zig version 0.12.0-dev.1861+412999621\n\n## How to use\n\nzig-fsm-compiler can be used either as a standalone compiler or directly from your zig program as a module.\n\n### Standalone usage\n\n```\nusage: zig-fsm-compiler [options] [file]\ngeneral:\n   -h, -H, -?, --help   Print this usage and exit\n   -v, --version        Print version information and exit\n   -o \u003cfile\u003e            Write output to \u003cfile\u003e\n   -s                   Print some statistics on stderr\n   -I \u003cdir\u003e             Add \u003cdir\u003e to the list of directories to search\n                        for included an imported files\nerror reporting format:\n   --error-format=gnu   file:line:column: message (default)\n   --error-format=msvc  file(line,column): message\nfsm minimization:\n   -n                   Do not perform minimization\nvisualization:\n   -V                   Generate a dot file for Graphviz\n   -p                   Display printable characters on labels\n   -S \u003cspec\u003e            FSM specification to output (for graphviz output)\n   -M \u003cmachine\u003e         Machine definition/instantiation to output (for graphviz output)\n```\n\n### Module usage\n\nFirst add zig-fsm-compiler to your project\n\n`build.zig.zon`\n```zig\n.fsm_compiler = .{\n  .url = \"https://github.com/Cloudef/zig-fsm-compiler/archive/{COMMIT}.tar.gz\",\n  .hash = \"{HASH}\",\n},\n```\n\n`build.zig`\n```zig\nconst fsm_compiler = b.dependency(\"fsm_compiler\", .{}).module(\"fsm-compiler\");\nexe.addModule(\"fsm-compiler\", fsm_compiler);\n```\n\n---\n\n`main.zig`\n```zig\nconst fsm_compiler = @import(\"fsm-compiler\");\n\nfn main() !void {\n  // TODO\n}\n```\n\n### Comptime usage\n\nIt is not possible to run the compiler itself comptime, but it is possible to use the generated output comptime.\nzig-fsm-compiler provides \"run artifact\" that can be used to generate machines from your `build.zig`.\n\n\u003e [!NOTE]\n\u003e Running compiler comptime may be possible once https://github.com/ziglang/zig/issues/14931 is fixed.\n\n`build.zig`\n```zig\nconst std = @import(\"std\");\nconst fsm_compiler = @import(\"fsm-compiler\");\n\npub fn build(b: *std.Build) void {\n  // TODO\n}\n```\n\n## Ragel\n\n[Ragel](https://www.colm.net/open-source/ragel) is a state machine compiler by Adrian Thurston.\nIt is highly recommended to read this [PDF](https://www.colm.net/files/ragel/ragel-guide-6.10.pdf) to learn the\nRagel language.\n\nzig-fsm-compiler is written by studying the above PDF, it contains no code from the actual Ragel project aside from\nthe modified `rlscan.rl` to bootstrap the initial version of the Ragel language parser.\n\n### Differences from Ragel\n\nWhile zig-fsm-compiler aims to be compatible with the Ragel language there are still differences.\n\n* Only zig target is supported for code generation.\n  - *Other languages may be supported in future, but it is not a priority.*\n* Actions with code only works if using code generation.\n  - *It is possible to bind functions to actions to get past this limitation.*\n* getkey, access, variable, write statements are ignored and hidden variables do not exist.\n  - *Instead the compiler generates a optimized machine and runner with an entrypoint for executing the machine.*\n  - *This means zig-fsm-compiler is not compatible with the output of Ragel.*\n* alphtype statement is ignored.\n  - *Instead the compiler always uses the smallest types possible for the optimized machine.*\n\n### Examples\n\n\u003e ![regex machine](./images/fsm-regex.png)\n\u003e ![kleene machine](./images/fsm-kleene.png)\n\u003e ![repetition machine](./images/fsm-repetition.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudef%2Fzig-fsm-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudef%2Fzig-fsm-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudef%2Fzig-fsm-compiler/lists"}