{"id":27867606,"url":"https://github.com/eteran/reader","last_synced_at":"2025-05-04T22:50:33.314Z","repository":{"id":65584209,"uuid":"341721128","full_name":"eteran/reader","owner":"eteran","description":"A class that makes writing a parser programatically easy","archived":false,"fork":false,"pushed_at":"2024-02-21T16:09:51.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-01T13:39:01.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/eteran.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-02-23T23:37:22.000Z","updated_at":"2024-02-01T06:49:35.000Z","dependencies_parsed_at":"2023-02-16T08:45:28.804Z","dependency_job_id":null,"html_url":"https://github.com/eteran/reader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Freader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Freader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Freader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Freader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eteran","download_url":"https://codeload.github.com/eteran/reader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252411807,"owners_count":21743604,"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":[],"created_at":"2025-05-04T22:50:32.799Z","updated_at":"2025-05-04T22:50:33.303Z","avatar_url":"https://github.com/eteran.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reader\nA class that makes writing a parser programmatically easy\n\n## Common usage patterns:\n\n### Tokenization\n\n```\nReader reader(source);\n\n// recommended that the tokens are sorted by length because the first match wins\nif (reader.match(\"++\")) {\n\t// make increment token\n} else if (reader.match(\"--\")) {\n\t// make decrement token\n}\n...\n```\n\n### Reading numbers (using a regex)\n\n```\nif (std::isdigit(reader.peek())) {\n\tstatic const std::regex integer_regex(R\"(^(0|[1-9][0-9]*))\");\n\tauto number = reader.match(integer_regex);\n\tif (!number) {\n\t\treturn invalid_numeric_constant();\n\t}\n\n\t// make sure that this is a valid integer that won't overflow\n\t// when converted to an integer\n\ttry {\n\t\t(void)std::stoi(*number, nullptr, 10);\n\t} catch (const std::out_of_range \u0026ex) {\n\t\t(void)ex;\n\t\treturn overflow_in_numeric_constant();\n\t}\n\n\t// create number token or convert to integer here\n}\n```\n\n### Match characters based on a predicate\n\n\n```\n// This effectively matches the regex: \"[a-zA-Z0-9_-]+\"\nauto key = reader.match_while([](char ch) {\n\treturn std::isalnum(ch) || ch == '-' || ch == '_';\n});\n\nif (!key) {\n    return malformed_key();\n}\nuse_character(*key);\n```\n\n### skipping whitespace\n```\nreader.consume_whitespace(); // skips ' ' and '\\t'\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feteran%2Freader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feteran%2Freader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feteran%2Freader/lists"}