{"library":"solidity-parser-antlr","title":"Solidity ANTLR Parser (Legacy)","type":"library","description":"solidity-parser-antlr is an unmaintained JavaScript package designed to parse Solidity source code into an Abstract Syntax Tree (AST) using an ANTLR 4 grammar. Its last published version, 0.4.11, was released over seven years ago, rendering it incompatible with modern Solidity language features and breaking changes introduced in versions 0.5.x and newer. While it served as the foundational parser for many tools in the past, its lack of updates means it does not support current Solidity syntax, semantics, or security requirements. Developers needing an active Solidity parser should consider the `@solidity-parser/parser` package, which is a continuously maintained fork of this original repository. This package does ship with TypeScript type definitions, but its utility is severely limited by its outdated Solidity grammar support.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install solidity-parser-antlr"],"cli":null},"imports":["import parser from 'solidity-parser-antlr';","import parser from 'solidity-parser-antlr';\n// ... then use parser.ParserError","import type { SourceUnit, ContractDefinition } from 'solidity-parser-antlr';","const parser = require('solidity-parser-antlr');"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/federicobond/solidity-parser-antlr","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/solidity-parser-antlr","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import parser from 'solidity-parser-antlr';\n\nconst input = `\n    pragma solidity ^0.4.0;\n    contract SimpleStorage {\n        uint256 public data;\n        function set(uint256 _data) public {\n            data = _data;\n        }\n    }\n`;\n\ntry {\n    const ast = parser.parse(input, { loc: true, range: true });\n    console.log('Successfully parsed Solidity code. Root node type:', ast.type);\n    console.log('AST contains location and range info:', ast.loc, ast.range);\n\n    // Example of visiting a node (e.g., ContractDefinition)\n    parser.visit(ast, {\n        ContractDefinition: function(node) {\n            console.log('Found contract:', node.name);\n        },\n        FunctionDefinition: function(node) {\n            console.log('Found function:', node.name, 'visibility:', node.visibility);\n        }\n    });\n\n} catch (e) {\n    if (e instanceof parser.ParserError) {\n        console.error('Parsing error:', e.errors);\n    } else {\n        console.error('An unexpected error occurred:', e);\n    }\n}","lang":"javascript","description":"Demonstrates parsing a simple Solidity contract, enabling location and range options, and walking the AST using the visitor pattern to log contract and function definitions. It also includes error handling for parsing failures.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}