{"id":19570767,"url":"https://github.com/lalloni/seared","last_synced_at":"2025-02-26T10:41:28.295Z","repository":{"id":139298854,"uuid":"81996558","full_name":"lalloni/seared","owner":"lalloni","description":"Lightweight PEG-based text parsing in Golang without code generation.","archived":false,"fork":false,"pushed_at":"2017-03-21T11:00:21.000Z","size":44,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-09T02:55:15.158Z","etag":null,"topics":["go","golang","parser","parser-library","parsing","parsing-expression-grammar","peg","text"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lalloni.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,"governance":null}},"created_at":"2017-02-14T22:42:18.000Z","updated_at":"2024-09-11T00:45:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"8142885b-7b23-40c7-80df-41fa7023855c","html_url":"https://github.com/lalloni/seared","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/lalloni%2Fseared","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalloni%2Fseared/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalloni%2Fseared/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalloni%2Fseared/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lalloni","download_url":"https://codeload.github.com/lalloni/seared/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240839576,"owners_count":19866162,"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":["go","golang","parser","parser-library","parsing","parsing-expression-grammar","peg","text"],"created_at":"2024-11-11T06:16:20.622Z","updated_at":"2025-02-26T10:41:28.157Z","avatar_url":"https://github.com/lalloni.png","language":"Go","readme":"Seared\n======\n\n*Seared* is a Go library targeted at allowing easy implementation of text parsers based on powerful [Parsing Expression Grammars](https://en.wikipedia.org/wiki/Parsing_expression_grammar) without the hassle of parser generation steps, while trying to be easy to use, lightweight and appropriate for high-performance parsing needs.\n\nSo, how does a grammar definition look in practice? The well-known example \"calculator\" grammar can be defined like this:\n\n```go\nfunc Number(r *seared.Rules) seared.Rule {\n    return r.Rule(func() seared.Rule {\n        return r.OneOrMore(r.Range('0', '9'))\n    })\n}\n\nfunc Factor(r *seared.Rules) seared.Rule {\n    return r.Rule(func() seared.Rule {\n        return r.Choice(Number(r), r.Sequence(r.Rune('('), Sum(r), r.Rune(')')))\n    })\n}\n\nfunc Term(r *seared.Rules) seared.Rule {\n    return r.Rule(func() seared.Rule {\n        return r.Sequence(Factor(r), r.ZeroOrMore(r.Any(\"*/\"), Factor(r)))\n    })\n}\n\nfunc Sum(r *seared.Rules) seared.Rule {\n    return r.Rule(func() seared.Rule {\n        return r.Sequence(Term(r), r.ZeroOrMore(r.Any(\"+-\"), Term(r)))\n    })\n}\n\nfunc Operation(r *seared.Rules) seared.Rule {\n    return r.Rule(func() seared.Rule {\n        return r.Sequence(Sum(r), r.End())\n    })\n}\n\nfunc Calculator() *seared.Parser {\n    return seared.NewParser(Operation)\n}\n```\n\nAnd this is how that parser could be directly used for syntax recognizing:\n\n```go\nparser := Calculator()\nsuccess := parser.Recognize(\"2+1*3+4*(2-1)\")\n```\n\nLicense\n=======\n\n*Seared* is released under the [Simplified BSD License](./LICENSE) which can be found at the root of this project.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalloni%2Fseared","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flalloni%2Fseared","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalloni%2Fseared/lists"}