{"library":"solidity-parser-sc","title":"Solidity PEG.js Parser (Abandoned)","type":"library","description":"solidity-parser-sc is an unmaintained JavaScript parser for Solidity, built using PEG.js. Last published in June 2018 with version 0.4.12, it is based on an older version of the `consensys/solidity-parser` with specific grammar rules, notably adding support for Gnosis-style interpolation (e.g., `{{Variable}}`) to defer address assignments. Due to its age and lack of maintenance (last update over 8 years ago), it does not support modern Solidity syntax or language features, and its parsing behavior may not conform to the current official Solidity specification. There is no active release cadence, and it is considered abandoned. For any current or new projects requiring robust and up-to-date Solidity parsing, developers are strongly advised to use `@solidity-parser/parser` (latest version 0.20.2), which is an actively maintained ANTLR4-based parser that provides comprehensive support for the evolving Solidity language.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install solidity-parser-sc"],"cli":null},"imports":["const parser = require('solidity-parser-sc');\nconst ast = parser.parse(solidityCode);","const { ParserError } = require('solidity-parser-sc');\n// ... catch (e) { if (e instanceof ParserError) { ... } }"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/solidity-parser-sc","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const parser = require('solidity-parser-sc');\n\nconst solidityCode = `\npragma solidity ^0.4.0;\n\ncontract SimpleStorage {\n    uint256 public storedData;\n\n    event DataStored(uint256 indexed oldValue, uint256 indexed newValue);\n\n    function set(uint256 x) public {\n        emit DataStored(storedData, x);\n        storedData = x;\n    }\n\n    function get() public view returns (uint256) {\n        return storedData;\n    }\n}\n`;\n\ntry {\n    const ast = parser.parse(solidityCode, { tolerant: true, loc: true });\n    console.log('Successfully parsed Solidity code.');\n    // console.log(JSON.stringify(ast, null, 2)); // Uncomment to see the full AST\n\n    // Example: Find contract names\n    const contractDefinitions = ast.children.filter(node => node.type === 'ContractDefinition');\n    if (contractDefinitions.length > 0) {\n        console.log(`Found contract: ${contractDefinitions[0].name}`);\n    } else {\n        console.log('No contract definition found.');\n    }\n} catch (e) {\n    if (e instanceof parser.ParserError) {\n        console.error('Solidity Parsing Error:');\n        e.errors.forEach(err => console.error(` - ${err.message} (Line: ${err.line}, Column: ${err.column})`));\n    } else {\n        console.error('An unexpected error occurred:', e.message);\n    }\n}","lang":"javascript","description":"This quickstart demonstrates how to parse a simple Solidity contract using `solidity-parser-sc` and extract a contract definition from the resulting Abstract Syntax Tree (AST).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}