2 releases

0.1.1 May 22, 2022
0.1.0 May 21, 2022

#295 in #ethereum


Used in yulc

MIT license

53KB
1K SLoC

Rust 854 SLoC // 0.0% comments Python 177 SLoC // 0.3% comments

Yul language tools

crates.io docs.rs MIT License dependency status codecov CI

Parsing

The parser uses Logos for tokenization and Rowan for a parsing. The tokens (aka lexer) are defined in the [token.rs][./src/tokens.rs] and the syntax (aka grammar) is defined in [syntax.rs][./src/syntax.rs].

The architecture is based on that of rust-analyzer. In fact, rowan is part of the rust-analyzer project. I recommend reading their write-up to understand rowan. Another great introduction is this tutorial by Luna Razzaghipour.

Specifically the architecture is for lossless parsing with good error recovery. This means that the original source file can always be perfectly reconstructed from the parse tree, even if it has errors. Comments, whitespace and parse errors are explicitly included in the parse tree.

Building and testing

Format, lint, build and test everything (I recommend creating a shell alias for this):

cargo fmt &&\
cargo clippy --all-features --all-targets &&\
cargo test --workspace --all-features --doc -- --nocapture &&\
cargo test --workspace --all-features --all-targets -- --nocapture &&\
cargo doc --workspace --all-features --no-deps

Run benchmarks with the provided .cargo/config.toml alias

cargo criterion

Check documentation coverage

RUSTDOCFLAGS="-Z unstable-options --show-coverage"  cargo doc --workspace --all-features --no-deps

To do

Goals:

  • Yul to EVM compiler
  • Yul optimizer
  • Yul language server

Maybe:

  • EVM to yul compiler
  • Yul LLVM compiler
  • Static analysis tools like SMT checker
  • Link in solc frontend for Solidity compatibility.

lines of code GitHub contributors GitHub issues GitHub pull requests GitHub Repo stars crates.io

Dependencies

~4.5MB
~60K SLoC