{"id":28316734,"url":"https://github.com/pkitazos/st_parser","last_synced_at":"2025-12-11T23:35:14.650Z","repository":{"id":286192915,"uuid":"960670354","full_name":"pkitazos/st_parser","owner":"pkitazos","description":"Simple Parser for Session Types","archived":false,"fork":false,"pushed_at":"2025-09-27T13:00:44.000Z","size":4379,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T14:42:19.784Z","etag":null,"topics":["elixir","session-types"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/pkitazos.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,"zenodo":null}},"created_at":"2025-04-04T20:59:16.000Z","updated_at":"2025-09-27T13:00:48.000Z","dependencies_parsed_at":"2025-06-24T06:31:15.904Z","dependency_job_id":"e0de7352-13d8-47db-ae50-9940f4d2885d","html_url":"https://github.com/pkitazos/st_parser","commit_stats":null,"previous_names":["pkitazos/st-parser","pkitazos/st_parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pkitazos/st_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkitazos%2Fst_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkitazos%2Fst_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkitazos%2Fst_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkitazos%2Fst_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkitazos","download_url":"https://codeload.github.com/pkitazos/st_parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkitazos%2Fst_parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27672129,"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-12-11T02:00:11.302Z","response_time":56,"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":["elixir","session-types"],"created_at":"2025-05-25T03:08:01.044Z","updated_at":"2025-12-11T23:35:14.643Z","avatar_url":"https://github.com/pkitazos.png","language":"Elixir","readme":"# Session Type Parser\n\nA simple, lightweight, flexible parser for Session Types in Elixir.\n\nST Parser converts textual session type descriptions into typed Elixir data structures, enabling formal verification and implementation of communication protocols between distributed system components.\n\n## What are Session Types?\n\nSession types provide a way to formally describe communication protocols between different roles in a distributed system. They let you specify:\n\n- Who sends messages to whom\n- What data is exchanged in those messages\n- The order of interactions\n- Choices and branches in the protocol flow\n\n## Features\n\n- Parse session type expressions into structured Elixir terms\n- Build session types programmatically with constructor functions\n- Handle complex session type constructs like input (external choice) and output (internal choice)\n- Support nested payload types (lists, tuples)\n- Clean and simple API for integration into larger projects\n\n## Installation\n\nAdd `st_parser` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:st_parser, \"~\u003e 0.4.1\"}\n  ]\nend\n```\n\n## Usage\n\n### Parsing Session Type Expressions\n\n```elixir\n# Parse a session type string into a structured type\n{:ok, session_type} = ST.Parser.parse(\"\u0026Server:{ Ack(unit).end }\")\n\n# Or use the bang version which raises on error\nsession_type = ST.Parser.parse!(\"\u0026Server:{ Ack(unit).end }\")\n\n# Parse just a payload type\n{:ok, payload_type} = ST.Parser.parse_type(\"(string, boolean[])\")\n```\n\n### Building Session Types Programmatically\n\n```elixir\n# Create an End type\nend_type = ST.end_session()\n\n# Create a simple branch\nack_branch = ST.branch(:ack, :unit, end_type)\n\n# Create an input type (receiving a message)\ninput_type = ST.input(:server, [ack_branch])\n# Or more concisely:\ninput_type = ST.input_one(:server, :ack, :unit, end_type)\n\n# Create an output type (sending a message)\noutput_type = ST.output_one(:client, :request, :binary, end_type)\n```\n\n### Using Session Type Sigils\n\nFor cleaner syntax and compile-time validation, you can use the `~q` sigil to define session types directly in your code:\n\n```elixir\nimport ST.Sigils\n\n# Define session types with clean, readable syntax\nauth_protocol = ~q/\n  \u0026Server:{\n    Login((string, string)).+Client:{\n      Success(unit).end,\n      Failure(string).end\n    }\n  }\n/\n\n# Access properties directly from the compiled struct\nIO.puts(\"Expecting message from: #{auth_protocol.from}\")\nIO.puts(\"First branch label: #{hd(auth_protocol.branches).label}\")\n```\n\nSigils provide the same functionality as ST.Parser.parse/1 but with compile-time parsing and validation, meaning syntax errors are caught when you compile rather than when your code runs.\n\n### Session Type Syntax\n\nSession type expressions use a concise syntax:\n\n```\n# Input (receiving messages)\n\u0026Role:{ Label1(PayloadType).Continuation, Label2(PayloadType).Continuation }\n\n# Output (sending messages)\n+Role:{ Label1(PayloadType).Continuation, Label2(PayloadType).Continuation }\n\n# Termination\nend\n```\n\nPayload types can be:\n\n- Basic types: `string`, `number`, `boolean`, `unit`\n- List types: `type[]` (e.g., `string[]`)\n- Tuple types: `(type1, type2, ...)` (e.g., `(string, number[])`)\n\n### Example: A Simple Request-Response Protocol\n\n```elixir\nrequest_response = \"\"\"\n\u0026Server:{\n  Request(string).+Client:{\n    Response((string, number[])).end,\n    Error(string).end\n  }\n}\n\"\"\"\n\n{:ok, protocol} = ST.Parser.parse(request_response)\n```\n\nThis describes a protocol where:\n1. The user sends a `Request` with a string payload to the server\n2. The client responds with either:\n   - A `Response` containing a tuple of a string and a number array, then ends\n   - An `Error` with a string message, then ends\n\n## Documentation\n\nFull documentation is available via ExDoc:\n\n```\nmix docs\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkitazos%2Fst_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkitazos%2Fst_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkitazos%2Fst_parser/lists"}