{"id":25663777,"url":"https://github.com/maxxsoft/laps","last_synced_at":"2025-10-13T04:36:38.738Z","repository":{"id":62022018,"uuid":"543960655","full_name":"MaxXSoft/laps","owner":"MaxXSoft","description":"Build lexers and parsers by deriving traits.","archived":false,"fork":false,"pushed_at":"2024-01-03T08:04:07.000Z","size":833,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T15:53:33.728Z","etag":null,"topics":["lexer","parse","parser","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/laps","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaxXSoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-01T09:05:28.000Z","updated_at":"2024-11-16T07:38:21.000Z","dependencies_parsed_at":"2024-01-03T09:27:21.257Z","dependency_job_id":"bc503578-a9ed-49d1-83af-6032276484e7","html_url":"https://github.com/MaxXSoft/laps","commit_stats":{"total_commits":271,"total_committers":1,"mean_commits":271.0,"dds":0.0,"last_synced_commit":"150734181b1f82bec83a5c49bd55f107d68929f7"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxXSoft%2Flaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxXSoft%2Flaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxXSoft%2Flaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxXSoft%2Flaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxXSoft","download_url":"https://codeload.github.com/MaxXSoft/laps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240420985,"owners_count":19798505,"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":["lexer","parse","parser","rust"],"created_at":"2025-02-24T05:19:02.119Z","updated_at":"2025-10-13T04:36:33.702Z","avatar_url":"https://github.com/MaxXSoft.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laps\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-MaxXSoft/laps-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/MaxXSoft/laps)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/laps.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/laps)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-laps-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K\" height=\"20\"\u003e](https://docs.rs/laps)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/MaxXSoft/laps/build-test.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/MaxXSoft/laps/actions?query=branch%3Amaster)\n\nLexer and parser collections.\n\nWith `laps`, you can build lexers/parsers by just defining tokens/ASTs and deriving `Tokenize`/`Parse` trait for them.\n\n## Usage\n\nAdd `laps` to your project by running `cargo add`:\n\n```\ncargo add laps --features macros\n```\n\n## Example\n\nImplement a lexer for [S-expression](https://en.wikipedia.org/wiki/S-expression):\n\n```rust\nuse laps::prelude::*;\n\n#[token_kind]\n#[derive(Debug, Tokenize)]\nenum TokenKind {\n  // This token will be skipped.\n  #[skip(r\"\\s+\")]\n  _Skip,\n  /// Parentheses.\n  #[regex(r\"[()]\")]\n  Paren(char),\n  /// Atom.\n  #[regex(r\"[^\\s()]+\")]\n  Atom(String),\n  /// End-of-file.\n  #[eof]\n  Eof,\n}\n```\n\nAnd the parser and [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (or actually [CSTs](https://en.wikipedia.org/wiki/Parse_tree)):\n\n```rust\ntype Token = laps::token::Token\u003cTokenKind\u003e;\n\ntoken_ast! {\n  macro Token\u003cTokenKind\u003e {\n    [atom] =\u003e { kind: TokenKind::Atom(_), prompt: \"atom\" },\n    [lpr] =\u003e { kind: TokenKind::Paren('(') },\n    [rpr] =\u003e { kind: TokenKind::Paren(')') },\n    [eof] =\u003e { kind: TokenKind::Eof },\n  }\n}\n\n#[derive(Parse)]\n#[token(Token)]\nenum Statement {\n  Elem(Elem),\n  End(Token![eof]),\n}\n\n#[derive(Parse)]\n#[token(Token)]\nstruct SExp(Token![lpr], Vec\u003cElem\u003e, Token![rpr]);\n\n#[derive(Parse)]\n#[token(Token)]\nenum Elem {\n  Atom(Token![atom]),\n  SExp(SExp),\n}\n```\n\nThe above implementation is very close in form to the corresponding EBNF representation of the S-expression:\n\n```ebnf\nStatement ::= Elem | EOF;\nSExp      ::= \"(\" {Elem} \")\";\nElem      ::= ATOM | SExp;\n```\n\n## More Examples\n\nSee the [`examples` directory](examples), which contains the following examples:\n\n* [`sexp`](examples/sexp): a [S-expression](https://en.wikipedia.org/wiki/S-expression) parser.\n* [`calc`](examples/calc): a simple expression calculator.\n* [`json`](examples/json): a simple JSON parser.\n* [`clike`](examples/clike): interpreter for a C-like programming language.\n\n## Accelerating Code Completion for IDEs\n\nBy default, Cargo does not enable optimizations for procedural macros, which may result in slower code completion if you are using `laps` to generate lexers. To avoid this, you can add the following configuration to `Cargo.toml`:\n\n```toml\n[profile.dev.build-override]\nopt-level = 3\n```\n\nYou can also try to manually enable/disable parallelization for lexer generation by adding:\n\n```rust\n#[derive(Tokenize)]\n#[enable_par(true)] // or #[enable_par(false)]\nenum TokenKind {\n  // ...\n}\n```\n\nThe parallelization setting only affects compilation speed and has no effect at runtime, it's set automatically by `laps` by default.\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n## License\n\nCopyright (C) 2022-2023 MaxXing. Licensed under either of [Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) at your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxxsoft%2Flaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxxsoft%2Flaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxxsoft%2Flaps/lists"}