{"id":13621249,"url":"https://github.com/federicobond/solidity-parser-antlr","last_synced_at":"2025-04-15T01:31:43.765Z","repository":{"id":46213520,"uuid":"94512608","full_name":"federicobond/solidity-parser-antlr","owner":"federicobond","description":"A Solidity parser for JS built on top of a robust ANTLR4 grammar","archived":true,"fork":false,"pushed_at":"2020-09-05T00:58:32.000Z","size":2095,"stargazers_count":156,"open_issues_count":35,"forks_count":57,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-14T19:18:07.583Z","etag":null,"topics":["antlr4","nodejs","parser","solidity"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/federicobond.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2017-06-16T06:28:11.000Z","updated_at":"2025-03-11T04:05:19.000Z","dependencies_parsed_at":"2022-07-19T12:59:28.655Z","dependency_job_id":null,"html_url":"https://github.com/federicobond/solidity-parser-antlr","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federicobond%2Fsolidity-parser-antlr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federicobond%2Fsolidity-parser-antlr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federicobond%2Fsolidity-parser-antlr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federicobond%2Fsolidity-parser-antlr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/federicobond","download_url":"https://codeload.github.com/federicobond/solidity-parser-antlr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989244,"owners_count":21194553,"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":["antlr4","nodejs","parser","solidity"],"created_at":"2024-08-01T21:01:03.960Z","updated_at":"2025-04-15T01:31:43.344Z","avatar_url":"https://github.com/federicobond.png","language":"JavaScript","funding_links":[],"categories":["Languages","Solidity","Tools"],"sub_categories":["Other dialects and variants"],"readme":"solidity-parser-antlr\n=====================\n\n[![npm](https://img.shields.io/npm/v/solidity-parser-antlr.svg)](https://www.npmjs.com/package/solidity-parser-antlr)\n[![Build Status](https://travis-ci.org/federicobond/solidity-parser-antlr.svg?branch=master)](https://travis-ci.org/federicobond/solidity-parser-antlr)\n\nA Solidity parser built on top of a robust [ANTLR4 grammar](https://github.com/solidityj/solidity-antlr4).\n\n### Usage\n\n```javascript\nimport parser from 'solidity-parser-antlr';\n\nvar input = `\n    contract test {\n        uint256 a;\n        function f() {}\n    }\n`\ntry {\n    parser.parse(input)\n} catch (e) {\n    if (e instanceof parser.ParserError) {\n        console.log(e.errors)\n    }\n}\n```\n\nThe `parse` method also accepts a second argument which lets you specify the\nfollowing options, in a style similar to the _esprima_ API:\n\n| Key      | Type    | Default | Description                                                                                                                                                                                          |\n|----------|---------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| tolerant | Boolean | false   | When set to `true` it will collect syntax errors and place them in a list under the key `errors` inside the root node of the returned AST. Otherwise, it will raise a `parser.ParserError`.          |\n| loc      | Boolean | false   | When set to `true`, it will add location information to each node, with start and stop keys that contain the corresponding line and column numbers. Column numbers start from 0, lines start from 1. |\n| range    | Boolean | false   | When set to `true`, it will add range information to each node, which consists of a two-element array with start and stop character indexes in the input.                                            |\n\n\n#### Example with location information\n\n```javascript\nparser.parse('contract test { uint a; }', { loc: true })\n\n// { type: 'SourceUnit',\n//   children:\n//    [ { type: 'ContractDefinition',\n//        name: 'test',\n//        baseContracts: [],\n//        subNodes: [Array],\n//        kind: 'contract',\n//        loc: [Object] } ],\n//   loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 24 } } }\n\n```\n\n#### Example using a visitor to walk over the AST\n\n```javascript\nvar ast = parser.parse('contract test { uint a; }')\n\n// output the path of each import found\nparser.visit(ast, {\n  ImportDirective: function(node) {\n    console.log(node.path)\n  }\n})\n```\n\n### Author\n\nFederico Bond ([@federicobond](https://github.com/federicobond))\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedericobond%2Fsolidity-parser-antlr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffedericobond%2Fsolidity-parser-antlr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedericobond%2Fsolidity-parser-antlr/lists"}