{"id":20027587,"url":"https://github.com/gothenburgbitfactory/rat","last_synced_at":"2026-06-09T19:31:21.879Z","repository":{"id":68631092,"uuid":"120088201","full_name":"GothenburgBitFactory/rat","owner":"GothenburgBitFactory","description":"rat is our new parser","archived":false,"fork":false,"pushed_at":"2018-05-13T18:40:18.000Z","size":212,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-02-14T04:58:22.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GothenburgBitFactory.png","metadata":{"files":{"readme":"README","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-03T12:16:03.000Z","updated_at":"2023-09-28T05:38:20.000Z","dependencies_parsed_at":"2023-06-19T12:08:28.648Z","dependency_job_id":null,"html_url":"https://github.com/GothenburgBitFactory/rat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GothenburgBitFactory/rat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GothenburgBitFactory%2Frat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GothenburgBitFactory%2Frat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GothenburgBitFactory%2Frat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GothenburgBitFactory%2Frat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GothenburgBitFactory","download_url":"https://codeload.github.com/GothenburgBitFactory/rat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GothenburgBitFactory%2Frat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34123171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":[],"created_at":"2024-11-13T09:10:54.460Z","updated_at":"2026-06-09T19:31:21.861Z","avatar_url":"https://github.com/GothenburgBitFactory.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"What is rat?\n=============\n\nRat is a packrat parser that uses a TPDL-like grammar. There are two components\ninvolved: PEG and Packrat. PEG is responsible for loading and validating the\ngrammar file. Packrat uses the syntax defined by the grammar to parse input.\n\n\nGrammar Syntax\n--------------\n\nThe grammar syntax is a text file which may contain comments that begin with\nthe '#' character:\n\n   # This is a comment\n\nA valid grammar defines at least one rule, contains no undefined rules, no\ndefined but unreferenced rules, and no left-recursion. The first rule defined\nis the top-level or entry rule, and represents the entire syntax. Here is a\ntypical first rule:\n\n   first: \"this\"\n          \"that\"\n\nThere are several syntactical elements here. The rule name is followed by a\ncolon, which makes this a rule definition. Everything between the colon and the\nnext blank line is the rule definition. This rule is named \"first\", and contains\ntwo alternate productions, each of which is a string literal (\"this\" and \"that\")\nfollowed by a blank line which terminates the definition.\n\nString literals always use double quotes. Character literals use single quotes,\nand the above could also be represented by the more verbose and less efficient:\n\n   first: 't' 'h' 'i' 's'\n          't' 'h' 'a' 't'\n\nThe indentation of the second line is only important in that it is not aligned\nat the left margin.\n\nAny unquoted word represents a grammar rule that must be defined. A rule may be\nfollowed by a quantifier, either '?', '+' or '*'. These correspond to the POSIX\nwildcard semantics of zero-or-one, one-or-more, and zero-or-more matches. Here\nis a grammar defining positive integers:\n\n   positive_integer: sign? digit+\n\n   sign:  '+'\n          '-'\n\n   digit: '0'\n          '1'\n          '2'\n          '3'\n          '4'\n          '5'\n          '6'\n          '7'\n          '8'\n          '9'\n\nNote the blank line between definitions, and only one production per line. Note\nthat 'sign' and 'digit' are leaf nodes, which contain no other rule references.\n\nThere are several built-in categories of character/token named intrinsics, and\nthese may be used to simplify grammar and speed parsing. The example above can\nuse the \u003cdigit\u003e intrinsic:\n\n   positive_integer: sign? \u003cdigit\u003e+\n\n   sign: '+'\n         '-'\n\nSupported intrinsics are:\n\n   \u003cdigit\u003e           Numeric digits: 0 ... 9\n   \u003chex\u003e             Hex digits: 0 ... 9, a ... f, A ... F\n   \u003cpunct\u003e           Punctuation: . , ; : ' \" ! ? etc\n   \u003calpha\u003e           Any single character that is printable, and not punctuation\n                     or whitespace\n   \u003ccharacter\u003e       Any one character\n   \u003cws\u003e              Any single white space character\n   \u003csep\u003e             Horizontal whitespace only\n   \u003ceol\u003e             Vertical whitespace only\n   \u003cword\u003e            Any consecutive string of non-whitespace, non-punctuation\n   \u003ctoken\u003e           Any consecutive string of non-whitespace\n\nEntities are literal strings that are defined externally, and represented in the\ngrammar as:\n\n   \u003centity:thing\u003e\n\nThis construct matches any of the externally provided entities in the 'thing'\ncategory. Entities are provided at runtime before a grammar is loaded. This\ncapability allows for dynamic lists, such as user-defined reports, command, or\nextensions.\n\nFurther dynamic support is available using the external intrinsic:\n\n   \u003cexternal:thing\u003e\n\nIn this case, the parsing is delegated to an external function call, identified\nby the name 'thing'. External intrinsics allow complex parsing situations that\nare not readily expressed in PEG.\n\nGrammar files can grow large, and definitions may be shared across projects. To\nfacilitate this, grammar files may be imported using this syntax:\n\n   import \u003cfile\u003e\n\nWhere the file is a resolvable path from the current working directory.\n\n\nHow to Construct a Grammar\n--------------------------\n\nA grammar is a tree structure. The easiest way to construct that tree is one\nbranch at a time. Start by defining the first rule which references a leaf node\nand add to that. Test the syntax at every step by running something like this:\n\n   $ ./rat -d integer.peg '-23'\n\nThis will load the grammar in the integer.peg file, and if valid, will attempt\nto parse the input '-23' against that grammar.\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgothenburgbitfactory%2Frat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgothenburgbitfactory%2Frat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgothenburgbitfactory%2Frat/lists"}