{"library":"solparse","title":"Solparse","type":"library","description":"Solparse is a JavaScript library providing a PEG.js-based parser for the Solidity programming language. It is currently at version 2.2.8, with its last major release dating back over seven years, indicating a sporadic and maintenance-driven release cadence. The library was originally a fork of Consensys' `solidity-parser` and is primarily maintained to support `Ethlint`, a Solidity linter. Due to its specific maintenance focus, the developers do not guarantee backward compatibility or new feature support for general use. Users are strongly advised to pin `solparse` as a fixed dependency in production systems. Alternatives like `solparse-exp-jb` (a more recent fork supporting newer Solidity features) or `@solidity-parser/parser` (an ANTLR-based parser) may offer more up-to-date Solidity syntax support.","language":"javascript","status":"maintenance","last_verified":"Wed Apr 22","install":{"commands":["npm install solparse"],"cli":null},"imports":["import parse from 'solparse';","import parse from 'solparse';\n// ParserError is typically accessed via the default export if available\n// or caught in a try-catch block and checked with `e instanceof parse.ParserError`"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/duaraghav8/solparse","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/solparse","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import parse from 'solparse';\n\nconst solidityCode = `\npragma solidity ^0.8.0;\n\ncontract SimpleStorage {\n    uint256 public storedData;\n\n    function set(uint256 x) public {\n        storedData = x;\n    }\n\n    function get() public view returns (uint256) {\n        return storedData;\n    }\n}\n`;\n\ntry {\n    const ast = parse(solidityCode);\n    console.log('Successfully parsed Solidity code. AST:', JSON.stringify(ast, null, 2));\n    // You can now traverse and analyze the AST\n    console.log('Contract name:', ast.body[0].name);\n} catch (e) {\n    if (e instanceof Error && e.name === 'SyntaxError') {\n        console.error('Parsing error:', e.message);\n    } else {\n        console.error('An unexpected error occurred:', e);\n    }\n}","lang":"typescript","description":"Demonstrates how to parse a basic Solidity contract string using solparse and log the resulting Abstract Syntax Tree (AST), including basic error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}