{"id":26207213,"url":"https://github.com/oelin/april","last_synced_at":"2025-06-15T14:07:33.107Z","repository":{"id":57182994,"uuid":"357180598","full_name":"oelin/april","owner":"oelin","description":"Probably the smallest recursive descent parser in existence 🤏.","archived":false,"fork":false,"pushed_at":"2023-01-17T12:11:13.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-30T09:04:05.606Z","etag":null,"topics":["javascript","parser","recursive-descent-parser","tiny"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/oelin.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}},"created_at":"2021-04-12T12:13:28.000Z","updated_at":"2023-03-10T01:04:40.000Z","dependencies_parsed_at":"2023-02-10T09:25:13.884Z","dependency_job_id":null,"html_url":"https://github.com/oelin/april","commit_stats":null,"previous_names":["oelin/aprils"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oelin%2Fapril","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oelin%2Fapril/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oelin%2Fapril/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oelin%2Fapril/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oelin","download_url":"https://codeload.github.com/oelin/april/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243165525,"owners_count":20246721,"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":["javascript","parser","recursive-descent-parser","tiny"],"created_at":"2025-03-12T05:31:18.546Z","updated_at":"2025-03-12T05:31:19.104Z","avatar_url":"https://github.com/oelin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# April 🌺\n\nProbably the smallest recursive descent parser in existence 🤏.\n\n```js\nconst { match, peek, feed } = require('april')\n\nfunction letters() {\n  return match(/^\\w+/)\n}\n\nfunction separator() {\n  return match(/^\\W*/) // stuff like spaces and periods\n}\n\nfunction word() {\n  sparator()\n  return letters()\n}\n```\n\nLet's test it out!\n\n\n```js\nfeed('Luke, I am your father')\n\nword() // returns 'Luke'\nword() // returns 'I'\"\nword() // returns 'am'\n```\n\n### Use peek to check the next token\n\n```js\nfunction upper() {\n  return match(/^[A-Z]/)\n}\n\nfunction lower() {\n  return match(/^[a-z]/)\n}\n\nfeed(\"AbCdE\")\n\npeek(upper) // returns `true` because the next token is uppercase\npeek(lower) // returns `false` because the next token isn't lowercase\n```\n\n### Use skip to add choices\n\n```js\nconst { skip } = require('aprils')\n\n// match lowercase or uppercase\n\nfunction letter() {\n  return skip(lower) || upper()\n}\n\nfeed('AbC')\n\nletter() // returns 'A'\nletter() // returns 'b'\nletter() // returns 'C'\n```\n\nYou can add more choices using JavaScript's `||` operator\n\n```js\n// accept A or B or ... or Z\n\nskip(A) || skip(B) || ... || skip(Y) || Z()\n```\n\n\n## API\n\n### feed(string)\n\nSets the input string.\n\n### match(pattern)\n\nConsumes and returns part of the input string that matches `pattern`. Note that `pattern` should start with `^` to match from the start of the input string.\n\n\n### peek(parser, [args...])\n\nExecutes a parser and returns true if it was successful. The input string isn't consumed.\n\n### skip(parser, [args...])\n\nExecutes a parser and returns the result if it was successful. The input string is only consumed on success.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foelin%2Fapril","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foelin%2Fapril","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foelin%2Fapril/lists"}