{"id":21442085,"url":"https://github.com/norskeld/sigma","last_synced_at":"2025-08-15T15:09:10.141Z","repository":{"id":38443795,"uuid":"411972857","full_name":"norskeld/sigma","owner":"norskeld","description":"TypeScript parser combinator library for building fast and convenient parsers.","archived":false,"fork":false,"pushed_at":"2024-07-07T08:09:12.000Z","size":1904,"stargazers_count":29,"open_issues_count":12,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-08T20:27:00.128Z","etag":null,"topics":["combinators","hacktoberfest","parsec","parser","parser-combinators","typescript"],"latest_commit_sha":null,"homepage":"https://sigma.nrsk.dev","language":"TypeScript","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/norskeld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-09-30T07:52:37.000Z","updated_at":"2025-07-06T19:03:12.000Z","dependencies_parsed_at":"2024-04-15T22:50:50.077Z","dependency_job_id":"703f8af1-844f-4a98-8041-21675ee01eb0","html_url":"https://github.com/norskeld/sigma","commit_stats":{"total_commits":318,"total_committers":4,"mean_commits":79.5,"dds":0.2295597484276729,"last_synced_commit":"1de06aa0487397ebb578353ee9402b9dc7e1a1b0"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":"norskeld/serpent","purl":"pkg:github/norskeld/sigma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norskeld%2Fsigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norskeld%2Fsigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norskeld%2Fsigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norskeld%2Fsigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/norskeld","download_url":"https://codeload.github.com/norskeld/sigma/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norskeld%2Fsigma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270586172,"owners_count":24611314,"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-08-15T02:00:12.559Z","response_time":110,"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":["combinators","hacktoberfest","parsec","parser","parser-combinators","typescript"],"created_at":"2024-11-23T01:48:32.027Z","updated_at":"2025-08-15T15:09:10.070Z","avatar_url":"https://github.com/norskeld.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `𝝨` sigma\n\n[![Build/Test](https://img.shields.io/github/actions/workflow/status/norskeld/sigma/test.yml?style=flat-square\u0026colorA=22272d\u0026colorB=22272d)](https://github.com/norskeld/sigma/actions 'Build and test workflows')\n[![Coverage](https://img.shields.io/coverallsCoverage/github/norskeld/sigma?style=flat-square\u0026colorA=22272d\u0026colorB=22272d)](https://coveralls.io/github/norskeld/sigma 'Test coverage')\n[![NPM](https://img.shields.io/npm/v/@nrsk/sigma?style=flat-square\u0026colorA=22272d\u0026colorB=22272d)](https://npm.im/@nrsk/sigma 'This package on NPM')\n![Supported Node Versions](https://img.shields.io/node/v/%40nrsk/sigma?style=flat-square\u0026colorA=22272d\u0026colorB=22272d)\n[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/@nrsk/sigma?label=minzipped\u0026style=flat-square\u0026colorA=22272d\u0026colorB=22272d)](https://bundlephobia.com/package/@nrsk/sigma)\n![Tree Shaking](https://img.shields.io/static/v1?label=tree+shaking\u0026message=✔\u0026style=flat-square\u0026colorA=22272d\u0026colorB=22272d)\n[![Semantic Release](https://img.shields.io/static/v1?label=semantic+release\u0026message=✔\u0026style=flat-square\u0026colorA=22272d\u0026colorB=22272d)](https://github.com/semantic-release/semantic-release 'This package uses semantic release to handle releasing, versioning, changelog generation and tagging')\n\nTypeScript [parser combinator][parser-combinator] library for building fast and convenient parsers.\n\n## Features\n\n- [x] Capable of parsing [LL grammars][ll-grammar] using [recursive descent][rd] with backtracking.\n- [x] Ergonomic API with excellent TypeScript support.\n- [x] Zero dependencies. Supports tree shaking.\n- [x] [Performant enough][bench] to beat similar parser combinator libraries.\n\nAll-in-all, Sigma is easy to use and extend, reasonably fast and convenient, *but* a bit limited regarding what types of grammars it can parse.\n\n## Docs\n\nYou can find the documentation [here][docs]. If you want to contribute, feel free to check out [the source code][docs-source].\n\n## Installation\n\n### Node\n\nJust use your favorite package manager.\n\n```bash\nnpm i @nrsk/sigma\n```\n\n### Deno\n\nYou can import the library via [Skypack] (note the `?dts` query parameter, this is to pull types):\n\n```ts\nimport { ... } from 'https://cdn.skypack.dev/@nrsk/sigma?dts'\nimport { ... } from 'https://cdn.skypack.dev/@nrsk/sigma/parsers?dts'\nimport { ... } from 'https://cdn.skypack.dev/@nrsk/sigma/combinators?dts'\n```\n\n## Example\n\nBelow is an example of parsing nested tuples like `(1, 2, (3, 4))` into an AST.\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show the tuples example.\u003c/summary\u003e\n\n```ts\nimport { choice, map, optional, sepBy, sequence, takeMid } from '@nrsk/sigma/combinators'\nimport { defer, integer, run, string, whitespace } from '@nrsk/sigma/parsers'\nimport type { Span } from '@nrsk/sigma'\n\n/* AST. */\n\ninterface NumberNode {\n  type: 'number'\n  span: Span\n  value: number\n}\n\ninterface ListNode {\n  type: 'list'\n  span: Span\n  value: Array\u003cNumberNode | ListNode\u003e\n}\n\n/* Mapping functions to turn parsed string values into AST nodes. */\n\nfunction toNumber(value: number, span: Span): NumberNode {\n  return {\n    type: 'number',\n    span,\n    value\n  }\n}\n\nfunction toList(value: Array\u003cNumberNode | ListNode\u003e, span: Span): ListNode {\n  return {\n    type: 'list',\n    span,\n    value\n  }\n}\n\n/* Parsers. */\n\nconst OpenParen = string('(')\nconst CloseParen = string(')')\nconst Space = optional(whitespace())\nconst Comma = sequence(Space, string(','), Space)\n\nconst TupleNumber = defer\u003cNumberNode\u003e()\nconst TupleList = defer\u003cListNode\u003e()\n\nTupleNumber.with(\n  map(\n    integer(),\n    toNumber\n  )\n)\n\nTupleList.with(\n  map(\n    takeMid(\n      OpenParen,\n      sepBy(choice(TupleList, TupleNumber), Comma),\n      CloseParen\n    ),\n    toList\n  )\n)\n```\n\nThen we simply `run` the root parser, feeding it `with` text:\n\n```ts\nrun(TupleList).with('(1, 2, (3, 4))')\n```\n\nAnd in the end we get the following output with the AST, which can then be manipulated if needed:\n\n```ts\n{\n  isOk: true,\n  span: [ 0, 14 ],\n  pos: 14,\n  value: {\n    type: 'list',\n    span: [ 0, 14 ],\n    value: [\n      { type: 'number', span: [ 1, 2 ], value: 1 },\n      { type: 'number', span: [ 4, 5 ], value: 2 },\n      {\n        type: 'list',\n        span: [ 7, 13 ],\n        value: [\n          { type: 'number', span: [ 8, 9 ], value: 3 },\n          { type: 'number', span: [ 11, 12 ], value: 4 }\n        ]\n      }\n    ]\n  }\n}\n```\n\u003c/details\u003e\n\n## Development\n\nFork, clone, then instead of `npm install` run:\n\n```sh\nnpm run install:all\n```\n\n\u003e [!NOTE]\\\n\u003e This will install dependencies for the package itself, and also for **docs** and **benchmarks** packages. This is due to limitations of the current repository setup and needed to avoid problems with eslint that runs on pre-commit hook.\n\nThis project follows [the conventional commits spec][cc-spec] and uses [a slightly modified commitlint preset][commitlint-preset] for automatic linting commits and generating changelog.\n\n## License\n\n[MIT](LICENSE).\n\n\u003c!-- Links. --\u003e\n\n[ll-grammar]: https://en.wikipedia.org/wiki/LL_grammar\n[rd]: https://en.wikipedia.org/wiki/Recursive_descent_parser\n[parser-combinator]: https://en.wikipedia.org/wiki/Parser_combinator\n[cfg]: https://en.wikipedia.org/wiki/Context-free_grammar\n[docs]: https://sigma.nrsk.dev\n[docs-source]: ./docs\n[bench]: ./benchmarks\n[skypack]: https://skypack.dev\n[cc-spec]: https://conventionalcommits.org/en/v1.0.0/#summary\n[commitlint-preset]: https://github.com/norskeld/config-conventional\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorskeld%2Fsigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorskeld%2Fsigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorskeld%2Fsigma/lists"}