{"id":29128219,"url":"https://github.com/mibk/hawk","last_synced_at":"2025-07-28T02:02:27.329Z","repository":{"id":76047781,"uuid":"47612047","full_name":"mibk/hawk","owner":"mibk","description":"an Awk clone","archived":false,"fork":false,"pushed_at":"2019-04-14T10:06:46.000Z","size":216,"stargazers_count":15,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-30T01:42:42.615Z","etag":null,"topics":["awk","go","golang","language","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Go","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/mibk.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-08T09:27:40.000Z","updated_at":"2021-02-04T02:47:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"2fef2390-5e18-484b-8d70-55143b1520e0","html_url":"https://github.com/mibk/hawk","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mibk/hawk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mibk%2Fhawk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mibk%2Fhawk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mibk%2Fhawk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mibk%2Fhawk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mibk","download_url":"https://codeload.github.com/mibk/hawk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mibk%2Fhawk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267451492,"owners_count":24089312,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"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":["awk","go","golang","language","programming-language"],"created_at":"2025-06-30T01:37:48.552Z","updated_at":"2025-07-28T02:02:27.274Z","avatar_url":"https://github.com/mibk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hawk\n\nThis project started as a reaction to Brian Kernighan's talk on [How to succeed in\nlanguage design without really trying](https://www.youtube.com/watch?v=Sg4U4r_AgJU).\nI've been always quite passionate about parsers, compilers, languages, but couldn't\nreally find a reason to actually build my own language. This talk motivated me so much\nthat I just had to do something. Because of lack of ideas I decided to make an Awk\nclone.\n\nIt was never meant to be a replacement for Awk. I'm doing it just for fun. Nevertheless\nthere might be the potential to make it actually useful. Right now, Hawk is unoptimized,\ndefinitely slower than the original Awk, and the design is in some ways probably quite\nnaive. Anyway, for anyone interested in making a new version of Awk, what would you add,\nleave out, simplify?\n\nThe language is basically Awk with a Go-like syntax. Some of the features are taken\nfrom PHP (especially arrays/maps).\n\n## Installation\n\n```\ngo get -u github.com/mibk/hawk\n```\n\n## Usage\n\nRunning `hawk -help` gives you an extended help message on how to use Hawk, although the\nbest documentation for the Hawk syntax is currently the `testdata` directory.\n\n```\nUsage: hawk 'program' [file ...]\n  or:  hawk -f progfile [file ...]\n\nHawk is an Awk clone. Program is a set of pattern {action} pairs. Hawk reads\nfrom all of the present files and for each line of each file executes all the\nprovided pairs. If no files are present, hawk reads from stdin.\n\nRun hawk -help for a detailed help message.\n\nFlags:\n  -F string\n        set the field separator, FS\n  -f file\n        read program from file\n  -help\n        display an extended help\n```\n\n## Examples of Hawk programs\n\n### Emulate wc\n\n```\n{ chars += len($0) + 1; words += NF }\nEND { printf \"%7d %7d %7d\\n\", NR, words, chars }\n```\n\n### Filter values of a list.\n\nHaving a list like this,\n\n```\n   92 ./value/undefined.go\n  260 ./value/value.go\n  140 ./value/array.go\n  136 ./compiler/internal/hawkc/semantic.go\n  319 ./compiler/internal/hawkc/expr.go\n  339 ./compiler/internal/hawkc/lex.go\n  211 ./compiler/internal/hawkc/syntax.go\n   71 ./compiler/internal/hawkc/builtin.go\n  277 ./compiler/internal/hawkc/stmt.go\n 1214 ./compiler/internal/hawkc/hawk.go\n   35 ./compiler/compiler.go\n  332 ./scan/scan.go\n   91 ./scan/scan_test.go\n   82 ./main.go\n  105 ./test/errcheck/short_test.go\n   47 ./test/run/run_test.go\n```\n\nthe whole program to print only the lines with the first field greater than\n200 is:\n\n```\n$1 \u003e 200\n```\n\n### Summarize a shopping list.\n\n```\nlunch    4.99\nlunch    3.99\nsnack    1\nlunch    2.49\nsnack    0.89\ncoffee   2.49\nlunch    3.20\n```\n\nYou can pipe any statement to an external program.\n\n```\n{ m[$1] += $2 }\nEND {\n    for k, v in m {\n        print v, k\n    } | \"sort -n\"\n}\n```\n\nThe output is:\n\n```\n1.89 snack\n2.49 coffee\n14.67 lunch\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmibk%2Fhawk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmibk%2Fhawk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmibk%2Fhawk/lists"}