{"id":17030771,"url":"https://github.com/frankshearar/fred","last_synced_at":"2026-01-19T12:33:29.438Z","repository":{"id":19007247,"uuid":"22229845","full_name":"frankshearar/Fred","owner":"frankshearar","description":"Parsing with derivatives in F#","archived":false,"fork":false,"pushed_at":"2018-03-21T05:03:05.000Z","size":604,"stargazers_count":1,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-11T23:56:36.023Z","etag":null,"topics":["derivative","f-sharp","parser"],"latest_commit_sha":null,"homepage":null,"language":"F#","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/frankshearar.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":"2014-07-24T20:29:06.000Z","updated_at":"2019-07-17T00:09:01.000Z","dependencies_parsed_at":"2022-09-25T03:41:37.058Z","dependency_job_id":null,"html_url":"https://github.com/frankshearar/Fred","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankshearar%2FFred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankshearar%2FFred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankshearar%2FFred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankshearar%2FFred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frankshearar","download_url":"https://codeload.github.com/frankshearar/Fred/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399887,"owners_count":20932880,"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":["derivative","f-sharp","parser"],"created_at":"2024-10-14T08:08:12.347Z","updated_at":"2025-04-05T21:14:23.012Z","avatar_url":"https://github.com/frankshearar.png","language":"F#","readme":"FRED\n----\n\nFred is an experiment in learning F# through implementing [parsing with derivatives](http://matt.might.net/articles/parsing-with-derivatives/).\n\nThe initial implementation uses the [standard](http://dl.acm.org/citation.cfm?id=321249) [Brzozowski derivative](http://www.mpi-sws.org/~turon/re-deriv.pdf) of a regular expression.\n\nLater work will implement Matt Might, David Darais and Daniel Spiewak's work on extending derivative parsing to context free grammars.\n\nAt the moment the project is largely feature complete for the regular languages, with a C#-friendly wrapper.\n\nDefining parsers\n----------------\n\nIn C#:\n````csharp\n// To find all strings \"aaa\" (or /a{3}/ if you prefer):\nRegularParser.Token('a').Count(3)\n\n// /abc(d|e)/\nusing P = Fred.RegularExpression.RegularParser;\nP.Token('a').Then(P.Token('b')).Then(P.Token('c')).Then(P.Token('d').Or(P.Token('e')))\n\n// /(ab)*/\n(RegularParser.Token('a').Then(RegularParser.Token('b')).Star()\n\n// /a?/\nRegularParser.Token('a').AtMost(1)\n````\n\nIn F#:\n````fsharp\n// To find all strings \"aaa\" (or /a{3}/ if you prefer):\nrep 3 (Char 'a')\n\n// /abc(d|e)/\nCat (all ['a'; 'b'; 'c'], Union (Char 'd', Char 'e'))\n // or, because a string is a sequence of char:\nCat (all (List.ofSeq \"abc\"), Union (Char 'd', Char 'e'))\n\n// /(ab)*/\n(all (List.ofSeq \"ab\")) |\u003e Star\n\n// /a?/\nChar 'a' |\u003e opt\n````\n\nFinding things\n--------------\n\nIn C#:\n````csharp\nRegularParser.Num().Count(3,6).Recognise(\"123456\")\n````\n\nIn F#:\n````fsharp\n// In which we not only find stuff, we find stuff in partial input: useful for\n// handling slow/buffered input, like reading off a socket.\nlet ab = all ['a';'b']\nlet finder = startFind ab\nlet someProcessedInput = resumableFind finder \"abab\"\nlet someMoreProcessing = resumableFind someProcessedInput \"abab\"\nfinishFind someMoreProcessing\n````\n\nTODO\n----\n* Publish on NuGet\n* Implement support for extended REs.\n* Implement/fix derivatives for context-free grammars\n\n[![Build status on .NET](https://ci.appveyor.com/api/projects/status/8ix7agowa8rrfu1k/branch/master)](https://ci.appveyor.com/project/frankshearar/fred/branch/master)\n[![Build Status on Mono](https://secure.travis-ci.org/frankshearar/Fred.png?branch=master)](http://travis-ci.org/frankshearar/Fred)\n\nLicence\n-------\nCopyright (C) 2014 by Frank Shearar\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankshearar%2Ffred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankshearar%2Ffred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankshearar%2Ffred/lists"}