{"id":18961401,"url":"https://github.com/nushell/new-nu-parser","last_synced_at":"2026-02-03T08:32:13.803Z","repository":{"id":243270150,"uuid":"811963719","full_name":"nushell/new-nu-parser","owner":"nushell","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-17T01:35:45.000Z","size":223,"stargazers_count":28,"open_issues_count":17,"forks_count":9,"subscribers_count":13,"default_branch":"main","last_synced_at":"2026-01-17T13:56:57.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nushell","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/nushell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing/typechecking.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-07T16:54:46.000Z","updated_at":"2026-01-17T01:35:49.000Z","dependencies_parsed_at":"2024-06-29T19:27:51.663Z","dependency_job_id":"bf53f85a-6647-42b6-a4bf-d9a231d528bf","html_url":"https://github.com/nushell/new-nu-parser","commit_stats":null,"previous_names":["nushell/new-nu-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nushell/new-nu-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nushell%2Fnew-nu-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nushell%2Fnew-nu-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nushell%2Fnew-nu-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nushell%2Fnew-nu-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nushell","download_url":"https://codeload.github.com/nushell/new-nu-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nushell%2Fnew-nu-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29038563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T06:39:36.383Z","status":"ssl_error","status_checked_at":"2026-02-03T06:39:32.787Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-08T14:12:39.686Z","updated_at":"2026-02-03T08:32:13.786Z","avatar_url":"https://github.com/nushell.png","language":"Nushell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# New Nushell Parser\n\nExperimental new parser for Nushell with the aim to eventually replace the old parser (including related data structures, such as EngineState).\n\nTo test it, run the parser on some file, e.g., `cargo run -- spam.nu`.\n\n## Goals\n\nThe goals of the new parser are:\n\n1. Readability, maintainability (making it easier for contributors to grasp and improve)\n2. Performance (we need faster parsing such that, for example, parsing standard library on Nushell startup should be instantaneous)\n3. Correctness (thanks to 1., it should be easier to iron out quirks of the old parser)\n\n## Structure\n\nUnlike the old parser, the new parser processes the source file in three stages:\n\n1. **Parsing**: Splitting the source file into tokens (lexing) and arranging them into AST nodes.\n2. **Resolving**: Binding symbol names to definitions such as commands or variables and making sure these names are visible in the scopes they are supposed to.\n3. **Typechecking**: Resolving / inferring types of values and making sure they match their expected types.\n\n(TBD) **Codegen**: Emitting Nushell's IR\n\nThis stage-based approach clearly separates what is being done and makes it easier to contribute.\nFor example, one can implement a syntax parsing for X inside the parsing stage without needing to worry about type checking just yet.\nThat can be added as an improvement.\nIn the old parser, all these stages were intertwined\n\nThe Compiler data structure holds the AST, similar to EngineState in the current Nushell (the Compiler might as well morph into EngineState over time).\nUnlike the old parser where AST was arranged in a tree structure, the new AST is just a flat vector of nodes, indexed by their position (NodeId) in the vector.\nThis new flat structure should bring better performance and makes the AST more inspectable.\n\nSome other notable differences vs. the old parser:\n\n- Syntax of keywords like `def` is directly embedded into the language instead of being a weird hybrid of a regular command with parser side effects.\n\n## Plans\n\nThe parser is mostly incomplete, whole swaths of features are missing.\nOnce we are able to emit some Nushell IR, we should start moving the parser to the main Nushell codebase behind a feature / CLI flag and work on integration with the rest of the engine etc.\n(To avoid engine-q situation as much as possible, for those who remember :-).)\n\n## Tests\n\nWith a great success we've used [`cargo insta`](https://github.com/mitsuhiko/insta).\nIt takes a bit used to working with the snapshots, but they are really useful for reviewing the impact of your changes.\n\n## Benchmarks\n\nWe use [tango](https://github.com/bazhenov/tango) for running the benchmarks.\nThis allows us to easily compare between different Git revisions.\n\nTo run the benchmarks (using `cargo-export`):\n\n1. `cargo export target/benchmarks/compiler -- bench` -- builds the benchmark binary in `target/benchmarks/parser`\n2. `target/benchmarks/compiler/benchmarks solo -s 100 --warmup true` -- run the benchmarks (`--help` to see the available CLI parameters)\n\nTo compare against another revision, build it in another directory, then run `\u003canother-directory\u003e/benchmarks compare \u003creference-directory\u003e ...options`.\nSee [this helper](https://github.com/nushell/nushell/blob/bdbcf829673c0a51805499832c20fab8a010733d/toolkit.nu#L498) in the Nushell repository for a more streamlined experience (the `benchmark-log` was written before the `solo` run option was available).\n\n## Contributing\n\nYou can just start hacking, the code should be more approachable than the old parser, and the stage-based structure makes it possible to split adding a feature into separate steps.\nIt's better to start small and keep the PRs focused.\n\nApart from coding the parser directly, we could use more tests, and organize the current ones better.\nPerhaps the test output can be printed better?\nAlso, old parser's tests can be brought over and in general, harmonizing the tests with the current Nushell's codebase would be a wise idea.\nThe CI can be expanded to include Windows.\nBenchmarks are missing (and should be added since our goal is performance!).\nIn other words, even if you don't want to code the parser directly, there are plenty other ways to contribute!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnushell%2Fnew-nu-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnushell%2Fnew-nu-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnushell%2Fnew-nu-parser/lists"}