{"id":30180576,"url":"https://github.com/ternjs/acorn","last_synced_at":"2025-08-12T08:01:54.582Z","repository":{"id":4780691,"uuid":"5932749","full_name":"acornjs/acorn","owner":"acornjs","description":"A small, fast, JavaScript-based JavaScript parser","archived":false,"fork":false,"pushed_at":"2025-08-04T08:25:20.000Z","size":6430,"stargazers_count":11050,"open_issues_count":17,"forks_count":950,"subscribers_count":180,"default_branch":"master","last_synced_at":"2025-08-10T00:25:16.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"cinchcast/youtrack-slack-bot","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acornjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-09-24T10:05:00.000Z","updated_at":"2025-08-09T13:29:28.000Z","dependencies_parsed_at":"2023-11-11T08:29:36.657Z","dependency_job_id":"ac8800af-12df-4e6e-9c3a-6971008f9a6c","html_url":"https://github.com/acornjs/acorn","commit_stats":{"total_commits":1471,"total_committers":142,"mean_commits":"10.359154929577464","dds":0.7437117607070021,"last_synced_commit":"3c6a5a98e8c6dcefef391e6114cc7e64657979d3"},"previous_names":["marijnh/acorn","ternjs/acorn"],"tags_count":134,"template":false,"template_full_name":null,"purl":"pkg:github/acornjs/acorn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acornjs%2Facorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acornjs%2Facorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acornjs%2Facorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acornjs%2Facorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acornjs","download_url":"https://codeload.github.com/acornjs/acorn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acornjs%2Facorn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"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-08-12T02:00:09.011Z","response_time":80,"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":[],"created_at":"2025-08-12T08:01:22.550Z","updated_at":"2025-08-12T08:01:54.529Z","avatar_url":"https://github.com/acornjs.png","language":"JavaScript","funding_links":[],"categories":["Packages","JavaScript","包","AST","目录","Parsers","Number"],"sub_categories":["AST","Brunch Plugins","Parsers"],"readme":"# \u003cimg src=\"https://raw.githubusercontent.com/acornjs/acorn/refs/heads/master/logo.svg\" alt=\"Acorn Logo\" width=\"100\"\u003e Acorn\n\n[![Build Status](https://github.com/acornjs/acorn/workflows/ci/badge.svg)](https://github.com/acornjs/acorn/actions)\n[![NPM version](https://img.shields.io/npm/v/acorn.svg)](https://www.npmjs.com/package/acorn)\n[![CDNJS](https://img.shields.io/cdnjs/v/acorn.svg)](https://cdnjs.com/libraries/acorn)  \n\nA tiny, fast JavaScript parser, written completely in JavaScript.\n\n## Community\n\n\u003ca href=\"https://stand-with-ukraine.pp.ua/\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg\" width=\"800\"\u003e\u003c/a\u003e\n\nAcorn is open source software released under an\n[MIT license](https://github.com/acornjs/acorn/blob/master/acorn/LICENSE).\n\nYou are welcome to\n[report bugs](https://github.com/acornjs/acorn/issues) or create pull\nrequests on [github](https://github.com/acornjs/acorn).\n\n## Packages\n\nThis repository holds three packages:\n\n - [acorn](https://github.com/acornjs/acorn/tree/master/acorn/): The\n   main parser\n - [acorn-loose](https://github.com/acornjs/acorn/tree/master/acorn-loose/): The\n   error-tolerant parser\n - [acorn-walk](https://github.com/acornjs/acorn/tree/master/acorn-walk/): The\n   syntax tree walker\n\nTo build the content of the repository, run `npm install`.\n\n```sh\ngit clone https://github.com/acornjs/acorn.git\ncd acorn\nnpm install\n```\n\n## Plugin developments\n\nAcorn is designed to support plugins which can, within reasonable\nbounds, redefine the way the parser works. Plugins can add new token\ntypes and new tokenizer contexts (if necessary), and extend methods in\nthe parser object. This is not a clean, elegant API—using it requires\nan understanding of Acorn's internals, and plugins are likely to break\nwhenever those internals are significantly changed. But still, it is\n_possible_, in this way, to create parsers for JavaScript dialects\nwithout forking all of Acorn. And in principle it is even possible to\ncombine such plugins, so that if you have, for example, a plugin for\nparsing types and a plugin for parsing JSX-style XML literals, you\ncould load them both and parse code with both JSX tags and types.\n\nA plugin is a function from a parser class to an extended parser\nclass. Plugins can be used by simply applying them to the `Parser`\nclass (or a version of that already extended by another plugin). But\nbecause that gets a little awkward, syntactically, when you are using\nmultiple plugins, the static method `Parser.extend` can be called with\nany number of plugin values as arguments to create a `Parser` class\nextended by all those plugins. You'll usually want to create such an\nextended class only once, and then repeatedly call `parse` on it, to\navoid needlessly confusing the JavaScript engine's optimizer.\n\n```javascript\nconst {Parser} = require(\"acorn\")\n\nconst MyParser = Parser.extend(\n  require(\"acorn-jsx\")(),\n  require(\"acorn-bigint\")\n)\nconsole.log(MyParser.parse(\"// Some bigint + JSX code\"))\n```\n\nPlugins override methods in their new parser class to implement\nadditional functionality. It is recommended for a plugin package to\nexport its plugin function as its default value or, if it takes\nconfiguration parameters, to export a constructor function that\ncreates the plugin function.\n\nThis is what a trivial plugin, which adds a bit of code to the\n`readToken` method, might look like:\n\n```javascript\nmodule.exports = function noisyReadToken(Parser) {\n  return class extends Parser {\n    readToken(code) {\n      console.log(\"Reading a token!\")\n      super.readToken(code)\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fternjs%2Facorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fternjs%2Facorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fternjs%2Facorn/lists"}