-
Notifications
You must be signed in to change notification settings - Fork 36
Update README #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update README #1294
Changes from 4 commits
c427aa6
5885935
211aaad
115ebc5
e67a290
93e713f
9fbc51d
e6ea9bf
7047cf2
fc91670
7eb698b
0d39fd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,86 @@ | |||||
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. | ||||||
|
||||||
Slang analyzes Solidity source code and generates a rich concrete syntax tree (CST) that can be reasoned about. This is a departure from the classic approach of "black-box" compilers, which are handed the input and only their output can be observed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT of adding a short code example (10-20 lines) on how to use the public API? |
||||||
|
||||||
Slang is not a replacement for solc, the standard Solidity compiler. We do not plan at the moment to support emitting optimized EVM bytecode for use in production. It does not perform formal verification of contracts or Solidity logic in general. However, other tools that serve this purpose are intended to be built on top of it. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
[Read the User Guide here.](https://nomicfoundation.github.io/slang/latest/user-guide/01-introduction/) | ||||||
|
||||||
### Supporting Multiple Solidity Versions | ||||||
|
||||||
The Solidity programming language has evolved quite a bit since its inception. Some features were introduced, some changed, while some eventually became obsolete and were removed altogether. Developer tooling must be able to understand and consume older contracts that are still being used on the blockchain, written in older versions of Solidity. | ||||||
|
||||||
Because of that, Slang must be able to reason about different versions of Solidity; how the language grammar, name capture rules, and semantics have changed across different versions. One of our goals is to document differences as part of our [Solidity Grammar](https://nomicfoundation.github.io/slang/latest/solidity-grammar/). | ||||||
|
||||||
This is why, instead of having to download separate versions of Slang for each Solidity version, you can access the Slang language APIs by simply specifying the Solidity version that you want to work with. | ||||||
ggiraldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
[See our supported versions.](https://nomicfoundation.github.io/slang/latest/solidity-grammar/supported-versions/) | ||||||
|
||||||
## Installation | ||||||
|
||||||
You can install the [Slang NPM package](https://www.npmjs.com/package/@nomicfoundation/slang) with the following `npm` command: | ||||||
|
||||||
```sh | ||||||
npm install "@nomicfoundation/slang" | ||||||
``` | ||||||
|
||||||
Or if you are using `yarn`: | ||||||
|
||||||
```sh | ||||||
yarn add "@nomicfoundation/slang" | ||||||
``` | ||||||
|
||||||
Although Slang is written in Rust, we do not currently support the usage of Slang as a standalone crate. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest removing this for now, since we are not actively discouraging people from using Rust+giving feedback. It is just that the API is not finalized yet.
Suggested change
|
||||||
|
||||||
[Learn more about how to get started with Slang.](https://nomicfoundation.github.io/slang/latest/user-guide/04-getting-started/01-installation/) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest placing this link (and others like it) in a bullet to indent/for visibility.
Suggested change
|
||||||
|
||||||
## Contributing | ||||||
|
||||||
Please check our [contributors guide](https://github.com/NomicFoundation/slang/blob/main/CONTRIBUTING.md) to learn about how you can get started on Slang development. | ||||||
|
||||||
## Using Slang | ||||||
|
||||||
We have [several examples](https://nomicfoundation.github.io/slang/latest/user-guide/08-examples/) showing some of the ways that you can use Slang APIs to develop your own Solidity tooling. For more detailed information about Slang concepts please check [our user guide](https://nomicfoundation.github.io/slang/latest/user-guide/). | ||||||
|
||||||
## Core Concepts | ||||||
|
||||||
### Concrete Syntax Trees | ||||||
|
||||||
Slang is capable of parsing the source code into a Concrete Syntax Tree (CST), which is a tree structure representing the entire source code. It includes the contracts, functions, statements, and expressions within. It also includes things like comments, whitespace, and punctuation. This is sometimes called a "full-fidelity" CST, and it can be used to reconstruct the original source code when needed. | ||||||
|
||||||
### Parser | ||||||
|
||||||
The Parser API is used to produce a CST from Solidity source code. Each Parser object is initialized with a specific Solidity version. | ||||||
ggiraldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
With a Parser object, you can analyze any source text according to the grammar of that specific version. Providing an accurate language version is important as it affects the shape of the syntax tree and the set of possible errors. | ||||||
ggiraldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
[Learn more about the Parser API.](https://nomicfoundation.github.io/slang/latest/user-guide/04-getting-started/01-installation/) | ||||||
|
||||||
### Cursors | ||||||
|
||||||
For many code analysis tasks it is useful to traverse the CST and visit each node. Slang provides this functionality through cursors. Cursors provide an efficient pre-order traversal API for full-source CSTs and subtrees. | ||||||
ggiraldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
[Learn more about using cursors.](https://nomicfoundation.github.io/slang/latest/user-guide/05-syntax-trees/03-navigating-with-cursors/) | ||||||
|
||||||
### Queries | ||||||
|
||||||
The `Cursor` API is a low-level API that allows you to traverse the CST in a procedural manner. However, it is often more convenient to use the declarative `Query` API. Queries allow you to express your intent more concisely, and also allows you to reuse the same query in multiple places. Queries can largely replace the need for both internal (cursor), and external (visitor) iterator patterns. | ||||||
|
||||||
[Learn more about using queries.](https://nomicfoundation.github.io/slang/latest/user-guide/06-query-language/01-query-syntax/) | ||||||
|
||||||
ggiraldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
## Built with Slang | ||||||
|
||||||
We're proud to support other projects in the Solidity ecosystem with our developer tools. Here are some of the projects currently using Slang: | ||||||
|
||||||
- [Hardhat Solidity VSCode Extension](https://github.com/NomicFoundation/hardhat-vscode) | ||||||
- [prettier-plugin-solidity](https://github.com/prettier-solidity/prettier-plugin-solidity/tree/v2) | ||||||
- [openzeppelin-upgrades](https://github.com/OpenZeppelin/openzeppelin-upgrades) | ||||||
|
||||||
[Learn more about projects using Slang.](https://nomicfoundation.github.io/slang/latest/user-guide/02-powered-by-slang/) | ||||||
|
||||||
--- | ||||||
|
||||||
- [Slang NPM Package](https://www.npmjs.com/package/@nomicfoundation/slang/) | ||||||
- [Slang User Guide](https://nomicfoundation.github.io/slang/latest/user-guide/) | ||||||
- [Slang Telegram Group](https://t.me/+pxApdT-Ssn5hMTFh) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once it is approved, let's sync the contents with other
_PRODUCT_README_
markers...