{"id":13413972,"url":"https://github.com/askeladdk/prattle","last_synced_at":"2026-01-14T13:14:34.509Z","repository":{"id":65483885,"uuid":"365477480","full_name":"askeladdk/prattle","owner":"askeladdk","description":"Scan and parse LL(1) grammars simply and efficiently.","archived":false,"fork":false,"pushed_at":"2025-10-19T09:32:31.000Z","size":38,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T13:31:06.468Z","etag":null,"topics":["go","golang","lexer","lexer-parser","parser","parser-library","pratt-parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/askeladdk.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":"2021-05-08T09:49:59.000Z","updated_at":"2025-10-19T09:31:30.000Z","dependencies_parsed_at":"2023-02-14T06:45:17.559Z","dependency_job_id":"ec00d522-e075-44b9-99d1-35e3642a69e8","html_url":"https://github.com/askeladdk/prattle","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/askeladdk/prattle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askeladdk%2Fprattle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askeladdk%2Fprattle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askeladdk%2Fprattle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askeladdk%2Fprattle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/askeladdk","download_url":"https://codeload.github.com/askeladdk/prattle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askeladdk%2Fprattle/sbom","scorecard":{"id":212303,"data":{"date":"2025-08-11","repo":{"name":"github.com/askeladdk/prattle","commit":"c36a35c2090e457f55147c070d2800033f30b4c6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/askeladdk/prattle/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/askeladdk/prattle/ci.yml/master?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/ci.yml:21","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T00:58:11.021Z","repository_id":65483885,"created_at":"2025-08-17T00:58:11.021Z","updated_at":"2025-08-17T00:58:11.021Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"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":["go","golang","lexer","lexer-parser","parser","parser-library","pratt-parser"],"created_at":"2024-07-30T20:01:54.130Z","updated_at":"2026-01-14T13:14:34.492Z","avatar_url":"https://github.com/askeladdk.png","language":"Go","readme":"# Prattle\n\n[![GoDoc](https://godoc.org/github.com/askeladdk/prattle?status.png)](https://godoc.org/github.com/askeladdk/prattle)\n[![Go Report Card](https://goreportcard.com/badge/github.com/askeladdk/prattle)](https://goreportcard.com/report/github.com/askeladdk/prattle)\n[![Coverage Status](https://coveralls.io/repos/github/askeladdk/prattle/badge.svg)](https://coveralls.io/github/askeladdk/prattle)\n\n## Overview\n\nPackage prattle implements a general purpose, unicode-aware lexical scanner and top down operator precedence parser suitable for parsing LL(1) grammars. The scanner and parser can be used independently from each other if desired.\n\n## Install\n\n```\ngo get -u github.com/askeladdk/prattle\n```\n\n## Quickstart\n\nUse `Scanner` to produce a sequence of `Token`s by scanning a source text using a `ScanFunc`. Use the `Expect*`, `Skip` and `Advance` methods to scan tokens.\n\n```go\n// Prepare the scanner.\nscanner := prattle.Scanner{\n\t// Scan scans the next token and returns its kind.\n\tScan: func(s *prattle.Scanner) (kind int) {\n\t\t// Skip any whitespace.\n\t\ts.ExpectAny(unicode.IsSpace)\n\t\ts.Skip()\n\n\t\t// Scan the next token.\n\t\tswitch {\n\t\tcase s.Done(): // Stop when the entire input has been consumed.\n\t\t\treturn 0\n\t\tcase s.Expect('+'): // Scan the addition operator.\n\t\t\treturn 1\n\t\tcase s.ExpectOne(unicode.IsDigit): // Scan a number consisting of one or more digits.\n\t\t\ts.ExpectAny(unicode.IsDigit)\n\t\t\treturn 2\n\t\t}\n\n\t\t// Invalid token.\n\t\ts.Advance()\n\t\treturn -1\n\t},\n}\n```\n\nUse `Parser` and `Driver` to associate tokens produced by `Scanner` with `ParseFunc`s. Define the `Driver` first.\n\n```go\n// Define the parsing Driver.\ntype driver struct {\n\tstack []int\n}\n\nfunc (d *driver) push(i int) {\n\td.stack = append(d.stack, i)\n}\n\nfunc (d *driver) pop() (i int) {\n\tn := len(d.stack)\n\ti, d.stack = d.stack[n-1], d.stack[:n-1]\n\treturn\n}\n\nfunc (d *driver) number(p *prattle.Parser, t prattle.Token) error {\n\tn, _ := strconv.Atoi(t.Text)\n\td.push(n)\n\treturn nil\n}\n\nfunc (d *driver) add(p *prattle.Parser, t prattle.Token) error {\n\t// Parse the right hand operator.\n\t_ = p.Parse(d.Precedence(t.Kind))\n\n\tright := d.pop()\n\tleft := d.pop()\n\tsum := left + right\n\tfmt.Printf(\"%d + %d = %d\\n\", left, right, sum)\n\td.push(sum)\n\treturn nil\n}\n\nfunc (d *driver) Prefix(kind int) prattle.ParseFunc {\n\treturn d.number\n}\n\nfunc (d *driver) Infix(kind int) prattle.ParseFunc {\n\treturn d.add\n}\n\nfunc (d *driver) Precedence(kind int) int {\n\treturn kind\n}\n\nfunc (d *driver) ParseError(t prattle.Token) error {\n\treturn fmt.Errorf(\"%s\", t)\n}\n\n// Prepare the parser.\nparser := prattle.Parser{\n\tDriver: \u0026driver{},\n}\n```\n\nFinally, `Init` the scanner and parser, and parse an expression.\n\n```go\nsource := \"1 + 23 + 456 + 7890\"\nscanner.InitWithString(source)\nparser.Init(\u0026scanner).Parse(0)\n\n// Output:\n// 1 + 23 = 24\n// 24 + 456 = 480\n// 480 + 7890 = 8370\n```\n\nSee the [calculator](_examples/calculator/main.go) for a complete example featuring prefix, postfix, infix, left, right and non-associative operators. Also read the [documentation on pkg.go.dev](https://pkg.go.dev/github.com/askeladdk/prattle).\n\n## License\n\nPackage prattle is released under the terms of the ISC license.\n","funding_links":[],"categories":["Text Processing","文本处理","Template Engines"],"sub_categories":["Parsers/Encoders/Decoders","解析 器/Encoders/Decoders"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskeladdk%2Fprattle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faskeladdk%2Fprattle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskeladdk%2Fprattle/lists"}