{"id":32111630,"url":"https://github.com/alehed/rex","last_synced_at":"2026-02-17T22:32:57.427Z","repository":{"id":62424336,"uuid":"72149733","full_name":"alehed/rex","owner":"alehed","description":"A DSL for deterministic finite state machines","archived":false,"fork":false,"pushed_at":"2018-06-13T17:28:35.000Z","size":59,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T14:54:12.318Z","etag":null,"topics":["dfa","dsl","racket","regular-expression"],"latest_commit_sha":null,"homepage":null,"language":"Racket","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/alehed.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":"2016-10-27T21:28:48.000Z","updated_at":"2023-05-27T09:37:45.000Z","dependencies_parsed_at":"2022-11-01T18:00:57.145Z","dependency_job_id":null,"html_url":"https://github.com/alehed/rex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/alehed/rex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alehed%2Frex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alehed%2Frex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alehed%2Frex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alehed%2Frex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alehed","download_url":"https://codeload.github.com/alehed/rex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alehed%2Frex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29560855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["dfa","dsl","racket","regular-expression"],"created_at":"2025-10-20T14:43:02.569Z","updated_at":"2026-02-17T22:32:57.413Z","avatar_url":"https://github.com/alehed.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rex\n\nA proof of concept implementation of a language to describe DFAs.\n\n\n## What is wrong with regexes?\n\nRegular expressions are used in a lot of places where they are clearly not the\nbest tool for the job. For example take syntax highlighting, where we should\nuse parsers instead. If you take a look at some source code written in a\nlanguage with built in support for regular expressions (Perl, Ruby, etc.)\nyou'll likely find other atrocious uses.\n\nThe problem is that regular expressions make it very easy to write expressions\nthat generate a lot of code and are slow (see theoretical background info).\n\nThis approach makes it really hard to write inefficient expressions. Execution\ntime and memory usage of a rex is roughly proportional to the length of the\nexpression.\n\nIs this approach better? I don't know, decide for yourself if you like it.\n\n### Theoretical Background\n\nFrom a mathematical standpoint the problems with regular expressions are the\nfollowing:\n\nRegular expressions are easily translated into non-deterministic finite\nautomata (NFA), while a computer can only execute deterministic finite state\nmachines (DFA). The two are mathematically equivalent and can be converted into\none another, but at a price: To convert an NFA into a DFA the number of states\nin the DFA will be O(2^(n)) in the worst case. This makes execution times\nunpredictable for the person writing the expression. So conversion from a NFA\nto a DFA is hard and expensive.\n\nThe other way around is similar: if we have an arbitrary DFA and we want to get\na regular expression from it, conversion is also hard and the length of the\nregular expression is O(2^(n)) in the worst case (where n is the number of\nstates in the DFA). This time you probably get a fast regex but it's really\nhard to write it.\n\nAnd there are extensions to regular expressions that are implemented by some\nengines that take them into the area of context-sensitive languages which makes\nexecution times even worse.\n\nThe solution here is that if you try to specify anything other than what\ndirectly generates a DFA, it will complain and fail.\n\n\u003e Note: Strictly speaking the automata generated are not DFAs because they\n\u003e don't include an explicit fail state, but adding one is cheap so that is what\n\u003e is done here.\n\n\n## Installation\n\n### For regular usage\n\n1. Install [Racket](https://racket-lang.org)\n1. Install the package using raco: `raco pkg install rex`\n1. Enjoy\n\n### For development\n\n1. Install [Racket](https://racket-lang.org)\n1. Clone this repository\n1. Install it as a local package using raco: `raco pkg install ./rex`\n1. Enjoy\n\n## Usage\n\nCreate a file that has `#lang rex` as the first line.\n\nThe initial line is followed by the actual expression.\n\nA basic rex that matches the string \"abc\" but nothing else looks like this.\n```\n#lang rex\nabc\n```\n\nThis file would be executed by running: `racket abc.rkt \"abc\" \"abcd\"`. This should print `(#t #f)` since the first expression was matched successfully while the second one was not.\n\nFor other options and flags consult `racket filename.rkt --help`.\n\n### Syntax\n\nFor a detailed documentation of the syntax, please consult the [documentation](http://docs.racket-lang.org/rex).\n\n## Contributing\n\n\u003e “On the internet nothing ever happens by asking permission.” – Don't remember\n\nJust fork away, PRs welcome.\n\nThe test-suite is run with `raco test -p rex`. Make sure it runs before every\ncommit. New features should preferably add a corresponding file in `tests/`.\n\n### Development\n\nOnce you added your changes you have to recompile the package using\n`raco setup --pkgs rex` otherwise racket will complain with:\n\n```\nlink: module mismatch;\n possibly, bytecode file needs re-compile because dependencies changed\n```\n\n## Future\n\nIn the long term if this turns out to be useful, probably a fast implementation\nin C is desirable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falehed%2Frex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falehed%2Frex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falehed%2Frex/lists"}