@nomicfoundation/slang
Solidity compiler tooling by @NomicFoundation
A modular set of compiler APIs empowering the next generation of Solidity code analysis and developer tooling. Written in Rust and distributed in multiple languages.
A modular set of compiler APIs empowering the next generation of Solidity code analysis and developer tooling. Written in Rust and distributed in multiple languages.
A modular set of compiler APIs empowering the next generation of Solidity code analysis and developer tooling. Written in Rust and distributed in multiple languages.
#1288 2090ab8
Thanks @OmarTawfik! - support Solidity 0.8.29
and Custom Storage Layouts:
ContractDefinition
nodes will no longer have an optional InheritanceSpecifier
child directly, but will hold a list of ContractSpecifier
childrenContractSpecifier
nodes have either InheritanceSpecifier
or StorageLayoutSpecifier
children#1265 2312260
Thanks @mjoerussell! - Add LanguageUtils::infer_language_versions(source_code) -> Version[]
API, which will analyze version pragmas inside a source file, and return a list of supported language versions that they allow. This can be used to select a valid language version to use with the rest of Slang APIs. Please see the Choosing a Solidity Version guide for more information.
da1f863
Thanks @ggiraldez! - Resolve arguments to inheritance specifiers and expressions in storage layout specifiers using the contract's parent scope.6de3e41
Thanks @OmarTawfik! - release Slang v1 🚀🚀🚀ed2cae9
Thanks @OmarTawfik! - rename ComparisonExpression
to InequalityExpression
#1203 a5c3b1a
Thanks @ggiraldez! - add separate contexts (ie. binding scopes) for Solidity and Yul built-ins
#1257 9f5d8f0
Thanks @OmarTawfik! - export assertUserFileLocation()
and assertBuiltInLocation()
utilities from the bindings
module
#1243 99d182f
Thanks @ggiraldez! - add definition.references()
API to find all references that resolve to a definition.
#1205 103b331
Thanks @mjoerussell! - Make Edge::label
a required field instead of being optional.
#1257 9f5d8f0
Thanks @OmarTawfik! - update user guides with new binding graph and compilation APIs
#1257 9f5d8f0
Thanks @OmarTawfik! - export assertNonterminalNode()
and assertTerminalNode()
utilities from the cst
module
#1246 aea2dd0
Thanks @OmarTawfik! - unreserve jump
and jumpi
yul keywords between 0.6.0
and 0.8.0
#1203 a5c3b1a
Thanks @ggiraldez! - enable address payable
from 0.5.0 and remove transfer
built-in from non-payable address
es
#1246 aea2dd0
Thanks @OmarTawfik! - make sure assembly flags are only enabled starting from 0.8.13
#1246 aea2dd0
Thanks @OmarTawfik! - enable yul's true
and false
keywords starting from 0.6.2
#1246 aea2dd0
Thanks @OmarTawfik! - make sure super
and this
keywords are unreserved before 0.8.0
.
#1156 3a82f06
Thanks @OmarTawfik! - add node.descendants()
and cursor.descendants()
APIs to allow iterating over all descendants of the current node in pre-order traversal.
#1156 3a82f06
Thanks @OmarTawfik! - fix node.children()
and parseOutput.errors()
return types
#1194 7a25d63
Thanks @OmarTawfik! - split parser/Parser.supportedVersions()
into a new utils/LanguageFacts
API, with allVersions()
, earliestVersion()
, and latestVersion()
methods.
#1194 7a25d63
Thanks @OmarTawfik! - expose the BingingGraph
API to allow querying definitions/references between source files.
#1156 3a82f06
Thanks @OmarTawfik! - add cursor.ancestors()
API to allow iterating over all ancestors of the current node, starting with the immediate parent, and moving upwards, ending with the root node.
#1156 3a82f06
Thanks @OmarTawfik! - add cursor.remainingNodes()
API to allow iterating over all the remaining nodes in the current tree, moving in pre-order traversal, until the tree is completed.
#1223 3e85a14
Thanks @OmarTawfik! - split Parser.parse()
API into parse_file_contents()
and parse_nonterminal()
.
#1194 7a25d63
Thanks @OmarTawfik! - add a CompilationBuilder
API to incrementally load and resolve source files and their imports.
#1223 3e85a14
Thanks @OmarTawfik! - rename Query.parse()
to Query.create()
, and provide exact TextRange
for any errors it returns.
#1172 6102886
Thanks @beta-ziliani! - Improved error recovery, where leading trivia are always parsed and included before an erroneous terminal.
#1223 3e85a14
Thanks @OmarTawfik! - add TerminalKindExtensions.is_identifier()
API to distinguish terminals like Solidity's Identifier
and Yul's YulIdentifier
.
#1187 6389361
Thanks @beta-ziliani! - Change ParseOutput
and File.tree
to return a NonTerminal
instead of a Node
.
#1134 cfc62f2
Thanks @OmarTawfik! - remove YulPathComponent
and just use YulIdentifier
instead.
#1138 44a706f
Thanks @OmarTawfik! - add ThisKeyword
and SuperKeyword
to the grammar, instead of parsing them as identifiers.
#1134 cfc62f2
Thanks @OmarTawfik! - unreserve AddressKeyword
, and let it be used for MemberAccessExpression
, StructMember
, etc...
#1154 7b9b478
Thanks @beta-ziliani! - Adding support for deprecated keywords jump
and jumpi
a97b27d
Thanks @OmarTawfik! - fix a bug where CST nodes are invalidated after using AST types#1126 e1d9748
Thanks @OmarTawfik! - fix wasm type exports for the npm package
#1122 bbb5323
Thanks @OmarTawfik! - support Solidity 0.8.28
release
bdb0ef3
Thanks @OmarTawfik! - fix a minor issue with npm package ESM imports#1120 25eef3e
Thanks @OmarTawfik! - migrate NAPI front-end to WASM and ESM
#1120 25eef3e
Thanks @OmarTawfik! - add TerminalKindExtensions.is_valid()
API to distinguish correctly-parsed and erroneous nodes
#1117 be7bb79
Thanks @OmarTawfik! - rename Language
API to Parser
, in preparation for introducing a multi-file compilation API.
#1116 c88f9b5
Thanks @OmarTawfik! - merge language
, parse_error
, parse_output
namespaces into the parser
namespace.
#1115 96df645
Thanks @OmarTawfik! - merge cursor
, kinds
, query
, and text_index
namespaces into the cst
namespace.
#1120 25eef3e
Thanks @OmarTawfik! - unify API methods on TerminalNode
and NonTerminalNode
, and add type assertions and guards to both types
#1120 25eef3e
Thanks @OmarTawfik! - expose edges and edge labels on CST nodes via Node.children()
method. This allows distinguishing between children of the same node based on their label/role in the parent, even if they have the same kind.
#1120 25eef3e
Thanks @OmarTawfik! - add TerminalNode.id
and Nonterminal.id
properties to get a numeric ID that can be used in indexing/comparison at runtime.
#1120 25eef3e
Thanks @OmarTawfik! - add TerminalKindExtensions.is_trivia()
API to distinguish between trivia nodes and other contentful nodes
#1096 15c437c
Thanks @OmarTawfik! - add support for Solidity 0.8.27
.
#1120 25eef3e
Thanks @OmarTawfik! - change Parser::new()
constructor to Parser::create()
static method.
#1097 e17af22
Thanks @OmarTawfik! - Fix the grammar of keywords (blobbasefee
, blobhash
, mcopy
, tload
, tstore
) added in 0.8.24
, as they were actually reserved in 0.8.25
.
43b389e
Thanks @OmarTawfik! - Move the Rust CLI into a separate slang_solidity_cli
crate.f749e53
Thanks @AntonyBlakey! - The grammar for VersionExpressionSet
has changed to more accurately model the allowed structure.#1030 7e467ce
Thanks @ggiraldez! - Tree Query Language: queries now ignore trivia nodes.
#1030 7e467ce
Thanks @ggiraldez! - Tree Query Language: remove the ellipsis query ...
operator making it implicit, add an adjacency operator .
.
#1015 369ee30
Thanks @OmarTawfik! - upgrade to rust 1.79.0
.
#1052 54c9067
Thanks @ggiraldez! - Tree Query Language: Compute row and column information for query parser errors.
#1048 c408caa
Thanks @OmarTawfik! - support Yul multiple variables declaration
#1047 2b32045
Thanks @OmarTawfik! - inline MemberAccess
enum into the parent MemberAccessExpression
#1062 6b05496
Thanks @OmarTawfik! - fix stack assignments operator =:
.
#1052 54c9067
Thanks @ggiraldez! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds.
#1037 2a74f91
Thanks @OmarTawfik! - fix ExponentiationExpression
associativity before 0.8.0
9ca51b4
Thanks @OmarTawfik! - expose QueryMatch
to public API#975 46b1dde
Thanks @OmarTawfik! - rename QueryResult
to QueryMatch
, and its bindings
to captures
.
#971 be943b7
Thanks @Xanewok! - Rename RuleKind
to NonterminalKind
, TokenKind
to TerminalKind
, and NodeLabel
to EdgeLabel
.
#963 a5593f9
Thanks @Xanewok! - Introduce a Diagnostic
API for compiler errors, warnings etc.
#996 cdc153d
Thanks @OmarTawfik! - add support for version 0.8.26
.
#983 ea31417
Thanks @ggiraldez! - Expose the language root non-terminal kind at Language.rootKind()
.
#965 61b6b06
Thanks @OmarTawfik! - refactor CST building and querying utilities into a separate metaslang_cst
crate.
#997 84ad856
Thanks @OmarTawfik! - Support stack assignments in Yul before 0.5.0
.
#948 ce88cb7
Thanks @Xanewok! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration
#945 e8f80d8
Thanks @Xanewok! - Support .address
built-in access in Yul paths
#753 b35c763
Thanks @AntonyBlakey! - Add tree query implementation as Query::parse
and Cursor::query
#755 8c260fc
Thanks @OmarTawfik! - support parsing NatSpec comments
#908 ab3688b
Thanks @Xanewok! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers
#887 dff1201
Thanks @Xanewok! - Add support for constant function modifier removed in 0.5.0
#885 a9bd8da
Thanks @Xanewok! - Flatten the trivia syntax nodes into sibling tokens
#908 ab3688b
Thanks @Xanewok! - Add RuleNode/TokenNode::toJSON() in the TypeScript API
#801 ecbba49
Thanks @OmarTawfik! - unreserve pragma keywords in all versions
#869 951b58d
Thanks @OmarTawfik! - support dots in yul identifiers from 0.5.8
till 0.7.0
#890 1ff8599
Thanks @Xanewok! - Mark override
as being a valid attribute only after 0.6.0
#800 d1827ff
Thanks @OmarTawfik! - support unicode characters in string literals up to 0.7.0
#797 86f36d7
Thanks @OmarTawfik! - fix source locations for unicode characters in error reports
#854 4b8970b
Thanks @OmarTawfik! - parse line breaks without newlines
#844 f62de9e
Thanks @OmarTawfik! - fix parsing empty /**/
comments
#799 303dda9
Thanks @OmarTawfik! - prevent parsing multiple literals under StringExpression
before 0.5.14
#847 6b6f260
Thanks @OmarTawfik! - prioritize parsing MultiLineComment
over MultiLineNatSpecComment
#796 59e1e53
Thanks @OmarTawfik! - add public
and internal
to UnnamedFunctionAttribute
till 0.5.0
#756 e839817
Thanks @OmarTawfik! - fix parsing payable
primary expressions
#851 67dfde8
Thanks @OmarTawfik! - fix selection order of prefix/postfix AST fields
#857 f677d5e
Thanks @OmarTawfik! - rename FieldName
to NodeLabel
#852 ca79eca
Thanks @OmarTawfik! - allow parsing ColonEqual
as two separate tokens before 0.5.5
#889 ce5050f
Thanks @Xanewok! - Support delete
as an expression rather than a statement
#923 bb30fc1
Thanks @Xanewok! - Support arbitrary ASCII escape sequences in string literals until 0.4.25
#887 dff1201
Thanks @Xanewok! - Support view and pure function modifiers only from 0.4.16
#800 d1827ff
Thanks @OmarTawfik! - rename AsciiStringLiteral
to StringLiteral
#838 ad98d1c
Thanks @OmarTawfik! - upgrade to rust 1.76.0
#849 5c42e0e
Thanks @OmarTawfik! - add override
and virtual
to ConstructorAttribute
#862 5e37ea0
Thanks @Xanewok! - allow call options as a post-fix expression
#786 0bfa6b7
Thanks @OmarTawfik! - support Yul label statements before 0.5.0
#839 2d698eb
Thanks @OmarTawfik! - support string literals in version pragmas
#891 70c9d7d
Thanks @Xanewok! - Fix parsing <NUMBER>.member
member access expression
#842 2069126
Thanks @OmarTawfik! - add private
to UnnamedFunctionAttribute
till 0.5.0
#840 7fb0d20
Thanks @OmarTawfik! - allow var
in TupleDeconstructionStatement
before 0.5.0
c289cbf7
Thanks @OmarTawfik! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18#710 2025b6cb
Thanks @Xanewok! - CST children nodes are now named
#723 b3dc6bcd
Thanks @Xanewok! - Properly parse unreserved keywords in an identifier position, i.e. from
, emit
, global
etc.
#728 662a672c
Thanks @Xanewok! - Remove Language#scan API; use the parser API instead
#719 1ad6bb37
Thanks @OmarTawfik! - introduce strong types for all Solidity non terminals in the TypeScript API.
#719 1ad6bb37
Thanks @OmarTawfik! - unify Rust/TypeScript node helpers: *_with_kind()
, *_with_kinds()
, *_is_kind()
), ...
#731 3deaea2e
Thanks @OmarTawfik! - add RuleNode.unparse()
to the TypeScript API
#699 ddfebfe9
Thanks @Xanewok! - Remove ProductionKind
in favor of RuleKind
#699 ddfebfe9
Thanks @Xanewok! - Allow parsing individual precedence expressions, like ShiftExpression
#665 4b5f8b46
Thanks @Xanewok! - Remove the CST Visitor API in favor of the Cursor API
#666 0434b68c
Thanks @Xanewok! - Add Node::unparse()
that allows to reconstruct the source code from the CST node
#675 daea4b7f
Thanks @OmarTawfik! - rename Cursor
's pathRuleNodes()
to ancestors()
in the NodeJS API.
#676 b496d361
Thanks @OmarTawfik! - Fix NAPI cursor
types and expose cursor.depth
.
#685 b5fca94a
Thanks @Xanewok! - bytes
is now properly recognized as a reserved word
#660 97028991
Thanks @Xanewok! - Drop List suffix from collection grammar rule names
#625 7bb650b
Thanks @Xanewok! - The CST Cursor now implements the Iterator trait as part of the Rust API
#647 b1dced3
Thanks @OmarTawfik! - Require specifying an initial offset when creating a CST cursor.
#648 2327bf5
Thanks @OmarTawfik! - Support Solidity v0.8.22.
#623 80114a8
Thanks @AntonyBlakey! - Correct the types in the TS api by adding the correct namespaces to type references
06cbbe8
Thanks @AntonyBlakey! - cursor
method is now exposed in Typescript API#595 1a258c4
Thanks @Xanewok! - Attempt error recovery when parsing incomplete lists
#564 e326a06
Thanks @AntonyBlakey! - Parsing operators with missing operands should no longer panic
#564 e326a06
Thanks @AntonyBlakey! - Inline parse rules are no longer exposed to the API.
#564 e326a06
Thanks @AntonyBlakey! - Scanners are no longer available as methods - use next_token instead
#564 e326a06
Thanks @AntonyBlakey! - Scanners are now grouped into contexts to deal with contextual scanning
#601 cbd2a79
Thanks @Xanewok! - Attempt parser error recovery between bracket delimiters
#599 4bbad48
Thanks @Xanewok! - Use correct versions for the revert
and global
keywords
#561 cb6a138
Thanks @Xanewok! - Add preliminary documentation for the solidity_language
Rust package
#603 be59a10
Thanks @OmarTawfik! - upgrade to rust 1.72.0
#540 0d04f95
Thanks @AntonyBlakey! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it.
#540 0d04f95
Thanks @AntonyBlakey! - Move Visitor et al to node:: namespace, which is where Cursor is.
#540 0d04f95
Thanks @AntonyBlakey! - Rename range
functions that return a TextRange to text_range
#543 7a34599
Thanks @OmarTawfik! - Move syntax::parser::ProductionKind
to syntax::nodes
namespace.
#540 0d04f95
Thanks @AntonyBlakey! - Add TokenNode.text to the TS API.
#540 0d04f95
Thanks @AntonyBlakey! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet.
#545 e73658a
Thanks @OmarTawfik! - render EBNF grammar on top of each ProductionKind
, RuleKind
, and TokenKind
.
#558 95bbc50
Thanks @OmarTawfik! - Correct versioning for SourceUnitMember
and ContractMember
children.
7e01250
Thanks @AntonyBlakey! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples.7ccca87
Thanks @AntonyBlakey! - Fix pratt parser behavior in the face of error correctione3450be4
Thanks @alcuadrado! - Make ESM named imports work in Node.js.#502 c383238
Thanks @AntonyBlakey! - Added error recovery i.e. a CST is always produced, even if there are errors. The erroneous/skipped text is in the CST as a TokenKind::SKIPPED
token.
#501 cb221fe
Thanks @OmarTawfik! - generate typescript string enums for CST kinds
#517 8bd5446
Thanks @OmarTawfik! - extract inlined and sub-expressions in language grammar
#518 b3b562b
Thanks @OmarTawfik! - fill in missing CST node names
#515 f24e873
Thanks @OmarTawfik! - switch over the NPM package to use CommonJS modules instead of ES modules.
#498 44f1ff7
Thanks @OmarTawfik! - flatten unnamed CST nodes into parent nodes
#502 c383238
Thanks @AntonyBlakey! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined length of their children's text.
#499 1582d60
Thanks @OmarTawfik! - preserve correct ranges on empty rule nodes
#500 73ddac9
Thanks @OmarTawfik! - inlining CST nodes that offer no additional syntactic information
#512 72dc3d3
Thanks @AntonyBlakey! - Expression productions now correctly wrap the recursive 'calls' in a rule node
#490 ea8e7e7
Thanks @OmarTawfik! - provide API to list supported language versions
#489 15c34a7
Thanks @OmarTawfik! - replace panics with JS exceptions in npm package
d7f171c
Thanks @DaniPopes! - introduce a cli
Cargo feature to compile the CLI binary#475 0cdfe86
Thanks @OmarTawfik! - match TypeScript and Rust API namespaces
#477 13c85a2
Thanks @OmarTawfik! - move expression operators into separate nodes
#481 0269f2b
Thanks @OmarTawfik! - fix grammar versions of individual keywords
#473 11d8cb0
Thanks @OmarTawfik! - upgrade to rust 1.69.0
#458 c0fc7e9
Thanks @AntonyBlakey! - Record both character and byte offsets for input positions
#463 0958d6b
Thanks @OmarTawfik! - use number
and getters in npm public API
#457 b7aae2a
Thanks @OmarTawfik! - minor grammar fixes
#453 0f2f9ab
Thanks @OmarTawfik! - move Rust's syntax::Parser::Language
API to root module
#454 85dec01
Thanks @OmarTawfik! - moving to Rust version 1.65.0
#456 c6d1041
Thanks @OmarTawfik! - expose ParseError
API
#451 78f633c
Thanks @OmarTawfik! - rename VisitorExitResponse::StepIn
to VisitorExitResponse::Continue
a858e2c
Thanks @AntonyBlakey! - Fix HexLiteral cannot have NumberUnit2a5b193
Thanks @OmarTawfik! - support user defined operators#416 fb977a5
Thanks @OmarTawfik! - fix primary expressions parser order
#434 beb3708
Thanks @OmarTawfik! - fix UnicodeStringLiteral versioning
#430 8b7492e
Thanks @OmarTawfik! - update READMEs with links to packages and user guides.
#425 9b49b3d
Thanks @OmarTawfik! - add user guides to rust crate and npm packages.
#432 1d1a8bb
Thanks @OmarTawfik! - fix FunctionCallOptions versioning
#427 1103916
Thanks @AntonyBlakey! - fix VariableDeclarationStatement versioning
9cac1a04
Thanks @OmarTawfik! - publish npm packages621b338
Thanks @OmarTawfik! - Initial release.