1 unstable release

0.1.1 May 22, 2022

#4 in #yul


Used in 2 crates (via yul)

MIT license

37KB
817 lines

Yul parser

Parses the Yul programming language. See the yul specification.

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.

Dependencies

~4MB
~46K SLoC