{"id":27078732,"url":"https://github.com/pkitazos/st-parser","last_synced_at":"2025-04-10T23:39:55.331Z","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-04-05T11:01:56.000Z","size":4362,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T20:17:29.328Z","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}},"created_at":"2025-04-04T20:59:16.000Z","updated_at":"2025-04-05T11:01:59.000Z","dependencies_parsed_at":"2025-04-09T20:17:29.200Z","dependency_job_id":null,"html_url":"https://github.com/pkitazos/st-parser","commit_stats":null,"previous_names":["pkitazos/st-parser"],"tags_count":0,"template":false,"template_full_name":null,"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","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125636,"owners_count":21051766,"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":["elixir","session-types"],"created_at":"2025-04-06T01:17:42.764Z","updated_at":"2025-04-10T23:39:55.288Z","avatar_url":"https://github.com/pkitazos.png","language":"Elixir","readme":"# ST 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### 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"}